/* ═══════════════════════════════════════════════════════════════
   WINLEDGER CLS — app.css v2.0 CLEAN
   ═══════════════════════════════════════════════════════════════ */

/* ── Variables: OSCURO (default) ────────────────────────────── */
:root,
html.theme-dark {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #21262d;
    --surface-3: #2d333b;
    --border: #30363d;
    --border-2: #444c56;
    --accent: #0078D4;
    --accent-h: #005a9e;
    --accent-soft: rgba(0,120,212,0.12);
    --text: #cdd9e5;
    --text-muted: #768390;
    --text-faint: #4d5566;
    --green: #2ea043;
    --green-soft: rgba(46,160,67,0.15);
    --amber: #d29922;
    --amber-soft: rgba(210,153,34,0.15);
    --red: #da3633;
    --red-soft: rgba(218,54,51,0.15);
    --blue-soft: rgba(0,120,212,0.15);
    --gray-soft: rgba(120,131,144,0.15);
    --shadow: 0 4px 24px rgba(0,0,0,0.45);
}

/* ── Variables: CLARO ──────────────────────────────────────── */
html.theme-light {
    --bg: #f3f4f6;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --surface-3: #e4e7ec;
    --border: #d1d5db;
    --border-2: #9ca3af;
    --accent: #0078D4;
    --accent-h: #005a9e;
    --accent-soft: rgba(0,120,212,0.10);
    --text: #111827;
    --text-muted: #6b7280;
    --text-faint: #9ca3af;
    --green: #16a34a;
    --green-soft: rgba(22,163,74,0.12);
    --amber: #d97706;
    --amber-soft: rgba(217,119,6,0.12);
    --red: #dc2626;
    --red-soft: rgba(220,38,38,0.12);
    --blue-soft: rgba(0,120,212,0.10);
    --gray-soft: rgba(107,114,128,0.12);
    --shadow: 0 4px 24px rgba(0,0,0,0.10);
}

/* ── Tokens base ────────────────────────────────────────────── */
:root {
    --radius: 8px;
    --radius-lg: 12px;
    --topbar-h: 52px;
    --sidebar-w-expanded: 230px;
    --sidebar-w-collapsed: 48px;
    --sidebar-transition: width 0.22s cubic-bezier(0.4,0,0.2,1);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'Consolas', 'Cascadia Code', monospace;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background 0.25s, color 0.25s;
}

a {
    color: var(--accent);
    text-decoration: none;
}

    a:hover {
        text-decoration: underline;
    }

/* ═══════════════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════════════ */
.layout-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w-expanded);
    min-width: var(--sidebar-w-expanded);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    transition: var(--sidebar-transition), background 0.25s, border-color 0.25s;
}

.sidebar-collapsed .sidebar {
    width: var(--sidebar-w-collapsed);
    min-width: var(--sidebar-w-collapsed);
}

/* ── Sidebar brand ──────────────────────────────────────────── */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    overflow: hidden;
    white-space: nowrap;
    min-height: 52px;
    flex-shrink: 0;
    user-select: none;
    transition: background 0.15s;
}

    .sidebar-brand:hover {
        background: var(--surface-2);
    }

/* Favicon — siempre del mismo tamaño */
.brand-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex-shrink: 0;
    display: none; /* oculto cuando expandido */
}

/* Logo completo */
.brand-logo {
    height: 30px;
    max-width: 150px;
    object-fit: contain;
    flex: 1;
    min-width: 0;
    display: block; /* visible cuando expandido */
}

/* Modo claro: logo de color, sin blend */
/* Modo claro: logo con colores */
html.theme-light .brand-logo {
    content: url('/images/logo-color.png');
}

/* Toggle « » */
.brand-toggle {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-faint);
    flex-shrink: 0;
    margin-left: auto;
    font-family: monospace;
}

/* Colapsado: favicon centrado, logo y toggle ocultos */
.sidebar-collapsed .brand-icon {
    display: block;
}

.sidebar-collapsed .brand-logo {
    display: none;
}

.sidebar-collapsed .brand-toggle {
    display: none;
}

.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding: 12px 0;
}

/* ── Nav links ──────────────────────────────────────────────── */
.nav-links {
    padding: 8px 6px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-decoration: none;
    position: relative;
    transition: background 0.12s, color 0.12s;
}

    .nav-link:hover {
        background: var(--surface-2);
        color: var(--text);
        text-decoration: none;
    }

    .nav-link.active {
        background: var(--accent-soft);
        color: var(--accent);
    }

.nav-icon {
    flex-shrink: 0;
    width: 24px;
    text-align: center;
    font-size: 16px;
}

.nav-icon-svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.nav-section-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--text-faint);
    padding: 10px 12px 3px;
}

.nav-label {
    overflow: hidden;
    white-space: nowrap;
}

/* Colapsado: solo iconos centrados */
.sidebar-collapsed .nav-links {
    overflow: visible;
}

.sidebar-collapsed .nav-link {
    justify-content: center;
    padding: 10px 0;
    overflow: visible;
}

.sidebar-collapsed .nav-label {
    display: none;
}

/* ── Section labels ─────────────────────────────────────────── */
.nav-section-label {
    display: flex;
    align-items: center;
    padding: 10px 10px 3px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-faint);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-collapsed .nav-section-label {
    padding: 8px 0;
    justify-content: center;
}

    .sidebar-collapsed .nav-section-label span {
        display: none;
    }

    .sidebar-collapsed .nav-section-label::after {
        content: '';
        display: block;
        width: 20px;
        height: 1px;
        background: var(--border);
    }

/* ── Nav footer ─────────────────────────────────────────────── */
.nav-footer {
    padding: 12px 10px;
    border-top: 1px solid var(--border);
    overflow: hidden;
}

.nav-version {
    font-size: 11px;
    color: var(--text-faint);
    white-space: nowrap;
}

.sidebar-collapsed .nav-footer {
    padding: 12px 0;
    text-align: center;
}

.sidebar-collapsed .nav-version {
    display: none;
}

/* ── Tooltip estilizado (solo en colapsado desktop) ─────────── */
.nav-tooltip {
    display: none;
}

.sidebar-collapsed .nav-link .nav-tooltip {
    display: block;
    position: fixed;
    left: calc(var(--sidebar-w-collapsed) + 12px);
    background: var(--surface-3);
    color: var(--text);
    font-size: 12.5px;
    font-weight: 500;
    padding: 7px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border-2);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.35);
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 9999;
    transform: translateX(-8px);
}

    .sidebar-collapsed .nav-link .nav-tooltip::before {
        content: '';
        position: absolute;
        left: -6px;
        top: 50%;
        transform: translateY(-50%);
        border: 6px solid transparent;
        border-left: 0;
        border-right-color: var(--border-2);
    }

    .sidebar-collapsed .nav-link .nav-tooltip::after {
        content: '';
        position: absolute;
        left: -4px;
        top: 50%;
        transform: translateY(-50%);
        border: 5px solid transparent;
        border-left: 0;
        border-right-color: var(--surface-3);
    }

.sidebar-collapsed .nav-link:hover .nav-tooltip {
    opacity: 1;
    transform: translateX(0);
}

.sidebar-expanded .nav-tooltip {
    display: none !important;
}

/* ── Botones de sidebar ─────────────────────────────────────── */
.sidebar-close {
    display: none !important;
}

.hamburger {
    display: none !important;
}

/* ── Main content ───────────────────────────────────────────── */
.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-h);
    min-height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    transition: background 0.25s, border-color 0.25s;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.topbar-user {
    font-size: 13px;
    color: var(--text-muted);
}

.theme-toggle {
    font-size: 16px !important;
    width: 32px !important;
    height: 32px !important;
}

.btn-logout {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius);
    padding: 5px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
    font-family: var(--font);
}

    .btn-logout:hover {
        border-color: var(--border-2);
        color: var(--text);
    }

/* ── Page body ──────────────────────────────────────────────── */
.page-body {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px;
}

/* ── Overlay móvil ──────────────────────────────────────────── */
.sidebar-overlay {
    display: none;
}

/* ═══════════════════════════════════════════════════════════════
   COMPONENTES
   ═══════════════════════════════════════════════════════════════ */

/* ── Page header ────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
}

.page-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}

.page-subtitle {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 3px;
}

/* ── Cards ──────────────────────────────────────────────────── */
.section-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    transition: background 0.25s, border-color 0.25s;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

/* ── Stats ──────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: background 0.25s, border-color 0.25s;
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.stat-blue {
    background: var(--blue-soft);
    color: var(--accent);
}

.stat-green {
    background: var(--green-soft);
    color: var(--green);
}

.stat-amber {
    background: var(--amber-soft);
    color: var(--amber);
}

.stat-red {
    background: var(--red-soft);
    color: var(--red);
}

.stat-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── Table ──────────────────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

    .data-table th {
        text-align: left;
        padding: 10px 14px;
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.6px;
        color: var(--text-muted);
        border-bottom: 1px solid var(--border);
    }

    .data-table td {
        padding: 11px 14px;
        border-bottom: 1px solid var(--border);
        vertical-align: middle;
    }

    .data-table tbody tr:hover td {
        background: var(--surface-2);
    }

    .data-table tbody tr:last-child td {
        border-bottom: none;
    }

.row-revocada td {
    opacity: 0.5;
}

.table-info {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.actions-cell {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.form-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text);
}

.form-input {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font);
    font-size: 13.5px;
    padding: 9px 12px;
    width: 100%;
    outline: none;
    appearance: none;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.25s;
}

    .form-input:focus {
        border-color: var(--accent);
        box-shadow: 0 0 0 3px rgba(0,120,212,0.15);
    }

    .form-input::placeholder {
        color: var(--text-faint);
    }

    .form-input[type="date"]::-webkit-calendar-picker-indicator {
        filter: invert(0.6);
        cursor: pointer;
    }

html.theme-light .form-input[type="date"]::-webkit-calendar-picker-indicator {
    filter: none;
}

textarea.form-input {
    resize: vertical;
    min-height: 70px;
}

.form-hint {
    font-size: 11.5px;
    color: var(--text-muted);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.validation-msg {
    font-size: 11.5px;
    color: var(--red);
    margin-top: 2px;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 9px 18px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s;
    font-family: var(--font);
}

    .btn-primary:hover {
        background: var(--accent-h);
        text-decoration: none;
        color: #fff;
    }

    .btn-primary:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 9px 18px;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    font-family: var(--font);
}

    .btn-ghost:hover {
        background: var(--surface-2);
        color: var(--text);
        border-color: var(--border-2);
        text-decoration: none;
    }

.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--red);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 9px 18px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
    font-family: var(--font);
}

    .btn-danger:hover {
        opacity: 0.85;
    }

.btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    width: 30px;
    height: 30px;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s, color 0.12s;
    text-decoration: none;
}

    .btn-icon:hover {
        background: var(--surface-2);
        color: var(--text);
        border-color: var(--border-2);
        text-decoration: none;
    }

.btn-danger-icon:hover {
    background: var(--red-soft);
    color: var(--red);
    border-color: var(--red);
}

.btn-copy {
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    padding: 5px 12px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.12s, color 0.12s;
    font-family: var(--font);
}

    .btn-copy:hover {
        background: var(--border);
        color: var(--text);
    }

.btn-chip {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-muted);
    padding: 3px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    font-family: var(--font);
}

    .btn-chip:hover {
        background: var(--accent-soft);
        color: var(--accent);
        border-color: var(--accent);
    }

.w-full {
    width: 100%;
}

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-green {
    background: var(--green-soft);
    color: #3fb950;
}

.badge-amber {
    background: var(--amber-soft);
    color: #e3b341;
}

.badge-red {
    background: var(--red-soft);
    color: #f85149;
}

.badge-blue {
    background: var(--blue-soft);
    color: #79c0ff;
}

.badge-gray {
    background: var(--gray-soft);
    color: var(--text-muted);
}

html.theme-light .badge-green {
    color: #16a34a;
}

html.theme-light .badge-amber {
    color: #d97706;
}

html.theme-light .badge-red {
    color: #dc2626;
}

html.theme-light .badge-blue {
    color: #0078D4;
}

/* ── Modals ─────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(1,4,9,0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
    padding: 20px;
}

html.theme-light .modal-overlay {
    background: rgba(0,0,0,0.45);
}

.modal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.modal-sm {
    max-width: 380px;
}

.modal-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 18px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* ── Alerts ─────────────────────────────────────────────────── */
.alert-error {
    background: var(--red-soft);
    border: 1px solid rgba(218,54,51,0.3);
    border-radius: var(--radius);
    color: #f85149;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 12px;
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.alert-success {
    background: var(--green-soft);
    border: 1px solid rgba(46,160,67,0.3);
    border-radius: var(--radius);
    color: #3fb950;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 12px;
}

/* ── Error boundary ─────────────────────────────────────────── */
.error-boundary-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 48px 32px;
    text-align: center;
    max-width: 500px;
    margin: 40px auto;
}

.error-boundary-icon {
    font-size: 48px;
    margin-bottom: 16px;
    color: var(--amber);
}

.error-boundary-panel h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.error-boundary-panel p {
    color: var(--text-muted);
    margin-bottom: 20px;
    font-size: 13px;
}

/* ── Reconnect modal ────────────────────────────────────────── */
.reconnect-overlay {
    position: fixed;
    inset: 0;
    background: rgba(1,4,9,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.reconnect-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 48px;
    text-align: center;
    box-shadow: var(--shadow);
    max-width: 360px;
    width: 100%;
}

    .reconnect-card h3 {
        font-size: 17px;
        font-weight: 600;
        color: var(--text);
        margin: 16px 0 8px;
    }

    .reconnect-card p {
        font-size: 13px;
        color: var(--text-muted);
        margin-bottom: 20px;
    }

.reconnect-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto;
    border: 3px solid var(--border-2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: wl-spin 0.9s linear infinite;
}

@keyframes wl-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── 404 ────────────────────────────────────────────────────── */
.not-found {
    text-align: center;
    padding: 80px 20px;
}

.not-found-code {
    font-size: 72px;
    font-weight: 800;
    color: var(--border-2);
    line-height: 1;
    margin-bottom: 16px;
}

.not-found h2 {
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.not-found p {
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* ── Login ──────────────────────────────────────────────────── */
.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 20px;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 42px 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.45);
}

.login-brand {
    margin-bottom: 6px;
}

.login-logo {
    height: 34px;
    max-width: 180px;
    object-fit: contain;
}

html.theme-light .login-logo {
    content: url('/images/logo-color.png');
}

.login-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin: 16px 0 4px;
}

.login-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* ── Licencias / HW ID ──────────────────────────────────────── */
.hw-id {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 7px;
    color: #79c0ff;
    letter-spacing: 1.2px;
}

html.theme-light .hw-id {
    color: var(--accent);
}

.hw-input {
    font-family: var(--font-mono) !important;
    letter-spacing: 2px;
}

/* ── Key display ────────────────────────────────────────────── */
.key-display {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

    .key-display code {
        font-family: var(--font-mono);
        font-size: 11px;
        color: #79c0ff;
        word-break: break-all;
        line-height: 1.7;
        flex: 1;
    }

html.theme-light .key-display code {
    color: var(--accent);
}

.key-display-label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

/* ── Generar licencia ───────────────────────────────────────── */
.gen-layout {
    display: grid;
    grid-template-columns: 1fr 420px;
    gap: 24px;
    align-items: start;
}

.gen-result-panel {
    position: sticky;
    top: 0;
}

.result-placeholder {
    background: var(--surface);
    border: 1px dashed var(--border-2);
    border-radius: var(--radius-lg);
    padding: 48px 24px;
    text-align: center;
    color: var(--text-muted);
}

.result-placeholder-icon {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.4;
}

.result-detail {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    gap: 12px;
}

    .detail-row:last-child {
        border-bottom: none;
    }

.detail-label {
    font-size: 11.5px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ── Filters ────────────────────────────────────────────────── */
.filters-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 16px;
}

.quick-dates {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

/* ── Modules ────────────────────────────────────────────────── */
.modules-grid {
    display: grid;
    grid-template-columns: repeat(3,1fr);
    gap: 8px;
}

.module-check {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    padding: 7px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.12s;
}

    .module-check:hover {
        border-color: var(--accent);
    }

    .module-check input[type="checkbox"] {
        width: 15px;
        height: 15px;
        accent-color: var(--accent);
        cursor: pointer;
    }

/* ── Misc ───────────────────────────────────────────────────── */
.text-muted {
    color: var(--text-muted);
}

.text-amber {
    color: var(--amber);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    font-size: 13.5px;
}

.loading-spinner {
    text-align: center;
    color: var(--text-muted);
    padding: 32px;
    font-size: 13.5px;
}

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-2);
    border-radius: 3px;
}

    ::-webkit-scrollbar-thumb:hover {
        background: var(--text-faint);
    }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

/* ── Tablet / Móvil: sidebar como drawer ────────────────────── */
@media (max-width: 1024px) {
    .hamburger {
        display: flex !important;
    }

    .sidebar-close {
        display: flex !important;
        position: absolute;
        top: 12px;
        right: 12px;
        z-index: 10;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: var(--sidebar-w-expanded) !important;
        min-width: var(--sidebar-w-expanded) !important;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
        box-shadow: 4px 0 24px rgba(0,0,0,0.35);
        overflow: hidden;
    }

    .sidebar-mobile-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.55);
        z-index: 199;
        backdrop-filter: blur(2px);
    }

    .sidebar-mobile-open .sidebar-overlay {
        display: block;
    }

    /* En drawer siempre mostrar todo aunque estado sea collapsed */
    .sidebar-collapsed .nav-label {
        display: block !important;
    }

    .sidebar-collapsed .nav-link {
        justify-content: flex-start !important;
        padding: 8px 10px !important;
        overflow: hidden !important;
    }

    .sidebar-collapsed .brand-logo {
        display: block !important;
    }

    .sidebar-collapsed .brand-icon {
        display: none !important;
    }

    .sidebar-collapsed .brand-toggle {
        display: block !important;
    }

    .sidebar-collapsed .sidebar-brand {
        justify-content: flex-start !important;
        padding: 12px 10px !important;
    }

    .sidebar-collapsed .nav-section-label::after {
        display: none !important;
    }

    .sidebar-collapsed .nav-section-label .nav-label {
        display: block !important;
    }

    .sidebar-collapsed .nav-version {
        display: block !important;
    }

    .nav-tooltip {
        display: none !important;
    }

    .stats-grid {
        grid-template-columns: repeat(2,1fr);
    }

    .gen-layout {
        grid-template-columns: 1fr;
    }

    .topbar-user-hide {
        display: none;
    }
}

/* ── Móvil ──────────────────────────────────────────────────── */
@media (max-width: 767px) {
    .page-body {
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .stat-card {
        padding: 14px;
        gap: 10px;
    }

    .stat-value {
        font-size: 22px;
    }

    .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 15px;
    }

    .section-card {
        padding: 14px;
        overflow-x: auto;
    }

    .data-table {
        min-width: 580px;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .modal-card {
        max-width: 100%;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        max-height: 92vh;
        padding: 24px 20px;
    }

    .modal-sm {
        max-width: 100%;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

        .page-header .btn-primary {
            width: 100%;
            justify-content: center;
        }

    .filters-bar {
        flex-direction: column;
        gap: 8px;
    }

        .filters-bar .form-input {
            width: 100% !important;
            max-width: 100% !important;
        }

    .topbar {
        padding: 0 14px;
    }

    .topbar-title {
        font-size: 13px;
    }

    .login-card {
        padding: 32px 24px;
    }

    .gen-result-panel {
        position: static;
    }

    .gen-layout {
        gap: 16px;
    }

    .actions-cell {
        gap: 4px;
    }
}

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

    .page-body {
        padding: 12px;
    }
}

/* ── Touch targets ──────────────────────────────────────────── */
@media (hover: none) and (pointer: coarse) {
    .btn-icon {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }

    .nav-link {
        padding: 11px 12px;
    }

    .form-input {
        padding: 11px 12px;
        font-size: 15px;
    }

    .btn-primary, .btn-ghost, .btn-danger {
        padding: 11px 18px;
        font-size: 14px;
    }

    .data-table td {
        padding: 13px 14px;
    }
}

/* ── Modal: permitir que el dropdown salga ───────────────────── */
/* overflow-y:auto atrapa el dropdown — lo cambiamos a visible   */
/* El scroll del contenido lo maneja el propio modal-card        */

/* ═══════════════════════════════════════════════════════════════
   SELECT NATIVO MEJORADO — pegar al final de app.css
   Misma apariencia que form-input pero con flecha personalizada
   ═══════════════════════════════════════════════════════════════ */

/* ── Select nativo mejorado ─────────────────────────────────── */
select.form-input {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23768390' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

html.theme-light select.form-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

select.form-input:focus  { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,120,212,0.15); outline: none; }
select.form-input:disabled { opacity: 0.45; cursor: not-allowed; }
select.form-input option { background: var(--surface-2); color: var(--text); padding: 6px 12px; }

/* ── Select expandido inline (size > 1) — siempre hacia abajo ── */
/* Cuando size > 1 el browser muestra lista inline, no popup      */
.select-wrap {
    position: relative;
    width: 100%;
}

/* select[size>1]: quitar flecha y mostrar como lista */
.select-down[size]:not([size="1"]) {
    appearance: auto;              /* lista nativa del browser */
    -webkit-appearance: auto;
    background-image: none;        /* sin flecha */
    padding-right: 12px;
    height: auto;
    overflow-y: auto;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0,120,212,0.15);
    border-radius: var(--radius);
    position: absolute;            /* sale del flujo — no empuja los campos de abajo */
    top: 0;
    left: 0;
    right: 0;
    z-index: 500;
    background: var(--surface);
    max-height: 220px;
}

.select-down[size="1"] {
    position: static;
}
 
/* ── Input number — quitar flechas spinner ──────────────────── */
input[type="number"] {
  -moz-appearance: textfield;   /* Firefox */
  appearance: textfield;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ═══════════════════════════════════════════════════════════════
   MODAL GRANDE — para contratos con sistemas
   ═══════════════════════════════════════════════════════════════ */
.modal-lg {
  max-width: 720px;
}

/* ── Input pequeño para config de sistemas ──────────────────── */
.form-input-sm {
  padding:    6px 10px;
  font-size:  12.5px;
}

/* ═══════════════════════════════════════════════════════════════
   SISTEMAS LICENCIADOS — grid de filas seleccionables
   ═══════════════════════════════════════════════════════════════ */
.sistemas-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.sistema-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s;
}

.sistema-row--active {
  border-color: var(--accent);
}

.sistema-row__header {
  padding: 10px 14px;
  background: var(--surface-2);
}

.sistema-check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text);
  user-select: none;
}

.sistema-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.sistema-row__config {
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

@media (max-width: 600px) {
  .sistema-row__config {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── Blazor EditForm — quitar estilos por defecto ────────────── */
.valid.modified { outline: none; }
.invalid        { border-color: var(--red) !important; }

/* ═══════════════════════════════════════════════════════════════
   DETALLE CONTRATO — Tarjetas de licenciamiento
   ═══════════════════════════════════════════════════════════════ */
.lic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 4px;
}

.lic-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border-color 0.15s;
}
.lic-card:hover { border-color: var(--border-2); }

.lic-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  gap: 10px;
}

.lic-card__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  overflow: hidden;
}

.lic-card__title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lic-card__body {
  padding: 14px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lic-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.lic-stat:last-of-type { border-bottom: none; }

.lic-stat__label { color: var(--text-muted); font-size: 12px; }
.lic-stat__value { font-weight: 500; display: flex; align-items: center; gap: 6px; }

.lic-card__footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.lic-card__footer .btn-primary {
  flex: 1;
  text-align: center;
}

/* ═══════════════════════════════════════════════════════════════
   TIPOS LICENCIA — Reglas
   ═══════════════════════════════════════════════════════════════ */
.reglas-base-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.reglas-extra-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}

.regla-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.regla-card--base {
  border-left: 3px solid var(--accent);
}

.regla-card__clave {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.regla-card__valor {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

.reglas-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.reglas-section__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

.regla-extra-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

/* ── SvgIcon (Bootstrap Icons) ──────────────────────────────────────────── */
.svg-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  flex-shrink: 0;
  pointer-events: none;
  line-height: 1;
}

/* ═══════════════════════════════════════════════════════════════
   ALERT BANNER — Dashboard
   ═══════════════════════════════════════════════════════════════ */
.alert-banner {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alert-banner__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  border: 1px solid;
}

.alert-banner--amber {
  background: var(--amber-soft);
  border-color: rgba(210,153,34,0.35);
  color: var(--amber);
}

.alert-banner--red {
  background: var(--red-soft);
  border-color: rgba(218,54,51,0.35);
  color: #f85149;
}

.alert-banner__item span { flex: 1; color: var(--text); }
.alert-banner__item strong { color: inherit; }

.alert-banner__link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: inherit;
  white-space: nowrap;
  text-decoration: none;
  opacity: 0.9;
}
.alert-banner__link:hover { opacity: 1; text-decoration: underline; }

/* Fila urgente en tabla de renovaciones */
.row-urgente td { background: rgba(218,54,51,0.04); }
.row-urgente:hover td { background: rgba(218,54,51,0.08) !important; }

/* Botón refresh en Renovaciones */
.btn-refresh {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  font-family: var(--font);
}
.btn-refresh:hover { background: var(--accent-h); }

/* ═══════════════════════════════════════════════════════════════
   PAGINADOR
   ═══════════════════════════════════════════════════════════════ */
.paginador {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 4px;
  flex-wrap: wrap;
}

.paginador__info {
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.paginador__controles {
  display: flex;
  align-items: center;
  gap: 3px;
}

.paginador__btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  font-family: var(--font);
}

.paginador__btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-2);
}

.paginador__btn--active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}

.paginador__ellipsis {
  padding: 0 4px;
  color: var(--text-faint);
  font-size: 13px;
  user-select: none;
}

.paginador__size {
  width: 130px !important;
  font-size: 12.5px;
  padding: 6px 10px;
}

/* ═══════════════════════════════════════════════════════════════
   ROLES — Chips de permisos
   ═══════════════════════════════════════════════════════════════ */
.permiso-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 12px;
}

.permiso-chip__modulo {
  font-weight: 600;
  color: var(--accent);
}

.permiso-chip__acciones {
  color: var(--text-muted);
}
