:root {
  --teal: #0F9F95; --teal-600: #0B8279; --teal-50: #E6F6F4; --teal-100: #C9EEEA;
  --ink: #1F2933; --ink-2: #3E4C59; --muted: #6B7785; --line: #E4E8EC;
  --bg: #F5F7F8; --card: #FFFFFF; --red: #D64545; --red-50: #FDECEC; --amber: #B7791F; --amber-50: #FDF4E3;
  --green: #138A5A; --green-50: #E5F5EE;
  --r: 18px; --r-sm: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 4px 16px rgba(16,24,40,.06);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  --tabbar-h: 64px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); }
body { min-height: 100vh; font-size: 16px; line-height: 1.45; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* Barra superior */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 4px;
  padding: calc(10px + var(--safe-t)) 16px 10px; background: rgba(245,247,248,.86);
  -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid transparent;
}
.topbar h1 { font-size: 20px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { border: 0; background: none; color: var(--teal); width: 36px; height: 36px; margin-left: -8px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn:active { background: var(--teal-50); }

main { max-width: 640px; margin: 0 auto; padding: 8px 16px calc(var(--tabbar-h) + var(--safe-b) + 28px); outline: none; }
main > * + * { margin-top: 14px; }
main.view-enter { animation: entrar .24s ease both; }
@keyframes entrar { from { opacity: 0; transform: translateY(6px); } }

/* Navegação inferior */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(255,255,255,.92); -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: #8A96A3; font-size: 11px; font-weight: 600; }
.tabbar svg { width: 24px; height: 24px; transition: transform .2s ease; }
.tabbar a.active { color: var(--teal); }
.tabbar a.active svg { transform: translateY(-1px) scale(1.06); }
.tabbar a:active svg { transform: scale(.9); }

/* Cartões */
.card { background: var(--card); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); display: block; }
.card h3 { font-size: 16px; margin-bottom: 12px; }
a.card, .btn { transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
a.card:active { transform: scale(.985); }
.ico { width: 22px; height: 22px; color: var(--teal); flex: none; }
.ico-lg { width: 40px; height: 40px; padding: 8px; border-radius: 12px; background: var(--teal-50); }
.ico-tile { width: 48px; height: 48px; padding: 12px; border-radius: 14px; background: var(--teal-50); }
.eyebrow { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.eyebrow.light { color: rgba(255,255,255,.85); }
.lead { color: var(--muted); }
.section-title { font-size: 15px; color: var(--ink-2); margin: 22px 2px 10px !important; }

/* Início */
.greet p { color: var(--muted); font-weight: 600; }
.greet h2 { font-size: 24px; line-height: 1.2; margin-top: 4px; }
.feature { position: relative; overflow: hidden; color: #fff; padding: 22px;
  background: radial-gradient(120% 140% at 100% 0%, #2DD4BF 0%, var(--teal) 45%, #0B6E68 100%); }
.feature::after { content: ""; position: absolute; right: -40px; bottom: -60px; width: 180px; height: 180px; border-radius: 50%; background: rgba(255,255,255,.08); }
.feature .ico-feature { position: absolute; right: 20px; top: 20px; width: 44px; height: 44px; padding: 10px; border-radius: 14px; background: rgba(255,255,255,.18); color: #fff; }
.feature h3 { font-size: 21px; margin: 10px 0 6px; padding-right: 56px; }
.feature p { opacity: .92; margin-bottom: 16px; max-width: 34ch; }
.shortcuts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 0 !important; }
.shortcut { display: flex; flex-direction: column; gap: 10px; font-weight: 600; font-size: 14px; }

/* Ferramentas */
.tool-card { display: flex; align-items: center; gap: 14px; }
.tool-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tool-txt b { font-size: 16px; }
.tool-txt small { color: var(--muted); font-size: 13.5px; }
.cat { font-size: 12px; font-weight: 700; color: var(--teal-600); text-transform: uppercase; letter-spacing: .05em; }
.pill { font-style: normal; background: var(--teal); color: #fff; border-radius: 99px; padding: 1px 8px; font-size: 10.5px; margin-left: 4px; }
.chev { width: 18px; height: 18px; color: #A7B1BC; flex: none; }
.soon { border: 1.5px dashed var(--line); box-shadow: none; background: transparent; display: flex; flex-direction: column; gap: 2px; color: var(--muted); }
.tool-intro { display: flex; gap: 14px; align-items: flex-start; }
.tool-intro h2 { font-size: 18px; } .tool-intro p { color: var(--muted); font-size: 14.5px; margin-top: 2px; }

/* Lista */
.list { padding: 4px 0; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 12px 18px; }
.list-item + .list-item { border-top: 1px solid var(--line); }
.list-item div { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.list-item small { font-size: 13px; color: var(--ink-2); }
.list-item small.muted { color: var(--muted); font-size: 12px; }
.empty { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 32px 20px; }
.empty p { color: var(--muted); margin-bottom: 8px; }

/* Botões */
.btn { appearance: none; border: 0; border-radius: 14px; padding: 13px 18px; font: inherit; font-weight: 650; font-size: 15px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .6; }
.btn-primary { background: var(--teal); color: #fff; box-shadow: 0 6px 14px -6px rgba(15,159,149,.6); }
.btn-primary:active { background: var(--teal-600); }
.btn-ghost { background: var(--teal-50); color: var(--teal-600); }
.btn-light { background: #fff; color: var(--teal-600); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger-ghost { background: var(--red-50); color: var(--red); }
.btn-sm { min-height: 36px; padding: 8px 14px; font-size: 14px; border-radius: 11px; }
.btn-block { width: 100%; }
.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.row { display: flex; gap: 10px; } .row > .btn { flex: 1; }

/* Formulário */
.form-group-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 6px 0 10px; }
.form-group-title:not(:first-child) { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.field { display: block; margin-bottom: 14px; }
.lbl { display: block; font-weight: 600; font-size: 14.5px; margin-bottom: 6px; }
.req { font-style: normal; font-weight: 600; font-size: 11px; color: var(--teal-600); background: var(--teal-50); padding: 1px 6px; border-radius: 6px; margin-left: 4px; }
.input-wrap { display: flex; align-items: center; background: #F7F9FA; border: 1.5px solid var(--line); border-radius: var(--r-sm); transition: border-color .15s, box-shadow .15s, background .15s; }
.input-wrap:focus-within { border-color: var(--teal); background: #fff; box-shadow: 0 0 0 4px rgba(15,159,149,.12); }
.prefix { padding-left: 14px; color: var(--muted); font-weight: 600; font-size: 15px; }
.input-wrap input, .name-input { flex: 1; width: 100%; border: 0; background: transparent; padding: 13px 14px; font: inherit; font-size: 17px; color: var(--ink); outline: none; min-width: 0; font-variant-numeric: tabular-nums; }
.name-input { border: 1.5px solid var(--line); border-radius: var(--r-sm); background: #fff; font-size: 16px; }
.name-input:focus { border-color: var(--teal); }
.hint { display: block; color: var(--muted); font-size: 12.5px; margin-top: 5px; }
.err { display: block; color: var(--red); font-size: 13px; font-weight: 600; }
.field.invalid .input-wrap { border-color: var(--red); background: var(--red-50); }
.field.invalid .hint { display: none; }

/* Relatório */
.report > * + * { margin-top: 14px; }
.print-head { display: none; }
.banner-demo { background: var(--amber-50); color: var(--amber); border: 1px solid #F3D9A4; border-radius: var(--r-sm); padding: 10px 14px; font-weight: 600; font-size: 14px; }
.hero-result { color: #fff; background: linear-gradient(135deg, #1F2933, #334155); }
.hero-result .eyebrow { color: rgba(255,255,255,.7); }
.hero-result .big { font-size: 34px; font-weight: 750; letter-spacing: -.02em; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.hero-result.pos .big { color: #5EEAD4; } .hero-result.neg .big { color: #FCA5A5; }
.hero-result .sub { color: rgba(255,255,255,.85); font-size: 14.5px; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kpi { background: var(--card); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi strong { font-size: 19px; font-variant-numeric: tabular-nums; word-break: break-word; }
.kpi small { font-size: 12px; color: var(--muted); }
.tag { font-style: normal; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 6px; border-radius: 6px; white-space: nowrap; }
.tag-dado { background: #EEF1F4; color: var(--ink-2); }
.tag-calc { background: var(--teal-50); color: var(--teal-600); }
.tag-est { background: var(--amber-50); color: var(--amber); }
.chart { display: flex; gap: 18px; align-items: center; }
.chart svg { width: 132px; height: 132px; flex: none; }
.chart circle { transition: stroke-width .2s; }
.legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.legend li { display: grid; grid-template-columns: 10px 1fr auto; column-gap: 8px; align-items: center; font-size: 13px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.legend span { min-width: 0; }
.legend small { grid-column: 2 / 4; color: var(--muted); font-size: 12px; }
.obs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; counter-reset: o; }
.obs li { border-radius: var(--r-sm); padding: 12px 14px 12px 44px; position: relative; background: #F4F6F8; counter-increment: o; }
.obs li::before { content: counter(o); position: absolute; left: 12px; top: 12px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--ink-2); color: #fff; }
.obs-positivo { background: var(--green-50) !important; } .obs-positivo::before { background: var(--green) !important; }
.obs-alerta { background: var(--red-50) !important; } .obs-alerta::before { background: var(--red) !important; }
.obs b { font-size: 14.5px; } .obs p { font-size: 14px; color: var(--ink-2); margin-top: 2px; }
.note ul { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 13.5px; display: flex; flex-direction: column; gap: 6px; }
.inputs-list { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; margin: 0 0 14px; font-size: 14.5px; }
.inputs-list dt { color: var(--muted); } .inputs-list dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.danger h3 { color: var(--red); } .danger p { margin-bottom: 14px; }
.foot { font-size: 12.5px; text-align: center; padding: 0 12px; }

/* Aviso de atualização e toast */
.update-bar { position: fixed; left: 12px; right: 12px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px); z-index: 40; max-width: 616px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--ink); color: #fff; padding: 10px 10px 10px 16px; border-radius: 16px; box-shadow: 0 10px 30px rgba(0,0,0,.25); font-weight: 600; font-size: 14.5px; animation: up .3s ease; }
.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 50;
  background: rgba(31,41,51,.94); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; transition: all .25s ease; max-width: calc(100% - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@keyframes up { from { transform: translateY(16px); opacity: 0; } }

@media (min-width: 720px) {
  main { padding-top: 20px; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 520px) { .chart { flex-direction: column; align-items: stretch; } .chart svg { align-self: center; width: 150px; height: 150px; } }
@media (max-width: 340px) { .kpis { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Impressão / PDF */
@media print {
  @page { margin: 14mm; }
  body { background: #fff; font-size: 12px; }
  .topbar, .tabbar, .update-bar, .toast, .no-print, .form, .tool-intro, .sticky-actions { display: none !important; }
  main { padding: 0; max-width: none; }
  .print-head { display: block; border-bottom: 2px solid var(--teal); padding-bottom: 8px; }
  .print-head h2 { font-size: 20px; } .print-head p { color: var(--muted); }
  .card, .kpi { box-shadow: none; border: 1px solid var(--line); break-inside: avoid; }
  .hero-result { background: #fff !important; color: var(--ink); }
  .hero-result .eyebrow, .hero-result .sub { color: var(--ink-2); }
  .hero-result.pos .big { color: var(--green); } .hero-result.neg .big { color: var(--red); }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
