/* =====================================================================
   Health Performance OS — Design System
   Base: Inter, superfícies "glass" com borda em gradiente, acento azul,
   modo escuro (padrão) e claro, paleta de dados validada para daltonismo.
   ===================================================================== */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
  src: url('../fonts/inter-latin.woff2') format('woff2');
}

:root {
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r-xs: 8px; --r-sm: 12px; --r: 16px; --r-lg: 24px; --r-pill: 9999px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --sidebar-w: 264px;
  --topbar-h: 64px;
  --content-max: 1440px;

  /* Status (fixos, nunca usados como série de dados) */
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
}

:root, [data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0a0a;
  --bg-2: #0e0e10;
  --surface: rgba(255, 255, 255, .035);
  --surface-2: rgba(255, 255, 255, .06);
  --surface-3: rgba(255, 255, 255, .09);
  --surface-solid: #141416;
  --surface-pop: #17171a;
  --border: rgba(255, 255, 255, .08);
  --border-2: rgba(255, 255, 255, .14);
  --grad-border: linear-gradient(225deg, rgba(255,255,255,0) 0%, rgba(255,255,255,.16) 50%, rgba(255,255,255,0) 100%);
  --card-bg: linear-gradient(225deg, rgba(255,255,255,.012) 0%, rgba(255,255,255,.05) 50%, rgba(255,255,255,.012) 100%);
  --text: #f5f5f4; --text-2: #d4d4d4; --text-3: #a3a3a3; --text-4: #737373; --text-5: #525252;
  --accent: #60a5fa; --accent-strong: #3b82f6; --accent-soft: rgba(96,165,250,.14); --accent-text: #93c5fd;
  --good-soft: rgba(12,163,12,.16); --good-text: #86efac;
  --warning-soft: rgba(250,178,25,.14); --warning-text: #fcd34d;
  --serious-soft: rgba(236,131,90,.15); --serious-text: #fdba74;
  --critical-soft: rgba(208,59,59,.16); --critical-text: #fca5a5;
  --demo-soft: rgba(168,85,247,.16); --demo-text: #d8b4fe; --demo: #a855f7;
  --shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 20px 40px -24px rgba(0,0,0,.6);
  --shadow-pop: 0 30px 60px -20px rgba(0,0,0,.75), 0 0 0 1px rgba(255,255,255,.06);
  --grid-line: rgba(255,255,255,.06);
  --chart-surface: #141414;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --band: rgba(57,135,229,.10);
  --seq-1: #184f95; --seq-2: #256abf; --seq-3: #3987e5; --seq-4: #6da7ec; --seq-5: #9ec5f4;
  --btn-primary-bg: #fafafa; --btn-primary-text: #0a0a0a;
  --input-bg: rgba(255,255,255,.04);
  --overlay: rgba(0,0,0,.6);
  --skeleton-a: rgba(255,255,255,.04); --skeleton-b: rgba(255,255,255,.09);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f7;
  --bg-2: #eef0f3;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --surface-3: #eceef2;
  --surface-solid: #ffffff;
  --surface-pop: #ffffff;
  --border: rgba(15, 23, 42, .08);
  --border-2: rgba(15, 23, 42, .14);
  --grad-border: linear-gradient(225deg, rgba(15,23,42,.02) 0%, rgba(15,23,42,.10) 50%, rgba(15,23,42,.02) 100%);
  --card-bg: #ffffff;
  --text: #0b0b0b; --text-2: #27272a; --text-3: #52525b; --text-4: #71717a; --text-5: #a1a1aa;
  --accent: #2563eb; --accent-strong: #1d4ed8; --accent-soft: rgba(37,99,235,.09); --accent-text: #1d4ed8;
  --good-soft: rgba(12,163,12,.1); --good-text: #166534;
  --warning-soft: rgba(250,178,25,.16); --warning-text: #92400e;
  --serious-soft: rgba(236,131,90,.14); --serious-text: #9a3412;
  --critical-soft: rgba(208,59,59,.1); --critical-text: #991b1b;
  --demo-soft: rgba(147,51,234,.1); --demo-text: #6b21a8; --demo: #9333ea;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 12px 32px -20px rgba(15,23,42,.18);
  --shadow-pop: 0 24px 60px -20px rgba(15,23,42,.35), 0 0 0 1px rgba(15,23,42,.06);
  --grid-line: rgba(15,23,42,.07);
  --chart-surface: #fcfcfb;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --band: rgba(42,120,214,.09);
  --seq-1: #9ec5f4; --seq-2: #6da7ec; --seq-3: #3987e5; --seq-4: #256abf; --seq-5: #184f95;
  --btn-primary-bg: #0b0b0b; --btn-primary-text: #ffffff;
  --input-bg: #ffffff;
  --overlay: rgba(15,23,42,.35);
  --skeleton-a: rgba(15,23,42,.05); --skeleton-b: rgba(15,23,42,.1);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-sans); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
  font-feature-settings: 'cv11', 'ss01', 'tnum' 0;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.02em; font-weight: 600; }
p { margin: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--accent-soft); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-2); }
.num, .tabular { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -40px; z-index: 100; background: var(--surface-pop); padding: 8px 12px; border-radius: var(--r-sm); }
.skip-link:focus { top: 12px; }

/* Fundo: grade sutil + brilhos */
.bg-decor { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.bg-decor::before {
  content: ''; position: absolute; inset: 0; opacity: .5;
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 64px 64px; mask-image: radial-gradient(ellipse at 30% 0%, #000 0%, transparent 70%);
}
.bg-decor .glow { position: absolute; border-radius: 50%; filter: blur(80px); }
.bg-decor .glow.a { width: 520px; height: 520px; top: -180px; left: -120px; background: rgba(59,130,246,.08); }
.bg-decor .glow.b { width: 420px; height: 420px; bottom: -160px; right: -100px; background: rgba(96,165,250,.05); }
[data-theme="light"] .bg-decor .glow.a { background: rgba(59,130,246,.07); }

/* ---------- Borda em gradiente ---------- */
.border-gradient { position: relative; }
.border-gradient::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background: var(--grad-border);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
}

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 14px 24px; border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(18px); z-index: 30; display: flex; flex-direction: column; gap: 8px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; color: #fff;
  background: radial-gradient(120% 120% at 20% 10%, #60a5fa 0%, #2563eb 45%, #1e3a8a 100%); box-shadow: 0 8px 24px -8px rgba(37,99,235,.6);
}
.brand-text strong { display: block; font-size: 14px; letter-spacing: -0.01em; }
.brand-text span { display: block; font-size: 11px; color: var(--text-4); }
.nav-group { margin-top: 10px; }
.nav-group-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text-5); padding: 6px 10px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--text-3); font-weight: 500; font-size: 13.5px;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--text); }
.nav-link.active .icon { color: var(--accent); }
.nav-link .icon { color: var(--text-4); flex: none; }
.nav-link .count { margin-left: auto; font-size: 11px; padding: 1px 7px; border-radius: var(--r-pill); background: var(--critical-soft); color: var(--critical-text); font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-4); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: blur(16px); border-bottom: 1px solid var(--border);
}
.topbar .search-trigger {
  flex: 1; max-width: 520px; display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 12px; border-radius: 12px; cursor: text;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-4); font-size: 13px; transition: border-color .15s;
}
.topbar .search-trigger:hover { border-color: var(--border-2); }
.topbar .search-trigger kbd { margin-left: auto; }
.topbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.content { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: 28px 28px 80px; }
.menu-toggle { display: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 28px; letter-spacing: -0.035em; line-height: 1.15; }
.page-head .sub { color: var(--text-3); margin-top: 6px; max-width: 760px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.eyebrow { font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-text); margin-bottom: 6px; display: inline-flex; align-items: center; gap: 6px; }
.section-title { font-size: 15px; font-weight: 600; margin: 28px 0 12px; display: flex; align-items: center; gap: 8px; }
.section-title .hint { font-weight: 400; color: var(--text-4); font-size: 12.5px; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.span-12 { grid-column: span 12; } .span-9 { grid-column: span 9; } .span-8 { grid-column: span 8; } .span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; } .span-5 { grid-column: span 5; } .span-4 { grid-column: span 4; } .span-3 { grid-column: span 3; } .span-2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.top { align-items: flex-start; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-16 { gap: 16px; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-3); } .subtle { color: var(--text-4); } .faint { color: var(--text-5); }
.small { font-size: 12.5px; } .tiny { font-size: 11.5px; }
.strong { font-weight: 600; }
.right { text-align: right; } .center { text-align: center; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- Cartões ---------- */
.card {
  position: relative; border-radius: var(--r-lg); background: var(--card-bg); padding: 20px; box-shadow: var(--shadow); min-width: 0;
  border: 1px solid transparent;
}
.card::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none; background: var(--grad-border);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
}
[data-theme="light"] .card { border-color: var(--border); }
[data-theme="light"] .card::before { display: none; }
.card.flat { box-shadow: none; }
.card.tight { padding: 14px 16px; }
.card.pad-lg { padding: 26px; }
.card.interactive { cursor: pointer; transition: transform .2s var(--ease), background .2s var(--ease); }
.card.interactive:hover { transform: translateY(-2px); background: var(--surface-2); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title { font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.card-title .icon { color: var(--text-4); }
.card-sub { font-size: 12.5px; color: var(--text-4); margin-top: 3px; }
.card-foot { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--text-4); flex-wrap: wrap; }
.card.accent { background: linear-gradient(160deg, rgba(59,130,246,.16), rgba(59,130,246,.02) 60%), var(--card-bg); }
.card.danger { background: linear-gradient(160deg, rgba(208,59,59,.16), rgba(208,59,59,.03) 60%), var(--card-bg); }

/* Indicador (stat tile) */
.stat { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stat-label { font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 28px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 6px; }
.stat-value .unit { font-size: 13px; font-weight: 500; color: var(--text-4); letter-spacing: 0; }
.stat-value.xl { font-size: 48px; letter-spacing: -0.045em; }
.stat-value.sm { font-size: 22px; }
.stat-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-4); flex-wrap: wrap; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.delta .dot { width: 6px; height: 6px; border-radius: 50%; }
.delta.good .dot { background: var(--good); } .delta.bad .dot { background: var(--serious); } .delta.neutral .dot { background: var(--text-5); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.kpi { border-radius: var(--r); background: var(--surface); border: 1px solid var(--border); padding: 14px 16px; min-width: 0; transition: border-color .15s; }
.kpi:hover { border-color: var(--border-2); }
.kpi .spark { margin-top: 8px; height: 30px; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: var(--r-pill);
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-weight: 500; font-size: 13.5px; cursor: pointer; white-space: nowrap;
  transition: transform .15s var(--ease), background .15s var(--ease), border-color .15s, color .15s; text-decoration: none !important;
}
.btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-2); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--btn-primary-bg); color: var(--btn-primary-text); border-color: transparent; font-weight: 600; box-shadow: 0 1px 0 rgba(255,255,255,.4) inset, 0 6px 16px -8px rgba(0,0,0,.5); }
.btn.primary:hover { filter: brightness(.96); }
.btn.accent { background: var(--accent-strong); color: #fff; border-color: transparent; font-weight: 600; }
.btn.accent:hover { background: var(--accent); }
.btn.danger { color: var(--critical-text); border-color: rgba(208,59,59,.3); background: var(--critical-soft); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-3); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { height: 30px; padding: 0 12px; font-size: 12.5px; }
.btn.lg { height: 46px; padding: 0 22px; font-size: 14.5px; }
.btn.block { width: 100%; }
.btn.icon-only { width: 38px; padding: 0; }
.btn.icon-only.sm { width: 30px; }
.btn .spinner { width: 14px; height: 14px; }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; border: 1px solid transparent; background: transparent; color: var(--text-3); cursor: pointer; position: relative; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn .badge-dot { position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--critical); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--bg); }

/* ---------- Badges / pills ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: var(--r-pill); font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border); white-space: nowrap; }
.badge .icon { width: 12px; height: 12px; }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.badge.good { background: var(--good-soft); color: var(--good-text); border-color: transparent; }
.badge.warning { background: var(--warning-soft); color: var(--warning-text); border-color: transparent; }
.badge.serious { background: var(--serious-soft); color: var(--serious-text); border-color: transparent; }
.badge.critical { background: var(--critical-soft); color: var(--critical-text); border-color: transparent; }
.badge.demo { background: var(--demo-soft); color: var(--demo-text); border-color: transparent; letter-spacing: .04em; }
.badge.outline { background: transparent; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); cursor: pointer; transition: all .15s; }
.chip:hover { border-color: var(--border-2); color: var(--text); }
.chip.active { background: var(--accent-soft); border-color: transparent; color: var(--text); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--text-5); }
.status-dot.good { background: var(--good); } .status-dot.warning { background: var(--warning); } .status-dot.serious { background: var(--serious); } .status-dot.critical { background: var(--critical); } .status-dot.accent { background: var(--accent); }
.status-dot.pulse { animation: pulse 2s infinite; }
kbd { font-family: var(--font-mono); font-size: 11px; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text-3); }

/* ---------- Formulários ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.field .hint { font-size: 11.5px; color: var(--text-4); }
.field .error-text { font-size: 11.5px; color: var(--critical-text); }
.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px; border-radius: var(--r-sm); background: var(--input-bg); border: 1px solid var(--border); color: var(--text);
  font-size: 13.5px; transition: border-color .15s, box-shadow .15s; outline: none;
}
.textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.select option { background: var(--surface-solid); color: var(--text); }
.input::placeholder, .textarea::placeholder { color: var(--text-5); }
.input:focus, .select:focus, .textarea:focus { border-color: color-mix(in srgb, var(--accent) 60%, transparent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.invalid, .select.invalid, .textarea.invalid { border-color: rgba(208,59,59,.6); }
input:-webkit-autofill { -webkit-box-shadow: 0 0 0 40px var(--surface-solid) inset !important; -webkit-text-fill-color: var(--text) !important; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.check input { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--accent-strong); flex: none; }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 11px; background: var(--surface-3); border: 1px solid var(--border-2); cursor: pointer; transition: background .2s; }
.switch span::after { content: ''; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; border-radius: 50%; background: #fff; transition: transform .2s var(--ease); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--accent-strong); border-color: transparent; }
.switch input:checked + span::after { transform: translateX(16px); }
.scale-input { display: flex; gap: 6px; }
.scale-input button { flex: 1; height: 36px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; color: var(--text-3); transition: all .15s; }
.scale-input button:hover { border-color: var(--border-2); color: var(--text); }
.scale-input button.active { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 50%, transparent); color: var(--text); }

/* Controle segmentado (períodos 7d/30d/90d...) */
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); gap: 2px; flex-wrap: wrap; }
.seg button { height: 28px; padding: 0 11px; border-radius: 9px; border: 0; background: transparent; color: var(--text-3); font-size: 12.5px; font-weight: 500; cursor: pointer; transition: all .15s; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.2); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs button { height: 40px; padding: 0 14px; background: transparent; border: 0; border-bottom: 2px solid transparent; color: var(--text-3); font-weight: 500; cursor: pointer; white-space: nowrap; margin-bottom: -1px; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- Tabelas e listas ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--r); border: 1px solid var(--border); }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-4); padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--border); min-width: 0; }
.list-item:last-child { border-bottom: 0; }
.list-item .li-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-3); flex: none; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 500; font-size: 13.5px; }
.list-item .li-sub { font-size: 12px; color: var(--text-4); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--text-4); }
.kv dd { margin: 0; color: var(--text-2); }

/* ---------- Avisos / callouts ---------- */
.callout { display: flex; gap: 12px; padding: 13px 15px; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface); font-size: 13px; color: var(--text-2); line-height: 1.55; }
.callout .icon { flex: none; margin-top: 1px; }
.callout.info .icon { color: var(--accent); }
.callout.warning { background: var(--warning-soft); border-color: transparent; } .callout.warning .icon { color: var(--warning); }
.callout.serious { background: var(--serious-soft); border-color: transparent; } .callout.serious .icon { color: var(--serious); }
.callout.critical { background: var(--critical-soft); border-color: rgba(208,59,59,.3); } .callout.critical .icon { color: var(--critical); }
.callout.good { background: var(--good-soft); border-color: transparent; } .callout.good .icon { color: var(--good); }
.callout.demo { background: var(--demo-soft); border-color: transparent; } .callout.demo .icon { color: var(--demo); }
.callout strong { color: var(--text); }
.disclaimer { font-size: 11.5px; color: var(--text-4); display: flex; gap: 6px; align-items: flex-start; line-height: 1.5; }
.disclaimer .icon { flex: none; width: 13px; height: 13px; margin-top: 2px; }
.demo-banner { display: flex; align-items: center; gap: 10px; padding: 8px 28px; background: var(--demo-soft); color: var(--demo-text); font-size: 12.5px; border-bottom: 1px solid var(--border); }
.demo-banner button { margin-left: auto; }
.mode-banner { display: flex; align-items: center; gap: 10px; padding: 8px 28px; background: var(--warning-soft); color: var(--warning-text); font-size: 12.5px; border-bottom: 1px solid var(--border); }

/* Transparência analítica */
details.transparency { margin-top: 12px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); }
details.transparency summary { cursor: pointer; padding: 9px 12px; font-size: 12.5px; color: var(--text-3); list-style: none; display: flex; align-items: center; gap: 8px; }
details.transparency summary::-webkit-details-marker { display: none; }
details.transparency[open] summary { border-bottom: 1px solid var(--border); }
details.transparency .t-body { padding: 12px; display: grid; grid-template-columns: max-content 1fr; gap: 7px 14px; font-size: 12.5px; }
details.transparency .t-body dt { color: var(--text-4); }
details.transparency .t-body dd { margin: 0; color: var(--text-2); }

/* ---------- Estados ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 36px 20px; gap: 10px; }
.empty .empty-icon { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-4); margin-bottom: 4px; }
.empty h3 { font-size: 15px; }
.empty p { color: var(--text-3); max-width: 460px; font-size: 13px; }
.empty .actions { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; justify-content: center; }
.empty.compact { padding: 18px 12px; }
.skeleton { border-radius: 10px; background: linear-gradient(90deg, var(--skeleton-a) 0%, var(--skeleton-b) 50%, var(--skeleton-a) 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }
.skeleton.line { height: 12px; margin: 8px 0; }
.skeleton.block { height: 160px; }
.skeleton.stat { height: 74px; }
.error-box { border-radius: var(--r); background: var(--critical-soft); border: 1px solid rgba(208,59,59,.25); color: var(--critical-text); padding: 12px 14px; font-size: 13px; display: flex; align-items: center; gap: 10px; }
.error-box button { margin-left: auto; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-2); border-top-color: var(--accent); animation: spin .8s linear infinite; display: inline-block; }
.loading-center { display: grid; place-items: center; padding: 60px 0; }

/* ---------- Progresso / medidores ---------- */
.progress { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 3px; background: var(--accent-strong); transition: width .6s var(--ease); }
.progress.good > span { background: var(--good); } .progress.warning > span { background: var(--warning); } .progress.critical > span { background: var(--critical); }
.ring-wrap { position: relative; display: grid; place-items: center; }
.ring-wrap .ring-label { position: absolute; text-align: center; }
.ring-wrap .ring-label strong { display: block; font-size: 26px; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.ring-wrap .ring-label span { font-size: 11px; color: var(--text-4); }
.stage-bar { display: flex; gap: 2px; height: 12px; border-radius: 6px; overflow: hidden; }
.stage-bar > span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--text-3); }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend .line-key { width: 14px; height: 2px; border-radius: 1px; display: inline-block; }

/* ---------- Gráficos ---------- */
.chart { position: relative; width: 100%; min-height: 120px; }
.chart svg { overflow: visible; }
.chart .axis text { fill: var(--text-4); font-size: 11px; font-family: var(--font-sans); font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--grid-line); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline-band { fill: var(--band); }
.chart .ref-line { stroke: var(--text-5); stroke-width: 1; stroke-dasharray: 3 4; }
.chart .ref-label { fill: var(--text-4); font-size: 10.5px; }
.chart .crosshair { stroke: var(--text-4); stroke-width: 1; }
.chart .annotation { stroke: var(--text-5); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .annotation-label { fill: var(--text-3); font-size: 10.5px; }
.chart-tooltip {
  position: absolute; pointer-events: none; z-index: 10; min-width: 140px; max-width: 260px; padding: 9px 11px; border-radius: 12px; font-size: 12px;
  background: var(--surface-pop); border: 1px solid var(--border-2); box-shadow: var(--shadow-pop); color: var(--text-2); opacity: 0; transition: opacity .12s; transform: translate(-50%, -100%);
}
.chart-tooltip.visible { opacity: 1; }
.chart-tooltip .tt-date { color: var(--text-4); font-size: 11px; margin-bottom: 5px; }
.chart-tooltip .tt-row { display: flex; align-items: center; gap: 7px; justify-content: space-between; }
.chart-tooltip .tt-row .tt-key { display: flex; align-items: center; gap: 6px; color: var(--text-3); }
.chart-tooltip .tt-row strong { color: var(--text); font-variant-numeric: tabular-nums; }
.chart-tooltip .tt-swatch { width: 8px; height: 8px; border-radius: 2px; }
.chart-empty { display: grid; place-items: center; height: 100%; min-height: 140px; color: var(--text-4); font-size: 12.5px; text-align: center; padding: 12px; }
details.table-view { margin-top: 10px; }
details.table-view summary { cursor: pointer; font-size: 12px; color: var(--text-4); }
details.table-view .table-wrap { margin-top: 8px; max-height: 260px; overflow: auto; }

/* ---------- Sobreposições ---------- */
.modal-backdrop { position: fixed; inset: 0; background: var(--overlay); backdrop-filter: blur(6px); z-index: 80; display: grid; place-items: center; padding: 20px; animation: fadeIn .18s var(--ease); }
.modal { width: 100%; max-width: 560px; max-height: calc(100vh - 40px); overflow: auto; border-radius: var(--r-lg); background: var(--surface-pop); box-shadow: var(--shadow-pop); animation: popIn .22s var(--ease); }
.modal.wide { max-width: 820px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 0; }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 16px 22px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 22px 20px; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); background: var(--surface-pop); box-shadow: var(--shadow-pop); z-index: 85; display: flex; flex-direction: column; animation: slideIn .25s var(--ease); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.drawer-body { flex: 1; overflow: auto; padding: 8px 20px 20px; }
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 95; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; min-width: 260px; max-width: 380px; padding: 12px 14px; border-radius: 14px; background: var(--surface-pop); box-shadow: var(--shadow-pop); font-size: 13px; display: flex; gap: 10px; align-items: flex-start; animation: toastIn .25s var(--ease); }
.toast.good .icon { color: var(--good); } .toast.critical .icon { color: var(--critical); } .toast.warning .icon { color: var(--warning); } .toast.info .icon { color: var(--accent); }
.toast.leaving { animation: toastOut .2s var(--ease) forwards; }

/* Paleta de comandos / busca global */
.palette { position: fixed; inset: 0; z-index: 90; background: var(--overlay); backdrop-filter: blur(6px); display: flex; justify-content: center; padding-top: 12vh; animation: fadeIn .15s; }
.palette-box { width: min(640px, calc(100vw - 32px)); max-height: 66vh; display: flex; flex-direction: column; border-radius: 18px; background: var(--surface-pop); box-shadow: var(--shadow-pop); overflow: hidden; animation: popIn .2s var(--ease); }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.palette-input input { flex: 1; border: 0; background: transparent; outline: none; font-size: 15px; color: var(--text); }
.palette-results { overflow: auto; padding: 6px; }
.palette-group { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-5); padding: 10px 10px 4px; }
.palette-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; cursor: pointer; color: var(--text-2); }
.palette-item .sub { margin-left: auto; font-size: 11.5px; color: var(--text-5); }
.palette-item.active, .palette-item:hover { background: var(--surface-2); color: var(--text); }

/* Notificações */
.notif { display: flex; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--border); }
.notif.unread .notif-title::after { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-left: 6px; vertical-align: middle; }
.notif-title { font-weight: 500; font-size: 13.5px; }
.notif-body { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.notif-time { font-size: 11px; color: var(--text-5); margin-top: 4px; }

/* Linha do tempo */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--border); border-radius: 1px; }
.tl-item { position: relative; padding: 0 0 18px; }
.tl-item::before { content: ''; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface-pop); border: 2px solid var(--accent); }
.tl-item.k-lab::before { border-color: var(--s3); } .tl-item.k-med::before { border-color: var(--s2); } .tl-item.k-event::before { border-color: var(--s7); }
.tl-item.k-insight::before { border-color: var(--s4); } .tl-item.k-symptom::before { border-color: var(--s8); } .tl-item.k-record::before { border-color: var(--s1); }
.tl-date { font-size: 11.5px; color: var(--text-4); }
.tl-title { font-weight: 500; margin-top: 2px; }
.tl-body { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }

/* Login */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-visual { position: relative; overflow: hidden; border-right: 1px solid var(--border); }
.auth-visual img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .9; }
.auth-visual::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10,10,10,.1) 0%, rgba(10,10,10,.35) 50%, rgba(10,10,10,.92) 100%); }
.auth-visual .auth-copy { position: absolute; left: 44px; right: 44px; bottom: 44px; z-index: 2; color: #f5f5f4; }
.auth-visual .auth-copy h2 { font-size: 34px; letter-spacing: -0.04em; line-height: 1.1; max-width: 520px; }
.auth-visual .auth-copy p { color: #d4d4d4; margin-top: 12px; max-width: 520px; }
.auth-points { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.auth-points span { font-size: 12px; padding: 6px 11px; border-radius: var(--r-pill); background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); color: #e5e5e5; backdrop-filter: blur(8px); }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h1 { font-size: 28px; letter-spacing: -0.035em; }

/* Assistente (estrutura básica; o módulo de IA complementa) */
.chat-msg { max-width: 820px; }
.prose p + p { margin-top: 8px; }
.prose ul { margin: 6px 0; padding-left: 20px; }
.prose li { margin: 3px 0; }

/* Calendário de calor */
.heatmap text { fill: var(--text-4); font-size: 10px; }

/* Fundo escurecido de gavetas e do menu lateral (todas as larguras) */
.sidebar-backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 25; backdrop-filter: blur(2px); animation: fadeIn .18s var(--ease); }

/* Barra inferior (mobile) */
.bottom-nav { display: none; }

/* ---------- Animações ---------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadeSlideIn { 0% { opacity: 0; transform: translateY(18px); filter: blur(6px); } 100% { opacity: 1; transform: none; filter: blur(0); } }
@keyframes popIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 40%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.anim-in { animation: fadeUp .45s var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms); }
.page-enter { animation: fadeSlideIn .5s var(--ease) both; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Responsivo ---------- */
@media (max-width: 1280px) {
  .span-3 { grid-column: span 6; }
  .span-4 { grid-column: span 6; }
  .span-8, .span-9, .span-7 { grid-column: span 12; }
  .span-5 { grid-column: span 12; }
}
@media (max-width: 1024px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 290px; transform: translateX(-100%); transition: transform .25s var(--ease); box-shadow: var(--shadow-pop); background: var(--surface-pop); }
  .sidebar.open { transform: none; }
  .menu-toggle { display: grid; }
  .span-6 { grid-column: span 12; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-visual { min-height: 0; border-right: 0; border-bottom: 1px solid var(--border); }
  .auth-visual .auth-copy { position: relative; left: auto; right: auto; bottom: auto; padding: 56px 24px 24px; }
  .auth-visual .auth-copy h2 { font-size: 24px; }
  .auth-visual .auth-copy p { font-size: 13px; }
  .auth-panel { padding: 28px 20px 40px; }
}
@media (max-width: 720px) {
  .auth-points { display: none; }
  .content { padding: 18px 16px 96px; }
  .topbar { padding: 0 12px; gap: 6px; }
  .topbar .search-trigger span.label, .topbar .search-trigger kbd { display: none; }
  .topbar .search-trigger { max-width: 44px; padding: 0; justify-content: center; }
  .page-head h1 { font-size: 23px; }
  .span-3, .span-4, .span-2 { grid-column: span 12; }
  .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .card { padding: 16px; border-radius: 20px; }
  .stat-value.xl { font-size: 40px; }
  .demo-banner, .mode-banner { padding: 8px 14px; }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: 64px; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface-pop) 92%, transparent); backdrop-filter: blur(16px); border-top: 1px solid var(--border); justify-content: space-around;
  }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 10.5px; color: var(--text-4); border-radius: 12px; text-decoration: none; }
  .bottom-nav a.active { color: var(--text); }
  .bottom-nav a.active .icon { color: var(--accent); }
  .toasts { left: 12px; right: 12px; bottom: 76px; }
  .toast { min-width: 0; max-width: none; }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal { border-radius: 22px 22px 0 0; max-height: 92vh; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table th, .table td { padding: 9px 10px; }
}
@media print {
  .sidebar, .topbar, .bottom-nav, .demo-banner, .no-print, .toasts { display: none !important; }
  .app { display: block; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
}
