/* ==========================================================================
   Lab4Docs — design system
   Paleta clínica sóbria, tipografia com hierarquia clara, densidade de dados
   alta sem poluição. Claro e escuro.
   ========================================================================== */

:root {
  /* superfícies */
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --line: #e4e8f0;
  --line-strong: #cfd6e4;

  /* texto */
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;

  /* marca */
  --brand: #1f5fd6;
  --brand-ink: #17489f;
  --brand-soft: #eaf1ff;
  --brand-ring: rgba(31, 95, 214, .18);

  /* semântica clínica */
  --high: #c2384a;        /* acima da referência */
  --high-soft: #fdeef0;
  --low: #1f6fb2;         /* abaixo da referência */
  --low-soft: #eaf4fc;
  --ok: #0f7b53;
  --ok-soft: #e8f6ef;
  --warn: #9a6413;
  --warn-soft: #fdf3e2;

  /* forma */
  --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-xl: 22px;
  --sh-1: 0 1px 2px rgba(15, 23, 42, .05);
  --sh-2: 0 1px 3px rgba(15, 23, 42, .06), 0 8px 24px -12px rgba(15, 23, 42, .18);
  --sh-3: 0 24px 60px -20px rgba(15, 23, 42, .28);
  --sidebar-w: 244px;

  --mono: "SF Mono", ui-monospace, "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
}

/* Tema escuro: segue o sistema por padrão, mas o botão (data-theme) manda nos dois sentidos. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120; --surface: #111a2e; --surface-2: #16203a; --surface-3: #1c2842;
    --line: #23304d; --line-strong: #33436a;
    --ink: #eef2fb; --ink-2: #cbd5e8; --muted: #93a1bd; --faint: #6b7a99;
    --brand: #6f9dff; --brand-ink: #a6c4ff; --brand-soft: #16244a; --brand-ring: rgba(111, 157, 255, .25);
    --high: #ff8a9b; --high-soft: #35141c; --low: #7cc0f0; --low-soft: #10283c;
    --ok: #5fd3a3; --ok-soft: #0f2f24; --warn: #e8b060; --warn-soft: #33260f;
    --sh-2: 0 1px 3px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
    --sh-3: 0 24px 60px -20px rgba(0,0,0,.7);
  }
}
:root[data-theme="dark"] {
  --bg: #0b1120; --surface: #111a2e; --surface-2: #16203a; --surface-3: #1c2842;
  --line: #23304d; --line-strong: #33436a;
  --ink: #eef2fb; --ink-2: #cbd5e8; --muted: #93a1bd; --faint: #6b7a99;
  --brand: #6f9dff; --brand-ink: #a6c4ff; --brand-soft: #16244a; --brand-ring: rgba(111, 157, 255, .25);
  --high: #ff8a9b; --high-soft: #35141c; --low: #7cc0f0; --low-soft: #10283c;
  --ok: #5fd3a3; --ok-soft: #0f2f24; --warn: #e8b060; --warn-soft: #33260f;
  --sh-2: 0 1px 3px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
  --sh-3: 0 24px 60px -20px rgba(0,0,0,.7);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 14px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3 { margin: 0; letter-spacing: -.015em; font-weight: 650; }
a { color: var(--brand); }
::selection { background: var(--brand-ring); }

/* ---------- primitivos ---------- */
.btn {
  --b: var(--brand); --f: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--b); color: var(--f); border: 1px solid transparent;
  border-radius: var(--r-sm); padding: 9px 14px; font: inherit; font-weight: 600; font-size: 13px;
  cursor: pointer; white-space: nowrap; transition: filter .15s, transform .06s, box-shadow .15s, background .15s;
  box-shadow: var(--sh-1);
}
.btn svg { width: 15px; height: 15px; flex: none; }
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.secondary { --b: var(--surface); --f: var(--ink-2); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--surface-3); filter: none; }
.btn.ghost { --b: transparent; --f: var(--muted); box-shadow: none; }
.btn.ghost:hover { background: var(--surface-3); color: var(--ink); filter: none; }
.btn.danger { --b: var(--high-soft); --f: var(--high); border-color: transparent; box-shadow: none; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn.block { width: 100%; }

.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; letter-spacing: .01em; }
.input, .field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); font: inherit;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input::placeholder, .field input::placeholder, .field textarea::placeholder { color: var(--faint); }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 3px var(--brand-ring);
}
.hint { color: var(--muted); font-size: 13px; margin: 4px 0 18px; max-width: 70ch; }
.err { background: var(--high-soft); color: var(--high); padding: 10px 13px; border-radius: var(--r-sm); font-size: 13px; margin-bottom: 14px; border: 1px solid color-mix(in srgb, var(--high) 22%, transparent); }
.ok-banner { background: var(--ok-soft); color: var(--ok); padding: 10px 13px; border-radius: var(--r-sm); font-size: 13px; margin-bottom: 14px; border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent); }

.tag {
  display: inline-flex; align-items: center; background: var(--brand-soft); color: var(--brand-ink);
  border-radius: 6px; padding: 1px 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .04em;
}
.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 3px 9px; font-size: 11.5px; font-weight: 600; }
.pill.high { background: var(--high-soft); color: var(--high); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--high-soft); color: var(--high); }

/* ---------- monitoramento das extracoes ---------- */
.mon-list { display: flex; flex-direction: column; gap: 2px; }
.mon-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.mon-item:last-child { border-bottom: 0; }
.mon-item .pill { flex: 0 0 auto; min-width: 92px; justify-content: center; }
.mon-item .n { font-weight: 600; font-size: 13.5px; }
.mon-item .s { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.mon-falhas { color: var(--high); font-weight: 600; }
/* Painel de operacao: a mesma linguagem do monitor, so que em tabela (uma linha por clinica). */
table.grid .n { font-weight: 600; }
table.grid .s { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ---------- login ---------- */
.auth-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--brand-soft), transparent 70%), var(--bg); }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--sh-3); padding: 34px; width: 100%; max-width: 412px; }
.auth-card .brand { margin-bottom: 6px; }
.auth-card h1 { font-size: 19px; margin-bottom: 2px; }
.switch { text-align: center; margin-top: 18px; font-size: 13px; color: var(--muted); }
.switch a { cursor: pointer; font-weight: 600; }
.row2 { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }

/* ---------- marca ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: -.02em; color: var(--ink); }
.brand .mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none;
  background: linear-gradient(150deg, var(--brand), #5b8ef0); color: #fff;
  box-shadow: 0 4px 12px -3px var(--brand-ring), inset 0 1px 0 rgba(255,255,255,.35);
}
.brand .mark svg { width: 17px; height: 17px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100dvh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--line); padding: 18px 14px;
  display: flex; flex-direction: column; gap: 20px; position: sticky; top: 0; height: 100dvh;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav .lbl { font-size: 10.5px; font-weight: 700; color: var(--faint); letter-spacing: .08em; text-transform: uppercase; padding: 0 10px; margin: 6px 0; }
.nav button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: transparent; border: 0; padding: 9px 10px; border-radius: var(--r-sm);
  color: var(--ink-2); font: inherit; font-size: 13.5px; font-weight: 500; cursor: pointer;
  transition: background .13s, color .13s;
}
.nav button svg { width: 17px; height: 17px; flex: none; opacity: .75; }
.nav button:hover { background: var(--surface-3); color: var(--ink); }
.nav button.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 650; }
.nav button.active svg { opacity: 1; }
.nav .count { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--faint); background: var(--surface-3); border-radius: 999px; padding: 1px 7px; }
.nav button.active .count { background: var(--surface); color: var(--brand-ink); }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; }
.theme-sw { display: flex; gap: 3px; background: var(--surface-3); border-radius: 999px; padding: 3px; margin-bottom: 10px; }
.theme-sw button { flex: 1; display: grid; place-items: center; gap: 0; background: transparent; border: 0;
  border-radius: 999px; padding: 5px; cursor: pointer; color: var(--muted); transition: background .13s, color .13s; }
.theme-sw button svg { width: 14px; height: 14px; }
.theme-sw button:hover { color: var(--ink); }
.theme-sw button.on { background: var(--surface); color: var(--brand-ink); box-shadow: var(--sh-1); }
.theme-sw button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.who { display: flex; align-items: center; gap: 10px; padding: 6px 4px; width: 100%; text-align: left;
       background: none; border: 1px solid transparent; border-radius: 10px; cursor: pointer; color: inherit; font: inherit; }
button.who:hover { background: var(--surface-2); border-color: var(--border); }
.sexo-ctl { display: flex; align-items: center; gap: 6px; margin-top: 7px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.sexo-op { min-width: 26px; height: 22px; padding: 0 7px; border: 1px solid var(--border); background: var(--surface); color: var(--muted);
           border-radius: 6px; cursor: pointer; font: inherit; font-size: 12px; line-height: 1; }
.sexo-op:hover { border-color: var(--brand); }
.sexo-op.on { background: var(--brand); color: #fff; border-color: transparent; font-weight: 600; }
.sexo-op:disabled { opacity: .5; cursor: default; }
.sexo-src { font-style: italic; }

/* Modelos de recado */
.tpl-vars { font-size: 12.5px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border);
            border-radius: 8px; padding: 10px 12px; margin: 0 0 14px; line-height: 1.7; }
.tpl-vars code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }
.tpl-actions { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.tpl-group { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; background: var(--surface); overflow: hidden; }
.tpl-group > summary { cursor: pointer; padding: 12px 14px; font-weight: 600; font-size: 13.5px; list-style: none; display: flex; align-items: center; gap: 8px; }
.tpl-group > summary::-webkit-details-marker { display: none; }
.tpl-group > summary::before { content: '▸'; color: var(--muted); font-size: 11px; }
.tpl-group[open] > summary::before { content: '▾'; }
.tpl-count { margin-left: auto; font-size: 11px; color: var(--muted); background: var(--surface-3); border-radius: 999px; padding: 1px 8px; font-weight: 600; }
.tpl-slot { padding: 11px 14px; border-top: 1px solid var(--border); }
.tpl-slot.on { background: var(--brand-soft); }
.tpl-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.tpl-head label { font-size: 13px; font-weight: 600; }
.tpl-slot.on .tpl-head label::after { content: ' • personalizado'; color: var(--brand); font-weight: 600; font-size: 11px; }
.tpl-reset { font-size: 11.5px; color: var(--brand); cursor: pointer; white-space: nowrap; }
.tpl-help { font-size: 11.5px; color: var(--muted); margin: 3px 0 6px; }
.tpl-slot textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; font: inherit;
                     font-size: 13px; line-height: 1.5; background: var(--surface-2); color: var(--ink); resize: vertical; margin-top: 5px; }
.tpl-slot textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); background: var(--surface); }
.who .who-edit { margin-left: auto; color: var(--muted); font-size: 13px; flex: none; opacity: .7; }
button.who:hover .who-edit { opacity: 1; }
.who .av { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-3); color: var(--muted); display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; }
.who .nm { font-size: 12.5px; font-weight: 600; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who .crm { font-size: 11px; color: var(--muted); }

.main { padding: 26px 30px 60px; max-width: 1180px; }
.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 21px; }
.page-head p { color: var(--muted); font-size: 13.5px; margin: 4px 0 0; max-width: 72ch; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-2); padding: 22px; margin-bottom: 18px; }
.card h2 { font-size: 15.5px; }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid2 .full { grid-column: 1 / -1; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 14px 0; }

/* ---------- laboratórios ---------- */
.lab-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 14px; border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 8px; background: var(--surface-2); transition: border-color .15s; }
.lab-row:hover { border-color: var(--line-strong); }
.lab-row .meta { font-size: 12px; color: var(--muted); margin-top: 3px; word-break: break-all; }

/* ---------- resultados ---------- */
.split { display: grid; grid-template-columns: 292px 1fr; gap: 20px; align-items: start; }
.res-list { max-height: calc(100dvh - 220px); overflow: auto; margin: -4px; padding: 4px; }
.res-item { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 7px; cursor: pointer; background: var(--surface); transition: border-color .13s, background .13s, transform .06s; }
.res-item:hover { border-color: var(--brand); }
.res-item:active { transform: scale(.995); }
.res-item.active { background: var(--brand-soft); border-color: var(--brand); }
.res-item .nm { font-weight: 620; font-size: 13.5px; letter-spacing: -.01em; }
.res-item .sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* resumo do prontuário — o herói da tela */
.summary-box {
  background: linear-gradient(180deg, #0d1730, #0a1226); color: #dbe6ff;
  border: 1px solid #1e2d52; border-radius: var(--r);
  padding: 16px 18px; font-family: var(--mono); font-size: 13px; line-height: 1.85;
  white-space: pre-wrap; word-break: normal; overflow-wrap: break-word;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
}
.summary-box b { color: #ffd479; font-weight: 700; text-shadow: 0 0 18px rgba(255, 212, 121, .25); }
.legend { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* tabela de detalhamento */
.group-h { font-size: 10.5px; font-weight: 700; color: var(--faint); letter-spacing: .08em; text-transform: uppercase; margin: 22px 0 8px; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th { text-align: left; color: var(--faint); font-weight: 600; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; padding: 0 10px 7px; border-bottom: 1px solid var(--line); }
table.grid td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid tbody tr:hover td { background: var(--surface-2); }
table.grid tr.abn td { background: color-mix(in srgb, var(--high-soft) 55%, transparent); }
table.grid tr.abn:hover td { background: var(--high-soft); }
td.val { font-family: var(--mono); font-weight: 600; white-space: nowrap; }
tr.abn td.val { color: var(--high); }
tr.abn.lowv td.val { color: var(--low); }
.arrow { font-size: 10px; vertical-align: 1px; }
.src { font-size: 10px; padding: 1px 6px; border-radius: 5px; font-weight: 600; }
.src.laudo { background: var(--ok-soft); color: var(--ok); }
.src.def { background: var(--surface-3); color: var(--muted); }
.note { font-size: 11px; color: var(--warn); margin-top: 3px; }

/* ---------- consolidado ---------- */
.cgroup { font-family: var(--mono); font-weight: 700; color: var(--brand); font-size: 12px; margin: 20px 0 6px; letter-spacing: .02em; }
.cline { font-family: var(--mono); font-size: 12.5px; line-height: 1.7; padding: 7px 10px; border-radius: var(--r-sm); border-bottom: 1px solid var(--line); cursor: pointer; word-break: break-word; transition: background .12s; }
.cline:hover { background: var(--surface-2); }
.cline b { color: var(--high); font-weight: 700; }
.abadge { font-family: var(--sans); font-size: 10.5px; font-weight: 700; color: var(--high); background: var(--high-soft); border-radius: 999px; padding: 1px 7px; white-space: nowrap; }

/* ---------- estados ---------- */
.empty { color: var(--muted); font-size: 13.5px; padding: 44px 20px; text-align: center; }
.empty svg { width: 30px; height: 30px; opacity: .35; margin-bottom: 10px; }
.spin { display: inline-block; width: 13px; height: 13px; border: 2px solid var(--line-strong); border-top-color: var(--brand); border-radius: 50%; animation: sp .7s linear infinite; vertical-align: -2px; }
@keyframes sp { to { transform: rotate(360deg); } }
.log { background: #0a1226; color: #9fb3dd; border: 1px solid #1e2d52; border-radius: var(--r); padding: 13px; font-family: var(--mono); font-size: 11.5px; line-height: 1.7; max-height: 260px; overflow: auto; white-space: pre-wrap; }
.reextract-msg { background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent); padding: 10px 13px; border-radius: var(--r-sm); font-size: 12.5px; margin: 2px 0 8px; }
textarea.msg { width: 100%; min-height: 300px; padding: 15px; border: 1px solid var(--line-strong); border-radius: var(--r); font: inherit; line-height: 1.65; background: var(--surface-2); color: var(--ink); resize: vertical; }
textarea.msg:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); background: var(--surface); }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(8px);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: 13px; font-weight: 550; opacity: 0; pointer-events: none; z-index: 60;
  transition: opacity .18s, transform .18s; box-shadow: var(--sh-3);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- arrastar PDF ---------- */
.drop { border: 2px dashed var(--line-strong); border-radius: var(--r-lg); background: var(--surface-2);
        padding: 40px 20px; text-align: center; cursor: pointer; color: var(--muted);
        transition: border-color .15s, background .15s, transform .08s; }
.drop:hover { border-color: var(--brand); background: var(--brand-soft); }
.drop:focus-visible { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.drop.over { border-color: var(--brand); background: var(--brand-soft); transform: scale(1.006); }
.drop svg { width: 30px; height: 30px; opacity: .5; margin-bottom: 10px; }
.drop.over svg { opacity: 1; color: var(--brand); }
.drop .d1 { font-size: 15px; font-weight: 600; color: var(--ink); }
.drop .d2 { font-size: 12.5px; margin-top: 4px; }
.drop * { pointer-events: none; }

.up-list { display: grid; gap: 8px; margin-top: 16px; }
.up { display: grid; grid-template-columns: 20px 1fr; gap: 11px; align-items: center; padding: 11px 13px;
      border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.up.ok { border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.up.bad { border-color: color-mix(in srgb, var(--high) 40%, transparent); background: var(--high-soft); }
.up .n { font-size: 13px; font-weight: 600; word-break: break-all; }
.up .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.up .ic { display: grid; place-items: center; width: 19px; height: 19px; border-radius: 50%; font-size: 11px; font-weight: 800; }
.up .ic.ok { background: var(--ok-soft); color: var(--ok); }
.up .ic.bad { background: var(--high-soft); color: var(--high); }
.sum { padding: 18px 22px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--ink-2); list-style: none; }
.sum::-webkit-details-marker { display: none; }
.sum::before { content: '▸ '; color: var(--faint); }
details[open] .sum::before { content: '▾ '; }
.sum:hover { color: var(--ink); }

/* ---------- histórico: modal + gráfico ---------- */
tr.hist { cursor: pointer; }
tr.hist td.chev { width: 26px; text-align: right; color: var(--faint); opacity: 0; transition: opacity .12s; }
tr.hist td.chev svg { width: 14px; height: 14px; vertical-align: -2px; }
tr.hist:hover td.chev { opacity: 1; }
tr.hist:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

.ov { position: fixed; inset: 0; background: rgba(8, 13, 24, .55); backdrop-filter: blur(3px);
      display: grid; place-items: center; padding: 20px; z-index: 50; animation: fade .14s ease-out; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.sheet { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
         box-shadow: var(--sh-3); padding: 22px; width: 100%; max-width: 700px;
         max-height: 88dvh; overflow: auto; animation: rise .18s ease-out; }
@keyframes rise { from { transform: translateY(6px); opacity: .6 } to { transform: none; opacity: 1 } }
@media (prefers-reduced-motion: reduce) { .ov, .sheet { animation: none } }
.sheet-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.sheet-h h2 { font-size: 17px; }
.one-pt { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r);
          padding: 14px; font-size: 13.5px; color: var(--ink-2); margin-top: 14px; }

.chart-wrap { position: relative; margin-top: 16px; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.c-band { fill: color-mix(in srgb, var(--ok) 11%, transparent); }
.c-bandline { stroke: color-mix(in srgb, var(--ok) 42%, transparent); stroke-width: 1; stroke-dasharray: 3 3; }
.c-grid { stroke: var(--line); stroke-width: 1; }
.c-line { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.c-dot { fill: var(--brand); stroke: var(--surface); stroke-width: 2; transition: r .1s; }
.c-dot.high { fill: var(--high); } .c-dot.low { fill: var(--low); }
.c-dot.on { r: 6.5; }
.c-cross { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 3 3; }
.c-ylab { fill: var(--faint); font-size: 10px; text-anchor: end; font-family: var(--mono); }
.c-xlab { fill: var(--faint); font-size: 10px; text-anchor: middle; font-family: var(--mono); }
.c-dlab { fill: var(--ink-2); font-size: 10.5px; font-weight: 700; text-anchor: middle; font-family: var(--mono); }
.c-dlab.high { fill: var(--high); } .c-dlab.low { fill: var(--low); }
.c-tip { position: absolute; background: var(--ink); color: var(--bg); border-radius: 7px; padding: 7px 10px;
         font-size: 12px; pointer-events: none; white-space: nowrap; box-shadow: var(--sh-2); z-index: 2; }
.c-tip .t2 { font-size: 11px; opacity: .78; margin-top: 2px; }
.c-tip .high { color: #ff9aa8; } .c-tip .low { color: #8ec7f0; }
.c-legend { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.c-legend .sw { width: 22px; height: 10px; border-radius: 3px; flex: none;
                background: color-mix(in srgb, var(--ok) 16%, transparent);
                border: 1px dashed color-mix(in srgb, var(--ok) 45%, transparent); }

/* ---------- minha voz (aprender o jeito de escrever) ---------- */
/* O aviso de privacidade abre a tela e não é decoração: o médico está prestes a colar
   recado de paciente, e precisa ver ANTES de colar que nada disso sai da máquina. */
.voz-privado { display: flex; gap: 11px; align-items: flex-start; background: var(--ok-soft);
  border: 1px solid color-mix(in srgb, var(--ok) 28%, transparent); border-radius: var(--r);
  padding: 13px 15px; margin-bottom: 16px; font-size: 12.5px; line-height: 1.6; color: var(--ink-2); max-width: 82ch; }
.voz-privado svg { width: 19px; height: 19px; flex: none; color: var(--ok); margin-top: 1px; }
.voz-campo { margin-bottom: 12px; }
.voz-campo textarea { resize: vertical; line-height: 1.55; }

.voz-resumo { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin: 4px 0 14px; font-size: 12.5px; color: var(--muted); }
.voz-traco { background: var(--surface-3); border-radius: 999px; padding: 2px 10px; }

.voz-sug { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface);
  padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--sh-1); }
.voz-sug.aceita { border-color: color-mix(in srgb, var(--ok) 45%, transparent); background: var(--ok-soft); }
.voz-sug-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 8px; }
.voz-sug-head b { font-size: 13.5px; }
.voz-sug-head .meta { font-size: 11.5px; color: var(--muted); }
.pill.mute { background: var(--surface-3); color: var(--muted); }
/* Aviso em destaque: é o que separa "sugestão boa" de "sugestão que precisa de olho". */
.voz-aviso { background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent);
  border-radius: var(--r-sm); padding: 7px 11px; font-size: 12px; margin-bottom: 7px; }
.voz-cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 8px 0 10px; }
.voz-cmp-t { font-size: 10.5px; font-weight: 700; color: var(--faint); letter-spacing: .07em; text-transform: uppercase; margin-bottom: 5px; }
.voz-atual { background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--r-sm);
  padding: 9px 11px; font-size: 12.5px; line-height: 1.6; color: var(--muted); white-space: pre-wrap; }
.voz-sug textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--brand); border-radius: var(--r-sm);
  font: inherit; font-size: 12.5px; line-height: 1.6; background: var(--surface); color: var(--ink); resize: vertical; }
.voz-sug textarea:focus { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }
.voz-acoes { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.voz-feito { font-size: 12px; color: var(--ok); font-weight: 600; }

.voz-atuais { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.voz-item { display: flex; align-items: flex-start; gap: 12px; padding: 11px 14px; border-top: 1px solid var(--line); }
.voz-item:first-child { border-top: 0; }
.voz-item .t { font-size: 12.5px; color: var(--ink-2); line-height: 1.55; white-space: pre-wrap; margin-top: 3px; }
.voz-item .r { font-size: 12px; font-weight: 600; }
.voz-voltar { font-size: 11.5px; color: var(--brand); cursor: pointer; white-space: nowrap; margin-left: auto; }

/* ---------- responsivo ---------- */
@media (max-width: 940px) {
  .voz-cmp { grid-template-columns: 1fr; }
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 12px; overflow-x: auto; padding: 10px 12px; }
  .sidebar .brand span:last-child, .side-foot .who > div, .nav .lbl { display: none; }
  .nav { flex-direction: row; }
  .side-foot { margin: 0 0 0 auto; border: 0; padding: 0; }
  .who { padding: 0; }
  .main { padding: 18px 14px 50px; }
  .split, .grid2 { grid-template-columns: 1fr; }
  .res-list { max-height: 320px; }
}
