/* Radio Cloud — painel. Dois temas (claro/escuro) sobre os mesmos tokens. */

:root {
  --grad: linear-gradient(100deg, #FF8A3D 0%, #F2338F 38%, #8E24C9 70%, #2B32C9 100%);
  --grad-v: linear-gradient(180deg, #F2338F 0%, #8E24C9 45%, #2B32C9 100%);
  --grad-bar: linear-gradient(0deg, #2B32C9 0%, #8E24C9 45%, #F2338F 100%);
  --grad-warm: linear-gradient(0deg, #F2338F 0%, #FF8A3D 100%);

  --ok: #12B76A;
  --warn: #F79009;
  --bad: #F04438;

  --radius-lg: 18px;
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Sora', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

[data-theme="light"] {
  --bg: #F4F5FA;
  --surface: #FFFFFF;
  --surface-2: #F7F7FC;
  --ink: #12162B;
  --muted: #5B6178;
  --faint: #8C91A8;
  --line: #E6E7F0;
  --side-bg: var(--grad-v);
  --side-ink: rgba(255,255,255,.82);
  --side-ink-active: #FFFFFF;
  --side-active: rgba(255,255,255,.18);
  --shadow: 0 1px 2px rgba(18,22,43,.04), 0 8px 24px -12px rgba(18,22,43,.12);
  --chip-ok-bg: #E7F8EF; --chip-bad-bg: #FDECEB; --chip-warn-bg: #FEF3E2; --chip-off-bg: #EEEFF4;
  --focus: #8E24C9;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0D1424;
  --surface: #151F35;
  --surface-2: #1A2640;
  --ink: #EEF1F8;
  --muted: #A2AAC0;
  --faint: #6F7993;
  --line: #24314E;
  --side-bg: #101A2D;
  --side-ink: #A2AAC0;
  --side-ink-active: #FFFFFF;
  --side-active: var(--grad);
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 12px 28px -16px rgba(0,0,0,.6);
  --chip-ok-bg: rgba(18,183,106,.14); --chip-bad-bg: rgba(240,68,56,.15); --chip-warn-bg: rgba(247,144,9,.15); --chip-off-bg: rgba(162,170,192,.12);
  --focus: #FF8A3D;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ─── Shell ─────────────────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side {
  background: var(--side-bg);
  color: var(--side-ink);
  padding: 22px 14px;
  display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; color: var(--side-ink-active); }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: rgba(255,255,255,.16); }
[data-theme="dark"] .brand-mark { background: var(--grad); }
.brand b { display: block; font-size: 16px; letter-spacing: -.01em; }
.brand small { font-size: 12px; opacity: .75; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: var(--radius);
  text-decoration: none; font-weight: 500;
}
.nav a:hover { color: var(--side-ink-active); background: rgba(255,255,255,.08); }
.nav a[aria-current="page"] { background: var(--side-active); color: var(--side-ink-active); font-weight: 600; }
.nav svg { width: 18px; height: 18px; flex: none; }
.side-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid rgba(255,255,255,.14); font-size: 13px; }
.side-foot b { color: var(--side-ink-active); display: block; font-weight: 600; }
.side-foot button { margin-top: 10px; background: none; border: 0; padding: 0; color: var(--side-ink); cursor: pointer; text-decoration: underline; }

.main { padding: 26px 30px 40px; min-width: 0; }
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.top p { margin: 4px 0 0; color: var(--muted); }
.top-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ─── Botões / campos ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 9px 14px; border-radius: var(--radius-sm); cursor: pointer; font-weight: 500; text-decoration: none;
}
.btn:hover { border-color: var(--faint); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--grad); color: #fff; border: 0; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-danger { color: var(--bad); }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: progress; }
.icon-btn { width: 38px; height: 38px; justify-content: center; padding: 0; }

label.field { display: block; margin-bottom: 14px; }
label.field span { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-2);
}
.input:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
.form-error { color: var(--bad); font-size: 13px; margin: 0 0 12px; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }

/* ─── Cartões ───────────────────────────────────────────────────────── */
.card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); border: 1px solid var(--line); }
[data-theme="light"] .card { border-color: transparent; }
.card-pad { padding: 20px 22px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.card-head p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.grid { display: grid; gap: 18px; }
.kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); margin-bottom: 18px; }
.row-2 { grid-template-columns: 1.6fr 1fr; margin-bottom: 18px; }
.row-3 { grid-template-columns: 1.4fr 1fr 1fr; }

/* KPI: faixa em degradê no topo, número grande e mini-barras (referência 3) */
.kpi { overflow: hidden; }
.kpi-band { height: 6px; background: var(--grad); }
.kpi:nth-child(2) .kpi-band { background: linear-gradient(100deg, #12B76A, #2B32C9); }
.kpi:nth-child(5) .kpi-band { background: linear-gradient(100deg, #FF8A3D, #F04438); }
.kpi-body { padding: 16px 18px 18px; }
.kpi-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi-value { font-size: 32px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; line-height: 1.1; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ─── Gráfico de barras em degradê ──────────────────────────────────── */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 190px; padding-top: 8px; border-bottom: 1px solid var(--line); }
.bars .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 3px; position: relative; }
.bars .b { width: 100%; max-width: 26px; border-radius: 6px 6px 2px 2px; background: var(--grad-bar); min-height: 2px; }
.bars .b.fail { background: var(--grad-warm); }
.bars .col:hover .tip { opacity: 1; }
.tip {
  position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); font-size: 11px; padding: 4px 7px; border-radius: 6px;
  white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s;
}
.bars-x { display: flex; gap: 8px; margin-top: 6px; }
.bars-x span { flex: 1; text-align: center; font-size: 11px; color: var(--faint); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; background: var(--grad-bar); }
.legend i.fail { background: var(--grad-warm); }

/* Barras horizontais (no ar agora) */
.hbars { display: grid; gap: 12px; }
.hbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; }
.hbar .track { grid-column: 1 / -1; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 99px; background: var(--grad); }
.hbar .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }

/* Indicador "tocando": equalizador */
.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; vertical-align: -2px; }
.eq i { width: 3px; border-radius: 2px; background: var(--grad-bar); height: 40%; animation: eq 1s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -.3s; } .eq i:nth-child(3) { animation-delay: -.6s; } .eq i:nth-child(4) { animation-delay: -.15s; }
@keyframes eq { 0%, 100% { height: 30%; } 50% { height: 100%; } }
@media (prefers-reduced-motion: reduce) { .eq i { animation: none; height: 70%; } .eq i:nth-child(2n) { height: 100%; } }

/* ─── Estados ───────────────────────────────────────────────────────── */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip-ok { color: var(--ok); background: var(--chip-ok-bg); }
.chip-bad { color: var(--bad); background: var(--chip-bad-bg); }
.chip-warn { color: var(--warn); background: var(--chip-warn-bg); }
.chip-off { color: var(--muted); background: var(--chip-off-bg); }

.empty { padding: 28px 12px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); margin-bottom: 4px; }
.skeleton { height: 120px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s linear infinite; }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }
.error-box { padding: 16px; border-radius: var(--radius); background: var(--chip-bad-bg); color: var(--bad); }

/* ─── Tabelas ───────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--faint); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover td { background: var(--surface-2); }
td .sub { display: block; font-size: 12px; color: var(--muted); }
.mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 12.5px; }

/* Listas de alertas / eventos */
.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.feed li { display: grid; grid-template-columns: 10px 1fr; gap: 10px; align-items: start; }
.feed .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; background: var(--faint); }
.feed .dot.ok { background: var(--ok); } .feed .dot.bad { background: var(--bad); } .feed .dot.warn { background: var(--warn); }
.feed p { margin: 0; }
.feed li.alert { display: block; }
.alert a { text-decoration: none; }
.alert { border-left: 3px solid var(--bad); padding: 10px 12px; border-radius: var(--radius-sm); background: var(--chip-bad-bg); }
.alert.warn { border-color: var(--warn); background: var(--chip-warn-bg); }
.alert b { display: block; }

/* ─── Detalhe do dispositivo ────────────────────────────────────────── */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px 20px; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .input { max-width: 280px; }
.radio-pick { display: grid; gap: 6px; max-height: 340px; overflow: auto; }
.radio-pick label { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); }
.order-btns { display: inline-flex; gap: 4px; }
.logo { width: 32px; height: 32px; border-radius: 8px; object-fit: cover; background: var(--grad); flex: none; }
.cell-flex { display: flex; gap: 10px; align-items: center; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; }

/* ─── Modal / toast ─────────────────────────────────────────────────── */
dialog { border: 0; padding: 0; border-radius: var(--radius-lg); background: var(--surface); color: var(--ink); width: min(520px, calc(100vw - 32px)); box-shadow: 0 30px 80px -20px rgba(0,0,0,.45); }
dialog::backdrop { background: rgba(13,20,36,.55); }
.modal-head { padding: 18px 22px 0; display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 16px 22px; }
.modal-foot { padding: 0 22px 20px; display: flex; gap: 10px; justify-content: flex-end; }
.code-big { font-size: 34px; font-weight: 700; letter-spacing: .12em; text-align: center; padding: 18px; border-radius: var(--radius); background: var(--surface-2); margin: 8px 0 12px; }
.code-big span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 50; }
#toast div { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 500; margin-top: 8px; }

/* ─── Login ─────────────────────────────────────────────────────────── */
.login { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-art { background: var(--grad); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login-art h1 { font-size: 40px; max-width: 12ch; }
.login-art .eq-big { display: flex; align-items: flex-end; gap: 8px; height: 140px; }
.login-art .eq-big i { flex: 1; max-width: 18px; background: rgba(255,255,255,.85); border-radius: 6px 6px 2px 2px; }
.login-form { display: grid; place-items: center; padding: 32px 16px; }
.login-form form { width: min(360px, 100%); }
.login-form h2 { font-size: 22px; margin-bottom: 6px; }
.install { max-width: 440px; margin: 40px auto; padding: 24px; }

/* ─── Responsivo ────────────────────────────────────────────────────── */
@media (max-width: 1560px) {
  .row-3 { grid-template-columns: 1fr 1fr; }
  .row-3 > :first-child { grid-column: 1 / -1; }
}
@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; padding: 12px 16px; }
  .brand { padding: 0 8px 0 0; }
  .nav { display: flex; gap: 4px; overflow-x: auto; width: 100%; order: 3; }
  .nav a { padding: 8px 10px; white-space: nowrap; }
  .side-foot { margin: 0 0 0 auto; border: 0; padding: 0; }
  .side-foot b { display: none; }
  .side-foot button { margin: 0; }
  .main { padding: 20px 16px 32px; }
  .row-2, .row-3 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login { grid-template-columns: 1fr; }
  .login-art { padding: 28px 16px; }
  .login-art h1 { font-size: 28px; }
  .login-art .eq-big { height: 60px; }
}
@media (max-width: 420px) { .kpis { gap: 12px; } .kpi-body { padding: 12px 14px 14px; } .kpi-value { font-size: 26px; } }
