/* eSaúde — hostmind-saude
   Design system v0.1. CSS puro, sem dependências.
   Tema: data-theme="light" | "dark" em qualquer ancestral; sem atributo, segue o sistema. */

:root, [data-theme="light"] {
  --bg: #F3F5F4;          /* bancada */
  --surface: #FFFFFF;
  --surface-2: #E9EDEB;
  --line: #D3D9D6;
  --line-strong: #858F8A;
  --ink: #17201D;
  --ink-2: #45524D;
  --ink-3: #5E6B66;
  --on-ink: #FFFFFF;
  --accent: #C4410F;      /* sinal: exige atenção agora */
  --accent-weak: #FBE6DC;
  --accent-ink: #9A300A;
  --on-accent: #FFFFFF;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #121A18;
  --surface: #18221F;
  --surface-2: #212D29;
  --line: #2E3B37;
  --line-strong: #66756F;
  --ink: #E6ECE9;
  --ink-2: #B3BFBA;
  --ink-3: #8C9994;
  --on-ink: #121A18;
  --accent: #FF7A45;
  --accent-weak: #3A1E13;
  --accent-ink: #FFB08F;
  --on-accent: #1A0A03;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121A18; --surface: #18221F; --surface-2: #212D29; --line: #2E3B37; --line-strong: #66756F;
    --ink: #E6ECE9; --ink-2: #B3BFBA; --ink-3: #8C9994; --on-ink: #121A18;
    --accent: #FF7A45; --accent-weak: #3A1E13; --accent-ink: #FFB08F; --on-accent: #1A0A03;
    color-scheme: dark;
  }
}

:root {
  /* Só fontes do sistema: nenhuma requisição a terceiros, nenhum IP da equipe vazado. */
  --f-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px;
  --r-1: 4px; --r-2: 8px;
  --row-h: 34px;      /* linha de agenda, ponteiro fino */
  --ctl-h: 36px;      /* controles */
  --ctl-h-sm: 28px;
}
/* Toque: tudo cresce para >= 44px. .touch força o modo (recepção no celular). */
@media (pointer: coarse) { :root { --row-h: 52px; --ctl-h: 48px; --ctl-h-sm: 44px; } }
.touch { --row-h: 52px; --ctl-h: 48px; --ctl-h-sm: 44px; }

/* Base */
.es { font-family: var(--f-ui); font-size: 14px; line-height: 20px; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
.es *, .es *::before, .es *::after { box-sizing: border-box; }
.es h1, .es h2, .es h3, .es p, .es ul, .es ol { margin: 0; }
.es ul, .es ol { padding: 0; list-style: none; }
.es a { color: inherit; text-decoration: none; }
.es a:hover { text-decoration: underline; text-underline-offset: 3px; }
.es :focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.display { font-family: var(--f-ui); font-weight: 600; letter-spacing: -0.02em; }
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.small { font-size: 13px; line-height: 18px; }
.xs { font-size: 12px; line-height: 16px; }
.sec { font-size: 12px; line-height: 16px; font-weight: 600; color: var(--ink-3); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.kbd { display: inline-block; font-size: 12px; line-height: 16px; padding: 0 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 3px; color: var(--ink-2); font-weight: 500; }

/* 1. Barra superior */
.topbar { height: 48px; flex: none; display: flex; align-items: center; gap: 20px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-size: 18px; font-weight: 700; letter-spacing: -0.03em; }
.nav { display: flex; gap: 2px; align-self: stretch; }
.nav a { display: flex; align-items: center; padding: 0 12px; color: var(--ink-2); font-weight: 500; border-bottom: 2px solid transparent; }
.nav a:hover { text-decoration: none; color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.search { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 8px 0 10px; border: 1px solid var(--line-strong); border-radius: var(--r-1); background: var(--bg); color: var(--ink-3); }
.search:focus-within { outline: 2px solid var(--ink); outline-offset: 2px; }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; color: var(--ink); outline: none; }
.search input::placeholder { color: var(--ink-3); }

/* 2. Botões */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: var(--ctl-h); padding: 0 14px; border: 1px solid var(--line-strong); border-radius: var(--r-1); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; white-space: nowrap; cursor: pointer; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.btn-primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn-signal { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-signal:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--surface-2); color: var(--ink); }
.btn-sm { height: var(--ctl-h-sm); padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled] { background: var(--surface-2); border-color: var(--line); color: var(--ink-3); cursor: not-allowed; }

/* 3. Campos com validação no lugar */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.label { display: flex; align-items: baseline; gap: 6px; font-size: 13px; line-height: 18px; font-weight: 600; color: var(--ink-2); }
.tag-bpa { font-size: 12px; line-height: 16px; font-weight: 600; color: var(--ink-3); border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; }
.input { width: 100%; height: var(--ctl-h); padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--r-1); background: var(--surface); color: var(--ink); font: inherit; }
.input::placeholder { color: var(--ink-3); }
textarea.input { height: auto; padding: 8px 10px; line-height: 20px; resize: vertical; }
select.input { padding-right: 28px; }
.input[readonly] { background: var(--surface-2); border-color: var(--line); }
.hint { display: flex; align-items: flex-start; gap: 6px; font-size: 12px; line-height: 16px; color: var(--ink-3); }
.field.is-invalid .input { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.field.is-invalid .hint { color: var(--accent-ink); font-weight: 600; }
.field.is-missing .input, .field.is-missing .seg button { border-style: dashed; }
.field.is-valid .hint { color: var(--ink-2); }
/* marcas de validação: forma diferente por estado */
.mk { flex: none; display: inline-grid; place-items: center; width: 14px; height: 14px; margin-top: 1px; border-radius: 50%; font-size: 10px; line-height: 1; font-weight: 800; }
.mk-ok { background: var(--ink-2); color: var(--surface); }
.mk-bad { border-radius: 2px; background: var(--accent); color: var(--on-accent); }
.mk-miss { border: 1.5px dashed var(--ink-3); }

/* 4. Seleção segmentada e caixa */
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg button { height: var(--ctl-h); padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r-1); background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; }
.seg button:hover { background: var(--surface-2); }
.seg button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--on-ink); font-weight: 600; }
.check { display: flex; align-items: center; gap: 10px; min-height: var(--ctl-h); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--ink); }

/* 5. Glifos de status do agendamento: forma + palavra, nunca só cor.
   Os 6 status reais da API. .st-emconsulta é fase 2 (ainda não existe). */
.st { flex: none; display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--ink-2); position: relative; }
.st-agendado { border-style: dashed; border-color: var(--ink-3); }
.st-confirmado { }
.st-presente { background: linear-gradient(90deg, var(--ink-2) 50%, transparent 50%); }
.st-atendido { background: var(--ink-3); border-color: var(--ink-3); }
.st-atendido::after { content: ""; position: absolute; left: 3.5px; top: 1px; width: 3px; height: 6px; border: solid var(--surface); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
.st-faltou { border-color: var(--ink-3); background: linear-gradient(135deg, transparent 43%, var(--ink-3) 43%, var(--ink-3) 57%, transparent 57%); }
.st-cancelado { border: 0; border-radius: 0; }
.st-cancelado::before, .st-cancelado::after { content: ""; position: absolute; left: 1px; top: 6.25px; width: 12px; height: 1.5px; background: var(--ink-3); transform: rotate(45deg); }
.st-cancelado::after { transform: rotate(-45deg); }
.st-emconsulta { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }

/* 6. Alertas clínicos e etiquetas */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px; border-radius: var(--r-1); background: var(--surface-2); color: var(--ink-2); font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip-alert { background: var(--accent-weak); color: var(--accent-ink); }
.chip-alert::before, .flag { content: "!"; flex: none; display: inline-grid; place-items: center; width: 14px; height: 14px; border-radius: 2px; background: var(--accent); color: var(--on-accent); font-size: 10px; font-weight: 800; line-height: 1; }

/* 7. Linha de agenda */
.agenda { display: flex; flex-direction: column; }
.row { position: relative; display: grid; grid-template-columns: 38px 14px minmax(0, 1fr) 76px 220px; align-items: center; column-gap: 8px; height: var(--row-h); padding: 0 8px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--bg); }
.row .t { font-size: 13px; color: var(--ink-2); }
.row .who { display: flex; align-items: center; gap: 8px; min-width: 0; }
/* nome: uma linha, reticências; title="" mostra o nome inteiro no mouse */
.row .nm { min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; unicode-bidi: plaintext; }
.row .meta, .row .flag { flex: none; }
.row .meta { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.row .sit { font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acts { display: flex; gap: 4px; justify-content: flex-end; }
.acts .btn-sm { padding: 0 8px; }
.row.is-done .t, .row.is-done .nm { color: var(--ink-3); font-weight: 500; }
.row.is-miss .t, .row.is-miss .nm { color: var(--ink-3); font-weight: 500; }
.row.is-cancel .t, .row.is-cancel .nm { color: var(--ink-3); font-weight: 500; text-decoration: line-through; text-decoration-thickness: 1px; }
.row.is-now { background: var(--accent-weak); }
.row.is-now .sit { color: var(--accent-ink); font-weight: 700; }
/* hora atual: tinta, não sinal. Tempo não é estado clínico. */
.nowline { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid var(--ink); pointer-events: none; z-index: 1; }
.nowline span { position: absolute; left: 4px; top: -9px; padding: 0 5px; border-radius: 2px; background: var(--ink); color: var(--on-ink); font-size: 12px; line-height: 16px; font-weight: 700; }
/* celular: duas linhas, ações embaixo, alvos de 44 px */
.mrow { height: auto; min-height: 0; grid-template-columns: 42px 14px minmax(0, 1fr) auto; row-gap: 8px; padding: 10px 12px 10px 16px; }
.mrow .acts { grid-column: 3 / -1; justify-content: flex-start; flex-wrap: wrap; }
.mrow .acts .btn-sm { padding: 0 12px; font-size: 14px; }

/* 8. Medidor de prontidão e barra de proporção */
.meter { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 3px; }
.meter i { height: 6px; border-radius: 1px; background: var(--ink-2); }
.meter i.off { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); }
.meter i.bad { background: var(--accent); }
.bar { display: flex; gap: 2px; height: 14px; }
.bar > span { border-radius: 2px; }
.bar .ok { background: var(--ink-2); }
.bar .bad { background: repeating-linear-gradient(135deg, var(--accent) 0 3px, var(--accent-weak) 3px 6px); }

/* Painéis, fluxo de evoluções, tabelas */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-2); }
.panel-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 36px; padding: 0 12px; border-bottom: 1px solid var(--line); }
.panel-h h2 { font-size: 14px; line-height: 20px; font-weight: 600; }
.feed { position: relative; padding-left: 28px; }
.feed::before { content: ""; position: absolute; left: 8px; top: 8px; bottom: 8px; width: 1px; background: var(--line-strong); }
.entry { position: relative; }
.entry::before { content: ""; position: absolute; left: -24px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--bg); border: 1.5px solid var(--ink-2); }
.entry.is-now::before { background: var(--ink); border-color: var(--ink); }
.soap { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 4px 10px; }
.soap b { font-weight: 700; color: var(--ink-3); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 0 10px; height: 32px; border-bottom: 1px solid var(--line-strong); }
.tbl td { padding: 0 10px; height: 40px; border-bottom: 1px solid var(--line); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); min-height: 60px; flex: none; background: var(--surface); border-top: 1px solid var(--line); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 60px; padding: 6px 2px; font-size: 12px; line-height: 14px; font-weight: 600; text-align: center; color: var(--ink-3); border-top: 2px solid transparent; }
.tabbar a:hover { text-decoration: none; }
.tabbar a[aria-current="page"] { color: var(--ink); border-top-color: var(--ink); }

@media (prefers-reduced-motion: reduce) { .es * { transition: none !important; animation: none !important; } }
