:root {
  --bg: #060B20; --panel: #0E1630; --panel-2: #131D3D; --line: #22305A; --text: #E8ECF8; --muted: #8E9BC2;
  --brand: #59E3B5; --brand-ink: #062A1F; --accent: #A891FF; --navy: #223A5F;
  --good: #59E3B5; --warn: #F6C453; --bad: #FF6B7A; --radius: 14px;
  font-family: Inter, ui-sans-serif, 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); }
body { min-height: 100vh; font-size: 15px; line-height: 1.45; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.1rem; } h3 { font-size: 0.95rem; color: var(--muted); font-weight: 600; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--brand); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 32px; display: grid; gap: 16px; }
.login-card .logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; }
.logo-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--navy); display: grid; place-items: center; }
.muted { color: var(--muted); } .small { font-size: 0.85rem; }

/* Layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: #080F26; border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; }
.side .logo { display: flex; align-items: center; gap: 10px; font-weight: 700; padding: 4px 10px 16px; }
.nav { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0; padding: 10px 12px; border-radius: 10px; cursor: pointer; text-align: left; color: var(--muted); }
.nav:hover { background: var(--panel); color: var(--text); }
.nav[aria-current="page"] { background: var(--panel-2); color: var(--text); box-shadow: inset 3px 0 0 var(--brand); }
.side .spacer { flex: 1; }
.who { padding: 10px 12px; font-size: 0.82rem; color: var(--muted); word-break: break-all; }
.main { padding: 28px clamp(16px, 3vw, 40px) 60px; display: grid; gap: 22px; align-content: start; min-width: 0; }
.head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.head .tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; }
  .side .logo, .side .who, .side .spacer { display: none; }
  .nav { width: auto; padding: 8px 10px; }
}

/* Componentes */
.grid { display: grid; gap: 14px; }
.cards { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card .label { color: var(--muted); font-size: 0.82rem; }
.card .value { font-size: 1.9rem; font-weight: 700; margin-top: 4px; letter-spacing: -0.02em; }
.card .sub { color: var(--muted); font-size: 0.82rem; margin-top: 2px; }
.card h2 { margin-bottom: 12px; }
.chart { position: relative; height: 240px; }
.chart.tall { height: 300px; }
.meter { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.meter > span { display: block; height: 100%; border-radius: 99px; background: var(--good); }
.meter.warn > span { background: var(--warn); } .meter.bad > span { background: var(--bad); }
.stack { display: flex; height: 26px; border-radius: 8px; overflow: hidden; background: var(--panel-2); margin-top: 8px; }
.stack > span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 0.82rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.hero { background: linear-gradient(135deg, #14264a, #0E1630 60%); border: 1px solid var(--line); border-radius: 18px; padding: 24px; }
.hero .big { font-size: clamp(1.4rem, 3vw, 2.1rem); font-weight: 700; letter-spacing: -0.02em; margin: 6px 0; }
.hero .big b { color: var(--brand); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 0.75rem; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.badge.good { color: var(--good); border-color: #1d5b49; } .badge.warn { color: var(--warn); border-color: #6a5420; } .badge.bad { color: var(--bad); border-color: #6a2a33; }
.notice { border: 1px solid #6a5420; background: #2a2210; color: #f2dca0; border-radius: 10px; padding: 10px 14px; font-size: 0.88rem; }

/* Tablas */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; }
table.wide { min-width: 860px; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--panel); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { white-space: nowrap; text-align: right; }

/* Formularios y botones */
.btn { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 650; }
.btn.danger { color: var(--bad); border-color: #6a2a33; }
.btn.small { padding: 4px 10px; font-size: 0.82rem; border-radius: 8px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.field { display: grid; gap: 6px; }
.field label { font-size: 0.82rem; color: var(--muted); }
input, select { background: #0A1230; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; }
input:focus, select:focus, .btn:focus-visible, .nav:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { background: none; border: 0; padding: 7px 12px; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--panel-2); color: var(--text); }
.err { color: var(--bad); font-size: 0.88rem; min-height: 1.2em; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row .grow { flex: 1 1 200px; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 0; width: min(460px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(2, 5, 16, 0.7); }
dialog form { padding: 24px; display: grid; gap: 14px; }
dialog .buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line); padding: 10px 18px; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 10; }
#toast.show { opacity: 1; }
.qr { background: #fff; padding: 8px; border-radius: 10px; width: max-content; }
code { background: var(--panel-2); padding: 2px 6px; border-radius: 6px; word-break: break-all; }

.row input, .row select { width: auto; min-width: 150px; }
.row .grow input { width: 100%; }
.nowrap { white-space: nowrap; }
