:root {
    --sidebar-w: 260px;
    --sidebar-bg: #0a0a0a;
    --sidebar-border: rgba(255,255,255,0.08);
    --accent: #dc2626;
    --accent-light: rgba(220,38,38,0.12);
    --accent-glow: rgba(220,38,38,0.25);
    --text-muted: #64748b;
    --surface: #ffffff;
    --bg: #f4f4f5;
    --card-border: #e4e4e7;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #dc2626;
    --info: #3b82f6;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    display: flex;
    min-height: 100vh;
    color: #1e293b;
}

a { color: inherit; text-decoration: none; }

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a, #1e293b);
}
.auth-card {
    background: white;
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.auth-brand { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.5rem; }
.auth-brand-icon {
    width: 42px; height: 42px;
    background: linear-gradient(135deg, #dc2626, #991b1b);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 1.1rem;
    box-shadow: 0 4px 12px rgba(220,38,38,0.4);
}
.auth-brand-text { font-weight: 800; font-size: 1.2rem; color: #0f172a; }

.app-shell { display: flex; min-height: 100vh; width: 100%; }

/* ─── Sidebar ─── */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1000;
    border-right: 1px solid var(--sidebar-border);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-brand {
    padding: 1.5rem 1.25rem 1.25rem;
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.sidebar-brand-icon {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, #dc2626, #991b1b);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(220,38,38,0.4);
}
.sidebar-brand-icon i { color: white; font-size: 1rem; }
.sidebar-brand-text { color: white; font-weight: 700; font-size: 1.15rem; letter-spacing: -0.3px; }

.sidebar-section-label {
    padding: 1.25rem 1.25rem 0.4rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #475569;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.25rem;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.15s;
    margin: 0.08rem 0.75rem;
    border-radius: 8px;
}
.nav-link:hover { color: white; background: rgba(255,255,255,0.07); }
.nav-link.active { color: white; background: var(--accent-light); border: 1px solid rgba(220,38,38,0.25); }
.nav-link.active .nav-icon { color: var(--accent); }
.nav-icon { width: 20px; text-align: center; font-size: 0.9rem; flex-shrink: 0; }

.sidebar-footer { margin-top: auto; padding: 1rem 0.75rem; border-top: 1px solid var(--sidebar-border); }
.user-pill { display: flex; align-items: center; gap: 0.65rem; padding: 0.6rem 0.75rem; border-radius: 10px; background: rgba(255,255,255,0.05); cursor: pointer; text-decoration: none; }
.user-pill:hover { background: rgba(255,255,255,0.1); }
.user-avatar {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, #dc2626, #991b1b);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 0.8rem; font-weight: 700;
    flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { color: white; font-size: 0.82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: #64748b; font-size: 0.7rem; }
.logout-btn {
    color: #64748b; font-size: 0.8rem; cursor: pointer;
    background: none; border: none; padding: 0.2rem;
    transition: color 0.15s;
}
.logout-btn:hover { color: #ef4444; }

/* ─── Main ─── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: white;
    border-bottom: 1px solid #e2e8f0;
    padding: 0 1.75rem;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #0f172a;
}
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.topbar-date { color: var(--text-muted); font-size: 0.82rem; }

.page-body {
    flex: 1;
    padding: 1.75rem;
}

/* ─── Cards ─── */
.card {
    background: white;
    border: 1px solid var(--card-border);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.card-header-plain {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header-plain h6 {
    font-size: 0.88rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
}
.card-body-pad { padding: 1.25rem; }

/* Stat Cards */
.stat-card {
    background: white;
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.08); }
.stat-icon {
    width: 52px; height: 52px;
    border-radius: 13px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}
.stat-icon.purple { background: rgba(220,38,38,0.12); color: #dc2626; }
.stat-icon.green  { background: rgba(16,185,129,0.12);  color: #10b981; }
.stat-icon.orange { background: rgba(245,158,11,0.12);  color: #f59e0b; }
.stat-icon.red    { background: rgba(239,68,68,0.12);   color: #ef4444; }
.stat-icon.blue   { background: rgba(59,130,246,0.12);  color: #3b82f6; }
.stat-icon.pink   { background: rgba(236,72,153,0.12);  color: #ec4899; }
.stat-value { font-size: 1.6rem; font-weight: 800; color: #0f172a; line-height: 1; }
.stat-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 3px; font-weight: 500; }

/* Badges */
.badge-active   { background: rgba(16,185,129,0.12);  color: #059669; padding: 3px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 600; }
.badge-expiring { background: rgba(245,158,11,0.12);  color: #d97706; padding: 3px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 600; }
.badge-inactive { background: rgba(100,116,139,0.12); color: #475569; padding: 3px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 600; }
.badge-bio  { background: rgba(220,38,38,0.1); color: #dc2626; padding: 2px 8px; border-radius: 6px; font-size: 0.7rem; font-weight: 600; }
.badge-man  { background: rgba(59,130,246,0.1); color: #3b82f6; padding: 2px 8px; border-radius: 6px; font-size: 0.7rem; font-weight: 600; }

/* Table */
.table-clean { width: 100%; border-collapse: collapse; }
.table-clean th {
    font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--text-muted);
    padding: 0.65rem 1rem; border-bottom: 1px solid #f1f5f9;
    background: #fafafa;
}
.table-clean td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f8fafc;
    font-size: 0.875rem;
    color: #334155;
    vertical-align: middle;
}
.table-clean tr:last-child td { border-bottom: none; }
.table-clean tbody tr:hover td { background: #fafafa; }

/* Folder tabs */
.folder-tab {
    display: inline-flex; align-items: center; gap: 6px;
    border: 1.5px solid #e2e8f0; background: #fff; color: #475569;
    border-radius: 9px; padding: 0.4rem 0.85rem; font-size: 0.8rem; font-weight: 600;
    cursor: pointer; transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.folder-tab:hover { border-color: #dc2626; color: #dc2626; }
.folder-tab-active { border-color: #dc2626; background: rgba(220,38,38,0.08); color: #dc2626; }
.folder-tab-count {
    background: #f1f5f9; color: #64748b; border-radius: 999px;
    padding: 1px 7px; font-size: 0.7rem; font-weight: 700;
}
.folder-tab-active .folder-tab-count { background: rgba(220,38,38,0.15); color: #dc2626; }

/* Search bar */
.search-input {
    padding: 0.55rem 0.9rem 0.55rem 2.25rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 9px;
    font-size: 0.875rem;
    outline: none;
    background: white;
    min-width: 220px;
    transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.search-wrap { position: relative; display: inline-block; }
.search-wrap i { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); color: #94a3b8; font-size: 0.8rem; }

/* Buttons */
.btn-primary-sm {
    background: var(--accent);
    color: white; border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.82rem; font-weight: 600;
    cursor: pointer; transition: all 0.15s;
    text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary-sm:hover { background: #b91c1c; color: white; transform: translateY(-1px); }
.btn-outline-sm {
    background: transparent;
    color: var(--text-muted);
    border: 1.5px solid #e2e8f0;
    padding: 0.45rem 0.85rem;
    border-radius: 8px;
    font-size: 0.82rem; font-weight: 500;
    cursor: pointer; transition: all 0.15s;
    text-decoration: none; display: inline-flex; align-items: center; gap: 5px;
}
.btn-outline-sm:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger-sm {
    background: rgba(239,68,68,0.1); color: #ef4444;
    border: none; padding: 0.4rem 0.8rem;
    border-radius: 7px; font-size: 0.8rem; font-weight: 600;
    cursor: pointer; transition: all 0.15s;
}
.btn-danger-sm:hover { background: #ef4444; color: white; }
.btn-success-sm {
    background: rgba(16,185,129,0.1); color: #10b981;
    border: none; padding: 0.4rem 0.8rem;
    border-radius: 7px; font-size: 0.8rem; font-weight: 600;
    cursor: pointer; transition: all 0.15s;
}
.btn-success-sm:hover { background: #10b981; color: white; }

/* Avatar */
.member-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, #dc2626, #991b1b);
    display: inline-flex; align-items: center; justify-content: center;
    color: white; font-size: 0.75rem; font-weight: 700;
    flex-shrink: 0;
}

/* Form controls */
.form-control, .form-select, input:not([type=checkbox]):not([type=radio]), textarea, select {
    border: 1.5px solid #e2e8f0; border-radius: 9px;
    padding: 0.6rem 0.85rem; font-size: 0.875rem;
    width: 100%; font-family: inherit;
}
.form-control:focus, .form-select:focus, input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
    outline: none;
}
.form-label {
    font-size: 0.8rem; font-weight: 600;
    color: #374151; text-transform: uppercase;
    letter-spacing: 0.3px; display: block; margin-bottom: 0.3rem;
}

/* ─── Sidebar overlay (mobile) ─── */
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.55); z-index: 999;
}
.sidebar-overlay.show { display: block; }

/* Mobile sidebar toggle button */
.sidebar-toggle { display: none; }

/* Empty state */
.empty-state {
    text-align: center; padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state i { font-size: 2.5rem; margin-bottom: 1rem; opacity: 0.4; display: block; }
.empty-state p { font-size: 0.9rem; }

/* Error */
.error { color: #b00020; font-size: 0.85rem; }

/* Toast */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; }

/* Modal */
.modal-content { border: none; border-radius: 16px; }
.modal-header { border-bottom: 1px solid #f1f5f9; padding: 1.25rem 1.5rem; }
.modal-body { padding: 1.5rem; }
.modal-footer { border-top: 1px solid #f1f5f9; padding: 1rem 1.5rem; }

/* Custom Modal (for inline usage) */
.modal-backdrop-custom {
    display: flex; position: fixed; inset: 0;
    background: rgba(0,0,0,0.5); z-index: 9999;
    align-items: center; justify-content: center; padding: 1rem;
}
.modal-box {
    background: #fff; border-radius: 16px; padding: 2rem;
    max-width: 420px; width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-box h3 { font-size: 1.1rem; font-weight: 800; color: #0f172a; margin: 0 0 0.5rem; }
.modal-box p { color: #64748b; font-size: 0.85rem; margin-bottom: 1.5rem; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; }

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 1100;
    }
    .sidebar.open { transform: translateX(0); box-shadow: 4px 0 30px rgba(0,0,0,0.5); }
    .main-content { margin-left: 0; }
    .sidebar-toggle { display: flex; }

    .topbar { padding: 0 0.9rem; }
    .topbar-date { display: none; }
    .topbar-right { gap: 0.5rem; }

    .page-body { padding: 0.9rem; }

    .search-input { min-width: 0; width: 100%; }
    .search-wrap { width: 100%; }
}

@media (max-width: 480px) {
    .page-body { padding: 0.65rem; }
    .topbar { height: 52px; }
    .topbar-title { font-size: 0.95rem; }
}
