:root {
  --bg:#f4f3ef; --card:#ffffff; --card2:#f8f7f4; --ink:#1b1e22; --muted:#666b73; --line:#e2dfd8;
  --accent:#1f5f8b; --accent-ink:#ffffff; --accent-soft:#e3eef6; --ok:#2e7d4f; --ok-soft:#e2f2e8;
  --warn:#9a6200; --warn-soft:#fbf0d9; --bad:#b3261e; --bad-soft:#fbe4e2; --chip:#eceae5;
  --tab-h:62px; --safe-b:env(safe-area-inset-bottom, 0px); --radius:14px;
}
@media (prefers-color-scheme: dark) { :root {
  --bg:#0f1418; --card:#182027; --card2:#1d262e; --ink:#e9e7e2; --muted:#9aa3ab; --line:#2a343d;
  --accent:#6fb3e0; --accent-ink:#0b1720; --accent-soft:#1c3446; --ok:#6fcf97; --ok-soft:#163327; --warn:#e3b04b;
  --warn-soft:#3a2d12; --bad:#f28b82; --bad-soft:#3c1d1b; --chip:#25303a;
} }
* { box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html { -webkit-text-size-adjust:100%; }
body { margin:0; font:16px/1.55 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif; background:var(--bg); color:var(--ink);
  padding-bottom:calc(var(--tab-h) + var(--safe-b) + 12px); }
a { color:var(--accent); }
h1 { font-size:22px; line-height:1.25; margin:6px 0 6px; } h2 { font-size:18px; margin:22px 0 8px; } h3 { font-size:16px; margin:14px 0 4px; }
p { margin:6px 0; }
.muted { color:var(--muted); } .small { font-size:14px; } .tiny { font-size:12.5px; }
.ok { color:var(--ok); } .warn { color:var(--warn); } .bad { color:var(--bad); }

/* Topo */
.top { position:sticky; top:0; z-index:20; display:flex; align-items:center; gap:14px; padding:10px 16px;
  padding-top:calc(10px + env(safe-area-inset-top, 0px)); background:var(--card); border-bottom:1px solid var(--line); }
.brand { display:flex; align-items:center; gap:8px; font-weight:700; text-decoration:none; color:var(--ink); font-size:17px; }
.brand img { border-radius:7px; }
.topnav { display:none; gap:4px 16px; flex-wrap:wrap; }
.topnav a { text-decoration:none; color:var(--muted); padding:4px 0; } .topnav a.on { color:var(--ink); font-weight:600; }
.aistate { margin-left:auto; font-size:12px; padding:3px 9px; border-radius:99px; background:var(--chip); color:var(--muted); white-space:nowrap; }
.aistate.on { background:var(--ok-soft); color:var(--ok); }

/* Barra inferior (celular) */
.tabbar { position:fixed; left:0; right:0; bottom:0; z-index:25; display:flex; background:var(--card); border-top:1px solid var(--line);
  height:calc(var(--tab-h) + var(--safe-b)); padding-bottom:var(--safe-b); }
.tabbar a { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; text-decoration:none;
  color:var(--muted); font-size:11.5px; position:relative; }
.tabbar svg { width:24px; height:24px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.tabbar a.on { color:var(--accent); font-weight:600; }
.tabbar .badge { position:absolute; top:6px; left:calc(50% + 6px); }
@media (min-width: 900px) {
  .topnav { display:flex; } .tabbar { display:none; } body { padding-bottom:40px; }
  .actionbar { bottom:16px !important; max-width:900px; margin:0 auto; border-radius:var(--radius); border:1px solid var(--line) !important; }
}
.badge:empty { display:none; }
.badge { display:inline-block; min-width:18px; height:18px; line-height:18px; text-align:center; background:var(--bad); color:#fff;
  border-radius:99px; padding:0 5px; font-size:11px; font-weight:700; font-style:normal; }

main { max-width:900px; margin:0 auto; padding:12px 16px 24px; }
.loading { padding:40px 0; text-align:center; color:var(--muted); }

/* Cartões */
.card { background:var(--card); border:1px solid var(--line); border-radius:var(--radius); padding:14px 16px; margin:10px 0; }
.card.tap { cursor:pointer; transition:transform .08s; } .card.tap:active { transform:scale(.99); }
.card.sel { border-color:var(--accent); box-shadow:0 0 0 1.5px var(--accent) inset; }
.card h3 { margin:6px 0 4px; font-size:17px; line-height:1.3; }
.clamp2 { display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.clamp3 { display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden; }
.row { display:flex; flex-wrap:wrap; gap:8px; align-items:center; } .spread { justify-content:space-between; } .nowrap { flex-wrap:nowrap; }
.grow { flex:1; min-width:0; }
.chip { display:inline-block; background:var(--chip); border-radius:99px; padding:2px 10px; font-size:12.5px; color:var(--muted); white-space:nowrap; }
.chip.ok { background:var(--ok-soft); color:var(--ok); } .chip.warn { background:var(--warn-soft); color:var(--warn); }
.chip.accent { background:var(--accent-soft); color:var(--accent); } .chip.bad { background:var(--bad-soft); color:var(--bad); }
.demo { background:var(--warn-soft); color:var(--warn); border-radius:6px; padding:1px 7px; font-size:12px; font-weight:600; }

/* Botões: alvos de toque de 44px */
button, .btn { font:inherit; font-size:15px; min-height:44px; border:1px solid var(--line); background:var(--card); color:var(--ink);
  border-radius:12px; padding:9px 14px; cursor:pointer; text-decoration:none; display:inline-flex; align-items:center; justify-content:center; gap:6px; }
button.primary, .btn.primary { background:var(--accent); border-color:var(--accent); color:var(--accent-ink); font-weight:600; }
button.ghost { background:transparent; border-color:transparent; color:var(--accent); }
button.danger { color:var(--bad); }
button:disabled { opacity:.5; cursor:default; }
.btns { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-top:10px; }
.btns.three { grid-template-columns:1fr 1fr 1fr; }
.full { width:100%; }
.selbtn { width:44px; height:44px; min-height:44px; padding:0; border-radius:50%; flex:none; font-size:20px; }
.card.sel .selbtn { background:var(--accent); color:var(--accent-ink); border-color:var(--accent); }

/* Barra de ações fixa acima da barra inferior */
.actionbar { position:fixed; left:0; right:0; bottom:calc(var(--tab-h) + var(--safe-b)); z-index:24; background:var(--card);
  border-top:1px solid var(--line); padding:10px 16px; display:flex; gap:8px; }
.actionbar > * { flex:1; }
.actionbar[hidden], [hidden] { display:none !important; }
.aistate:empty { display:none; }
body.has-actionbar { padding-bottom:calc(var(--tab-h) + var(--safe-b) + 80px); }

/* Seções que abrem e fecham */
details.sec { background:var(--card); border:1px solid var(--line); border-radius:var(--radius); margin:10px 0; overflow:hidden; }
details.sec > summary { list-style:none; cursor:pointer; padding:14px 16px; min-height:52px; display:flex; align-items:center; gap:10px; font-weight:600; font-size:16px; }
details.sec > summary::-webkit-details-marker { display:none; }
details.sec > summary::after { content:''; margin-left:auto; width:9px; height:9px; border-right:2px solid var(--muted); border-bottom:2px solid var(--muted);
  transform:rotate(45deg); transition:transform .15s; flex:none; }
details.sec[open] > summary::after { transform:rotate(-135deg); }
details.sec > .body { padding:0 16px 14px; }
details.sec > summary .chip { font-weight:400; }
details.inline > summary { cursor:pointer; color:var(--accent); padding:8px 0; min-height:40px; }

.kv { display:grid; gap:10px; } .kv > div > b { display:block; font-size:13px; color:var(--muted); font-weight:600; margin-bottom:1px; }
@media (min-width:640px) { .kv { grid-template-columns:1fr 1fr; } }
.list { list-style:none; padding:0; margin:6px 0; } .list li { padding:8px 0; border-bottom:1px solid var(--line); } .list li:last-child { border:none; }
ul.dots { padding-left:20px; margin:6px 0; } ul.dots li { margin:4px 0; }
.tag-fato { color:var(--ok); font-weight:600; } .tag-interp { color:var(--accent); font-weight:600; } .tag-hip { color:var(--warn); font-weight:600; }
.notice { border-radius:12px; padding:10px 14px; margin:10px 0; font-size:14.5px; }
.notice.warn { background:var(--warn-soft); color:var(--ink); } .notice.ok { background:var(--ok-soft); } .notice.info { background:var(--accent-soft); }
.notice.bad { background:var(--bad-soft); }
.strip { display:flex; align-items:center; gap:10px; background:var(--accent-soft); border-radius:12px; padding:10px 14px; margin:10px 0; text-decoration:none; color:var(--ink); }
.strip b { flex:1; }

/* Formulários */
label { display:block; margin:12px 0 4px; font-size:14px; color:var(--muted); }
textarea, input, select { font:inherit; font-size:16px; width:100%; padding:11px 12px; border:1px solid var(--line); border-radius:12px; background:var(--card); color:var(--ink); }
textarea.script { min-height:55vh; line-height:1.65; font-size:17px; }
.seg { display:flex; gap:6px; overflow-x:auto; padding-bottom:4px; margin:10px 0; scrollbar-width:none; }
.seg::-webkit-scrollbar { display:none; }
.seg button { flex:none; min-height:38px; border-radius:99px; padding:6px 14px; font-size:14px; }
.seg button.on { background:var(--ink); color:var(--bg); border-color:var(--ink); }
.filters { display:flex; gap:8px; overflow-x:auto; scrollbar-width:none; padding:2px 0 6px; } .filters::-webkit-scrollbar { display:none; }
.filters button { flex:none; min-height:36px; border-radius:99px; padding:4px 13px; font-size:14px; }
.filters button.on { background:var(--accent); color:var(--accent-ink); border-color:var(--accent); }

/* Folha inferior (perguntas e confirmações) */
.sheet-bg { position:fixed; inset:0; background:rgba(0,0,0,.45); z-index:40; display:flex; align-items:flex-end; justify-content:center; }
.sheet { background:var(--card); width:100%; max-width:560px; max-height:92vh; overflow:auto; border-radius:20px 20px 0 0;
  padding:8px 18px calc(18px + var(--safe-b)); animation:up .18s ease-out; }
.sheet .grab { width:40px; height:5px; border-radius:9px; background:var(--line); margin:4px auto 10px; }
@media (min-width:640px) { .sheet-bg { align-items:center; } .sheet { border-radius:20px; } }
@keyframes up { from { transform:translateY(30px); opacity:.6; } to { transform:none; opacity:1; } }

#toast { position:fixed; left:50%; transform:translateX(-50%); bottom:calc(var(--tab-h) + var(--safe-b) + 14px); background:var(--ink); color:var(--bg);
  padding:10px 16px; border-radius:12px; display:none; z-index:60; max-width:92vw; font-size:14.5px; text-align:center; }
@media (min-width:900px) { #toast { bottom:24px; } }

.empty { text-align:center; padding:30px 10px; color:var(--muted); }
.login { max-width:380px; margin:12vh auto 0; text-align:center; }
.login img { border-radius:18px; }
pre.snap { white-space:pre-wrap; font:inherit; font-size:15px; background:var(--card2); border-radius:10px; padding:12px; }
.cmp { display:grid; gap:10px; } @media (min-width:700px) { .cmp { grid-template-columns:1fr 1fr; } }
.progress { height:4px; border-radius:4px; background:var(--chip); overflow:hidden; } .progress i { display:block; height:100%; background:var(--accent); }
