/* ==========================================================
   MF Lash Studio · Fichas de clientes — estilos
   Marca: bordô #5B1626 e creme #F3ECE4 (logo), preto quente como apoio,
   verde e cinza apenas em detalhes (marcações e estados).
   Tipografia: Bodoni Moda (títulos, como o monograma) + Manrope (interface).
   ========================================================== */

@font-face {
  font-family: "Bodoni Moda";
  src: url("/fonts/bodoni-moda-latin.woff2") format("woff2");
  font-weight: 500 600;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Manrope";
  src: url("/fonts/manrope-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Marca */
  --wine: #5b1626;          /* bordô da logo: ações principais, faixas de marca */
  --wine-strong: #47101d;   /* hover/pressionado */
  --wine-bright: #8c2a3f;   /* foco e bordas ativas sobre fundo claro */
  --wine-tint: #f4e6e6;     /* hover suave */
  --wine-tint-2: #e8cfd2;   /* região preenchida, anel de foco do campo */
  --cream: #f3ece4;         /* creme da logo: fundo da página e texto sobre bordô */
  --cream-muted: #e2cfcb;   /* texto secundário sobre bordô */

  /* Preto quente (apoio) */
  --ink: #1c1316;
  --ink-soft: #2a1e22;
  --ink-line: #3d2f34;
  --ink-muted: #cdbeb8;     /* texto secundário sobre preto */

  /* Neutros quentes */
  --text: #261c1f;
  --text-2: #5a4d50;
  --text-3: #66595b;        /* metadados e dicas: ≥5,7:1 no creme */
  --line: #e3d9cf;          /* separadores */
  --line-strong: #8e7f75;   /* contorno de campos e controles (≥3:1) */
  --well: #f7f1ea;
  --bg: var(--cream);
  --surface: #fffcf8;

  /* Detalhes e estados */
  --green: #2f6b4f;
  --green-strong: #24533d;
  --green-tint: #e3efe8;
  --danger: #a3261e;
  --danger-tint: #f9e7e4;

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(40, 14, 22, .06), 0 1px 3px rgba(40, 14, 22, .07);
  --shadow: 0 6px 16px rgba(40, 14, 22, .09), 0 2px 4px rgba(40, 14, 22, .05);
  --shadow-lg: 0 24px 56px rgba(28, 19, 22, .28);

  --font: "Manrope", ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
  --font-display: "Bodoni Moda", "Bodoni 72", Didot, Georgia, serif;

  /* Papéis tipográficos */
  --fs-display: clamp(1.875rem, 1.4rem + 1.6vw, 2.5rem);
  --fs-title: 1.5rem;
  --fs-section: 1.125rem;
  --fs-label: .9375rem;
  --fs-body: 1rem;
  --fs-control: .9375rem;
  --fs-meta: .8125rem;
  --fs-overline: .6875rem;

  --tap: 44px;
  --gutter: 16px;
  --content: 1200px;

  accent-color: var(--wine);
  color-scheme: light;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--line-strong) transparent; scroll-padding: 72px 0 96px; }

body {
  margin: 0;
  overflow-x: hidden;
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  caret-color: var(--wine);
}

::selection { background: var(--wine); color: var(--cream); }

[hidden] { display: none !important; }

h1, h2, h3 { line-height: 1.2; margin: 0; color: var(--ink); }

a { color: var(--wine); text-underline-offset: .2em; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 3px solid var(--wine-bright);
  outline-offset: 2px;
}
/* Foco claro sobre superfícies escuras */
.topbar :focus-visible, .profile :focus-visible, .picker :focus-visible,
.date-band :focus-visible, .login-wrap > .login-mark :focus-visible { outline-color: var(--cream); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Números alinhados em datas, comprimentos e espessuras */
.chip, .tag, .chosen, .seg-label, .history-date, .client-meta, .input[type="date"], .profile-details, .eye-regions-ctrl {
  font-variant-numeric: tabular-nums lining-nums;
}

/* Assinatura "LASH STUDIO", como na logo */
.wordmark {
  font: 500 var(--fs-overline)/1 var(--font);
  text-transform: uppercase;
  letter-spacing: .36em;
  margin-right: -.36em; /* compensa o espaçamento final para centralizar opticamente */
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px var(--gutter);
  padding-top: max(8px, env(safe-area-inset-top));
  background: var(--wine);
  color: var(--cream);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--cream); min-width: 0; }
.brand img { flex: none; display: block; }
.brand-text { display: flex; flex-direction: column; gap: 5px; }
.brand-name { font: 500 1.1875rem/1 var(--font-display); letter-spacing: .01em; }
.brand-sub { color: var(--cream-muted); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-user { font-size: var(--fs-meta); color: var(--cream-muted); }
@media (max-width: 480px) { .topbar-user { display: none; } }

/* ---------- Layout ---------- */
.app { outline: none; }
.page {
  max-width: var(--content);
  margin: 0 auto;
  padding: 24px var(--gutter) 96px;
}
.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px;
  margin-bottom: 20px;
}
.page-title { font: 600 var(--fs-display)/1.1 var(--font-display); letter-spacing: -.005em; }
.page-subtitle { margin: 6px 0 0; color: var(--text-3); font-size: .9375rem; max-width: 65ch; }
.loading { padding: 64px var(--gutter); text-align: center; color: var(--text-3); }

.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: var(--tap); padding: 0 4px; margin-bottom: 6px;
  color: var(--wine); font-weight: 600; font-size: var(--fs-control); text-decoration: none;
}
.back-link:hover { text-decoration: underline; }
.back-link svg { width: 20px; height: 20px; flex: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px;
  border: 1.5px solid transparent; border-radius: var(--radius-pill);
  font-weight: 600; font-size: var(--fs-control); line-height: 1.2; letter-spacing: .005em;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: .875rem; }
.btn-primary { background: var(--wine); color: var(--cream); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--wine-strong); }
.btn-dark { background: var(--ink); color: var(--cream); }
.btn-dark:hover { background: var(--ink-soft); }
.btn-outline { background: var(--surface); border-color: var(--line-strong); color: var(--text); }
.btn-outline:hover { border-color: var(--wine); color: var(--wine); }
.btn-danger { background: var(--surface); border-color: #d9a39e; color: var(--danger); }
.btn-danger:hover { background: var(--danger-tint); border-color: var(--danger); }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: #82201a; }
.btn-ghost-dark { background: transparent; color: var(--cream); border-color: rgba(243, 236, 228, .38); }
.btn-ghost-dark:hover { border-color: var(--cream); background: rgba(243, 236, 228, .08); }
.picker .btn-primary { background: var(--wine); border-color: #7a2a3b; }
.picker .btn-primary:hover { background: #6d1b2e; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap); flex: none;
  border: 0; border-radius: 50%; background: transparent; color: var(--text-2);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { background: var(--wine-tint); color: var(--wine); }
.icon-btn.danger:hover { background: var(--danger-tint); color: var(--danger); }
.icon-btn:disabled { opacity: .4; cursor: default; background: transparent; }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label, .field .label { font-weight: 600; font-size: var(--fs-label); line-height: 1.3; color: var(--text); }
.hint { font: 500 var(--fs-meta)/1.4 var(--font); color: var(--text-3); letter-spacing: .005em; }
.input, .textarea {
  width: 100%; min-height: var(--tap); padding: 10px 14px;
  border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: var(--fs-body);
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); opacity: 1; }
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.input:hover, .textarea:hover { border-color: var(--text-2); }
.input:focus, .textarea:focus { outline: none; border-color: var(--wine); box-shadow: 0 0 0 3px var(--wine-tint-2); }
.field.has-error .input, .field.has-error .textarea { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: var(--fs-meta); font-weight: 600; }
.form-error {
  padding: 10px 14px; margin-bottom: 14px; border-radius: var(--radius-sm);
  background: var(--danger-tint); color: var(--danger); font-weight: 600; font-size: .9375rem;
}
.form-grid { display: grid; gap: 0 16px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .form-grid.two { grid-template-columns: 1fr 1fr; } }

/* Título de um item do formulário (Modelo, Formato do fio, Observações) — mesmo papel das seções */
.field .field-title, .field-title { font: 700 var(--fs-section)/1.3 var(--font); color: var(--ink); letter-spacing: -.005em; }
.field-title .hint { margin-left: 4px; }
.help-text { margin: 0 0 12px; color: var(--text-3); font-size: .875rem; max-width: 65ch; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 28px; padding: 32px var(--gutter);
  background: var(--wine);
  color: var(--cream);
}
.login-mark { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.login-mark img { width: 132px; height: 132px; display: block; }
.login-mark .wordmark { font-size: .8125rem; color: var(--cream); }
.login-card {
  width: 100%; max-width: 400px; padding: 28px 26px 30px;
  background: var(--surface); color: var(--text);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
.login-card h1 { font: 500 var(--fs-title)/1.2 var(--font-display); margin-bottom: 4px; }
.login-card .login-sub { margin: 0 0 20px; color: var(--text-3); font-size: .875rem; }
.login-card .btn { width: 100%; margin-top: 6px; }

/* ---------- Clients toolbar ---------- */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px;
}
.search {
  position: relative; flex: 1 1 260px;
}
.search svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--text-3); pointer-events: none;
}
.search .input { padding-left: 42px; border-radius: var(--radius-pill); }

/* Alfabeto: faixa horizontal no celular, abas verticais (como as divisórias de um caderno) no computador */
.clients-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.clients-layout > * { min-width: 0; }
.alphabet {
  display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 10px;
  scrollbar-width: thin; -webkit-overflow-scrolling: touch;
}
.alpha-btn {
  flex: none; min-width: 40px; height: 40px; padding: 0 10px;
  border: 1.5px solid var(--line); border-radius: var(--radius-pill);
  background: var(--surface); color: var(--text);
  font-weight: 600; font-size: var(--fs-control); cursor: pointer;
}
.alpha-btn:hover:not(:disabled) { border-color: var(--wine); color: var(--wine); }
.alpha-btn[aria-pressed="true"] { background: var(--wine); border-color: var(--wine); color: var(--cream); }
.alpha-btn:disabled { color: #b3a69c; background: transparent; cursor: default; }

/* Trilho vertical só com mouse: no toque (tablet) as letras ficam grandes, em faixa */
@media (min-width: 960px) and (pointer: fine) {
  .clients-layout { grid-template-columns: minmax(0, 1fr) 56px; align-items: start; }
  .clients-layout.no-alpha { grid-template-columns: minmax(0, 1fr); }
  .alphabet {
    position: sticky; top: 76px; order: 2; max-height: calc(100vh - 92px); overflow-y: auto;
    flex-direction: column; overflow: visible; padding: 8px 6px;
    background: var(--ink); border-radius: var(--radius);
    gap: 2px;
  }
  .alpha-btn {
    min-width: 0; width: 100%; height: 23px; padding: 0;
    border: 0; border-radius: 8px; background: transparent; color: var(--cream); font-size: .75rem;
  }
  .alpha-btn:hover:not(:disabled) { background: var(--ink-soft); color: #fff; }
  .alpha-btn[aria-pressed="true"] { background: var(--wine); color: var(--cream); }
  .alpha-btn:disabled { color: #7d6e72; background: transparent; }
  .alpha-btn.all { height: 34px; font-size: var(--fs-overline); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px; }
}

/* ---------- Client cards ---------- */
.client-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr));
}
.client-card {
  display: flex; align-items: center; gap: 6px;
  min-height: 72px; padding: 6px 6px 6px 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.client-card:hover { border-color: var(--wine-tint-2); box-shadow: var(--shadow); }
.client-open {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px;
  padding: 6px; border: 0; background: transparent; text-align: left; cursor: pointer;
  border-radius: var(--radius-pill); text-decoration: none; color: inherit;
}
.avatar {
  flex: none; width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--wine); color: var(--cream);
  font: 500 1.0625rem/1 var(--font-display); letter-spacing: .02em;
}
.client-info { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.client-name { font-weight: 600; font-size: 1rem; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-meta { font-size: var(--fs-meta); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-actions { display: flex; flex: none; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px; border-radius: var(--radius-pill);
  font-size: var(--fs-overline); font-weight: 600; letter-spacing: .04em; line-height: 1.6;
}
.badge-demo { background: var(--well); color: var(--text-2); border: 1px dashed var(--line-strong); }
.badge-green { background: var(--green-tint); color: var(--green-strong); }
.list-summary { color: var(--text-3); font-size: .875rem; margin: 0 0 10px; }

/* ---------- Empty state ---------- */
.empty {
  text-align: center; padding: 48px 20px;
  background: var(--surface); border: 1.5px dashed var(--line-strong); border-radius: var(--radius-lg);
}
.empty-mark { display: block; width: 96px; height: 96px; margin: 0 auto 18px; border-radius: 24px; box-shadow: var(--shadow); }
.empty h2 { font: 500 var(--fs-title)/1.2 var(--font-display); margin-bottom: 8px; }
.empty p { color: var(--text-3); margin: 0 auto 18px; max-width: 420px; }
.empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

/* ---------- Cards / panels ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: 20px;
}
.panel + .panel { margin-top: 16px; }
.panel-title {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.panel-title h2 { font: 500 var(--fs-title)/1.2 var(--font-display); }

/* ---------- Client profile ---------- */
.profile {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between;
  padding: 22px; margin-bottom: 16px;
  background: var(--ink); color: var(--cream); border-radius: var(--radius-lg);
}
.profile .avatar { width: 64px; height: 64px; font-size: 1.5rem; background: var(--wine); }
.profile-main { display: flex; align-items: center; gap: 16px; min-width: 0; }
.profile h1 { color: var(--cream); font: 600 var(--fs-display)/1.1 var(--font-display); overflow-wrap: anywhere; }
.profile-details { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin-top: 8px; color: var(--ink-muted); font-size: .875rem; }
.profile .badge-demo { background: transparent; color: var(--ink-muted); border-color: #6f6064; }
.profile-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.profile-notes { margin: 4px 0 0; flex-basis: 100%; color: var(--ink-muted); font-size: .9375rem; white-space: pre-wrap; max-width: 65ch; }

/* ---------- History ---------- */
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.history-item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center;
  padding: 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface);
}
.history-item:hover { border-color: var(--wine-tint-2); }
.history-date {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  width: 64px; min-height: 68px; padding: 6px 0; border-radius: 14px;
  background: var(--wine); color: var(--cream); line-height: 1; text-decoration: none; flex: none;
}
.history-date:hover { background: var(--wine-strong); }
.history-date .d { font: 700 1.5rem/1 var(--font); }
.history-date .m { font-size: var(--fs-overline); font-weight: 600; text-transform: uppercase; letter-spacing: .12em; }
.history-date .y { font-size: .75rem; color: var(--cream-muted); }
.history-body { min-width: 0; }
.history-title { font-weight: 600; color: var(--ink); margin-bottom: 8px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-flex; gap: 4px; align-items: baseline;
  padding: 3px 10px; border-radius: var(--radius-pill);
  background: var(--well); border: 1px solid var(--line); color: var(--text-2); font-size: var(--fs-meta);
}
.tag b { color: var(--ink); font-weight: 600; }
.history-eyes { display: flex; gap: 6px; margin-top: 10px; }
.history-eyes svg { width: 150px; height: auto; }
.history-actions { display: flex; flex-direction: column; gap: 4px; }
@media (max-width: 560px) {
  .history-item { grid-template-columns: auto 1fr; }
  .history-actions { grid-column: 1 / -1; flex-direction: row; justify-content: flex-end; border-top: 1px solid var(--line); padding-top: 8px; }
  .history-eyes svg { width: 48%; }
}

/* ---------- Procedure form ---------- */
.date-band {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; margin-bottom: 16px;
  background: var(--wine); color: var(--cream); border-radius: var(--radius-lg);
}
.date-band label { font: 500 var(--fs-title)/1.2 var(--font-display); }
.date-band .input { max-width: 220px; border-color: transparent; font-weight: 600; font-size: 1.0625rem; }
.date-band .field-error { color: #ffd9d6; flex-basis: 100%; }
.date-band.has-error .input { border-color: #ffb4ab; box-shadow: 0 0 0 3px rgba(255, 180, 171, .35); }

.section { padding: 20px 0; border-top: 1px solid var(--line); }
.section:first-child { border-top: 0; padding-top: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head h3 { font: 700 var(--fs-section)/1.3 var(--font); letter-spacing: -.005em; }
.section-head h3 .hint { margin-left: 4px; }
.section-head .chosen { font-size: var(--fs-meta); color: var(--text-3); }
.section-head .chosen b { color: var(--wine); font-weight: 700; }
/* O mapeamento é o coração da ficha: título no papel de destaque */
.section-feature .section-head h3 { font: 500 var(--fs-title)/1.2 var(--font-display); letter-spacing: 0; }
.form-cols { display: grid; grid-template-columns: 1fr; gap: 0 28px; }
@media (min-width: 820px) { .form-cols { grid-template-columns: 1fr 1fr; } }

/* Chips de seleção — o valor escolhido fica em bordô, com a marcação verde */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; border: 0; }
.chip {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); min-width: var(--tap); padding: 0 16px;
  border: 1.5px solid var(--line-strong); border-radius: var(--radius-pill);
  background: var(--surface); color: var(--text);
  font-weight: 600; font-size: var(--fs-control); line-height: 1.2; cursor: pointer; user-select: none;
  transition: background-color .12s, border-color .12s, color .12s;
  -webkit-tap-highlight-color: transparent;
}
.chip:hover { border-color: var(--wine); color: var(--wine); }
.chip[aria-pressed="true"], .chip[aria-checked="true"] {
  background: var(--wine); border-color: var(--wine); color: var(--cream);
  box-shadow: 0 2px 8px rgba(91, 22, 38, .28);
}
.chip .check {
  display: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--green); color: #fff; align-items: center; justify-content: center;
  box-shadow: 0 0 0 1.5px var(--cream);
}
.chip .check svg { width: 12px; height: 12px; }
.chip[aria-pressed="true"] .check, .chip[aria-checked="true"] .check { display: inline-flex; }
.chips.compact .chip { min-width: 48px; padding: 0 10px; }

/* Comprimento: valores que vêm do mapeamento dos olhos (marcados automaticamente) */
.chip .map-mark { display: none; width: 18px; height: 18px; align-items: center; justify-content: center; }
.chip .map-mark svg, .legend-map svg { width: 15px; height: 15px; }
.chip.from-map .check { display: none; }
.chip.from-map .map-mark { display: inline-flex; }
.chip.from-map[aria-pressed="true"] { cursor: default; box-shadow: none; }
.legend-map { display: inline-flex; vertical-align: -3px; color: var(--wine); }
.section-help { margin: -4px 0 12px; }

/* ---------- Mapeamento dos olhos ---------- */
.eyes {
  display: grid; grid-template-columns: 1fr; gap: 16px;
}
@media (min-width: 720px) { .eyes { grid-template-columns: 1fr 1fr; } }
.eye-card {
  padding: 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--well), var(--surface));
}
.eye-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.eye-title { font-weight: 700; font-size: var(--fs-label); color: var(--ink); display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.eye-side {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--ink); color: var(--cream); font-size: .8125rem; font-weight: 700;
}
.eye-regions-ctrl { display: flex; align-items: center; gap: 2px; font-size: var(--fs-meta); color: var(--text-3); white-space: nowrap; }
.eye-regions-ctrl .icon-btn { width: 36px; height: 36px; }
.eye-svg { width: 100%; height: auto; display: block; touch-action: manipulation; }
.eye-corners { display: flex; justify-content: space-between; font-size: .75rem; color: var(--text-3); padding: 0 4px; }

.seg { cursor: pointer; }
.seg-shape { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1.5; transition: fill .12s; }
.seg:hover .seg-shape { fill: var(--wine-tint); }
.seg.filled .seg-shape { fill: var(--wine-tint-2); stroke: var(--wine); }
.seg.active .seg-shape { fill: var(--wine); stroke: var(--wine-strong); }
.seg:focus { outline: none; }
.seg:focus-visible .seg-shape { stroke: var(--green); stroke-width: 3.5; }
/* O tamanho vem do atributo font-size do SVG (editor x miniatura) */
.seg-label { font-family: var(--font); font-weight: 700; fill: var(--ink); pointer-events: none; text-anchor: middle; dominant-baseline: central; }
.seg.active .seg-label { fill: var(--cream); }
.seg-empty { fill: #9c8f86; font-weight: 500; }
.eye-white { fill: #fff; stroke: var(--ink); stroke-width: 2.5; }
.eye-lid { fill: none; stroke: var(--ink); stroke-width: 3.5; stroke-linecap: round; }
.eye-iris { fill: #4a3a3e; }
.eye-pupil { fill: var(--ink); }
.eye-shine { fill: #fff; }
.lash { stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; pointer-events: none; }

.picker {
  margin-top: 14px; padding: 14px 16px 16px; border-radius: var(--radius);
  background: var(--ink); color: var(--cream);
}
.picker-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.picker-heading { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.picker-title { font-size: .9375rem; font-weight: 700; }
.picker-sub { font-size: var(--fs-meta); color: var(--ink-muted); }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; }
.picker-grid .chip { min-width: 0; padding: 0; min-height: 48px; font-size: 1rem; }
.picker-foot { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.picker .chip { background: var(--ink-soft); border-color: var(--ink-line); color: var(--cream); }
.picker .chip:hover { border-color: var(--cream-muted); color: #fff; }
.picker .chip[aria-pressed="true"] { background: var(--wine); border-color: var(--cream-muted); color: var(--cream); }
.picker .btn:disabled { opacity: .45; }
.picker-hint { margin: 10px 0 0; font-size: var(--fs-meta); color: var(--ink-muted); }
.eyes-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* Barra de ações fixa */
.action-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  display: flex; justify-content: center;
  padding: 10px var(--gutter); padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: rgba(255, 252, 248, .95); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.action-bar-inner {
  width: 100%; max-width: var(--content);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
@media (max-width: 520px) {
  .action-bar .btn { padding: 0 14px; }
  .action-bar .btn-label-optional { display: none; }
  .dirty-flag { display: none; }
}
.action-bar-right { display: flex; gap: 8px; margin-left: auto; }
.dirty-flag { font-size: var(--fs-meta); color: var(--wine); font-weight: 600; }

/* ---------- Dialog ---------- */
.dialog {
  width: min(520px, calc(100vw - 2 * var(--gutter)));
  max-height: calc(100vh - 32px);
  padding: 0; border: 0; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); background: var(--surface); color: var(--text);
}
.dialog::backdrop { background: rgba(28, 19, 22, .62); }
.dialog-head { padding: 22px 22px 0; }
.dialog-head h2 { font: 500 var(--fs-title)/1.2 var(--font-display); }
.dialog-body { padding: 16px 22px; }
.dialog-body p { margin: 0 0 8px; }
.dialog-detail { color: var(--text-3); font-size: .875rem; }
.dialog-foot {
  display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap;
  padding: 14px 22px 20px; border-top: 1px solid var(--line);
}
@media (max-width: 480px) {
  .dialog-foot .btn { flex: 1; }
}

/* ---------- Toast ---------- */
.toast-region {
  position: fixed; z-index: 50; left: 50%; transform: translateX(-50%);
  bottom: 84px; display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: calc(100% - 2 * var(--gutter)); max-width: 420px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px 12px 12px; border-radius: var(--radius-pill); box-shadow: var(--shadow-lg);
  background: var(--ink); color: var(--cream); font-weight: 500; font-size: .9375rem;
  animation: toast-in .2s ease-out;
}
.toast-icon {
  display: inline-grid; place-items: center; flex: none;
  width: 24px; height: 24px; border-radius: 50%; background: var(--green); color: #fff;
}
.toast-icon svg { width: 14px; height: 14px; }
.toast.error .toast-icon { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ==========================================================
   Celular e tablet (uso principal da plataforma)
   ========================================================== */

/* Botões e campos não disparam zoom duplo nem atraso de toque */
button, a, .chip, .seg, input, textarea, label { touch-action: manipulation; }

/* Toque: alvos de no mínimo 44px e retorno visual ao pressionar */
@media (pointer: coarse) {
  .btn-sm { min-height: var(--tap); padding: 0 16px; }
  .eye-regions-ctrl .icon-btn { width: var(--tap); height: var(--tap); }
  .alpha-btn { min-width: var(--tap); height: var(--tap); }
  .chip:active, .btn:active, .icon-btn:active, .alpha-btn:active { transform: scale(.96); }
  .client-open:active, .history-date:active { opacity: .75; }
}

/* Sem mouse, os estados de "passar por cima" não podem ficar grudados após o toque */
@media (hover: none) {
  .chip:hover { border-color: var(--line-strong); color: var(--text); }
  .chip[aria-pressed="true"]:hover { border-color: var(--wine); color: var(--cream); }
  .picker .chip:hover { border-color: var(--ink-line); color: var(--cream); }
  .picker .chip[aria-pressed="true"]:hover { border-color: var(--cream-muted); }
  .alpha-btn:hover:not(:disabled) { border-color: var(--line); color: var(--text); }
  .alpha-btn[aria-pressed="true"]:hover { border-color: var(--wine); color: var(--cream); }
  .btn-outline:hover { border-color: var(--line-strong); color: var(--text); }
  .icon-btn:hover, .icon-btn.danger:hover { background: transparent; color: var(--text-2); }
  .client-card:hover { border-color: var(--line); box-shadow: var(--shadow-sm); }
  .history-item:hover { border-color: var(--line); }
  .seg:hover .seg-shape { fill: var(--surface); }
  .seg.filled:hover .seg-shape { fill: var(--wine-tint-2); }
  .seg.active:hover .seg-shape { fill: var(--wine); }
}

/* Tablet com toque: letras do alfabeto em faixa larga, todas visíveis */
@media (min-width: 600px) and (pointer: coarse) {
  .alphabet { flex-wrap: wrap; overflow: visible; padding-bottom: 4px; }
}

/* Seletor de comprimento como gaveta no rodapé (toque ou telas até tablet) */
@media (max-width: 1023px), (pointer: coarse) {
  .picker {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    margin: 0; max-height: 72vh; overflow-y: auto; overscroll-behavior: contain;
    padding: 10px max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -12px 32px rgba(28, 19, 22, .32);
    animation: sheet-in .22s cubic-bezier(.2, .8, .2, 1);
  }
  .picker::before {
    content: ""; display: block; width: 40px; height: 4px; margin: 0 auto 10px;
    border-radius: 2px; background: var(--ink-line);
  }
  .picker-hint { display: none; }
  /* Com a gaveta aberta, a barra de salvar dá lugar a ela e a página ganha espaço para rolar */
  body.picker-open .action-bar { visibility: hidden; }
  body.picker-open .page { padding-bottom: calc(var(--sheet-h, 320px) + 24px); }
}
@media (max-width: 1023px) and (min-width: 600px), (pointer: coarse) and (min-width: 600px) {
  .picker > * { max-width: 760px; margin-left: auto; margin-right: auto; }
  .picker-grid { grid-template-columns: repeat(8, 1fr); }
}
@media (max-width: 599px) {
  .picker-grid { grid-template-columns: repeat(5, 1fr); }
}
/* Barra de carregamento ao trocar de tela */
body.is-loading::after {
  content: ""; position: fixed; z-index: 60; top: 0; left: 0; right: 0; height: 3px;
  background: var(--cream); box-shadow: 0 0 0 1px rgba(91, 22, 38, .25);
  transform-origin: left; transform: scaleX(0);
  animation: loading-grow 6s cubic-bezier(.1, .75, .15, 1) forwards;
}
body.is-loading .app { cursor: progress; }
@keyframes loading-grow { to { transform: scaleX(.92); } }

@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }

/* Celular */
@media (max-width: 599px) {
  .page { padding-top: 16px; }
  .page-head { margin-bottom: 14px; }
  .page-subtitle { display: none; }

  /* Ação principal flutuante, ao alcance do polegar */
  .page-action {
    position: fixed; z-index: 16;
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    min-height: 56px; padding: 0 22px; font-size: 1rem;
    box-shadow: 0 10px 24px rgba(91, 22, 38, .35), 0 2px 6px rgba(28, 19, 22, .2);
  }

  /* Nome da cliente pode ocupar duas linhas em vez de ser cortado */
  .client-name {
    white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    line-height: 1.25;
  }
  .client-card { border-radius: 22px; }

  .panel { padding: 16px; border-radius: 18px; }
  .profile { padding: 18px; gap: 14px; }
  .profile .avatar { width: 52px; height: 52px; font-size: 1.25rem; }
  .profile-actions { width: 100%; }
  .profile-actions .btn { flex: 1; }

  /* Histórico: dados em grade compacta (rótulo em cima, valor embaixo) */
  .history-item { padding: 12px; gap: 12px; }
  .history-date { width: 56px; min-height: 60px; }
  .history-date .d { font-size: 1.3rem; }
  .history-title { font-size: .9375rem; }
  .tags { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
  .tag { display: flex; flex-direction: column; gap: 1px; padding: 0; background: none; border: 0; }
  .tag-label { font-size: var(--fs-overline); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
  .tag b { font-size: .875rem; }

  /* Formulário do procedimento */
  .date-band { flex-direction: column; align-items: stretch; gap: 10px; padding: 14px 16px; }
  .date-band label { font-size: 1.25rem; }
  .date-band .input { max-width: none; }
  .section { padding: 16px 0; }
  .section-head { flex-direction: column; align-items: flex-start; gap: 2px; }
  .chips { gap: 6px; }
  .eye-card { padding: 10px 10px 8px; }
  .eyes-tools .btn { flex: 1 1 100%; }
  .help-text { font-size: .8125rem; }

  /* Janelas abrem de baixo, como no celular */
  .dialog {
    width: 100%; max-width: 100%; margin: auto 0 0;
    border-radius: 22px 22px 0 0; max-height: 92vh;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .dialog[open] { animation: sheet-in .22s cubic-bezier(.2, .8, .2, 1); }
  .dialog-foot { flex-direction: column-reverse; }
  .dialog-foot .btn { width: 100%; min-height: 48px; }

  .toast-region { bottom: calc(96px + env(safe-area-inset-bottom)); }
}

/* Tags no computador/tablet: "Rótulo: valor" */
@media (min-width: 600px) {
  .tag-label::after { content: ":"; }
}

/* Celular deitado: menos altura, gaveta mais compacta */
@media (max-height: 500px) and (orientation: landscape) {
  .topbar { position: static; }
  .picker { max-height: 88vh; }
  .picker-grid { grid-template-columns: repeat(8, 1fr); }
  .picker-grid .chip { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

@media print {
  .topbar, .action-bar, .alphabet, .client-actions, .history-actions, .profile-actions { display: none !important; }
  body { background: #fff; }
}
