:root {
  --bg: #f6f5f2; --panel: #fff; --side: #efeee9; --side-hover: #e4e2db; --line: #e3e1da; --line-2: #d4d1c8;
  --ink: #1d1c1a; --ink-2: #55524b; --ink-3: #8a867c;
  --accent: #3b5bdb; --accent-soft: #e8edfd; --accent-ink: #2b47b8;
  --ok: #2b8a3e; --ok-soft: #e6f4ea; --warn: #b8650f; --warn-soft: #fdf0dc; --bad: #c92a2a; --bad-soft: #fde8e8;
  --radius: 12px; --shadow: 0 1px 2px rgba(30,25,15,.06), 0 4px 16px rgba(30,25,15,.05);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
/* temas: branco (fundo todo branco) e escuro */
[data-mode=white] { --bg: #ffffff; --side: #f7f7f8; --side-hover: #eeeef0; --line: #ececee; --line-2: #dcdce0; }
[data-mode=dark] { --bg: #121417; --panel: #1b1e23; --side: #16191d; --side-hover: #23272e; --line: #2a2f37; --line-2: #3a404a; --ink: #e8e9ec; --ink-2: #b4b8c0; --ink-3: #8a909b;
  --ok: #4ade80; --ok-soft: #13301f; --warn: #f5a524; --warn-soft: #3a2a10; --bad: #f87171; --bad-soft: #3b1a1a; --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark; }
[data-mode=dark] .tbl tr.click:hover td { background: #20242a; }
[data-mode=dark] .toast { background: #2a2f37; }
[data-mode=dark] .modal-bg, [data-mode=dark] .popup { background: rgba(0,0,0,.6); }
.logo-img { height: 40px; max-width: 170px; object-fit: contain; display: block; }
.logo-img.lg { height: 52px; max-width: 220px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 34px; height: 34px; border-radius: 10px; border: 2px solid transparent; cursor: pointer; position: relative; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.swatch.on { border-color: var(--ink); } .swatch.on::after { content: '✓'; color: #fff; position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.theme-prev { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: grid; grid-template-columns: 70px 1fr; height: 92px; }
.switch { position: relative; display: inline-block; vertical-align: middle; width: 40px; height: 22px; flex: none; } .switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line-2); border-radius: 99px; transition: .15s; cursor: pointer; } .switch span::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--accent); } .switch input:checked + span::before { transform: translateX(18px); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.02rem; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--ink-3); } .small { font-size: .86rem; } .tiny { font-size: .76rem; } .nowrap { white-space: nowrap; } .right { text-align: right; }
.hidden { display: none !important; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }

/* layout */
.shell { display: grid; grid-template-columns: 256px 1fr; height: 100vh; }
.side { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; align-items: center; gap: 10px; padding: 18px 16px 12px; }
.side-head b { font-size: 1.02rem; display: block; line-height: 1.2; } .side-head span { font-size: .76rem; color: var(--ink-3); }
.logo { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.side-scroll { overflow-y: auto; flex: 1; padding: 4px 10px 12px; }
.nav-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); padding: 12px 10px 4px; font-weight: 600; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 9px; color: var(--ink); font-size: .93rem; width: 100%; text-align: left; border: 0; background: none; cursor: pointer; }
.nav-item:hover { background: var(--side-hover); text-decoration: none; }
.nav-item.active { background: var(--panel); box-shadow: 0 1px 2px rgba(0,0,0,.06); font-weight: 600; }
.nav-item .count { margin-left: auto; background: var(--bad); color: #fff; font-size: .7rem; border-radius: 99px; padding: 0 7px; font-weight: 600; }
.side-foot { border-top: 1px solid var(--line); padding: 10px; }
.who { display: flex; gap: 10px; align-items: center; padding: 4px 10px; font-size: .86rem; }
.who b { display: block; font-weight: 600; line-height: 1.2; } .who span { color: var(--ink-3); font-size: .78rem; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; font-weight: 650; font-size: .8rem; flex: none; }
.main { min-width: 0; overflow-y: auto; }
.topbar { display: none; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.page { max-width: 1120px; margin: 0 auto; padding: 28px 28px 80px; }
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head > div:first-child { flex: 1; min-width: 220px; }
.page-head p { margin: 0; color: var(--ink-2); }
.crumb { font-size: .84rem; color: var(--ink-3); margin-bottom: 4px; } .crumb a { color: var(--ink-3); }

/* componentes */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; flex: 1; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .row.end { justify-content: flex-end; } .grow { flex: 1; }
.kpi { padding: 16px 18px; }
.kpi .lbl { font-size: .8rem; color: var(--ink-3); font-weight: 500; }
.kpi .val { font-size: 1.65rem; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .8rem; color: var(--ink-2); margin-top: 3px; }
.up { color: var(--ok); } .down { color: var(--bad); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--panel); cursor: pointer; font-weight: 550; font-size: .9rem; white-space: nowrap; color: var(--ink); }
.btn:hover { background: var(--bg); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; } .btn.primary:hover { filter: brightness(.94); }
.btn.danger { color: var(--bad); } .btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.sm { padding: 5px 10px; font-size: .82rem; border-radius: 8px; } .btn.ghost { border-color: transparent; background: none; } .btn.ghost:hover { background: var(--side-hover); }
.btn:disabled { opacity: .55; cursor: default; } .btn.block { width: 100%; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: .74rem; font-weight: 600; background: var(--side); color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.bad { background: var(--bad-soft); color: var(--bad); } .badge.warn { background: var(--warn-soft); color: var(--warn); } .badge.info { background: var(--accent-soft); color: var(--accent-ink); }
.note { padding: 12px 14px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-ink); font-size: .9rem; }
.note.warn { background: var(--warn-soft); color: var(--warn); } .note.bad { background: var(--bad-soft); color: var(--bad); } .note.ok { background: var(--ok-soft); color: var(--ok); }
.empty { text-align: center; padding: 36px 16px; color: var(--ink-3); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 550; white-space: nowrap; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.seg { display: inline-flex; background: var(--side); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 7px; cursor: pointer; font-size: .86rem; color: var(--ink-2); }
.seg button.active { background: var(--panel); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* tabelas */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { text-align: left; font-weight: 600; color: var(--ink-3); font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; } .tbl tr.click:hover td { background: #faf9f6; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl td.act { text-align: right; white-space: nowrap; }

/* formulários */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: .84rem; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.field > span em { font-style: normal; color: var(--bad); }
.field small { display: block; color: var(--ink-3); font-size: .78rem; margin-top: 4px; }
.inp, select.inp, textarea.inp { width: 100%; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--panel); outline: none; }
.inp:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.inp { min-height: 90px; resize: vertical; }
.check { display: flex; gap: 9px; align-items: flex-start; font-size: .9rem; cursor: pointer; margin-bottom: 10px; } .check input { margin-top: 4px; }
.fgrid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0 14px; }
.fgrid .c1 { grid-column: span 1; } .fgrid .c2 { grid-column: span 2; } .fgrid .c3 { grid-column: span 3; } .fgrid .c4 { grid-column: span 4; } .fgrid .c6 { grid-column: span 6; }
.section-t { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 650; margin: 8px 0 10px; grid-column: 1 / -1; }
.drop { border: 1.5px dashed var(--line-2); border-radius: 10px; padding: 14px; display: flex; align-items: center; gap: 12px; cursor: pointer; background: var(--bg); }
.drop:hover { border-color: var(--accent); } .drop.done { border-style: solid; border-color: var(--ok); background: var(--ok-soft); }
.drop input { display: none; } .drop .ic { width: 38px; height: 38px; border-radius: 9px; background: var(--panel); display: grid; place-items: center; color: var(--accent); flex: none; }

/* modal, toast, popup */
.modal-bg { position: fixed; inset: 0; background: rgba(20,18,14,.42); display: grid; place-items: center; z-index: 50; padding: 18px; animation: fade .15s; }
.modal { background: var(--panel); border-radius: 14px; width: min(560px, 100%); max-height: calc(100vh - 36px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { width: min(820px, 100%); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; } .modal-head h2 { margin: 0; flex: 1; font-size: 1.1rem; }
.modal-body { padding: 18px 20px; overflow-y: auto; } .modal-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #1d1c1a; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: .9rem; box-shadow: 0 6px 20px rgba(0,0,0,.2); animation: rise .2s; max-width: 90vw; }
.toast.bad { background: var(--bad); }
.popup { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(20,18,14,.5); padding: 18px; animation: fade .2s; }
.popup .box { background: var(--panel); border-radius: 16px; width: min(480px, 100%); overflow: hidden; box-shadow: 0 24px 70px rgba(0,0,0,.3); animation: rise .25s; }
.popup .bar { height: 6px; background: var(--accent); } .popup.aviso .bar { background: var(--warn); } .popup.urgente .bar { background: var(--bad); } .popup.novidade .bar { background: var(--ok); }
.popup .in { padding: 22px 24px 18px; } .popup .in p { white-space: pre-line; color: var(--ink-2); }
@keyframes fade { from { opacity: 0; } } @keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* gráficos */
.chart { display: block; overflow: visible; }
.chart .bar { transition: opacity .1s; } .chart .bar:hover { opacity: .75; }
.chart text { font-size: 11px; fill: var(--ink-3); font-family: var(--font); }
.chart .grid-l { stroke: var(--line); stroke-dasharray: 2 3; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--ink-2); } .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.heat { display: grid; grid-template-columns: 30px repeat(24, minmax(0, 1fr)); gap: 2px; font-size: .7rem; color: var(--ink-3); }
.heat div { height: 18px; border-radius: 3px; min-width: 0; } .heat .lb { aspect-ratio: auto; display: flex; align-items: center; } .heat .hd { height: auto; text-align: center; overflow: visible; white-space: nowrap; } .heat .lb { height: 18px; }
.tip { position: fixed; pointer-events: none; background: #1d1c1a; color: #fff; padding: 6px 10px; border-radius: 8px; font-size: .8rem; z-index: 90; white-space: nowrap; }
.meter { height: 10px; background: var(--side); border-radius: 99px; overflow: hidden; } .meter > div { height: 100%; background: var(--accent); border-radius: 99px; }
.meter.over > div { background: var(--warn); }

/* login */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-art { background: linear-gradient(150deg, var(--accent), #1c2f80); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-art h1 { font-size: 2.1rem; max-width: 440px; } .auth-art p { opacity: .85; max-width: 420px; }
.auth-art .logo { background: rgba(255,255,255,.18); width: 44px; height: 44px; font-size: 1.1rem; }
.auth-art ul { list-style: none; padding: 0; margin: 24px 0 0; } .auth-art li { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; opacity: .92; }
.auth-form { display: grid; place-items: center; padding: 32px; }
.auth-form form { width: min(380px, 100%); }
.auth-form h2 { font-size: 1.45rem; } .auth-form .lnk { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font-size: .88rem; }
.otp { letter-spacing: .4em; text-align: center; font-size: 1.3rem; font-variant-numeric: tabular-nums; }

/* central — destaques */
.hero { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.hero .big { font-size: 2.3rem; font-weight: 700; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.hero .kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.hero .kv div span { display: block; font-size: .78rem; color: var(--ink-3); } .hero .kv div b { font-weight: 600; }
.inv-ic { width: 42px; height: 42px; border-radius: 11px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.code { font-family: ui-monospace, Consolas, monospace; font-size: .82rem; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; word-break: break-all; }
.mono { font-family: ui-monospace, Consolas, monospace; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .side { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .topbar { display: flex; }
  .page { padding: 18px 16px 60px; }
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g2 { grid-template-columns: 1fr; }
  .fgrid { grid-template-columns: 1fr 1fr; } .fgrid > * { grid-column: span 2 !important; }
  .auth { grid-template-columns: 1fr; } .auth-art { display: none; }
}
@media (max-width: 520px) { .g3, .g4 { grid-template-columns: 1fr 1fr; } .kpi .val { font-size: 1.35rem; } }
@media print { .side, .topbar, .no-print { display: none !important; } .shell { display: block; } .main { overflow: visible; } }
