/* ============================================
   KVTM Admin Dashboard - Design System
   Premium Dark Mode with Glassmorphism
   ============================================ */

/* ---------- Google Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ---------- CSS Variables ---------- */
:root {
    color-scheme: dark;
    /* Colors */
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --bg-glass-hover: rgba(255, 255, 255, 0.06);
    --bg-input: rgba(255, 255, 255, 0.05);

    --border: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(99, 102, 241, 0.5);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-accent: #818cf8;

    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a78bfa 100%);
    --accent-glow: rgba(99, 102, 241, 0.2);

    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.1);

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px var(--accent-glow);

    /* Sidebar */
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
    color-scheme: dark;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

a {
    color: var(--text-accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-secondary);
}

img {
    max-width: 100%;
}

input,
select,
textarea,
button {
    font-family: inherit;
    font-size: inherit;
}

/* ---------- Animated Background ---------- */
body::before {
    content: '';
    position: fixed;
    top: -150px;
    right: -150px;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.08) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    animation: float 8s ease-in-out infinite;
}

body::after {
    content: '';
    position: fixed;
    bottom: -100px;
    left: -100px;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.06) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    animation: float 10s ease-in-out infinite reverse;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(30px, -20px);
    }
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ---------- Typography ---------- */
h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

h2 {
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

h3 {
    font-size: 1.15rem;
    font-weight: 600;
}

h4 {
    font-size: 1rem;
    font-weight: 500;
}

.text-gradient {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ---------- Layout ---------- */
.app-layout {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform var(--transition-slow);
    overflow-y: auto;
}

.sidebar-brand {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.sidebar-brand .brand-icon {
    width: 40px;
    height: 40px;
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 800;
    color: white;
    flex-shrink: 0;
}

.sidebar-brand .brand-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.sidebar-brand .brand-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-md);
}

.nav-section {
    margin-bottom: var(--space-lg);
}

.nav-section-title {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    padding: 0 var(--space-md);
    margin-bottom: var(--space-sm);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 10px var(--space-md);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: 2px;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.nav-item:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent-primary);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--accent-gradient);
    border-radius: 0 3px 3px 0;
}

.nav-item .nav-icon {
    font-size: 1.15rem;
    width: 24px;
    text-align: center;
}

.nav-item .nav-label {
    font-size: 0.9rem;
    font-weight: 500;
}

.nav-item .nav-badge {
    margin-left: auto;
    background: var(--accent-primary);
    color: white;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.sidebar-footer {
    padding: var(--space-md);
    border-top: 1px solid var(--border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm);
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: white;
}

.user-name {
    font-weight: 600;
    font-size: 0.85rem;
}

.user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: var(--space-xl);
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-xl);
    flex-wrap: wrap;
    gap: var(--space-md);
}

.page-header h1 {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

/* ---------- Cards ---------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: all var(--transition-normal);
    overflow: hidden;
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.card-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
}

.card-body {
    padding: var(--space-lg);
}

.card-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ---------- Stat Cards ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    backdrop-filter: blur(20px);
    position: relative;
    overflow: hidden;
    transition: all var(--transition-normal);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
    border-color: rgba(99, 102, 241, 0.3);
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 80px;
    height: 80px;
    border-radius: 0 0 0 100%;
    opacity: 0.06;
}

.stat-card.primary::after {
    background: var(--accent-primary);
}

.stat-card.success::after {
    background: var(--success);
}

.stat-card.warning::after {
    background: var(--warning);
}

.stat-card.danger::after {
    background: var(--danger);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    margin-bottom: var(--space-md);
}

.stat-card.primary .stat-icon {
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent-primary);
}

.stat-card.success .stat-icon {
    background: var(--success-bg);
    color: var(--success);
}

.stat-card.warning .stat-icon {
    background: var(--warning-bg);
    color: var(--warning);
}

.stat-card.danger .stat-icon {
    background: var(--danger-bg);
    color: var(--danger);
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: var(--space-xs);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 8px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-glass);
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
}

.btn:hover {
    background: var(--bg-glass-hover);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--accent-gradient);
    border-color: transparent;
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
    border-color: transparent;
}

.btn-success {
    background: var(--success);
    border-color: transparent;
    color: white;
}

.btn-danger {
    background: var(--danger);
    border-color: transparent;
    color: white;
}

.btn-warning {
    background: var(--warning);
    border-color: transparent;
    color: #0a0e1a;
}

.btn-outline {
    background: transparent;
    border-color: var(--border);
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.78rem;
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 12px 28px;
    font-size: 1rem;
}

.btn-icon {
    padding: 8px;
    width: 36px;
    height: 36px;
    justify-content: center;
}

.btn-icon.sm {
    padding: 4px;
    width: 28px;
    height: 28px;
}

.btn-group {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

/* ---------- Forms ---------- */
.form-group {
    margin-bottom: var(--space-md);
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: all var(--transition-fast);
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--border-focus);
    background: rgba(255, 255, 255, 0.07);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-select {
    cursor: pointer;
}

.form-select option {
    background: #1e293b;
    color: #f1f5f9;
}

select,
select option {
    background: #1e293b !important;
    color: #f1f5f9 !important;
}

.filter-select option {
    background: #1e293b;
    color: #f1f5f9;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

.form-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ---------- Table ---------- */
.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table th {
    padding: 12px var(--space-md);
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: color var(--transition-fast);
}

.data-table th:hover {
    color: var(--text-primary);
}

.data-table th.sorted {
    color: var(--accent-primary);
}

.data-table td {
    padding: 12px var(--space-md);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 0.85rem;
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--bg-glass-hover);
}

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
}

.badge-primary {
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent-primary);
}

.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
    padding: var(--space-md);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95) translateY(10px);
    transition: transform var(--transition-slow);
    box-shadow: var(--shadow-lg);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.1rem;
}

.modal-close {
    width: 32px;
    height: 32px;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    font-size: 1.1rem;
}

.modal-close:hover {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: var(--danger);
}

.modal-body {
    padding: var(--space-lg);
}

.modal-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
}

/* ---------- Toast ---------- */
.toast-container {
    position: fixed;
    top: var(--space-lg);
    right: var(--space-lg);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md) var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    min-width: 300px;
    max-width: 450px;
    box-shadow: var(--shadow-lg);
    animation: slideInRight var(--transition-slow) forwards;
    font-size: 0.85rem;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--danger);
}

.toast.warning {
    border-left: 3px solid var(--warning);
}

.toast.info {
    border-left: 3px solid var(--info);
}

.toast-icon {
    font-size: 1.2rem;
}

.toast.success .toast-icon {
    color: var(--success);
}

.toast.error .toast-icon {
    color: var(--danger);
}

.toast.hiding {
    animation: slideOutRight 0.3s forwards;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    flex-wrap: wrap;
}

.pagination .page-btn {
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 0.82rem;
    font-weight: 500;
}

.pagination .page-btn:hover {
    background: var(--bg-glass);
    color: var(--text-primary);
}

.pagination .page-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.pagination .page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.pagination .page-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 0 var(--space-sm);
}

/* ---------- Search & Filter Bar ---------- */
.toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-wrap: wrap;
    margin-bottom: var(--space-md);
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 220px;
}

.search-box .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
    pointer-events: none;
}

.search-box .form-input {
    padding-left: 36px;
}

.filter-select {
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
    min-width: 140px;
}

.filter-select:focus {
    border-color: var(--border-focus);
}

/* ---------- Loading ---------- */
.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 14, 26, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    border-radius: inherit;
}

.skeleton {
    background: linear-gradient(90deg, var(--bg-glass) 25%, rgba(255, 255, 255, 0.06) 50%, var(--bg-glass) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    to {
        background-position: -200% 0;
    }
}

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    opacity: 0.3;
}

.empty-state p {
    font-size: 0.9rem;
}

/* ---------- Checkbox ---------- */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
}

.checkbox-wrapper input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-primary);
    cursor: pointer;
}

/* ---------- Login Page ---------- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
    animation: fadeUp 0.5s ease forwards;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-card .brand-logo {
    width: 56px;
    height: 56px;
    background: var(--accent-gradient);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 800;
    color: white;
    margin: 0 auto var(--space-lg);
    box-shadow: var(--shadow-glow);
}

.login-card h2 {
    text-align: center;
    margin-bottom: var(--space-xs);
}

.login-card .subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: var(--space-xl);
}

.login-card .btn-primary {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 0.95rem;
    margin-top: var(--space-md);
}

.login-error {
    background: var(--danger-bg);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    color: var(--danger);
    font-size: 0.82rem;
    margin-bottom: var(--space-md);
    display: none;
}

.login-error.show {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* ---------- Chart Container ---------- */
.chart-container {
    position: relative;
    height: 300px;
}

/* ---------- Mobile Toggle ---------- */
.mobile-toggle {
    display: none;
    position: fixed;
    top: var(--space-md);
    left: var(--space-md);
    z-index: 200;
    width: 40px;
    height: 40px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

/* Sidebar mobile overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
}

/* ---------- Key Stats Bar (compact inline) ---------- */
.key-stats-bar {
    display: flex;
    gap: var(--space-lg);
    flex-wrap: wrap;
}

.key-stat {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 8px 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
}

.key-stat:hover {
    background: var(--bg-glass-hover);
    border-color: rgba(255, 255, 255, 0.12);
}

.key-stat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.key-stat-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.key-stat-val {
    font-size: 1.1rem;
    font-weight: 700;
}

/* ---------- Layout Utilities ---------- */
.grid-2-1 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-md);
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
}

.mt-md {
    margin-top: var(--space-md);
}

/* ---------- Responsive ---------- */

/* Tablet */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .grid-2-1 {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}

/* Mobile */
@media (max-width: 768px) {
    html {
        font-size: 13px;
        overflow-x: hidden;
    }

    .mobile-toggle {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
    }

    .main-content {
        margin-left: 0;
        padding: var(--space-md);
        padding-top: 60px;
        overflow-x: hidden;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: var(--space-sm);
    }

    .stat-card {
        padding: var(--space-md);
    }

    .stat-value {
        font-size: 1.3rem;
    }

    .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
        margin-bottom: var(--space-sm);
    }

    .stat-label {
        font-size: 0.72rem;
    }

    .grid-2-1,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-sm);
    }

    .page-header h1 {
        font-size: 1.2rem;
    }

    .page-header .btn-group {
        width: 100%;
        flex-wrap: wrap;
    }

    .page-header .btn-group .btn {
        flex: 1;
        justify-content: center;
    }

    .toolbar {
        flex-direction: column;
        gap: var(--space-sm);
    }

    .search-box {
        width: 100%;
    }

    .filter-select {
        width: 100%;
    }

    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table {
        min-width: 580px;
    }

    .data-table th,
    .data-table td {
        padding: 8px 10px;
        font-size: 0.78rem;
    }

    .modal-overlay {
        padding: var(--space-sm);
        align-items: flex-end;
    }

    .modal {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 92vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    .modal-body {
        max-height: 62vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-header {
        padding: var(--space-md);
    }

    .modal-header h3 {
        font-size: 1rem;
    }

    .modal-footer {
        padding: var(--space-md);
    }

    .modal-footer .btn {
        flex: 1;
        justify-content: center;
    }

    .btn {
        padding: 8px 14px;
        font-size: 0.8rem;
    }

    .btn-group {
        gap: var(--space-xs);
    }

    .btn-icon {
        width: 32px;
        height: 32px;
    }

    .chart-container {
        min-height: 180px;
        height: 200px;
        max-width: 100%;
        overflow: hidden;
    }

    .card {
        border-radius: var(--radius-md);
    }

    .card-header {
        padding: var(--space-md);
    }

    .card-header h3 {
        font-size: 0.9rem;
    }

    .card-body {
        padding: var(--space-md);
    }

    .card-footer {
        padding: var(--space-sm) var(--space-md);
        flex-wrap: wrap;
        gap: var(--space-sm);
    }

    .pagination {
        flex-wrap: wrap;
        gap: 4px;
        justify-content: center;
    }

    .page-info {
        width: 100%;
        text-align: center;
        font-size: 0.72rem;
    }

    .page-btn {
        min-width: 28px;
        height: 28px;
        font-size: 0.72rem;
    }

    .badge {
        font-size: 0.68rem;
        padding: 2px 6px;
    }

    .toast-container {
        left: var(--space-sm);
        right: var(--space-sm);
        max-width: none;
    }

    body::before {
        width: 200px;
        height: 200px;
        opacity: 0.5;
    }

    body::after {
        width: 150px;
        height: 150px;
        opacity: 0.5;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
    }

    .form-input,
    .form-select,
    .form-textarea {
        padding: 9px 12px;
        font-size: 16px;
    }
}

/* Small phones */
@media (max-width: 480px) {
    html {
        font-size: 12.5px;
    }

    .main-content {
        padding: var(--space-sm);
        padding-top: 54px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }

    .stat-card {
        padding: 10px 12px;
    }

    .stat-icon {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
        margin-bottom: 4px;
    }

    .stat-value {
        font-size: 1.1rem;
    }

    .stat-label {
        font-size: 0.62rem;
    }

    .page-header h1 {
        font-size: 1rem;
    }

    .modal {
        max-height: 100vh;
        border-radius: 0;
    }

    .modal-body {
        max-height: 75vh;
    }

    .data-table {
        min-width: 480px;
    }

    .data-table th,
    .data-table td {
        padding: 6px 8px;
        font-size: 0.72rem;
    }

    .card {
        border-radius: var(--radius-sm);
    }

    .card-header {
        padding: var(--space-sm) var(--space-md);
    }

    .card-body {
        padding: var(--space-sm) var(--space-md);
    }

    .chart-container {
        min-height: 150px;
        height: 160px;
    }

    .btn-sm {
        padding: 4px 8px;
        font-size: 0.7rem;
    }
}

/* ---------- Custom Dropdown (replaces native select) ---------- */
.custom-select {
    position: relative;
    min-width: 160px;
}

.custom-select .cs-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
    white-space: nowrap;
}

.custom-select .cs-trigger:hover {
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.07);
}

.custom-select.open .cs-trigger {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.custom-select .cs-arrow {
    font-size: 0.6rem;
    transition: transform var(--transition-fast);
    color: var(--text-muted);
}

.custom-select.open .cs-arrow {
    transform: rotate(180deg);
}

.custom-select .cs-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 500;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: all var(--transition-fast);
    max-height: 280px;
    overflow-y: auto;
    padding: 4px;
}

.custom-select.open .cs-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-select .cs-option {
    padding: 9px 14px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.custom-select .cs-option:hover {
    background: rgba(99, 102, 241, 0.15);
    color: var(--text-primary);
}

.custom-select .cs-option.active {
    background: rgba(99, 102, 241, 0.2);
    color: var(--accent-primary);
    font-weight: 600;
}