/* ---------------------------------------------------------------------------
   Tokens
--------------------------------------------------------------------------- */
:root {
  --navy: #003366;
  --navy-deep: #00284f;
  --navy-soft: #e6edf5;
  --orange: #ff8000;
  --orange-soft: #fff1e2;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f1f4f8;
  --line: #e2e7ee;
  --text: #13233a;
  --muted: #5b6a7c;
  --faint: #8a96a6;
  --ok: #157a4f;
  --ok-soft: #e3f3ea;
  --warn: #b35300;
  --warn-soft: #fff0df;
  --danger: #c4321c;
  --primary: var(--navy);
  --primary-text: #ffffff;
  --series-1: #003366;
  --series-2: #ff8000;
  --sidebar: #003366;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(0, 40, 79, .05), 0 6px 20px rgba(0, 40, 79, .06);
  --shadow-lg: 0 20px 50px rgba(0, 25, 50, .22);
  --font: 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --navy-soft: #16304d;
    --orange-soft: #3a2410;
    --bg: #0a1420;
    --surface: #111e2e;
    --surface-2: #17273a;
    --line: #22354b;
    --text: #e7edf4;
    --muted: #a0b0c2;
    --faint: #6f8297;
    --ok: #4cc58a;
    --ok-soft: #12301f;
    --warn: #ffa047;
    --warn-soft: #3a2410;
    --danger: #ff7a66;
    --primary: #ff8000;
    --primary-text: #1a0d00;
    --series-1: #79aeea;
    --sidebar: #0c1e33;
    --shadow: none;
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, .5);
  }
}

/* ---------------------------------------------------------------------------
   Base
--------------------------------------------------------------------------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 700; }
p { margin: 0; }
a { color: var(--navy); font-weight: 600; }
@media (prefers-color-scheme: dark) { a { color: var(--series-1); } }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.warn-txt { color: var(--warn); }
.loading { padding: 40px; text-align: center; color: var(--muted); }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.i.sm { width: 17px; height: 17px; }
.i.xs { width: 14px; height: 14px; stroke-width: 2.2; }
.i.xl { width: 40px; height: 40px; stroke-width: 1.4; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .72rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--orange);
}

/* Faixas diagonais — motivo gráfico */
.stripes {
  position: absolute; pointer-events: none;
  background: repeating-linear-gradient(135deg, var(--orange) 0 26px, transparent 26px 52px);
  clip-path: polygon(38% 0, 100% 0, 100% 100%, 0 100%);
}

/* ---------------------------------------------------------------------------
   Botões e campos
--------------------------------------------------------------------------- */
button { font: inherit; color: inherit; cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px; border: 1px solid transparent;
  font-weight: 600; font-size: .92rem; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); color: var(--primary-text); }
.btn.primary:hover { filter: brightness(1.12); }
.btn.accent { background: var(--orange); color: #1a0d00; }
.btn.ghost { background: var(--surface); border-color: var(--line); color: var(--text); }
.btn.ghost:hover { border-color: var(--faint); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 7px 14px; font-size: .84rem; }
.btn.block { width: 100%; padding: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none;
  border-radius: 50%; border: 1px solid transparent; background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); }
.link {
  display: inline-flex; align-items: center; gap: 2px; padding: 4px 0;
  border: 0; background: none; color: var(--navy); font-weight: 600; font-size: .86rem;
}
@media (prefers-color-scheme: dark) { .link { color: var(--series-1); } }
.link:hover { text-decoration: underline; }

label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: 6px; color: var(--text); }
label .opt { font-weight: 500; color: var(--faint); }
input, select, textarea {
  font: inherit; width: 100%; padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft); }
textarea { min-height: 80px; resize: vertical; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--orange); }
.field { margin-bottom: 16px; }
.field.hidden { display: none; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-2 .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }
.error { color: var(--danger); font-size: .88rem; min-height: 1.2em; margin: 2px 0 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); font-size: .76rem; font-weight: 600; white-space: nowrap;
}
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); font-size: .72rem; font-weight: 700; color: var(--muted); }
.count.warn { background: var(--warn-soft); color: var(--warn); }

/* ---------------------------------------------------------------------------
   Login
--------------------------------------------------------------------------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-art { position: relative; overflow: hidden; background: var(--navy); color: #fff; display: flex; align-items: flex-end; padding: 56px; }
.auth-art .stripes { top: -10%; right: -8%; width: 70%; height: 70%; opacity: .95; }
.auth-copy { position: relative; max-width: 420px; }
.auth-copy .logo { width: 56px; height: 56px; margin-bottom: 28px; border-radius: 14px; box-shadow: 0 0 0 2px rgba(255,255,255,.15); }
.auth-copy h1 { font-size: 2.6rem; font-weight: 800; text-transform: uppercase; letter-spacing: -.01em; line-height: 1.05; }
.auth-copy h1::after { content: ''; display: block; width: 48px; height: 5px; background: var(--orange); margin: 20px 0 18px; }
.auth-copy p { color: rgba(255,255,255,.78); font-size: 1.02rem; }
.auth-panel { display: grid; place-items: center; padding: 32px 20px; }
.auth-form { width: 100%; max-width: 380px; }
.auth-form h2 { font-size: 1.7rem; font-weight: 800; margin: 6px 0 24px; }
.auth-form > .muted { margin: -12px 0 24px; }
.auth-switch { margin-top: 20px; text-align: center; font-size: .9rem; color: var(--muted); }
@media (max-width: 820px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art { min-height: 220px; padding: 28px 20px; }
  .auth-copy .logo { width: 44px; height: 44px; margin-bottom: 16px; }
  .auth-copy h1 { font-size: 1.8rem; }
  .auth-copy h1::after { margin: 14px 0 10px; }
  .auth-copy p { font-size: .9rem; }
}

/* ---------------------------------------------------------------------------
   Estrutura do app
--------------------------------------------------------------------------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 252px; z-index: 20;
  background: var(--sidebar); color: #fff; display: flex; flex-direction: column; padding: 22px 14px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 22px; }
.brand .logo { width: 38px; height: 38px; border-radius: 10px; box-shadow: 0 0 0 1.5px rgba(255,255,255,.2); }
.brand span { display: flex; flex-direction: column; font-size: .7rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: rgba(255,255,255,.7); line-height: 1.3; }
.brand b { font-size: 1rem; font-weight: 800; letter-spacing: .04em; color: #fff; }

.who { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; border-radius: 14px; border: 1px solid transparent; background: transparent; text-align: left; }
.who-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.who-txt small { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; opacity: .7; }
.who-txt strong { font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .who { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.1); color: #fff; margin-bottom: 18px; }
.sidebar .who:hover { background: rgba(255,255,255,.12); }

.avatar {
  display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 50%;
  background: var(--orange); color: #1a0d00; font-weight: 800; font-size: .85rem; letter-spacing: .02em;
}

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav button {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px;
  border: 0; background: none; color: rgba(255,255,255,.72); font-weight: 600; font-size: .92rem; text-align: left; position: relative;
}
.side-nav button:hover { color: #fff; background: rgba(255,255,255,.06); }
.side-nav button.active { color: #fff; background: rgba(255,255,255,.1); }
.side-nav button.active::before { content: ''; position: absolute; left: -14px; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--orange); }
.side-nav button.active .i { color: var(--orange); }
.side-account {
  margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px;
  border: 0; background: none; color: rgba(255,255,255,.7); font-size: .86rem; text-align: left;
}
.side-account:hover { color: #fff; background: rgba(255,255,255,.06); }
.side-account span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

main { margin-left: 252px; padding: 36px 44px 72px; max-width: 1240px; }
.topbar, .bottom-nav, .fab { display: none; }

@media (max-width: 899px) {
  .sidebar { display: none; }
  main { margin-left: 0; padding: 16px 16px 128px; }
  .topbar {
    display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 20;
    padding: 10px 12px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
  }
  .topbar .who { flex: 1; padding: 4px; }
  .topbar .avatar { width: 34px; height: 34px; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(6, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav button {
    display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0;
    border: 0; background: none; color: var(--faint); font-size: .64rem; font-weight: 600;
  }
  .bottom-nav button.active { color: var(--navy); }
  .bottom-nav button.active .i { color: var(--orange); }
  .fab {
    display: grid; place-items: center; position: fixed; right: 18px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 21;
    width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--orange); color: #1a0d00;
    box-shadow: 0 10px 24px rgba(255, 128, 0, .4);
  }
  .fab .i { width: 26px; height: 26px; stroke-width: 2.4; }
}
@media (max-width: 899px) and (prefers-color-scheme: dark) { .bottom-nav button.active { color: var(--text); } }

/* Cabeçalho de página: título forte com traço laranja */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { font-size: 1.75rem; font-weight: 800; letter-spacing: -.01em; }
.page-head h1::after { content: ''; display: block; width: 36px; height: 4px; background: var(--orange); margin-top: 10px; }
.page-head p { color: var(--muted); margin-top: 10px; font-size: .92rem; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 560px) {
  .page-head h1 { font-size: 1.45rem; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
}

.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.search { position: relative; margin: 0; flex: 1; min-width: 200px; max-width: 340px; }
.search .i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search input { padding-left: 38px; border-radius: 999px; }
@media (max-width: 560px) { .search { max-width: none; } }

.seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.seg.wrap { flex-wrap: wrap; border-radius: 18px; margin-bottom: 18px; }
.seg button {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px;
  border: 0; background: none; color: var(--muted); font-weight: 600; font-size: .85rem;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg button.on .i { color: var(--orange); }
.seg .count { background: var(--line); }
.toggle { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: .85rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.toggle span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------------------------------------------------------------------------
   Início
--------------------------------------------------------------------------- */
.hero {
  position: relative; overflow: hidden; border-radius: 22px; padding: 30px 32px;
  background: var(--navy); color: #fff; display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap;
}
.hero .stripes { top: 0; right: 0; width: 300px; height: 100%; opacity: .16; }
.hero-body { position: relative; min-width: 0; }
.hero h1 { font-size: 2rem; font-weight: 800; letter-spacing: -.01em; margin-top: 6px; }
.hero-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 10px; color: rgba(255,255,255,.78); font-weight: 500; }
.hero-meta i { width: 4px; height: 4px; border-radius: 50%; background: var(--orange); }
.hero-allergy {
  display: inline-flex; align-items: flex-start; gap: 8px; margin-top: 16px; padding: 8px 14px; border-radius: 12px;
  background: rgba(255,128,0,.16); color: #ffd2a6; font-size: .88rem;
}
.hero-allergy b { color: #fff; margin-right: 4px; }
.hero-allergy .i { margin-top: 2px; color: var(--orange); }
.next {
  position: relative; display: flex; align-items: center; gap: 14px; min-width: 280px; max-width: 420px;
  padding: 16px 18px; border-radius: 16px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); backdrop-filter: blur(6px);
}
.next-ic { display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 12px; background: var(--orange); color: #1a0d00; }
.next div { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.next small { font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; color: rgba(255,255,255,.65); font-weight: 600; }
.next strong { font-size: 1rem; }
.next span { font-size: .85rem; color: rgba(255,255,255,.75); }
@media (max-width: 560px) {
  .hero { padding: 22px 20px; border-radius: 18px; }
  .hero h1 { font-size: 1.55rem; }
  .hero .stripes { width: 150px; height: 110px; opacity: .22; }
  .next { min-width: 0; width: 100%; }
}

.block { margin-top: 28px; }
.block-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.block-head h2 { font-size: 1.05rem; font-weight: 700; }
.block-head .eyebrow { margin-bottom: 4px; }
.block-actions { display: flex; gap: 2px; }

.vitals { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1180px) { .vitals { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .vitals { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
.vital {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 14px; text-align: left;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s;
}
.vital:hover { border-color: var(--orange); transform: translateY(-1px); }
.vital-ic { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--navy-soft); color: var(--navy); margin-bottom: 8px; }
@media (prefers-color-scheme: dark) { .vital-ic { color: var(--series-1); } }
.vital-label { font-size: .76rem; font-weight: 600; color: var(--muted); }
.vital-val { display: flex; align-items: baseline; gap: 4px; font-size: 1.35rem; font-weight: 700; letter-spacing: -.01em; }
.vital-val small { font-size: .72rem; font-weight: 600; color: var(--muted); }
.vital-val .trend { align-self: center; color: var(--faint); }
.vital-date { font-size: .74rem; color: var(--faint); }
.vital.blank { border-style: dashed; box-shadow: none; background: transparent; }
.vital.blank .vital-ic { background: var(--surface-2); color: var(--faint); }
.vital-add { display: inline-flex; align-items: center; gap: 4px; margin-top: 6px; font-size: .8rem; font-weight: 700; color: var(--orange); }

.dash { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-top: 28px; }
.panel {
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.panel-head h3 { font-size: .98rem; font-weight: 700; flex: 1; }
.panel-ic { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 10px; background: var(--orange-soft); color: var(--orange); }
.panel-ic .i { width: 18px; height: 18px; }
.panel-foot { margin-top: auto; padding-top: 16px; display: flex; gap: 8px; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; flex-direction: column; gap: 1px; padding: 10px 0; border-top: 1px solid var(--line); }
.rows li:first-child { border-top: 0; padding-top: 0; }
.rows strong { font-weight: 600; }
.exam-last { display: flex; flex-direction: column; gap: 4px; }
.exam-last strong { font-size: 1.02rem; }
.exam-last .chips { margin-top: 8px; }
.exam-last + .small { margin-top: 12px; }

.ring-row { display: flex; align-items: center; gap: 18px; }
.ring { width: 104px; height: 104px; flex: none; }
.ring-bg { fill: none; stroke: var(--surface-2); stroke-width: 9; }
.ring-fg { fill: none; stroke: var(--orange); stroke-width: 9; stroke-linecap: round; }
.ring-num { font: 800 20px var(--font); fill: var(--text); }
.ring-unit { font: 600 8.5px var(--font); fill: var(--muted); }
.ring-stats { display: flex; flex-direction: column; gap: 4px; }
.ring-stats b { font-size: 1.1rem; }

.ficha dl { margin: 0; display: grid; gap: 12px; }
.ficha dl div { display: grid; grid-template-columns: 22px 1fr; column-gap: 8px; }
.ficha .i { color: var(--faint); margin-top: 2px; grid-row: span 2; }
.ficha dt { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.ficha dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Carrossel de novos resultados */
.highlight {
  margin-top: 24px; padding: 22px; border-radius: 22px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.highlight::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--orange); }
.highlight .block-head { align-items: flex-start; }
.highlight h2 { font-size: 1.15rem; }
.highlight h2 .muted { font-weight: 500; }
.carousel {
  display: grid; grid-auto-flow: column; grid-auto-columns: 236px; gap: 14px;
  overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 2px 8px; scrollbar-width: none;
}
.carousel::-webkit-scrollbar { display: none; }
@media (max-width: 560px) { .carousel { grid-auto-columns: 78%; } .highlight { padding: 18px 16px; } .highlight .block-actions .icon-btn:not(:last-child) { display: none; } }
.mk-card {
  scroll-snap-align: start; display: flex; flex-direction: column; gap: 8px; padding: 16px;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg); cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.mk-card:hover { border-color: var(--navy); transform: translateY(-2px); }
.mk-card.alt { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.mk-cat { display: flex; align-items: center; gap: 5px; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.mk-card h4 { font-size: .98rem; font-weight: 700; }
.mk-value { display: flex; align-items: baseline; gap: 5px; font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.mk-value small { font-size: .78rem; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.mk-card .chip { align-self: flex-start; }
.mk-foot { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.mk-ref { font-size: .74rem; color: var(--faint); }
.trend-txt { display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; font-weight: 600; color: var(--muted); }
.carousel-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.dots { display: flex; gap: 6px; }
.dots span { width: 7px; height: 7px; border-radius: 999px; background: var(--line); transition: width .2s, background .2s; }
.dots span.on { width: 20px; background: var(--orange); }

.spark { width: 88px; height: 28px; flex: none; overflow: visible; }
.mk-card .spark { width: 100%; height: 34px; }
.spark polyline { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: var(--series-1); stroke: var(--surface); stroke-width: 1.5; }
.spark circle.alt { fill: var(--orange); }

/* Marcadores agrupados */
.mk-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; }
@media (max-width: 560px) { .mk-groups { grid-template-columns: 1fr; } }
.mk-group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.mk-group header { display: flex; align-items: center; gap: 10px; padding: 16px 18px 10px; }
.mk-group h3 { font-size: .98rem; flex: 1; }
.mk-group ul { list-style: none; margin: 0; padding: 0 8px 8px; }
.mk-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 88px minmax(92px, auto) 18px; align-items: center; gap: 12px;
  width: 100%; padding: 10px; border: 0; border-radius: 12px; background: none; text-align: left;
}
.mk-row:hover { background: var(--surface-2); }
.mk-name { display: flex; flex-direction: column; font-weight: 600; font-size: .9rem; min-width: 0; }
.mk-name small { font-weight: 500; font-size: .74rem; color: var(--faint); }
.mk-val { text-align: right; font-weight: 700; white-space: nowrap; }
.mk-val small { font-weight: 500; color: var(--muted); font-size: .74rem; }
.mk-row.alt .mk-val { color: var(--warn); }
.mk-row.alt { box-shadow: inset 3px 0 0 var(--orange); border-radius: 4px 12px 12px 4px; }
.mk-trend { color: var(--faint); display: grid; place-items: center; }
@media (max-width: 420px) { .mk-row { grid-template-columns: minmax(0, 1fr) auto 16px; } .mk-row .spark { display: none; } }

.mk-detail .mk-big { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 8px 0 6px; }
.mk-detail .mk-value { font-size: 2.2rem; }
.chart-box { margin: 18px 0 8px; padding: 14px; border-radius: var(--radius); background: var(--bg); }
.sheet-sub { font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 18px 0 4px; }
.disclaimer { margin-top: 14px; }

/* ---------------------------------------------------------------------------
   Listas de registros
--------------------------------------------------------------------------- */
.list { display: grid; gap: 12px; }
.list-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 8px 0 12px; }
.list + .list-title { margin-top: 28px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.card-head { display: flex; gap: 14px; align-items: flex-start; }
.card-date {
  flex: none; width: 58px; display: flex; flex-direction: column; align-items: center; padding: 7px 4px;
  border-radius: 12px; background: var(--navy-soft); color: var(--navy); font-size: .72rem; font-weight: 700; text-transform: uppercase; line-height: 1.15;
}
@media (prefers-color-scheme: dark) { .card-date { color: var(--series-1); } }
.card-date b { font-size: 1.2rem; font-weight: 800; }
.card-date small { font-weight: 500; font-size: .66rem; opacity: .8; text-transform: none; }
.card-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; padding-top: 2px; }
.card-title strong { font-size: 1rem; overflow-wrap: anywhere; }
.card-body { margin: 14px 0 0; display: grid; gap: 10px; }
.card-body dt { font-size: .7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.card-body dd { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.file {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; max-width: 100%;
  border: 1px solid var(--line); border-radius: 999px; font-size: .84rem; font-weight: 600; text-decoration: none; color: var(--text);
}
.file .i { color: var(--orange); }
.file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file small { color: var(--faint); font-weight: 500; }
.file:hover { border-color: var(--orange); }

.empty {
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  padding: 48px 20px; color: var(--muted); border: 1.5px dashed var(--line); border-radius: var(--radius);
}
.empty .i.xl { color: var(--orange); }
.empty h3 { color: var(--text); font-size: 1.05rem; }
.empty p { max-width: 440px; }
.empty .btn { margin-top: 6px; }

.chart-panel { margin-bottom: 20px; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid line { stroke: var(--line); }
.chart text { fill: var(--faint); font: 500 11px var(--font); }
.chart .bar { fill: var(--navy-soft); }
.chart .bar.now { fill: var(--orange); }
@media (prefers-color-scheme: dark) { .chart .bar { fill: #2a4565; } }
.chart-empty { padding: 20px 0; }
.legend { display: flex; gap: 16px; font-size: .82rem; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
@media (max-width: 560px) { .chart text { font-size: 20px; } }

/* Tabela de resultados */
.results { margin-top: 14px; }
.results summary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: .84rem; font-weight: 600; color: var(--navy); list-style: none; }
@media (prefers-color-scheme: dark) { .results summary { color: var(--series-1); } }
.results summary::-webkit-details-marker { display: none; }
.results[open] summary .i { transform: rotate(90deg); }
.table-wrap { overflow-x: auto; margin-top: 10px; }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table-wrap th, .table-wrap td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-wrap thead th { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.table-wrap tr.group th { background: var(--surface-2); font-size: .8rem; font-weight: 700; }
.table-wrap td.num { white-space: nowrap; font-weight: 700; }
.table-wrap tr.alt td.num { color: var(--warn); }
.table-wrap tr.alt { background: var(--warn-soft); }

/* ---------------------------------------------------------------------------
   Diálogos (folha inferior no celular)
--------------------------------------------------------------------------- */
dialog {
  border: 0; padding: 0; width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  border-radius: 22px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog.narrow { width: min(480px, calc(100vw - 32px)); }
dialog.wide { width: min(940px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 20, 40, .5); backdrop-filter: blur(3px); }
dialog[open] { animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
dialog form, dialog .sheet { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.dlg-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 14px 24px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { flex: 1; font-size: 1.1rem; font-weight: 700; }
.dlg-body { padding: 20px 24px 8px; overflow-y: auto; }
.dlg-foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--line); }
.dlg-foot .left { margin-right: auto; }
@media (max-width: 640px) {
  dialog, dialog.narrow, dialog.wide {
    width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 22px 22px 0 0; max-height: 92vh;
  }
  dialog form, dialog .sheet { max-height: 92vh; }
  dialog[open] { animation: up .22s ease-out; }
  .dlg-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .dlg-foot .btn { flex: 1; }
  .dlg-foot .left { flex: 0 0 100%; order: 3; margin: 0; }
}
@keyframes up { from { transform: translateY(40px); opacity: .6; } }

.existing-files { display: grid; gap: 6px; margin-bottom: 10px; }
.existing-files div { display: flex; align-items: center; gap: 8px; font-size: .9rem; background: var(--surface-2); border-radius: 10px; padding: 4px 4px 4px 12px; }
.existing-files span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.existing-files .i { color: var(--orange); }

.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding-bottom: 16px; }
.quick {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 16px; text-align: left;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
}
.quick:hover:not(:disabled) { border-color: var(--orange); }
.quick:disabled { opacity: .45; cursor: not-allowed; }
.quick-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--navy-soft); color: var(--navy); margin-bottom: 10px; }
@media (prefers-color-scheme: dark) { .quick-ic { color: var(--series-1); } }
.quick strong { font-size: .95rem; }
.quick small { font-size: .78rem; color: var(--muted); }
.quick.featured { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; align-items: center; column-gap: 14px; background: var(--navy); border-color: var(--navy); color: #fff; }
.quick.featured .quick-ic { background: var(--orange); color: #1a0d00; margin: 0; grid-row: span 2; }
.quick.featured strong { flex: 1; }
.quick.featured small { color: rgba(255,255,255,.72); flex-basis: 100%; padding-left: 54px; margin-top: -8px; }

.people { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 6px; }
.person {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; text-align: left;
  border-radius: 14px; border: 1px solid var(--line); background: var(--surface);
}
.person span:not(.avatar) { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.person.on { border-color: var(--orange); background: var(--orange-soft); }
.person .i { color: var(--orange); }
.sheet-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sheet-actions .btn { flex: 1; }
.sheet-note { display: flex; align-items: center; gap: 6px; margin: 16px 0 18px; }

.importing { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 36px 28px 32px; }
.importing h2 { font-size: 1.2rem; font-weight: 800; }
.scan { position: relative; display: grid; place-items: center; width: 76px; height: 76px; border-radius: 20px; background: var(--navy); color: #fff; overflow: hidden; margin-bottom: 8px; }
.scan .i { width: 34px; height: 34px; }
.scan-line { position: absolute; left: 10px; right: 10px; height: 3px; border-radius: 3px; background: var(--orange); box-shadow: 0 0 12px var(--orange); animation: scan 1.6s ease-in-out infinite alternate; }
@keyframes scan { from { top: 14px; } to { top: 58px; } }
.steps { display: flex; gap: 6px; margin-top: 14px; }
.steps span { padding: 4px 10px; border-radius: 999px; background: var(--surface-2); font-size: .74rem; font-weight: 600; color: var(--faint); transition: .3s; }
.steps span.on { background: var(--orange-soft); color: var(--warn); }

.review-sum { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; margin-bottom: 18px; border-radius: 12px; background: var(--ok-soft); font-size: .9rem; }
.review-sum .i { color: var(--ok); margin-top: 1px; }
.edit-table { min-width: 700px; }
.edit-table input { padding: 7px 9px; font-size: .86rem; }
.edit-table td { padding: 4px; vertical-align: middle; }
.edit-table td small { display: block; font-size: .7rem; padding: 3px 2px 0; }
.edit-table td.c { text-align: center; }

#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 999px; font-size: .9rem; font-weight: 600;
  transition: .25s; pointer-events: none; z-index: 100; max-width: calc(100vw - 32px); box-shadow: var(--shadow-lg);
}
@media (prefers-color-scheme: dark) { #toast { background: var(--surface-2); color: var(--text); } }
@media (max-width: 899px) { #toast { bottom: calc(150px + env(safe-area-inset-bottom)); } }
#toast.show { opacity: 1; transform: translateX(-50%); }

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