:root {
  color-scheme: dark;
  --bg: #0b111c; --panel: #141e2d; --line: #2b3b52; --text: #f1f6fc;
  --muted: #a6b6ca; --mint: #54e3d1; --ink: #062824;
  font: 16px/1.5 "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, textarea { font: inherit; }
button { border: 1px solid transparent; border-radius: .8rem; cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible, summary:focus-visible, textarea:focus-visible { outline: 3px solid var(--mint); outline-offset: 3px; }
button:disabled { opacity: .48; cursor: default; }
h1, h2, p, dl, dd { margin: 0; }
h1 { font-size: clamp(1.6rem, 5vw, 2rem); font-weight: 730; line-height: 1.14; letter-spacing: -.035em; }
h2 { font-size: 1.3rem; }
small { font-size: .8rem; color: var(--muted); }
.shell { max-width: 44rem; margin: auto; padding: max(1rem, env(safe-area-inset-top)) 1rem max(1.25rem, env(safe-area-inset-bottom)); }
.home { max-width: 28rem; margin: auto; padding: clamp(1rem, 7dvh, 4rem) 0 1rem; text-align: center; }
.home-actions, .report-actions { display: grid; gap: .75rem; margin: 1.5rem auto 0; }
.primary, .secondary, .quiet, .danger-button { min-height: 3rem; padding: .65rem .85rem; font-weight: 650; }
.primary { background: var(--mint); color: var(--ink); }
.secondary { background: var(--panel); border-color: var(--line); color: var(--text); }
.quiet { background: transparent; color: var(--muted); }
.danger { color: #ffb1ad; }
.danger-button { background: #a22d38; color: #fff; }
.panel, .procedure, .identity, .report-loss, .report-metrics, .history-item { border: 1px solid var(--line); border-radius: .9rem; background: var(--panel); }
.fields { display: grid; gap: .35rem; padding: .85rem; text-align: left; }
.fields input, textarea { width: 100%; min-height: 2.9rem; background: #0a1422; color: var(--text); border: 1px solid var(--line); border-radius: .6rem; padding: .55rem .65rem; }
.fields label:not(:first-child) { margin-top: .35rem; }
.fields small { float: right; }
.count-modes { display: grid; gap: .5rem; margin-top: .65rem; }
.automatic-option:disabled {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
  gap: .35rem .65rem; color: var(--muted); opacity: 1;
}
.automatic-option span, .history-item .history-mode {
  border: 1px solid var(--line); border-radius: 1rem;
  padding: .15rem .5rem; font-size: .8rem; font-weight: 600;
}
.toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: .35rem; }
.toolbar .settings-button { display: grid; place-items: center; justify-self: end; width: 2.75rem; min-height: 2.75rem; padding: 0; color: var(--text); }
.settings { width: 19rem; }
.settings-options { display: grid; gap: .5rem; margin: .9rem 0; }
.settings .toggle { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.settings [data-state] { font-size: .8rem; }
.settings form button { width: 100%; }
.toggle { min-height: 2.75rem; padding: .4rem .65rem; color: var(--muted); background: var(--panel); border-color: var(--line); font-size: .875rem; }
.toggle[aria-pressed="true"] { background: #123632; border-color: #31645f; color: #aefff1; }
.counter-header { position: sticky; z-index: 2; top: 0; background: var(--bg); padding: .25rem 0 .65rem; }
.counter-header h1 { margin: .2rem 0 .65rem; }
.procedure { margin-bottom: .65rem; }
.procedure summary { cursor: pointer; padding: .52rem .7rem; font-size: .9rem; color: var(--muted); }
.procedure[open] .fields { max-height: 45dvh; overflow: auto; padding-top: .15rem; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: .3rem; border: 1px solid var(--line); border-radius: .85rem; background: var(--panel); padding: .55rem .35rem; text-align: center; }
.metrics div + div { border-left: 1px solid var(--line); }
.metrics dt { font-size: .82rem; color: var(--muted); }
.metrics .transection-label { white-space: nowrap; }
.metrics dd { font-size: clamp(1.36rem, 5.7vw, 1.85rem); font-weight: 750; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.tile { position: relative; --tone: #8eb8ff; --surface:#182f51; }
.tile.f2 { --tone:#a1ecc4; --surface:#123b2d; }
.tile.f3 { --tone:#d0bbff; --surface:#332450; }
.tile.f4 { --tone:#ffd4a4; --surface:#483018; }
.tile.discard { --tone:#ffb3ae; --surface:#491e29; grid-column: 1 / -1; }
.add { width: 100%; position: relative; min-height: clamp(6.3rem, 16dvh, 9rem); padding: .65rem 3.35rem .65rem .8rem; text-align: left; background: var(--surface); border: 1px solid color-mix(in srgb, var(--tone) 38%, var(--surface)); color: var(--tone); display: grid; align-content: center; }
.add-label { font-weight: 760; font-size: 1.2rem; line-height: 1.1; }
.add-note { font-size: .83rem; }
.add-value { font-size: clamp(1.65rem, 7vw, 2.35rem); font-weight: 760; line-height: 1.2; font-variant-numeric: tabular-nums; color: #fff; overflow-wrap: anywhere; }
.discard .add { min-height: 4.7rem; grid-template-columns: 1fr auto; align-items: center; gap: .7rem; }
.discard .add-label { font-size: 1rem; }
.minus { position: absolute; top: .45rem; right: .45rem; width: 2.65rem; height: 2.65rem; padding: 0; background: #0b111caa; border: 1px solid color-mix(in srgb, var(--tone) 40%, var(--surface)); color: var(--tone); font-weight: 700; font-size: .92rem; }
.add:active, .minus:active { filter: brightness(1.3); }
.flash { animation: flash .23s ease-out; }
@keyframes flash { from { filter: brightness(1.65); } to { filter: brightness(1); } }
@media (prefers-reduced-motion: reduce) { .flash { animation: none; } }
.counter-actions { display: grid; gap: .35rem; margin-top: .6rem; }
.back { margin-bottom: .5rem; }
.muted { color: var(--muted); margin-top: .7rem; }
.history-list { display: grid; margin-top: .75rem; gap: .65rem; }
.history-item { display: grid; text-align: left; min-width: 0; padding: .8rem; gap: .15rem; color: var(--text); width: 100%; }
.history-item span { color: var(--muted); overflow-wrap: anywhere; }
.history-item strong { font-size: 1.02rem; }
.history-heading { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem .65rem; }
.history-item .history-mode { color: var(--mint); }
.report-heading { padding-bottom: .65rem; }
.identity, .report-loss, .report-metrics { display: grid; gap: .35rem; padding: .8rem; margin: .75rem 0; }
.identity div, .report-loss div, .report-metrics div { display: flex; justify-content: space-between; gap: .5rem; }
.identity dd { text-align: right; overflow-wrap: anywhere; min-width: 0; }
.report-metrics dd, .report-loss dd { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
table { width:100%; border-collapse: collapse; margin: 1rem 0; font-variant-numeric: tabular-nums; }
caption { text-align: left; font-weight: 700; padding-bottom: .35rem; }
th, td { padding: .48rem .2rem; border-bottom: 1px solid var(--line); text-align: right; }
th:first-child { text-align: left; }
thead th { color: var(--muted); font-size: .85rem; }
.notice, .storage-warning { padding: .6rem .75rem; background: var(--panel); border: 1px solid var(--line); border-radius: .65rem; margin-top: .7rem; }
.storage-warning { color: #ffb1ad; border-color: #7a4547; }
#copy-fallback { margin-top: .75rem; }
.confirm { max-width: min(25rem, calc(100% - 2rem)); border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 1rem; padding: 1rem; }
.confirm::backdrop { background: #000b; }
.confirm p { color: var(--muted); margin: .55rem 0 1rem; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
@media (max-width: 360px) { .shell { padding-inline: .7rem; } .tiles { gap: .5rem; } .add { padding-right: 2.9rem; } .minus { width: 2.3rem; } }
@media print {
  @page { margin: 14mm; }
  :root, body { color-scheme: light; background: #fff; color: #142238; }
  .shell { max-width: none; padding: 0; }
  .shell > :not(#report), #report > :not(#print-report), .confirm { display: none !important; }
  #print-report { break-inside: avoid; }
  .identity, .report-loss, .report-metrics { background: transparent; border-color: #bac4d2; }
  thead th { color: #244961; }
  th, td { border-color: #bac4d2; }
}
.home-brand { display: block; width: min(11rem, 60vw); height: auto; margin: 0 auto 1.4rem; }
.home-footer { margin-top: clamp(2.2rem, 11dvh, 5.5rem); }
.home-footer a { color: var(--mint); text-underline-offset: .24em; }
.counter-brand { display: block; width: clamp(4.4rem, 27vw, 11.5rem); height: auto; }
.toolbar .home-link { justify-self: start; min-height: 2.75rem; padding: .25rem .3rem; font-size: .85rem; text-decoration: underline; text-underline-offset: .2em; }
.report-heading { text-align: center; }
.report-brand { display: block; margin: 0 auto .9rem; width: min(10rem, 50vw); height: auto; }
.export-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.export-actions button { min-width: 0; padding-inline: .4rem; }
.export-actions .whatsapp { color: #b0f5d1; border-color: #39735a; }
