:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --surface-2: #f8f7f4;
  --ink: #17212b;
  --muted: #667383;
  --line: #e4e1da;
  --accent: #0f626e;
  --accent-ink: #ffffff;
  --accent-soft: #e2f0f1;
  --gold: #c98a12;
  --ok: #1f7a4d;
  --ok-soft: #e3f3ea;
  --warn: #9a6400;
  --warn-soft: #fbf0d9;
  --bad: #b03434;
  --bad-soft: #fbe6e4;
  --weekend: #b03434;
  --shadow: 0 1px 2px rgba(23, 33, 43, .05), 0 6px 20px rgba(23, 33, 43, .05);
  --radius: 14px;
  --nav-w: 248px;
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10161c;
    --surface: #18212a;
    --surface-2: #1e2933;
    --ink: #e9eef2;
    --muted: #93a1af;
    --line: #2a3742;
    --accent: #45b3c0;
    --accent-ink: #072a2f;
    --accent-soft: #173a40;
    --gold: #e7b04a;
    --ok: #5cc592;
    --ok-soft: #173527;
    --warn: #e7b04a;
    --warn-soft: #3a2e12;
    --bad: #f08a80;
    --bad-soft: #3d1f1d;
    --weekend: #f08a80;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; }
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; word-break: break-all; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 16px; }
.brand img { width: 34px; height: 34px; }
.brand b { display: block; font-size: 15.5px; letter-spacing: -.01em; }
.brand span { font-size: 12px; color: var(--muted); }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 12px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--ink); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.side-foot { margin-top: auto; padding: 12px; border-top: 1px solid var(--line); font-size: 13px; }
.side-foot b { display: block; }
main { padding: 26px 30px 60px; max-width: 1180px; width: 100%; }
.tabbar { display: none; }

.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.head h1 { font-size: 25px; letter-spacing: -.02em; }
.head p { color: var(--muted); margin-top: 2px; }
.back { display: inline-flex; align-items: center; gap: 4px; font-size: 13.5px; margin-bottom: 8px; }

/* ---------- pieces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card, .card + .grid, .grid + .card, .grid + .grid { margin-top: 16px; }
.grid > .card, .grid > div > .card:first-child { margin-top: 0; }
.card h2 { font-size: 16px; margin-bottom: 2px; }
.card .sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g21 { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 31px; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; margin-top: 4px; }
.kpi .hint { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
a.kpi { color: inherit; display: block; }
a.kpi:hover { text-decoration: none; border-color: var(--accent); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); padding: 9px 14px; border-radius: 10px; font-weight: 600; cursor: pointer; min-height: 40px; white-space: nowrap; }
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); color: var(--accent-ink); }
.btn.danger { color: var(--bad); }
.btn.sm { min-height: 32px; padding: 5px 10px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: default; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.row.center { align-items: center; }
.spread { justify-content: space-between; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.grow { flex: 1 1 200px; }
.field label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
input, select, textarea { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; min-height: 40px; width: 100%; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.filters { margin-bottom: 16px; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.chip.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip.csv { border-style: dashed; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.time { font-variant-numeric: tabular-nums; font-weight: 600; }
.notice { border-radius: 12px; padding: 12px 14px; background: var(--warn-soft); color: var(--warn); font-size: 13.5px; margin-bottom: 16px; }
.notice.info { background: var(--accent-soft); color: var(--accent); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice b { display: block; margin-bottom: 2px; }
.empty { text-align: center; color: var(--muted); padding: 34px 12px; }

/* ---------- lists & tables ---------- */
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-top: 1px solid var(--line); color: inherit; }
.item:first-child { border-top: 0; }
a.item:hover { background: var(--surface-2); text-decoration: none; }
.item .grow { flex: 1; min-width: 0; }
.item .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { font-size: 12.5px; color: var(--muted); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.right { text-align: right; }
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.c, th.c { text-align: center; }
.weekend { color: var(--weekend); }
.times { display: flex; flex-wrap: wrap; gap: 5px; }
.day-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 12px; padding: 11px 4px; border-top: 1px solid var(--line); align-items: center; }
.day-row:first-child { border-top: 0; }
.day-row .d b { display: block; }
details.day { border-top: 1px solid var(--line); }
details.day:first-of-type { border-top: 0; }
details.day summary { cursor: pointer; padding: 12px 4px; display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 600; list-style: none; }
details.day summary::-webkit-details-marker { display: none; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 14px; }

/* ---------- charts (barras em CSS) ---------- */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 150px; }
.bars .bar { flex: 1; min-width: 0; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bars .bar.weekend { background: var(--gold); opacity: .75; }
.bars .bar.zero { background: var(--line); }
.bars .bar:hover { filter: brightness(1.15); }
.axis { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; background: var(--accent); }
.legend i.w { background: var(--gold); }
.hbar { display: grid; grid-template-columns: 120px minmax(0, 1fr) 44px; gap: 10px; align-items: center; font-size: 13.5px; padding: 4px 0; }
.hbar div { height: 12px; border-radius: 6px; background: var(--accent); min-width: 3px; }

/* ---------- misc ---------- */
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 30px 16px; text-align: center; cursor: pointer; background: var(--surface-2); }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop b { display: block; font-size: 16px; margin-bottom: 4px; }
.drop input { display: none; }
.kv { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; word-break: break-word; }
.feed { display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; }
.feed > div { display: grid; grid-template-columns: 8px minmax(0, 1fr); gap: 10px; align-items: baseline; }
.feed .dot.ok { color: var(--ok); } .feed .dot.warn { color: var(--warn); } .feed .dot.error { color: var(--bad); } .feed .dot.info { color: var(--muted); }
pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; overflow-x: auto; font-size: 12px; margin: 8px 0 0; white-space: pre-wrap; word-break: break-all; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--bg); padding: 11px 14px; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.25); font-size: 14px; }
.toast.bad { background: var(--bad); color: #fff; }
.loading { color: var(--muted); padding: 30px 0; text-align: center; }

.profile { display: flex; gap: 18px; align-items: flex-start; }
.profile .grow { flex: 1; min-width: 0; }
.photo { width: 92px; height: 92px; border-radius: 22px; object-fit: cover; flex: none; background: var(--accent-soft); border: 1px solid var(--line); cursor: zoom-in; box-shadow: var(--shadow); }
.photo.none { display: grid; place-items: center; font-size: 28px; font-weight: 700; color: var(--accent); cursor: default; }
.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .82); z-index: 60; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center; padding: 20px; cursor: zoom-out; color: #fff; font-size: 14px; text-align: center; }
.lightbox img { max-width: min(92vw, 520px); max-height: 78vh; border-radius: 18px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background:
  radial-gradient(900px 500px at 15% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent),
  radial-gradient(700px 400px at 100% 110%, color-mix(in srgb, var(--gold) 18%, transparent), transparent), var(--bg); }
.login form { width: min(400px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 28px; }
.login h1 { font-size: 22px; letter-spacing: -.02em; }
.login img { width: 46px; height: 46px; }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  .shell { display: block; }
  .side { display: none; }
  main { padding: 18px 16px calc(92px + env(safe-area-inset-bottom)); }
  .head h1 { font-size: 21px; }
  .g4, .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g2, .g21 { grid-template-columns: minmax(0, 1fr); }
  .g3 > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .kpi .value { font-size: 26px; }
  .card { padding: 15px; }
  .table-wrap { margin: 0 -15px; padding: 0 15px; }
  .day-row { grid-template-columns: minmax(0, 1fr) auto; }
  .day-row .times { grid-column: 1 / -1; order: 3; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .kv dd { margin-bottom: 8px; }
  .hide-m { display: none !important; }
  .profile { gap: 12px; }
  .photo { width: 68px; height: 68px; border-radius: 18px; }
  .row .btn { flex: 1 1 auto; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 20; }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 5px 2px; border: 0; background: none; border-radius: 10px; font-weight: 600; cursor: pointer; }
  .tabbar a.on, .tabbar button.on { color: var(--accent); }
  .tabbar a:hover { text-decoration: none; }
  .sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30; display: flex; align-items: flex-end; }
  .sheet { background: var(--surface); width: 100%; border-radius: 20px 20px 0 0; padding: 10px 12px calc(18px + env(safe-area-inset-bottom)); max-height: 82vh; overflow-y: auto; }
  .sheet .nav a { padding: 13px 12px; }
  #toasts { bottom: calc(84px + env(safe-area-inset-bottom)); left: 16px; right: 16px; max-width: none; }
}
@media (min-width: 901px) { .sheet-bg { display: none; } .only-m { display: none !important; } }
@media print { .side, .tabbar, .filters, .btn { display: none !important; } main { padding: 0; } .card { box-shadow: none; } }
