/* ============================================================
   ISP MANAGER — Design System v3
   Fuentes: Syne (títulos) + Inter (body) + JetBrains Mono
   Tema: Light con color real, sidebar índigo intenso
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@700;800&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --brand:         #0284c7;
    --brand-light:   #38bdf8;
    --brand-dark:    #0369a1;
    --brand-bg:      #e0f2fe;
    --brand-border:  #7dd3fc;

    --bg:            #f1f5f9;
    --bg-card:       #ffffff;
    --bg-hover:      #e8f4fd;

    --sidebar-bg:    #1e2466;
    --sidebar-top:   #151a52;
    --sidebar-glow:  #2a3280;

    --topbar-bg:     rgba(241,245,249,0.95);

    --border:        #cbd5e1;
    --border-light:  #e2e8f0;

    --text:          #0f172a;
    --text-2:        #1e293b;
    --text-3:        #475569;
    --text-4:        #94a3b8;

    --success:       #047857;
    --success-bg:    #d1fae5;
    --success-border:#6ee7b7;
    --warning:       #b45309;
    --warning-bg:    #fef3c7;
    --warning-border:#fcd34d;
    --danger:        #b91c1c;
    --danger-bg:     #fee2e2;
    --danger-border: #fca5a5;
    --info:          #0e7490;
    --info-bg:       #cffafe;
    --info-border:   #67e8f9;

    --sidebar-w:  260px;
    --topbar-h:   58px;
    --radius:     12px;
    --radius-sm:  8px;
    --radius-lg:  16px;
    --shadow:     0 4px 20px rgba(15,23,42,0.12);
    --shadow-sm:  0 1px 6px rgba(15,23,42,0.08);
    --shadow-lg:  0 12px 40px rgba(15,23,42,0.18);
    --t:          0.16s ease;

    --font:         'Inter', sans-serif;
    --font-display: 'Syne', sans-serif;
    --font-mono:    'JetBrains Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 99px; }

/* ========== SIDEBAR ========== */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: linear-gradient(180deg, var(--sidebar-top) 0%, var(--sidebar-bg) 50%, var(--sidebar-glow) 100%);
    position: fixed;
    top: 0; left: 0;
    display: flex;
    flex-direction: column;
    z-index: 300;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform var(--t);
    border-right: 1px solid rgba(255,255,255,0.06);
}

.sidebar-header {
    padding: 20px 16px 14px;
    display: flex;
    align-items: center;
    gap: 11px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}
.sidebar-logo {
    width: 42px; height: 42px;
    object-fit: contain; border-radius: 10px;
    background: rgba(255,255,255,0.1); padding: 4px;
}
.sidebar-brand-icon {
    width: 42px; height: 42px;
    background: linear-gradient(135deg, #0ea5e9, #0369a1);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: white; flex-shrink: 0;
    box-shadow: 0 3px 12px rgba(14,165,233,0.5);
}
.sidebar-brand-icon svg { width: 22px; height: 22px; }
.sidebar-brand-text { display: flex; flex-direction: column; overflow: hidden; }
.brand-name {
    font-family: var(--font-display);
    font-size: 0.85rem; font-weight: 800;
    color: white; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
    letter-spacing: -0.01em;
}
.brand-sub { font-size: 0.66rem; color: rgba(255,255,255,0.4); margin-top: 1px; }

.sidebar-nav { flex: 1; padding: 12px 10px; }
.nav-group { margin-bottom: 18px; }
.nav-label {
    display: block;
    font-size: 0.6rem; font-weight: 700;
    letter-spacing: 0.14em; text-transform: uppercase;
    color: rgba(255,255,255,0.3);
    padding: 0 9px 6px;
    font-family: var(--font);
}
.nav-item {
    display: flex; align-items: center; gap: 9px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.72);
    text-decoration: none;
    font-size: 0.83rem; font-weight: 500;
    transition: all var(--t);
    margin-bottom: 2px;
    border-left: 2px solid transparent;
    position: relative;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.7; }
.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: white;
    border-left-color: rgba(56,189,248,0.5);
}
.nav-item:hover svg { opacity: 1; }
.nav-item.active {
    background: rgba(56,189,248,0.18);
    color: #7dd3fc;
    border-left-color: #38bdf8;
    font-weight: 600;
}
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex; align-items: center; gap: 10px;
    flex-shrink: 0;
}
.user-avatar {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, #38bdf8, #0284c7);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.71rem; font-weight: 700; color: white; flex-shrink: 0;
}
.user-details { flex: 1; overflow: hidden; }
.user-name { display: block; font-size: 0.77rem; font-weight: 600; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.65rem; color: rgba(255,255,255,0.38); }
.logout-btn {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.38);
    text-decoration: none;
    transition: all var(--t); border: 1px solid transparent;
}
.logout-btn svg { width: 14px; height: 14px; }
.logout-btn:hover { background: rgba(220,38,38,0.25); color: #fca5a5; border-color: rgba(220,38,38,0.2); }

/* ========== OVERLAY MOBILE ========== */
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(15,23,42,0.6);
    z-index: 250; backdrop-filter: blur(3px);
}
.sidebar-overlay.open { display: block; }

/* ========== TOPBAR ========== */
.topbar {
    position: fixed;
    top: 0; left: var(--sidebar-w); right: 0;
    height: var(--topbar-h);
    background: var(--topbar-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-light);
    display: flex; align-items: center; gap: 14px;
    padding: 0 24px;
    z-index: 200;
}
.topbar-toggle {
    display: none;
    background: none; border: none; cursor: pointer;
    color: var(--text-3); padding: 6px;
    border-radius: var(--radius-sm);
    transition: background var(--t);
}
.topbar-toggle:hover { background: var(--border-light); }
.topbar-toggle svg { width: 20px; height: 20px; display: block; }
.topbar-title {
    font-family: var(--font-display);
    font-size: 1rem; font-weight: 800;
    color: var(--text); flex: 1;
    letter-spacing: -0.02em;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-date {
    font-size: 0.75rem; color: var(--text-3);
    background: white;
    padding: 4px 11px;
    border-radius: 99px;
    border: 1px solid var(--border-light);
    font-weight: 500;
    white-space: nowrap;
}

/* ========== LAYOUT WRAPPER ========== */
.layout-wrapper {
    margin-left: var(--sidebar-w);
    margin-top: var(--topbar-h);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - var(--topbar-h));
}

/* ========== MAIN CONTENT ========== */
.main-content {
    flex: 1;
    padding: 26px 28px 24px;
}

/* ========== PIE DE PÁGINA — DESARROLLADO POR RED ENTRE RIOS ========== */
.dev-footer {
    background: linear-gradient(90deg, var(--sidebar-top) 0%, var(--sidebar-glow) 100%);
    border-top: 2px solid rgba(56,189,248,0.3);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 100%;
}
.dev-footer-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    font-size: 0.75rem;
}
.dev-footer-logo {
    color: #38bdf8;
    display: flex; align-items: center;
}
.dev-footer-text { color: rgba(255,255,255,0.5); font-weight: 400; }
.dev-footer-brand {
    font-family: var(--font-display);
    font-weight: 800; font-size: 0.82rem;
    color: #38bdf8; text-decoration: none;
    letter-spacing: 0.01em;
    transition: color var(--t);
}
.dev-footer-brand:hover { color: white; }
.dev-footer-sep { color: rgba(255,255,255,0.2); }
.dev-footer-link {
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    transition: color var(--t);
    display: flex; align-items: center; gap: 4px;
    font-weight: 500;
}
.dev-footer-link:hover { color: #38bdf8; }
.dev-footer-wa { color: #34d399 !important; font-weight: 600; }
.dev-footer-wa:hover { color: #6ee7b7 !important; }
.dev-footer-wa svg { flex-shrink: 0; }

/* ========== PAGE HEADER ========== */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 22px; flex-wrap: wrap; gap: 12px;
}
.page-header h2 {
    font-family: var(--font-display);
    font-size: 1.35rem; font-weight: 800;
    color: var(--text); letter-spacing: -0.025em;
}

/* ========== GRIDS ========== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 18px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; }

/* ========== CARD ========== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-sm);
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 0.7rem; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em; }

/* ========== STAT CARDS con color fuerte ========== */
.stat-card {
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex; flex-direction: column; gap: 10px;
    box-shadow: var(--shadow-sm);
    transition: transform var(--t), box-shadow var(--t);
    border: 1.5px solid transparent;
    position: relative; overflow: hidden;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-card.sc-blue   { background:#dbeafe; border-color:#93c5fd; }
.stat-card.sc-cyan   { background:#cffafe; border-color:#67e8f9; }
.stat-card.sc-green  { background:#dcfce7; border-color:#86efac; }
.stat-card.sc-amber  { background:#fef3c7; border-color:#fcd34d; }
.stat-card.sc-red    { background:#fee2e2; border-color:#fca5a5; }
.stat-card.sc-violet { background:#ede9fe; border-color:#c4b5fd; }
.stat-card.sc-indigo { background:#e0e7ff; border-color:#a5b4fc; }

.stat-icon {
    width: 42px; height: 42px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
}
.stat-icon svg { width: 20px; height: 20px; }
.sc-blue   .stat-icon { background:#bfdbfe; color:#1e40af; }
.sc-cyan   .stat-icon { background:#a5f3fc; color:#0e7490; }
.sc-green  .stat-icon { background:#bbf7d0; color:#14532d; }
.sc-amber  .stat-icon { background:#fde68a; color:#78350f; }
.sc-red    .stat-icon { background:#fecaca; color:#7f1d1d; }
.sc-violet .stat-icon { background:#ddd6fe; color:#4c1d95; }
.sc-indigo .stat-icon { background:#c7d2fe; color:#312e81; }

.stat-value {
    font-family: var(--font-display);
    font-size: 2rem; font-weight: 800;
    color: var(--text); letter-spacing: -0.04em; line-height: 1;
}
.stat-label { font-size: 0.77rem; font-weight: 600; color: var(--text-2); }

/* Compat con inline style del código existente */
.stat-card[style*="--stat-color:var(--brand)"]   { background:#dbeafe !important; border-color:#93c5fd !important; }
.stat-card[style*="--stat-color:var(--success)"] { background:#dcfce7 !important; border-color:#86efac !important; }
.stat-card[style*="--stat-color:var(--warning)"] { background:#fef3c7 !important; border-color:#fcd34d !important; }
.stat-card[style*="--stat-color:var(--danger)"]  { background:#fee2e2 !important; border-color:#fca5a5 !important; }
.stat-card[style*="--stat-color:var(--info)"]    { background:#cffafe !important; border-color:#67e8f9 !important; }
.stat-card[style*="--stat-color"] .stat-icon     { background:rgba(0,0,0,0.08); color:var(--stat-color,#334155); }

/* ========== BOTONES ========== */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 18px; border-radius: var(--radius-sm);
    font-family: var(--font); font-size: 0.84rem; font-weight: 600;
    cursor: pointer; border: none; text-decoration: none;
    transition: all var(--t); white-space: nowrap;
    letter-spacing: -0.01em;
}
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--brand); color: white; box-shadow: 0 2px 8px rgba(2,132,199,0.35); }
.btn-primary:hover { background: var(--brand-dark); box-shadow: 0 4px 14px rgba(2,132,199,0.5); transform: translateY(-1px); }
.btn-secondary { background: white; color: var(--text-2); border: 1.5px solid var(--border); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--bg); color: var(--text); }
.btn-success { background: #059669; color: white; box-shadow: 0 2px 8px rgba(5,150,105,0.35); }
.btn-success:hover { background: #047857; transform: translateY(-1px); }
.btn-danger  { background: #dc2626; color: white; box-shadow: 0 2px 8px rgba(220,38,38,0.3); }
.btn-danger:hover  { background: #b91c1c; }
.btn-warning { background: #d97706; color: white; box-shadow: 0 2px 8px rgba(217,119,6,0.3); }
.btn-warning:hover { background: #b45309; }
.btn-ghost { background: transparent; color: var(--text-2); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: white; color: var(--text); }
.btn-sm   { padding: 6px 13px; font-size: 0.78rem; }
.btn-lg   { padding: 11px 24px; font-size: 0.9rem; }
.btn-icon { padding: 8px; }
.btn-block { width: 100%; justify-content: center; }

/* ========== FORMULARIOS ========== */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-row { display: grid; gap: 14px; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

label {
    font-size: 0.72rem; font-weight: 700;
    color: var(--text-2); text-transform: uppercase;
    letter-spacing: 0.06em;
}
label .req { color: var(--danger); }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="time"],
input[type="tel"], input[type="url"], select, textarea {
    background: white; border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text);
    font-family: var(--font); font-size: 0.88rem; padding: 9px 12px;
    width: 100%; transition: border-color var(--t), box-shadow var(--t);
    outline: none; appearance: none;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(2,132,199,0.15);
}
input::placeholder, textarea::placeholder { color: var(--text-4); }
textarea { resize: vertical; min-height: 85px; }
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center; background-size: 14px;
    padding-right: 32px; cursor: pointer;
}
.form-hint  { font-size: 0.72rem; color: var(--text-3); }
.form-error { font-size: 0.72rem; color: var(--danger); }

/* ========== TABLAS ========== */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
thead th {
    background: linear-gradient(135deg, #1e2466, #2a3280);
    padding: 11px 14px;
    text-align: left; font-size: 0.67rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.09em;
    color: rgba(255,255,255,0.75); white-space: nowrap;
}
thead th:first-child { border-radius: var(--radius) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--radius) 0 0; }
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border-light); color: var(--text-2); background: white; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }
.td-strong { color: var(--text); font-weight: 600; }
.td-mono   { font-family: var(--font-mono); font-size: 0.81rem; color: var(--text-3); }

/* ========== BADGES ========== */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 9px; border-radius: 99px;
    font-size: 0.69rem; font-weight: 700;
    letter-spacing: 0.04em; text-transform: uppercase;
    white-space: nowrap; border: 1px solid transparent;
}
.badge::before { content:''; width:5px; height:5px; border-radius:50%; background:currentColor; flex-shrink:0; }
.badge-success { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.badge-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger);  border-color: var(--danger-border); }
.badge-info    { background: var(--info-bg);    color: var(--info);    border-color: var(--info-border); }
.badge-neutral { background: #f1f5f9; color: var(--text-3); border-color: var(--border); }
.badge-brand   { background: var(--brand-bg); color: var(--brand-dark); border-color: var(--brand-border); }

/* ========== MODAL ========== */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.55);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: none;
    align-items: center; justify-content: center;
    padding: 16px;
}
.modal-overlay.open {
    display: flex;
    animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
    background: white; border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%; max-width: 580px; max-height: 92vh;
    overflow-y: auto;
    transform: translateY(16px) scale(0.97);
    transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1);
    box-shadow: var(--shadow-lg);
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-lg { max-width: 780px; }
.modal-sm { max-width: 420px; }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 22px; border-bottom: 1px solid var(--border-light);
    position: sticky; top: 0; background: white; z-index: 1;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-title { font-family: var(--font-display); font-size: 0.95rem; font-weight: 800; color: var(--text); letter-spacing: -0.02em; }
.modal-close {
    width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--bg); color: var(--text-3); cursor: pointer;
    transition: all var(--t); font-size: 1.1rem;
}
.modal-close:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.modal-body   { padding: 22px; }
.modal-footer {
    display: flex; align-items: center; justify-content: flex-end; gap: 10px;
    padding: 14px 22px; border-top: 1px solid var(--border-light);
    background: #f8fafc;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ========== SEARCH/FILTROS ========== */
.filters-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.search-box {
    display: flex; align-items: center; gap: 8px;
    background: white; border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); padding: 0 12px;
    flex: 1; min-width: 180px;
    transition: border-color var(--t), box-shadow var(--t);
}
.search-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(2,132,199,0.12); }
.search-box svg { width: 14px; height: 14px; color: var(--text-4); flex-shrink: 0; }
.search-box input { border:none; background:none; padding:8px 0; font-size:0.84rem; flex:1; width:100%; box-shadow:none !important; }
.filter-select {
    background: white; border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); padding: 8px 30px 8px 12px;
    font-size: 0.82rem; color: var(--text-2); cursor: pointer;
    min-width: 130px; appearance: none; font-family: var(--font);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 8px center; background-size: 13px;
}

/* ========== TOASTS ========== */
.toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; }
.toast {
    display: flex; align-items: center; gap: 10px;
    background: white; border: 1.5px solid var(--border);
    border-radius: var(--radius); padding: 12px 16px;
    min-width: 260px; max-width: 360px;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.28s cubic-bezier(0.34,1.56,0.64,1);
    font-size: 0.84rem; font-weight: 500;
}
.toast.success { border-left: 3px solid #059669; }
.toast.error   { border-left: 3px solid #dc2626; }
.toast.warning { border-left: 3px solid #d97706; }
.toast.info    { border-left: 3px solid var(--brand); }
.toast-icon svg { width: 17px; height: 17px; }
.toast.success .toast-icon { color: #059669; }
.toast.error   .toast-icon { color: #dc2626; }
.toast.warning .toast-icon { color: #d97706; }
.toast.info    .toast-icon { color: var(--brand); }
.toast-out { animation: toastOut 0.22s ease forwards; }
@keyframes toastIn  { from { opacity:0; transform:translateX(20px) scale(0.95); } to { opacity:1; transform:none; } }
@keyframes toastOut { to { opacity:0; transform:translateX(20px); } }

/* ========== EMPTY STATE ========== */
.empty-state { display:flex; flex-direction:column; align-items:center; justify-content:center; padding:50px 20px; text-align:center; color:var(--text-3); gap:10px; }
.empty-state svg { opacity:0.2; }
.empty-state h3 { font-family:var(--font-display); font-size:0.95rem; font-weight:700; color:var(--text-2); }
.empty-state p  { font-size:0.83rem; max-width:300px; }

/* ========== ALERTAS ========== */
.alert { border-radius:var(--radius-sm); padding:11px 14px; font-size:0.86rem; margin-bottom:16px; border:1.5px solid; font-weight:500; }
.alert-success { background:var(--success-bg); color:var(--success); border-color:var(--success-border); }
.alert-error   { background:var(--danger-bg);  color:var(--danger);  border-color:var(--danger-border); }
.alert-warning { background:var(--warning-bg); color:var(--warning); border-color:var(--warning-border); }
.alert-info    { background:var(--info-bg);    color:var(--info);    border-color:var(--info-border); }

/* ========== LOGIN ========== */
.login-page {
    min-height: 100vh; display: flex;
    align-items: center; justify-content: center;
    background: linear-gradient(135deg, #151a52 0%, #1e2466 50%, #0f1240 100%);
    padding: 20px; position: relative; overflow: hidden;
}
.login-page::before {
    content:''; position:absolute;
    width:600px; height:600px;
    background:radial-gradient(circle, rgba(56,189,248,0.14) 0%, transparent 65%);
    top:50%; left:50%; transform:translate(-50%,-50%);
    pointer-events:none;
}
.login-card {
    background:white; border-radius:var(--radius-lg);
    padding: 40px 36px; width:100%; max-width:420px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.4);
    position:relative; z-index:1;
}
.login-logo { display:flex; flex-direction:column; align-items:center; gap:12px; margin-bottom:32px; text-align:center; }
.login-logo img { max-width:120px; max-height:60px; object-fit:contain; }
.login-logo .icon-wrap {
    width:58px; height:58px;
    background:linear-gradient(135deg, #0ea5e9, #0284c7);
    border-radius:var(--radius); display:flex; align-items:center; justify-content:center;
    box-shadow:0 6px 20px rgba(2,132,199,0.45);
}
.login-logo .icon-wrap svg { width:28px; height:28px; color:white; }
.login-logo h1 { font-family:var(--font-display); font-size:1.25rem; font-weight:800; color:var(--text); letter-spacing:-0.025em; }
.login-logo p  { font-size:0.8rem; color:var(--text-3); }

.login-dev-footer {
    margin-top: 24px; padding-top: 16px;
    border-top: 1px solid var(--border-light);
    display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.login-dev-footer p { font-size: 0.68rem; color: var(--text-4); }
.login-dev-footer a { font-size: 0.71rem; color: var(--brand); text-decoration: none; font-weight: 600; }
.login-dev-footer a:hover { color: var(--brand-dark); }
.login-dev-wa { color: #059669 !important; }

/* ========== FACTURA ========== */
.factura-preview {
    background:white; color:#1a1a1a; padding:28px;
    border-radius:var(--radius); max-width:680px;
    font-family:var(--font); font-size:0.86rem; line-height:1.55;
    border:1px solid #e2e8f0;
}
.factura-header { display:flex; justify-content:space-between; align-items:flex-start; margin-bottom:24px; padding-bottom:18px; border-bottom:2px solid #e2e8f0; }
.factura-logo img { max-width:130px; max-height:55px; object-fit:contain; }
.factura-empresa-nombre { font-family:var(--font-display); font-size:1rem; font-weight:800; color:#0f172a; letter-spacing:-0.02em; }
.factura-empresa-info { font-size:0.76rem; color:#64748b; line-height:1.7; margin-top:3px; }
.factura-numero-box { text-align:right; }
.factura-numero-label { font-size:0.65rem; font-weight:700; text-transform:uppercase; letter-spacing:0.1em; color:#94a3b8; }
.factura-numero { font-family:var(--font-mono); font-size:1.5rem; font-weight:600; color:var(--brand); line-height:1.1; }
.factura-fecha { font-size:0.76rem; color:#64748b; margin-top:3px; }
.factura-cliente-box { background:#f8fafc; border-radius:8px; padding:14px 16px; margin-bottom:20px; border-left:4px solid var(--brand); }
.factura-cliente-title { font-size:0.63rem; font-weight:700; text-transform:uppercase; letter-spacing:0.1em; color:#94a3b8; margin-bottom:5px; }
.factura-cliente-nombre { font-size:0.95rem; font-weight:700; font-family:var(--font-display); }
.factura-cliente-info { font-size:0.78rem; color:#64748b; margin-top:3px; }
.factura-table { width:100%; border-collapse:collapse; margin-bottom:18px; font-size:0.82rem; }
.factura-table th { background:linear-gradient(90deg, #1e2466, #2a3280); padding:9px 13px; text-align:left; font-size:0.66rem; font-weight:700; text-transform:uppercase; letter-spacing:0.08em; color:rgba(255,255,255,0.72); }
.factura-table th:first-child { border-radius:7px 0 0 0; } .factura-table th:last-child { border-radius:0 7px 0 0; }
.factura-table td { padding:10px 13px; border-bottom:1px solid #f1f5f9; color:#475569; }
.factura-table tr:last-child td { border-bottom:none; }
.factura-totales { display:flex; flex-direction:column; align-items:flex-end; gap:5px; margin-bottom:20px; }
.factura-total-row { display:flex; gap:24px; min-width:240px; justify-content:space-between; font-size:0.83rem; color:#475569; }
.factura-total-row.total-final { border-top:2px solid #e2e8f0; padding-top:9px; margin-top:3px; font-size:1rem; font-weight:800; color:var(--brand); }
.factura-total-row span:last-child { font-family:var(--font-mono); }
.factura-estado-pagada { text-align:center; margin:18px 0; padding:12px; background:#f0fdf4; border-radius:8px; border:1.5px solid #86efac; color:#14532d; font-weight:700; font-size:0.86rem; }
.factura-footer { text-align:center; margin-top:20px; padding-top:14px; border-top:1px solid #e2e8f0; font-size:0.7rem; color:#94a3b8; }

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; display: inline-block; }

/* ========== RESPONSIVE MOBILE FIRST ========== */
@media (max-width: 1200px) {
    .grid-4 { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 900px) {
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .form-row-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
    :root { --sidebar-w: 0px; }
    .sidebar {
        width: 260px;
        transform: translateX(-100%);
        box-shadow: none;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 8px 0 32px rgba(15,23,42,0.25);
    }
    .topbar { left: 0; padding: 0 14px; }
    .topbar-toggle { display: flex; }
    .topbar-title { font-size: 0.9rem; }
    .topbar-date { display: none; }
    .layout-wrapper { margin-left: 0; }
    .main-content { padding: 16px 14px 18px; }
    .dev-footer { position: static; left: 0; }
    .dev-footer-inner { font-size: 0.7rem; gap: 6px; }
    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .grid-4 { grid-template-columns: 1fr 1fr; }
    .form-row-2 { grid-template-columns: 1fr; }
    .form-row-3 { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .page-header h2 { font-size: 1.15rem; }
    .filters-bar { flex-direction: column; align-items: stretch; }
    .search-box { min-width: unset; }
    .filter-select { width: 100%; }
    .modal { max-width: 100%; }
    .modal-header { padding: 14px 16px; }
    .modal-body   { padding: 16px; }
    .modal-footer { padding: 12px 16px; flex-wrap: wrap; }
    .btn-block-mobile { width: 100%; justify-content: center; }
    .table-wrapper { font-size: 0.8rem; }
    thead th, tbody td { padding: 10px 10px; }
    .factura-header { flex-direction: column; gap: 14px; }
    .factura-numero-box { text-align: left; }
    .stat-value { font-size: 1.7rem; }
}
@media (max-width: 480px) {
    .grid-4 { grid-template-columns: 1fr; }
    .login-card { padding: 26px 18px; }
    .btn { font-size: 0.8rem; padding: 8px 14px; }
    .dev-footer-sep { display: none; }
    .dev-footer-inner { row-gap: 3px; }
    .toast-container { left: 12px; right: 12px; bottom: 16px; }
    .toast { min-width: unset; max-width: 100%; }
}

/* ========== PRINT ========== */
@media print {
    .sidebar, .topbar, .btn, .filters-bar, .modal-overlay, .dev-footer { display: none !important; }
    .layout-wrapper { margin: 0 !important; }
    .main-content { padding: 0 !important; }
    body { background: white !important; }
}
