:root {
  --bg: #0b0b0c; --bg2: #111113; --card: #17171a; --card2: #1e1e22; --border: #2a2a30; --border2: #36363e;
  --text: #f4f4f5; --muted: #9a9aa6; --dim: #6b6b76;
  --accent: #FFC107; --accent2: #ffd54f; --accent-ink: #171200;
  --danger: #ff5c5c; --ok: #4ade80; --warn: #fb923c; --info: #60a5fa;
  --radius: 14px; --shadow: 0 10px 30px rgba(0,0,0,.35);
  --sidebar: 236px; --bottomnav: 64px;
}
* { box-sizing: border-box; }
html { color-scheme: dark; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif; min-height: 100dvh; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent2); }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 17px; }
h3 { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); } .dim { color: var(--dim); }
.small { font-size: 13px; }
.accent { color: var(--accent); } .danger { color: var(--danger); } .ok { color: var(--ok); } .warn { color: var(--warn); }
.mono { font-variant-numeric: tabular-nums; }

/* shell */
.shell { display: flex; min-height: 100dvh; }
.sidebar { width: var(--sidebar); flex: 0 0 var(--sidebar); background: var(--bg2); border-right: 1px solid var(--border); padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100dvh; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 19px; color: var(--text); font-weight: 600; padding: 4px 8px; }
.brand b { color: var(--accent); font-weight: 800; }
.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-weight: 900; font-size: 20px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--muted); font-weight: 500; }
.sidebar nav a svg { width: 20px; height: 20px; fill: currentColor; opacity: .85; }
.sidebar nav a:hover { background: var(--card); color: var(--text); }
.sidebar nav a.active { background: rgba(255,193,7,.12); color: var(--accent); }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; padding: 0 6px; }
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.avatar { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--card2); color: var(--accent); font-weight: 700; border: 1px solid var(--border2); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 22px 28px 8px; }
.topbar h1 { font-size: 24px; }
.who-mobile { display: none; color: var(--muted); font-size: 14px; }
.content { padding: 12px 28px 40px; display: flex; flex-direction: column; gap: 18px; }
.bottomnav { display: none; }
.sheet { display: none; }

/* cards & grid */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(12, 1fr); }
.col-3 { grid-column: span 3; } .col-4 { grid-column: span 4; } .col-6 { grid-column: span 6; } .col-8 { grid-column: span 8; } .col-12 { grid-column: span 12; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card.pad-0 { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head.in { padding: 16px 18px 0; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--dim); font-size: 12.5px; }
.stat.hi .value { color: var(--accent); }

/* lists & tables */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-top: 1px solid var(--border); }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .meta { color: var(--muted); font-size: 12.5px; }
.list .amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.list li.clickable { cursor: pointer; }
.list li.clickable:hover { background: var(--card2); }
.empty { color: var(--dim); padding: 18px; text-align: center; font-size: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; padding: 10px 14px; border-bottom: 1px solid var(--border); }
td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.clickable { cursor: pointer; } tr.clickable:hover td { background: var(--card2); }
.table-wrap { overflow-x: auto; }

/* badges & buttons */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .02em; border: 1px solid transparent; }
.badge.open { color: var(--info); background: rgba(96,165,250,.12); }
.badge.overdue { color: var(--danger); background: rgba(255,92,92,.12); }
.badge.paid { color: var(--ok); background: rgba(74,222,128,.12); }
.badge.skipped { color: var(--muted); background: rgba(154,154,166,.12); }
.badge.accent { color: var(--accent); background: rgba(255,193,7,.12); }
.badge.muted { color: var(--muted); background: rgba(154,154,166,.12); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--border2); background: var(--card2); color: var(--text); font-weight: 600; font-size: 14px; cursor: pointer; line-height: 1.2; white-space: nowrap; }
.btn:hover { border-color: var(--dim); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent2); }
.btn.danger { color: var(--danger); border-color: rgba(255,92,92,.35); background: rgba(255,92,92,.08); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 4px; }
button.link:hover { color: var(--accent); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

/* forms */
form.inline { display: inline; }
.form { display: grid; gap: 12px; }
.form.cols { grid-template-columns: 1fr 1fr; }
.form .full { grid-column: 1 / -1; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 600; }
input, select, textarea { width: 100%; background: var(--bg2); border: 1px solid var(--border2); color: var(--text); border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 15px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(255,193,7,.5); outline-offset: 0; border-color: var(--accent); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
label.check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text); font-weight: 500; }
input[type=range] { accent-color: var(--accent); padding: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.filters label.field { min-width: 140px; }
.filters input, .filters select { padding: 8px 10px; font-size: 14px; }

/* flash */
.flash { margin: 8px 28px 0; padding: 12px 14px; border-radius: 10px; font-weight: 600; font-size: 14px; }
.flash.ok { background: rgba(74,222,128,.12); color: var(--ok); border: 1px solid rgba(74,222,128,.25); }
.flash.erro { background: rgba(255,92,92,.12); color: var(--danger); border: 1px solid rgba(255,92,92,.25); }

/* dialog */
dialog.modal { border: 1px solid var(--border2); background: var(--card); color: var(--text); border-radius: 16px; padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog.modal::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(2px); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: space-between; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.modal-foot .right { display: flex; gap: 8px; margin-left: auto; }

/* fab */
.fab { display: none; }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .dow { color: var(--dim); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; text-align: center; padding: 4px 0; }
.cal .day { min-height: 92px; background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 6px; display: flex; flex-direction: column; gap: 3px; }
.cal .day.out { opacity: .35; }
.cal .day.today { border-color: var(--accent); }
.cal .day .n { font-size: 12.5px; color: var(--muted); font-weight: 700; }
.cal .day.today .n { color: var(--accent); }
.cal .ev { font-size: 11.5px; line-height: 1.25; padding: 3px 6px; border-radius: 6px; background: rgba(255,193,7,.14); color: var(--accent2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.cal .ev.task { background: rgba(96,165,250,.14); color: var(--info); }
.cal .ev.bill { background: rgba(255,92,92,.14); color: var(--danger); }
.cal .ev.past { opacity: .5; }
.daylist { display: none; }
.month-nav { display: flex; align-items: center; gap: 8px; }
.month-nav .cur { font-weight: 700; min-width: 150px; text-align: center; }

/* charts */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 8px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; min-width: 0; }
.bars .bar i { display: block; width: 100%; max-width: 46px; background: var(--accent); border-radius: 6px 6px 2px 2px; opacity: .85; transition: opacity .15s; }
.bars .bar:hover i { opacity: 1; }
.bars .bar.cur i { background: var(--accent2); opacity: 1; }
.bars .bar b { font-size: 11px; color: var(--muted); font-weight: 600; }
.bars .bar small { font-size: 10.5px; color: var(--dim); white-space: nowrap; }
.hbar { display: grid; grid-template-columns: 130px 1fr auto; gap: 10px; align-items: center; font-size: 13.5px; padding: 5px 0; }
.hbar .track { height: 10px; background: var(--bg2); border-radius: 999px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--accent); border-radius: 999px; }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* login */
body.bare { display: grid; place-items: center; padding: 16px; }
.login { width: min(400px, 100%); background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 28px; box-shadow: var(--shadow); }
.login .brand { justify-content: center; margin-bottom: 20px; font-size: 24px; }

/* Zé status */
.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; }
.status-dot.open { background: var(--ok); box-shadow: 0 0 0 4px rgba(74,222,128,.15); }
.status-dot.closed { background: var(--danger); }
.status-dot.connecting { background: var(--warn); }
.qr { background: #fff; padding: 12px; border-radius: 12px; display: inline-block; }
.chat-preview { background: #0f1a12; border: 1px solid #1f3a26; border-radius: 12px; padding: 12px 14px; font-size: 14px; white-space: pre-wrap; }

/* responsive */
@media (max-width: 1100px) {
  .col-3 { grid-column: span 6; } .col-4 { grid-column: span 6; } .col-8 { grid-column: span 12; }
}
@media (max-width: 900px) {
  :root { --sidebar: 0px; }
  .sidebar { display: none; }
  .topbar { padding: 16px 16px 4px; }
  .topbar h1 { font-size: 21px; }
  .who-mobile { display: inline; }
  .content { padding: 10px 16px calc(var(--bottomnav) + 28px + env(safe-area-inset-bottom)); gap: 14px; }
  .flash { margin: 8px 16px 0; }
  .col-4, .col-6, .col-8 { grid-column: span 12; }
  .col-3 { grid-column: span 6; }
  .card { padding: 14px; }
  .stat .value { font-size: 20px; }
  td, th { padding: 9px 10px; }
  .btn.sm { padding: 6px 9px; font-size: 12.5px; }
  .form.cols { grid-template-columns: 1fr; }
  .bottomnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--bottomnav) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: rgba(17,17,19,.96); backdrop-filter: blur(12px); border-top: 1px solid var(--border); z-index: 30; }
  .bottomnav a, .bottomnav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 600; background: none; border: 0; font-family: inherit; padding: 6px 0; cursor: pointer; }
  .bottomnav svg { width: 22px; height: 22px; fill: currentColor; }
  .bottomnav .active { color: var(--accent); }
  .sheet[open] { display: block; }
  .sheet { border: 0; background: transparent; padding: 0; width: 100vw; max-width: 100vw; position: fixed; inset: auto 0 0 0; margin: 0; height: auto; max-height: 100dvh; }
  .sheet::backdrop { background: rgba(0,0,0,.55); }
  .sheet-body { background: var(--card); border-radius: 18px 18px 0 0; padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 4px; border-top: 1px solid var(--border2); }
  .sheet-item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-radius: 10px; color: var(--text); font-weight: 600; font-size: 15px; background: none; border: 0; width: 100%; text-align: left; font-family: inherit; cursor: pointer; }
  .sheet-item svg { width: 20px; height: 20px; fill: var(--accent); }
  .sheet-item:hover { background: var(--card2); }
  .sheet-item.danger { color: var(--danger); } .sheet-item.muted { color: var(--muted); justify-content: center; }
  .fab { display: grid; place-items: center; position: fixed; right: 18px; bottom: calc(var(--bottomnav) + 18px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); border: 0; font-size: 30px; font-weight: 800; box-shadow: 0 8px 24px rgba(255,193,7,.35); z-index: 25; cursor: pointer; }
  .hide-mobile { display: none !important; }
  .cal { display: none; }
  .daylist { display: block; }
  .daylist .dh { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; padding: 12px 18px 4px; }
  .daylist .dh.today { color: var(--accent); }
  th.opt, td.opt { display: none; }
  .hbar { grid-template-columns: 90px 1fr auto; }
}
@media (min-width: 901px) { .hide-desktop { display: none !important; } }
