/* Layout: cabeçalho fixo, conteúdo em coluna única (até 760px), barra de abas inferior. */
:root {
  --bg: #F1F5F6; --surface: #FFFFFF; --ink: #12262D; --muted: #55707A; --line: #DAE4E7;
  --accent: #0E6B7B; --accent-ink: #FFFFFF; --accent-soft: #DCEEF1;
  --money: #7A4E00; --money-soft: #FAEED0;
  --ok: #1E7446; --ok-soft: #DCF0E4; --warn: #94600A; --warn-soft: #FBEAC6; --bad: #AE362B; --bad-soft: #F8DDD9;
  --radius: 14px;
  --font-display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Atkinson Hyperlegible', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D1A1E; --surface: #15262B; --ink: #E7F0F2; --muted: #9DB4BC; --line: #26393F;
    --accent: #52C2D4; --accent-ink: #06262C; --accent-soft: #12383F;
    --money: #F2C46E; --money-soft: #382D12;
    --ok: #6FD49C; --ok-soft: #12321F; --warn: #F2C46E; --warn-soft: #382D12; --bad: #FF9084; --bad-soft: #3D1B17;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0D1A1E; --surface: #15262B; --ink: #E7F0F2; --muted: #9DB4BC; --line: #26393F;
  --accent: #52C2D4; --accent-ink: #06262C; --accent-soft: #12383F;
  --money: #F2C46E; --money-soft: #382D12;
  --ok: #6FD49C; --ok-soft: #12321F; --warn: #F2C46E; --warn-soft: #382D12; --bad: #FF9084; --bad-soft: #3D1B17;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body { font-family: var(--font-body); font-size: 16px; line-height: 1.4; -webkit-text-size-adjust: 100%; }
h1, h2, h3 { font-family: var(--font-display); margin: 0; text-wrap: balance; line-height: 1.15; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.ic { flex: none; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#app { max-width: 760px; margin: 0 auto; min-height: 100vh; padding-bottom: 88px; }
#hd { position: sticky; top: 0; z-index: 5; background: var(--accent); color: var(--accent-ink); padding: 12px 16px; display: flex; align-items: center; gap: 12px; min-height: 60px; }
#hd h1 { font-size: 22px; font-weight: 700; flex: 1; }
#hd .hbtn { background: transparent; border: 0; color: inherit; display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 10px; font-weight: 600; }
#hd .hbtn:hover { background: rgb(255 255 255 / .16); }
#main { padding: 14px 16px; display: flex; flex-direction: column; gap: 14px; }

#nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
#nav .in { max-width: 760px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); }
#nav button { background: none; border: 0; padding: 8px 2px 9px; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 12px; color: var(--muted); font-weight: 600; }
#nav button[aria-current="page"] { color: var(--accent); }
#nav button[aria-current="page"] .pill { background: var(--accent-soft); }
#nav .pill { padding: 3px 18px; border-radius: 999px; display: flex; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card h2 { font-size: 18px; }
.card.tan { background: var(--money-soft); border-color: transparent; }
.sec { font-family: var(--font-display); font-size: 15px; font-weight: 700; color: var(--muted); margin: 6px 2px 0; letter-spacing: .01em; }

.mnav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mnav .t { font-family: var(--font-display); font-size: 19px; font-weight: 700; text-align: center; flex: 1; }
.ibtn { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.ibtn.sm { width: 36px; height: 36px; border-radius: 10px; }
.ibtn.danger { color: var(--bad); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 10px 14px; font-weight: 700; min-height: 44px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.sm { min-height: 36px; padding: 6px 10px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }

.sum-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.sum-grid .k { font-size: 13px; color: var(--money); font-weight: 700; }
.sum-grid .big { font-family: var(--font-display); font-size: 26px; font-weight: 700; color: var(--ink); }
.sum-grid .r { text-align: right; }
.hr { border: 0; border-top: 1px solid color-mix(in srgb, var(--money) 25%, transparent); margin: 10px 0; }
.line3 { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.line3 b { font-variant-numeric: tabular-nums; }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dh { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); padding: 2px 0; }
.cell { min-height: 74px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 4px 3px; text-align: left; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.cell.out { visibility: hidden; border: 0; }
.cell .dn { font-size: 13px; font-weight: 700; display: flex; justify-content: space-between; padding: 0 2px; }
.cell.sun .dn, .cell.hol .dn { color: var(--bad); }
.cell.today { border: 2px solid var(--accent); }
.cell.gap { border-style: dashed; border-color: var(--warn); }
.chip { --c: var(--accent); font-size: 10.5px; line-height: 1.15; font-weight: 700; border-left: 3px solid var(--c); background: color-mix(in srgb, var(--c) 20%, var(--surface)); border-radius: 4px; padding: 2px 3px; white-space: nowrap; overflow: hidden; text-overflow: clip; }
.chip.falta { opacity: .55; text-decoration: line-through; }
.more { font-size: 10px; color: var(--muted); padding-left: 3px; }

.tile { display: grid; grid-template-columns: 62px 1fr auto; gap: 12px; align-items: center; }
.tile .sw { height: 56px; border-radius: 10px; border: 1.5px solid #12262D; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; color: #12262D; text-align: center; padding: 2px; }
.tile .nums { font-size: 13px; text-align: right; display: grid; gap: 2px; }
.tile .nums b { font-variant-numeric: tabular-nums; }
.stripe { border-left: 6px solid var(--c, var(--accent)); }

.pill-s { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 3px 10px; font-size: 13px; font-weight: 700; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.pill-s.ok { background: var(--ok-soft); color: var(--ok); }
.pill-s.warn { background: var(--warn-soft); color: var(--warn); }
.pill-s.bad { background: var(--bad-soft); color: var(--bad); }
.pill-s.mute { background: var(--bg); color: var(--muted); }

.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c, var(--accent)); display: inline-block; flex: none; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--c, var(--accent)); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 700; flex: none; }

.item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.item .ico { width: 46px; height: 46px; border-radius: 12px; background: var(--ok-soft); color: var(--ok); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.item .ico.blue { background: var(--accent-soft); color: var(--accent); }
.item .ico.warn { background: var(--warn-soft); color: var(--warn); }
.item .tt { font-weight: 700; font-size: 17px; }
.item.done { opacity: .72; }

.dose { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.dose:first-child { border-top: 0; }
.dose .tm { font-family: var(--font-display); font-weight: 700; font-size: 19px; }
.banner { border-radius: var(--radius); padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; font-weight: 600; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner.info { background: var(--accent-soft); color: var(--accent); }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.tabs button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 14px; font-weight: 700; white-space: nowrap; color: var(--muted); min-height: 40px; }
.tabs button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* formulários */
.fld { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.fld > label, .fld > .lb { font-size: 13px; font-weight: 700; color: var(--muted); }
input[type=text], input[type=number], input[type=time], input[type=date], input[type=month], input[type=tel], select, textarea {
  width: 100%; min-height: 44px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--bg); padding: 8px 10px; }
textarea { min-height: 84px; resize: vertical; }
input[type=color] { width: 56px; height: 44px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--bg); padding: 3px; }
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.g3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips label { position: relative; }
.chips input { position: absolute; opacity: 0; inset: 0; }
.chips span { display: inline-flex; align-items: center; justify-content: center; min-width: 46px; min-height: 40px; padding: 0 12px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--bg); font-weight: 700; color: var(--muted); }
.chips input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chips input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.hint { font-size: 13px; color: var(--muted); }

/* sheet */
#sheet-root .scrim { position: fixed; inset: 0; background: rgb(8 20 24 / .55); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
#sheet-root .sheet { background: var(--surface); width: 100%; max-width: 760px; max-height: 92vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
#sheet-root .sheet > header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#sheet-root .sheet h2 { font-size: 21px; }
.foot { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
@media (min-width: 700px) { #sheet-root .scrim { align-items: center; } #sheet-root .sheet { border-radius: 20px; } }

#toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 700; z-index: 40; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; text-align: center; }
#toast.on { opacity: 1; }

/* relatório */
.rep { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.rep h3 { font-size: 21px; color: var(--accent); }
.rep h4 { font-family: var(--font-display); font-size: 18px; color: var(--accent); margin: 0; display: flex; gap: 8px; align-items: center; }
.rep dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 8px; }
.rep dt { font-weight: 700; }
.rep dd { margin: 0; }
.rep hr { border: 0; border-top: 1px solid var(--line); margin: 0; }
.vitals { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.vital { background: var(--bg); border-radius: 12px; padding: 10px 12px; }
.vital .k { font-size: 13px; color: var(--muted); }
.vital .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.vital.flag { background: var(--warn-soft); }
.vital.flag .k { color: var(--warn); }

table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; color: var(--muted); padding: 4px 6px; }
table.t td { padding: 7px 6px; border-top: 1px solid var(--line); vertical-align: top; }
table.t td.r, table.t th.r { text-align: right; font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; }
.empty { text-align: center; padding: 22px 10px; color: var(--muted); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media (max-width: 420px) {
  .cell { min-height: 66px; padding: 3px 2px; }
  .chip { font-size: 9.5px; padding: 1px 2px; }
  .g3 { grid-template-columns: 1fr 1fr; }
}

/* servidor / papéis */
.item:disabled { cursor: default; opacity: 1; color: inherit; }
#hd .net { font-size: 12px; font-weight: 700; background: rgb(255 255 255 / .22); padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
input:disabled, textarea:disabled, select:disabled { opacity: .75; cursor: not-allowed; }
