:root {
  --paper: #F4F3EF;
  --sheet: #FFFFFF;
  --graphite: #2A2C2E;
  --muted: #6B6E72;
  --line: #DAD8D2;
  --soft: #ECEAE4;
  --alert: #B42318;
  --done: #2E6A4E;
  --wide: 'wdth' 100;
  --tabbar: 64px;
  font-family: 'Archivo', system-ui, sans-serif;
  color: var(--graphite);
  background: var(--paper);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--paper); }
body { font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--graphite); outline-offset: 2px; }

.shell { max-width: 720px; margin: 0 auto; padding: 0 16px calc(var(--tabbar) + 32px + env(safe-area-inset-bottom)); }

/* Cabeçalho */
.top { padding: 28px 0 8px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.top h1 { margin: 0; font-size: 34px; line-height: 1; font-weight: 800; font-variation-settings: 'wdth' 75; letter-spacing: -0.01em; }
.top .who { font-size: 14px; color: var(--muted); text-align: right; }
.top .who button { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 14px; }
.sub { margin: 4px 0 20px; color: var(--muted); font-size: 15px; }

/* Grupos e linhas de prazo */
.group { margin: 24px 0 0; }
.group h2 { margin: 0 0 4px; font-size: 15px; font-weight: 700; color: var(--muted); }
.group.urgent h2 { color: var(--alert); }

.row { display: grid; grid-template-columns: 76px 1fr; gap: 14px; align-items: start; width: 100%; text-align: left;
  background: none; border: 0; border-top: 1px solid var(--line); padding: 14px 0; cursor: pointer; }
.row:last-child { border-bottom: 1px solid var(--line); }
.row:hover .what { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }

.count { font-variation-settings: 'wdth' 62; font-weight: 800; line-height: 0.85; font-size: 54px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.count small { display: block; font-size: 12px; font-weight: 600; letter-spacing: 0; line-height: 1.3; margin-top: 4px; font-variation-settings: 'wdth' 100; color: var(--muted); }
.count.word { font-size: 30px; line-height: 0.95; padding-top: 6px; }
.count.alert { color: var(--alert); }
.count.alert small { color: var(--alert); }
.count.none { color: var(--line); }

.what { font-weight: 650; font-size: 16px; line-height: 1.3; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px; font-size: 13.5px; color: var(--muted); }
.tag { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--soft); color: var(--graphite); }
.tag.check { background: #FBE9E7; color: var(--alert); }

.empty { padding: 28px 0; color: var(--muted); border-top: 1px solid var(--line); }
.empty strong { color: var(--graphite); display: block; font-size: 17px; margin-bottom: 2px; }

/* Busca e filtros */
.search { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--sheet); font-size: 16px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 4px; }
.chip { border: 1px solid var(--line); background: var(--sheet); border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer; }
.chip[aria-pressed='true'] { background: var(--graphite); color: var(--paper); border-color: var(--graphite); }

.item { display: block; width: 100%; text-align: left; background: none; border: 0; border-top: 1px solid var(--line); padding: 12px 0; cursor: pointer; }
.item:last-child { border-bottom: 1px solid var(--line); }
.item .what { font-weight: 600; }

/* Barra inferior */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--paper); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); }
.tabs nav { max-width: 720px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); height: var(--tabbar); }
.tabs button { background: none; border: 0; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; position: relative; }
.tabs button[aria-current='page'] { color: var(--graphite); }
.tabs button[aria-current='page']::before { content: ''; position: absolute; top: -1px; left: 22%; right: 22%; height: 3px; background: var(--graphite); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 3px; border-radius: 9px; background: var(--alert); color: #fff; font-size: 11px; line-height: 18px; }

.fab { position: fixed; right: max(16px, calc(50% - 344px)); bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom)); z-index: 11;
  background: var(--graphite); color: var(--paper); border: 0; border-radius: 999px; padding: 14px 20px; font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 18px rgba(42, 44, 46, 0.25); }

/* Painel de detalhe */
.veil { position: fixed; inset: 0; background: rgba(42, 44, 46, 0.35); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--sheet); width: 100%; max-width: 720px; max-height: 92vh; overflow: auto; border-radius: 16px 16px 0 0;
  padding: 20px 20px calc(24px + env(safe-area-inset-bottom)); animation: rise 180ms ease-out; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
.sheet header { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: start; }
.sheet h3 { margin: 0; font-size: 20px; line-height: 1.25; }
.close { background: var(--soft); border: 0; border-radius: 999px; width: 36px; height: 36px; cursor: pointer; font-size: 18px; }
.facts { margin: 16px 0; display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 14.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.block { margin: 14px 0; font-size: 14.5px; white-space: pre-wrap; }
.block h4 { margin: 0 0 4px; font-size: 13.5px; color: var(--muted); font-weight: 600; }
.links { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 12px 0; font-size: 14.5px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.btn { border: 1px solid var(--graphite); background: var(--sheet); border-radius: 10px; padding: 10px 14px; font-weight: 650; cursor: pointer; }
.btn.primary { background: var(--graphite); color: var(--paper); }
.btn.done { border-color: var(--done); color: var(--done); }
.btn:disabled { opacity: 0.5; cursor: wait; }

label.field { display: block; margin: 12px 0; font-size: 14px; color: var(--muted); }
label.field input, label.field select, label.field textarea { display: block; width: 100%; margin-top: 4px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--sheet); font-size: 16px; color: var(--graphite); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login form { width: 100%; max-width: 360px; }
.login .mark { font-size: 46px; font-weight: 800; font-variation-settings: 'wdth' 70; line-height: 0.95; margin: 0 0 6px; color: var(--graphite); }
.login p { color: var(--muted); margin: 0 0 18px; }
.err { color: var(--alert); font-size: 14.5px; min-height: 20px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar) + 80px); background: var(--graphite); color: var(--paper);
  padding: 10px 16px; border-radius: 10px; font-size: 14.5px; z-index: 30; }

@media (max-width: 420px) {
  .row { grid-template-columns: 64px 1fr; }
  .count { font-size: 46px; }
  .facts { grid-template-columns: 112px 1fr; }
  .two { grid-template-columns: 1fr; }
}
