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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #eef2ff;
    --accent: #06b6d4;
    --success: #10b981;
    --success-bg: #d1fae5;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --bg: #f5f6fb;
    --bg-alt: #eef1f7;
    --card: #ffffff;
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e7eaf2;
    --sidebar: #ffffff;
    --sidebar-hover: #f1f5f9;
    --sidebar-text: #475569;
    --sidebar-text-strong: #0f172a;
    --sidebar-muted: #94a3b8;
    --sidebar-border: #e9edf5;
    --sidebar-active-bg: rgba(99,102,241,.12);
    --sidebar-active-text: #4f46e5;
    --sidebar-width-collapsed: 76px;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.05);
    --shadow-md: 0 6px 16px -6px rgba(16,24,40,.12), 0 2px 6px rgba(16,24,40,.05);
    --shadow-lg: 0 20px 50px -16px rgba(16,24,40,.22), 0 8px 20px -10px rgba(16,24,40,.12);
    --nav-height: 64px;
    --topbar-height: 64px;
    --sidebar-width: 280px;
    --transition: .2s cubic-bezier(.4,0,.2,1);
    --transition-slow: .35s cubic-bezier(.4,0,.2,1);
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    --gradient-accent: linear-gradient(135deg, #6366f1 0%, #06b6d4 100%);
    --font-sans: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-display: 'Plus Jakarta Sans', 'Inter', 'Segoe UI', system-ui, sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv11', 'ss01';
    letter-spacing: -0.011em;
}

h1, h2, h3, h4 { font-family: var(--font-display); letter-spacing: -0.02em; }

a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; }

/* ========== AUTH ========== */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, #0f172a 0%, #312e81 50%, #6366f1 100%);
    position: relative;
    overflow: hidden;
}

.auth-page::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(99,102,241,.3) 0%, transparent 70%);
    top: -200px; right: -200px;
    border-radius: 50%;
}

.auth-card {
    background: var(--card);
    border-radius: 20px;
    padding: 40px 32px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo .icon {
    width: 96px; height: 96px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 16px;
    background: #fff;
}
.auth-logo .icon img { width: 100%; height: 100%; object-fit: contain; }

.auth-logo h1 { font-size: 1.5rem; font-weight: 700; }
.auth-logo p { color: var(--text-muted); font-size: .9rem; margin-top: 4px; }

/* ========== FORMS ========== */
.form-group { margin-bottom: 20px; }

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: .875rem;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background: var(--card);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
    -webkit-appearance: none;
}

.form-group input[type="checkbox"],
.form-group input[type="radio"] {
    width: 18px;
    height: 18px;
    min-width: 18px;
    padding: 0;
    margin: 0;
    flex: 0 0 auto;
    accent-color: var(--primary);
    cursor: pointer;
    -webkit-appearance: auto;
    appearance: auto;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99,102,241,.15);
}

.password-wrap { position: relative; }
.password-wrap input { padding-right: 48px; }
.password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 6px;
    line-height: 1;
    opacity: .7;
}
.password-toggle:hover { opacity: 1; }

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

@media (max-width: 480px) {
    .form-row { grid-template-columns: 1fr; }
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.form-grid-2 .span-2 { grid-column: 1 / -1; }
@media (max-width: 768px) {
    .form-grid-2 { grid-template-columns: 1fr; }
    .form-grid-2 .span-2 { grid-column: auto; }
}
.form-hint {
    display: block;
    margin-top: 6px;
    color: var(--text-muted);
    font-size: .78rem;
}
.mig-help {
    color: var(--text-muted);
    font-size: .9rem;
    margin: 0 0 16px;
    line-height: 1.5;
}
.mig-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: .9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    touch-action: manipulation;
}

.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text-secondary);
}
.btn-outline:hover { background: var(--bg-alt); }
.btn-ghost { background: transparent; color: var(--text-secondary); padding: 8px; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: .8125rem; }
.btn-icon { padding: 10px; border-radius: 50%; }

/* ========== ALERTS ========== */
.alert {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: .9rem;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.alert-error { background: var(--danger-bg); color: #b91c1c; }
.alert-success { background: var(--success-bg); color: #047857; }
.alert-info { background: var(--primary-light); color: var(--primary-dark); }
.alert-warning { background: var(--warning-bg); color: #b45309; }

.hidden { display: none !important; }

/* ========== APP LAYOUT ========== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar);
    color: var(--sidebar-text);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform var(--transition);
}

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

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.5);
    z-index: 199;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
}

.sidebar-overlay.open { opacity: 1; visibility: visible; }

.sidebar-brand {
    padding: 20px 24px;
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    flex-direction: column;
    gap: 8px;
    text-align: center;
    position: relative;
}

.sidebar-brand .brand-logo-full {
    width: 120px;
    height: 120px;
    max-height: none;
    object-fit: cover;
    clip-path: circle(40% at 50% 50%);
}

.sidebar-brand .logo-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: #fff;
    flex-shrink: 0;
}
.sidebar-brand .logo-icon img { width: 100%; height: 100%; object-fit: contain; }

.sidebar-brand h2 { color: var(--sidebar-text-strong); font-size: 1.1rem; font-weight: 700; }
.sidebar-brand small { color: var(--sidebar-muted); font-size: .75rem; display: block; }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
}

.sidebar-nav a,
.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    color: var(--sidebar-text);
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-weight: 500;
    margin-bottom: 4px;
    transition: all var(--transition);
    text-decoration: none;
    width: 100%;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
}

.sidebar-nav a:hover,
.sidebar-nav .nav-link:hover { background: var(--sidebar-hover); color: var(--sidebar-text-strong); text-decoration: none; }
.sidebar-nav a.active,
.sidebar-nav .nav-link.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); }
.sidebar-nav a .nav-icon,
.sidebar-nav .nav-link .nav-icon { font-size: 1.2rem; width: 24px; text-align: center; flex-shrink: 0; }

.nav-group { margin-bottom: 6px; }

.nav-group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 16px;
    color: var(--sidebar-muted);
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    margin-bottom: 2px;
    margin-top: 8px;
    transition: all var(--transition);
}

.nav-group-head:hover { color: var(--sidebar-text-strong); background: var(--sidebar-hover); }

.nav-group.open .nav-group-head { color: var(--sidebar-text); }

.nav-group-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-group-title .nav-icon { font-size: 1rem; }

.nav-group-chevron {
    font-size: .75rem;
    opacity: .7;
    transition: transform var(--transition);
}

.nav-group.open .nav-group-chevron { transform: rotate(180deg); }

.nav-group-items {
    display: none;
    padding-left: 8px;
    margin-bottom: 4px;
}

.nav-group.open .nav-group-items { display: block; }

.nav-group-items .nav-link {
    padding: 10px 16px 10px 40px;
    font-size: .85rem;
    font-weight: 500;
}

.nav-group-items .nav-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    width: 100%;
    overflow-x: hidden;
}

.topbar {
    height: var(--topbar-height);
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 12px;
}

.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-left h1 { font-size: 1.125rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.menu-toggle {
    display: flex;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text);
    padding: 4px;
}

.notification-btn {
    position: relative;
    background: var(--bg-alt);
    border: none;
    width: 40px; height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-badge {
    position: absolute;
    top: 2px; right: 2px;
    background: var(--danger);
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    min-width: 18px; height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.notif-wrap { position: relative; }

.notif-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: min(380px, calc(100vw - 24px));
    max-height: min(460px, 72vh);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1200;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.notif-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-alt);
}

.notif-panel-head h3 {
    font-size: .95rem;
    font-weight: 700;
    margin: 0;
}

.notif-panel-body {
    overflow-y: auto;
    padding: 8px;
    flex: 1;
}

.notif-panel-body .notif-item {
    padding: 12px;
    margin-bottom: 0;
}

.notif-panel-foot {
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    text-align: center;
    background: var(--bg-alt);
}

.notif-panel-foot a {
    font-size: .85rem;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
}

.notif-panel-foot a:hover { text-decoration: underline; }

.notif-panel-empty,
.notif-panel-loading {
    padding: 28px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: .9rem;
}

.notif-panel-empty span { font-size: 1.6rem; display: block; margin-bottom: 8px; }

@media (max-width: 480px) {
    .notif-panel {
        position: fixed;
        top: 60px;
        right: 12px;
        left: 12px;
        width: auto;
    }
}

.user-chip {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 6px 6px;
    background: var(--bg-alt);
    border-radius: 24px;
    font-size: .85rem;
}

.user-avatar {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: .8rem;
}

.page-content {
    flex: 1;
    padding: 20px;
    padding-bottom: calc(var(--nav-height) + 24px);
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
}

/* Bottom mobile nav */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--nav-height);
    background: var(--card);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-muted);
    font-size: .65rem;
    font-weight: 600;
    text-decoration: none;
    padding: 8px 4px;
    transition: color var(--transition);
}

.bottom-nav a .bn-icon { font-size: 1.35rem; }
.bottom-nav a.active { color: var(--primary); }

@media (min-width: 1024px) {
    .sidebar { transform: translateX(0); }
    .sidebar-overlay { display: none; }
    .menu-toggle { display: none; }
    .bottom-nav { display: none; }
    .main-area { margin-left: var(--sidebar-width); }
    .page-content { padding: 32px; padding-bottom: 32px; }
    .user-chip { display: flex; }
}

/* ========== CARDS & STATS ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

@media (min-width: 768px) {
    .stats-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 60px; height: 60px;
    background: var(--primary-light);
    border-radius: 0 0 0 60px;
    opacity: .5;
}

.stat-card .stat-icon { font-size: 1.5rem; margin-bottom: 8px; }
.stat-card .label { color: var(--text-muted); font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.stat-card .value { font-size: 1.75rem; font-weight: 800; color: var(--text); line-height: 1.2; }
.stat-card .sub { font-size: .75rem; color: var(--text-muted); margin-top: 4px; }
.stat-card.highlight { border-color: var(--primary); background: linear-gradient(135deg, #fff 0%, var(--primary-light) 100%); }

/* ========== DASHBOARD TILES ========== */
.dash-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.dash-toolbar-hint {
    margin: 0;
    color: var(--text-muted);
    font-size: .9rem;
}
.dash-tiles-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}
@media (min-width: 768px) {
    .dash-tiles-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
}
@media (min-width: 1100px) {
    .dash-tiles-grid { grid-template-columns: repeat(4, 1fr); }
}
.dash-tile {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
    min-height: 108px;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.dash-tile-module {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}
.dash-tile-module:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}
.dash-tile-icon { font-size: 1.75rem; line-height: 1; flex-shrink: 0; }
.dash-tile-body { min-width: 0; }
.dash-tile-label {
    color: var(--text-muted);
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.dash-tile-value {
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.15;
    margin-top: 4px;
}
.dash-tile-sub {
    font-size: .75rem;
    color: var(--text-muted);
    margin-top: 4px;
}
.dash-tile-stat.highlight {
    border-color: var(--primary);
    background: linear-gradient(135deg, #fff 0%, var(--primary-light) 100%);
}
.dash-tile-module.dash-tile-blue { border-left: 4px solid #3b82f6; }
.dash-tile-module.dash-tile-indigo { border-left: 4px solid #6366f1; }
.dash-tile-module.dash-tile-teal { border-left: 4px solid #14b8a6; }
.dash-tile-module.dash-tile-purple { border-left: 4px solid #a855f7; }
.dash-tile-module.dash-tile-amber { border-left: 4px solid #f59e0b; }
.dash-tile-module.dash-tile-rose { border-left: 4px solid #f43f5e; }
.dash-tile-module.dash-tile-cyan { border-left: 4px solid #06b6d4; }
.dash-tile-module.dash-tile-slate,
.dash-tile-module.dash-tile-gray { border-left: 4px solid #64748b; }

.dash-tile-shell {
    position: relative;
    min-height: 108px;
}
.dash-tile-shell > .dash-tile {
    height: 100%;
    min-height: 108px;
}
.dash-tile-drag-handle {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card);
    color: var(--text-muted);
    font-size: .85rem;
    cursor: grab;
    opacity: 0;
    transition: opacity .15s ease, border-color .15s ease, color .15s ease;
    padding: 0;
    line-height: 1;
}
.dash-tile-shell:hover .dash-tile-drag-handle,
.dash-tile-shell.dragging .dash-tile-drag-handle {
    opacity: 1;
}
.dash-tile-drag-handle:hover {
    color: var(--primary);
    border-color: var(--primary);
}
.dash-tile-drag-handle:active { cursor: grabbing; }
.dash-tile-shell.dragging {
    opacity: .55;
}
.dash-tile-shell.drag-over > .dash-tile {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}
.dash-tiles-grid--sortable .dash-tile-module { padding-right: 40px; }
.dash-tiles-grid--sortable .dash-tile-stat { padding-right: 40px; }
@media (hover: none) {
    .dash-tile-drag-handle { opacity: 0.75; }
}

.dash-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    background: var(--card);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

/* Recent requests widget */
.dash-recent-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.dash-recent-body { padding: 0 !important; }
.dash-recent-list {
    display: flex;
    flex-direction: column;
}
.dash-recent-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
    transition: background .15s ease;
}
.dash-recent-item:last-child { border-bottom: none; }
.dash-recent-item:hover { background: var(--bg-alt); }
.dash-recent-avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: .85rem;
    flex-shrink: 0;
}
.dash-recent-main { flex: 1; min-width: 0; }
.dash-recent-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}
.dash-recent-name {
    font-weight: 700;
    font-size: .95rem;
}
.dash-recent-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
    font-size: .82rem;
    color: var(--text-muted);
}
.dash-recent-type {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}
.dash-recent-type-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.dash-recent-dept::before {
    content: '·';
    margin-right: 8px;
    opacity: .6;
}
.dash-recent-dates {
    margin-top: 4px;
    font-size: .8rem;
    color: var(--text-secondary);
}
.dash-recent-aside {
    flex-shrink: 0;
    text-align: right;
}
.dash-recent-days {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    font-size: .78rem;
    font-weight: 700;
    color: var(--text-secondary);
    white-space: nowrap;
}
.dash-recent-empty {
    text-align: center;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
@media (max-width: 640px) {
    .dash-recent-item {
        flex-wrap: wrap;
        align-items: flex-start;
    }
    .dash-recent-aside {
        width: 100%;
        text-align: left;
        padding-left: 58px;
    }
    .dash-recent-header-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

.modal-dash-customize { max-width: 960px; width: calc(100% - 24px); }
.dash-customize-intro {
    margin: 0 0 18px;
    color: var(--text-muted);
    font-size: .9rem;
    line-height: 1.5;
}
.dash-customize-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}
@media (min-width: 768px) {
    .dash-customize-layout { grid-template-columns: 1fr 1.25fr; gap: 20px; }
}
.dash-customize-col {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    min-height: 320px;
    display: flex;
    flex-direction: column;
}
.dash-customize-col-main {
    background: linear-gradient(180deg, var(--primary-light) 0%, var(--bg-alt) 48px);
    border-color: rgba(99, 102, 241, .2);
}
.dash-customize-col h4 {
    margin: 0;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    font-weight: 700;
}
.dash-pick-hint {
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    color: var(--primary);
    font-size: .75rem;
}
.dash-customize-col-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
    flex-shrink: 0;
}
.dash-customize-col-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.dash-pick-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--card);
    border: 1px solid var(--border);
    font-size: .75rem;
    font-weight: 700;
    color: var(--text-muted);
}
.dash-pick-count-primary {
    background: var(--primary-light);
    border-color: rgba(99, 102, 241, .25);
    color: var(--primary-dark);
}
.dash-pick-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    max-height: 380px;
    overflow-y: auto;
    padding: 2px;
}
.dash-pick-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card);
    transition: border-color .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.dash-pick-item-available:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(99, 102, 241, .1);
}
.dash-pick-item-selected {
    background: var(--card);
    padding-left: 8px;
}
.dash-pick-item-selected.dragging { opacity: .5; }
.dash-pick-item-selected.drag-over {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}
.dash-pick-drag-handle {
    width: 28px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-alt);
    color: var(--text-muted);
    cursor: grab;
    flex-shrink: 0;
    font-size: .9rem;
    padding: 0;
    line-height: 1;
}
.dash-pick-drag-handle:hover {
    color: var(--primary);
    border-color: var(--primary);
}
.dash-pick-drag-handle:active { cursor: grabbing; }
.dash-pick-index {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: var(--primary-light);
    color: var(--primary-dark);
    font-size: .72rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.dash-pick-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}
.dash-pick-icon-wrap {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--bg-alt);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}
.dash-pick-text { min-width: 0; }
.dash-pick-title {
    font-weight: 600;
    font-size: .9rem;
    line-height: 1.25;
    margin-bottom: 4px;
}
.dash-pick-type-badge {
    display: inline-block;
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .35px;
    padding: 2px 8px;
    border-radius: 999px;
}
.dash-pick-type-badge.type-module { background: #dbeafe; color: #1d4ed8; }
.dash-pick-type-badge.type-stat { background: #fef3c7; color: #b45309; }
.dash-pick-type-badge.type-widget { background: #ede9fe; color: #6d28d9; }
.dash-pick-add-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    line-height: 1;
    transition: transform .15s ease, background .15s ease;
}
.dash-pick-add-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}
.dash-pick-remove-btn {
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    flex-shrink: 0;
    line-height: 1;
    padding: 0;
}
.dash-pick-remove-btn:hover {
    color: #dc2626;
    border-color: #fecaca;
    background: #fef2f2;
}
.dash-pick-empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: .88rem;
    border: 2px dashed var(--border);
    border-radius: 12px;
    background: var(--card);
}
.dash-pick-empty-sub {
    margin: 6px 0 0;
    font-size: .78rem;
    opacity: .85;
}
.dash-pick-order {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.dash-pick-order .btn-icon {
    width: 28px;
    height: 22px;
    padding: 0;
    font-size: .65rem;
    line-height: 1;
}
[data-theme="dark"] .dash-tile-stat.highlight {
    background: linear-gradient(135deg, var(--card) 0%, #1e1b4b 100%);
}

.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.card-header h2 { font-size: 1rem; font-weight: 700; }
.card-body { padding: 20px; }

/* ========== TABLES (responsive) ========== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; font-size: .875rem; }

th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--border); }
th {
    background: var(--bg-alt);
    font-weight: 600;
    color: var(--text-muted);
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    white-space: nowrap;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }

/* Mobile card list — hidden on desktop only when a table alternative exists */
.data-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.has-desktop-table .data-list { display: none; }

@media (max-width: 768px) {
    .has-desktop-table .table-desktop { display: none; }
    .has-desktop-table .data-list { display: flex; flex-direction: column; gap: 12px; }

    .data-card {
        background: var(--bg-alt);
        border-radius: var(--radius-sm);
        padding: 16px;
        border: 1px solid var(--border);
    }

    .data-card-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 12px;
    }

    .data-card-title { font-weight: 700; font-size: .95rem; }
    .data-card-sub { color: var(--text-muted); font-size: .8rem; }

    .data-card-row {
        display: flex;
        justify-content: space-between;
        font-size: .85rem;
        padding: 4px 0;
        color: var(--text-secondary);
    }

    .data-card-row strong { color: var(--text); }
    .data-card-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
}

.page-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
    gap: 8px;
}

/* ========== BADGES ========== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .3px;
}

.badge-pending, .badge-pending_manager, .badge-pending_hr { background: var(--warning-bg); color: #b45309; }
.badge-approved { background: var(--success-bg); color: #047857; }
.badge-rejected { background: var(--danger-bg); color: #b91c1c; }
.badge-cancelled { background: var(--bg-alt); color: var(--text-muted); }
.badge-active { background: var(--success-bg); color: #047857; }
.badge-inactive { background: var(--danger-bg); color: #b91c1c; }

/* ========== MODAL ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.6);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 300;
    padding: 0;
    backdrop-filter: blur(4px);
}

@media (min-width: 640px) {
    .modal-overlay { align-items: center; padding: 20px; }
}

.modal {
    background: var(--card);
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp .3s ease;
}

@media (min-width: 640px) {
    .modal { border-radius: var(--radius); animation: fadeIn .2s ease; }
}

@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: var(--card);
    z-index: 1;
}

.modal-header h2 { font-size: 1.1rem; font-weight: 700; }
.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.close-btn {
    background: var(--bg-alt);
    border: none;
    width: 36px; height: 36px;
    border-radius: 50%;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========== CALENDAR ========== */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
}

.cal-header {
    text-align: center;
    font-size: .7rem;
    font-weight: 700;
    color: var(--text-muted);
    padding: 8px 4px;
    text-transform: uppercase;
}

.cal-day {
    border-radius: var(--radius-sm);
    padding: 4px;
    font-size: .8rem;
    background: var(--bg-alt);
    border: 1px solid transparent;
    position: relative;
    min-height: 72px;
    display: flex;
    flex-direction: column;
}

.cal-day.other-month { opacity: .4; }
.cal-day-empty { min-height: 72px; pointer-events: none; visibility: hidden; }
.cal-day.today { border-color: var(--primary); background: var(--primary-light); }
.cal-day.holiday { background: #fef2f2; }
.cal-day.weekend { background: #f8fafc; }
.cal-day.non-working { background: #f1f5f9; }
.cal-day.non-working.has-leave,
.cal-day.non-working.busy { background: #f1f5f9; }
.cal-day.non-working .cal-day-count { display: none; }
.cal-day.non-working .cal-event:not(.cal-holiday) { display: none; }
.cal-day.has-leave { background: #ecfdf5; }
.cal-day.busy { background: linear-gradient(180deg, #ecfdf5 0%, #d1fae5 100%); }
.cal-day.cal-day-clickable { cursor: pointer; }
.cal-day.cal-day-clickable:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(99,102,241,.15); }
.cal-day.cal-day-selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }

.cal-day-num {
    font-weight: 700;
    font-size: .75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    margin-bottom: 4px;
}
.cal-day-count {
    font-size: .6rem;
    font-weight: 700;
    background: var(--primary);
    color: #fff;
    border-radius: 999px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.cal-event {
    font-size: .5rem;
    line-height: 1.25;
    background: var(--primary);
    color: #fff;
    border-radius: 4px;
    padding: 2px 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}
.cal-event.pending { background: #f59e0b; }
.cal-day-events {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.cal-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
}

.cal-nav-center {
    flex: 1;
    min-width: 0;
    text-align: center;
}

.cal-nav-center h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}

.cal-scope-hint {
    margin: 4px 0 0;
    font-size: .75rem;
}

.cal-nav-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 8px;
    flex-wrap: wrap;
}

.cal-month-card {
    margin-bottom: 20px;
    min-width: 0;
    max-width: 100%;
}

.cal-month-card-body {
    padding: 12px;
    min-width: 0;
}

.cal-grid-wrap {
    min-width: 0;
    max-width: 100%;
}

.cal-event-more {
    background: #64748b !important;
    font-weight: 700;
    text-align: center;
}

.cal-day-popup-trigger {
    cursor: pointer;
    border: none;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

button.cal-day-count {
    cursor: pointer;
    border: none;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

button.cal-day-count:active,
button.cal-event-more:active {
    transform: scale(0.96);
}

.cal-day-modal {
    max-width: 520px;
}

.cal-day-modal-sub {
    margin: 4px 0 0;
    font-size: .8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.cal-day-modal-body {
    padding: 12px 16px 20px;
}

.cal-day-modal-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: min(60vh, 480px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.cal-day-leave-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.cal-day-leave-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: .75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.cal-day-leave-info {
    flex: 1;
    min-width: 0;
}

.cal-day-leave-name {
    font-weight: 700;
    font-size: .9rem;
    line-height: 1.25;
}

.cal-day-leave-meta {
    font-size: .75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.cal-day-leave-dates {
    font-size: .72rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.cal-day-leave-row .badge {
    flex-shrink: 0;
    font-size: .65rem;
}

.cal-nav h3 { font-size: 1.1rem; font-weight: 700; }

@media (max-width: 767px) {
    .cal-nav {
        display: grid;
        grid-template-columns: 44px 1fr 44px;
        grid-template-rows: auto 44px;
        gap: 10px 8px;
        align-items: center;
    }
    .cal-nav > #prevMonth { grid-area: 2 / 1; }
    .cal-nav > .cal-nav-center { grid-area: 1 / 1 / 2 / 4; }
    .cal-nav > #nextMonth { grid-area: 2 / 3; }
    .cal-nav-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .cal-nav-actions .btn {
        width: 100%;
    }
    .cal-month-card-body {
        padding: 6px;
    }
    .calendar-grid {
        gap: 2px;
        min-width: 0;
    }
    .cal-header {
        font-size: .62rem;
        padding: 4px 1px;
        letter-spacing: -.02em;
    }
    .cal-day {
        min-height: 40px;
        padding: 2px;
        min-width: 0;
    }
    .cal-day-empty {
        min-height: 40px;
    }
    .cal-day-num {
        font-size: .68rem;
        margin-bottom: 1px;
    }
    .cal-day-count {
        font-size: .55rem;
        min-width: 14px;
        height: 14px;
        padding: 0 3px;
    }
    .cal-day-events {
        gap: 1px;
    }
    .cal-event {
        font-size: .5rem;
        padding: 1px 2px;
        line-height: 1.2;
    }
    .cal-event-more {
        font-size: .55rem;
        width: 100%;
    }
    button.cal-day-count {
        min-width: 18px;
        height: 18px;
    }
    .cal-panel-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .cal-panel-expand-btn {
        width: 100%;
        justify-content: center;
    }
    .month-leaves-toolbar input,
    .month-leaves-toolbar select {
        min-width: 0;
        width: 100%;
        flex: 1 1 100%;
    }
    .month-leaves-filter-hint.visible {
        flex-direction: column;
        align-items: stretch;
    }
    .month-leaves-filter-hint.visible .btn {
        width: 100%;
    }
}

/* Month leaves — rich list */
.month-leaves-card .card-header {
    flex-wrap: wrap;
    gap: 12px;
}
.month-leaves-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 16px 20px 0;
}
@media (min-width: 640px) {
    .month-leaves-stats { grid-template-columns: repeat(4, 1fr); }
}
.ml-stat {
    background: linear-gradient(135deg, var(--bg-alt) 0%, var(--card) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    position: relative;
    overflow: hidden;
}
.ml-stat::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    opacity: .85;
}
.ml-stat-value {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.1;
}
.ml-stat-label {
    font-size: .72rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.ml-stat.pending .ml-stat-value { color: #d97706; }
.ml-stat.approved .ml-stat-value { color: #059669; }

.month-leaves-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    align-items: center;
}
.month-leaves-toolbar input,
.month-leaves-toolbar select {
    flex: 1;
    min-width: 140px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card);
    font-size: .85rem;
}
.month-leaves-filter-hint {
    width: 100%;
    font-size: .8rem;
    color: var(--primary-dark);
    background: var(--primary-light);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    display: none;
}
.month-leaves-filter-hint.visible { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.month-leaves-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 16px 20px 20px;
}
@media (min-width: 768px) {
    .month-leaves-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1200px) {
    .month-leaves-grid { grid-template-columns: repeat(3, 1fr); }
}

.ml-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
    display: flex;
    flex-direction: column;
}
.ml-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
}
.ml-card-accent { height: 4px; }
.ml-card-body { padding: 14px 16px 16px; flex: 1; display: flex; flex-direction: column; gap: 12px; }
.ml-card-top {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.ml-card-avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: .85rem;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.ml-card-meta { flex: 1; min-width: 0; }
.ml-card-name {
    font-weight: 700;
    font-size: .95rem;
    margin: 0 0 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ml-card-sub {
    font-size: .78rem;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.ml-dept-chip {
    background: var(--bg-alt);
    border-radius: 999px;
    padding: 2px 8px;
    font-size: .7rem;
    font-weight: 600;
}
.ml-type-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .75rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--bg-alt);
}
.ml-type-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.ml-dates {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.ml-date-box {
    background: var(--bg-alt);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
}
.ml-date-box span {
    display: block;
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 2px;
}
.ml-date-box strong { font-size: .82rem; }
.ml-timeline-wrap { margin-top: auto; }
.ml-timeline-label {
    display: flex;
    justify-content: space-between;
    font-size: .7rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 600;
}
.ml-timeline {
    height: 8px;
    background: var(--bg-alt);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}
.ml-timeline-bar {
    position: absolute;
    top: 0;
    bottom: 0;
    border-radius: 999px;
    min-width: 4px;
}
.ml-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding-top: 4px;
    border-top: 1px dashed var(--border);
}
.ml-days-badge {
    font-size: .8rem;
    font-weight: 800;
    color: var(--primary-dark);
    background: var(--primary-light);
    padding: 4px 10px;
    border-radius: 999px;
}

/* Calendar collapsible panels */
.cal-panel-card { overflow: hidden; }
.cal-panel-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.cal-panel-header:hover { background: var(--bg-alt); }
.cal-panel-header-left { flex: 1; min-width: 0; }
.cal-panel-header-top {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.cal-panel-summary {
    margin: 6px 0 0;
    font-size: .82rem;
    color: var(--text-muted);
    font-weight: 500;
}
.cal-panel-expand-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.cal-panel-chevron {
    display: inline-block;
    transition: transform .2s ease;
    font-size: .7rem;
}
.cal-panel-chevron.open { transform: rotate(180deg); }
.cal-panel-body {
    border-top: 1px solid var(--border);
    overflow: hidden;
    transition: max-height .35s ease, opacity .25s ease, padding .25s ease;
    max-height: 8000px;
    opacity: 1;
    padding: 0;
}
.cal-panel-body.collapsed {
    max-height: 0;
    opacity: 0;
    border-top-color: transparent;
    pointer-events: none;
}

.today-leaves-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 16px 20px 0;
}
.tl-stat {
    background: linear-gradient(135deg, var(--bg-alt) 0%, var(--card) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
}
.tl-stat-value {
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1.1;
}
.tl-stat-label {
    font-size: .7rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.tl-stat.pending .tl-stat-value { color: #d97706; }
.tl-stat.approved .tl-stat-value { color: #059669; }
.today-leaves-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 16px 20px 20px;
}
@media (min-width: 640px) {
    .today-leaves-grid { grid-template-columns: repeat(2, 1fr); }
}
.tl-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.tl-card-accent { height: 3px; }
.tl-card-body { padding: 12px 14px; }
.tl-card-top {
    display: flex;
    gap: 12px;
    align-items: center;
}
.tl-card-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: .85rem;
    flex-shrink: 0;
}
.tl-card-meta { flex: 1; min-width: 0; }
.tl-card-name {
    margin: 0;
    font-size: .95rem;
    font-weight: 700;
}
.tl-card-sub {
    margin: 4px 0 0;
    font-size: .8rem;
    color: var(--text-muted);
}

/* Team conflicts — collapsible panel */
.conflicts-card { overflow: hidden; }
.conflicts-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.conflicts-header:hover { background: var(--bg-alt); }
.conflicts-header-left { flex: 1; min-width: 0; }
.conflicts-header-top {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.conflicts-summary {
    margin: 6px 0 0;
    font-size: .82rem;
    color: var(--text-muted);
    font-weight: 500;
}
.conflicts-expand-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.conflicts-chevron {
    display: inline-block;
    transition: transform .2s ease;
    font-size: .7rem;
}
.conflicts-chevron.open { transform: rotate(180deg); }
.conflicts-body {
    border-top: 1px solid var(--border);
    overflow: hidden;
    transition: max-height .35s ease, opacity .25s ease, padding .25s ease;
    max-height: 4000px;
    opacity: 1;
    padding: 0;
}
.conflicts-body.collapsed {
    max-height: 0;
    opacity: 0;
    border-top-color: transparent;
    pointer-events: none;
}
.conflicts-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 16px 20px 0;
}
@media (min-width: 640px) {
    .conflicts-stats { grid-template-columns: repeat(4, 1fr); }
}
.cf-stat {
    background: linear-gradient(135deg, var(--bg-alt) 0%, var(--card) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
}
.cf-stat.warn .cf-stat-value { color: #d97706; }
.cf-stat-value {
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1.1;
}
.cf-stat-label {
    font-size: .7rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.conflicts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 16px 20px 20px;
}
@media (min-width: 768px) {
    .conflicts-grid { grid-template-columns: repeat(2, 1fr); }
}
.cf-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform .15s ease, box-shadow .15s ease;
}
.cf-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.cf-card-accent { height: 4px; }
.cf-card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.cf-card-top {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.cf-dept-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.cf-card-meta { flex: 1; min-width: 0; }
.cf-dept-name {
    margin: 0;
    font-size: .95rem;
    font-weight: 700;
}
.cf-dept-sub {
    margin: 2px 0 0;
    font-size: .78rem;
    color: var(--text-muted);
}
.cf-severity-badge {
    font-size: .72rem;
    font-weight: 800;
    padding: 5px 10px;
    border-radius: 999px;
    white-space: nowrap;
}
.cf-dates {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.cf-date-box {
    background: var(--bg-alt);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
}
.cf-date-box span {
    display: block;
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 2px;
}
.cf-date-box strong { font-size: .82rem; }
.cf-timeline-wrap { margin-top: 0; }
.cf-people {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 4px;
    border-top: 1px dashed var(--border);
}
.cf-person-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .75rem;
    font-weight: 600;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 4px 10px 4px 4px;
}
.cf-person-chip.pending {
    border-color: #fcd34d;
    background: #fffbeb;
}
.cf-person-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    font-size: .55rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.cf-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 28px 16px 12px;
}
.cf-empty-icon { font-size: 2.5rem; margin-bottom: 8px; }
.cf-empty h3 { margin: 0 0 6px; font-size: 1rem; }
.cf-empty p { margin: 0; color: var(--text-muted); font-size: .85rem; max-width: 420px; margin-inline: auto; }

/* ========== TEAM / DEPT ========== */
.team-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

@media (min-width: 640px) {
    .team-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
    .team-grid { grid-template-columns: repeat(3, 1fr); }
}

.person-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: box-shadow var(--transition);
}

.person-card:hover { box-shadow: var(--shadow); }

.person-avatar {
    width: 48px; height: 48px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    flex-shrink: 0;
}

.person-info h3 { font-size: .95rem; font-weight: 700; }
.person-info p { font-size: .8rem; color: var(--text-muted); }

.dept-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transition: all var(--transition);
}

.dept-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }

.dept-card h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 4px; }
.dept-meta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; font-size: .85rem; color: var(--text-secondary); }

/* ========== NOTIFICATIONS ========== */
.notif-list { display: flex; flex-direction: column; gap: 8px; }

.notif-item {
    display: flex;
    gap: 14px;
    padding: 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}

.notif-item:hover { background: var(--bg-alt); }
.notif-item.unread { border-left: 3px solid var(--primary); background: var(--primary-light); }

.notif-icon {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--bg-alt);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.notif-content h4 { font-size: .9rem; font-weight: 600; margin-bottom: 2px; }
.notif-content p { font-size: .8rem; color: var(--text-secondary); }
.notif-time { font-size: .7rem; color: var(--text-muted); margin-top: 4px; }

/* ========== FAB ========== */
.fab {
    position: fixed;
    bottom: calc(var(--nav-height) + 16px);
    right: 20px;
    width: 56px; height: 56px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    box-shadow: 0 4px 20px rgba(99,102,241,.4);
    cursor: pointer;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition);
}

.fab:hover { transform: scale(1.05); }

@media (min-width: 1024px) {
    .fab { bottom: 32px; }
}

/* ========== MISC ========== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; opacity: .5; }

.tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-alt);
    padding: 4px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    overflow-x: auto;
}

.tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
}

.tab.active { background: var(--card); color: var(--primary); box-shadow: var(--shadow); }

.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-bar select {
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .875rem;
    background: var(--card);
    min-width: 140px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-alt);
    border-radius: 20px;
    font-size: .8rem;
    color: var(--text-secondary);
}
.chip-warning { background: #fffbeb; color: #b45309; font-weight: 700; }
.chip-success { background: #ecfdf5; color: #047857; font-weight: 700; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.progress-bar {
    height: 8px;
    background: var(--bg-alt);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 4px;
    transition: width .3s ease;
}

.balance-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 12px;
}

.balance-card h4 { font-size: .9rem; color: var(--text-secondary); margin-bottom: 8px; }
.balance-card .balance-num { font-size: 2rem; font-weight: 800; color: var(--primary); }
.balance-card .balance-detail { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }

/* ========== ROLES ========== */
.roles-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

@media (min-width: 640px) {
    .roles-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1200px) {
    .roles-grid { grid-template-columns: repeat(3, 1fr); }
}

.role-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow var(--transition), transform var(--transition);
}

.role-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }

.role-card-top {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid var(--border);
}

.role-icon {
    width: 48px; height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
    color: #fff;
}

.role-icon.role-admin { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.role-icon.role-hr_manager { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.role-icon.role-manager { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.role-icon.role-employee { background: linear-gradient(135deg, #10b981, #059669); }
.role-icon.role-default { background: linear-gradient(135deg, #64748b, #475569); }

.role-card-top h3 { font-size: 1.05rem; font-weight: 700; }
.role-card-top .role-slug { font-size: .75rem; color: var(--text-muted); font-family: monospace; }

.role-card-body { padding: 20px; flex: 1; }
.role-card-body .role-desc { color: var(--text-secondary); font-size: .85rem; margin-bottom: 16px; }

.role-perm-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.role-perm-count {
    font-size: .8rem;
    color: var(--text-muted);
    font-weight: 600;
}

.role-perm-count strong { color: var(--primary); font-size: 1.1rem; }

.module-tags { display: flex; flex-wrap: wrap; gap: 6px; }

.module-tag {
    font-size: .68rem;
    font-weight: 600;
    padding: 4px 9px;
    border-radius: 6px;
    background: var(--primary-light);
    color: var(--primary-dark);
    text-transform: capitalize;
}

.role-card-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-alt);
}

/* Permission editor in modal */
.perm-search {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .9rem;
    margin-bottom: 16px;
}

.perm-modules { display: flex; flex-direction: column; gap: 14px; }

.perm-module {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.perm-module-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-alt);
    cursor: pointer;
    user-select: none;
}

.perm-module-head .pm-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: .9rem;
    text-transform: capitalize;
}

.perm-module-head .pm-icon { font-size: 1.1rem; }

.pm-count {
    font-size: .72rem;
    color: var(--text-muted);
    font-weight: 600;
    background: var(--card);
    padding: 2px 8px;
    border-radius: 10px;
}

.perm-module-body {
    padding: 6px 16px 12px;
    display: flex;
    flex-direction: column;
}

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

.perm-row:last-child { border-bottom: none; }
.perm-row .perm-info { min-width: 0; }
.perm-row .perm-name { font-weight: 600; font-size: .85rem; }
.perm-row .perm-slug { font-size: .72rem; color: var(--text-muted); font-family: monospace; }

/* Toggle switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.switch .slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #cbd5e1;
    border-radius: 24px;
    transition: background .2s;
}

.switch .slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }

.module-toggle-all {
    font-size: .72rem;
    color: var(--primary);
    cursor: pointer;
    font-weight: 600;
    background: none;
    border: none;
    padding: 0;
}

.perm-module-head .pm-actions { display: flex; align-items: center; gap: 12px; }

.role-system-badge {
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--warning);
    background: var(--warning-bg);
    padding: 3px 8px;
    border-radius: 6px;
}

/* ========== DARK MODE ========== */
[data-theme="dark"] {
    --primary-light: #1e1b4b;
    --bg: #0b1120;
    --bg-alt: #1e293b;
    --card: #111827;
    --text: #e2e8f0;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border: #1f2937;
    --sidebar: #020617;
    --sidebar-hover: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-text-strong: #f8fafc;
    --sidebar-muted: #64748b;
    --sidebar-border: rgba(255,255,255,.07);
    --sidebar-active-bg: rgba(99,102,241,.22);
    --sidebar-active-text: #c7d2fe;
    --success-bg: #064e3b;
    --warning-bg: #78350f;
    --danger-bg: #7f1d1d;
    --shadow: 0 1px 3px rgba(0,0,0,.4);
    --shadow-lg: 0 10px 40px rgba(0,0,0,.5);
}

[data-theme="dark"] body { background: var(--bg); }
[data-theme="dark"] tr:hover td { background: rgba(255,255,255,.03); }
[data-theme="dark"] .stat-card::after { background: rgba(99,102,241,.15); }
[data-theme="dark"] .stat-card.highlight { background: linear-gradient(135deg, var(--card) 0%, #1e1b4b 100%); }
[data-theme="dark"] .module-tag { background: #1e1b4b; color: #a5b4fc; }
[data-theme="dark"] .switch .slider { background: #475569; }
[data-theme="dark"] .alert-error { background: var(--danger-bg); color: #fca5a5; }
[data-theme="dark"] .alert-success { background: var(--success-bg); color: #6ee7b7; }
[data-theme="dark"] .alert-warning { background: var(--warning-bg); color: #fcd34d; }

/* ========== TOASTS ========== */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: calc(100vw - 32px);
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    box-shadow: var(--shadow-lg);
    font-size: .9rem;
    font-weight: 500;
    min-width: 260px;
    transform: translateX(120%);
    opacity: 0;
    transition: transform .25s cubic-bezier(.4,0,.2,1), opacity .25s;
}

.toast.show { transform: translateX(0); opacity: 1; }
.toast-icon {
    width: 24px; height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: .8rem;
    flex-shrink: 0;
}
.toast-success { border-left-color: var(--success); }
.toast-success .toast-icon { background: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-error .toast-icon { background: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-warning .toast-icon { background: var(--warning); }
.toast-info .toast-icon { background: var(--primary); }
.toast-progress { min-width: 280px; }
.toast-progress .toast-msg { white-space: pre-wrap; }

@media (max-width: 600px) {
    .toast-container { top: auto; bottom: calc(var(--nav-height) + 12px); left: 16px; right: 16px; }
    .toast { transform: translateY(120%); min-width: 0; width: 100%; }
    .toast.show { transform: translateY(0); }
}

/* ========== EXPORT MENU ========== */
.export-toolbar { display: flex; justify-content: flex-end; }
.export-menu { position: relative; }

.export-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    padding: 6px;
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: all var(--transition);
}

.export-dropdown.open { opacity: 1; visibility: visible; transform: translateY(0); }

.export-dropdown button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: .85rem;
    font-weight: 500;
    text-align: left;
    border-radius: 6px;
    cursor: pointer;
}

.export-dropdown button:hover { background: var(--bg-alt); }

/* ========== TOOLBAR (search + actions on one row) ========== */
.toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.toolbar .toolbar-search { flex: 1; min-width: 180px; }
.toolbar .toolbar-actions { display: flex; gap: 8px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.toolbar-wrap select { padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font-size: .9rem; }
.toolbar-wrap .toolbar-search { min-width: 220px; }
@media (max-width: 768px) {
    .toolbar-wrap .toolbar-search,
    .toolbar-wrap select { width: 100%; min-width: 0; }
    .toolbar-wrap .toolbar-actions { width: 100%; margin-left: 0; justify-content: space-between; }
}

/* ========== SKELETON LOADER ========== */
.skeleton {
    background: linear-gradient(90deg, var(--bg-alt) 25%, var(--border) 37%, var(--bg-alt) 63%);
    background-size: 400% 100%;
    animation: skeleton 1.4s ease infinite;
    border-radius: var(--radius-sm);
}
@keyframes skeleton { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.skeleton-row { height: 56px; margin-bottom: 8px; }

/* ========== CHARTS / REPORTS ========== */
.reports-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    min-width: 0;
    max-width: 100%;
}
@media (min-width: 900px) {
    .reports-grid { grid-template-columns: repeat(2, 1fr); }
    .reports-grid .span-2 { grid-column: 1 / -1; }
}
.chart-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    min-width: 0;
    max-width: 100%;
}
.chart-card h3 {
    font-size: .95rem;
    font-weight: 700;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.chart-canvas-wrap {
    position: relative;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: 280px;
    overflow: hidden;
}
.chart-canvas-wrap canvas {
    display: block;
    max-width: 100%;
}

@media (max-width: 767px) {
    .reports-grid,
    .sales-reports-page,
    .reports-hub-page {
        min-width: 0;
        max-width: 100%;
    }
    .chart-card {
        padding: 14px;
    }
    .chart-canvas-wrap {
        height: 240px;
    }
    .chart-canvas-wrap.chart-canvas-wrap--legend-bottom {
        height: 300px;
    }
    .sales-reports-toolbar .form-group select {
        min-width: 0 !important;
        width: 100%;
    }
    .sales-reports-toolbar {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
    .sales-customer-search {
        min-width: 0;
        max-width: 100%;
        width: 100%;
    }
    .sales-table-head {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .sales-table-head h3 {
        flex: none;
        width: 100%;
        font-size: .9rem;
        line-height: 1.35;
    }
    .sales-table-count {
        display: block;
        margin-top: 4px;
        font-size: .8rem;
    }
    .sales-table-head-tools {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .sales-table-head .export-toolbar {
        width: 100%;
        justify-content: flex-start;
    }
    .sales-table-head .export-menu {
        width: 100%;
    }
    .sales-table-head .export-menu > .btn {
        width: 100%;
        justify-content: center;
    }
}

.sales-reports-page {
    min-width: 0;
    max-width: 100%;
}
.sales-reports-page .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.sales-table-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.sales-table-head h3 {
    margin-bottom: 0;
    flex: 1;
    min-width: 0;
}
.sales-table-head .export-toolbar {
    flex-shrink: 0;
}
.sales-reports-toolbar {
    flex-wrap: wrap;
    gap: 10px;
}
.sales-table-head-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    min-width: 0;
}
.sales-customer-search {
    min-width: 200px;
    max-width: 280px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: .875rem;
    background: var(--card);
    color: var(--text);
}
.sales-diff-up { color: var(--success); }
.sales-diff-down { color: var(--danger); }
.sales-customers-table-wrap {
    max-height: 520px;
    overflow: auto;
}
.sales-customers-table-wrap thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--card);
}
.sales-reports-page #customerHeadRow [data-sort] {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.sales-reports-page #customerHeadRow [data-sort]:hover {
    color: var(--primary);
}
.sales-reports-page .sort-ind {
    display: inline-block;
    min-width: 12px;
    font-size: .65rem;
    color: var(--primary);
}
.sales-reports-page .num {
    text-align: right;
    white-space: nowrap;
}
.sales-customer-link {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}
.sales-customer-link:hover {
    text-decoration: underline;
}
.sales-table-count {
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.sales-inactive-hint {
    font-size: .85rem;
    color: var(--text-secondary);
    margin: -8px 0 14px;
}
.sales-inactive-table-wrap {
    max-height: 320px;
}

/* Sales KPIs */
.kpi-segment-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 280px;
    overflow-y: auto;
}
.kpi-segment-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-alt);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: border-color var(--transition), background var(--transition);
}
.kpi-segment-chip:hover,
.kpi-segment-chip:focus {
    border-color: var(--primary);
    background: var(--primary-light);
}
.kpi-segment-label {
    flex: 1;
    font-size: .82rem;
    font-weight: 600;
}
.kpi-segment-chip strong {
    font-size: .95rem;
    min-width: 2rem;
    text-align: right;
}
.kpi-segment-chip small {
    font-size: .72rem;
    color: var(--text-muted);
    min-width: 4.5rem;
    text-align: right;
}
.sales-kpi-segment-select {
    min-width: 160px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    font-size: .85rem;
}
.sales-kpis-page .executive-kpi-grid {
    margin-bottom: 4px;
}
@media (max-width: 767px) {
    .sales-kpis-page .sales-table-head {
        flex-direction: column;
        align-items: stretch;
    }
    .sales-kpi-segment-select {
        width: 100%;
        min-width: 0;
    }
}
.sales-table-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
.sales-pagination-info {
    font-size: .82rem;
    color: var(--text-secondary);
}
.sales-customers-table-wrap.is-loading {
    opacity: .55;
    pointer-events: none;
}

.dq-issues-table td.num { text-align: right; white-space: nowrap; }

/* Executive dashboard */
.executive-dashboard-page { max-width: 1200px; }
.executive-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}
.executive-title { font-size: 1.6rem; font-weight: 800; margin: 0 0 4px; }
.executive-sub { font-size: .85rem; color: var(--text-muted); margin: 0; }
.executive-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}
.executive-kpi-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
.executive-kpi-label {
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 8px;
}
.executive-kpi-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1.1;
    color: var(--text);
}
.executive-kpi-sub { font-size: .82rem; margin-top: 6px; color: var(--text-muted); }
.exec-positive { color: #10b981; font-weight: 600; }
.exec-negative { color: #ef4444; font-weight: 600; }
.executive-migration-box { display: flex; flex-direction: column; gap: 10px; }
.executive-migration-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .9rem;
}
.executive-links { display: flex; flex-wrap: wrap; gap: 8px; }

/* Report builder */
.builder-columns-box {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
}
.builder-col-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .88rem;
    cursor: pointer;
}
.builder-api-list { margin: 0; padding-left: 20px; }
.builder-api-list code { font-size: .82rem; }

.reports-hub-intro {
    color: var(--text-secondary);
    font-size: .92rem;
    margin-bottom: 20px;
    max-width: 640px;
}
.reports-hub-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}
@media (min-width: 700px) {
    .reports-hub-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1100px) {
    .reports-hub-grid { grid-template-columns: repeat(3, 1fr); }
}
.reports-hub-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--card);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    transition: transform .15s, box-shadow .15s, border-color .15s;
    min-height: 120px;
}
.reports-hub-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    text-decoration: none;
    color: inherit;
}
.reports-hub-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.reports-hub-card-indigo .reports-hub-card-icon { background: rgba(99,102,241,.12); }
.reports-hub-card-rose .reports-hub-card-icon { background: rgba(229,115,115,.15); }
.reports-hub-card-teal .reports-hub-card-icon { background: rgba(6,182,212,.12); }
.reports-hub-card-indigo:hover { border-color: #6366f1; }
.reports-hub-card-rose:hover { border-color: #e57373; }
.reports-hub-card-teal:hover { border-color: #06b6d4; }
.reports-hub-card-amber .reports-hub-card-icon { background: rgba(245,158,11,.14); }
.reports-hub-card-amber:hover { border-color: #f59e0b; }

/* Report bookmark bar (saved views) */
.report-bookmark-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    margin: 0 0 16px;
    padding: 10px 14px;
    background: var(--surface-elevated, #f8fafc);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 10px;
}
.report-bookmark-actions { flex-shrink: 0; }
.report-bookmark-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}
.report-bookmark-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: .78rem;
    font-weight: 600;
    color: var(--primary, #6366f1);
    background: rgba(99,102,241,.08);
    border: 1px solid rgba(99,102,241,.25);
    border-radius: 999px;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.report-bookmark-chip:hover {
    background: rgba(99,102,241,.16);
    border-color: #6366f1;
}
.report-bookmark-del {
    margin-left: -4px;
    margin-right: 4px;
    width: 20px;
    height: 20px;
    padding: 0;
    font-size: 1rem;
    line-height: 1;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}
.report-bookmark-del:hover { color: #ef4444; background: rgba(239,68,68,.1); }
.report-bookmark-empty {
    font-size: .78rem;
    color: var(--text-muted);
}

.stat-card .stat-sub {
    font-size: .75rem;
    color: var(--text-muted);
    margin-top: 4px;
}
.reports-hub-card-body h2 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 6px;
}
.reports-hub-card-body p {
    font-size: .82rem;
    color: var(--text-secondary);
    line-height: 1.45;
    margin: 0;
}
.reports-hub-card-arrow {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 1.1rem;
    align-self: center;
}

.reports-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .82rem;
    color: var(--text-muted);
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.reports-breadcrumb a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}
.reports-breadcrumb a:hover { text-decoration: underline; }
.reports-breadcrumb-sep { opacity: .5; }

.reports-quality-grid {
    display: grid;
    gap: 14px;
}
@media (min-width: 700px) {
    .reports-quality-grid { grid-template-columns: repeat(2, 1fr); }
}
.reports-quality-item {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-alt);
}
.reports-quality-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    font-size: .85rem;
    margin-bottom: 8px;
}
.reports-quality-head small {
    font-weight: 500;
    color: var(--text-muted);
}
.reports-quality-bar {
    height: 8px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}
.reports-quality-bar span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #e57373, #6366f1);
    min-width: 2px;
}

/* Subtle entrance animation for cards/stats */
.stat-card, .chart-card, .card, .role-card, .person-card, .dept-card {
    animation: fadeUp .4s ease both;
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.stat-card { transition: transform var(--transition), box-shadow var(--transition); }
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

/* ========== LEAVE BALANCES GRID ========== */
.bal-emp-group { margin-bottom: 28px; }

.bal-emp-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.bal-avatar {
    width: 42px; height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .85rem;
    flex-shrink: 0;
}

.bal-emp-name { font-weight: 700; font-size: .95rem; }
.bal-emp-sub { font-size: .78rem; color: var(--text-muted); }

.balance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.bal-card {
    position: relative;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition);
}

.bal-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.bal-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--bal-color, var(--primary));
}

.bal-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 18px;
}

.bal-card-head h4 { font-size: .95rem; font-weight: 700; line-height: 1.3; }

.bal-type-chip {
    font-size: .62rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    color: var(--bal-color, var(--primary));
    border: 1px solid var(--bal-color, var(--primary));
    text-transform: uppercase;
    letter-spacing: .5px;
    white-space: nowrap;
    flex-shrink: 0;
}

.bal-ring-wrap { display: flex; align-items: center; gap: 16px; }

.bal-ring {
    --val: 0;
    width: 86px; height: 86px;
    border-radius: 50%;
    flex-shrink: 0;
    background: conic-gradient(var(--bal-color, var(--primary)) calc(var(--val) * 1%), var(--bg-alt) 0);
    display: flex;
    align-items: center;
    justify-content: center;
}

.bal-ring-inner {
    width: 64px; height: 64px;
    border-radius: 50%;
    background: var(--card);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.bal-ring-inner .num { font-size: 1.5rem; font-weight: 800; color: var(--text); line-height: 1; }
.bal-ring-inner .lbl { font-size: .58rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-top: 2px; }

.bal-meta { flex: 1; display: flex; flex-direction: column; gap: 7px; min-width: 0; }

.bal-meta .row { display: flex; justify-content: space-between; font-size: .8rem; }
.bal-meta .row span { color: var(--text-muted); }
.bal-meta .row strong { color: var(--text); font-weight: 700; }

.bal-low {
    position: absolute;
    top: 14px; right: 14px;
    font-size: .6rem;
    font-weight: 700;
    color: var(--danger);
    background: var(--danger-bg);
    padding: 3px 8px;
    border-radius: 20px;
    z-index: 1;
}

/* ========== TOP LOADING BAR ========== */
.top-progress {
    position: fixed;
    top: 0; left: 0;
    height: 3px;
    width: 0;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    box-shadow: 0 0 10px rgba(99,102,241,.6);
    z-index: 2000;
    opacity: 0;
    transition: width .3s ease, opacity .3s ease;
}
.top-progress.active { opacity: 1; }

/* ========== ACCESSIBILITY & POLISH ========== */
html { scroll-behavior: smooth; }

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Custom scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--text-muted) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 8px;
    border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Styled select with custom arrow */
.form-group select,
.filter-bar select,
.toolbar select {
    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 fill='%2394a3b8' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

/* Confirm/prompt dialog appears above other modals */
.confirm-overlay { z-index: 400; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ========== PRINT ========== */
@media print {
    .sidebar, .bottom-nav, .topbar, .fab, .export-toolbar, .filter-bar,
    .page-toolbar, .tabs, .toast-container, .sidebar-overlay { display: none !important; }
    .main-area { margin-left: 0 !important; }
    .page-content { padding: 0 !important; }
    .card, .chart-card, .stat-card { box-shadow: none !important; border: 1px solid #ddd !important; break-inside: avoid; }
    body { background: #fff !important; }
}

/* ========== GROUP MODAL ========== */
.modal-group { max-width: 600px; }

.form-group label .optional {
    font-weight: 400;
    color: var(--text-muted);
    font-size: .8em;
}

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

.member-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.member-section-head label {
    font-weight: 600;
    font-size: .875rem;
    color: var(--text-secondary);
    margin: 0;
}

.member-count-chip {
    font-size: .75rem;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-light);
    padding: 3px 10px;
    border-radius: 20px;
}

.member-search {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: .9rem;
    margin-bottom: 10px;
}

.member-search:focus {
    outline: none;
    border-color: var(--primary);
}

.member-picker {
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-alt);
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.member-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    background: var(--card);
    border: 1.5px solid transparent;
    transition: border-color var(--transition), background var(--transition);
}

.member-row:hover { background: var(--bg); }

.member-row.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

.member-row input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.member-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    font-size: .8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.member-info {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    flex: 1;
    min-width: 0;
}

.member-info strong { font-size: .9rem; }
.member-info small { color: var(--text-muted); font-size: .75rem; }

.member-check {
    width: 22px; height: 22px;
    border-radius: 50%;
    border: 2px solid var(--border);
    color: transparent;
    font-size: .75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition);
}

.member-row.selected .member-check {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.member-empty {
    padding: 24px 12px;
    text-align: center;
    color: var(--text-muted);
    font-size: .85rem;
}

/* ========== CUSTOMERS ========== */
.customers-page { --cust-accent: #e57373; --cust-accent-dark: #d45c5c; }

.cust-page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.cust-page-title {
    font-size: 1.35rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.cust-title-icon { font-size: 1.5rem; }

.cust-page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.btn-cust {
    background: var(--cust-accent);
    color: #fff;
    border: none;
    font-weight: 700;
    letter-spacing: .02em;
}
.btn-cust:hover { background: var(--cust-accent-dark); color: #fff; }

.cust-kpi-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    margin-bottom: 20px;
}
@media (min-width: 640px) { .cust-kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .cust-kpi-grid { grid-template-columns: repeat(4, 1fr); } }

.cust-kpi {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
}

.cust-kpi-icon {
    width: 48px; height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}
.cust-kpi-icon.red { background: #fde8e8; }
.cust-kpi-icon.teal { background: #e0f7f4; }
.cust-kpi-icon.yellow { background: #fef9e7; }
.cust-kpi-icon.purple { background: #f3e8fd; }

.cust-kpi-label { font-size: .7rem; font-weight: 700; color: var(--text-muted); letter-spacing: .04em; }
.cust-kpi-value { font-size: 1.5rem; font-weight: 800; line-height: 1.2; }

.cust-toolbar { padding: 16px; margin-bottom: 16px; overflow: visible; }
.cust-filter-panel { padding: 16px; margin-bottom: 16px; overflow: visible; }
.cust-toolbar-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.cust-toolbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-left: auto; }
.cust-per-page {
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    font-size: .85rem;
}
.cust-search-wrap {
    flex: 1;
    min-width: 220px;
    position: relative;
    display: flex;
    align-items: center;
}
.cust-search-icon {
    position: absolute;
    left: 12px;
    font-size: .9rem;
    opacity: .55;
    pointer-events: none;
}
.cust-search-wrap .cust-search {
    padding-left: 38px;
    width: 100%;
}

.cust-quick-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}
.cust-quick-chip {
    border: 1.5px solid var(--border);
    background: var(--bg);
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .15s, background .15s, color .15s;
}
.cust-quick-chip:hover {
    border-color: var(--cust-accent);
    color: var(--cust-accent);
}
.cust-quick-chip.active {
    background: var(--cust-accent);
    border-color: var(--cust-accent);
    color: #fff;
}

.cust-adv-filters-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}
.cust-adv-toggle {
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer;
    padding: 6px 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.cust-adv-toggle:hover { color: var(--cust-accent); }
.cust-adv-toggle-icon { font-size: .7rem; }
.cust-filter-badge {
    font-size: .72rem;
    font-weight: 700;
    color: var(--cust-accent);
    background: rgba(220, 38, 38, .08);
    padding: 4px 10px;
    border-radius: 999px;
}
.cust-filter-reset { margin-left: auto; }

.cust-adv-filters {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
}
.cust-adv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}
.cust-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: .72rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: .03em;
    text-transform: uppercase;
}
.cust-field select,
.cust-field input[type="search"],
.cust-field input[type="date"] {
    padding: 9px 11px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: .85rem;
    font-weight: 500;
    text-transform: none;
    letter-spacing: normal;
}
.cust-field select:focus,
.cust-field input:focus {
    outline: none;
    border-color: var(--cust-accent);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .1);
}

.cust-filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
.cust-filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px 5px 10px;
    border-radius: 8px;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    font-size: .75rem;
    max-width: 100%;
}
.cust-filter-tag-label { color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.cust-filter-tag-val { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.cust-filter-tag-remove {
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0 2px;
}
.cust-filter-tag-remove:hover { color: #dc2626; }

#btnToggleColFilters.active {
    border-color: var(--cust-accent);
    color: var(--cust-accent);
    background: rgba(220, 38, 38, .06);
}

/* Column picker — fixed overlay (outside clipped .card containers) */
.cust-col-picker-panel {
    position: fixed;
    z-index: 1200;
    width: 340px;
    max-height: min(70vh, 520px);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 20px 50px -12px rgba(15, 23, 42, .35);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: custPickerIn .15s ease;
}
@keyframes custPickerIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}
.cust-col-picker-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px 10px;
    font-size: .8rem;
    font-weight: 700;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    background: var(--bg-alt);
}
.cust-col-picker-count {
    font-size: .72rem;
    font-weight: 700;
    color: var(--cust-accent);
    background: rgba(220, 38, 38, .08);
    padding: 3px 8px;
    border-radius: 999px;
}
.cust-col-picker-search-wrap { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.cust-col-picker-search {
    width: 100%;
    padding: 9px 12px;
    font-size: .85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
}
.cust-col-picker-search:focus {
    outline: none;
    border-color: var(--cust-accent);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .1);
}
.cust-col-picker-list {
    padding: 10px 12px;
    overflow-y: auto;
    flex: 1;
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
}
.cust-col-picker-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: .85rem;
    user-select: none;
    border: 1px solid transparent;
    transition: background .12s, border-color .12s;
}
.cust-col-picker-item:hover { background: var(--bg-alt); border-color: var(--border); }
.cust-col-picker-item input { accent-color: var(--cust-accent); width: 16px; height: 16px; flex-shrink: 0; }
.cust-col-picker-item span { flex: 1; line-height: 1.3; }
.cust-col-picker-empty {
    padding: 20px 12px;
    text-align: center;
    color: var(--text-muted);
    font-size: .85rem;
}
.cust-col-picker-foot {
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    gap: 8px;
    background: var(--bg-alt);
}

.cust-notes-cell {
    display: inline-block;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .8rem;
    color: var(--text-secondary);
}

/* Customers page: contain horizontal scroll inside table only */
.customers-page .page-content,
.customers-page #mainContent,
.customers-page #page-content {
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
}

.cust-table-card {
    padding: 0;
    overflow: hidden;
    max-width: 100%;
}

.cust-table-scroll {
    overflow-x: auto;
    overflow-y: visible;
    max-width: 100%;
    width: 100%;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
}

.cust-table-scroll .cust-table {
    width: max-content;
    min-width: 100%;
}
.cust-search { flex: 1; min-width: 200px; padding: 11px 14px; border: 1.5px solid var(--border); border-radius: 8px; background: var(--bg); }

.cust-filters {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}
.cust-filters select,
.cust-filters input {
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    min-width: 180px;
}

.cust-view-toggle {
    display: flex;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-left: auto;
}
.cust-view-toggle button {
    border: none;
    background: var(--bg);
    padding: 9px 16px;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-secondary);
}
.cust-view-toggle button.active {
    background: var(--cust-accent);
    color: #fff;
}

.cust-table-card { padding: 0; overflow: hidden; max-width: 100%; }
.cust-table { border-collapse: collapse; font-size: .85rem; }
.cust-table th {
    text-align: left;
    padding: 14px 12px;
    font-size: .7rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: .05em;
    border-bottom: 1px solid var(--border);
    background: var(--bg-alt);
}
.cust-grid-head th[data-sort] { cursor: pointer; user-select: none; white-space: nowrap; }
.cust-grid-head th[data-sort]:hover { color: var(--cust-accent); }
.cust-grid-head .sort-ind { display: inline-block; min-width: 12px; font-size: .65rem; color: var(--cust-accent); }

.cust-col-filters th {
    padding: 6px 8px 10px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.cust-col-filters.cust-col-filters-hidden,
#custFilterRow.cust-col-filters-hidden { display: none; }
.cust-col-filter-wrap {
    position: relative;
    display: flex;
    align-items: center;
    max-width: 160px;
}
.cust-col-filter-icon {
    position: absolute;
    left: 8px;
    font-size: .72rem;
    color: var(--text-muted);
    opacity: .7;
    pointer-events: none;
}
.cust-col-filter-clear {
    position: absolute;
    right: 4px;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 2px 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s, color .15s;
}
.cust-col-filter-clear.visible {
    opacity: 1;
    pointer-events: auto;
}
.cust-col-filter-clear:hover { color: #dc2626; }
.cust-col-input {
    width: 100%;
    min-width: 0;
    max-width: 160px;
    padding: 7px 22px 7px 22px;
    font-size: .75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
.cust-col-input::placeholder { color: var(--text-muted); opacity: .85; }
.cust-col-input:hover { border-color: #cbd5e1; }
.cust-col-input:focus {
    outline: none;
    border-color: var(--cust-accent);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .1);
    background: var(--card);
}
.cust-col-input:not(:placeholder-shown) {
    border-color: var(--cust-accent);
    background: rgba(220, 38, 38, .04);
}

.cust-branch-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 700;
    font-size: .8rem;
    color: var(--text-muted);
    background: var(--bg-alt);
}
.cust-branch-count.has-branches {
    color: var(--cust-accent);
    background: rgba(220, 38, 38, .08);
}
.cust-table td { padding: 14px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.cust-table tr:hover td { background: var(--bg-alt); }

.cust-code { color: var(--cust-accent); font-weight: 700; }
.cust-warn-tag { font-size: .65rem; font-weight: 700; color: var(--cust-accent); letter-spacing: .03em; }
.cust-link { color: var(--cust-accent); text-decoration: none; }
.cust-link:hover { text-decoration: underline; }

.cust-status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .03em;
}
.cust-status-active { background: #d1fae5; color: #047857; }
.cust-status-inactive { background: #f1f5f9; color: #64748b; }
.cust-status-lead { background: #fef3c7; color: #b45309; }
.cust-status-prospect { background: #ede9fe; color: #6d28d9; }

.cust-actions { display: flex; gap: 6px; }
.cust-act-btn {
    width: 32px; height: 32px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-alt);
    cursor: pointer;
    font-size: .9rem;
}
.cust-act-btn:hover { border-color: var(--cust-accent); }
.cust-act-btn.danger:hover { border-color: var(--danger); }

.cust-map-placeholder { padding: 48px 20px; }

.cust-section-title {
    font-size: .9rem;
    font-weight: 700;
    margin: 8px 0 12px;
    color: var(--text-secondary);
}

.cust-address-section {
    margin: 8px 0 16px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
}

.cust-map-preview-btn { margin-top: 4px; }

.cust-map-card {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-alt, var(--bg));
}

.cust-act-btn.cust-map-btn {
    color: #2563eb;
    border-color: rgba(37, 99, 235, .25);
}

.cust-act-btn.cust-map-btn:hover {
    border-color: #2563eb;
    background: rgba(37, 99, 235, .08);
}

.modal-cust-detail { max-width: 820px; padding: 0; overflow: hidden; }

.cust-detail-head {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 24px 24px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-alt);
}

.cust-detail-avatar {
    width: 56px; height: 56px;
    border-radius: 12px;
    background: var(--cust-accent);
    color: #fff;
    font-weight: 800;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cust-detail-meta { flex: 1; min-width: 0; }
.cust-detail-meta h2 { font-size: 1.15rem; margin: 0 0 8px; overflow-wrap: anywhere; word-break: normal; line-height: 1.3; }
.cust-detail-sub { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-size: .85rem; color: var(--text-muted); }
.cust-detail-actions { display: flex; gap: 8px; align-items: flex-start; flex-shrink: 0; }

@media (max-width: 600px) {
    .cust-detail-head {
        flex-wrap: wrap;
        gap: 12px;
        padding: 18px 16px 14px;
    }
    .cust-detail-avatar { width: 46px; height: 46px; font-size: 1rem; }
    .cust-detail-meta { flex: 1 1 auto; }
    .cust-detail-meta h2 { font-size: 1.05rem; }
    .cust-detail-actions {
        order: 3;
        flex-basis: 100%;
        width: 100%;
    }
    .cust-detail-actions .btn { flex: 1; justify-content: center; }
    .cust-detail-actions .close-btn {
        position: absolute;
        top: 14px;
        right: 14px;
    }
    .cust-detail-head { position: relative; }
    .cust-tab-body { padding: 16px; max-height: 60vh; }
}

.cust-tabs {
    display: flex;
    gap: 0;
    overflow-x: auto;
    border-bottom: 1px solid var(--border);
    padding: 0 12px;
    background: var(--card);
}
.cust-tab {
    border: none;
    background: none;
    padding: 14px 16px;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}
.cust-tab.active { color: var(--cust-accent); border-bottom-color: var(--cust-accent); }
.tab-badge {
    display: inline-block;
    min-width: 18px;
    padding: 1px 6px;
    border-radius: 10px;
    background: var(--cust-accent);
    color: #fff;
    font-size: .65rem;
    margin-left: 4px;
}

.cust-tab-body { padding: 20px 24px 28px; max-height: 55vh; overflow-y: auto; }

.cust-info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}
@media (min-width: 700px) { .cust-info-grid { grid-template-columns: repeat(2, 1fr); } }
.cust-info-card.span-2 { grid-column: 1 / -1; }

.cust-info-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px 18px;
    background: var(--bg-alt);
}
.cust-info-card h4 { font-size: .8rem; font-weight: 700; color: var(--text-muted); margin: 0 0 12px; text-transform: uppercase; letter-spacing: .04em; }
.cust-info-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.cust-info-row:last-child { border-bottom: none; }
.cust-info-row span { color: var(--text-muted); }
.cust-notes { color: var(--text-secondary); font-size: .9rem; margin: 0; white-space: pre-line; }

.cust-list-item {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    background: var(--card);
}
.cust-empty-tab { text-align: center; color: var(--text-muted); padding: 32px 16px; }

@media (max-width: 900px) {
    .cust-table-card .table-desktop { display: none; }
    .cust-toolbar-actions { margin-left: 0; width: 100%; }
    .cust-adv-grid { grid-template-columns: 1fr 1fr; }
    .cust-filter-reset { margin-left: 0; width: 100%; }
    .cust-adv-filters-bar { gap: 8px; }
}
@media (min-width: 901px) {
    .cust-table-card .data-list { display: none; }
}

/* =====================================================================
   MODERN UI REFRESH — visual override layer (no structural changes)
   Loaded last so single-class rules win via source order.
   ===================================================================== */

/* ---- Ambient background ---- */
body {
    background:
        radial-gradient(1200px 600px at 100% -10%, rgba(99,102,241,.06), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(6,182,212,.05), transparent 55%),
        var(--bg);
    background-attachment: fixed;
}

/* ---- Sidebar polish (light) ---- */
.sidebar {
    background:
        linear-gradient(180deg, rgba(99,102,241,.05), transparent 220px),
        var(--sidebar);
    border-right: 1px solid var(--sidebar-border);
    box-shadow: 0 8px 40px -16px rgba(16,24,40,.12);
}
.sidebar-brand {
    background: transparent;
    border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-brand h2 { color: var(--sidebar-text-strong); }
.sidebar-brand small { color: var(--sidebar-muted); }
.app-shell.sidebar-collapsed .sidebar-brand { padding: 16px 0; }

.sidebar-nav a,
.sidebar-nav .nav-link { position: relative; font-weight: 600; }

.sidebar-nav a:hover,
.sidebar-nav .nav-link:hover { background: var(--sidebar-hover); }

.sidebar-nav a.active,
.sidebar-nav .nav-link.active,
.nav-group-items .nav-link.active {
    background: linear-gradient(90deg, rgba(99,102,241,.16), rgba(99,102,241,.05));
    color: var(--sidebar-active-text);
}
.sidebar-nav a.active::before,
.sidebar-nav .nav-link.active::before {
    content: '';
    position: absolute;
    left: 4px; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 20px;
    border-radius: 4px;
    background: linear-gradient(180deg, #818cf8, #6366f1);
    box-shadow: 0 0 10px rgba(99,102,241,.45);
}

/* ---- Sidebar collapse toggle ---- */
.sidebar-collapse-btn {
    display: none;
    position: absolute;
    top: 50%;
    right: -13px;
    transform: translateY(-50%);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid var(--sidebar-border);
    background: var(--card);
    color: var(--text-secondary);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    z-index: 5;
    transition: all var(--transition);
}
.sidebar-collapse-btn:hover { color: var(--primary); border-color: var(--primary); }
@media (min-width: 1024px) {
    .sidebar-collapse-btn { display: flex; }
}

/* ---- Quick actions ---- */
.sidebar-quick {
    padding: 14px 12px 6px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.sidebar-quick-title {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--sidebar-muted);
    padding: 0 4px 2px;
}
.quick-action {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: .85rem;
    font-weight: 600;
    color: #fff;
    background: var(--gradient-primary);
    border: none;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 6px 14px -8px rgba(79,70,229,.6);
    transition: transform var(--transition), box-shadow var(--transition), filter var(--transition);
}
.quick-action:hover { transform: translateY(-1px); filter: brightness(1.05); text-decoration: none; color: #fff; }
.quick-action .qa-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
.quick-action.qa-secondary {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-strong);
    box-shadow: none;
}
.quick-action.qa-secondary:hover { color: var(--sidebar-text-strong); background: var(--sidebar-active-bg); }

/* ---- Nav badges ---- */
.nav-badge {
    margin-left: auto;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.nav-group-head .nav-badge { margin-left: 8px; }
.nav-group.open .nav-group-head .nav-badge { display: none; }

/* ---- Sidebar footer buttons ---- */
.sidebar-footer .sidebar-theme-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--sidebar-border);
    background: var(--sidebar-hover);
    color: var(--sidebar-text);
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.sidebar-footer .sidebar-theme-btn:hover { color: var(--sidebar-text-strong); border-color: var(--primary); }
.sidebar-footer .btn-outline { color: var(--sidebar-text) !important; border-color: var(--sidebar-border) !important; }
.sidebar-footer .btn-outline:hover { color: var(--sidebar-text-strong) !important; border-color: var(--primary) !important; }

/* ---- Collapsed sidebar (desktop) ---- */
@media (min-width: 1024px) {
    .app-shell.sidebar-collapsed .sidebar { width: var(--sidebar-width-collapsed); }
    .app-shell.sidebar-collapsed .main-area { margin-left: var(--sidebar-width-collapsed); }
    .app-shell.sidebar-collapsed .sidebar-brand h2,
    .app-shell.sidebar-collapsed .sidebar-brand small,
    .app-shell.sidebar-collapsed .sidebar-brand .brand-logo-full { display: none; }
    .app-shell.sidebar-collapsed .sidebar-brand::after {
        content: 'S';
        font-family: var(--font-display);
        font-weight: 800;
        font-size: 1.4rem;
        color: var(--primary);
    }
    .app-shell.sidebar-collapsed .nav-link span:not(.nav-icon):not(.nav-badge),
    .app-shell.sidebar-collapsed .nav-group-title span:not(.nav-icon),
    .app-shell.sidebar-collapsed .nav-group-chevron,
    .app-shell.sidebar-collapsed .sidebar-quick-title,
    .app-shell.sidebar-collapsed .quick-action span:not(.qa-icon),
    .app-shell.sidebar-collapsed .sidebar-theme-btn span:not(.theme-ico),
    .app-shell.sidebar-collapsed .sidebar-footer .btn span:not(.theme-ico) { display: none; }
    .app-shell.sidebar-collapsed .nav-link,
    .app-shell.sidebar-collapsed .quick-action,
    .app-shell.sidebar-collapsed .sidebar-footer .btn,
    .app-shell.sidebar-collapsed .nav-group-head { justify-content: center; padding-left: 0; padding-right: 0; }
    .app-shell.sidebar-collapsed .nav-group-items .nav-link { padding-left: 0; }
    .app-shell.sidebar-collapsed .nav-badge {
        position: absolute;
        top: 4px; right: 8px;
        margin-left: 0;
        min-width: 16px; height: 16px;
        padding: 0 4px;
        font-size: .6rem;
    }
    .app-shell.sidebar-collapsed .sidebar-footer .sidebar-theme-btn { padding: 10px 0; }
    .app-shell.sidebar-collapsed .sidebar-collapse-btn { transform: translateY(-50%) rotate(180deg); }
}

/* ---- Topbar glass ---- */
.topbar {
    background: color-mix(in srgb, var(--card) 80%, transparent);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    backdrop-filter: blur(14px) saturate(160%);
    border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.topbar-left h1 { font-weight: 800; letter-spacing: -.02em; }

/* ---- Buttons ---- */
.btn {
    border-radius: 12px;
    letter-spacing: -.01em;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition), filter var(--transition);
}
.btn-primary {
    background: var(--gradient-primary);
    box-shadow: 0 1px 2px rgba(79,70,229,.35), 0 8px 18px -8px rgba(99,102,241,.55);
}
.btn-primary:hover { background: var(--gradient-primary); filter: brightness(1.07); transform: translateY(-1px); box-shadow: 0 2px 4px rgba(79,70,229,.35), 0 12px 26px -8px rgba(99,102,241,.6); }
.btn-success { background: linear-gradient(135deg, #10b981, #059669); box-shadow: 0 8px 18px -8px rgba(16,185,129,.55); }
.btn-success:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-danger { background: linear-gradient(135deg, #f43f5e, #e11d48); box-shadow: 0 8px 18px -8px rgba(244,63,94,.5); }
.btn-danger:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-warning { background: linear-gradient(135deg, #f59e0b, #d97706); box-shadow: 0 8px 18px -8px rgba(245,158,11,.5); }
.btn-outline { border-color: var(--border); background: var(--card); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); transform: translateY(-1px); }

/* ---- Inputs ---- */
.form-group input,
.form-group select,
.form-group textarea,
.perm-search, .member-search, .cust-search,
.filter-bar select, .toolbar select,
.cust-filters select, .cust-filters input {
    border-radius: 12px;
    border-width: 1.5px;
    background: var(--card);
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.perm-search:focus, .member-search:focus, .cust-search:focus,
.filter-bar select:focus, .toolbar select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99,102,241,.14);
}

/* ---- Cards ---- */
.card, .chart-card {
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    border-color: color-mix(in srgb, var(--border) 80%, transparent);
}
.card-header { border-bottom-color: color-mix(in srgb, var(--border) 75%, transparent); }
.card-header h2 { font-weight: 800; letter-spacing: -.02em; }

/* ---- Stat cards & dashboard tiles ---- */
.stat-card, .cust-kpi {
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    border-color: color-mix(in srgb, var(--border) 80%, transparent);
}
.stat-card::after {
    width: 90px; height: 90px;
    border-radius: 0 var(--radius) 0 90px;
    background: var(--gradient-accent);
    opacity: .10;
}
.stat-card .value, .dash-tile-value, .cust-kpi-value { letter-spacing: -.03em; }
.dash-tile { border-radius: var(--radius); box-shadow: var(--shadow-md); }
.dash-tile-module:hover { box-shadow: var(--shadow-lg); transform: translateY(-4px); }

/* ---- Badges & chips ---- */
.badge { border-radius: 8px; letter-spacing: .2px; }
.chip, .bal-type-chip, .module-tag, .member-count-chip { border-radius: 999px; }

/* ---- Tabs ---- */
.tabs { background: var(--bg-alt); border-radius: 12px; padding: 5px; }
.tab { border-radius: 9px; }
.tab.active { box-shadow: var(--shadow); font-weight: 700; }

/* ---- Avatars: richer gradient ---- */
.user-avatar, .person-avatar, .bal-avatar, .member-avatar, .cust-detail-avatar {
    background: var(--gradient-accent);
    box-shadow: 0 6px 16px -6px rgba(99,102,241,.5);
}

/* ---- Modals ---- */
.modal { border-radius: 22px; box-shadow: var(--shadow-lg); }
@media (min-width: 640px) { .modal { border-radius: 20px; } }
.modal-overlay { background: rgba(15,23,42,.55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.modal-header h2 { font-weight: 800; }

/* ---- Toasts ---- */
.toast { border-radius: 14px; box-shadow: var(--shadow-lg); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }

/* ---- Tables ---- */
th { letter-spacing: .6px; }
tr:hover td { background: var(--bg-alt); }
[data-theme="dark"] tr:hover td { background: rgba(255,255,255,.04); }

/* ---- FAB ---- */
.fab { background: var(--gradient-primary); box-shadow: 0 10px 30px -6px rgba(99,102,241,.6); }
.fab:hover { transform: scale(1.08) translateY(-2px); }

/* ---- Notification button / bell ---- */
.notification-btn { transition: background var(--transition), transform var(--transition); }
.notification-btn:hover { background: var(--primary-light); transform: translateY(-1px); }

/* ---- Auth / login refresh ---- */
.auth-card {
    border-radius: 24px;
    box-shadow: 0 30px 70px -20px rgba(2,6,23,.55);
    border: 1px solid rgba(255,255,255,.5);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}
.auth-page::after {
    content: '';
    position: absolute;
    width: 520px; height: 520px;
    background: radial-gradient(circle, rgba(6,182,212,.28) 0%, transparent 70%);
    bottom: -200px; left: -160px;
    border-radius: 50%;
}

/* ---- Progress & rings already gradient; add glow ---- */
.progress-fill { box-shadow: 0 0 10px rgba(99,102,241,.4); }

/* ---- Dark mode fine-tuning for new layer ---- */
[data-theme="dark"] .topbar { background: color-mix(in srgb, var(--card) 75%, transparent); }
[data-theme="dark"] .btn-outline { background: var(--bg-alt); }
[data-theme="dark"] .btn-outline:hover { background: var(--primary-light); color: #c7d2fe; }
[data-theme="dark"] .auth-card { border-color: rgba(255,255,255,.08); }
[data-theme="dark"] .sidebar { border-right-color: rgba(255,255,255,.04); }

/* ---- Global search ---- */
.global-search-overlay { align-items: flex-start; padding-top: 12vh; }
.global-search-panel {
    width: min(560px, calc(100% - 32px));
    margin: 0 auto;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.global-search-panel input {
    width: 100%;
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 16px 18px;
    font-size: 1rem;
    background: transparent;
    color: var(--text);
}
.global-search-results { max-height: 360px; overflow-y: auto; }
.global-search-item {
    display: flex;
    gap: 12px;
    padding: 12px 18px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid var(--border);
}
.global-search-item:hover,
.global-search-item.is-active { background: var(--bg-alt); }
.global-search-item small { display: block; color: var(--text-muted); font-size: .78rem; margin-top: 2px; }
.global-search-icon { font-size: 1.2rem; }
.global-search-empty { padding: 20px; text-align: center; color: var(--text-muted); font-size: .9rem; }
.global-search-hint { margin: 10px 16px 14px; font-size: .72rem; color: var(--text-muted); text-align: center; }

.timeline-list { display: flex; flex-direction: column; gap: 12px; }
.timeline-item { display: flex; gap: 12px; align-items: flex-start; }
.timeline-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--primary); margin-top: 6px; flex-shrink: 0;
}
