/* Sentinel — tema escuro de operação */
:root {
  --bg: #0B1018;
  --surface: #121A26;
  --surface-2: #172131;
  --surface-3: #1C2839;
  --border: #253143;
  --border-strong: #33425A;
  --text: #E6EDF7;
  --text-2: #A7B3C6;
  --text-3: #7C8AA0;
  --primary: #4F8CFF;
  --primary-strong: #3B78EE;
  --primary-soft: rgba(79, 140, 255, .14);

  --green: #34D399;  --green-soft: rgba(52, 211, 153, .13);
  --blue: #6FA3FF;   --blue-soft: rgba(79, 140, 255, .15);
  --amber: #FBBF24;  --amber-soft: rgba(251, 191, 36, .14);
  --gray: #93A0B4;   --gray-soft: rgba(147, 160, 180, .12);
  --red: #F87171;    --red-soft: rgba(248, 113, 113, .15);

  --radius: 10px;
  --radius-sm: 7px;
  --gap: 16px;
  --side-w: 244px;
  --side-w-c: 68px;
  --top-h: 60px;
  --font: 'Inter', 'Geist', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--primary); }
code { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: .92em; background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
pre { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; overflow-x: auto; font-size: 12.5px; }
.num, .timer { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { flex: none; vertical-align: -3px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- Marca ---------- */
.brand-mark { color: var(--primary); display: inline-flex; width: 38px; height: 38px; align-items: center; justify-content: center; background: var(--primary-soft); border: 1px solid rgba(79,140,255,.35); border-radius: 10px; flex: none; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.brand-sub { font-size: 11.5px; color: var(--text-3); line-height: 1.3; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 600px at 50% -10%, rgba(79,140,255,.12), transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; display: grid; gap: 14px; }
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.login-card .btn-ghost.btn-block { height: 34px; margin-top: -6px; color: var(--text-2); border-color: transparent; }
.form-error { color: var(--red); min-height: 1.2em; margin: 0; font-size: 13px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }
.shell.collapsed { grid-template-columns: var(--side-w-c) 1fr; }
.side { position: sticky; top: 0; height: 100vh; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 14px 10px; gap: 14px; overflow: hidden; z-index: 30; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 2px 4px 12px; border-bottom: 1px solid var(--border); min-height: 56px; }
.side-brand-text { min-width: 0; }
.nav { display: grid; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px; color: var(--text-2); text-decoration: none; background: none; border: 0; cursor: pointer; width: 100%; text-align: left; white-space: nowrap; font-weight: 500; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: #fff; box-shadow: inset 2px 0 0 var(--primary); }
.nav-item.active .ic { color: var(--primary); }
.side-foot { margin-top: auto; display: grid; gap: 2px; border-top: 1px solid var(--border); padding-top: 10px; }
.collapsed .side-brand-text, .collapsed .nav-item span { display: none; }
.collapsed .nav-item { justify-content: center; padding: 10px; }
.collapsed .side-brand { justify-content: center; padding-inline: 0; }
.collapsed .collapse-btn .ic { transform: rotate(180deg); }
.side-backdrop { display: none; }
.powered { margin: 6px 0 0; font-size: 11px; color: var(--text-3); text-align: center; letter-spacing: .02em; white-space: nowrap; }
.powered strong { color: var(--text-2); font-weight: 600; }
.side-foot .powered { padding-top: 8px; }
.collapsed .side-foot .powered { display: none; }
body:not(.tv) .powered-tv { display: none; }
body.tv .powered-tv { position: fixed; right: 20px; bottom: 6px; z-index: 5; }
body.tv .powered-tv .powered { font-size: 13px; margin: 0; opacity: .8; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 20; height: var(--top-h); display: flex; align-items: center; gap: 12px; padding: 0 20px; background: rgba(11,16,24,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.top-title h1 { font-size: 17px; margin: 0; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
body:not(.tv) .tv-brand, body:not(.tv) .tv-exit, body:not(.tv) .tv-clock { display: none; }
.filters { display: flex; gap: 8px; flex: 1; min-width: 0; flex-wrap: wrap; justify-content: flex-start; }
.filter select, .filter-search input { height: 34px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 0 10px; color: var(--text); min-width: 0; max-width: 220px; }
.filter-search { position: relative; display: flex; align-items: center; }
.filter-search .ic { position: absolute; left: 9px; color: var(--text-3); pointer-events: none; }
.filter-search input { padding-left: 32px; width: 210px; }
.integrations { display: flex; gap: 8px; margin-left: auto; flex-wrap: nowrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; border: 1px solid var(--border); background: var(--surface); white-space: nowrap; }
.pill strong { font-weight: 600; }
.pill-text { color: var(--text-2); font-variant-numeric: tabular-nums; }
.p-green .ic { color: var(--green); } .p-green { border-color: rgba(52,211,153,.35); }
.p-blue .ic { color: var(--blue); } .p-blue { border-color: rgba(79,140,255,.4); }
.p-amber .ic { color: var(--amber); } .p-amber { border-color: rgba(251,191,36,.4); }
.p-red { border-color: rgba(248,113,113,.5); background: var(--red-soft); } .p-red .ic, .p-red .pill-text { color: var(--red); }
.p-gray .ic { color: var(--gray); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px; background: transparent; border: 1px solid transparent; color: var(--text-2); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.menu-btn { display: none; }
.user-menu { position: relative; }
.user-pop { position: absolute; right: 0; top: 42px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; min-width: 200px; padding: 6px; box-shadow: 0 12px 30px rgba(0,0,0,.4); }
.user-pop-head { padding: 8px 10px; display: grid; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.user-pop-head span { color: var(--text-3); font-size: 12px; }
.pop-item { display: flex; gap: 8px; align-items: center; width: 100%; padding: 8px 10px; background: none; border: 0; border-radius: 6px; cursor: pointer; }
.pop-item:hover { background: var(--surface-2); }

.demo-banner, .conn-banner { display: flex; align-items: center; gap: 10px; padding: 7px 20px; font-size: 13px; }
.demo-banner { background: linear-gradient(90deg, rgba(79,140,255,.22), rgba(79,140,255,.08)); border-bottom: 1px solid rgba(79,140,255,.35); color: #DCE7FF; }
.demo-banner strong { text-transform: uppercase; letter-spacing: .06em; font-size: 12px; }
.conn-banner { background: var(--red-soft); color: var(--red); border-bottom: 1px solid rgba(248,113,113,.4); }

.view { padding: 18px 20px 28px; outline: none; min-width: 0; }
.loading { color: var(--text-3); padding: 40px; text-align: center; }
.stack { display: grid; gap: var(--gap); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); align-items: start; }
.split-60 { grid-template-columns: 3fr 2fr; }

/* ---------- Painéis ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.panel-title h2 { margin: 0; font-size: 15px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.panel-title h2 .ic { color: var(--primary); }
.panel-title p { margin: 3px 0 0; color: var(--text-3); font-size: 12.5px; }
.panel-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.count { display: inline-flex; min-width: 24px; height: 20px; padding: 0 7px; align-items: center; justify-content: center; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-size: 12px; font-variant-numeric: tabular-nums; font-weight: 600; }
.hint { color: var(--text-3); font-size: 12.5px; margin: 10px 0 0; }
.empty { display: flex; gap: 10px; align-items: center; justify-content: center; color: var(--text-3); padding: 26px 12px; text-align: center; }
.empty .ic { color: var(--text-3); }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); }
.kpi { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 6px; min-width: 0; overflow: hidden; }
.kpi::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; background: transparent; }
.kpi-warn { border-color: rgba(251,191,36,.45); } .kpi-warn::before { background: var(--amber); }
.kpi-crit { border-color: rgba(248,113,113,.6); background: linear-gradient(180deg, rgba(248,113,113,.08), transparent 60%), var(--surface); } .kpi-crit::before { background: var(--red); }
.kpi-head { display: flex; align-items: center; gap: 8px; }
.kpi-head h2 { margin: 0; font-size: 13px; font-weight: 600; color: var(--text-2); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-icon { color: var(--primary); display: inline-flex; }
.kpi-src { font-size: 11px; color: var(--text-3); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.kpi-body { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.kpi-value { font-size: 44px; font-weight: 700; line-height: 1.05; letter-spacing: -.03em; }
.kpi-foot { font-size: 12.5px; color: var(--text-2); min-height: 20px; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.kpi-foot .timer { font-weight: 600; }
.kpi-breakdown { display: flex; flex-wrap: wrap; gap: 6px; }
.kpi-stale { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--red); }
.kpi.is-stale .kpi-value { opacity: .55; }
.spark { color: var(--primary); opacity: .9; flex: none; margin-bottom: 6px; }
.kpi-crit .spark { color: var(--red); } .kpi-warn .spark { color: var(--amber); }

.attention { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-radius: var(--radius-sm); font-size: 13px; }
.attention span { color: var(--text-2); }
.a-crit { background: var(--red-soft); border: 1px solid rgba(248,113,113,.4); } .a-crit .ic, .a-crit strong { color: var(--red); }
.a-warn { background: var(--amber-soft); border: 1px solid rgba(251,191,36,.35); } .a-warn .ic, .a-warn strong { color: var(--amber); }

/* Visão geral: cabe na tela sem rolar no desktop */
.overview { display: grid; gap: var(--gap); }
@media (min-width: 1100px) and (min-height: 680px) {
  .overview { height: calc(100vh - var(--top-h) - 46px); grid-template-rows: auto auto minmax(0, 1fr); }
  .overview:not(:has(.attention)) { grid-template-rows: auto minmax(0, 1fr); }
  .overview .split { min-height: 0; height: 100%; align-items: stretch; }
  .overview .panel-fill { display: flex; flex-direction: column; min-height: 0; }
  .overview .panel-fill .table-wrap { flex: 1; min-height: 0; overflow: auto; }
  body:has(.demo-banner:not([hidden])) .overview { height: calc(100vh - var(--top-h) - 46px - 34px); }
}

/* ---------- Tabelas ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); text-align: left; font-weight: 600; font-size: 12px; color: var(--text-2); padding: 0 12px; height: 36px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .r { text-align: right; }
.tbl th.r .th-sort { justify-content: flex-end; width: 100%; }
.th-sort { display: inline-flex; gap: 6px; align-items: center; background: none; border: 0; padding: 0; cursor: pointer; color: inherit; font-weight: inherit; font-size: inherit; }
.th-sort:hover { color: var(--text); }
.sorti { font-size: 9px; color: var(--text-3); } .sorti.on { color: var(--primary); }
.row-link { cursor: pointer; }
.row-link:hover td { background: var(--surface-2); }
.big { font-size: 17px; font-weight: 650; }
.cell-title { font-weight: 600; }
.cell-sub { color: var(--text-3); font-size: 12px; margin-top: 1px; }
.sev-row-crit td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.sev-row-warn td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
.tbl-compact td, .tbl-compact th { padding-inline: 10px; }
.tbl-compact td { padding-block: 7px; }
.tbl-form td { padding-block: 6px; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }

.timer.sev-warn { color: var(--amber); }
.timer.sev-crit { color: var(--red); }

/* ---------- Chips de status ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 7px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.chip-extra { font-weight: 500; opacity: .85; }
.mini { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 6px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.minis { display: flex; flex-wrap: wrap; gap: 4px; }
.s-green { color: var(--green); background: var(--green-soft); }
.s-blue { color: var(--blue); background: var(--blue-soft); }
.s-amber { color: var(--amber); background: var(--amber-soft); }
.s-gray { color: var(--gray); background: var(--gray-soft); }
.s-red { color: var(--red); background: var(--red-soft); }
.s-neutral { color: var(--text-2); background: var(--surface-3); font-weight: 500; }
.dev { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); background: none; }
.dev i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.dev.s-green i { background: var(--green); } .dev.s-blue i { background: var(--blue); } .dev.s-red i { background: var(--red); } .dev.s-gray i { background: var(--gray); }
.dev.s-green, .dev.s-blue, .dev.s-red, .dev.s-gray { background: none; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.b-ok { color: var(--green); background: var(--green-soft); }
.b-warn { color: var(--amber); background: var(--amber-soft); }
.b-crit { color: var(--red); background: var(--red-soft); }

.status-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.strip-item { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: center; padding: 10px 12px; border-radius: 8px; }
.strip-item .ic { grid-row: span 2; }
.strip-n { font-size: 22px; font-weight: 700; line-height: 1.1; color: var(--text); }
.strip-l { font-size: 12px; font-weight: 600; }

.qcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.qcard { text-align: left; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 12px; display: grid; gap: 8px; cursor: pointer; }
.qcard:hover { border-color: var(--border-strong); background: var(--surface-3); }
.qcard-head { display: flex; justify-content: space-between; gap: 6px; }
.qcard-nums { display: flex; justify-content: space-between; align-items: flex-end; }
.qcard-nums > div { display: grid; }
.qcard-nums .timer { font-size: 17px; font-weight: 650; }
.lbl { font-size: 11.5px; color: var(--text-3); font-weight: 500; }
.sev-card-warn { border-color: rgba(251,191,36,.5); }
.sev-card-crit { border-color: rgba(248,113,113,.65); background: linear-gradient(180deg, rgba(248,113,113,.08), transparent), var(--surface-2); }

.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 140px) 1fr 40px; gap: 10px; align-items: center; font-size: 13px; }
.bar-l { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 10px; background: var(--surface-3); border-radius: 5px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--primary); border-radius: 5px; transition: width .4s ease; }
.bar-v { text-align: right; font-weight: 600; }

/* ---------- Drawer ---------- */
.drawer-wrap { position: fixed; inset: 0; z-index: 50; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(4,7,12,.6); }
.drawer { position: absolute; right: 0; top: 0; bottom: 0; width: min(620px, 100%); background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; box-shadow: -20px 0 40px rgba(0,0,0,.35); animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { margin: 0; font-size: 18px; display: flex; gap: 8px; align-items: center; }
.drawer-head p { margin: 2px 0 0; color: var(--text-3); font-size: 12.5px; }
.drawer-body { padding: 16px 18px 24px; overflow: auto; flex: 1; }
.drawer-body h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin: 22px 0 8px; font-weight: 600; }
.dstats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.dstats > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; display: grid; gap: 4px; align-content: start; }
.dstats .timer, .dstats .big { font-size: 22px; font-weight: 700; }

/* ---------- Formulários ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; font-weight: 600; font-size: 13.5px; white-space: nowrap; }
.btn:hover { border-color: var(--border-strong); background: var(--surface-3); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn-ghost { background: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-block { width: 100%; height: 40px; }
.form { display: grid; gap: 12px; align-content: start; }
.field { display: grid; gap: 5px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.field small { color: var(--text-3); font-size: 12px; }
.input, .field input, .field select { height: 36px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 0 10px; color: var(--text); width: 100%; min-width: 0; }
.input:focus, .field input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }
.input-sm { max-width: 110px; }
select.suggested { border-color: var(--green); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 16px; }
.checks-inline { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.checks-inline .check { font-size: 12.5px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.sticky-actions { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 40%); }
.help { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: var(--surface-2); font-size: 13px; color: var(--text-2); }
.help summary { cursor: pointer; font-weight: 600; color: var(--text); }
.help p { margin: 8px 0; }
.note { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); font-size: 13px; }
.note > div { display: grid; gap: 4px; }
.note-ok { border-color: rgba(52,211,153,.4); background: var(--green-soft); } .note-ok > .ic { color: var(--green); }
.note-err { border-color: rgba(248,113,113,.45); background: var(--red-soft); color: var(--red); }
.note-info { border-color: rgba(79,140,255,.4); background: var(--primary-soft); } .note-info > .ic { color: var(--primary); }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; }
.switch input { position: absolute; opacity: 0; }
.switch-ui { width: 42px; height: 24px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; transition: background .15s; }
.switch-ui::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--text-2); transition: transform .15s, background .15s; }
.switch input:checked + .switch-ui { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .switch-ui::after { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--primary); outline-offset: 2px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab { background: none; border: 0; padding: 10px 14px; color: var(--text-2); cursor: pointer; font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--text); border-bottom-color: var(--primary); }

#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 80; }
.toast { display: flex; gap: 8px; align-items: center; padding: 10px 14px; background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 9px; box-shadow: 0 10px 30px rgba(0,0,0,.4); max-width: 380px; font-size: 13.5px; }
.t-ok .ic { color: var(--green); } .t-err { border-color: rgba(248,113,113,.5); } .t-err .ic { color: var(--red); }

/* ---------- Responsivo ---------- */
@media (max-width: 1360px) {
  .integrations .pill-text { display: none; }
  .filter-search input { width: 170px; }
}
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split, .split-60 { grid-template-columns: 1fr; }
  .status-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .top { height: auto; min-height: var(--top-h); flex-wrap: wrap; padding-block: 10px; }
  .filters { order: 5; flex-basis: 100%; }
}
@media (max-width: 760px) {
  :root { --gap: 12px; }
  .shell, .shell.collapsed { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 270px; transform: translateX(-100%); transition: transform .2s ease; }
  .shell.side-open .side { transform: none; }
  .shell.side-open .side-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 25; }
  .collapsed .side-brand-text, .collapsed .nav-item span { display: initial; }
  .collapsed .nav-item { justify-content: flex-start; padding: 9px 12px; }
  .collapse-btn { display: none; }
  .menu-btn { display: inline-flex; }
  .top { padding-inline: 12px; gap: 8px; }
  .top-title h1 { font-size: 16px; }
  .top-title { flex: 1; }
  .integrations { gap: 6px; order: 4; flex-basis: 100%; margin-left: 0; }
  body.tv .integrations { order: 0; flex-basis: auto; }
  .pill { padding: 0 8px; }
  .filter, .filter select, .filter-search, .filter-search input { flex: 1 1 140px; max-width: none; width: 100%; }
  .view { padding: 12px 12px 24px; }
  .demo-banner, .conn-banner { padding-inline: 12px; font-size: 12px; flex-wrap: wrap; }
  .kpi-value { font-size: 34px; }
  .kpi .spark { display: none; }
  .status-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: 1fr; }
  .panel { padding: 12px; }
  /* Tabelas viram cartões com os dados prioritários */
  .table-wrap { border: 0; overflow: visible; }
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tr { background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 8px 12px; margin-bottom: 8px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; }
  .tbl td { border: 0; padding: 4px 0; text-align: left !important; }
  .tbl td:first-child { grid-column: 1 / -1; box-shadow: none !important; }
  .tbl td::before { content: attr(data-label); display: block; font-size: 11px; color: var(--text-3); font-weight: 500; }
  .tbl td:first-child::before { display: none; }
  .tbl .lp { display: none; }
  .sev-row-crit { border-left: 3px solid var(--red) !important; }
  .sev-row-warn { border-left: 3px solid var(--amber) !important; }
  .tbl-compact tr { grid-template-columns: 1fr 1fr; }
  .bar-row { grid-template-columns: 90px 1fr 32px; }
}
@media (max-width: 420px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi-head h2 { white-space: normal; font-size: 12px; }
  .kpi-src { display: none; }
  .kpi-value { font-size: 30px; }
}

/* ---------- Modo TV ---------- */
body.tv { font-size: 17px; }
body.tv .shell, body.tv .shell.collapsed { grid-template-columns: 1fr; }
body.tv .side, body.tv .filters, body.tv .menu-btn, body.tv .user-menu, body.tv .top-title h1, body.tv .tv-hide, body.tv .conn-banner + .top .filters { display: none !important; }
body.tv .tv-brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 20px; }
body.tv .tv-clock { display: block; font-size: 26px; font-weight: 700; margin-left: 12px; }
body.tv .tv-exit { display: inline-flex; opacity: .35; }
body.tv .tv-exit:hover, body.tv .tv-exit:focus-visible { opacity: 1; }
body.tv .top { height: 72px; padding-inline: 28px; }
body.tv .integrations .pill-text { display: inline; }
body.tv .pill { height: 36px; font-size: 15px; }
body.tv .view { padding: 20px 28px; }
body.tv .kpi { padding: 18px 22px 16px; }
body.tv .kpi-head h2 { font-size: 18px; }
body.tv .kpi-value { font-size: 84px; }
body.tv .kpi-foot { font-size: 17px; }
body.tv .mini { font-size: 15px; }
body.tv .tbl { font-size: 19px; }
body.tv .tbl th { font-size: 15px; height: 44px; }
body.tv .tbl td { padding-block: 12px; }
body.tv .big, body.tv .tbl .timer { font-size: 28px; }
body.tv .cell-sub { font-size: 14px; }
body.tv .badge { font-size: 15px; }
body.tv .panel-title h2 { font-size: 20px; }
body.tv .attention { font-size: 17px; }
body.tv .row-link { cursor: default; }
@media (min-width: 1100px) and (min-height: 680px) {
  body.tv .overview { height: calc(100vh - 72px - 40px); }
  body.tv:has(.demo-banner:not([hidden])) .overview { height: calc(100vh - 72px - 40px - 34px); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Logo Sentinel */
.brand-logo { width: 36px; height: 36px; flex: none; display: block; filter: drop-shadow(0 0 10px rgba(42, 98, 242, .35)); }
.login-brand .brand-logo { width: 44px; height: 44px; }
body.tv .tv-brand .brand-logo { width: 32px; height: 32px; }
.brand-name { font-size: 17px; }

/* ---------- Modo claro (alternável; o padrão é o escuro) ---------- */
:root[data-theme="light"] {
  --bg: #F3F6FA;
  --surface: #FFFFFF;
  --surface-2: #F6F8FB;
  --surface-3: #E9EEF5;
  --border: #DCE3EC;
  --border-strong: #C3CDDA;
  --text: #0F1722;
  --text-2: #3F4B5E;
  --text-3: #66738A;
  --primary: #2A62F2;
  --primary-strong: #1F51D6;
  --primary-soft: rgba(42, 98, 242, .10);
  --green: #0B7F55;  --green-soft: rgba(16, 150, 100, .12);
  --blue: #1F56D8;   --blue-soft: rgba(42, 98, 242, .11);
  --amber: #A65400;  --amber-soft: rgba(230, 140, 20, .16);
  --gray: #5B677A;   --gray-soft: rgba(91, 103, 122, .12);
  --red: #C4221F;    --red-soft: rgba(220, 38, 38, .10);
  color-scheme: light;
}
:root[data-theme="light"] .top { background: rgba(243, 246, 250, .92); }
:root[data-theme="light"] .nav-item.active { color: var(--text); }
:root[data-theme="light"] .demo-banner { color: #12306E; background: linear-gradient(90deg, rgba(42,98,242,.16), rgba(42,98,242,.05)); }
:root[data-theme="light"] .login { background: radial-gradient(1200px 600px at 50% -10%, rgba(42,98,242,.10), transparent 60%), var(--bg); }
:root[data-theme="light"] .panel, :root[data-theme="light"] .kpi { box-shadow: 0 1px 2px rgba(15, 23, 34, .05); }
:root[data-theme="light"] .user-pop, :root[data-theme="light"] .toast { box-shadow: 0 10px 30px rgba(15, 23, 34, .14); }
:root[data-theme="light"] .drawer { box-shadow: -20px 0 40px rgba(15, 23, 34, .12); }
:root[data-theme="light"] .drawer-backdrop { background: rgba(15, 23, 34, .35); }
:root[data-theme="light"] .brand-logo { filter: none; }
:root[data-theme="light"] .pill { background: var(--surface); }
:root[data-theme="light"] .switch-ui::after { background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
:root[data-theme="light"] .switch-ui { background: var(--border-strong); }
:root[data-theme="light"] .kpi-crit { background: linear-gradient(180deg, rgba(220,38,38,.06), transparent 60%), var(--surface); }
:root[data-theme="light"] .sev-card-crit { background: linear-gradient(180deg, rgba(220,38,38,.06), transparent), var(--surface-2); }

.theme-float { position: fixed; top: 14px; right: 14px; border-color: var(--border); background: var(--surface); }

/* ---------- Relatórios ---------- */
.rep-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg-btn { background: none; border: 0; padding: 6px 12px; border-radius: 6px; cursor: pointer; color: var(--text-2); font-weight: 600; font-size: 13px; }
.seg-btn:hover { color: var(--text); background: var(--surface-2); }
.seg-btn.on { background: var(--primary-soft); color: var(--text); box-shadow: inset 0 0 0 1px rgba(79,140,255,.45); }
.rep-dates { display: flex; align-items: center; gap: 8px; }
.input-date { width: 150px; height: 36px; color-scheme: inherit; }
:root:not([data-theme="light"]) .input-date { color-scheme: dark; }
.rep-actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.rtiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); }
.rtiles-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rtile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 4px; }
.rtile-l { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.rtile-v { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.rtile-s { font-size: 12.5px; color: var(--text-3); }
.inbar { display: grid; grid-template-columns: auto; justify-items: end; gap: 3px; min-width: 70px; }
.inbar i { display: block; height: 4px; border-radius: 2px; background: var(--primary); opacity: .75; justify-self: stretch; max-width: 100%; }
.tbl-report td { padding-block: 8px; }
.rep-person-head h2 { margin: 0; font-size: 22px; }
.rep-person-head p { margin: 2px 0 0; color: var(--text-3); }
.bar-row-wide { grid-template-columns: minmax(100px, 160px) 1fr 110px; }
.bar-amber { background: var(--amber); }
.chart-wrap { position: relative; }
.dchart { width: 100%; height: auto; display: block; overflow: visible; }
.dchart .grid { stroke: var(--border); stroke-width: 1; }
.dchart text { fill: var(--text-3); font-size: 10.5px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.dchart .cbar path { fill: var(--primary); }
.dchart .cbar .chit { fill: transparent; }
.dchart .cbar.hover path { fill: var(--primary-strong); }
.dchart .cbar.hover .chit { fill: var(--primary-soft); }
.ctip { position: absolute; pointer-events: none; background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 6px; padding: 4px 8px; font-size: 12.5px; white-space: nowrap; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.chart-table { margin-top: 8px; font-size: 13px; color: var(--text-2); }
.chart-table summary { cursor: pointer; }
.chart-table table { margin-top: 8px; }
.print-head { display: none; }
@media (max-width: 1100px) { .rtiles, .rtiles-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .rep-actions { margin-left: 0; } }
@media (max-width: 760px) { .rtile-v { font-size: 24px; } .input-date { width: 100%; } .rep-dates { flex: 1 1 100%; } .rep-dates input { flex: 1; } }

/* ---------- Impressão / PDF ---------- */
@media print {
  :root, :root[data-theme="light"] {
    --bg: #fff; --surface: #fff; --surface-2: #f6f7f9; --surface-3: #eef1f5; --border: #d5dbe3; --border-strong: #b9c2cf;
    --text: #111; --text-2: #333; --text-3: #555; --primary: #2A62F2; --primary-strong: #1F51D6; --primary-soft: rgba(42,98,242,.1);
    --amber: #A65400; --green: #0B7F55; --blue: #1F56D8; --red: #C4221F;
  }
  body { background: #fff; color: #111; font-size: 11.5px; }
  .side, .top, .demo-banner, .conn-banner, .no-print, .theme-float, #toasts, .drawer-wrap, .chart-table summary, .powered-tv { display: none !important; }
  .shell, .shell.collapsed { display: block; }
  .view { padding: 0; }
  .panel, .rtile, .kpi { box-shadow: none !important; break-inside: avoid; }
  .split { grid-template-columns: 1fr 1fr; }
  .table-wrap { overflow: visible; border-color: #d5dbe3; }
  .tbl th { position: static; }
  .print-head { display: block; }
  .ph { display: flex; align-items: center; gap: 10px; border-bottom: 2px solid #2A62F2; padding-bottom: 8px; margin-bottom: 4px; }
  .ph div { display: grid; }
  .ph strong { font-size: 15px; }
  .ph span { color: #555; font-size: 11px; }
  .chart-table[open] table { display: none; }
  @page { size: A4; margin: 12mm; }
}
