/* ============================================================================
   Connectra Link — identidad de marca (Manual de Marca + brand-kit)
   Look B2B/profesional alineado al panel sdwan/ui (DCIM): sidebar + topbar,
   fondo navy, Hanken Grotesk, azul #1B56FD, acentos teal/amarillo/coral.
   ========================================================================== */
@font-face {
  font-family: "Hanken Grotesk";
  src: url("/static/assets/HankenGrotesk.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}
:root {
  color-scheme: light;
  --cnct-blue: #1b56fd;   /* color #1 */
  --cnct-blue-80: #4978fd;/* #1 al 80% (#4) */
  --cnct-soft: #eaf0ff;   /* azul muy suave */
  --bg: #f5f7fb;          /* fondo app (tema claro B2B, match connectra-cloud) */
  --panel: #ffffff;       /* sidebar / tarjetas */
  --panel2: #f0f3f9;      /* superficies internas */
  --border: #e3e8f1;
  --ink: #0a1628;         /* títulos / navy */
  --text: #2b3a52;        /* cuerpo */
  --muted: #6b7a93;
  --accent: var(--cnct-blue);
  --accent-soft: #1448d6; /* azul legible sobre fondos claros */
  --ok: #1f9d57;          /* verde — éxito */
  --warn: #b9822a;        /* ámbar — advertencia */
  --crit: #d23f3f;        /* rojo — error */
  --radius: 10px;
  --ring: 0 0 0 3px rgba(27,86,253,.20);
  --shadow: 0 1px 2px rgba(16,30,60,.06), 0 4px 14px rgba(16,30,60,.05);
  --shadow-lg: 0 8px 30px rgba(16,30,60,.10);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 "Hanken Grotesk", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ===== Login ===== */
.login-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #eef2fb 0%, #f5f7fb 60%); z-index: 100;
  overflow: hidden;
}
.login-screen[hidden] { display: none; }
.login-trama {
  position: absolute; left: 0; right: 0; bottom: 0; height: 230px; pointer-events: none;
  background: url("/static/assets/trama.svg") repeat-x bottom center / auto 100%;
  opacity: .12;
}
#app[hidden] { display: none; }
.login-box {
  position: relative; z-index: 1;
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 34px 32px; width: 360px; max-width: 100%; text-align: center;
  box-shadow: var(--shadow-lg);
}
.login-box .logo { height: 34px; width: auto; margin: 0 auto 16px; display: block; }
.login-box h2 { font-size: 19px; font-weight: 700; }
.login-box .sub { display: block; margin-bottom: 16px; color: var(--muted); font-size: 12.5px; }
.login-box label { display: block; text-align: left; color: var(--muted); font-size: 12px; margin: 12px 0 4px; }
.login-box input {
  width: 100%; background: var(--panel2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); padding: 10px 12px; font-size: 14px; font-family: inherit;
}
.login-box input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.lg-error { color: var(--crit); font-size: 12.5px; margin-top: 12px; }

/* ===== Shell: sidebar + main (estilo DCIM, como sdwan/ui) ===== */
.shell { display: flex; min-height: 100vh; }
#app.shell[hidden] { display: none; }
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--panel);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sb-brand {
  display: flex; align-items: center; gap: 11px; padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.sb-logo { height: 24px; width: auto; }
.sb-name { font-weight: 700; font-size: 18px; line-height: 1; letter-spacing: .3px; }
.sb-name small { display: block; font-weight: 400; font-size: 9.5px; color: var(--muted);
  letter-spacing: .2px; margin-top: 4px; text-transform: none; }
.sb-nav { padding: 10px 8px 16px; flex: 1; }
.sb-group { margin-top: 12px; }
.sb-group-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); padding: 4px 10px; opacity: .8;
}
.sb-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: none; color: var(--text); cursor: pointer;
  padding: 8px 10px; border-radius: 8px; font-size: 13.5px; font-family: inherit;
}
.sb-item .ic { width: 16px; font-size: 13px; color: var(--muted); font-style: normal; text-align: center; }
.sb-item:hover { background: var(--panel2); }
.sb-item.active { background: var(--accent); color: #fff; }
.sb-item.active .ic { color: #fff; }
.sb-foot { padding: 12px 16px; border-top: 1px solid var(--border); color: var(--muted);
  font-size: 11px; letter-spacing: .03em; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 0 18px; height: 56px;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,.85); backdrop-filter: blur(8px);
}
.page-title { font-weight: 700; font-size: 16px; }
.spacer { flex: 1; }
.nav-toggle { display: none; font-size: 18px; line-height: 1; padding: 6px 10px; }
.whoami { color: var(--text); font-size: 12.5px; font-weight: 600; }
.whoami small { color: var(--muted); font-weight: 400; }
.content { padding: 20px 22px; max-width: 1380px; margin: 0 auto; width: 100%; }
.nav-backdrop { display: none; }

/* ===== Tipografía de contenido ===== */
h1 { font-size: 16px; font-weight: 700; letter-spacing: .2px; }
h2 { font-size: 16px; font-weight: 700; margin: 4px 0 12px; }
.sub { color: var(--muted); font-size: 11.5px; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; gap: 10px; flex-wrap: wrap; }

/* ===== Badges ===== */
.badge { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 5px;
  background: rgba(27,86,253,.12); color: var(--accent); border: 1px solid rgba(27,86,253,.30);
  margin-left: 6px; vertical-align: middle; }
.api-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.api-cat { font-size: 11.5px; color: var(--muted); margin-top: 6px; line-height: 1.85; }
.api-cat b { color: var(--ink); font-weight: 600; }
.api-cat i { color: var(--ok); font-style: normal; font-weight: 700; }
.badge-mock { background: rgba(255,214,107,.14); color: var(--warn); border: 1px solid rgba(255,214,107,.35); }
.badge-real { background: rgba(10,186,181,.14); color: var(--ok); border: 1px solid rgba(10,186,181,.35); margin-left: 8px; font-size: 10px; vertical-align: middle; }

/* ===== KPIs / cards ===== */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.card .k { color: var(--muted); font-size: 12px; }
.card .v { font-size: 26px; font-weight: 700; margin-top: 3px; line-height: 1.1; }
.card .v small { font-size: 13px; color: var(--muted); font-weight: 400; }

/* ===== Sitios ===== */
.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 14px; margin-top: 12px; }
.site-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; transition: border-color .15s, transform .15s; }
.site-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.site-card .top { display: flex; justify-content: space-between; align-items: center; }
.site-card h3 { font-size: 14.5px; font-weight: 700; }
.site-card .client { color: var(--muted); font-size: 12px; margin-top: 1px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-ok { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.dot-warn { background: var(--warn); box-shadow: 0 0 6px var(--warn); }
.dot-crit { background: var(--crit); box-shadow: 0 0 6px var(--crit); }
.dot-off { background: #555; }
.tier { font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 4px; }
.tier-Base { background: rgba(27,86,253,.18); color: var(--accent-soft); }
.tier-Plus { background: rgba(10,186,181,.16); color: var(--ok); }
.tier-Critico { background: rgba(255,99,99,.16); color: var(--crit); }
.stats { display: flex; gap: 16px; margin-top: 10px; font-size: 12.5px; }
.stats .s { color: var(--muted); }
.stats .s b { color: var(--text); font-weight: 700; display: block; font-size: 14px; }
.spark { margin-top: 10px; }
.meta-line { color: var(--muted); font-size: 11.5px; margin-top: 9px; display: flex; gap: 12px; flex-wrap: wrap; }

/* ===== Botones ===== */
.btn { background: var(--accent); color: #fff; border: none; padding: 8px 14px;
  border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 13px; font-family: inherit;
  transition: filter .15s, background .15s; }
.btn:hover { filter: brightness(1.1); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); font-weight: 500; }
.btn-ghost:hover { color: var(--ink); background: var(--panel2); }
.btn-danger { background: var(--crit); color: #fff; }

/* ===== Tablas ===== */
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 9px 13px; font-size: 13px; }
th { background: var(--panel2); color: var(--muted); font-weight: 600; font-size: 12px; }
tr { border-top: 1px solid var(--border); }
.sev { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 4px; }
.sev-info { background: rgba(27,86,253,.18); color: var(--accent-soft); }
.sev-warning { background: rgba(255,214,107,.14); color: var(--warn); }
.sev-critical { background: rgba(255,99,99,.16); color: var(--crit); }

/* ===== Detalle de sitio ===== */
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; margin-top: 14px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.panel h3 { font-size: 13.5px; margin-bottom: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 5px 10px; font-size: 13px; }
.kv .k { color: var(--muted); }
.chart-title { font-size: 12.5px; color: var(--muted); margin: 12px 0 4px; }
svg.chart { width: 100%; background: var(--panel2); border-radius: 7px; }
.events-list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; }
.event-item { font-size: 12.5px; padding: 8px 10px; background: var(--panel2); border-radius: 7px; }
.event-item .ts { color: var(--muted); font-size: 11px; }

/* ===== Otros widgets ===== */
.whoami { color: var(--text); font-size: 12.5px; font-weight: 600; }
.qr-box { background: #fff; padding: 10px; border-radius: 10px; width: max-content; margin: 10px auto; }
.qr-box svg { display: block; width: 200px; height: 200px; }
.poolbar { height: 6px; background: var(--panel2); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.poolbar div { height: 100%; border-radius: 3px; }
.bar-ok { background: var(--ok); }
.bar-warn { background: var(--warn); }
.bar-crit { background: var(--crit); }
#map { background: var(--panel2); border-radius: var(--radius); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--text); }
.leaflet-popup-content a { color: var(--accent); }

/* ===== Modal ===== */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 3000; }
.modal[hidden] { display: none; }
.modal-box { background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 18px 20px; width: 440px; max-height: 85vh; overflow-y: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-box label { display: block; color: var(--muted); font-size: 12px; margin: 10px 0 3px; }
.modal-box input, .modal-box select {
  width: 100%; background: var(--panel2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); padding: 8px 10px; font-size: 13px; font-family: inherit; }
.modal-box input:focus, .modal-box select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.modal-actions { margin-top: 16px; display: flex; justify-content: flex-end; gap: 8px; }

/* ===== Responsive: sidebar deslizable (móvil) ===== */
@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; align-items: center; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; height: 100vh;
    transform: translateX(-100%); transition: transform .2s ease; }
  .nav-open .sidebar { transform: translateX(0); }
  .nav-open .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.5); }
}
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }

/* ===== Pulido tema claro (alineado al modelo connectra-cloud) ===== */
.card, .site-card, .panel, table, .modal-box { box-shadow: var(--shadow); }
.login-box { box-shadow: var(--shadow-lg); }
.site-card:hover { box-shadow: var(--shadow-lg); border-color: #d3dcec; }
h1, h2, h3, .page-title, .sb-name, .login-box h2, .card .v,
.site-card h3, .modal-head h3, .sb-item { color: var(--ink); }
.dot-ok, .dot-warn, .dot-crit { box-shadow: none; } /* sin glow neón en tema claro */

/* ===== Connectra Remoto: específicos ===== */
.rid { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-weight: 700;
  letter-spacing: .5px; color: var(--ink); }
.online-pill { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.online-yes { background: rgba(31,157,87,.14); color: var(--ok); }
.online-no { background: rgba(107,122,147,.14); color: var(--muted); }
.plat-ic { font-style: normal; }
.codebox { position: relative; background: var(--panel2); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; font-family: ui-monospace, Consolas, monospace;
  font-size: 12px; word-break: break-all; color: var(--ink); margin-top: 6px; }
.copy-btn { font-size: 11px; padding: 4px 9px; }
.steps { counter-reset: s; list-style: none; display: flex; flex-direction: column; gap: 12px; }
.steps li { counter-increment: s; position: relative; padding-left: 34px; font-size: 13px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: -1px;
  width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff;
  font-weight: 700; font-size: 12px; display: flex; align-items: center; justify-content: center; }
.srv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px,1fr)); gap: 8px; }
.srv-item { background: var(--panel2); border-radius: 8px; padding: 8px 10px; font-size: 12px; }
.srv-item b { display: block; font-size: 13px; color: var(--ink); margin-top: 2px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.toolbar input, .toolbar select { background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; font-size: 13px; font-family: inherit; color: var(--text); }
