/* =====================================================================
   WebVPN — sistema de diseño corporativo
   Los colores de marca llegan de /brand.css (--brand, --brand-contrast);
   el resto de tonos se derivan aquí con color-mix().
   ===================================================================== */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/vendor/fonts/inter-latin-wght.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
                 U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212,
                 U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/vendor/fonts/inter-latin-ext-wght.woff2") format("woff2");
  unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB,
                 U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("/static/vendor/fonts/jetbrains-mono-latin-wght.woff2") format("woff2");
}

:root {
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --brand: #2457c5;
  --brand-contrast: #ffffff;

  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e2e7ee;
  --border-strong: #cdd5e0;
  --text: #101a2b;
  --text-2: #4b5a6f;
  --text-3: #7b889a;

  --ok: #15803d;      --ok-bg: #e9f7ee;
  --warn: #b45309;    --warn-bg: #fdf4e4;
  --danger: #c42b2b;  --danger-bg: #fdeded;
  --info: var(--brand);

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 26, 43, .05);
  --shadow: 0 1px 2px rgba(16, 26, 43, .05), 0 6px 16px -4px rgba(16, 26, 43, .08);
  --shadow-lg: 0 24px 48px -12px rgba(16, 26, 43, .25);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c111b;
    --surface: #131a27;
    --surface-2: #182131;
    --border: #243045;
    --border-strong: #31405a;
    --text: #e7ecf3;
    --text-2: #a6b2c4;
    --text-3: #75839a;
    --ok: #4ade80;      --ok-bg: #12301f;
    --warn: #fbbf24;    --warn-bg: #33270e;
    --danger: #f87171;  --danger-bg: #3a1717;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 20px -6px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
  :root:not([data-theme="light"]) body { --brand-ink: color-mix(in srgb, var(--brand) 55%, #fff); }
}
:root[data-theme="dark"] body { --brand-ink: color-mix(in srgb, var(--brand) 55%, #fff); }
:root[data-theme="dark"] {
  --bg: #0c111b;
  --surface: #131a27;
  --surface-2: #182131;
  --border: #243045;
  --border-strong: #31405a;
  --text: #e7ecf3;
  --text-2: #a6b2c4;
  --text-3: #75839a;
  --ok: #4ade80;      --ok-bg: #12301f;
  --warn: #fbbf24;    --warn-bg: #33270e;
  --danger: #f87171;  --danger-bg: #3a1717;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 20px -6px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

:root {
  --brand-hover: color-mix(in srgb, var(--brand) 86%, #000);
  --brand-soft: color-mix(in srgb, var(--brand) 10%, var(--surface));
  --brand-line: color-mix(in srgb, var(--brand) 35%, var(--border));
  --brand-ink: var(--brand);
  --focus-ring: 0 0 0 3px color-mix(in srgb, var(--brand) 28%, transparent);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.55 var(--font);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; font-weight: 650; }
h2 { font-size: 1.15rem; font-weight: 620; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: .86em; }
code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 5px;
}
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.spacer { flex: 1; }
.mb { margin-bottom: 16px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* iconos (sprite inline: <svg class="i"><use href="#i-lock"/></svg>) */
.i {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -3px;
}
.i-sm { width: 15px; height: 15px; vertical-align: -2px; }
.i-lg { width: 22px; height: 22px; }

/* ---------- botones ---------- */
.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px;
  font: 560 .92rem/1 var(--font);
  color: var(--brand-contrast);
  background: var(--brand);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover, button:hover { background: var(--brand-hover); text-decoration: none; }
.btn:focus-visible, button:focus-visible { outline: none; box-shadow: var(--focus-ring); }
button:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: default; }
button:disabled:hover { background: var(--brand); }

.btn.secondary, button.secondary {
  color: var(--text); background: var(--surface); border-color: var(--border-strong);
}
.btn.secondary:hover, button.secondary:hover { background: var(--surface-2); }
.btn.ghost, button.ghost {
  color: var(--text-2); background: transparent; border-color: transparent;
}
.btn.ghost:hover, button.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger, button.danger { background: var(--danger); color: #fff; }
.btn.danger:hover, button.danger:hover { background: color-mix(in srgb, var(--danger) 85%, #000); }
.btn.danger-ghost, button.danger-ghost {
  color: var(--danger); background: transparent; border-color: var(--border-strong);
}
.btn.danger-ghost:hover, button.danger-ghost:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn.sm, button.sm { height: 32px; padding: 0 12px; font-size: .85rem; }
.btn.icon, button.icon { width: 38px; padding: 0; }
.btn.sm.icon, button.sm.icon { width: 32px; }
.btn.block, button.block { width: 100%; }

/* ---------- formularios ---------- */
.field { display: block; margin: 0 0 16px; }
.field > .label {
  display: block; margin-bottom: 6px;
  font-size: .86rem; font-weight: 560; color: var(--text);
}
.field > .hint { display: block; margin-top: 6px; font-size: .8rem; color: var(--text-3); }
input, textarea, select {
  width: 100%;
  font: 400 .95rem/1.4 var(--font);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  transition: border-color .15s, box-shadow .15s;
}
input, select { height: 40px; }
textarea { font-family: var(--mono); font-size: .82rem; line-height: 1.5; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--brand); box-shadow: var(--focus-ring);
}
input.code {
  height: 54px; text-align: center;
  font: 600 1.6rem/1 var(--mono); letter-spacing: .45em; padding-left: .45em;
}
.check {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; margin: 0 0 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer;
}
.check input { width: 18px; height: 18px; margin: 2px 0 0; flex: none; accent-color: var(--brand); }
.check strong { display: block; font-weight: 600; font-size: .9rem; }
.check span { color: var(--text-2); font-size: .84rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-3-1 { display: grid; grid-template-columns: 3fr 1fr; gap: 0 16px; }

/* ---------- avisos ---------- */
.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 14px; margin: 0 0 18px;
  border-radius: var(--radius-sm); font-size: .9rem;
  border: 1px solid transparent;
}
.alert .i { margin-top: 2px; }
.alert.error { color: var(--danger); background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert.ok { color: var(--ok); background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.alert.info { color: var(--text-2); background: var(--brand-soft); border-color: var(--brand-line); }
.alert:empty, .alert.empty { display: none; }
.alert.warn { color: var(--warn); background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.alert ul { margin: 4px 0 0; padding-left: 18px; }

/* carga de ficheros .ovpn */
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; flex-wrap: wrap; }
.label-row > .label { margin: 0; font-size: .86rem; font-weight: 560; color: var(--text); }
.file-btn { position: relative; overflow: hidden; }
.file-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.file-btn:focus-within { box-shadow: var(--focus-ring); }
#ovpn-msg { margin-bottom: 10px; }
textarea.dropzone.dragover { border-color: var(--brand); box-shadow: var(--focus-ring); background: var(--brand-soft); }

/* ---------- insignias ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px;
  font-size: .74rem; font-weight: 600; letter-spacing: .01em;
  border-radius: 999px;
  color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border);
  white-space: nowrap;
}
.badge .i { width: 12px; height: 12px; vertical-align: 0; }
.badge.ok { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.badge.warn { color: var(--warn); background: var(--warn-bg); border-color: transparent; }
.badge.danger { color: var(--danger); background: var(--danger-bg); border-color: transparent; }
.badge.brand { color: var(--brand-ink); background: var(--brand-soft); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.dot.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* =====================================================================
   Pantallas de acceso (login, TOTP, cambio de contraseña, errores)
   ===================================================================== */
.auth {
  display: grid; grid-template-columns: minmax(380px, 44%) 1fr;
  min-height: 100vh;
}
.auth-brand {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 44px 52px;
  color: #fff;
  background:
    radial-gradient(1200px 600px at -10% -20%, color-mix(in srgb, var(--brand) 60%, #fff) 0%, transparent 55%),
    linear-gradient(155deg, var(--brand) 0%, color-mix(in srgb, var(--brand) 55%, #050a14) 100%);
}
.auth-brand::after {           /* trama sutil de líneas */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(160deg, #000 0%, transparent 70%);
}
.auth-brand > * { position: relative; z-index: 1; }
.brand-lockup { display: flex; align-items: center; gap: 14px; }
.brand-lockup .logo-tile {
  width: 48px; height: 48px; border-radius: 12px;
  background: #fff; display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
}
.brand-lockup .logo-tile img { width: 34px; height: 34px; object-fit: contain; }
.brand-lockup .names { line-height: 1.2; }
.brand-lockup .company { font-weight: 650; font-size: 1.05rem; }
.brand-lockup .product { opacity: .78; font-size: .88rem; }
.auth-pitch h1 { font-size: 2.1rem; font-weight: 680; letter-spacing: -0.02em; max-width: 15ch; }
.auth-pitch p { margin-top: 14px; max-width: 42ch; opacity: .85; font-size: 1rem; }
.auth-features { list-style: none; margin: 34px 0 0; padding: 0; display: grid; gap: 16px; }
.auth-features li { display: flex; gap: 14px; align-items: flex-start; max-width: 44ch; }
.auth-features .ficon {
  width: 36px; height: 36px; flex: none; border-radius: 10px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.18);
}
.auth-features strong { display: block; font-weight: 600; font-size: .95rem; }
.auth-features span { opacity: .78; font-size: .86rem; }
.auth-legal { font-size: .78rem; opacity: .65; }

.auth-main {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 40px 24px; background: var(--surface);
}
.auth-card { width: 100%; max-width: 380px; }
.auth-card.wide { max-width: 460px; }
.auth-card .eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--brand-ink); font-weight: 600; font-size: .8rem;
  text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px;
}
.auth-card h1 { margin-bottom: 8px; }
.auth-card .lead { color: var(--text-2); margin-bottom: 26px; }
.auth-card form button[type="submit"] { width: 100%; height: 44px; margin-top: 6px; font-size: .95rem; }
.auth-foot { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--border);
  font-size: .82rem; color: var(--text-3); display: flex; gap: 8px; align-items: center; }

/* pasos del enrolado TOTP */
.steps { list-style: none; padding: 0; margin: 0 0 22px; display: grid; gap: 12px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; font-size: .9rem; color: var(--text-2); }
.steps .n {
  width: 24px; height: 24px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  font-size: .78rem; font-weight: 700;
  color: var(--brand); background: var(--brand-soft); border: 1px solid var(--brand-line);
}
.qr-box {
  display: flex; gap: 18px; align-items: center;
  padding: 16px; margin-bottom: 22px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
}
#qr { background: #fff; padding: 10px; border-radius: 10px; border: 1px solid var(--border); line-height: 0; }
#qr img, #qr canvas { display: block; width: 150px; height: 150px; }
.qr-box .manual { font-size: .82rem; color: var(--text-2); min-width: 0; }
.qr-box .manual code { display: block; margin-top: 6px; word-break: break-all; font-size: .8rem; }

/* =====================================================================
   Aplicación (barra superior + contenido)
   ===================================================================== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 28px;
  height: 64px; padding: 0 28px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar .brand { display: flex; align-items: center; gap: 11px; color: var(--text); }
.topbar .brand:hover { text-decoration: none; }
.topbar .brand img { width: 30px; height: 30px; object-fit: contain; }
.topbar .brand .names { line-height: 1.15; }
.topbar .brand .company { font-weight: 650; font-size: .95rem; }
.topbar .brand .product { color: var(--text-3); font-size: .76rem; }
.nav { display: flex; gap: 4px; height: 100%; }
.nav a {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 0 12px; height: 100%;
  color: var(--text-2); font-weight: 520; font-size: .9rem;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.nav a:hover { color: var(--text); text-decoration: none; }
.nav a.active { color: var(--brand-ink); border-bottom-color: var(--brand); font-weight: 600; }
.topbar .spacer { flex: 1; }
.userchip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: .8rem; font-weight: 700; letter-spacing: .02em;
  color: var(--brand-ink); background: var(--brand-soft); border: 1px solid var(--brand-line);
}
.userchip .who { line-height: 1.15; }
.userchip .who strong { display: block; font-size: .86rem; font-weight: 600; }
.userchip .who span { font-size: .74rem; color: var(--text-3); }
.userchip form { margin: 0; }

.page { max-width: 1240px; margin: 0 auto; padding: 32px 28px 64px; }
.page.narrow { max-width: 820px; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-bottom: 24px;
}
.page-head .crumb { font-size: .82rem; color: var(--text-3); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.page-head .crumb a { color: var(--text-3); }
.page-head p { color: var(--text-2); margin-top: 6px; }
.section { margin-bottom: 36px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head h2 { display: flex; align-items: center; gap: 10px; }
.count {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 7px;
  font-size: .75rem; font-weight: 650; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
}

/* tarjetas */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 22px 24px; }
.page > .card + .card, .page > section.card + section.card { margin-top: 16px; }
.card-head { padding: 18px 24px; border-bottom: 1px solid var(--border); }
.card-head p { color: var(--text-2); font-size: .86rem; margin-top: 4px; }
.card-body { padding: 22px 24px; }
.card-body > :last-child, .card-body > form > :last-child,
.card-pad > :last-child { margin-bottom: 0; }
.card-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 24px; background: var(--surface-2);
  border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius);
}

/* rejilla de conexiones */
.conn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.conn-card { display: flex; flex-direction: column; padding: 20px; transition: border-color .15s, box-shadow .15s; }
.conn-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.conn-top { display: flex; gap: 14px; align-items: flex-start; }
.tile {
  width: 42px; height: 42px; flex: none; border-radius: 11px;
  display: grid; place-items: center;
  color: var(--brand-ink); background: var(--brand-soft); border: 1px solid var(--brand-line);
}
.tile.prod { color: var(--danger); background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.conn-id { min-width: 0; flex: 1; }
.conn-id h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn-id .target { display: block; margin-top: 3px; color: var(--text-3); font: .8rem/1.3 var(--mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0 18px; min-height: 22px; }
.conn-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.conn-actions .connect { flex: 1; }

.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 44px 24px; color: var(--text-2);
  border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface);
}
.empty .tile { width: 52px; height: 52px; margin-bottom: 14px; }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.empty p { max-width: 44ch; font-size: .9rem; }
.empty .btn { margin-top: 18px; }

/* sesiones activas */
.sess-list { display: grid; gap: 12px; }
.sess {
  display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center;
  padding: 16px 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border-left: 3px solid var(--border-strong);
}
.sess.connected { border-left-color: var(--ok); }
.sess.connecting { border-left-color: var(--warn); }
.sess.error { border-left-color: var(--danger); }
.sess .meta { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 6px; font-size: .82rem; color: var(--text-2); }
.sess .meta span { display: inline-flex; gap: 6px; align-items: center; }
.sess .meta .i { color: var(--text-3); }
.sess h3 { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sess .acts { display: flex; gap: 8px; }
.sess-none {
  display: flex; gap: 12px; align-items: center;
  padding: 16px 20px; color: var(--text-2); font-size: .9rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}

/* tablas */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .87rem; }
table.data th {
  position: sticky; top: 0;
  text-align: left; font-weight: 600; font-size: .76rem;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-3); background: var(--surface-2);
  padding: 10px 16px; border-bottom: 1px solid var(--border);
}
table.data td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data td.mono { font-family: var(--mono); font-size: .8rem; color: var(--text-2); white-space: nowrap; }
table.data td.detail { color: var(--text-2); max-width: 420px; overflow-wrap: anywhere; }

/* filas de usuario (admin) */
.user-list { display: grid; }
.user-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
}
.user-row:last-child { border-bottom: none; }
.user-row .who strong { display: block; font-weight: 600; }
.user-row .badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.user-row .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.user-row.locked .avatar { color: var(--danger); background: var(--danger-bg); border-color: transparent; }

/* subnavegación admin */
.subnav { display: flex; gap: 6px; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
.subnav a {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 14px; color: var(--text-2); font-weight: 520; font-size: .9rem;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.subnav a:hover { color: var(--text); text-decoration: none; }
.subnav a.active { color: var(--brand-ink); border-bottom-color: var(--brand); font-weight: 600; }

.filter-bar { display: flex; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.filter-bar input { max-width: 260px; height: 36px; }
.filter-bar input[type="number"] { max-width: 110px; }
.filter-bar button { height: 36px; }

.temppw {
  display: block; margin-top: 10px; padding: 12px 14px;
  font: 600 1.05rem/1.2 var(--mono); letter-spacing: .03em;
  background: var(--surface); border: 1px dashed var(--ok); border-radius: var(--radius-sm);
  user-select: all; word-break: break-all;
}

.split > form > .card + .card { margin-top: 16px; }
.aside > * + * { margin-top: 16px; }
.aside-title { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; color: var(--text); }
.aside-title .i { color: var(--brand-ink); }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.danger-zone h3 { color: var(--danger); margin-bottom: 6px; }
.danger-zone p { color: var(--text-2); font-size: .85rem; margin-bottom: 14px; }
.auth-card > .tile { margin-bottom: 18px; }
.foot-note { margin-top: 28px; text-align: center; font-size: .78rem; color: var(--text-3); }

/* =====================================================================
   Consola
   ===================================================================== */
body.console {
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
  overflow: hidden; overscroll-behavior: none;
  background: #0a0e15; color: #dbe3ee;
}
.cbar {
  display: flex; align-items: center; gap: 14px;
  height: 52px; padding: 0 14px 0 16px;
  background: #111723; border-bottom: 1px solid #1e2737;
}
.cbar .brand img { width: 24px; height: 24px; object-fit: contain; display: block; }
.cbar .title { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.cbar .title strong { font-size: .92rem; font-weight: 600; color: #f1f5fb; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cbar .title span { font-size: .74rem; color: #8b98ad; }
.cbar .spacer { flex: 1; }
.cbar .status {
  display: inline-flex; align-items: center; gap: 7px;
  height: 26px; padding: 0 10px; border-radius: 999px;
  font-size: .76rem; font-weight: 600;
  color: #9fb0c8; background: #1a2232; border: 1px solid #263044;
}
.cbar .status.ok { color: #4ade80; background: #102419; border-color: #1a3b28; }
.cbar .status.warn { color: #fbbf24; background: #2a2010; border-color: #43341a; }
.cbar .status.bad { color: #f87171; background: #2c1414; border-color: #4a2020; }
.cbar button, .cbar .btn { height: 32px; padding: 0 12px; font-size: .84rem; }
.cbar .btn.ghost, .cbar button.ghost { color: #b4c0d2; }
.cbar .btn.ghost:hover, .cbar button.ghost:hover { background: #1c2536; color: #fff; }
.cbar button.danger-ghost { color: #f87171; border-color: #3a2630; }
.cbar button.danger-ghost:hover { background: #2c1414; border-color: #f87171; }
/* el tema del perfil tiñe la barra para distinguir entornos */
.theme-verde .cbar { box-shadow: inset 0 -2px 0 #33ff66; }
.theme-ambar .cbar { box-shadow: inset 0 -2px 0 #ffb000; }
.theme-claro .cbar { box-shadow: inset 0 -2px 0 #c8c0b0; }
.theme-rojo .cbar { background: #2a0f12; border-bottom-color: #4a1a1f; box-shadow: inset 0 -2px 0 #f04444; }
.theme-rojo .cbar .title span::before { content: "PRODUCCIÓN · "; color: #ff8a8a; font-weight: 700; }

#tabbar {
  display: flex; gap: 2px; align-items: flex-end;
  height: 38px; padding: 0 10px;
  background: #0d121c; border-bottom: 1px solid #1e2737;
  overflow-x: auto; scrollbar-width: none;
}
#tabbar button {
  height: 31px; padding: 0 10px 0 14px; gap: 10px; flex: none;
  font: 500 .82rem/1 var(--font);
  color: #8b98ad; background: transparent;
  border: 1px solid transparent; border-bottom: none;
  border-radius: 8px 8px 0 0;
}
#tabbar button:hover { color: #dbe3ee; background: #151c29; }
#tabbar button.on { color: #f1f5fb; background: #000; border-color: #1e2737; }
#tabbar button.dead span:first-child { text-decoration: line-through; opacity: .55; }
#tabbar .closex { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 4px; color: #6b7890; }
#tabbar .closex:hover { color: #fff; background: #c42b2b; }
#tabbar #addtab { width: 31px; padding: 0; color: #8b98ad; }
#tabbar #addtab:hover { color: #fff; }

#term { position: relative; flex: 1; min-height: 0; background: #000; }
.pane { position: absolute; inset: 0; padding: 8px 10px; }
.pane .xterm { height: 100%; }
.pane .xterm-viewport { scrollbar-width: thin; scrollbar-color: #2a3446 transparent; }

#keybar {
  display: none; gap: 6px; padding: 7px 8px;
  background: #111723; border-top: 1px solid #1e2737;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
#keybar button {
  height: 36px; padding: 0 13px; flex: 0 0 auto;
  font: 600 .85rem/1 var(--mono);
  color: #dbe3ee; background: #1a2232; border: 1px solid #263044;
}
#keybar button.on { background: var(--brand); color: var(--brand-contrast); border-color: transparent; }
@media (pointer: coarse) { #keybar { display: flex; } }

.lock {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(6, 9, 14, .82);
  backdrop-filter: blur(10px);
}
.lock-card {
  width: 100%; max-width: 380px; padding: 30px 28px;
  text-align: center;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg);
}
.lock-card .tile { width: 52px; height: 52px; margin: 0 auto 16px; }
.lock-card h2 { margin-bottom: 6px; }
.lock-card p { color: var(--text-2); font-size: .9rem; margin-bottom: 20px; }
.lock-card form { text-align: left; }
.lock-card button { width: 100%; height: 42px; }

/* =====================================================================
   Adaptación: 14" (≈1366-1600 px), 24" (≥1900 px), móvil
   ===================================================================== */
@media (min-width: 1100px) {
  .split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
  .split .aside { position: sticky; top: 88px; }
}
@media (min-width: 1900px) {
  body { font-size: 16px; }
  .page { max-width: 1560px; padding-top: 40px; }
  .page.narrow { max-width: 900px; }
  .conn-grid { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 20px; }
  .auth-brand { padding: 64px 80px; }
  .auth-pitch h1 { font-size: 2.6rem; }
  .auth-card { max-width: 420px; }
}
@media (max-width: 1000px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { padding: 22px 24px; }
  .auth-pitch, .auth-features, .auth-legal { display: none; }
  .auth-main { justify-content: flex-start; padding-top: 36px; }
  .topbar { gap: 14px; padding: 0 16px; }
  .topbar .brand .product, .userchip .who { display: none; }
  .nav a { padding: 0 9px; }
  .nav a .label { display: none; }
}
@media (max-width: 640px) {
  input, select, textarea { font-size: 16px; }    /* sin auto-zoom en Chrome Android */
  .page { padding: 20px 16px 48px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .grid-2, .grid-3-1 { grid-template-columns: 1fr; }
  .conn-grid { grid-template-columns: 1fr; }
  .sess { grid-template-columns: 1fr; gap: 12px; }
  .sess > .tile { display: none; }
  .sess .acts { justify-content: flex-end; flex-wrap: wrap; }
  .user-row { grid-template-columns: auto 1fr; }
  .user-row .acts { grid-column: 1 / -1; justify-content: flex-start; }
  .card-pad, .card-body, .card-head { padding-left: 16px; padding-right: 16px; }
  .qr-box { flex-direction: column; align-items: stretch; text-align: center; }
  #qr { align-self: center; }
  .cbar { gap: 8px; padding: 0 8px; }
  .cbar .btn .label, .cbar button .label { display: none; }
  .filter-bar { flex-wrap: wrap; }
  .filter-bar input { max-width: none; }
}
