/* =========================================================================
   ZONA INFORMATICA - Software Management Center
   Design system. No framework, no build step: one hand-written stylesheet.
   ========================================================================= */

/* ---------- 1. Design tokens ---------- */
:root {
    /* Tells the browser to render its OWN widgets dark: date pickers, select
       popups, scrollbars, autofill and focus rings. Without this the native
       controls come out light-on-light and their text is unreadable. */
    color-scheme: dark;

    /* Surfaces (dark first: this is an operations console) */
    --bg-root:        #0a0f1a;
    --bg-canvas:      #0d1424;
    --bg-surface:     #111a2e;
    --bg-surface-2:   #16203a;
    --bg-elevated:    #1b2742;
    --bg-hover:       #1e2b49;
    --bg-input:       #0e1729;

    /* Lines */
    --border:         #1f2c48;
    --border-strong:  #2b3b5e;
    --border-subtle:  #172238;

    /* Text */
    --text:           #e8eefc;
    --text-muted:     #93a3c4;
    /* 5.16:1 against the card background. The previous #64748b sat at 3.64:1,
       below WCAG AA, which made hints, table headers, placeholders and empty
       states hard to read — they are used at 11-13px. */
    --text-dim:       #7d8da9;
    --text-inverse:   #08101f;

    /* Brand + semantics */
    --primary:        #3b82f6;
    --primary-strong: #2563eb;
    --primary-soft:   rgba(59, 130, 246, .14);
    --primary-line:   rgba(59, 130, 246, .38);

    --success:        #22c55e;
    --success-soft:   rgba(34, 197, 94, .14);
    --success-line:   rgba(34, 197, 94, .35);

    --warning:        #f97316;
    --warning-soft:   rgba(249, 115, 22, .14);
    --warning-line:   rgba(249, 115, 22, .35);

    --danger:         #ef4444;
    --danger-soft:    rgba(239, 68, 68, .14);
    --danger-line:    rgba(239, 68, 68, .35);

    --purple:         #a855f7;
    --purple-soft:    rgba(168, 85, 247, .14);
    --purple-line:    rgba(168, 85, 247, .35);

    --cyan:           #06b6d4;
    --cyan-soft:      rgba(6, 182, 212, .14);

    /* "info" and "muted" are tones returned by Support\Status, so they must
       exist as colour tokens too: several views build var(--<tone>) from them
       and an undefined variable renders the icon or border invisible. */
    --info:           #3b82f6;
    --info-soft:      rgba(59, 130, 246, .14);
    --info-line:      rgba(59, 130, 246, .38);

    --muted:          #94a3b8;
    --muted-soft:     rgba(148, 163, 184, .12);
    --muted-line:     rgba(148, 163, 184, .3);

    /* Geometry */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 22px;
    --r-pill: 999px;

    --sidebar-w: 264px;
    --sidebar-w-compact: 76px;
    --topbar-h: 64px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-md: 0 8px 24px -12px rgba(0, 0, 0, .7);
    --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .8);

    --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --mono: "JetBrains Mono", "Cascadia Code", "SF Mono", Consolas, monospace;

    --ease: cubic-bezier(.4, 0, .2, 1);
}

/* ---------- 2. Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg-root);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5 { margin: 0; font-weight: 650; letter-spacing: -.01em; line-height: 1.25; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p  { margin: 0 0 10px; }
a  { color: var(--primary); text-decoration: none; }
a:hover { color: #60a5fa; }
img { max-width: 100%; display: block; }
hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #253251; border-radius: 8px; border: 2px solid var(--bg-canvas); }
::-webkit-scrollbar-thumb:hover { background: #32436c; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

/* ---------- 3. Shell ---------- */
.app-shell { display: flex; min-height: 100vh; background: var(--bg-canvas); }

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: linear-gradient(180deg, #0b1120 0%, #0a0f1c 100%);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 40;
    transition: transform .25s var(--ease);
}

.sidebar__brand {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 18px;
    border-bottom: 1px solid var(--border-subtle);
    flex: 0 0 auto;
}

.brand-mark {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary) 0%, #1d4ed8 100%);
    display: grid; place-items: center;
    box-shadow: 0 4px 14px -4px rgba(59, 130, 246, .7);
    flex: 0 0 auto;
}
.brand-mark svg { width: 20px; height: 20px; color: #fff; }

.brand-text { min-width: 0; }
.brand-text strong { display: block; font-size: 14.5px; font-weight: 680; letter-spacing: -.02em; white-space: nowrap; }
.brand-text span { display: block; font-size: 10.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .09em; white-space: nowrap; }

.sidebar__nav { flex: 1 1 auto; overflow-y: auto; padding: 14px 12px 20px; }

.nav-group { margin-bottom: 18px; }
.nav-group__title {
    font-size: 10px; font-weight: 700; letter-spacing: .12em;
    text-transform: uppercase; color: var(--text-dim);
    padding: 0 10px; margin-bottom: 7px;
}

.nav-link {
    display: flex; align-items: center; gap: 11px;
    padding: 8px 10px; margin-bottom: 2px;
    border-radius: var(--r-sm);
    color: var(--text-muted);
    font-size: 13.5px; font-weight: 500;
    position: relative;
    transition: background .15s var(--ease), color .15s var(--ease);
}
.nav-link svg { width: 17px; height: 17px; flex: 0 0 auto; opacity: .85; }
.nav-link:hover { background: var(--bg-hover); color: var(--text); }
.nav-link.is-active { background: var(--primary-soft); color: #bfdbfe; font-weight: 600; }
.nav-link.is-active::before {
    content: ""; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
    width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--primary);
}
.nav-link__badge {
    margin-left: auto; font-size: 10.5px; font-weight: 700;
    min-width: 20px; height: 18px; padding: 0 6px;
    border-radius: var(--r-pill);
    display: grid; place-items: center;
    background: var(--danger); color: #fff;
}
.nav-link__badge--muted { background: var(--bg-elevated); color: var(--text-muted); }

.sidebar__footer { flex: 0 0 auto; padding: 12px; border-top: 1px solid var(--border-subtle); }

.tls-chip {
    display: flex; align-items: center; gap: 9px;
    padding: 9px 11px; border-radius: var(--r-md);
    background: var(--success-soft); border: 1px solid var(--success-line);
    font-size: 11.5px; color: #86efac;
}
.tls-chip.is-insecure { background: var(--warning-soft); border-color: var(--warning-line); color: #fdba74; }
.tls-chip svg { width: 15px; height: 15px; flex: 0 0 auto; }
.tls-chip strong { display: block; font-size: 11.5px; font-weight: 650; }
.tls-chip span { display: block; font-size: 10.5px; opacity: .8; }

/* ---------- 4. Main column ---------- */
.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: var(--topbar-h);
    flex: 0 0 auto;
    display: flex; align-items: center; gap: 14px;
    padding: 0 22px;
    background: rgba(13, 20, 36, .82);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 30;
}

.icon-btn {
    width: 36px; height: 36px; flex: 0 0 auto;
    border: 1px solid var(--border); border-radius: var(--r-sm);
    background: var(--bg-surface); color: var(--text-muted);
    display: grid; place-items: center; cursor: pointer;
    position: relative;
    transition: all .15s var(--ease);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn__dot {
    position: absolute; top: -4px; right: -4px;
    min-width: 17px; height: 17px; padding: 0 4px;
    border-radius: var(--r-pill); background: var(--danger); color: #fff;
    font-size: 10px; font-weight: 700; display: grid; place-items: center;
    border: 2px solid var(--bg-canvas);
}

.sidebar-toggle { display: none; }

/* Global search */
.search {
    position: relative; flex: 1 1 auto; max-width: 520px;
}
.search__input {
    width: 100%; height: 38px;
    padding: 0 40px 0 38px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: var(--bg-input); color: var(--text);
    font-family: var(--font); font-size: 13.5px;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.search__input::placeholder { color: var(--text-dim); }
.search__input:focus { outline: none; border-color: var(--primary-line); box-shadow: 0 0 0 3px var(--primary-soft); }
.search__icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-dim); pointer-events: none; }
.search__kbd {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    font-family: var(--mono); font-size: 10px; color: var(--text-dim);
    border: 1px solid var(--border-strong); border-radius: 5px; padding: 2px 5px;
    pointer-events: none;
}

.search-results {
    position: absolute; top: calc(100% + 8px); left: 0; right: 0;
    background: var(--bg-elevated); border: 1px solid var(--border-strong);
    border-radius: var(--r-md); box-shadow: var(--shadow-lg);
    max-height: 420px; overflow-y: auto; z-index: 60; padding: 6px;
}
.search-results[hidden] { display: none; }
.search-results__group { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-dim); padding: 8px 10px 4px; font-weight: 700; }
.search-results__item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); color: var(--text); }
.search-results__item:hover, .search-results__item.is-active { background: var(--bg-hover); }
.search-results__item small { color: var(--text-dim); margin-left: auto; font-size: 11px; }
.search-results__empty { padding: 18px; text-align: center; color: var(--text-dim); font-size: 13px; }

/* User menu */
.user-chip {
    display: flex; align-items: center; gap: 9px;
    padding: 5px 10px 5px 5px; border-radius: var(--r-pill);
    border: 1px solid var(--border); background: var(--bg-surface);
    cursor: pointer; transition: all .15s var(--ease);
}
.user-chip:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.user-chip__name { font-size: 13px; font-weight: 600; line-height: 1.15; }
.user-chip__role { font-size: 10.5px; color: var(--text-dim); line-height: 1.15; }

.avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: #fff; font-size: 11.5px; font-weight: 700;
    display: grid; place-items: center; flex: 0 0 auto;
}
.avatar--lg { width: 46px; height: 46px; font-size: 16px; }
.avatar--sm { width: 24px; height: 24px; font-size: 9.5px; }

.dropdown { position: relative; }
.dropdown__menu {
    position: absolute; right: 0; top: calc(100% + 8px);
    min-width: 210px; padding: 6px;
    background: var(--bg-elevated); border: 1px solid var(--border-strong);
    border-radius: var(--r-md); box-shadow: var(--shadow-lg); z-index: 60;
}
.dropdown__menu[hidden] { display: none; }
/* Menus opened inside a scrollable container (a table, for instance) are
   switched to fixed positioning by app.js so the card's overflow does not
   clip them. */
.dropdown__menu.is-floating { position: fixed; margin: 0; }
.dropdown__item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 8px 10px; border-radius: var(--r-sm);
    background: none; border: 0; cursor: pointer;
    color: var(--text); font-size: 13px; font-family: var(--font); text-align: left;
}
.dropdown__item:hover { background: var(--bg-hover); }
.dropdown__item svg { width: 15px; height: 15px; color: var(--text-muted); }
.dropdown__item--danger { color: #fca5a5; }
.dropdown__item--danger svg { color: #fca5a5; }
.dropdown__divider { height: 1px; background: var(--border); margin: 5px 0; }
.dropdown__header { padding: 9px 10px; border-bottom: 1px solid var(--border); margin-bottom: 5px; }

/* Content area */
.content { flex: 1 1 auto; padding: 22px; max-width: 1680px; width: 100%; }

.page-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
.page-head__title { display: flex; align-items: center; gap: 12px; }
.page-head h1 { font-size: 22px; }
.page-head p { color: var(--text-muted); font-size: 13.5px; margin: 3px 0 0; }
.page-head__actions { display: flex; gap: 9px; flex-wrap: wrap; }

.breadcrumb { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.breadcrumb a { color: var(--text-dim); }
.breadcrumb a:hover { color: var(--text-muted); }

/* ---------- 5. Cards ---------- */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
}
.card--flush { overflow: hidden; }
.card__head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--border);
}
.card__head h2 { font-size: 14.5px; font-weight: 650; min-width: 0; }
.card__head > div:first-child { min-width: 0; }
.card__head p { font-size: 12px; color: var(--text-dim); margin: 2px 0 0; }
.card__body { padding: 18px; }
.card__body--tight { padding: 12px; }
.card__foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 10px; }

.grid { display: grid; gap: 16px; }
.grid--kpi { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid--cards { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid--main { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); align-items: start; }

/* KPI */
.kpi {
    position: relative; overflow: hidden;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 16px 17px;
    transition: transform .18s var(--ease), border-color .18s var(--ease);
}
.kpi:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.kpi::after {
    content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
    background: var(--accent, var(--primary)); opacity: .8;
}
.kpi__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.kpi__icon {
    width: 36px; height: 36px; border-radius: var(--r-md);
    display: grid; place-items: center;
    background: var(--accent-soft, var(--primary-soft));
    color: var(--accent, var(--primary));
}
.kpi__icon svg { width: 18px; height: 18px; }
.kpi__label { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.kpi__value { font-size: 28px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi__meta { font-size: 12px; color: var(--text-dim); margin-top: 5px; display: flex; align-items: center; gap: 5px; }
.kpi__trend { font-weight: 650; }
.kpi__trend--up { color: var(--success); }
.kpi__trend--down { color: var(--danger); }

/* ---------- Thumbnails / monograms ----------
   Placeholders are drawn with CSS instead of generated bitmaps: scaled bitmap
   fonts came out jagged and made the whole catalogue look broken. */
.thumb {
    position: relative;
    display: grid;
    place-items: center;
    overflow: hidden;
    flex: 0 0 auto;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    font-weight: 700;
    letter-spacing: .02em;
    line-height: 1;
    user-select: none;
}
.thumb__image { width: 100%; height: 100%; object-fit: cover; }
.thumb__label { position: relative; z-index: 1; }

/* A soft diagonal sheen keeps the tile from looking flat. */
.thumb::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(150deg, rgba(255, 255, 255, .10) 0%, transparent 48%);
    pointer-events: none;
}

.thumb--sm    { width: 26px;  height: 26px;  border-radius: 7px;  font-size: 9.5px; }
.thumb--md    { width: 32px;  height: 32px;  border-radius: 9px;  font-size: 11.5px; }
.thumb--lg    { width: 46px;  height: 46px;  border-radius: 12px; font-size: 15px; }
.thumb--xl    { width: 68px;  height: 68px;  border-radius: var(--r-lg); font-size: 23px; }
.thumb--xl .thumb__label { font-size: clamp(14px, 1.9em, 23px); }
.thumb__label { padding: 0 4px; text-align: center; overflow: hidden; }
.thumb--cover {
    width: 100%;
    aspect-ratio: 2 / 1;
    border-radius: 0;
    border: 0;
    font-size: 40px;
    letter-spacing: .06em;
}
.thumb--cover .thumb__label { opacity: .92; }

/* Software cards */
.soft-card {
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: var(--r-lg); overflow: hidden;
    display: flex; flex-direction: column;
    transition: transform .18s var(--ease), border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.soft-card:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.soft-card__cover { position: relative; background: var(--bg-surface-2); overflow: hidden; }
.soft-card__cover::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(180deg, transparent 45%, rgba(10, 15, 26, .78) 100%);
}
.soft-card__badges { position: absolute; top: 10px; right: 10px; z-index: 2; display: flex; gap: 6px; }
.soft-card__icon {
    position: absolute; left: 14px; bottom: -18px; z-index: 2;
    border-radius: 13px;
    box-shadow: 0 0 0 2px var(--bg-surface), var(--shadow-md);
}
.soft-card__icon .thumb { background-color: var(--bg-elevated); }
.soft-card__body { padding: 15px; flex: 1 1 auto; }
.soft-card__cover:has(.soft-card__icon) + .soft-card__body { padding-top: 26px; }
.soft-card__title { font-size: 15px; font-weight: 650; margin-bottom: 2px; }
.soft-card__title a { color: var(--text); }
.soft-card__title a:hover { color: var(--primary); }
.soft-card__sub { font-size: 12.5px; color: var(--text-dim); margin-bottom: 12px; min-height: 19px; }
.soft-card__meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-muted); }
.soft-card__meta span { display: inline-flex; align-items: center; gap: 5px; }
.soft-card__meta svg { width: 13px; height: 13px; opacity: .7; }
.soft-card__foot {
    padding: 11px 15px; border-top: 1px solid var(--border-subtle);
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    background: rgba(0, 0, 0, .12);
}

/* ---------- 6. Badges & pills ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    height: 21px; padding: 0 8px;
    border-radius: var(--r-pill);
    font-size: 11px; font-weight: 650; letter-spacing: .01em;
    white-space: nowrap;
    background: var(--bg-elevated); color: var(--text-muted);
    border: 1px solid transparent;
}
.badge svg { width: 11px; height: 11px; }
.badge--success { background: var(--success-soft); color: #86efac; border-color: var(--success-line); }
.badge--warning { background: var(--warning-soft); color: #fdba74; border-color: var(--warning-line); }
.badge--danger  { background: var(--danger-soft);  color: #fca5a5; border-color: var(--danger-line); }
.badge--info    { background: var(--primary-soft); color: #93c5fd; border-color: var(--primary-line); }
.badge--purple  { background: var(--purple-soft);  color: #d8b4fe; border-color: var(--purple-line); }
.badge--muted   { background: rgba(148, 163, 184, .12); color: var(--text-muted); border-color: var(--border-strong); }
.badge--lg { height: 26px; padding: 0 11px; font-size: 12px; }

/* inline-block por el mismo motivo: se usa suelto dentro de párrafos y
   leyendas, donde un <span> en línea ignoraría su tamaño. */
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; background: currentColor; vertical-align: middle; }
.dot--pulse { position: relative; }
.dot--pulse::after {
    content: ""; position: absolute; inset: -4px; border-radius: 50%;
    border: 1px solid currentColor; opacity: .5;
    animation: pulse 2s var(--ease) infinite;
}
@keyframes pulse {
    0%   { transform: scale(.7); opacity: .7; }
    70%  { transform: scale(1.5); opacity: 0; }
    100% { transform: scale(1.5); opacity: 0; }
}

.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: var(--r-pill);
    background: var(--bg-surface-2); border: 1px solid var(--border);
    font-size: 12px; color: var(--text-muted);
}

/* ---------- 7. Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 36px; padding: 0 14px;
    border-radius: var(--r-sm); border: 1px solid transparent;
    font-family: var(--font); font-size: 13px; font-weight: 600;
    cursor: pointer; white-space: nowrap;
    transition: all .15s var(--ease);
    text-decoration: none;
}
.btn svg { width: 15px; height: 15px; }
.btn:disabled, .btn.is-loading { opacity: .6; cursor: not-allowed; }

.btn--primary { background: var(--primary); color: #fff; box-shadow: 0 2px 10px -3px rgba(59, 130, 246, .8); }
.btn--primary:hover:not(:disabled) { background: var(--primary-strong); color: #fff; }
.btn--ghost { background: var(--bg-surface); border-color: var(--border); color: var(--text-muted); }
.btn--ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); border-color: var(--border-strong); }
.btn--success { background: var(--success); color: #052e16; }
.btn--success:hover:not(:disabled) { background: #16a34a; color: #f0fdf4; }
.btn--warning { background: var(--warning); color: #1c1006; }
.btn--warning:hover:not(:disabled) { background: #ea580c; color: #fff7ed; }
.btn--danger  { background: var(--danger); color: #fff; }
.btn--danger:hover:not(:disabled) { background: #dc2626; color: #fff; }
.btn--purple  { background: var(--purple); color: #fff; }
.btn--purple:hover:not(:disabled) { background: #9333ea; }
.btn--subtle { background: transparent; color: var(--text-muted); }
.btn--subtle:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }
.btn--sm { height: 29px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn--sm svg { width: 13px; height: 13px; }
.btn--xs { height: 25px; padding: 0 8px; font-size: 11.5px; border-radius: 6px; }
.btn--xs svg { width: 12px; height: 12px; }
.btn--block { width: 100%; }
.btn--icon { width: 36px; padding: 0; }
.btn--icon.btn--sm { width: 29px; }

.btn.is-loading { position: relative; color: transparent !important; }
.btn.is-loading::after {
    content: ""; position: absolute; width: 14px; height: 14px;
    border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff;
    border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-group { display: inline-flex; gap: 0; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.btn-group .btn:last-child { border-radius: 0 var(--r-sm) var(--r-sm) 0; }

/* ---------- 8. Forms ---------- */
.field { margin-bottom: 14px; }
.field__label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.field__label .req { color: var(--danger); }
.field__hint { font-size: 11.5px; color: var(--text-dim); margin-top: 5px; }
.field__error { font-size: 11.5px; color: #fca5a5; margin-top: 5px; display: flex; align-items: center; gap: 5px; }

.input, .select, .textarea {
    width: 100%; padding: 9px 12px;
    background: var(--bg-input); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--r-sm);
    font-family: var(--font); font-size: 13.5px;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-dim); }
.input:focus, .select:focus, .textarea:focus {
    outline: none; border-color: var(--primary-line); box-shadow: 0 0 0 3px var(--primary-soft);
}
.input.has-error, .select.has-error, .textarea.has-error { border-color: var(--danger-line); }
.input:disabled, .textarea:disabled { opacity: .55; cursor: not-allowed; }
.textarea { min-height: 100px; resize: vertical; line-height: 1.6; }
.textarea--code { font-family: var(--mono); font-size: 12.5px; }
.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2393a3c4' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 11px center;
    padding-right: 32px;
}

/* The dropdown list of a <select> is painted by the OS, not by the page.
   Without explicit colours some browsers render it light-on-light. */
.select option,
.select optgroup {
    background: var(--bg-elevated);
    color: var(--text);
}

/* Autofill: browsers force their own (light) background and text colour,
   which makes a filled login field look broken on a dark form. */
.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus,
.select:-webkit-autofill,
.textarea:-webkit-autofill {
    -webkit-text-fill-color: var(--text);
    -webkit-box-shadow: 0 0 0 1000px var(--bg-input) inset;
    box-shadow: 0 0 0 1000px var(--bg-input) inset;
    caret-color: var(--text);
    transition: background-color 5000s ease-in-out 0s;
}

/* Native date/time pickers keep a dark icon on a dark field otherwise. */
.input[type="date"]::-webkit-calendar-picker-indicator,
.input[type="datetime-local"]::-webkit-calendar-picker-indicator,
.input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(0.75);
    cursor: pointer;
}

.input[type="color"] {
    padding: 3px;
    height: 38px;
    cursor: pointer;
}

.input-group { display: flex; }
.input-group .input { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.input-group .btn { border-radius: 0 var(--r-sm) var(--r-sm) 0; height: auto; }

.form-grid { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.form-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field--full { grid-column: 1 / -1; }

.checkbox, .radio { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; padding: 7px 0; }
.checkbox input, .radio input { width: 16px; height: 16px; margin: 1px 0 0; accent-color: var(--primary); cursor: pointer; flex: 0 0 auto; }
.checkbox__text { font-size: 13px; }
.checkbox__text small { display: block; color: var(--text-dim); font-size: 11.5px; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
    width: 38px; height: 21px; border-radius: var(--r-pill);
    background: var(--bg-elevated); border: 1px solid var(--border-strong);
    position: relative; transition: all .18s var(--ease); flex: 0 0 auto;
}
.switch__track::after {
    content: ""; position: absolute; top: 2px; left: 2px;
    width: 15px; height: 15px; border-radius: 50%;
    background: var(--text-dim); transition: all .18s var(--ease);
}
.switch input:checked + .switch__track { background: var(--primary-soft); border-color: var(--primary-line); }
.switch input:checked + .switch__track::after { transform: translateX(17px); background: var(--primary); }

.file-drop {
    position: relative;
    display: block;
    border: 1.5px dashed var(--border-strong); border-radius: var(--r-md);
    padding: 26px 18px; text-align: center; cursor: pointer;
    background: var(--bg-input); transition: all .15s var(--ease);
    overflow: hidden;
}
.file-drop:hover, .file-drop.is-over { border-color: var(--primary-line); background: var(--primary-soft); }
.file-drop:focus-within { border-color: var(--primary-line); box-shadow: 0 0 0 3px var(--primary-soft); }
.file-drop svg { width: 26px; height: 26px; color: var(--text-dim); margin-bottom: 8px; }
.file-drop strong { display: block; font-size: 13.5px; word-break: break-word; }
.file-drop span { font-size: 11.5px; color: var(--text-dim); }

/* The input covers the whole drop zone instead of being display:none.
   display:none would make a `required` file input impossible to focus, and the
   browser then refuses to submit the form without any visible explanation. */
.file-drop input[type=file] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* Secret field */
.secret {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; border-radius: var(--r-sm);
    background: var(--bg-input); border: 1px solid var(--border);
    font-family: var(--mono); font-size: 13px;
}
.secret__value { flex: 1 1 auto; letter-spacing: .12em; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.secret__value.is-revealed { letter-spacing: normal; color: #86efac; }

/* ---------- 9. Tables ---------- */
/* Sombra al borde derecho cuando la tabla se sale del ancho: sin ella parecía
   que el contenido estaba cortado, no desplazable. */
.table-wrap {
    overflow-x: auto;
    background:
        linear-gradient(to right, var(--bg-surface) 30%, rgba(17, 26, 46, 0)) left / 28px 100% no-repeat,
        linear-gradient(to left,  var(--bg-surface) 30%, rgba(17, 26, 46, 0)) right / 28px 100% no-repeat,
        radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, .35), transparent) left / 12px 100% no-repeat,
        radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, .35), transparent) right / 12px 100% no-repeat;
    background-attachment: local, local, scroll, scroll;
}
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table thead th {
    text-align: left; padding: 10px 14px;
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
    color: var(--text-dim); background: rgba(0, 0, 0, .16);
    border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s var(--ease); }
.table tbody tr:hover { background: rgba(59, 130, 246, .05); }
.table td.is-numeric, .table th.is-numeric { text-align: right; font-variant-numeric: tabular-nums; }
.table td.is-actions { text-align: right; white-space: nowrap; }
.table .cell-main { font-weight: 600; color: var(--text); }
.table .cell-sub { font-size: 11.5px; color: var(--text-dim); }
.table--compact tbody td { padding: 8px 12px; }

.cell-flex { display: flex; align-items: center; gap: 10px; }
.cell-icon {
    width: 30px; height: 30px; border-radius: 8px; flex: 0 0 auto;
    background: var(--bg-elevated); overflow: hidden;
    display: grid; place-items: center; font-size: 11px; font-weight: 700;
}
.cell-icon img { width: 100%; height: 100%; object-fit: cover; }

.mono { font-family: var(--mono); font-size: 12.5px; }
.hash { font-family: var(--mono); font-size: 11px; color: var(--text-dim); word-break: break-all; }

/* ---------- 10. Tabs ---------- */
/* Las pestañas envuelven en varias filas: cortarlas a la derecha escondía
   las últimas (API, Logs, Ajustes) sin ninguna pista visual. */
.tabs {
    display: flex; flex-wrap: wrap; gap: 2px 4px;
    border-bottom: 1px solid var(--border); margin-bottom: 20px;
}
.tab {
    padding: 10px 14px; font-size: 13.5px; font-weight: 550;
    color: var(--text-muted); white-space: nowrap;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
    display: inline-flex; align-items: center; gap: 7px;
    transition: color .15s var(--ease), border-color .15s var(--ease);
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 650; }
.tab__count {
    font-size: 10.5px; font-weight: 700; padding: 1px 6px;
    border-radius: var(--r-pill); background: var(--bg-elevated); color: var(--text-dim);
}
.tab.is-active .tab__count { background: var(--primary-soft); color: #93c5fd; }

/* ---------- 11. Timeline ---------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 1px; background: var(--border); }
.timeline__item { position: relative; padding-bottom: 16px; }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__dot {
    position: absolute; left: -22px; top: 3px;
    width: 15px; height: 15px; border-radius: 50%;
    background: var(--bg-surface); border: 2px solid var(--primary);
    display: grid; place-items: center;
}
.timeline__dot svg { width: 7px; height: 7px; color: var(--primary); }
.timeline__dot--success { border-color: var(--success); }
.timeline__dot--success svg { color: var(--success); }
.timeline__dot--warning { border-color: var(--warning); }
.timeline__dot--warning svg { color: var(--warning); }
.timeline__dot--danger { border-color: var(--danger); }
.timeline__dot--danger svg { color: var(--danger); }
.timeline__dot--purple { border-color: var(--purple); }
.timeline__dot--purple svg { color: var(--purple); }
.timeline__dot--info { border-color: var(--info); }
.timeline__dot--info svg { color: var(--info); }
.timeline__dot--muted { border-color: var(--border-strong); }
.timeline__dot--muted svg { color: var(--text-dim); }
.timeline__text { font-size: 13px; line-height: 1.5; }
.timeline__meta { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; display: flex; align-items: center; gap: 8px; }

/* ---------- 12. Chat ---------- */
.chat { display: flex; flex-direction: column; height: 100%; }
.chat__stream { flex: 1 1 auto; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.chat__msg { display: flex; gap: 11px; }
.chat__bubble { flex: 1 1 auto; min-width: 0; }
.chat__head { display: flex; align-items: baseline; gap: 9px; margin-bottom: 3px; }
.chat__author { font-size: 12.5px; font-weight: 700; letter-spacing: .02em; }
.chat__time { font-size: 11px; color: var(--text-dim); }
.chat__text {
    font-size: 13.5px; line-height: 1.6; color: var(--text);
    background: var(--bg-surface-2); border: 1px solid var(--border-subtle);
    border-radius: 4px 12px 12px 12px; padding: 9px 13px;
    white-space: pre-wrap; word-wrap: break-word;
}
.chat__msg--own .chat__text { background: var(--primary-soft); border-color: var(--primary-line); }
.chat__msg--system .chat__text { background: transparent; border-style: dashed; color: var(--text-muted); font-style: italic; }
.chat__composer { flex: 0 0 auto; border-top: 1px solid var(--border); padding: 12px 16px; display: flex; gap: 10px; align-items: flex-end; }
.chat__composer .textarea { min-height: 42px; max-height: 160px; }

/* ---------- 13. Charts (pure CSS/SVG) ---------- */
.bar-chart { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr auto; align-items: center; gap: 12px; font-size: 12.5px; }
.bar-row__label { color: var(--text-muted); display: flex; align-items: center; gap: 7px; }
.bar-row__track { height: 8px; background: var(--bg-elevated); border-radius: var(--r-pill); overflow: hidden; }
/* display:block es imprescindible: el relleno es un <span> dentro de un
   bloque, y width/height no se aplican a elementos en línea. Sin esto la
   barra quedaba completamente invisible. */
.bar-row__fill { display: block; height: 100%; border-radius: var(--r-pill); background: var(--primary); transition: width .6s var(--ease); }
.bar-row__value { color: var(--text-muted); font-variant-numeric: tabular-nums; min-width: 62px; text-align: right; }

.donut { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.donut__svg { flex: 0 0 auto; transform: rotate(-90deg); }
.donut__legend { flex: 1 1 160px; display: flex; flex-direction: column; gap: 8px; }
.donut__item { display: flex; align-items: center; gap: 9px; font-size: 12.5px; }
.donut__swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.donut__item span:last-child { margin-left: auto; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.donut__center { font-size: 18px; font-weight: 700; }

.spark { display: flex; align-items: flex-end; gap: 3px; height: 40px; }
/* A flat --primary-soft fill was almost indistinguishable from the card
   behind it, so the sparkline looked empty. */
.spark__bar {
    display: block;
    flex: 1 1 auto;
    background: linear-gradient(180deg, var(--primary) 0%, rgba(59, 130, 246, .32) 100%);
    border-radius: 2px 2px 0 0;
    min-height: 4px;
    transition: height .4s var(--ease), background .15s var(--ease);
}
.spark__bar:hover { background: var(--primary); }

.progress { height: 6px; background: var(--bg-elevated); border-radius: var(--r-pill); overflow: hidden; }
.progress__fill { display: block; height: 100%; background: var(--primary); border-radius: var(--r-pill); transition: width .5s var(--ease); }

/* ---------- 14. Modals ---------- */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(5, 9, 18, .72); backdrop-filter: blur(4px);
    display: grid; place-items: start center; padding: 40px 16px;
    overflow-y: auto;
    animation: fade .18s var(--ease);
}
.modal-backdrop[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
    width: 100%; max-width: 620px;
    background: var(--bg-surface); border: 1px solid var(--border-strong);
    border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
    animation: rise .22s var(--ease);
}
.modal--wide { max-width: 900px; }
.modal--narrow { max-width: 440px; }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }

.modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal__head h2 { font-size: 16px; }
.modal__head p { font-size: 12.5px; color: var(--text-dim); margin: 3px 0 0; }
.modal__body { padding: 20px; max-height: 65vh; overflow-y: auto; }
.modal__foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 9px; }

/* ---------- 15. Toasts ---------- */
.toast-stack { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 9px; max-width: 380px; }
.toast {
    display: flex; align-items: flex-start; gap: 11px;
    padding: 12px 14px; border-radius: var(--r-md);
    background: var(--bg-elevated); border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-lg);
    animation: slide-in .25s var(--ease);
}
@keyframes slide-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
.toast.is-leaving { animation: slide-out .2s var(--ease) forwards; }
@keyframes slide-out { to { opacity: 0; transform: translateX(24px); } }
.toast__icon { width: 19px; height: 19px; flex: 0 0 auto; margin-top: 1px; }
.toast__body { flex: 1 1 auto; font-size: 13px; line-height: 1.45; }
.toast__close { background: none; border: 0; color: var(--text-dim); cursor: pointer; padding: 0; line-height: 1; }
.toast--success { border-left: 3px solid var(--success); }
.toast--success .toast__icon { color: var(--success); }
.toast--error { border-left: 3px solid var(--danger); }
.toast--error .toast__icon { color: var(--danger); }
.toast--warning { border-left: 3px solid var(--warning); }
.toast--warning .toast__icon { color: var(--warning); }
.toast--info { border-left: 3px solid var(--primary); }
.toast--info .toast__icon { color: var(--primary); }

/* ---------- 16. Empty / loading states ---------- */
.empty { text-align: center; padding: 44px 20px; }
.empty__icon {
    width: 56px; height: 56px; margin: 0 auto 14px;
    border-radius: var(--r-lg); background: var(--bg-elevated);
    display: grid; place-items: center; color: var(--text-dim);
}
.empty__icon svg { width: 26px; height: 26px; }
.empty h3 { font-size: 15px; margin-bottom: 5px; }
.empty p { color: var(--text-dim); font-size: 13px; max-width: 420px; margin: 0 auto 16px; }

.skeleton {
    background: linear-gradient(90deg, var(--bg-surface-2) 25%, var(--bg-elevated) 50%, var(--bg-surface-2) 75%);
    background-size: 200% 100%; animation: shimmer 1.4s infinite;
    border-radius: var(--r-sm);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skeleton--text { height: 12px; margin-bottom: 8px; }
.skeleton--title { height: 20px; width: 45%; margin-bottom: 14px; }
.skeleton--card { height: 128px; }

/* ---------- 17. Software header ---------- */
.soft-head {
    display: flex; align-items: flex-start; gap: 18px; flex-wrap: wrap;
    padding: 20px; margin-bottom: 20px;
    background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-lg);
    position: relative; overflow: hidden;
}
.soft-head::before {
    content: ""; position: absolute; inset: 0 0 auto 0; height: 92px;
    background: linear-gradient(135deg, var(--primary-soft), transparent 65%);
    pointer-events: none;
}
.soft-head__icon { z-index: 1; }
.soft-head__main { flex: 1 1 300px; min-width: 0; z-index: 1; }
.soft-head__title { display: flex; align-items: center; gap: 11px; flex-wrap: wrap; margin-bottom: 4px; }
.soft-head__title h1 { font-size: 22px; overflow-wrap: anywhere; }
.soft-head__desc { color: var(--text-muted); font-size: 13.5px; margin-bottom: 12px; }

/* Los datos de cabecera van en fichas, no como iconos sueltos con texto:
   así se leen como un grupo y no como una lista descolgada. */
.soft-head__facts { display: flex; flex-wrap: wrap; gap: 7px; }
.soft-head__facts > span,
.soft-head__facts > a {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 4px 10px; border-radius: var(--r-pill);
    background: var(--bg-surface-2); border: 1px solid var(--border);
    font-size: 12.5px; color: var(--text-muted); max-width: 100%;
}
.soft-head__facts > a:hover { border-color: var(--border-strong); color: var(--text); }
.soft-head__facts svg { width: 13px; height: 13px; opacity: .75; flex: 0 0 auto; }
.soft-head__facts .version-pill { background: var(--bg-elevated); border-color: var(--border-strong); color: var(--text); }

/* Columna derecha: cifras + acciones. Antes quedaba un vacío enorme entre el
   título y el botón, sobre todo en fichas con pocos datos. */
.soft-head__side {
    margin-left: auto; z-index: 1;
    display: flex; flex-direction: column; align-items: flex-end;
    gap: 16px; flex: 0 0 auto;
}
.soft-head__stats { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.head-stat {
    min-width: 104px; padding: 10px 14px;
    border-radius: var(--r-md);
    background: var(--bg-surface-2); border: 1px solid var(--border);
    text-align: right;
}
.head-stat__value { font-size: 21px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.head-stat__value small { font-size: 13px; font-weight: 600; color: var(--text-dim); }
.head-stat__label {
    font-size: 10.5px; font-weight: 700; letter-spacing: .07em;
    text-transform: uppercase; color: var(--text-dim); margin-top: 3px;
}
.head-stat--accent { border-color: var(--accent-line, var(--primary-line)); background: var(--accent-soft, var(--primary-soft)); }
.head-stat--accent .head-stat__value { color: var(--accent, var(--primary)); }

.soft-head__actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; z-index: 1; }

@media (max-width: 900px) {
    .soft-head__side { margin-left: 0; align-items: flex-start; width: 100%; }
    .soft-head__stats { justify-content: flex-start; }
}

.version-pill {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 5px 12px; border-radius: var(--r-pill);
    background: var(--bg-elevated); border: 1px solid var(--border-strong);
    font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--text);
}

/* ---------- 18. Definition lists ---------- */
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 9px 16px; font-size: 13px; }
.dl dt { color: var(--text-dim); }
.dl dd { margin: 0; color: var(--text); word-break: break-word; }

.stat-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border-subtle); font-size: 13px; }
.stat-row__value { min-width: 0; }
.stat-row:last-child { border-bottom: 0; }
.stat-row__label { color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
.stat-row__value { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- 19. Auth & installer ---------- */
.auth-shell {
    min-height: 100vh; display: grid; place-items: center;
    padding: 30px 18px;
    background:
        radial-gradient(1100px 520px at 12% -8%, rgba(59, 130, 246, .18), transparent 62%),
        radial-gradient(900px 460px at 92% 108%, rgba(168, 85, 247, .14), transparent 60%),
        var(--bg-root);
}
.auth-card { width: 100%; max-width: 420px; }
.auth-card__brand { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 22px; }
.auth-card__brand .brand-mark { width: 42px; height: 42px; border-radius: 12px; }
.auth-card__brand .brand-mark svg { width: 23px; height: 23px; }
.auth-box { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: 26px; box-shadow: var(--shadow-lg); }
.auth-box h1 { font-size: 19px; margin-bottom: 4px; }
.auth-box > p { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 11.5px; color: var(--text-dim); }

.alert {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 11px 13px; border-radius: var(--r-md);
    font-size: 13px; line-height: 1.5; margin-bottom: 16px;
    border: 1px solid transparent;
}
.alert svg { width: 17px; height: 17px; flex: 0 0 auto; margin-top: 1px; }
.alert--error,
.alert--danger  { background: var(--danger-soft);  border-color: var(--danger-line);  color: #fca5a5; }
.alert--muted   { background: var(--muted-soft);   border-color: var(--muted-line);   color: var(--text-muted); }
.alert--success { background: var(--success-soft); border-color: var(--success-line); color: #86efac; }
.alert--warning { background: var(--warning-soft); border-color: var(--warning-line); color: #fdba74; }
.alert--info    { background: var(--primary-soft); border-color: var(--primary-line); color: #93c5fd; }

/* Installer */
.install-shell { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg-root); }
.install-top {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 24px; border-bottom: 1px solid var(--border);
    background: var(--bg-canvas);
}
.install-body { flex: 1 1 auto; display: flex; gap: 26px; padding: 26px; max-width: 1180px; width: 100%; margin: 0 auto; }
.install-steps { flex: 0 0 244px; }
.install-step {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 11px; border-radius: var(--r-md);
    font-size: 13px; color: var(--text-dim);
}
.install-step__num {
    width: 25px; height: 25px; border-radius: 50%; flex: 0 0 auto;
    display: grid; place-items: center;
    border: 1px solid var(--border-strong); background: var(--bg-surface);
    font-size: 11.5px; font-weight: 700;
}
.install-step.is-done { color: var(--text-muted); }
.install-step.is-done .install-step__num { background: var(--success-soft); border-color: var(--success-line); color: #86efac; }
.install-step.is-current { background: var(--primary-soft); color: #bfdbfe; font-weight: 600; }
.install-step.is-current .install-step__num { background: var(--primary); border-color: var(--primary); color: #fff; }
.install-main { flex: 1 1 auto; min-width: 0; }

.req-list { display: flex; flex-direction: column; }
.req-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 2px; border-bottom: 1px solid var(--border-subtle); font-size: 13px;
}
.req-item:last-child { border-bottom: 0; }
.req-item__state { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; }
.req-item__state svg { width: 12px; height: 12px; }
.req-item__state--ok { background: var(--success-soft); color: var(--success); }
.req-item__state--fail { background: var(--danger-soft); color: var(--danger); }
.req-item__state--warn { background: var(--warning-soft); color: var(--warning); }
.req-item__label { flex: 1 1 auto; min-width: 0; }
.req-item__label small { display: block; color: var(--text-dim); font-size: 11.5px; }
.req-item__value { font-family: var(--mono); font-size: 11.5px; color: var(--text-muted); text-align: right; }

.install-log { font-family: var(--mono); font-size: 12px; line-height: 1.9; }
.install-log__line { display: flex; align-items: flex-start; gap: 9px; }
.install-log__line svg { width: 13px; height: 13px; margin-top: 4px; flex: 0 0 auto; }
.install-log__line--ok { color: #86efac; }
.install-log__line--fail { color: #fca5a5; }

.code-block {
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--r-sm); padding: 11px 13px;
    font-family: var(--mono); font-size: 12px; color: #93c5fd;
    overflow-x: auto; white-space: pre;
}

/* Bloque plegable de permisos por rol */
.perm-details { border-top: 1px solid var(--border-subtle); padding-top: 14px; }
.perm-summary {
    display: flex; align-items: center; gap: 10px;
    cursor: pointer; list-style: none;
    padding: 9px 12px; border-radius: var(--r-sm);
    background: var(--bg-surface-2); border: 1px solid var(--border);
    font-size: 13px; font-weight: 600;
    transition: background .15s var(--ease), border-color .15s var(--ease);
}
.perm-summary::-webkit-details-marker { display: none; }
.perm-summary:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.perm-summary__hint { margin-left: auto; font-size: 11.5px; font-weight: 500; color: var(--text-dim); }
.perm-details[open] .perm-summary__hint::after { content: " (plegar)"; }
.perm-details[open] .perm-summary { border-color: var(--primary-line); }

/* ---------- 20. Utilities ---------- */
.stack   { display: flex; flex-direction: column; }
.stack-8 > * + * { margin-top: 8px; }
.stack-12 > * + * { margin-top: 12px; }
.stack-16 > * + * { margin-top: 16px; }
.stack-20 > * + * { margin-top: 20px; }
.row     { display: flex; align-items: center; gap: 10px; }
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.row--wrap { flex-wrap: wrap; }
.grow    { flex: 1 1 auto; min-width: 0; }
.muted   { color: var(--text-muted); }
.dim     { color: var(--text-dim); }
.small   { font-size: 12px; }
.tiny    { font-size: 11px; }
.bold    { font-weight: 650; }
.center  { text-align: center; }
.right   { text-align: right; }
.nowrap  { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; } .mb-20 { margin-bottom: 20px; }
.hidden { display: none !important; }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger  { color: var(--danger); }
.text-primary { color: var(--primary); }
.text-purple  { color: var(--purple); }
.text-info    { color: var(--info); }
.text-muted   { color: var(--text-muted); }
.text-cyan    { color: var(--cyan); }

/* Truncation only works when the flex/grid item is allowed to shrink below its
   content size. Without min-width:0 a long hash or URL widens the whole card
   instead of being cut with an ellipsis. */
.cell-flex > div,
.stat-row__label > span,
.dl dd,
.soft-head__main,
.chat__bubble,
.grow { min-width: 0; }

.filters { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters .input, .filters .select { width: auto; min-width: 170px; height: 36px; padding-top: 0; padding-bottom: 0; }
.filters .select { max-width: 260px; }

.pagination { display: flex; align-items: center; gap: 5px; }
.pagination__link {
    min-width: 32px; height: 32px; padding: 0 9px;
    border-radius: var(--r-sm); border: 1px solid var(--border);
    background: var(--bg-surface); color: var(--text-muted);
    display: grid; place-items: center; font-size: 12.5px; font-weight: 600;
}
.pagination__link:hover { background: var(--bg-hover); color: var(--text); }
.pagination__link.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination__link.is-disabled { opacity: .4; pointer-events: none; }

/* ---------- 21. Responsive ---------- */
@media (max-width: 1200px) {
    .grid--main { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
    .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.is-open { transform: none; }
    .sidebar-toggle { display: grid; }
    .content { padding: 16px; }
    .dl { grid-template-columns: 1fr; gap: 2px 0; }
    .dl dd { margin-bottom: 9px; }
}

@media (max-width: 860px) {
    .install-body { flex-direction: column; padding: 16px; }
    .install-steps { flex: 0 0 auto; display: flex; gap: 6px; overflow-x: auto; }
    .install-step { flex: 0 0 auto; }
    .install-step span:not(.install-step__num) { display: none; }
    .form-grid--2 { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    /* En pantallas estrechas el par etiqueta/valor no cabe en una línea: si se
       mantiene en fila, el valor se comprime hasta desaparecer. */
    .stat-row { flex-direction: column; align-items: flex-start; gap: 3px; }
    .stat-row__value { text-align: left !important; max-width: 100% !important; }
    .soft-head { padding: 16px; gap: 14px; }
    .soft-head__title h1 { font-size: 19px; }
    .soft-head__stats { width: 100%; }
    .head-stat { flex: 1 1 96px; }
    .dl dd { max-width: 100% !important; }

    .topbar { padding: 0 14px; gap: 9px; }
    .search__kbd { display: none; }
    .user-chip__name, .user-chip__role { display: none; }
    .user-chip { padding: 4px; }
    .page-head { flex-direction: column; align-items: stretch; }
    .kpi__value { font-size: 24px; }
    .bar-row { grid-template-columns: 96px 1fr auto; }
    .modal-backdrop { padding: 16px 10px; }
}

.sidebar-scrim {
    position: fixed; inset: 0; z-index: 35;
    background: rgba(5, 9, 18, .6); backdrop-filter: blur(2px);
}
.sidebar-scrim[hidden] { display: none; }
@media (min-width: 1025px) { .sidebar-scrim { display: none !important; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
    .sidebar, .topbar, .page-head__actions, .btn { display: none !important; }
    body, .app-shell, .content { background: #fff; color: #000; }
    .card { border-color: #ccc; box-shadow: none; }
}

/* ---------- 22. Tareas: tablero, ficha y plantillas ---------- */

/* El tablero es una fila de columnas que se desplaza en horizontal: con cinco
   estados no siempre caben en pantalla, y partirlas en varias filas rompe la
   lectura de izquierda a derecha. */
.board {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(232px, 1fr);
    gap: 14px;
    overflow-x: auto;
    padding-bottom: 10px;
    align-items: start;
    /* En pantallas estrechas las cinco columnas no caben: la barra tiene que
       verse para que se sepa que hay tablero a la derecha. */
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}
.board::-webkit-scrollbar { height: 9px; }
.board::-webkit-scrollbar-track { background: transparent; }
.board::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: var(--r-pill);
}
.board::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
.board__column {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-height: calc(100vh - 300px);
}
.board__head {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 11px 13px;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 1;
    background: var(--bg-elevated);
    border-radius: var(--r-md) var(--r-md) 0 0;
}
.board__title {
    display: inline-flex; align-items: center; gap: 7px;
    font-size: 12px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase;
    color: var(--text-muted);
    min-width: 0;
}
.board__title svg { width: 14px; height: 14px; flex: 0 0 auto; }
.board__list { padding: 10px; display: flex; flex-direction: column; gap: 9px; overflow-y: auto; }
.board__empty { font-size: 12px; color: var(--text-dim); text-align: center; padding: 14px 6px; margin: 0; }

.task-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border-strong);
    border-radius: var(--r-sm);
    padding: 11px 12px;
    display: flex; flex-direction: column; gap: 8px;
    transition: border-color .15s var(--ease), transform .15s var(--ease);
}
.task-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.task-card--danger  { border-left-color: var(--danger); }
.task-card--warning { border-left-color: var(--warning); }
.task-card--info    { border-left-color: var(--primary); }
.task-card--muted   { border-left-color: var(--border-strong); }

.task-card__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.task-card__title {
    display: block;
    font-size: 13.5px; font-weight: 600; line-height: 1.4; color: var(--text);
}
.task-card__title:hover { color: var(--primary); }
.task-card__tags { display: flex; flex-wrap: wrap; gap: 5px; }
.task-tag {
    display: inline-flex; align-items: center; gap: 4px;
    max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 11px; color: var(--text-dim);
    background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: var(--r-pill); padding: 2px 8px;
}
.task-tag svg { width: 11px; height: 11px; flex: 0 0 auto; }
.task-card__progress { display: flex; align-items: center; gap: 8px; }
.task-card__progress .progress { flex: 1 1 auto; height: 4px; }
.task-card__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.task-card__people { display: flex; align-items: center; gap: 4px; min-width: 0; }
.task-card__meta { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; }
.task-card__meta span { display: inline-flex; align-items: center; gap: 3px; }
.task-card__meta svg { width: 11px; height: 11px; }

.badge--xs { height: 18px; padding: 0 7px; font-size: 10.5px; }

/* Ficha: contenido principal + columna de datos. */
.grid--detail { grid-template-columns: minmax(0, 1.65fr) minmax(270px, 1fr); align-items: start; }

/* Cambio de estado: una fila de botones, el actual marcado y deshabilitado. */
.status-flow { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.status-flow__label {
    font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em;
    color: var(--text-dim); margin-right: 3px;
}
.status-flow__step {
    display: inline-flex; align-items: center; gap: 6px;
    height: 32px; padding: 0 12px;
    border-radius: var(--r-pill);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-muted);
    font-size: 12.5px; font-weight: 600; font-family: inherit;
    cursor: pointer;
    transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.status-flow__step svg { width: 13px; height: 13px; }
.status-flow__step:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); border-color: var(--border-strong); }
.status-flow__step.is-current {
    background: var(--primary-soft); border-color: var(--primary-line); color: #93c5fd;
    cursor: default; opacity: 1;
}

/* Checklist del proceso. */
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.checklist__item {
    display: flex; align-items: flex-start; gap: 11px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
}
.checklist__item:last-child { border-bottom: 0; }
.checklist__check {
    flex: 0 0 auto;
    width: 20px; height: 20px; margin-top: 1px;
    display: grid; place-items: center;
    border-radius: 6px;
    border: 1.5px solid var(--border-strong);
    background: var(--bg-elevated);
    color: transparent;
    cursor: pointer;
    padding: 0;
    transition: background .15s var(--ease), border-color .15s var(--ease);
}
.checklist__check:hover { border-color: var(--primary); background: var(--primary-soft); }
.checklist__check svg { width: 13px; height: 13px; }
.checklist__body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.checklist__title { font-size: 13px; line-height: 1.45; color: var(--text); }
.checklist__remove {
    flex: 0 0 auto;
    width: 24px; height: 24px;
    display: grid; place-items: center;
    border: 0; background: transparent; color: var(--text-dim);
    border-radius: 6px; cursor: pointer; padding: 0;
    opacity: 0; transition: opacity .15s var(--ease), color .15s var(--ease);
}
.checklist__item:hover .checklist__remove { opacity: 1; }
.checklist__remove:hover { color: var(--danger); background: var(--danger-soft); }
.checklist__remove:focus-visible { opacity: 1; }
.checklist__item.is-done .checklist__check {
    background: var(--success); border-color: var(--success); color: #05131a;
}
.checklist__item.is-done .checklist__title { color: var(--text-dim); text-decoration: line-through; }

/* Selector de personas: lista con scroll, no un multiselect nativo. */
.picker {
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--bg-elevated);
    max-height: 220px;
    overflow-y: auto;
}
.picker__item {
    display: flex; align-items: center; gap: 9px;
    padding: 7px 10px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    font-size: 13px;
}
.picker__item:last-child { border-bottom: 0; }
.picker__item:hover { background: var(--bg-hover); }
.picker__item input { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; flex: 0 0 auto; }

/* Pasos de una plantilla de proceso. */
.steps-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.steps-list li { display: flex; align-items: flex-start; gap: 9px; font-size: 12.5px; line-height: 1.45; }
.steps-list__num {
    flex: 0 0 auto;
    width: 19px; height: 19px; margin-top: 1px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--bg-surface); border: 1px solid var(--border);
    color: var(--text-dim); font-size: 10.5px; font-weight: 650;
    font-variant-numeric: tabular-nums;
}
.tpl-icon {
    display: inline-grid; place-items: center;
    width: 26px; height: 26px; border-radius: 8px;
    background: color-mix(in srgb, var(--tpl) 18%, transparent);
    border: 1px solid color-mix(in srgb, var(--tpl) 38%, transparent);
    color: var(--tpl);
    flex: 0 0 auto;
}
.card.is-muted { opacity: .68; }

@media (max-width: 1100px) {
    .grid--detail { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .board { grid-auto-columns: minmax(240px, 82vw); }
    .board__column { max-height: none; }
    .status-flow__label { width: 100%; margin-bottom: 2px; }
    .checklist__remove { opacity: 1; }
}

/* ---------- 23. Tiendas ---------- */

/* La tarjeta se lee de arriba abajo: primero el código interno con la
   provincia (PR-21 · ALICANTE) y debajo la localidad concreta, que es como
   el departamento nombra los puntos. */
.site-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: inherit;
    transition: border-color .15s var(--ease), transform .15s var(--ease);
}
.site-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.site-card.is-inactive { opacity: .62; }

.site-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.site-card__ident { min-width: 0; }
.site-card__code {
    display: block;
    font-family: var(--mono);
    font-size: 12px; font-weight: 650; letter-spacing: .04em;
    color: var(--primary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.site-card__place {
    display: block;
    font-size: 15px; font-weight: 650; letter-spacing: -.01em;
    color: var(--text);
    margin-top: 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.site-card__name { font-size: 12.5px; color: var(--text-dim); margin: -4px 0 0; }

.site-card__meta { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-dim); }
.site-card__meta span { display: flex; align-items: center; gap: 6px; min-width: 0; }
.site-card__meta svg { flex: 0 0 auto; opacity: .8; }

.site-card__stats {
    display: flex; flex-wrap: wrap; gap: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 12px; color: var(--text-muted);
}
.site-card__stats span { display: inline-flex; align-items: center; gap: 5px; }
.site-card__stats svg { opacity: .8; }

/* Fila de tabla atenuada: un equipo retirado sigue en el histórico. */
.table tr.is-dim td { opacity: .6; }

/* =========================================================================
   24. Fotogramas compartidos
   -------------------------------------------------------------------------
   Los únicos que quedan: los usa la pantalla de acceso. El interior de la
   aplicación no lleva animaciones de entrada.
   ========================================================================= */
@keyframes zi-fade  { from { opacity: 0; } }
@keyframes zi-pop   { from { opacity: 0; transform: scale(.955) translateY(8px); } }
@keyframes zi-blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

/* =========================================================================
   26. Pantalla de acceso
   -------------------------------------------------------------------------
   Terminal de intrusión: lluvia de código, figura encapuchada tecleando y
   consola que va comentando la jugada. Cuando las credenciales fallan la
   escena entera se pone en rojo y suelta el repertorio.

   Todo es CSS y SVG a mano: ni imágenes, ni tipografías externas, ni
   dependencias. Sin JavaScript el formulario sigue siendo un formulario
   normal y corriente que se envía igual.
   ========================================================================= */

.hx-shell {
    --hx: #3ffb8b;                       /* fósforo verde: el color de la escena */
    --hx-dim: rgba(63, 251, 139, .18);
    position: relative;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px 18px;
    background:
        radial-gradient(1000px 620px at 22% -10%, rgba(16, 185, 129, .10), transparent 60%),
        radial-gradient(900px 520px at 88% 110%, rgba(34, 211, 238, .09), transparent 58%),
        #05090d;
    transition: --hx .3s linear;
}

/* Credenciales rechazadas: la escena vira a rojo y se sacude. */
.hx-shell.is-denied {
    --hx: #ff3b5c;
    --hx-dim: rgba(255, 59, 92, .2);
    animation: zi-hx-shake .5s cubic-bezier(.36, .07, .19, .97);
}
@keyframes zi-hx-shake {
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(4px); }
    30%, 50%, 70% { transform: translateX(-7px); }
    40%, 60% { transform: translateX(7px); }
}

/* Lluvia de código: la pinta el canvas, aquí solo se coloca. */
.hx-rain {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    z-index: 0; pointer-events: none;
    opacity: .34;
    -webkit-mask-image: radial-gradient(120% 100% at 50% 40%, transparent 8%, #000 72%);
    mask-image: radial-gradient(120% 100% at 50% 40%, transparent 8%, #000 72%);
}

/* Líneas de tubo de rayos catódicos sobre todo el conjunto. */
.hx-shell::after {
    content: "";
    position: absolute; inset: 0; z-index: 3; pointer-events: none;
    background: repeating-linear-gradient(180deg, rgba(0, 0, 0, .22) 0 1px, transparent 1px 3px);
    -webkit-mask-image: radial-gradient(130% 110% at 50% 50%, #000 55%, rgba(0, 0, 0, .55) 100%);
    mask-image: radial-gradient(130% 110% at 50% 50%, #000 55%, rgba(0, 0, 0, .55) 100%);
}

.hx-stage {
    position: relative; z-index: 2;
    width: 100%; max-width: 1020px;
    display: grid; gap: 26px;
    grid-template-columns: minmax(0, 1.05fr) minmax(330px, .95fr);
    align-items: center;
}

/* ---------- Escena del hacker ---------- */
.hx-scene { position: relative; min-width: 0; animation: zi-fade .7s var(--ease) .15s backwards; }

.hx-figure {
    display: block; width: 100%; max-width: 460px; height: auto; margin: 0 auto 6px;
    overflow: visible;
    filter: drop-shadow(0 0 26px var(--hx-dim));
}

/* Respiración: el cuerpo sube y baja despacio. */
.hx-body { animation: zi-hx-breathe 3.4s ease-in-out infinite; transform-origin: 130px 190px; }
@keyframes zi-hx-breathe {
    50% { transform: translateY(-2.5px) scaleY(1.006); }
}

.hx-hood   { fill: #071018; stroke: var(--hx); stroke-width: 2.2; stroke-linejoin: round; }
.hx-face   { fill: #02060a; }
.hx-fold   { fill: none; stroke: var(--hx); stroke-width: 1.6; opacity: .45; stroke-linecap: round; }
.hx-desk   { fill: none; stroke: var(--hx); stroke-width: 2; opacity: .5; stroke-linecap: round; }
.hx-screen { fill: #040c10; stroke: var(--hx); stroke-width: 1.8; }
.hx-stand  { fill: none; stroke: var(--hx); stroke-width: 1.8; opacity: .6; stroke-linecap: round; }

/* Ojos: dos rendijas encendidas que parpadean. */
.hx-eye {
    fill: var(--hx);
    transform-box: fill-box; transform-origin: center;
    animation: zi-hx-blink 4.6s steps(1) infinite;
    filter: drop-shadow(0 0 5px var(--hx));
}
.hx-eye--r { animation-delay: .04s; }
@keyframes zi-hx-blink {
    0%, 92%, 96%, 100% { opacity: 1; transform: scaleY(1); }
    93%, 95% { opacity: .25; transform: scaleY(.12); }
}

/* Manos: teclean a distinto ritmo, que es lo que lo hace creíble. */
.hx-hand { fill: #071018; stroke: var(--hx); stroke-width: 2; stroke-linejoin: round; }
.hx-hand--l,
.hx-hand--r { transform-box: fill-box; transform-origin: bottom center; }
.hx-hand--l { animation: zi-hx-tap .34s ease-in-out infinite; }
.hx-hand--r { animation: zi-hx-tap .29s ease-in-out .12s infinite; }
@keyframes zi-hx-tap { 50% { transform: translateY(-3.5px) rotate(-4deg); } }

/* Portátil: la tapa vista por detrás y el resplandor que sube a la cara. */
.hx-lid   { fill: #040c12; stroke: var(--hx); stroke-width: 2; stroke-linejoin: round; }
.hx-base  { fill: #071018; stroke: var(--hx); stroke-width: 2; stroke-linejoin: round; }
.hx-logo  { fill: var(--hx); opacity: .75; animation: zi-hx-flicker 2.6s steps(1) infinite; }
.hx-glow  {
    fill: var(--hx); opacity: .16;
    animation: zi-hx-flicker 1.9s steps(1) infinite;
}
@keyframes zi-hx-flicker {
    0%, 100% { opacity: .16; }
    47% { opacity: .16; }
    48% { opacity: .05; }
    52% { opacity: .22; }
    72% { opacity: .1; }
}

/* Los monitores laterales quedan un paso por detrás de la figura. */
.hx-side { opacity: .78; }
.hx-laptop { filter: drop-shadow(0 0 10px var(--hx-dim)); }

/* Barras de código que corren por la pantalla auxiliar. */
.hx-bar { fill: var(--hx); opacity: .55; transform-box: fill-box; transform-origin: left center; }
.hx-bar:nth-of-type(1) { animation: zi-hx-scanbar 1.4s linear infinite; }
.hx-bar:nth-of-type(2) { animation: zi-hx-scanbar 1.9s linear .2s infinite; }
.hx-bar:nth-of-type(3) { animation: zi-hx-scanbar 1.6s linear .5s infinite; }
.hx-bar:nth-of-type(4) { animation: zi-hx-scanbar 2.4s linear .8s infinite; }
.hx-bar:nth-of-type(5) { animation: zi-hx-scanbar 1.7s linear .3s infinite; }
.hx-bar:nth-of-type(6) { animation: zi-hx-scanbar 2.1s linear .6s infinite; }
@keyframes zi-hx-scanbar {
    0%   { transform: scaleX(.15); opacity: .2; }
    45%  { transform: scaleX(1);   opacity: .75; }
    100% { transform: scaleX(.3);  opacity: .25; }
}

/* ---------- Consola de la escena ---------- */
.hx-console {
    margin: 0 auto; max-width: 460px;
    min-height: 96px;
    padding: 12px 14px;
    border: 1px solid var(--hx-dim);
    border-radius: 10px;
    background: rgba(4, 10, 8, .6);
    font-family: var(--mono); font-size: 12px; line-height: 1.75;
    color: var(--hx);
    text-shadow: 0 0 10px var(--hx-dim);
    white-space: pre-wrap; word-break: break-word;
}
.hx-console span { display: block; }
.hx-console b { font-weight: 400; color: #d8fff0; }
.hx-caret {
    display: inline-block; width: 7px; height: 12px;
    background: var(--hx); vertical-align: -1px;
    animation: zi-blink 1s steps(1) infinite;
}

/* ---------- Tarjeta de acceso ---------- */
.hx-card {
    position: relative; min-width: 0;
    padding: 26px;
    border: 1px solid var(--hx-dim);
    border-radius: var(--r-xl);
    background: linear-gradient(180deg, rgba(9, 18, 16, .93), rgba(4, 9, 12, .96));
    box-shadow: 0 40px 110px -40px #000, inset 0 1px 0 rgba(215, 255, 240, .06);
    animation: zi-pop .6s cubic-bezier(.22, 1, .36, 1) .1s backwards;
}
.hx-card::before,
.hx-card::after {
    content: ""; position: absolute; width: 18px; height: 18px; pointer-events: none;
    border: 2px solid var(--hx); opacity: .8;
}
.hx-card::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; border-radius: var(--r-xl) 0 0 0; }
.hx-card::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; border-radius: 0 0 var(--r-xl) 0; }

.hx-card__head { margin-bottom: 20px; }
.hx-card__brand { display: flex; align-items: center; gap: 11px; margin-bottom: 16px; }
.hx-card__mark {
    width: 40px; height: 40px; border-radius: 11px; flex: 0 0 auto;
    display: grid; place-items: center;
    border: 1px solid var(--hx-dim);
    background: rgba(63, 251, 139, .07);
    color: var(--hx);
}
.hx-card__mark svg { width: 21px; height: 21px; }
.hx-card__brand > div strong { display: block; font-size: 15px; color: #e7fff5; letter-spacing: -.01em; }
.hx-card__brand > div span {
    display: block; font-family: var(--mono); font-size: 9.5px;
    letter-spacing: .18em; text-transform: uppercase; color: var(--hx); opacity: .8;
}

.hx-card h1 {
    font-family: var(--mono); font-size: 15px; font-weight: 700;
    letter-spacing: .04em; color: #e7fff5; margin-bottom: 5px;
}
.hx-card__sub { font-family: var(--mono); font-size: 11.5px; color: var(--hx); opacity: .75; margin: 0; }

/* Los campos van con estética de terminal, pero son inputs normales. */
.hx-field { margin-bottom: 15px; }
.hx-field__label {
    display: block; margin-bottom: 6px;
    font-family: var(--mono); font-size: 10.5px; letter-spacing: .14em;
    text-transform: uppercase; color: var(--hx); opacity: .85;
}
.hx-input {
    width: 100%; height: 42px; padding: 0 13px;
    font-family: var(--mono); font-size: 13.5px; color: #e7fff5;
    background: rgba(2, 6, 8, .85);
    border: 1px solid var(--hx-dim); border-radius: 9px;
    outline: none;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.hx-input::placeholder { color: rgba(215, 255, 240, .25); }
.hx-input:focus {
    border-color: var(--hx);
    box-shadow: 0 0 0 3px var(--hx-dim), 0 0 22px -6px var(--hx);
}

.hx-submit {
    width: 100%; height: 44px; margin-top: 4px;
    display: inline-flex; align-items: center; justify-content: center; gap: 9px;
    font-family: var(--mono); font-size: 13px; font-weight: 700; letter-spacing: .1em;
    text-transform: uppercase;
    color: #04110b; background: var(--hx);
    border: 0; border-radius: 9px; cursor: pointer;
    box-shadow: 0 0 26px -6px var(--hx);
    transition: transform .15s var(--ease), box-shadow .15s var(--ease), filter .15s var(--ease);
}
.hx-submit svg { width: 16px; height: 16px; }
.hx-submit:hover { transform: translateY(-1px); box-shadow: 0 0 34px -4px var(--hx); filter: brightness(1.06); }
.hx-submit:active { transform: translateY(0); }

.hx-alert {
    display: flex; align-items: flex-start; gap: 9px;
    margin-bottom: 16px; padding: 10px 12px;
    border: 1px solid rgba(255, 59, 92, .4);
    border-radius: 9px;
    background: rgba(255, 59, 92, .1);
    font-family: var(--mono); font-size: 12px; line-height: 1.55; color: #ffb3c0;
}
.hx-alert svg { width: 16px; height: 16px; flex: 0 0 auto; margin-top: 1px; }
.hx-alert--warning { border-color: rgba(251, 191, 36, .4); background: rgba(251, 191, 36, .1); color: #fde08a; }
.hx-alert--success { border-color: var(--hx-dim); background: rgba(63, 251, 139, .1); color: #9dffcb; }

.hx-meta {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    margin-top: 18px; padding-top: 14px;
    border-top: 1px solid var(--hx-dim);
    font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em;
    color: rgba(215, 255, 240, .45);
}
.hx-meta span { display: inline-flex; align-items: center; gap: 6px; }
.hx-meta svg { width: 13px; height: 13px; }

.hx-foot {
    margin: 16px 0 0; text-align: center;
    font-family: var(--mono); font-size: 10.5px; line-height: 1.7;
    color: rgba(215, 255, 240, .3);
}

/* ---------- Cartel de acceso denegado ---------- */
.hx-denied {
    position: absolute; inset: 0; z-index: 4;
    display: grid; place-items: center;
    pointer-events: none;
}
.hx-denied[hidden] { display: none !important; }
.hx-denied__text {
    position: relative;
    font-family: var(--mono); font-size: clamp(26px, 6.5vw, 62px); font-weight: 700;
    letter-spacing: .12em; color: #ff3b5c;
    text-shadow: 0 0 30px rgba(255, 59, 92, .6);
    animation: zi-hx-denied 1.5s steps(1) forwards;
}
/* Separación RGB: el desdoblamiento típico de una señal rota. */
.hx-denied__text::before,
.hx-denied__text::after {
    content: attr(data-text);
    position: absolute; inset: 0;
}
.hx-denied__text::before { color: #22d3ee; animation: zi-hx-split-a .28s steps(2) 5; }
.hx-denied__text::after  { color: #ff3b5c; animation: zi-hx-split-b .32s steps(2) 5; }
@keyframes zi-hx-split-a { 0%, 100% { transform: none; opacity: 0; } 50% { transform: translate(-4px, 2px); opacity: .8; } }
@keyframes zi-hx-split-b { 0%, 100% { transform: none; opacity: 0; } 50% { transform: translate(5px, -2px); opacity: .7; } }
@keyframes zi-hx-denied {
    0%, 8%, 16%, 30% { opacity: 1; }
    12%, 22% { opacity: .15; }
    90% { opacity: 1; }
    100% { opacity: 0; visibility: hidden; }
}

@media (max-width: 900px) {
    .hx-stage { grid-template-columns: 1fr; gap: 20px; }
    .hx-figure { max-width: 300px; }
    .hx-console { min-height: 76px; font-size: 11.5px; }
}

@media (max-width: 520px) {
    .hx-figure { max-width: 230px; }
    .hx-card { padding: 20px; }
}

/* Quien pide menos movimiento recibe la misma pantalla, quieta. */
@media (prefers-reduced-motion: reduce) {
    .hx-rain { display: none; }
    .hx-shell::after { background: none; }
}

/* =========================================================================
   27. Barra lateral: presencia verde
   -------------------------------------------------------------------------
   El menú comparte el color de la pantalla de acceso, pero quieto: nada
   parpadea ni se recompone mientras se lee. Lo único que se mueve es el
   punto de "en línea", muy despacio, y el destello que sigue al puntero
   cuando pasa por encima de un enlace.
   ========================================================================= */

:root {
    --phos:      #3ffb8b;                    /* el verde de la terminal */
    --phos-soft: rgba(63, 251, 139, .10);
    --phos-line: rgba(63, 251, 139, .32);
}

/* El apartado activo se marca en verde, sin animación de ningún tipo. */
.nav-link.is-active {
    background: var(--phos-soft);
    color: #b9ffd8;
    box-shadow: inset 0 0 24px -14px var(--phos);
}
.nav-link.is-active::before { background: var(--phos); box-shadow: 0 0 10px -1px var(--phos); }
.nav-link.is-active svg { opacity: 1; color: var(--phos); }
.nav-link.is-active .nav-link__badge--muted { border-color: var(--phos-line); color: #b9ffd8; }

/* Al pasar por encima, el icono se tiñe. Es una transición de color, no un
   movimiento: no desplaza nada ni distrae en visión periférica. */
.nav-link svg { transition: color .15s var(--ease), opacity .15s var(--ease); }
.nav-link:hover svg { color: var(--phos); opacity: 1; }

/* Destello tenue que acompaña al puntero dentro del enlace. */
.nav-link { position: relative; overflow: hidden; }
.nav-link::after {
    content: "";
    position: absolute; inset: 0;
    pointer-events: none;
    background: linear-gradient(90deg, transparent, var(--phos-soft) 45%, transparent);
    transform: translateX(-100%);
    opacity: 0;
}
.nav-link:hover::after { animation: zi-sb-sweep .5s ease-out; }
@keyframes zi-sb-sweep {
    0%   { transform: translateX(-100%); opacity: 1; }
    100% { transform: translateX(100%); opacity: 0; }
}
.nav-link svg,
.nav-link span { position: relative; z-index: 1; }

/* Testigo de sistema en línea: un punto que respira cada cuatro segundos.
   Es el único elemento con movimiento continuo dentro del panel. */
.sys-live {
    display: flex; align-items: center; gap: 9px;
    padding: 8px 11px; margin-bottom: 8px;
    border: 1px solid var(--phos-line);
    border-radius: var(--r-sm);
    background: var(--phos-soft);
    font-family: var(--mono); font-size: 10.5px;
    letter-spacing: .12em; text-transform: uppercase;
    color: #b9ffd8;
}
.sys-live__dot {
    width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto;
    background: var(--phos);
    box-shadow: 0 0 8px var(--phos);
    animation: zi-live 4s ease-in-out infinite;
}
@keyframes zi-live {
    0%, 100% { opacity: .45; }
    50%      { opacity: 1; }
}
.sys-live__text { flex: 1 1 auto; min-width: 0; }
.sys-live__count { color: var(--phos); font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
    .sys-live__dot { animation: none; opacity: 1; }
    .nav-link:hover::after { animation: none; }
}

/* ---------- 28. Accesos: resumen por IP ---------- */
.ip-row {
    display: flex; flex-direction: column; gap: 6px;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--bg-elevated);
}
.ip-row__meta {
    display: flex; flex-wrap: wrap; gap: 10px;
    font-size: 11.5px; color: var(--text-dim);
}
.ip-row__meta span { display: inline-flex; align-items: center; gap: 4px; }

/* ---------- 29. Reloj del CMS ---------- */
/* La hora de la zona configurada para el panel, no la del servidor ni la del
   navegador de quien mira. */
.cms-clock {
    display: inline-flex; align-items: center; gap: 7px;
    height: 34px; padding: 0 11px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--bg-elevated);
    color: var(--text-muted);
    font-family: var(--mono); font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    transition: border-color .15s var(--ease), color .15s var(--ease);
}
.cms-clock:hover { border-color: var(--border-strong); color: var(--text); }
.cms-clock svg { width: 14px; height: 14px; opacity: .75; }
.cms-clock small { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-dim); }

@media (max-width: 900px) { .cms-clock small { display: none; } }
@media (max-width: 640px) { .cms-clock { display: none; } }

/* ---------- 30. Progreso de subida por trozos ---------- */
.upload-progress {
    display: flex; flex-direction: column; gap: 6px;
    margin-bottom: 14px;
    padding: 10px 12px;
    border: 1px solid var(--primary-line);
    border-radius: var(--r-sm);
    background: var(--primary-soft);
}
.upload-progress[hidden] { display: none !important; }
