:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --card-2: #f7f9fc;
  --line: #e3e8f0;
  --line-2: #cfd7e3;
  --text: #141a26;
  --muted: #5d687a;
  --faint: #8d97a8;
  --accent: #1d4ed8;
  --accent-soft: rgba(29, 78, 216, .09);
  --ok: #15803d;
  --ok-soft: rgba(21, 128, 61, .10);
  --warn: #b45309;
  --warn-soft: rgba(217, 119, 6, .12);
  --bad: #dc2626;
  --bad-soft: rgba(220, 38, 38, .10);
  --c-ativo: #22a559;
  --c-pausa: #9be0b2;
  --c-ocioso: #ef4444;
  --c-just: #3b82f6;
  --c-bloq: #a3adbd;
  --shadow: 0 6px 22px rgba(20, 30, 60, .08);
  --radius: 14px;
  --radius-sm: 9px;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1018; --card: #141a24; --card-2: #19202c; --line: #242d3b; --line-2: #313c4e;
    --text: #e7ebf3; --muted: #93a0b4; --faint: #64708a; --accent: #6b8cff; --accent-soft: rgba(107, 140, 255, .14);
    --ok: #34d17a; --ok-soft: rgba(52, 209, 122, .13); --warn: #f5a524; --warn-soft: rgba(245, 165, 36, .13);
    --bad: #f87171; --bad-soft: rgba(248, 113, 113, .13);
    --c-ativo: #2fbf6a; --c-pausa: #1f6b44; --c-ocioso: #f05252; --c-just: #4f8df5; --c-bloq: #4b5567;
    --shadow: 0 8px 26px rgba(0, 0, 0, .35); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1018; --card: #141a24; --card-2: #19202c; --line: #242d3b; --line-2: #313c4e;
  --text: #e7ebf3; --muted: #93a0b4; --faint: #64708a; --accent: #6b8cff; --accent-soft: rgba(107, 140, 255, .14);
  --ok: #34d17a; --ok-soft: rgba(52, 209, 122, .13); --warn: #f5a524; --warn-soft: rgba(245, 165, 36, .13);
  --bad: #f87171; --bad-soft: rgba(248, 113, 113, .13);
  --c-ativo: #2fbf6a; --c-pausa: #1f6b44; --c-ocioso: #f05252; --c-just: #4f8df5; --c-bloq: #4b5567;
  --shadow: 0 8px 26px rgba(0, 0, 0, .35); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background-color: var(--bg); color: var(--text); font: 14px/1.5 "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
small { font-size: 12px; }

/* botões e formulários */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background-color: var(--card); color: var(--text); font: inherit; font-weight: 560; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--faint); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background-color: var(--accent); border-color: transparent; color: #fff; }
.btn-primary:hover { filter: brightness(1.08); border-color: transparent; }
.btn-danger { background-color: var(--bad-soft); color: var(--bad); border-color: transparent; }
.btn-danger:hover { background-color: var(--bad); color: #fff; }
.btn-ghost { background-color: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background-color: var(--card-2); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn svg, .nav-item svg, .icon-btn svg { width: 17px; height: 17px; flex: none; }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: var(--radius-sm); border: 1px solid var(--line); background-color: var(--card); color: var(--muted); cursor: pointer; }
.icon-btn:hover { color: var(--text); }
input, select, textarea { font: inherit; color: var(--text); background-color: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 7px 10px; min-height: 36px; width: 100%; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label { display: grid; gap: 4px; font-size: 13px; font-weight: 560; color: var(--muted); }
label > small { font-weight: 400; color: var(--faint); }
.form-grid { display: grid; gap: 12px; }
.form-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); }
.check input { width: auto; min-height: 0; }
.form-error { color: var(--bad); background-color: var(--bad-soft); padding: 8px 12px; border-radius: var(--radius-sm); margin: 0; font-size: 13px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 400px; background-color: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); display: grid; gap: 16px; }
.setup-card { max-width: 480px; }
.login-foot { text-align: center; font-size: 12px; color: var(--faint); margin: 0; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand b { display: block; font-size: 15px; }
.brand small { display: block; color: var(--muted); font-size: 12px; line-height: 1.2; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background-color: var(--accent); background-image: linear-gradient(135deg, var(--accent), var(--c-ativo)); display: grid; place-items: center; color: #fff; flex: none; }
.brand-mark svg { width: 20px; height: 20px; }
.brand-lg .brand-mark { width: 42px; height: 42px; }
.otp-input { font-family: var(--mono); font-size: 20px; letter-spacing: 6px; text-align: center; }

/* layout */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { background-color: var(--card); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar nav { display: grid; gap: 2px; }
.nav-sep { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 12px 10px 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 560; }
.nav-item:hover { background-color: var(--card-2); color: var(--text); text-decoration: none; }
.nav-item.active { background-color: var(--accent-soft); color: var(--accent); }
.nav-item .badge { margin-left: auto; }
.side-foot { margin-top: auto; display: grid; gap: 8px; }
.me-box { display: block; padding: 10px; border-radius: var(--radius-sm); background-color: var(--card-2); color: var(--text); font-size: 13px; }
.me-box small { display: block; color: var(--muted); }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 16px 24px; border-bottom: 1px solid var(--line); background-color: var(--card); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 18px; }
.topbar-title { flex: 1; min-width: 0; }
.topbar-title small { color: var(--muted); display: block; font-size: 12.5px; }
.content { padding: 20px 24px 48px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; max-width: 1500px; }
.grid-2 > *, .grid-3-1 > *, .card { min-width: 0; }
.only-mobile { display: none; }
.demo-bar { background-color: var(--warn-soft); color: var(--warn); font-size: 12.5px; padding: 6px 24px; font-weight: 560; }

/* cartões */
.card { background-color: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-h h2 { flex: 1; }
.card-b { padding: 16px 18px; }
.card-b.flush { padding: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; }
.kpi { background-color: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi span { display: block; color: var(--muted); font-size: 12.5px; font-weight: 560; }
.kpi b { display: block; font-size: 24px; font-weight: 680; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--faint); }
.kpi.bad b { color: var(--bad); }
.kpi.ok b { color: var(--ok); }
.kpi.warn b { color: var(--warn); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }

/* tabelas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background-color: var(--card-2); white-space: nowrap; position: sticky; top: 0; }
th.sort { cursor: pointer; user-select: none; }
th.sort:hover { color: var(--text); }
th.sorted::after { content: " ▾"; }
th.sorted.asc::after { content: " ▴"; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background-color: var(--card-2); }
.person-cell b { display: block; }
.person-cell small { color: var(--muted); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* selos */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; background-color: var(--card-2); color: var(--muted); border: 1px solid var(--line); }
.badge.ok { background-color: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background-color: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background-color: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.info { background-color: var(--accent-soft); color: var(--accent); border-color: transparent; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; background-color: var(--c-bloq); }
.st { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; white-space: nowrap; }
.st small { display: block; font-weight: 400; color: var(--muted); }
.st-ativo .dot { background-color: var(--c-ativo); box-shadow: 0 0 0 3px var(--ok-soft); }
.st-pausa .dot { background-color: var(--c-pausa); }
.st-ocioso { color: var(--bad); }
.st-ocioso .dot { background-color: var(--c-ocioso); box-shadow: 0 0 0 3px var(--bad-soft); animation: pulse 1.6s infinite; }
.st-just .dot { background-color: var(--c-just); }
.st-bloq .dot { background-color: var(--c-bloq); }
.st-fora { color: var(--faint); }
.st-fora .dot { background-color: transparent; border: 2px solid var(--line-2); }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px transparent; } }
.alerts { display: flex; flex-wrap: wrap; gap: 4px; }
.alert-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.alert-list li { display: flex; gap: 8px; align-items: flex-start; padding: 8px 12px; border-radius: var(--radius-sm); background-color: var(--warn-soft); color: var(--warn); font-weight: 560; font-size: 13px; }
.alert-list li.grave { background-color: var(--bad-soft); color: var(--bad); }
.alert-list svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }

/* linha do tempo */
.tl { position: relative; height: 16px; background-color: var(--card-2); border-radius: 4px; overflow: hidden; min-width: 160px; border: 1px solid var(--line); }
.tl.big { height: 26px; }
.tl i { position: absolute; top: 0; bottom: 0; }
.c-ativo { background-color: var(--c-ativo); }
.c-pausa { background-color: var(--c-pausa); }
.c-ocioso { background-color: var(--c-ocioso); }
.c-just { background-color: var(--c-just); }
.c-bloq { background-color: var(--c-bloq); }
.tl-axis { position: relative; height: 16px; font-size: 11px; color: var(--faint); min-width: 160px; }
.tl-axis span { position: absolute; transform: translateX(-50%); }
.tl-now { position: absolute; top: -2px; bottom: -2px; width: 2px; background-color: var(--text); opacity: .5; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.stack { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background-color: var(--card-2); min-width: 120px; }
.stack i { height: 100%; }
.bar { position: relative; height: 8px; border-radius: 4px; background-color: var(--card-2); min-width: 70px; overflow: visible; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; }
.bar em { position: absolute; top: -3px; bottom: -3px; width: 2px; background-color: var(--text); opacity: .55; }
.pct-cell { display: grid; grid-template-columns: 38px 1fr; gap: 8px; align-items: center; min-width: 130px; }
.delta { font-size: 12px; font-weight: 600; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--bad); }

/* mapa de calor */
.heat { display: grid; gap: 3px; font-size: 11px; color: var(--muted); }
.heat-row { display: grid; grid-template-columns: 34px repeat(var(--cols), 1fr); gap: 3px; align-items: center; }
.heat-row i { height: 24px; border-radius: 4px; background-color: var(--card-2); display: grid; place-items: center; font-style: normal; font-size: 10.5px; color: transparent; }
.heat-row i:hover { color: var(--text); outline: 1px solid var(--line-2); }
.heat-row span { text-align: center; }

/* períodos */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow-x: auto; max-width: 100%; background-color: var(--card); }
.seg button { white-space: nowrap; flex: none; border: 0; background-color: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 560; padding: 0 12px; height: 34px; cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background-color: var(--accent-soft); color: var(--accent); }
.toolbar input[type="date"] { width: auto; min-height: 34px; padding: 4px 8px; }
.toolbar select { width: auto; min-height: 34px; padding: 4px 8px; }

/* eventos */
.events { list-style: none; margin: 0; padding: 0; }
.events li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.events li:last-child { border-bottom: 0; }
.events .ev-ico { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; background-color: var(--card-2); color: var(--muted); }
.events .ev-ico svg { width: 14px; height: 14px; }
.events li.grave .ev-ico { background-color: var(--bad-soft); color: var(--bad); }
.events li.aviso .ev-ico { background-color: var(--warn-soft); color: var(--warn); }
.events small { color: var(--muted); display: block; }

/* ficha */
.profile { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.avatar { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 18px; color: #fff; flex: none; background-color: var(--accent); }
.avatar.sm { width: 32px; height: 32px; font-size: 12.5px; }
.pcell { display: flex; gap: 10px; align-items: center; }
.compare { font-size: 12px; color: var(--muted); }
.code-box { font-family: var(--mono); font-size: 28px; letter-spacing: 6px; text-align: center; padding: 14px; border-radius: var(--radius-sm); background-color: var(--card-2); border: 1px dashed var(--line-2); }
.note { background-color: var(--accent-soft); color: var(--text); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; }
.note.warn { background-color: var(--warn-soft); }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.rec-codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-family: var(--mono); font-size: 15px; text-align: center; }
.rec-codes span { background-color: var(--card-2); border-radius: 6px; padding: 6px; }
.qr { display: grid; place-items: center; background-color: #fff; padding: 12px; border-radius: var(--radius-sm); }
.qr svg { width: 200px; height: 200px; }

/* modal e avisos */
.modal-bg { position: fixed; inset: 0; background-color: rgba(10, 15, 25, .5); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background-color: var(--card); border-radius: var(--radius); width: 100%; max-width: 540px; max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: var(--shadow); border: 1px solid var(--line); }
.modal-h { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-h h2 { flex: 1; }
.modal-b { padding: 18px 20px; display: grid; gap: 12px; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
#toasts { position: fixed; bottom: 16px; right: 16px; display: grid; gap: 8px; z-index: 60; }
.toast { background-color: var(--text); color: var(--bg); padding: 10px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow); font-weight: 560; max-width: 360px; }
.toast.bad { background-color: var(--bad); color: #fff; }

.comprovante { display: grid; gap: 10px; }
.comprovante td { padding: 6px 8px; font-size: 13px; }
.termo-texto { white-space: pre-wrap; font-size: 13px; line-height: 1.6; background-color: var(--card-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; max-height: 340px; overflow-y: auto; }

/* como usar */
details.ajuda > summary { cursor: pointer; padding: 14px 18px; font-weight: 650; font-size: 15px; list-style: none; display: flex; align-items: center; gap: 8px; }
details.ajuda > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
details.ajuda[open] > summary::before { transform: rotate(90deg); }
details.ajuda[open] > summary { border-bottom: 1px solid var(--line); }
details.ajuda ul, details.ajuda ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.ajuda-telas { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.ajuda-tela { display: flex; gap: 12px; align-items: flex-start; }
.ajuda-tela p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.ajuda-ico { width: 34px; height: 34px; border-radius: 9px; background-color: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.ajuda-ico svg { width: 18px; height: 18px; }
.card-h > svg { width: 18px; height: 18px; color: var(--warn); }
.faq dt { font-weight: 650; margin-top: 10px; }
.faq dt:first-child { margin-top: 0; }
.faq dd { margin: 2px 0 0; color: var(--muted); }

@media (max-width: 1100px) {
  .grid-2, .grid-3-1 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .only-mobile { display: inline-grid; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  #page-actions:not(:empty) { width: 100%; }
  .content { padding: 16px 16px 40px; }
  .form-2 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi b { font-size: 20px; }
  .hide-sm { display: none; }
  .demo-bar { padding: 6px 16px; }
}
@media print {
  body.print-modal #app, body.print-modal #toasts { display: none !important; }
  body.print-modal .modal-bg { position: static; background-color: transparent; padding: 0; display: block; }
  body.print-modal .modal { box-shadow: none; border: 0; max-height: none; max-width: none; }
  body.print-modal .modal-h button, body.print-modal .modal-f { display: none !important; }
  body.print-modal .termo-texto { max-height: none; overflow: visible; }
  .sidebar, .topbar .icon-btn, .toolbar, .no-print, .demo-bar { display: none !important; }
  .shell { display: block; }
  .card, .kpi { box-shadow: none; }
  body { background-color: #fff; }
}
