:root {
  --navy-900: #071428;
  --navy-800: #0b1f3a;
  --navy-700: #12305a;
  --primary: #1f6feb;
  --primary-600: #1959c4;
  --accent: #00b8a9;
  --ok: #12a150;
  --ok-bg: #e7f7ee;
  --warn: #d97706;
  --warn-bg: #fef3e2;
  --bad: #dc3545;
  --bad-bg: #fdecee;
  --info-bg: #eaf1fe;
  --bg: #f2f5fa;
  --card: #ffffff;
  --text: #0f1b2d;
  --muted: #64748b;
  --line: #e3e8f0;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 27, 45, .04), 0 8px 24px rgba(15, 27, 45, .06);
  --teal-bg: #e0f7f5;
  --card-2: #f8fafd;
  --head-bg: #f6f8fc;
  --row-line: #eef2f7;
  --row-hover: #f8faff;
  --sel-bg: #f3f7ff;
  --track: #cbd5e1;
  --bar-bg: #e9eef5;
  --text-2: #334155;
  --bad-text: #a61b29;
  --ok-line: #bfe8cf; --warn-line: #f6d9a8; --bad-line: #f5c2c7; --info-line: #c9dafc;
  --ctrl: #6d28d9; --ctrl-bg: #f1ebff;
  --flash: #dff7ee;
  --li-bg: rgba(255, 255, 255, .7);
  color-scheme: light;
}

/* ---------- Modo oscuro ---------- */
:root[data-theme="dark"] {
  --primary: #4c8dff;
  --primary-600: #2f6fe0;
  --accent: #19c9b9;
  --ok: #34c77b;   --ok-bg: rgba(52, 199, 123, .14);
  --warn: #f0a33a; --warn-bg: rgba(240, 163, 58, .14);
  --bad: #f2596a;  --bad-bg: rgba(242, 89, 106, .14);
  --info-bg: rgba(76, 141, 255, .15);
  --teal-bg: rgba(25, 201, 185, .14);
  --bg: #0a1220;
  --card: #111c2e;
  --card-2: #142136;
  --head-bg: #16233a;
  --text: #e6edf7;
  --text-2: #c3cfe0;
  --muted: #8c9bb3;
  --line: #22314a;
  --row-line: #1b2940;
  --row-hover: #16243b;
  --sel-bg: rgba(76, 141, 255, .12);
  --track: #334155;
  --bar-bg: #1e2d45;
  --bad-text: #ff9aa5;
  --ok-line: rgba(52, 199, 123, .35); --warn-line: rgba(240, 163, 58, .35); --bad-line: rgba(242, 89, 106, .35); --info-line: rgba(76, 141, 255, .35);
  --ctrl: #b79bff; --ctrl-bg: rgba(139, 92, 246, .18);
  --flash: rgba(52, 199, 123, .22);
  --li-bg: rgba(255, 255, 255, .05);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}
:root[data-theme="dark"] .sidebar { background: linear-gradient(180deg, #08162b, #050d1a); border-right: 1px solid var(--line); }
#btn-theme { width: 40px; padding: 0; justify-content: center; }
#btn-theme .i-sun { display: none; }
:root[data-theme="dark"] #btn-theme .i-sun { display: block; }
:root[data-theme="dark"] #btn-theme .i-moon { display: none; }
body, .card, .kpi, .gate, .sector, select, .search, th { transition: background-color .2s, border-color .2s, color .2s; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
svg { width: 18px; height: 18px; flex: none; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12.5px; }
code { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 12.5px; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 256px; flex: none; height: 100vh; position: sticky; top: 0;
  background: linear-gradient(180deg, var(--navy-800), var(--navy-900));
  color: #c9d5e8; display: flex; flex-direction: column; padding: 22px 16px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 26px; }
.logo {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 6px 18px rgba(31, 111, 235, .45);
}
.logo svg { width: 22px; height: 22px; }
.brand-text strong { display: block; color: #fff; font-size: 16px; letter-spacing: .2px; }
.brand-text span { font-size: 12px; color: #8ea3c2; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: #6b81a3; padding: 14px 12px 6px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px;
  border: 0; background: transparent; color: #c9d5e8; text-align: left; font-weight: 500; transition: .15s;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(31, 111, 235, .35), rgba(31, 111, 235, .08));
  color: #fff; box-shadow: inset 3px 0 0 var(--accent);
}
.sidebar-foot { margin-top: auto; }
.conn {
  display: flex; gap: 10px; align-items: center; padding: 12px; border-radius: 12px;
  background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .07);
}
.conn strong { display: block; color: #fff; font-size: 13px; }
.conn span:not(.dot) { font-size: 11.5px; color: #8ea3c2; word-break: break-all; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #94a3b8; flex: none; }
.conn.ok .dot { background: #22c55e; box-shadow: 0 0 0 4px rgba(34, 197, 94, .2); animation: pulse 2s infinite; }
.conn.demo .dot { background: #f59e0b; box-shadow: 0 0 0 4px rgba(245, 158, 11, .2); }
.conn.err .dot { background: var(--bad); }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); } }

/* ---------- Main / topbar ---------- */
.main { flex: 1; min-width: 0; padding: 24px 28px 40px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.titles h1 { margin: 0; font-size: 24px; letter-spacing: -.3px; }
.titles p { margin: 4px 0 0; color: var(--muted); }
.top-actions { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); }
select, .field input, .search input {
  height: 40px; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 0 12px; outline: none;
  transition: border .15s, box-shadow .15s;
}
select:focus, .field input:focus, .search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31, 111, 235, .15); }
#sel-evento { min-width: 280px; font-weight: 600; }

.btn {
  height: 40px; border-radius: 10px; padding: 0 16px; display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid transparent; font-weight: 600; transition: .15s; white-space: nowrap;
}
.btn.sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary-600)); color: #fff; box-shadow: 0 6px 16px rgba(31, 111, 235, .3); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: var(--card); border-color: var(--line); color: var(--text); }
.btn.ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn.outline { background: transparent; border-color: var(--line); color: var(--text); }
.btn.outline:hover { border-color: var(--primary); color: var(--primary); }
.btn:disabled { opacity: .6; cursor: wait; }
#btn-refresh { width: 40px; padding: 0; justify-content: center; }
#btn-refresh.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.switch { display: flex; align-items: center; gap: 8px; height: 40px; cursor: pointer; user-select: none; font-weight: 600; }
.switch input { display: none; }
.track { width: 38px; height: 22px; border-radius: 99px; background: var(--track); position: relative; transition: .2s; }
.track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { left: 19px; }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: 18px; padding: 26px 30px; margin-bottom: 18px;
  display: flex; justify-content: space-between; align-items: center; gap: 20px; color: #fff;
  background:
    radial-gradient(600px 220px at 85% -20%, rgba(0, 184, 169, .45), transparent 70%),
    radial-gradient(500px 260px at 10% 130%, rgba(31, 111, 235, .55), transparent 70%),
    linear-gradient(120deg, var(--navy-800), var(--navy-700));
  box-shadow: 0 14px 34px rgba(11, 31, 58, .25);
}
.hero::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .08;
  background-image: linear-gradient(rgba(255,255,255,.6) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.6) 1px, transparent 1px);
  background-size: 28px 28px;
}
.hero-info { position: relative; z-index: 1; min-width: 0; }
.hero h2 { margin: 10px 0 8px; font-size: 28px; letter-spacing: -.4px; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 8px 22px; color: #c3d3ea; }
.hero-meta span:empty { display: none; }
.badge {
  display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase;
  padding: 5px 11px; border-radius: 99px; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .18);
}
.badge.live { background: rgba(220, 53, 69, .9); border-color: transparent; }
.badge.live::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.ring {
  --p: 0; position: relative; z-index: 1; width: 124px; height: 124px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), rgba(255, 255, 255, .14) 0);
  display: grid; place-items: center; transition: --p .6s;
}
.ring-in { width: 98px; height: 98px; border-radius: 50%; background: var(--navy-800); display: grid; place-content: center; text-align: center; }
.ring-in strong { font-size: 24px; }
.ring-in span { font-size: 11px; color: #9fb3d1; text-transform: uppercase; letter-spacing: .8px; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.kpi {
  background: var(--card); border-radius: var(--radius); padding: 18px 18px 16px; box-shadow: var(--shadow);
  border: 1px solid var(--line); position: relative; overflow: hidden;
}
.kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c, var(--primary)); }
.kpi-top { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-weight: 600; font-size: 12.5px; }
.kpi-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: var(--c, var(--primary)); background: var(--cb, var(--info-bg)); }
.kpi-val { font-size: 30px; font-weight: 800; letter-spacing: -.8px; margin: 8px 0 2px; font-variant-numeric: tabular-nums; }
.kpi-foot { font-size: 12px; color: var(--muted); }

/* ---------- Cards ---------- */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.card { background: var(--card); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); border: 1px solid var(--line); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head.wrap { flex-wrap: wrap; }
.card-head h3 { margin: 0; font-size: 15.5px; display: flex; align-items: center; gap: 8px; }
.count { font-size: 12px; font-weight: 700; background: var(--info-bg); color: var(--primary); padding: 2px 9px; border-radius: 99px; }
.count.warn { background: var(--warn-bg); color: var(--warn); }
.count.bad { background: var(--bad-bg); color: var(--bad); }
.count:empty { display: none; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw-ok { background: var(--primary); }
.sw-bad { background: var(--bad); }
.chart-box { position: relative; height: 280px; }

/* ---------- Gates ---------- */
.gates { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.gate {
  text-align: left; border: 1px solid var(--line); background: linear-gradient(180deg, var(--card), var(--card-2)); border-radius: 12px; padding: 14px;
  transition: .15s; position: relative;
}
.gate:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); }
.gate.sel { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31, 111, 235, .15); background: var(--sel-bg); }
.gate-name { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13.5px; }
.gate-name .g-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--track); }
.gate-name .g-dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(18, 161, 80, .18); }
.gate-val { font-size: 24px; font-weight: 800; margin: 8px 0 6px; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.bar { height: 6px; border-radius: 99px; background: var(--bar-bg); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .6s; }
.gate-foot { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.gate-foot b { color: var(--bad); font-weight: 600; }

/* ---------- Filters / table ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.search { display: flex; align-items: center; gap: 8px; height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: var(--card); }
.search input { border: 0; height: 100%; padding: 0; box-shadow: none !important; width: 200px; background: transparent; }
.search svg { color: var(--muted); }
.search.big { height: 52px; flex: 1; }
.search.big input { width: 100%; font-size: 16px; font-weight: 500; }
.table-wrap { overflow: auto; max-height: 520px; border: 1px solid var(--line); border-radius: 10px; }
.table-wrap.short { max-height: 360px; }
table { width: 100%; border-collapse: collapse; }
th { position: sticky; top: 0; z-index: 1; background: var(--head-bg); text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); padding: 11px 14px; border-bottom: 1px solid var(--line); }
td { padding: 10px 14px; border-bottom: 1px solid var(--row-line); white-space: nowrap; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--row-hover); }
tbody tr.nuevo { animation: flash 2.4s ease-out; }
@keyframes flash { from { background: var(--flash); } to { background: transparent; } }
td.mono { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-weight: 600; }
td.empty { text-align: center; color: var(--muted); padding: 36px; white-space: normal; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 99px; }
.tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag.ok { color: var(--ok); background: var(--ok-bg); }
.tag.bad { color: var(--bad); background: var(--bad-bg); }
.tag.warn { color: var(--warn); background: var(--warn-bg); }

/* ---------- Validador ---------- */
.ticket-form { display: flex; gap: 10px; }
.ticket-form .btn { height: 52px; padding: 0 26px; }
.ticket-result { margin-top: 16px; border-radius: 12px; padding: 18px; border: 1px solid var(--line); }
.ticket-result.empty { color: var(--muted); background: var(--card-2); border-style: dashed; }
.ticket-result.empty p { margin: 0; line-height: 1.5; }
.tr-head { display: flex; align-items: center; gap: 14px; }
.tr-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; color: #fff; flex: none; }
.tr-icon svg { width: 26px; height: 26px; }
.tr-head strong { display: block; font-size: 18px; }
.tr-head span { color: var(--muted); }
.tr-list { margin: 14px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.tr-list li { display: flex; justify-content: space-between; gap: 10px; background: var(--li-bg); padding: 8px 12px; border-radius: 8px; font-size: 13px; }
.ticket-result.ok { background: var(--ok-bg); border-color: var(--ok-line); } .ticket-result.ok .tr-icon { background: var(--ok); }
.ticket-result.warn { background: var(--warn-bg); border-color: var(--warn-line); } .ticket-result.warn .tr-icon { background: var(--warn); }
.ticket-result.bad { background: var(--bad-bg); border-color: var(--bad-line); } .ticket-result.bad .tr-icon { background: var(--bad); }
.ticket-result.none { background: var(--info-bg); border-color: var(--info-line); } .ticket-result.none .tr-icon { background: #64748b; }
.ticket-result.pop { animation: pop .35s ease-out; }
@keyframes pop { from { transform: scale(.97); opacity: .4; } }

.dist { display: flex; align-items: center; gap: 24px; }
.chart-box.donut { width: 230px; height: 230px; flex: none; }
.dist-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; flex: 1; min-width: 0; }
.dist-legend li { display: grid; grid-template-columns: 12px 1fr auto; gap: 10px; align-items: center; }
.dist-legend i { width: 12px; height: 12px; border-radius: 3px; }
.dist-legend b { font-variant-numeric: tabular-nums; }
.dist-legend small { grid-column: 2 / 4; color: var(--muted); margin-top: -8px; }

/* ---------- Conexión ---------- */
.conn-grid { grid-template-columns: 1.3fr 1fr; }
.form { display: grid; gap: 14px; }
.row { display: flex; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.w120 { width: 120px; }
.form .field input { width: 100%; }
.checks { display: flex; flex-wrap: wrap; gap: 10px 22px; color: var(--muted); font-weight: 500; }
.checks label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.checks input { accent-color: var(--primary); width: 16px; height: 16px; }
.actions { display: flex; justify-content: flex-end; gap: 10px; }
.alert { background: var(--bad-bg); color: var(--bad-text); border: 1px solid var(--bad-line); padding: 12px 14px; border-radius: 10px; font-size: 13px; }
.pill { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 99px; background: var(--warn-bg); color: var(--warn); }
.pill.sql { background: var(--ok-bg); color: var(--ok); }
.help ol { margin: 0; padding-left: 20px; display: grid; gap: 10px; line-height: 1.45; color: var(--text-2); }
.schema { margin-top: 18px; display: grid; gap: 6px; background: var(--navy-800); color: #cfe0ff; padding: 14px; border-radius: 10px; }
.schema span { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #7f97bb; font-weight: 700; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; right: 24px; bottom: 24px; z-index: 50; background: var(--navy-800); color: #fff; padding: 12px 18px; border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,.25); opacity: 0; transform: translateY(10px); transition: .25s; pointer-events: none; max-width: 420px;
}
.toast.show { opacity: 1; transform: none; }
.toast.err { background: var(--bad); }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .conn-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  body { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; padding: 14px 16px; }
  .brand { padding-bottom: 10px; }
  .nav { flex-direction: row; overflow-x: auto; }
  .nav-label, .sidebar-foot { display: none; }
  .main { padding: 16px; }
  #sel-evento { min-width: 0; width: 100%; }
  .top-actions, .top-actions .field { width: 100%; }
  .hero { padding: 20px; }
  .hero h2 { font-size: 22px; }
  .ring { width: 96px; height: 96px; } .ring-in { width: 76px; height: 76px; } .ring-in strong { font-size: 18px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-val { font-size: 24px; }
  .row { flex-direction: column; } .w120 { width: 100%; }
  .dist { flex-direction: column; }
  .search input { width: 100%; }
  .filters, .filters > * { width: 100%; }
}

/* enlaces de ticket y columnas que deben ajustarse */
a[data-ticket] { color: var(--primary); text-decoration: none; }
a[data-ticket]:hover { text-decoration: underline; }
td.wrap { white-space: normal; min-width: 160px; }

.tag.info { color: var(--primary); background: var(--info-bg); }
.motivos { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px 0 12px; }
.motivos span { font-size: 12px; background: var(--bad-bg); color: var(--bad-text); border-radius: 99px; padding: 4px 10px; font-weight: 600; }
.motivos span b { font-variant-numeric: tabular-nums; margin-left: 4px; }
.tr-info { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 16px; margin-top: 14px; font-size: 13px; }
.tr-info div span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; font-weight: 600; }
.tr-info div b { word-break: break-all; }

.stack { display: grid; gap: 18px; margin-bottom: 18px; }
.stack .chart-box { height: 260px; }
td.mono { max-width: 300px; overflow: hidden; text-overflow: ellipsis; }
.badge.today { background: rgba(0, 184, 169, .85); border-color: transparent; }
.table-wrap.short td.mono { max-width: 190px; }
.gate-foot span { white-space: nowrap; }

/* Puntos de control y localidades */
.ctrl { display: inline-block; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--ctrl); background: var(--ctrl-bg); border-radius: 6px; padding: 2px 7px; margin-top: 6px; }
td .ctrl { margin: 0 0 0 6px; }
.sectores { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.sector { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: linear-gradient(180deg, var(--card), var(--card-2)); }
.sector-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.sector-top strong { font-size: 13.5px; }
.sector-top span { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.sector-top small { font-size: 12px; color: var(--muted); font-weight: 600; }
.sector-foot { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--muted); margin-top: 8px; }

/* ---------- Login ---------- */
body.login-page { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100vh; }
.login-side {
  color: #fff; padding: 40px 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
  background:
    radial-gradient(600px 300px at 90% 0%, rgba(0, 184, 169, .4), transparent 70%),
    radial-gradient(600px 340px at 0% 100%, rgba(31, 111, 235, .5), transparent 70%),
    linear-gradient(150deg, var(--navy-800), var(--navy-900));
}
.login-side::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .06;
  background-image: linear-gradient(rgba(255,255,255,.6) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.6) 1px, transparent 1px);
  background-size: 28px 28px;
}
.login-side .brand { padding: 0; position: relative; z-index: 1; }
.login-pitch { position: relative; z-index: 1; max-width: 440px; margin-bottom: 40px; }
.login-pitch h2 { font-size: 32px; letter-spacing: -.6px; line-height: 1.15; margin: 0 0 12px; }
.login-pitch p { color: #c3d3ea; line-height: 1.55; margin: 0 0 20px; }
.login-pitch ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; color: #dbe6f5; }
.login-pitch li { display: flex; align-items: center; gap: 10px; }
.login-pitch li::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(0, 184, 169, .2); }
.login-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px 24px; position: relative; }
.login-card { width: 100%; max-width: 380px; display: grid; gap: 16px; margin: auto 0; }
.login-card h1 { margin: 0; font-size: 26px; letter-spacing: -.4px; }
.login-card .muted { margin: -8px 0 6px; font-size: 13.5px; }
.login-card .field input { width: 100%; height: 44px; }
.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 44px !important; }
.pass-eye { position: absolute; right: 4px; top: 4px; width: 36px; height: 36px; border: 0; background: transparent; color: var(--muted); border-radius: 8px; display: grid; place-items: center; }
.pass-eye:hover { color: var(--primary); }
.login-btn { height: 46px; justify-content: center; font-size: 15px; margin-top: 4px; }
.login-foot { margin-top: 32px; font-size: 12.5px; color: var(--muted); text-align: center; }
.login-foot strong { color: var(--text); font-weight: 600; }
.login-theme { position: fixed; top: 16px; right: 16px; z-index: 5; }
@media (max-width: 820px) {
  body.login-page { grid-template-columns: 1fr; }
  .login-side { padding: 22px 16px; }
  .login-pitch { display: none; }
}

/* Cerrar sesión */
.btn-logout { width: 100%; margin-top: 10px; justify-content: center; background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.1); color: #c9d5e8; }
.btn-logout:hover { background: rgba(255,255,255,.1); color: #fff; }

/* Integración bTicket */
.int-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.int-stats div { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--card-2); }
.int-stats span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; }
.int-stats b { font-size: 16px; }
.int-sub { margin: 0 0 10px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
#view-conexion .alert { margin-top: 14px; }
#view-conexion .actions { margin-top: 16px; }
#tbody-endpoints td.mono { max-width: 340px; font-weight: 500; font-size: 12px; }
.int-nota { margin: 14px 0 0; }

/* Usuarios de solo consulta: se ocultan las opciones de configuracion */
.rol-consulta .solo-admin { display: none !important; }

/* ---------- Usuarios ---------- */
.usr-grid { grid-template-columns: 1fr 1fr; }
.usr-intro { margin: -4px 0 14px; line-height: 1.5; }
.usr-acc { white-space: nowrap; text-align: right; }
.usr-acc .btn + .btn { margin-left: 6px; }
.usr-acc-h { text-align: right; }
.btn.danger:hover { border-color: var(--bad); color: var(--bad); }
.cred-card { border: 1px solid var(--ok); }
.cred { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; margin: 0 0 14px; align-items: center; }
.cred dt { font-size: 12px; font-weight: 600; color: var(--muted); }
.cred dd { margin: 0; word-break: break-all; }
.cred .mono, dd.mono { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-weight: 600; }
.cred-clave { font-size: 20px; letter-spacing: 1.5px; color: var(--ok); user-select: all; background: var(--ok-bg); padding: 8px 12px; border-radius: 8px; }
.cred-aviso { font-size: 12.5px; color: var(--warn); margin: 0 0 14px; }
.card .actions { flex-wrap: wrap; }
@media (max-width: 900px) { .usr-grid { grid-template-columns: 1fr; } .usr-acc { white-space: normal; } }
.btn-logout + .btn-logout { margin-top: 6px; }
.miclave-card { margin-top: 18px; }
.miclave-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 14px; align-items: end; }
.miclave-grid .field input { width: 100%; }
.miclave-nota { margin: 14px 0 0; line-height: 1.5; }
@media (max-width: 900px) { .miclave-grid { grid-template-columns: 1fr; } }
