/* Portal Red Ruijie — Manual de Identidad Visual Bytelink SAS
   Primarios: #00B3FF #006DFF #0022AF #170041 · Degradados: #00B3FF→#006DFF y #00B3FF→#006DFF(89%)→#0022AF
   Secundarios: #FFFFFF #F6F9FB #EDF2F5 #D1D6DB #B5BAC1 #9A9FA8 #7E838E #626874 #464C5A #2A3040 #161B27
   Tipografía: Poppins Light / Medium / Semibold, tracking -25 */
@font-face { font-family: "PoppinsLocal"; font-weight: 300; font-display: swap; src: url("/static/fonts/Poppins-Light.woff2") format("woff2"); }
@font-face { font-family: "PoppinsLocal"; font-weight: 500 600; font-display: swap; src: url("/static/fonts/Poppins-Medium.woff2") format("woff2"); }
:root {
  --b1: #00B3FF; --b2: #006DFF; --b3: #0022AF; --b4: #170041;
  --grad: linear-gradient(135deg, #00B3FF 0%, #006DFF 100%);
  --grad-3: linear-gradient(90deg, #00B3FF 0%, #006DFF 89%, #0022AF 100%);
  --g0: #FFFFFF; --g1: #F6F9FB; --g2: #EDF2F5; --g3: #D1D6DB; --g4: #B5BAC1; --g5: #9A9FA8;
  --g6: #7E838E; --g7: #626874; --g8: #464C5A; --g9: #2A3040; --g10: #161B27;
  --bg: var(--g1); --surface: var(--g0); --surface-2: var(--g1); --line: var(--g2); --line-2: var(--g3);
  --text: var(--g10); --heading: var(--b4); --muted: var(--g7); --faint: var(--g5);
  --ok: #0E9F6E; --ok-bg: #E4F6EE; --warn: #C27803; --warn-bg: #FDF3DC; --bad: #D92D20; --bad-bg: #FDE8E7;
  --info: var(--b2); --info-bg: #E5F0FF;
  --side: linear-gradient(160deg, #240A60 0%, #170041 60%, #12003A 100%); --side-2: rgba(255,255,255,.07); --side-text: #CFCBE6; --side-line: rgba(255,255,255,.08);
  --radius: 12px; --shadow: 0 1px 2px rgba(23,0,65,.05), 0 1px 3px rgba(23,0,65,.06);
  --font: Poppins, PoppinsLocal, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0F0230; --surface: #1A0748; --surface-2: #150540; --line: #2A1764; --line-2: #3A2680;
  --text: var(--g2); --heading: #FFFFFF; --muted: var(--g4); --faint: var(--g6);
  --ok: #34D399; --ok-bg: rgba(52,211,153,.12); --warn: #FBBF24; --warn-bg: rgba(251,191,36,.12);
  --bad: #F87171; --bad-bg: rgba(248,113,113,.13); --info: var(--b1); --info-bg: rgba(0,179,255,.13);
  --side: linear-gradient(160deg, #1B0650 0%, #12003A 60%, #0B0026 100%);
  --shadow: 0 1px 2px rgba(0,0,0,.4);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-weight: 300; font-size: 14px; letter-spacing: -.025em;
  color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
b, strong { font-weight: 500; }
h1, h2, h3, h4 { color: var(--heading); }
a { color: var(--b2); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
.mono { font-family: var(--mono); font-size: 12.5px; letter-spacing: 0; font-weight: 400; }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.boot { display: grid; place-items: center; height: 100vh; background: var(--b4); }
.boot img { width: 56px; height: 56px; animation: pulse 1s infinite alternate; }
@keyframes pulse { to { transform: scale(1.12); opacity: .55; } }

/* trazos curvos del manual (portadas) */
.brand-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.brand-lines path, .brand-lines rect { fill: none; stroke: #006DFF; stroke-width: 1.2; opacity: .75; }

/* logotipo — área de respeto 2X; nunca alterar colores, proporciones ni aplicar sombras */
.logo-claro { display: block; height: 30px; width: auto; }
.isotipo { display: block; width: 30px; height: 30px; }

/* ---------- login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero { background: linear-gradient(135deg, #250A62 0%, #170041 55%, #12003A 100%);
  color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-hero > * { position: relative; z-index: 1; }
.login-hero .brand-lines { z-index: 0; opacity: .5; }
.login-hero .logo-claro { height: 42px; }
.login-hero h1 { color: #fff; font-weight: 300; font-size: 40px; line-height: 1.15; margin: 0 0 14px; }
.login-hero h1 b { font-weight: 600; }
.login-hero h1 .n { color: var(--b1); font-weight: 300; }
.login-hero p { max-width: 460px; color: #CFCBE6; line-height: 1.6; }
.login-hero .meta { font-size: 12px; color: #9C94C8; }
.login-card { display: grid; place-items: center; padding: 32px; background: var(--surface); }
.login-card form { width: 100%; max-width: 360px; }
.login-card .isotipo { width: 44px; height: 44px; margin-bottom: 26px; }
.login-card h2 { font-weight: 600; font-size: 24px; margin: 0 0 6px; }
.foot-legal { font-size: 11.5px; color: var(--faint); margin-top: 26px; text-align: center; }

/* ---------- layout */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); padding: 22px 12px 16px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow: hidden; }
.side .brand-lines { opacity: .28; }
.side > * { position: relative; }
.login-hero > .brand-lines, .side > .brand-lines { position: absolute; inset: 0; }
.side .logo-wrap { padding: 2px 12px 20px; }
.side .logo-wrap .logo-claro { height: 28px; }
.side .logo-wrap small { display: block; font-size: 11px; color: #9C94C8; margin-top: 6px; letter-spacing: .02em; }
.nav-label { font-size: 10.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .1em; color: #8A82BC; padding: 14px 12px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: var(--side-text); font-size: 13.5px; }
.nav a:hover { background: var(--side-2); color: #fff; text-decoration: none; }
.nav a.on { background: linear-gradient(90deg, rgba(0,179,255,.22), rgba(0,109,255,.06)); color: #fff; font-weight: 500; box-shadow: inset 3px 0 0 var(--b1); }
.nav svg { width: 17px; height: 17px; flex: none; opacity: .9; }
.nav .count { margin-left: auto; background: var(--bad); color: #fff; font-size: 11px; font-weight: 500; border-radius: 99px; padding: 1px 7px; letter-spacing: 0; }
.side-foot { margin-top: auto; border-top: 1px solid var(--side-line); padding: 12px 8px 0; font-size: 12px; }
.side-foot .who { color: #fff; font-weight: 500; font-size: 13px; }
.side-foot .row { display: flex; gap: 6px; margin-top: 10px; }
.side-foot button { flex: 1; background: var(--side-2); border: 0; color: var(--side-text); border-radius: 8px; padding: 7px 4px; cursor: pointer; font-size: 11.5px; white-space: nowrap; }
.side-foot button:hover { color: #fff; background: rgba(0,179,255,.18); }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 20px 28px 6px; }
.topbar h1 { font-size: 24px; font-weight: 600; margin: 0; }
.topbar .crumb { color: var(--muted); font-size: 13px; }
.topbar .sp { flex: 1; }
.page { padding: 14px 28px 40px; }
.btn.menu-btn { display: none; }
.tbl td.nw, .tbl td .nw { white-space: nowrap; }

/* ---------- componentes */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card-h h3 { margin: 0; font-size: 14.5px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.card-h h3::before { content: ""; width: 14px; height: 14px; border-radius: 2px; background: var(--grad); flex: none; }
.card-h .sp { flex: 1; }
.card-b { padding: 16px; }
.grid { display: grid; gap: 16px; }
.g-kpi { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.g-2 { grid-template-columns: 1.6fr 1fr; }
.g-kpi3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-kpi3 .kpi .v { font-size: 24px; }
.g-2e { grid-template-columns: 1fr 1fr; }
.kpi { padding: 14px 16px; }
.kpi .l { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .v { font-size: 28px; font-weight: 600; color: var(--heading); margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--faint); }
.kpi.accent { background: var(--grad); color: #fff; border: 0; }
.kpi.accent .v { color: #fff; }
.kpi.accent .l, .kpi.accent .s { color: rgba(255,255,255,.85); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); } .dot.warn { background: var(--warn); } .dot.off { background: var(--faint); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; letter-spacing: 0; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); } .pill.info { background: var(--info-bg); color: var(--info); }
.pill.neutral { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.sev-critica { background: var(--bad-bg); color: var(--bad); } .sev-mayor { background: var(--warn-bg); color: var(--warn); }
.sev-menor { background: var(--info-bg); color: var(--info); } .sev-info { background: var(--surface-2); color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line-2); background: var(--surface);
  border-radius: 9px; padding: 7px 13px; cursor: pointer; font-size: 13px; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--b2); color: var(--b2); }
.btn.primary { background: var(--grad); border-color: transparent; color: #fff; }
.btn.primary:hover { background: var(--grad-3); color: #fff; }
.btn.danger { color: var(--bad); border-color: var(--bad-bg); background: var(--bad-bg); }
.btn.danger:hover { background: var(--bad); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 7px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; }
.field label { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.field .hint { font-size: 11.5px; color: var(--faint); }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line-2); background: var(--surface); border-radius: 9px; padding: 9px 11px; outline: none; }
.input:focus { border-color: var(--b2); box-shadow: 0 0 0 3px rgba(0,109,255,.15); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 10px; cursor: pointer; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.err { background: var(--bad-bg); color: var(--bad); padding: 9px 12px; border-radius: 9px; font-size: 13px; margin-bottom: 12px; }
.note { background: var(--info-bg); color: var(--text); padding: 11px 13px; border-radius: 10px; font-size: 13px; line-height: 1.5; border: 1px solid transparent; }
.note.warn { background: var(--warn-bg); }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar .input { width: auto; min-width: 150px; padding: 7px 10px; }
.toolbar .search { min-width: 240px; flex: 1; max-width: 360px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; cursor: pointer; font-size: 12.5px; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 500; }

.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 500; letter-spacing: .06em; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint);
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); position: sticky; top: 0; white-space: nowrap; }
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--surface-2); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 38px 16px; text-align: center; color: var(--faint); }

/* sedes */
.sites { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.site { padding: 14px; cursor: pointer; position: relative; overflow: hidden; transition: border-color .15s, transform .15s; }
.site:hover { border-color: var(--b2); transform: translateY(-1px); }
.site::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--ok); }
.site.degradada::before { background: var(--warn); } .site.caida::before { background: var(--bad); } .site.sin_datos::before { background: var(--line-2); }
.site .n { font-weight: 600; font-size: 14px; color: var(--heading); }
.site .t { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.site .stats { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.site .stats b { color: var(--text); font-weight: 600; font-size: 15px; display: block; font-variant-numeric: tabular-nums; }
.bar { height: 5px; background: var(--surface-2); border-radius: 9px; overflow: hidden; margin: 10px 0 0; }
.bar i { display: block; height: 100%; background: var(--grad); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--b2); border-color: var(--b2); }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-all; }

.list-alarm { display: flex; flex-direction: column; }
.list-alarm .it { display: flex; gap: 10px; padding: 11px 16px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.list-alarm .it:last-child { border: 0; }
.list-alarm .m { font-size: 13px; } .list-alarm .w { font-size: 11.5px; color: var(--faint); }

.chart { width: 100%; height: auto; display: block; }
.chart .axis { stroke: var(--line); } .chart text { fill: var(--faint); font-size: 11px; font-family: var(--font); }
.chart .ln { fill: none; stroke: var(--b2); stroke-width: 2; } .chart .ar { fill: url(#cg); }
.chart .ln2 { fill: none; stroke: var(--b1); stroke-width: 1.5; stroke-dasharray: 4 3; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

.rep { padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.rep h4 { margin: 0; font-size: 15px; font-weight: 600; }
.rep p { margin: 0 0 6px; color: var(--muted); font-size: 13px; line-height: 1.5; flex: 1; }
.rep .ic { width: 38px; height: 38px; border-radius: 10px; background: var(--grad); color: #fff; display: grid; place-items: center; }
.rep .ic svg { width: 20px; height: 20px; }

/* modal y cajón */
.overlay { position: fixed; inset: 0; background: rgba(8,12,28,.48); z-index: 40; display: flex; justify-content: center; align-items: flex-start; padding: 6vh 16px; overflow-y: auto; animation: fade .12s; }
.overlay.drawer { justify-content: flex-end; align-items: stretch; padding: 0; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 520px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.drawer .modal { max-width: 620px; border-radius: 0; height: 100vh; overflow-y: auto; animation: slide .18s ease-out; }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-h h3 { margin: 0; font-size: 16px; font-weight: 600; flex: 1; }
.modal-b { padding: 20px; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
@keyframes fade { from { opacity: 0; } } @keyframes slide { from { transform: translateX(40px); opacity: 0; } }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 20px); background: var(--b4); border-left: 3px solid var(--b1); color: #fff; padding: 11px 18px;
  border-radius: 10px; font-size: 13px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: 90vw; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.toast.show { opacity: 1; transform: translate(-50%, 0); } .toast.bad { background: var(--bad); }
.token-box { font-family: var(--mono); background: var(--surface-2); border: 1px dashed var(--line-2); padding: 12px; border-radius: 9px; word-break: break-all; font-size: 12.5px; }
.spin { width: 16px; height: 16px; border: 2px solid var(--line-2); border-top-color: var(--b2); border-radius: 50%; animation: rot .7s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes rot { to { transform: rotate(360deg); } }
.demo-flag { font-size: 11px; font-weight: 500; letter-spacing: 0; background: rgba(0,179,255,.12); color: var(--b2); border: 1px solid rgba(0,179,255,.35); padding: 3px 9px; border-radius: 99px; }

@media (max-width: 1200px) { .g-kpi { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 50; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .btn.menu-btn { display: inline-flex; }
  .g-2, .g-2e { grid-template-columns: 1fr; }
  .login { grid-template-columns: 1fr; } .login-hero { display: none; }
  .topbar, .page { padding-left: 16px; padding-right: 16px; }
}
@media (max-width: 560px) { .g-kpi3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); } .row-2 { grid-template-columns: 1fr; } .kv { grid-template-columns: 1fr; } }
