/* ==========================================================================
   ui.css — Sistema de diseño "Claro" del panel HernanDVF
   Guía: .claude/standards/07-guia-estilos-ui.md
   ========================================================================== */

/* ---------- Fuentes (locales) ---------- */
@font-face {
    font-family: 'Inter';
    src: url('/public/assets/fonts/inter-var-latin.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'JetBrains Mono';
    src: url('/public/assets/fonts/jetbrains-mono-var-latin.woff2') format('woff2');
    font-weight: 100 800;
    font-style: normal;
    font-display: swap;
}

/* ---------- Tokens ---------- */
/* Paleta "azul pastel": dos colores de marca.
   --brand-light  azul pastel claro  -> fondos suaves, selección, acentos, marca en sidebar
   --brand-dark   azul pastel oscuro -> acción primaria, sidebar, enlaces, foco */
:root {
    color-scheme: light;

    --brand-light: #a9c9ec;
    --brand-light-soft: #e8f1fb;
    --brand-dark: #4a6fa5;
    --brand-dark-deep: #3a5a8c;

    --bg: #f3f7fc;
    --surface: #ffffff;
    --surface-2: #edf3fa;
    --surface-3: #e0eaf6;
    --border: #dbe5f1;
    --border-strong: #c4d3e6;
    --overlay: rgba(20, 35, 58, 0.42);

    --text: #14233a;
    --text-2: #4b5d78;
    --text-3: #8a9bb4;
    --text-inverse: #ffffff;

    --primary: var(--brand-dark);
    --primary-hover: var(--brand-dark-deep);
    --primary-soft: var(--brand-light-soft);
    --primary-text: #34548a;
    --on-primary: #ffffff;
    --accent: var(--brand-light);
    --focus-ring: 0 0 0 3px rgba(74, 111, 165, 0.28);

    --sidebar-bg: var(--brand-dark);
    --sidebar-fg: #e4edf8;
    --sidebar-fg-muted: #b5c9e3;
    --sidebar-hover: rgba(255, 255, 255, 0.10);
    --sidebar-active-bg: rgba(169, 201, 236, 0.24);
    --sidebar-active-fg: #ffffff;
    --sidebar-border: rgba(255, 255, 255, 0.12);

    --success: #3fa57a;
    --success-soft: #e9f7f0;
    --success-text: #1f7a52;
    --warning: #e39a3b;
    --warning-soft: #fdf4e6;
    --warning-text: #9a5b0d;
    --danger: #d9534f;
    --danger-hover: #c0403c;
    --danger-soft: #fcefee;
    --danger-text: #a8322e;
    --info: #5b9bd5;
    --info-soft: #ebf4fc;
    --info-text: #2a6496;

    --chart-1: #4a6fa5;
    --chart-2: #7fb0e3;
    --chart-3: #3fa57a;
    --chart-4: #e39a3b;
    --chart-5: #8e7cc3;
    --chart-6: #d97fa8;

    --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
    --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-full: 999px;

    --shadow-xs: 0 1px 2px rgba(20, 35, 58, 0.05);
    --shadow-sm: 0 2px 6px rgba(20, 35, 58, 0.07), 0 1px 2px rgba(20, 35, 58, 0.04);
    --shadow-lg: 0 16px 32px -8px rgba(20, 35, 58, 0.18), 0 4px 8px -2px rgba(20, 35, 58, 0.06);

    --ease: cubic-bezier(0.2, 0, 0, 1);
    --dur: 150ms;

    --sidebar-w: 248px;
    --topbar-h: 60px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --brand-light: #a9c9ec;
        --brand-light-soft: rgba(169, 201, 236, 0.14);
        --brand-dark: #4a6fa5;
        --brand-dark-deep: #3a5a8c;
        --bg: #0e1622;
        --surface: #152133;
        --surface-2: #1b2a40;
        --surface-3: #23354f;
        --border: #263852;
        --border-strong: #34496a;
        --overlay: rgba(4, 10, 20, 0.62);
        --text: #eef3fa;
        --text-2: #b3c2d8;
        --text-3: #7488a6;
        --primary: #8fb6e6;
        --primary-hover: #a9c9ec;
        --primary-soft: rgba(143, 182, 230, 0.15);
        --primary-text: #b9d4f2;
        --on-primary: #0e1622;
        --focus-ring: 0 0 0 3px rgba(143, 182, 230, 0.32);
        --sidebar-bg: #12233a;
        --sidebar-fg: #c9d8ec;
        --sidebar-fg-muted: #8098b8;
        --sidebar-hover: rgba(169, 201, 236, 0.08);
        --sidebar-active-bg: rgba(169, 201, 236, 0.16);
        --sidebar-active-fg: #e8f1fb;
        --sidebar-border: #1f3150;
        --success-soft: rgba(63, 165, 122, 0.15);
        --success-text: #7fd3ae;
        --warning-soft: rgba(227, 154, 59, 0.15);
        --warning-text: #f2c181;
        --danger-soft: rgba(217, 83, 79, 0.16);
        --danger-text: #f19a97;
        --info-soft: rgba(91, 155, 213, 0.15);
        --info-text: #9cc6ee;
        --chart-1: #8fb6e6;
        --chart-2: #4f7fc0;
        --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.35);
        --shadow-lg: 0 16px 32px -8px rgba(0, 0, 0, 0.6);
    }
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --brand-light: #a9c9ec;
    --brand-light-soft: rgba(169, 201, 236, 0.14);
    --brand-dark: #4a6fa5;
    --brand-dark-deep: #3a5a8c;
    --bg: #0e1622;
    --surface: #152133;
    --surface-2: #1b2a40;
    --surface-3: #23354f;
    --border: #263852;
    --border-strong: #34496a;
    --overlay: rgba(4, 10, 20, 0.62);
    --text: #eef3fa;
    --text-2: #b3c2d8;
    --text-3: #7488a6;
    --primary: #8fb6e6;
    --primary-hover: #a9c9ec;
    --primary-soft: rgba(143, 182, 230, 0.15);
    --primary-text: #b9d4f2;
    --on-primary: #0e1622;
    --focus-ring: 0 0 0 3px rgba(143, 182, 230, 0.32);
    --sidebar-bg: #12233a;
    --sidebar-fg: #c9d8ec;
    --sidebar-fg-muted: #8098b8;
    --sidebar-hover: rgba(169, 201, 236, 0.08);
    --sidebar-active-bg: rgba(169, 201, 236, 0.16);
    --sidebar-active-fg: #e8f1fb;
    --sidebar-border: #1f3150;
    --success-soft: rgba(63, 165, 122, 0.15);
    --success-text: #7fd3ae;
    --warning-soft: rgba(227, 154, 59, 0.15);
    --warning-text: #f2c181;
    --danger-soft: rgba(217, 83, 79, 0.16);
    --danger-text: #f19a97;
    --info-soft: rgba(91, 155, 213, 0.15);
    --info-text: #9cc6ee;
    --chart-1: #8fb6e6;
    --chart-2: #4f7fc0;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 32px -8px rgba(0, 0, 0, 0.6);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv11', 'ss01';
}
img, svg, video, canvas { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
h1, h2, h3, h4 { line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; } h2 { font-size: 16px; } h3 { font-size: 15px; } h4 { font-size: 14px; }
p { color: var(--text-2); }
code, kbd, pre, .mono { font-family: var(--font-mono); font-size: 0.92em; }
hr, .divider { border: 0; border-top: 1px solid var(--border); margin: var(--sp-4) 0; }
::selection { background: var(--primary-soft); color: var(--text); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: var(--radius-sm); }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

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

/* ---------- Iconos ---------- */
.icon { width: 18px; height: 18px; flex-shrink: 0; display: inline-block; vertical-align: middle; }
.icon--xs { width: 14px; height: 14px; }
.icon--sm { width: 16px; height: 16px; }
.icon--lg { width: 22px; height: 22px; }
.icon--xl { width: 28px; height: 28px; }
.spin { animation: ui-spin 0.9s linear infinite; }
@keyframes ui-spin { to { transform: rotate(360deg); } }

.icon-tile {
    display: inline-grid; place-items: center; flex-shrink: 0;
    width: 40px; height: 40px; border-radius: var(--radius);
    background: var(--surface-2); color: var(--text-2);
}
.icon-tile--sm { width: 32px; height: 32px; border-radius: var(--radius-sm); }
.icon-tile--sm .icon { width: 16px; height: 16px; }
.icon-tile--primary { background: var(--primary-soft); color: var(--primary); }
.icon-tile--success { background: var(--success-soft); color: var(--success-text); }
.icon-tile--warning { background: var(--warning-soft); color: var(--warning-text); }
.icon-tile--danger  { background: var(--danger-soft);  color: var(--danger-text); }
.icon-tile--info    { background: var(--info-soft);    color: var(--info-text); }
.icon-tile--neutral { background: var(--surface-2);    color: var(--text-2); }

.brand-mark {
    display: inline-grid; place-items: center;
    width: 32px; height: 32px; border-radius: 9px;
    background: var(--primary); color: var(--on-primary);
}
.brand-mark .icon { width: 18px; height: 18px; }

/* ---------- Layout de aplicación ---------- */
.app { min-height: 100vh; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40;
    width: var(--sidebar-w);
    display: flex; flex-direction: column;
    background: var(--sidebar-bg); color: var(--sidebar-fg);
    border-right: 1px solid var(--sidebar-border);
    transition: transform 200ms var(--ease);
}
.sidebar__brand {
    display: flex; align-items: center; gap: var(--sp-3);
    height: var(--topbar-h); padding: 0 var(--sp-5);
    font-weight: 650; font-size: 15px; color: var(--sidebar-active-fg);
    border-bottom: 1px solid var(--sidebar-border);
}
.sidebar__brand:hover { color: var(--sidebar-active-fg); }
.sidebar .brand-mark { background: var(--brand-light); color: var(--brand-dark-deep); }
.sidebar__search {
    display: flex; align-items: center; gap: var(--sp-2); width: calc(100% - 2 * var(--sp-3));
    margin: var(--sp-3) var(--sp-3) 0; padding: 7px var(--sp-3);
    border: 1px solid var(--sidebar-border); border-radius: var(--radius-sm);
    background: var(--sidebar-hover); color: var(--sidebar-fg-muted); font-size: 13px; text-align: left;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.sidebar__search:hover { color: var(--sidebar-active-fg); background: var(--sidebar-active-bg); }
.sidebar__search .icon { width: 16px; height: 16px; }
.sidebar__search kbd { margin-left: auto; }
.sidebar__nav { flex: 1; overflow-y: auto; padding: var(--sp-3) var(--sp-3) var(--sp-4); display: flex; flex-direction: column; gap: 2px; }
.sidebar__section { padding: var(--sp-4) var(--sp-3) var(--sp-2); font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--sidebar-fg-muted); }
.sidebar__footer { padding: var(--sp-3); border-top: 1px solid var(--sidebar-border); }
.sidebar * { scrollbar-color: var(--sidebar-border) transparent; }

.nav-item {
    position: relative;
    display: flex; align-items: center; gap: var(--sp-3);
    padding: 8px var(--sp-3); border-radius: var(--radius-sm);
    color: var(--sidebar-fg); font-weight: 500;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-item .icon { color: var(--sidebar-fg-muted); }
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-active-fg); }
.nav-item:hover .icon { color: var(--brand-light); }
.nav-item.is-active { background: var(--sidebar-active-bg); color: var(--sidebar-active-fg); font-weight: 600; }
.nav-item.is-active::before {
    content: ''; position: absolute; left: calc(var(--sp-3) * -1); top: 8px; bottom: 8px;
    width: 3px; border-radius: 0 3px 3px 0; background: var(--brand-light);
}
.nav-item.is-active .icon { color: var(--brand-light); }
.sidebar :focus-visible { outline-color: var(--brand-light); }

.user-chip { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2); border-radius: var(--radius); }
.avatar {
    display: inline-grid; place-items: center; flex-shrink: 0;
    width: 34px; height: 34px; border-radius: var(--radius-full);
    background: var(--primary-soft); color: var(--primary-text);
    font-weight: 600; font-size: 13px; text-transform: uppercase;
}
.sidebar .avatar { background: var(--brand-light); color: var(--brand-dark-deep); }
.user-chip__name { font-weight: 600; font-size: 13px; color: var(--text); line-height: 1.2; }
.user-chip__meta { font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 4px; }
.sidebar .user-chip__name { color: var(--sidebar-active-fg); }
.sidebar .user-chip__meta { color: var(--sidebar-fg-muted); }
.sidebar .status-dot { box-shadow: none; }
.sidebar .btn--ghost { --btn-fg: var(--sidebar-fg-muted); --btn-bg-hover: var(--sidebar-hover); }
.sidebar .btn--ghost:hover { --btn-fg: var(--sidebar-active-fg); }

.app-main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 30;
    height: var(--topbar-h);
    display: flex; align-items: center; gap: var(--sp-3);
    padding: 0 var(--sp-6);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--border);
    box-shadow: inset 0 -2px 0 var(--brand-light-soft);
}
.topbar__title { font-weight: 600; font-size: 15px; }
.topbar__spacer { flex: 1; }
.sidebar-toggle, .btn.sidebar-toggle { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 959px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.is-open { transform: none; }
    .sidebar-backdrop.is-open { display: block; position: fixed; inset: 0; z-index: 35; background: var(--overlay); }
    .app-main { margin-left: 0; }
    .sidebar-toggle, .btn.sidebar-toggle { display: inline-flex; }
    .topbar { padding: 0 var(--sp-4); }
}

.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 var(--sp-4); }
@media (min-width: 768px) { .container { padding: 0 var(--sp-6); } }
.page { padding-top: var(--sp-6); padding-bottom: var(--sp-10); }
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-6); }
.page-title { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; color: var(--text); }
.page-subtitle { margin-top: 2px; color: var(--text-2); }
.page-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); }

.app-footer { margin-top: auto; padding: var(--sp-5) var(--sp-6); font-size: 12px; color: var(--text-3); border-top: 1px solid var(--border); }

/* ---------- Superficies ---------- */
.card, .panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}
.card { padding: var(--sp-5); }
.card--flush { padding: 0; }
.card--hover { transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease); }
.card--hover:hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); }
.card__header {
    display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border);
}
.card > .card__header { margin: calc(var(--sp-5) * -1) calc(var(--sp-5) * -1) var(--sp-5); }
.card--flush > .card__header, .panel > .card__header { margin: 0; }
.card__title, .section-title { font-size: 15px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: var(--sp-2); }
.card__title .icon, .section-title .icon { color: var(--text-3); }
.card__subtitle { font-size: 13px; color: var(--text-3); }
.card__body { padding: var(--sp-5); }
.card__footer { padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.card > .card__footer { margin: var(--sp-5) calc(var(--sp-5) * -1) calc(var(--sp-5) * -1); }
.card--flush > .card__footer, .panel > .card__footer { margin: 0; } /* sin relleno: no hay que compensar */

/* ---------- KPIs ---------- */
.stats-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.stat {
    display: flex; align-items: flex-start; gap: var(--sp-4);
    padding: var(--sp-5); background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
}
.stat__body { min-width: 0; }
.stat__label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.stat__value { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; margin-top: 2px; font-variant-numeric: tabular-nums; color: var(--text); }
.stat__meta { font-size: 12px; color: var(--text-3); margin-top: var(--sp-1); display: flex; align-items: center; gap: 4px; }
.stat__meta--up { color: var(--success-text); }
.stat__meta--down { color: var(--danger-text); }
@media (max-width: 600px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
    .stat { align-items: center; gap: var(--sp-3); padding: var(--sp-3); }
    .stat .icon-tile { width: 32px; height: 32px; flex-shrink: 0; }
    .stat .icon-tile .icon { width: 16px; height: 16px; }
    .stat__label { font-size: 12px; }
    .stat__value { font-size: 20px; }
    .stat__meta { -webkit-line-clamp: 2; display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
    .stat__more { display: none; }
}

/* ---------- Botones ---------- */
.btn {
    --btn-bg: var(--surface); --btn-fg: var(--text); --btn-bd: var(--border-strong); --btn-bg-hover: var(--surface-2);
    position: relative;
    display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
    height: 38px; padding: 0 var(--sp-4);
    font-size: 14px; font-weight: 550; line-height: 1; white-space: nowrap;
    color: var(--btn-fg); background: var(--btn-bg);
    border: 1px solid var(--btn-bd); border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    cursor: pointer; text-decoration: none; user-select: none;
    transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn:hover { background: var(--btn-bg-hover); color: var(--btn-fg); }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn:disabled, .btn.is-disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn .icon { width: 16px; height: 16px; }

.btn--primary   { --btn-bg: var(--primary); --btn-fg: var(--on-primary); --btn-bd: var(--primary); --btn-bg-hover: var(--primary-hover); }
.btn--secondary { --btn-bg: var(--primary-soft); --btn-fg: var(--primary-text); --btn-bd: transparent; --btn-bg-hover: color-mix(in srgb, var(--primary-soft) 70%, var(--primary) 12%); box-shadow: none; }
.btn--ghost     { --btn-bg: transparent; --btn-fg: var(--text-2); --btn-bd: transparent; --btn-bg-hover: var(--surface-2); box-shadow: none; }
.btn--ghost:hover { --btn-fg: var(--text); }
.btn--danger    { --btn-bg: var(--danger); --btn-fg: #fff; --btn-bd: var(--danger); --btn-bg-hover: var(--danger-hover); }
.btn--danger-ghost { --btn-bg: transparent; --btn-fg: var(--danger-text); --btn-bd: transparent; --btn-bg-hover: var(--danger-soft); box-shadow: none; }
.btn--success   { --btn-bg: var(--success); --btn-fg: #fff; --btn-bd: var(--success); --btn-bg-hover: var(--success-text); }

.btn--sm { height: 32px; padding: 0 var(--sp-3); font-size: 13px; border-radius: var(--radius-sm); }
.btn--lg { height: 44px; padding: 0 var(--sp-5); font-size: 15px; }
.btn--icon { width: 38px; padding: 0; }
.btn--icon.btn--sm { width: 32px; }
.btn--block { display: flex; width: 100%; }

.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
    content: ''; position: absolute; inset: 0; margin: auto;
    width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid var(--btn-fg); border-right-color: transparent;
    animation: ui-spin 0.7s linear infinite;
}
.btn.is-loading > * { visibility: hidden; }

.btn-group { display: inline-flex; gap: var(--sp-2); flex-wrap: wrap; }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-4); }
.field__label, .label { font-size: 13px; font-weight: 550; color: var(--text); }
.field__hint { font-size: 12px; color: var(--text-3); }
.field__error { font-size: 12px; color: var(--danger-text); }

.input, .select, .textarea {
    width: 100%; min-height: 38px;
    padding: 8px var(--sp-3);
    font-size: 14px; color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong); border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-2); color: var(--text-3); cursor: not-allowed; }
.input.is-invalid { border-color: var(--danger); }
.input--sm { min-height: 32px; padding: 4px 10px; font-size: 13px; border-radius: var(--radius-sm); }
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.textarea.mono, .input.mono { font-family: var(--font-mono); font-size: 13px; }
.select {
    appearance: none; padding-right: 36px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2398a2b3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
input[type="file"].input { padding: 6px; }
input[type="file"].input::file-selector-button {
    margin-right: var(--sp-3); padding: 4px 10px; border: 0; border-radius: var(--radius-sm);
    background: var(--primary-soft); color: var(--primary-text); font-weight: 550; cursor: pointer;
}

.input-group { position: relative; display: flex; align-items: center; }
.input-group > .icon { position: absolute; left: 12px; color: var(--text-3); pointer-events: none; width: 16px; height: 16px; }
.input-group > .input { padding-left: 38px; }
.input-group > .input-group__action { position: absolute; right: 4px; }

.form-row { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.check { display: inline-flex; align-items: center; gap: var(--sp-2); cursor: pointer; font-size: 14px; color: var(--text-2); }
.check input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

.switch { display: inline-flex; align-items: center; gap: var(--sp-2); cursor: pointer; }
.switch input { appearance: none; width: 36px; height: 20px; border-radius: var(--radius-full); background: var(--border-strong); position: relative; cursor: pointer; transition: background var(--dur) var(--ease); }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-xs); transition: transform var(--dur) var(--ease); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(16px); }

/* ---------- Tablas ---------- */
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.card--flush > .table-wrap, .panel > .table-wrap { border: 0; border-radius: inherit; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
    padding: 10px var(--sp-4); text-align: left; white-space: nowrap;
    font-size: 12px; font-weight: 600; color: var(--text-2);
    background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.table td { padding: 12px var(--sp-4); border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--dur) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.is-selected { background: var(--primary-soft); }
.table--compact th, .table--compact td { padding: 8px var(--sp-3); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    height: 22px; padding: 0 8px; border-radius: var(--radius-full);
    font-size: 12px; font-weight: 550; white-space: nowrap;
    background: var(--surface-2); color: var(--text-2);
}
.badge .icon { width: 12px; height: 12px; }
.badge--primary { background: var(--primary-soft); color: var(--primary-text); }
.badge--success { background: var(--success-soft); color: var(--success-text); }
.badge--warning { background: var(--warning-soft); color: var(--warning-text); }
.badge--danger  { background: var(--danger-soft);  color: var(--danger-text); }
.badge--info    { background: var(--info-soft);    color: var(--info-text); }
.badge--neutral { background: var(--surface-2);    color: var(--text-2); }
.badge--outline { background: transparent; border: 1px solid var(--border-strong); }
.badge--dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex-shrink: 0; }
.status-dot--success { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.status-dot--warning { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }
.status-dot--danger  { background: var(--danger);  box-shadow: 0 0 0 3px var(--danger-soft); }

/* ---------- Alertas ---------- */
.alert {
    display: flex; align-items: flex-start; gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4); border-radius: var(--radius);
    border: 1px solid transparent; font-size: 14px;
    background: var(--surface-2); color: var(--text);
}
.alert > .icon { margin-top: 1px; }
.alert__title { font-weight: 600; }
.alert--success { background: var(--success-soft); color: var(--success-text); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.alert--warning { background: var(--warning-soft); color: var(--warning-text); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.alert--danger  { background: var(--danger-soft);  color: var(--danger-text);  border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert--info    { background: var(--info-soft);    color: var(--info-text);    border-color: color-mix(in srgb, var(--info) 25%, transparent); }

/* ---------- Tabs / segmented ---------- */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
    display: inline-flex; align-items: center; gap: var(--sp-2);
    padding: 10px var(--sp-3); margin-bottom: -1px;
    font-weight: 550; color: var(--text-2); white-space: nowrap;
    border-bottom: 2px solid transparent; cursor: pointer;
    transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--primary-text); border-bottom-color: var(--primary); }
.tab .icon { width: 16px; height: 16px; }

.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: var(--radius); }
.segmented > button, .segmented > a {
    display: inline-flex; align-items: center; gap: 6px;
    height: 30px; padding: 0 var(--sp-3); border-radius: 7px;
    font-size: 13px; font-weight: 550; color: var(--text-2);
}
.segmented > .is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }
.segmented .icon { width: 16px; height: 16px; }

/* ---------- Modal (<dialog>) ---------- */
.modal {
    width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
    padding: 0; margin: auto;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.modal--sm { width: min(420px, calc(100vw - 32px)); }
.modal--lg { width: min(880px, calc(100vw - 32px)); }
.modal--xl { width: min(1120px, calc(100vw - 32px)); }
.modal::backdrop { background: var(--overlay); backdrop-filter: blur(2px); }
.modal[open] { animation: ui-pop 160ms var(--ease); display: flex; flex-direction: column; }
.modal__header {
    display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, var(--brand-light-soft), var(--surface));
}
.modal__title { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.modal__title > .icon { color: var(--primary); }
.modal__title .icon-tile { width: 34px; height: 34px; }
.modal__subtitle { font-size: 13px; font-weight: 400; color: var(--text-3); }
.modal__body { padding: var(--sp-5); overflow-y: auto; flex: 1; }
.modal__body > p + p { margin-top: var(--sp-2); }
.modal__footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border); background: var(--surface-2); }
.modal__footer-start { margin-right: auto; display: flex; align-items: center; gap: var(--sp-2); }
@keyframes ui-pop { from { opacity: 0; transform: translateY(6px) scale(0.98); } }

/* Confirmación: icono centrado, sin cabecera */
.modal--confirm .modal__body { display: flex; gap: var(--sp-4); align-items: flex-start; padding: var(--sp-6) var(--sp-5) var(--sp-5); }
.modal--confirm .modal__title { font-size: 16px; margin-bottom: var(--sp-1); }
.modal--confirm .icon-tile { width: 40px; height: 40px; border-radius: var(--radius-full); }
.modal--confirm .modal__footer { background: var(--surface); border-top: 0; padding-top: 0; }

/* Drawer: panel lateral derecho para detalles largos */
.modal--drawer {
    width: min(480px, 100vw); height: 100vh; max-height: 100vh;
    margin: 0 0 0 auto; border-radius: 0; border-width: 0 0 0 1px;
}
.modal--drawer[open] { animation: ui-slide-in 200ms var(--ease); }
@keyframes ui-slide-in { from { transform: translateX(24px); opacity: 0; } }

/* Lista de detalles clave/valor (para modales de información) */
.detail-list { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.detail-list dt, .detail-list dd { padding: 10px var(--sp-4); border-bottom: 1px solid var(--border); }
.detail-list dt { display: flex; align-items: center; gap: var(--sp-2); font-size: 13px; font-weight: 550; color: var(--text-2); background: var(--surface-2); }
.detail-list dt .icon { width: 15px; height: 15px; color: var(--text-3); }
.detail-list dd { color: var(--text); overflow-wrap: anywhere; min-width: 0; }
.detail-list dt:nth-last-of-type(1), .detail-list dd:last-of-type { border-bottom: 0; }
@media (max-width: 480px) {
    .detail-list { grid-template-columns: 1fr; }
    .detail-list dt { border-bottom: 0; padding-bottom: 2px; }
}

/* Paleta de comandos (Ctrl/Cmd + K) */
.cmdk { width: min(620px, calc(100vw - 32px)); margin: 12vh auto auto; }
.cmdk .modal__body { padding: 0; }
.cmdk__input-wrap { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); }
.cmdk__input-wrap .icon { color: var(--primary); }
.cmdk__input { flex: 1; border: 0; background: none; font-size: 15px; padding: 6px 0; color: var(--text); }
.cmdk__input:focus { outline: none; }
.cmdk__list { max-height: min(420px, 55vh); overflow-y: auto; padding: var(--sp-2); }
.cmdk__group { padding: var(--sp-2) var(--sp-3) var(--sp-1); font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); }
.cmdk__item { display: flex; align-items: center; gap: var(--sp-3); width: 100%; padding: 9px var(--sp-3); border-radius: var(--radius-sm); color: var(--text); text-align: left; }
.cmdk__item .icon { color: var(--text-3); }
.cmdk__item.is-selected { background: var(--primary-soft); color: var(--primary-text); }
.cmdk__item.is-selected .icon { color: var(--primary); }
.cmdk__hint { margin-left: auto; font-size: 12px; color: var(--text-3); }
.cmdk__empty { padding: var(--sp-8) var(--sp-4); text-align: center; color: var(--text-3); }
.cmdk__footer { display: flex; gap: var(--sp-4); padding: var(--sp-2) var(--sp-4); border-top: 1px solid var(--border); background: var(--surface-2); font-size: 12px; color: var(--text-3); }

kbd, .kbd {
    display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px;
    font-family: var(--font-sans); font-size: 11px; font-weight: 600; line-height: 1; color: inherit;
    border: 1px solid currentColor; border-radius: 5px; opacity: 0.75;
}

/* Tarjetas/KPI que abren un modal con más información */
button.stat, a.stat { width: 100%; text-align: left; cursor: pointer; transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease); }
button.stat:hover, a.stat:hover { border-color: var(--brand-light); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
button.stat:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.stat__more { margin-left: auto; align-self: center; color: var(--text-3); transition: color var(--dur) var(--ease), transform var(--dur) var(--ease); }
button.stat:hover .stat__more, a.stat:hover .stat__more { color: var(--primary); transform: translateX(2px); }

/* ---------- Dropdown ---------- */
.dropdown { position: relative; display: inline-block; }
.dropdown__menu {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 50;
    min-width: 200px; padding: var(--sp-1);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    opacity: 0; visibility: hidden; transform: translateY(-4px);
    transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease), visibility var(--dur);
}
.dropdown__menu.is-open, .dropdown.is-open > .dropdown__menu { opacity: 1; visibility: visible; transform: none; }
.dropdown__item {
    display: flex; align-items: center; gap: var(--sp-2); width: 100%;
    padding: 8px 10px; border-radius: var(--radius-sm);
    font-size: 14px; color: var(--text); text-align: left;
}
.dropdown__item .icon { width: 16px; height: 16px; color: var(--text-3); }
.dropdown__item:hover { background: var(--surface-2); color: var(--text); }
.dropdown__item--danger, .dropdown__item--danger .icon { color: var(--danger-text); }
.dropdown__divider { height: 1px; margin: var(--sp-1) 0; background: var(--border); }

/* ---------- Toasts ---------- */
.toast-stack { position: fixed; right: var(--sp-4); bottom: var(--sp-4); z-index: 100; display: flex; flex-direction: column; gap: var(--sp-2); max-width: min(380px, calc(100vw - 32px)); }
.toast {
    display: flex; align-items: flex-start; gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); font-size: 14px;
    animation: ui-pop 160ms var(--ease);
}
.toast .icon { margin-top: 1px; }
.toast--success .icon { color: var(--success); }
.toast--danger  .icon { color: var(--danger); }
.toast--warning .icon { color: var(--warning); }
.toast--info    .icon { color: var(--info); }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: all 200ms var(--ease); }

/* ---------- Tooltips (data-tip, gestionados por ui.js) ---------- */
.tooltip {
    position: fixed; top: 0; left: 0; z-index: 110;
    max-width: min(280px, calc(100vw - 16px));
    padding: 6px 10px;
    background: var(--text); color: var(--surface);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
    font-size: 12.5px; font-weight: 500; line-height: 1.45;
    white-space: pre-line; overflow-wrap: anywhere;
    pointer-events: none;
    opacity: 0; transform: translateY(2px);
    transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.tooltip.is-open { opacity: 1; transform: none; }
.tooltip[data-side="bottom"] { transform: translateY(-2px); }
.tooltip[data-side="bottom"].is-open { transform: none; }
.tip-help {
    display: inline-flex; align-items: center; vertical-align: middle;
    margin-left: var(--sp-1); color: var(--text-3); cursor: help;
    border-radius: var(--radius-full);
}
.tip-help:hover, .tip-help:focus-visible { color: var(--primary); }
.tip-help .icon { width: 14px; height: 14px; }
th[data-tip], .stat__label[data-tip], .field__label[data-tip], .card__title[data-tip],
.section-title[data-tip], .page-title[data-tip], .badge[data-tip] { cursor: help; }

/* ---------- Vacío / carga ---------- */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--sp-2); padding: var(--sp-10) var(--sp-6); color: var(--text-2); }
.empty-state > .icon-tile { width: 48px; height: 48px; margin-bottom: var(--sp-2); }
.empty-state__title { font-size: 15px; font-weight: 600; color: var(--text); }
.empty-state p { max-width: 360px; font-size: 14px; }

.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: ui-spin 0.7s linear infinite; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: ui-shimmer 1.4s infinite; border-radius: var(--radius-sm); min-height: 12px; }
@keyframes ui-shimmer { to { background-position: -200% 0; } }

.progress { height: 6px; background: var(--surface-3); border-radius: var(--radius-full); overflow: hidden; }
.progress__bar { height: 100%; background: var(--primary); border-radius: inherit; transition: width 300ms var(--ease); }
.progress__bar--success { background: var(--success); }
.progress__bar--warning { background: var(--warning); }
.progress__bar--danger  { background: var(--danger); }

/* Loader global de acciones (UI.loader): barra indeterminada en el borde superior */
.page-loader {
    display: none; position: fixed; inset: 0 0 auto 0; z-index: 200;
    width: auto; height: 3px; margin: 0; padding: 0; border: 0;
    background: color-mix(in srgb, var(--primary) 18%, transparent);
    overflow: hidden; pointer-events: none;
}
.page-loader.is-active { display: block; }
.page-loader::before {
    content: ''; position: absolute; inset: 0 auto 0 0; width: 40%;
    background: var(--primary); border-radius: var(--radius-full);
    animation: ui-indeterminate 1.1s var(--ease) infinite;
}
@keyframes ui-indeterminate { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
textarea.is-loading, .input.is-loading { opacity: 0.6; cursor: progress; }
@media (prefers-reduced-motion: reduce) {
    .page-loader::before { animation: none; width: 100%; opacity: 0.7; }
}

/* ---------- Listas ---------- */
.list { display: flex; flex-direction: column; }
.list__item { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); }
.list__item:last-child { border-bottom: 0; }
.list__item:hover { background: var(--surface-2); }
.list__title { font-weight: 550; color: var(--text); }
.list__meta { font-size: 13px; color: var(--text-3); }

.code-block, .console {
    font-family: var(--font-mono); font-size: 13px; line-height: 1.6;
    background: var(--surface-2); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: var(--sp-3) var(--sp-4); overflow: auto; white-space: pre-wrap; word-break: break-word;
}
.console { background: #14233a; color: #dbe5f1; border-color: #14233a; }

/* ---------- Auth (login / registro) ---------- */
.auth-layout {
    min-height: 100vh; display: grid; place-items: center; padding: var(--sp-6) var(--sp-4);
    background:
        radial-gradient(ellipse 80% 50% at 50% -10%, var(--primary-soft), transparent 70%),
        var(--bg);
}
.auth-card { width: 100%; max-width: 400px; padding: var(--sp-8); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
@media (max-width: 480px) { .auth-card { padding: var(--sp-6) var(--sp-5); } }

/* ---------- Utilidades ---------- */
.flex { display: flex; } .inline-flex { display: inline-flex; } .grid { display: grid; }
.flex-col { flex-direction: column; } .flex-wrap { flex-wrap: wrap; } .flex-1 { flex: 1; min-width: 0; }
.items-center { align-items: center; } .items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; } .justify-end { justify-content: flex-end; } .justify-center { justify-content: center; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); } .gap-4 { gap: var(--sp-4); } .gap-6 { gap: var(--sp-6); }
.grid-2 { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.mt-1 { margin-top: var(--sp-1); } .mt-2 { margin-top: var(--sp-2); } .mt-4 { margin-top: var(--sp-4); } .mt-6 { margin-top: var(--sp-6); }
.mb-2 { margin-bottom: var(--sp-2); } .mb-4 { margin-bottom: var(--sp-4); } .mb-6 { margin-bottom: var(--sp-6); }
.w-full { width: 100%; }
.muted { color: var(--text-2); } .subtle { color: var(--text-3); }
.text-sm { font-size: 13px; } .text-xs { font-size: 12px; } .text-right { text-align: right; } .text-center { text-align: center; }
.font-medium { font-weight: 550; } .font-semibold { font-weight: 600; }
.text-success { color: var(--success-text); } .text-danger { color: var(--danger-text); } .text-warning { color: var(--warning-text); } .text-primary { color: var(--primary-text); }
.tabular { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.hidden, [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (max-width: 767px) { .hide-mobile { display: none !important; } }
@media (min-width: 768px) { .show-mobile { display: none !important; } }

/* ==========================================================================
   Notificaciones (campana del sidebar) · 2026-10-28
   ========================================================================== */
.sidebar__brand-row { display: flex; align-items: center; border-bottom: 1px solid var(--sidebar-border); padding-right: var(--sp-3); }
.sidebar__brand-row .sidebar__brand { flex: 1; border-bottom: 0; }
.sidebar__bell { position: relative; color: var(--sidebar-fg-muted); }
.sidebar__bell:hover, .sidebar__bell.has-unread { color: var(--sidebar-active-fg); }
.sidebar__bell-badge {
    position: absolute; top: 1px; right: 0; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
    background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}
.notif-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.notif-item {
    display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-3); border-radius: var(--radius-sm);
    border: 1px solid var(--border); color: inherit; text-decoration: none; background: var(--surface);
}
a.notif-item:hover { border-color: var(--primary); }
.notif-item.is-unread { border-left: 3px solid var(--primary); background: var(--primary-soft); }
.notif-item--danger.is-unread { border-left-color: var(--danger); }
.notif-item--warning.is-unread { border-left-color: var(--warning); }
.notif-item__title { font-weight: 600; font-size: 13px; }
.notif-item__text { font-size: 12.5px; color: var(--text-2); margin-top: 2px; white-space: pre-line; }
.notif-item__time { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }
.min-w-0 { min-width: 0; }

/* ==========================================================================
   Sexta tanda (2026-10-30): componentes de ui-overlays / ui-components / ui-command
   ========================================================================== */
html { scrollbar-gutter: stable; }
/* Con un modal abierto o el menú móvil desplegado, la página de fondo no se desplaza */
html:has(dialog.modal[open]), html.is-sidebar-open { overflow: hidden; }
main[tabindex="-1"]:focus { outline: none; }

/* Saltar al contenido (visible solo al enfocarlo con el teclado) */
.skip-link {
    position: fixed; top: var(--sp-2); left: var(--sp-2); z-index: 300;
    padding: var(--sp-2) var(--sp-4); border-radius: var(--radius);
    background: var(--primary); color: var(--on-primary); font-weight: 600;
    transform: translateY(-200%); transition: transform var(--dur) var(--ease);
}
.skip-link:focus { transform: none; color: var(--on-primary); }

/* Toasts: título, acción, contador de repetidos y cierre */
.toast { position: relative; padding-right: var(--sp-8); }
.toast__title { font-weight: 600; }
.toast__text { overflow-wrap: anywhere; }
.toast__action { margin-top: var(--sp-1); font-size: 13px; font-weight: 600; color: var(--primary-text); text-decoration: underline; }
.toast__count { font-size: 12px; font-weight: 600; color: var(--text-3); align-self: center; }
.toast__count:empty { display: none; }
.toast__close { position: absolute; top: 8px; right: 8px; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: var(--radius-sm); color: var(--text-3); }
.toast__close:hover { background: var(--surface-2); color: var(--text); }
.toast--danger { border-left: 3px solid var(--danger); }
.toast--warning { border-left: 3px solid var(--warning); }
.toast--success { border-left: 3px solid var(--success); }
@media (max-width: 600px) { .toast-stack { left: var(--sp-3); right: var(--sp-3); bottom: var(--sp-3); max-width: none; } }

/* Sidebar contraído en escritorio (data-ui="sidebar-collapse", tecla [) */
.sidebar__collapse { color: var(--sidebar-fg-muted); }
@media (min-width: 960px) {
    html[data-sidebar="collapsed"] { --sidebar-w: 68px; }
    html[data-sidebar="collapsed"] .sidebar__brand > span:not(.brand-mark),
    html[data-sidebar="collapsed"] .nav-item > span,
    html[data-sidebar="collapsed"] .nav-item > .icon--xs,
    html[data-sidebar="collapsed"] .sidebar__section,
    html[data-sidebar="collapsed"] .sidebar__search > span,
    html[data-sidebar="collapsed"] .sidebar__search > kbd,
    html[data-sidebar="collapsed"] .user-chip > .flex-1 { display: none; }
    html[data-sidebar="collapsed"] .sidebar__brand-row { flex-direction: column; padding: 0 0 var(--sp-2); }
    html[data-sidebar="collapsed"] .sidebar__brand { padding: 0; justify-content: center; }
    html[data-sidebar="collapsed"] .nav-item { justify-content: center; padding: 10px 0; }
    html[data-sidebar="collapsed"] .sidebar__nav { padding-inline: var(--sp-2); }
    html[data-sidebar="collapsed"] .sidebar__search { justify-content: center; padding: 8px 0; }
    html[data-sidebar="collapsed"] .user-chip { flex-direction: column; padding: 0; gap: var(--sp-1); }
    html[data-sidebar="collapsed"] .sidebar__collapse .icon { transform: scaleX(-1); }
    .sidebar, .app-main { transition: width 200ms var(--ease), margin-left 200ms var(--ease); }
}
@media (max-width: 959px) { .sidebar__collapse { display: none; } }

/* Migas de pan */
.breadcrumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1); list-style: none; padding: 0; font-size: 13px; color: var(--text-3); }
.breadcrumbs li { display: inline-flex; align-items: center; gap: var(--sp-1); min-width: 0; }
.breadcrumbs li + li::before { content: '/'; color: var(--border-strong); margin-right: var(--sp-1); }
.breadcrumbs a, .breadcrumbs span { display: inline-flex; align-items: center; gap: 4px; }
.breadcrumbs a { color: var(--text-2); }
.breadcrumbs a:hover { color: var(--primary); }
.breadcrumbs [aria-current="page"] { color: var(--text); font-weight: 550; }

/* Paginación */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); }
.pager__nav { display: flex; align-items: center; gap: var(--sp-1); }
.pager__num { min-width: 32px; height: 32px; padding: 0 var(--sp-2); border-radius: var(--radius-sm); font-size: 13px; font-weight: 550; color: var(--text-2); font-variant-numeric: tabular-nums; }
.pager__num:hover { background: var(--surface-2); color: var(--text); }
.pager__num.is-active { background: var(--primary-soft); color: var(--primary-text); }
.pager__gap { padding: 0 2px; color: var(--text-3); }
.pager__size { width: auto; min-height: 32px; }
@media (max-width: 600px) { .pager__num:not(.is-active), .pager__gap { display: none; } }

/* Tablas: ordenación, filas clicables y barra de filtro */
.ui-table__toolbar { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); }
.ui-table__toolbar .input-group { max-width: 320px; }
.ui-table .table-wrap { border: 0; border-radius: 0; }
.table th.is-sortable { cursor: pointer; user-select: none; }
.table th.is-sortable:hover { color: var(--text); }
.th-sort { display: inline-flex; align-items: center; gap: 4px; font: inherit; color: inherit; }
.th-sort .icon { color: var(--text-3); }
.table th[aria-sort="ascending"], .table th[aria-sort="descending"] { color: var(--primary-text); }
.table th[aria-sort="ascending"] .icon, .table th[aria-sort="descending"] .icon { color: var(--primary); }
th.num .th-sort { flex-direction: row-reverse; }
.table tr.is-clickable { cursor: pointer; }
.table tr.is-clickable:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }

/* Estados de carga */
.state-loading { display: flex; align-items: center; justify-content: center; gap: var(--sp-3); padding: var(--sp-8) var(--sp-4); }
.skeleton-block { display: grid; grid-template-columns: repeat(var(--sk-cols, 1), minmax(0, 1fr)); gap: var(--sp-3); padding: var(--sp-4); }
.skeleton-block .skeleton { height: 14px; }

/* Formularios: contador de caracteres */
.field__counter { font-size: 12px; color: var(--text-3); text-align: right; margin-top: 2px; font-variant-numeric: tabular-nums; }
.field__counter.is-near { color: var(--warning-text); }

/* Copiar al portapapeles */
.detail-list dd { position: relative; }
.detail-list__copy { float: right; margin: -6px -8px -6px var(--sp-2); }
[data-copy].is-copied, [data-copy-target].is-copied { color: var(--success-text); }

/* Paleta de comandos: coincidencias resaltadas y contador */
.cmdk__item { cursor: pointer; }
.cmdk__item mark { background: none; color: var(--primary-text); font-weight: 650; text-decoration: underline; text-decoration-color: var(--brand-light); text-underline-offset: 3px; }
.cmdk__count { margin-left: auto; }
.cmdk__footer { flex-wrap: wrap; }
@media (max-width: 600px) { .cmdk { margin-top: var(--sp-4); } .cmdk__footer > span:nth-child(3) { display: none; } }

/* Ayuda de atajos */
.shortcuts { display: grid; gap: var(--sp-5); grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.shortcuts__title { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); margin-bottom: var(--sp-2); }
.shortcuts__list { display: grid; grid-template-columns: max-content 1fr; gap: var(--sp-2) var(--sp-4); align-items: center; }
.shortcuts__list dd { color: var(--text-2); font-size: 13px; }
.kbd-group { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }

/* ---------- Encuadre: que el texto no se salga (ui-density.js) ---------- */
/* Los hijos de flex/grid pueden encogerse por debajo de su texto; las palabras largas (hosts, rutas, correos) se parten */
.card, .stat, .panel, .alert, .modal__body, .detail-list dd, .empty-state, .dropdown__item { overflow-wrap: break-word; }
.stat__body > *, .card__title, .alert > div { min-width: 0; }
.stat__label, .stat__meta { hyphens: auto; }
/* Badges: nunca más anchas que su caja; si no caben, el texto pasa a otra línea dentro de la píldora */
.badge { max-width: 100%; min-width: 0; height: auto; min-height: 22px; padding-block: 2px; line-height: 1.3; white-space: normal; overflow-wrap: break-word; }
.badge > .icon, .badge > .flag { flex-shrink: 0; }
/* Selects estrechos: puntos suspensivos en lugar de cortar la palabra */
.select { text-overflow: ellipsis; white-space: nowrap; overflow: hidden; min-width: 0; }
.truncate { min-width: 0; }

/* Dropdown que se abre hacia arriba / hacia la derecha cuando no cabe */
.dropdown__menu--up { top: auto; bottom: calc(100% + 6px); }
.dropdown__menu--start { right: auto; left: 0; }
.dropdown__menu { max-width: min(360px, calc(100vw - 24px)); }
.dropdown__item { min-width: 0; }

/* Chips con "+N": el resto se despliega en un menú */
.chips-more { display: inline-flex; }
.chips-more__btn { cursor: pointer; }
.chips-more__btn:hover { border-color: var(--primary); color: var(--primary-text); }
.chips-more__menu { display: flex; flex-wrap: wrap; gap: var(--sp-1); padding: var(--sp-2); min-width: 160px; max-width: 280px; left: 0; right: auto; }

/* Secciones desplegables recordadas: [data-collapse] > [data-collapse-toggle] + [data-collapse-body] */
.collapse__toggle { display: inline-flex; align-items: center; gap: var(--sp-2); min-width: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; border-radius: var(--radius-sm); }
.collapse__toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.collapse__chevron { color: var(--text-3); transition: transform var(--dur) var(--ease); flex-shrink: 0; }
.is-collapsed .collapse__chevron { transform: rotate(-90deg); }
.collapse__toggle:hover .collapse__chevron { color: var(--text); }
.collapse__count { margin-left: var(--sp-1); }

/* Pestañas declarativas ([data-tabs]) */
[data-tabs] > .tabs { margin-bottom: var(--sp-4); scrollbar-width: none; }
[data-tabs] > .tabs::-webkit-scrollbar { display: none; }
.tab { white-space: nowrap; flex-shrink: 0; }
/* "Más" al final de una barra de pestañas que no cabe (ui-density.js): fijo a la derecha con un fundido */
.tabs-more { position: sticky; right: 0; z-index: 20; margin-left: auto; flex-shrink: 0; display: flex; background: var(--surface); }
.tabs-more::before { content: ''; position: absolute; right: 100%; top: 0; bottom: 0; width: 28px; pointer-events: none; background: linear-gradient(to right, transparent, var(--surface)); }
.tabs-more__btn { display: inline-flex; align-items: center; gap: var(--sp-1); padding: 10px var(--sp-3); margin-bottom: -1px; font-weight: 550; color: var(--text-2); white-space: nowrap; border-bottom: 2px solid transparent; }
.tabs-more__btn:hover, .tabs-more.is-open .tabs-more__btn { color: var(--primary-text); }
.dropdown__menu.dropdown__menu--fixed { position: fixed; z-index: 120; max-height: min(420px, 70vh); overflow-y: auto; }
.dropdown__item.is-active { background: var(--primary-soft); color: var(--primary-text); font-weight: 550; }
.dropdown__item.is-active .icon { color: var(--primary); }
.tabs-more__check { margin-left: auto; }
.tab__count { margin-left: 2px; }

/* Banderas de país (SVG locales en /public/assets/flags, flag-icons MIT) */
.flag { display: inline-block; width: 20px; height: 15px; flex-shrink: 0; border-radius: 2px; object-fit: cover; vertical-align: -2px; box-shadow: 0 0 0 1px var(--border); background: var(--surface-2); }
.flag--code { width: auto; height: auto; padding: 0 3px; font-size: 10px; font-weight: 650; line-height: 15px; color: var(--text-2); }
.place { display: inline-flex; align-items: center; gap: var(--sp-2); min-width: 0; }

/* Tablas apiladas en móvil: cada fila es una ficha "etiqueta: valor" (etiquetas puestas por ui-density.js) */
@media (max-width: 640px) {
    .table.table--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .table.table--stack, .table.table--stack tbody, .table.table--stack tr, .table.table--stack td { display: block; width: 100%; }
    .table.table--stack tr { padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--border); }
    .table.table--stack tbody tr:last-child { border-bottom: 0; }
    .table.table--stack td { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: 5px 0; border: 0; text-align: right; min-width: 0; overflow-wrap: anywhere; }
    .table.table--stack td[data-label]::before { content: attr(data-label); flex-shrink: 0; max-width: 45%; font-size: 12px; font-weight: 550; color: var(--text-3); text-align: left; }
    .table.table--stack td:not([data-label]) { justify-content: flex-start; text-align: left; }
    .table.table--stack td.actions, .table.table--stack td:last-child:empty { justify-content: flex-end; }
    .table.table--stack td > * { min-width: 0; }
    .table.table--stack td.truncate, .table.table--stack td .truncate { white-space: normal; }
    .table.table--stack .hide-mobile { display: none; }
    .table-wrap:has(> .table--stack) { overflow-x: visible; }
}

/* Impresión: sin navegación ni avisos */
@media print {
    .sidebar, .sidebar-backdrop, .topbar, .toast-stack, .page-loader, .skip-link, .page-actions, .tooltip { display: none !important; }
    .app-main { margin-left: 0 !important; }
    body { background: #fff; }
    .card, .stat { box-shadow: none; break-inside: avoid; }
}
