:root {
  --bg: #0b0d10;
  --panel: #14171c;
  --panel-2: #1b1f26;
  --line: #262b34;
  --text: #e8eaed;
  --muted: #8b93a1;
  --red: #e5383b;
  --red-soft: rgba(229, 56, 59, .14);
  --green: #2fbf71;
  --green-soft: rgba(47, 191, 113, .14);
  --amber: #f2a93b;
  --amber-soft: rgba(242, 169, 59, .14);
  --blue: #4c8dff;
  --radius: 14px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
a { color: var(--blue); text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; background: linear-gradient(to right, var(--panel) 230px, var(--bg) 230px); }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 18px; padding: 4px 10px 20px; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--muted); font-weight: 550; }
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.active { background: var(--panel-2); color: var(--text); }
.nav svg { width: 18px; height: 18px; flex: none; }
.side-foot { margin-top: auto; padding: 10px 12px; font-size: 13px; color: var(--muted); }
.main { padding: 28px 32px 60px; max-width: 1180px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; background: var(--bg); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 6px 10px; width: 100%; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav a { padding: 8px 10px; }
  .side-foot { display: none; }
  .main { padding: 20px 16px 60px; }
}

/* ---------- componentes ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

.btn { appearance: none; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; font-weight: 600;
  padding: 9px 14px; border-radius: 10px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.btn:hover { border-color: #3a414d; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: #f04a4d; }
.btn.green { background: var(--green); border-color: var(--green); color: #06170e; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; justify-content: center; }

input, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; }
input:focus, select:focus { outline: 2px solid rgba(76, 141, 255, .35); border-color: var(--blue); }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 550; }
input[type=range] { padding: 0; accent-color: var(--red); background: transparent; border: 0; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; padding: 3px 9px; border-radius: 99px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.badge.red { background: var(--red-soft); color: #ff7a7c; border-color: transparent; }
.badge.green { background: var(--green-soft); color: #5ddc97; border-color: transparent; }
.badge.amber { background: var(--amber-soft); color: #ffc36b; border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

.banner { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--radius); margin-bottom: 20px; border: 1px solid transparent; }
.banner.amber { background: var(--amber-soft); border-color: rgba(242, 169, 59, .3); }
.banner.red { background: var(--red-soft); border-color: rgba(229, 56, 59, .35); }
.banner.green { background: var(--green-soft); border-color: rgba(47, 191, 113, .3); }

/* ---------- aparelhos ---------- */
.device-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.device-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 6px; }
.arm-switch { width: 100%; margin: 16px 0; padding: 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg);
  display: flex; align-items: center; justify-content: space-between; cursor: pointer; font: inherit; color: var(--text); }
.arm-switch .label { font-size: 17px; font-weight: 700; }
.arm-switch.on { background: var(--red-soft); border-color: rgba(229, 56, 59, .5); }
.toggle { width: 52px; height: 30px; border-radius: 99px; background: #2c323c; position: relative; transition: background .2s; flex: none; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.on .toggle { background: var(--red); }
.on .toggle::after { transform: translateX(22px); }
.sliders { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.slider-val { float: right; color: var(--text); }

/* ---------- eventos ---------- */
.event { display: grid; grid-template-columns: 120px 1fr auto; gap: 16px; align-items: center; padding: 12px; border-bottom: 1px solid var(--line); }
.event-wrap { border-bottom: 1px solid var(--line); }
.event-wrap:last-child { border-bottom: 0; }
.event-wrap .event { border-bottom: 0; }
.event-wrap.open { background: var(--bg); border-radius: 12px; }
.event-detail { padding: 0 12px 14px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.detail-grid figure { margin: 0; }
.detail-grid figcaption { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.detail-grid video, .detail-grid img { width: 100%; max-height: 360px; border-radius: 12px; background: #000; display: block; }
.detail-grid .map { height: 260px; }
.event:last-child { border-bottom: 0; }
.thumb { width: 120px; height: 80px; border-radius: 10px; object-fit: cover; background: var(--panel-2); display: grid; place-items: center; color: var(--muted); font-size: 12px; cursor: zoom-in; }
.channels { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
@media (max-width: 620px) { .event { grid-template-columns: 90px 1fr; } .event > :last-child { grid-column: 1 / -1; } .thumb { width: 90px; height: 64px; } }

/* ---------- planos ---------- */
.plans { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.plan { position: relative; }
.plan.current { border-color: var(--red); }
.plan .price { font-size: 34px; font-weight: 750; letter-spacing: -.02em; margin: 8px 0 2px; }
.plan .price span { font-size: 15px; color: var(--muted); font-weight: 500; }
.plan ul { padding: 0; list-style: none; margin: 14px 0 18px; }
.plan li { padding: 5px 0 5px 24px; position: relative; }
.plan li::before { content: "✓"; position: absolute; left: 2px; color: var(--green); font-weight: 700; }
.plan li.off { color: var(--muted); }
.plan li.off::before { content: "–"; color: var(--muted); }
.pix-box { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: center; }
.pix-box img, .qr-placeholder { width: 220px; height: 220px; border-radius: 12px; background: #fff; }
.qr-placeholder { display: grid; place-items: center; color: #444; text-align: center; padding: 20px; font-size: 13px; }
.copy-code { font-family: ui-monospace, monospace; font-size: 12px; word-break: break-all; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; max-height: 92px; overflow: auto; }
@media (max-width: 620px) { .pix-box { grid-template-columns: 1fr; } }

/* ---------- tabelas ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.kpi .label { font-size: 13px; color: var(--muted); font-weight: 550; }
.kpi .value { font-size: 28px; font-weight: 750; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.bars { display: flex; align-items: flex-end; gap: 12px; height: 160px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar { width: 100%; max-width: 46px; background: var(--red); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.bar-col .v { font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; }
.bar-col .m { font-size: 12px; color: var(--muted); }

/* ---------- login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: 100%; max-width: 400px; padding: 28px; }
.auth .brand { justify-content: center; padding-bottom: 6px; font-size: 22px; }
.tabs { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; margin: 18px 0; }
.tabs button { flex: 1; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600; padding: 8px; border-radius: 8px; cursor: pointer; }
.tabs button.active { background: var(--panel-2); color: var(--text); }
.error { color: #ff7a7c; font-size: 14px; min-height: 20px; }

/* ---------- modal / vídeo ---------- */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .75); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal .card { width: 100%; max-width: 860px; max-height: 92vh; overflow: auto; }
.video-wrap { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 16 / 9; margin-top: 14px; }
.video-wrap video { width: 100%; height: 100%; object-fit: contain; display: block; }
.video-state { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 20px; }
.live-pill { position: absolute; top: 12px; left: 12px; background: var(--red); color: #fff; font-size: 12px; font-weight: 750; padding: 4px 10px; border-radius: 6px; letter-spacing: .05em; }
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--panel-2); border: 1px solid var(--line); padding: 12px 16px; border-radius: 12px; z-index: 60; max-width: 360px; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.toast.red { border-color: var(--red); }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.pair-qr { width: 240px; margin: 8px auto; padding: 8px; background: #fff; border-radius: 12px; }
.pair-qr svg { display: block; width: 100%; height: auto; }
.pair-code { font-size: 40px; font-weight: 800; letter-spacing: .25em; font-variant-numeric: tabular-nums; text-align: center; padding: 14px; background: var(--bg); border-radius: 12px; border: 1px dashed var(--line); }

/* ---------- gravação de vídeo ---------- */
.rec-box { margin-top: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.check { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 15px; font-weight: 600; margin: 0; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--red); }
.video-wrap.free { aspect-ratio: auto; }
.video-wrap video[controls] { max-height: 70vh; }

/* ---------- mapa e gravações ---------- */
.map-wrap { margin-top: 14px; }
.map { width: 100%; height: 220px; border: 0; border-radius: 12px; background: var(--bg); display: block; }
.rec-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 4px; border-top: 1px solid var(--line); }
.rec-row:first-child { border-top: 0; }
