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

/* ── Variables de tema ── */
:root, [data-theme="light"] {
    --bg-page:        #F3F4F6;
    --bg-card:        #ffffff;
    --bg-sidebar:     #ffffff;
    --bg-hover:       #F9FAFB;
    --border:         #E5E7EB;
    --border-strong:  #D1D5DB;
    --text-primary:   #111827;
    --text-secondary: #6B7280;
    --text-tertiary:  #9CA3AF;
    --accent:         #4F46E5;
    --accent-hover:   #4338CA;
    --accent-bg:      #EEF2FF;
    --accent-text:    #3730A3;
}

[data-theme="dark"] {
    --bg-page:        #0F172A;
    --bg-card:        #1E293B;
    --bg-sidebar:     #1E293B;
    --bg-hover:       #334155;
    --border:         #334155;
    --border-strong:  #475569;
    --text-primary:   #F1F5F9;
    --text-secondary: #94A3B8;
    --text-tertiary:  #64748B;
    --accent:         #6366F1;
    --accent-hover:   #4F46E5;
    --accent-bg:      #1E1B4B;
    --accent-text:    #A5B4FC;
}

@media (prefers-color-scheme: dark) {
    [data-theme="auto"] {
        --bg-page:        #0F172A;
        --bg-card:        #1E293B;
        --bg-sidebar:     #1E293B;
        --bg-hover:       #334155;
        --border:         #334155;
        --border-strong:  #475569;
        --text-primary:   #F1F5F9;
        --text-secondary: #94A3B8;
        --text-tertiary:  #64748B;
        --accent:         #6366F1;
        --accent-hover:   #4F46E5;
        --accent-bg:      #1E1B4B;
        --accent-text:    #A5B4FC;
    }
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
}

/* ── Layout ─ */
.app-layout { display: flex; min-height: 100vh; }

/* ─ Sidebar ── */
.sidebar {
    width: 220px; min-width: 220px;
    background: var(--bg-sidebar);
    border-right: 0.5px solid var(--border);
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 100; overflow-y: auto;
}
.sidebar-logo {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 16px;
    border-bottom: 0.5px solid var(--border);
    flex-shrink: 0;
}
.logo-dot {
    width: 30px; height: 30px; background: var(--accent);
    border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.logo-dot span { color: #fff; font-size: 12px; font-weight: 500; }
.logo-text { font-size: 14px; font-weight: 500; color: var(--text-primary); }
.sidebar-nav { flex: 1; padding: 8px 0; }
.nav-section {
    display: block; padding: 10px 16px 4px;
    font-size: 10px; font-weight: 500; color: var(--text-tertiary);
    text-transform: uppercase; letter-spacing: 0.06em;
}
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 16px; font-size: 13px; color: var(--text-secondary);
    text-decoration: none; border-left: 2px solid transparent;
    transition: all 0.15s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--accent-bg); color: var(--accent); border-left-color: var(--accent); font-weight: 500; }
.nav-item svg { flex-shrink: 0; opacity: 0.7; }
.nav-item.active svg { opacity: 1; }
.sidebar-footer {
    padding: 12px 16px; border-top: 0.5px solid var(--border);
    display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.user-info { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.user-avatar {
    width: 30px; height: 30px; background: var(--accent-bg); color: var(--accent);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 500; flex-shrink: 0;
}
.user-name { font-size: 12px; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-tertiary); }
.btn-logout { color: var(--text-tertiary); text-decoration: none; flex-shrink: 0; padding: 4px; border-radius: 6px; transition: color 0.15s; }
.btn-logout:hover { color: #DC2626; }

/* ── Main content ── */
.main-content { margin-left: 220px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
    height: 52px; background: var(--bg-card); border-bottom: 0.5px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px; position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 15px; font-weight: 500; color: var(--text-primary); }
.topbar-date { font-size: 12px; color: var(--text-tertiary); }
.page-content { padding: 24px; flex: 1; background: var(--bg-page); }

/* ─ Alerts ── */
.alert { padding: 10px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 20px; }
.alert-success { background: #ECFDF5; border: 0.5px solid #A7F3D0; color: #065F46; }
.alert-error   { background: #FEF2F2; border: 0.5px solid #FECACA; color: #991B1B; }

/* ── Stat cards ── */
.stats-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card {
    background: var(--bg-card); border: 0.5px solid var(--border); border-radius: 12px;
    padding: 16px; display: flex; align-items: center; gap: 12px; border-left: 3px solid;
}
.stat-card.blue   { border-left-color: #4F46E5; }
.stat-card.green  { border-left-color: #059669; }
.stat-card.amber  { border-left-color: #D97706; }
.stat-card.red    { border-left-color: #DC2626; }
.stat-card.purple { border-left-color: #7C3AED; }
.stat-icon { width: 40px; height: 40px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon.blue   { background: #EEF2FF; }
.stat-icon.green  { background: #ECFDF5; }
.stat-icon.amber  { background: #FFFBEB; }
.stat-icon.red    { background: #FEF2F2; }
.stat-icon.purple { background: #F5F3FF; }
.stat-icon svg { width: 18px; height: 18px; }
.stat-num   { font-size: 24px; font-weight: 500; color: var(--text-primary); line-height: 1.2; }
.stat-label { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

/* ── Cards ── */
.card { background: var(--bg-card); border: 0.5px solid var(--border); border-radius: 12px; overflow: hidden; margin-bottom: 20px; }
.card-header {
    padding: 14px 16px; border-bottom: 0.5px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.card-body  { padding: 16px; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead tr { background: var(--bg-hover); }
th { padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 500; color: var(--text-secondary); border-bottom: 0.5px solid var(--border); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 0.5px solid var(--border); color: var(--text-primary); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg-hover); }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.badge-green  { background: #ECFDF5; color: #065F46; }
.badge-red    { background: #FEF2F2; color: #991B1B; }
.badge-amber  { background: #FFFBEB; color: #92400E; }
.badge-blue   { background: #EEF2FF; color: #3730A3; }
.badge-gray   { background: var(--bg-hover); color: var(--text-secondary); }
.badge-purple { background: #F5F3FF; color: #5B21B6; }

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: 8px; font-size: 12px; font-weight: 500;
    cursor: pointer; text-decoration: none;
    border: 0.5px solid var(--border-strong);
    background: var(--bg-card); color: var(--text-primary);
    transition: all 0.15s;
}
.btn:hover { background: var(--bg-hover); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger  { background: #FEF2F2; color: #991B1B; border-color: #FECACA; }
.btn-danger:hover { background: #FEE2E2; }
.btn-sm { padding: 5px 10px; font-size: 11px; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text-primary); margin-bottom: 6px; }
.form-control {
    width: 100%; padding: 9px 12px;
    border: 0.5px solid var(--border-strong); border-radius: 8px;
    font-size: 13px; color: var(--text-primary);
    background: var(--bg-card);
    outline: none; transition: border-color 0.15s; font-family: inherit;
}
.form-control:focus { border-color: var(--accent); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; }

/* ── User cells ── */
.user-cell { display: flex; align-items: center; gap: 8px; }
.user-avatar-sm {
    width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 500; flex-shrink: 0;
}
.user-name-sm { font-size: 12px; font-weight: 500; color: var(--text-primary); }
.user-sub-sm  { font-size: 11px; color: var(--text-tertiary); }

/* ── Pagination ── */
.pagination {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; border-top: 0.5px solid var(--border);
    font-size: 12px; color: var(--text-secondary);
}
.page-btns { display: flex; gap: 4px; }
.page-btn {
    width: 28px; height: 28px; border-radius: 6px; border: 0.5px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 12px; background: var(--bg-card); color: var(--text-secondary);
    text-decoration: none; transition: all 0.15s;
}
.page-btn:hover { background: var(--bg-hover); }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .main-content { margin-left: 0; }
    .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
    .stats-row { grid-template-columns: 1fr 1fr; }
    .page-content { padding: 16px; }
}

/* ── Nombre Logo ── */
.logo-info    { display:flex; flex-direction:column; }
.logo-company { font-size:10px; color:var(--text-tertiary); margin-top:1px; }
