:root {
  --bg: #f6f4f0;
  --card: #ffffff;
  --ink: #23201c;
  --muted: #6b645b;
  --line: #ddd7cd;
  --accent: #a8440a;
  --accent-ink: #ffffff;
  --accent-soft: #fbeadd;
  --ok: #1d6b3a;
  --ok-soft: #e2f2e7;
  --warn: #8a5a00;
  --warn-soft: #fbf0d3;
  --bad: #a3231c;
  --bad-soft: #fae3e1;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3, p { margin: 0; }
h2 { font-size: 1.05rem; margin-bottom: 10px; }
.site-head { font-size: .92rem; color: var(--accent); margin: 12px 0 6px; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px 16px; text-align: center; color: var(--muted); }

.top { position: sticky; top: 0; z-index: 5; background: var(--accent); color: var(--accent-ink); padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; max-width: 760px; margin: 0 auto; }
.brand { font-weight: 700; font-size: 1.05rem; }
.top-actions { display: flex; align-items: center; gap: 6px; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge.on { background: var(--ok-soft); color: var(--ok); }
.badge.off { background: var(--warn-soft); color: var(--warn); }
.link { background: none; border: 0; color: inherit; text-decoration: underline; padding: 8px 10px; min-height: 44px; min-width: 44px; cursor: pointer; font-size: 1rem; font-weight: 600; }

main { max-width: 760px; margin: 0 auto; padding: 14px 16px calc(84px + env(safe-area-inset-bottom)); display: grid; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; min-width: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat b { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .82rem; }
.muted { color: var(--muted); font-size: .88rem; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

.alert { border-radius: 10px; padding: 10px 12px; font-size: .92rem; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.secret { background: var(--accent-soft); color: var(--ink); overflow-wrap: anywhere; }
.alert.secret code { font-size: 1.1rem; font-weight: 700; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 10px 0; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.list > li:first-child { border-top: 0; padding-top: 0; }
.list > li:last-child { padding-bottom: 0; }
.list .main { min-width: 0; overflow-wrap: anywhere; }
.list .side { text-align: right; flex-shrink: 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

form { display: grid; gap: 12px; }
label { display: grid; gap: 4px; font-size: .88rem; font-weight: 600; }
label small { font-weight: 400; color: var(--muted); }
input, select, textarea { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid #a89f92; border-radius: 8px; background: #fff; font-size: 16px; font-weight: 400; }
input[type=checkbox] { width: 22px; min-height: 22px; height: 22px; accent-color: var(--accent); flex-shrink: 0; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid #e8914f; outline-offset: 1px; }
.check { display: flex; flex-direction: row; align-items: center; gap: 10px; font-weight: 600; min-height: 44px; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; border: 0; padding: 0; margin: 0; }
.choice legend { font-size: .88rem; font-weight: 600; padding: 0; margin-bottom: 4px; }
.choice label { display: flex; align-items: center; justify-content: center; min-height: 46px; border: 1px solid #a89f92; border-radius: 8px; background: #fff; cursor: pointer; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.choice input:checked + span { font-weight: 700; }
.choice label:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); }
.choice label:has(input:focus-visible) { outline: 3px solid #e8914f; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two > * { min-width: 0; }
details summary { cursor: pointer; font-weight: 600; font-size: .92rem; min-height: 32px; }
details[open] summary { margin-bottom: 10px; }

.btn { min-height: 46px; padding: 10px 16px; border: 0; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-weight: 700; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.btn.small { min-height: 38px; padding: 6px 12px; font-size: .88rem; font-weight: 600; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid #a89f92; }
.btn.danger { background: #fff; color: var(--bad); border: 1px solid var(--bad); }
.btn:disabled { opacity: .6; cursor: default; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { padding: 7px 8px; text-align: left; border-top: 1px solid var(--line); white-space: nowrap; }
thead th { border-top: 0; color: var(--muted); font-weight: 600; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
td.up { color: var(--bad); font-weight: 700; }

.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav button { background: none; border: 0; min-height: 60px; padding: 6px 2px; cursor: pointer; color: var(--muted); font-size: .84rem; font-weight: 600; border-top: 3px solid transparent; }
.nav button[aria-current=page] { color: var(--accent); border-top-color: var(--accent); background: var(--accent-soft); font-weight: 800; }
.fast input:not([type=checkbox]):not([type=radio]), .fast select { min-height: 56px; font-size: 1.15rem; }
.fast label { font-size: 1rem; }
.fast .choice label { min-height: 56px; font-size: 1.05rem; }
.btn.huge { min-height: 64px; font-size: 1.25rem; }
.more { display: grid; gap: 12px; }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.quick .btn { min-height: 52px; overflow-wrap: anywhere; }
.quick .btn.on { background: var(--accent-soft); border-color: var(--accent); font-weight: 700; }
.big-alert { font-size: 1.1rem; font-weight: 700; padding: 14px; }
.list > li.stack { flex-direction: column; align-items: stretch; }
.steps { margin: 8px 0 0; padding-left: 22px; display: grid; gap: 10px; }
.ok-step { color: var(--ok); }
.stack-actions { display: grid; gap: 8px; margin-top: 12px; }
td.wrap { white-space: normal; min-width: 180px; }
.hide { display: none; }
.card p + p { margin-top: 8px; }
.summary { padding: 10px 12px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); font-size: .95rem; }
.period { font-weight: 700; }
.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0; }
.presets .btn { padding-inline: 4px; }
table.compact th, table.compact td { padding: 7px 4px; }
table.compact td:first-child { white-space: normal; }
.unit { position: relative; display: block; }
.unit input { padding-right: 30px; }
.unit i { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--muted); font-weight: 600; pointer-events: none; }
.fast { scroll-margin-top: 72px; gap: 10px; }
.fast .btn.huge { position: sticky; bottom: 8px; z-index: 2; }
.fix { margin-top: 6px; }
.fix summary { font-size: .85rem; color: var(--muted); }
.fix[open] { padding-bottom: 4px; }
.fix form, .fix .row-actions, .fix > button { margin-top: 6px; }
.segments { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.segments .btn { padding-inline: 2px; }
.row-link { display: grid; gap: 2px; width: 100%; min-height: 52px; padding: 8px 0; background: none; border: 0; text-align: left; cursor: pointer; font-size: 1rem; }
.guide-more h3 { font-size: .98rem; margin: 16px 0 6px; }
.stats .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
.stats { grid-template-columns: 1fr 1fr; }
input[type=date] { min-width: 0; max-width: 100%; padding-inline: 8px; font-size: 15px; }
@media (min-width: 720px) { .only-narrow { display: none; } .stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); } .stats .stat:last-child:nth-child(odd) { grid-column: auto; } }
@media (max-width: 719px) { .only-wide { display: none; } }
@media (min-width: 1000px) {
  main.wide { max-width: 1100px; }
  main.t-resumo { grid-template-columns: 1fr 1fr; align-items: start; }
  main.t-resumo > .full { grid-column: 1 / -1; }
  .top-row { max-width: 1100px; }
}
.picked { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--accent); border-radius: 8px; background: var(--accent-soft); }
.link.dark { color: var(--ink); }
.small-link { font-size: .85rem; min-height: 44px; padding: 8px 0; text-align: left; justify-self: start; font-weight: 500; }
.picker { display: grid; gap: 10px; }
.picker input { min-height: 56px; font-size: 1.1rem; }
.fast-sub { gap: 12px; }
.list > li.stack { flex-direction: column; align-items: stretch; }
.login { max-width: 400px; margin: 0 auto; padding: 48px 16px; display: grid; gap: 16px; }
.login h1 { color: var(--accent); font-size: 1.5rem; }

#toast { position: fixed; left: 16px; right: 16px; bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 10; display: none; max-width: 560px; margin: 0 auto; padding: 12px 14px; border-radius: 10px; background: #2b2723; color: #fff; font-size: .92rem; box-shadow: 0 4px 16px rgb(0 0 0 / .25); }
#toast.show { display: block; }
#toast.bad { background: var(--bad); }
