:root {
    --primary: #4f6ef7;
    --primary-dark: #3a56d4;
    --primary-light: #eef1ff;
    --secondary: #6c757d;
    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --info: #06b6d4;
    --info-light: #cffafe;
    --body-bg: #f0f2f5;
    --card-bg: #ffffff;
    --sidebar-bg: #1e293b;
    --sidebar-header-bg: #0f172a;
    --sidebar-hover: #334155;
    --sidebar-active: #4f6ef7;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --navbar-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow: 0 4px 24px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body.theme-dark {
    --primary: #6b8aff;
    --primary-dark: #4f6ef7;
    --primary-light: #1e2a4a;
    --body-bg: #0f1117;
    --card-bg: #1a1d2e;
    --sidebar-bg: #0f1117;
    --sidebar-header-bg: #0a0b12;
    --sidebar-hover: #252840;
    --sidebar-text: #6b7280;
    --sidebar-text-active: #ffffff;
    --navbar-bg: #1a1d2e;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #6b7280;
    --border-color: #2d3148;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.4);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background-color: var(--body-bg);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Page fade-in */
@keyframes pageFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
    animation: pageFadeIn 0.35s ease-out;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Sidebar ─── */
#sidebar {
    min-width: 260px;
    max-width: 260px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    transition: all var(--transition);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255,255,255,0.05);
}

#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: var(--sidebar-hover); border-radius: 4px; }

#sidebar.active { margin-left: -260px; }

#sidebar .sidebar-header {
    padding: 20px;
    background: var(--sidebar-header-bg);
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: center;
}

#sidebar .sidebar-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    letter-spacing: -0.3px;
}

#sidebar .sidebar-logo {
    max-width: 200px;
    max-height: 80px;
    object-fit: contain;
    border-radius: 12px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 0 0 rgba(79, 110, 247, 0);
}

#sidebar .sidebar-logo:hover {
    transform: scale(1.06);
    box-shadow: 0 0 24px rgba(79, 110, 247, 0.35);
}

#sidebar ul.components {
    padding: 12px 0;
    flex: 1;
    list-style: none;
}

#sidebar ul li a {
    padding: 11px 20px 11px 16px;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all var(--transition);
    border-left: 3px solid transparent;
    margin: 2px 8px;
    border-radius: var(--radius-sm);
    font-weight: 500;
}

#sidebar ul li a i {
    font-size: 1.15rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

#sidebar ul li a:hover {
    color: var(--sidebar-text-active);
    background: var(--sidebar-hover);
}

#sidebar ul li.active > a,
#sidebar ul li a[aria-expanded="true"] {
    color: var(--sidebar-text-active);
    background: var(--sidebar-active);
    border-left-color: var(--sidebar-active);
}

#sidebar ul li a.dropdown-toggle {
    position: relative;
    padding-right: 36px;
}

#sidebar ul li a.dropdown-toggle::after {
    display: inline-block;
    content: "\F282";
    font-family: "bootstrap-icons";
    font-size: 0.65rem;
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    transition: transform var(--transition);
    border: none;
    vertical-align: middle;
    opacity: 0.5;
}

#sidebar ul li a.dropdown-toggle[aria-expanded="true"]::after {
    transform: translateY(-50%) rotate(90deg);
    opacity: 1;
}

#sidebar ul li.has-submenu > a.dropdown-toggle {
    border-left-color: rgba(255,255,255,0.08);
    font-weight: 500;
    transition: all var(--transition);
}

#sidebar ul li.has-submenu > a.dropdown-toggle[aria-expanded="true"] {
    border-left-color: var(--sidebar-active);
    background: rgba(79, 110, 247, 0.12);
}

#sidebar ul li.has-submenu.active > a.dropdown-toggle {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
    border-left-color: var(--sidebar-active);
}

#sidebar ul li ul {
    background: rgba(0,0,0,0.12);
    border-radius: var(--radius-sm);
    margin: 2px 8px 6px;
    padding: 6px 0;
    list-style: none;
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#sidebar ul li ul::before {
    display: none;
}

#sidebar ul li ul li {
    position: relative;
}

#sidebar ul li ul li::before {
    content: "";
    position: absolute;
    left: 22px;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(255,255,255,0.06);
}

#sidebar ul li ul li a {
    padding: 8px 16px 8px 44px;
    font-size: 0.825rem;
    border-left: none;
    margin: 0 8px;
    border-radius: 6px;
    position: relative;
    gap: 10px;
}

#sidebar ul li ul li a::before {
    content: "";
    display: inline-block;
    width: 5px;
    height: 5px;
    border: 1.5px solid var(--sidebar-text);
    border-radius: 50%;
    flex-shrink: 0;
    transition: all var(--transition);
}

#sidebar ul li ul li a:hover::before,
#sidebar ul li ul li.active a::before {
    background: var(--sidebar-active);
    border-color: var(--sidebar-active);
}

#sidebar ul li ul li.active a {
    color: var(--sidebar-text-active);
    background: var(--sidebar-active);
    font-weight: 600;
}

#sidebar ul li ul li a:hover {
    background: var(--sidebar-hover);
}

#sidebar ul li ul li.active a:hover {
    background: var(--sidebar-active);
}

.sidebar-footer {
    padding: 16px 20px;
    text-align: center;
    font-size: 0.75rem;
    color: var(--sidebar-text);
    border-top: 1px solid rgba(255,255,255,0.06);
}

/* ─── Digital Clock ─── */
.digital-clock-wrapper {
    padding: 16px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    margin: 0;
}

#digital-clock {
    font-family: 'JetBrains Mono', 'Inter', monospace;
    font-size: 1.6rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.3;
    letter-spacing: 1px;
}

#digital-clock .ampm {
    font-size: 0.75rem;
    font-weight: 500;
    vertical-align: text-top;
    margin-left: 4px;
    opacity: 0.7;
}

#digital-date {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--sidebar-text);
    margin-top: 4px;
    letter-spacing: 0.5px;
}

/* ─── Content ─── */
#content {
    margin-left: 260px;
    width: calc(100% - 260px);
    padding: 24px 28px;
    min-height: 100vh;
    transition: all var(--transition);
}

#content.active {
    margin-left: 0;
    width: 100%;
}

/* ─── Navbar ─── */
.navbar {
    padding: 14px 24px;
    background: var(--navbar-bg);
    border: none;
    border-radius: var(--radius);
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.3s, box-shadow 0.3s;
}

.navbar .navbar-text {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.navbar .btn-outline-danger {
    border-color: var(--border-color);
    color: var(--text-secondary);
    background: transparent;
}

.navbar .btn-outline-danger:hover {
    background: var(--danger-light);
    border-color: var(--danger);
    color: var(--danger);
}

/* ─── Page Heading ─── */
.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-heading h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.5px;
}

.page-heading .btn {
    white-space: nowrap;
}

/* ─── Back to Top ─── */
#back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(79,110,247,0.35);
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: all var(--transition);
    z-index: 1050;
}

#back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#back-to-top:hover {
    background: var(--primary-dark);
    transform: translateY(-3px);
    box-shadow: 0 6px 24px rgba(79,110,247,0.45);
}

/* ─── Skeleton Loading ─── */
@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton {
    background: linear-gradient(90deg, var(--border-color) 25%, transparent 50%, var(--border-color) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
    color: transparent !important;
    user-select: none;
    pointer-events: none;
}

/* ─── Empty State ─── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
}

.empty-state i {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h5 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

/* ─── Toast / Notification ─── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.875rem;
    color: var(--text-primary);
    min-width: 300px;
    max-width: 420px;
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(100%); }
    to   { opacity: 1; transform: translateX(0); }
}

.toast i { font-size: 1.2rem; }
.toast.success i { color: var(--success); }
.toast.error i { color: var(--danger); }
.toast.info i { color: var(--info); }
.toast.warning i { color: var(--warning); }

/* ─── Cards ─── */
.card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    background-color: var(--card-bg);
    transition: all var(--transition);
}

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

.card-header {
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-body {
    padding: 24px;
}

/* ─── Stat Cards ─── */
.stat-card {
    border-radius: var(--radius);
    border: none;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary);
    opacity: 0;
    transition: opacity var(--transition);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    margin-bottom: 12px;
}

.stat-card .stat-icon.primary {
    background: var(--primary-light);
    color: var(--primary);
}

.stat-card .stat-icon.success {
    background: var(--success-light);
    color: var(--success);
}

.stat-card .stat-icon.info {
    background: var(--info-light);
    color: var(--info);
}

.stat-card .stat-icon.warning {
    background: var(--warning-light);
    color: var(--warning);
}

.stat-card .stat-value {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    letter-spacing: -1px;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* ─── Tables ─── */
.table {
    width: 100%;
    margin-bottom: 0;
    color: var(--text-primary);
    border-collapse: separate;
    border-spacing: 0;
}

.table thead th {
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-color);
    background: var(--card-bg);
}

.table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.table tbody tr {
    transition: background-color var(--transition);
}

.table tbody tr:hover {
    background-color: rgba(79,110,247,0.03);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table-bordered {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.table-bordered thead th:first-child { border-radius: var(--radius) 0 0 0; }
.table-bordered thead th:last-child { border-radius: 0 var(--radius) 0 0; }

.table-responsive {
    border-radius: var(--radius-sm);
    overflow-x: auto;
}

/* ─── Badges ─── */
.badge {
    padding: 4px 10px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    border-radius: 100px;
    text-transform: capitalize;
}

.badge.bg-success { background: var(--success-light) !important; color: #065f46; }
.badge.bg-warning { background: var(--warning-light) !important; color: #92400e; }
.badge.bg-info { background: var(--info-light) !important; color: #155e75; }
.badge.bg-danger { background: var(--danger-light) !important; color: #991b1b; }

.theme-dark .badge.bg-success { background: rgba(16,185,129,0.2) !important; color: #34d399; }
.theme-dark .badge.bg-warning { background: rgba(245,158,11,0.2) !important; color: #fbbf24; }
.theme-dark .badge.bg-info { background: rgba(6,182,212,0.2) !important; color: #22d3ee; }
.theme-dark .badge.bg-danger { background: rgba(239,68,68,0.2) !important; color: #f87171; }

/* ─── Buttons ─── */
.btn {
    padding: 9px 18px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    text-transform: none;
    letter-spacing: 0;
    box-shadow: none;
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(255,255,255,0.2) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.btn:hover::after {
    opacity: 1;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn i {
    font-size: 1em;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #fff;
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
    border-color: var(--primary);
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

.btn-success:hover {
    background: #059669;
    border-color: #059669;
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
}

.btn-outline-danger {
    color: var(--danger);
    border-color: var(--border-color);
    background: transparent;
}

.btn-outline-danger:hover {
    background: var(--danger-light);
    border-color: var(--danger);
    color: var(--danger);
}

.btn-warning {
    background: var(--warning);
    border-color: var(--warning);
    color: #fff;
}

.btn-warning:hover {
    background: #d97706;
    border-color: #d97706;
    color: #fff;
}

.btn-info {
    background: var(--info);
    border-color: var(--info);
    color: #fff;
}

.btn-info:hover {
    background: #0891b2;
    border-color: #0891b2;
    color: #fff;
}

.btn-secondary {
    background: var(--secondary);
    border-color: var(--secondary);
    color: #fff;
}

.btn-secondary:hover {
    background: #5a6268;
    border-color: #5a6268;
    color: #fff;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.78rem;
    gap: 5px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 0.95rem;
    gap: 10px;
}

/* Table row action buttons */
/* ─── btn-group ─── */
.btn-group .btn {
    margin: 0;
    border-radius: 0;
}

.btn-group .btn:first-child {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.btn-group .btn:last-child {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Action buttons in tables */
.action-btns {
    display: inline-flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.action-btns .btn {
    border-radius: var(--radius-sm) !important;
    padding: 5px 9px;
    font-size: 0.78rem;
    line-height: 1.2;
    border: 1px solid transparent;
    min-width: 30px;
    text-align: center;
}

/* ─── Forms ─── */
.form-control, .form-select {
    padding: 10px 14px;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-primary);
    transition: all var(--transition);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.03);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,110,247,0.12);
    outline: none;
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-label {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.form-text {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.input-group-text {
    background: var(--body-bg);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 10px 14px;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.form-control.is-invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(239,68,68,0.12);
}

.invalid-feedback {
    color: var(--danger);
    font-size: 0.8rem;
    margin-top: 4px;
}

/* Card with form focus */
.card:focus-within {
    box-shadow: var(--shadow);
    border-color: var(--primary);
}

/* ─── Custom Checkbox / Radio ─── */
.form-check-input {
    width: 1.1em;
    height: 1.1em;
    border: 1.5px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--card-bg);
    cursor: pointer;
    transition: all var(--transition);
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.form-check-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,110,247,0.12);
}

.form-check-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
}

/* ─── Dropdown ─── */
.dropdown-menu {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    background: var(--card-bg);
}

.dropdown-item {
    padding: 8px 14px;
    font-size: 0.85rem;
    color: var(--text-primary);
    border-radius: 6px;
    transition: all var(--transition);
}

.dropdown-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.dropdown-item i {
    margin-right: 8px;
    width: 18px;
    text-align: center;
}

/* ─── Modal ─── */
.modal-content {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 80px rgba(0,0,0,0.2);
    background: var(--card-bg);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 20px 24px 16px;
}

.modal-header .modal-title {
    font-weight: 700;
    font-size: 1.05rem;
}

.modal-body {
    padding: 20px 24px;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 16px 24px 20px;
}

.modal-backdrop {
    backdrop-filter: blur(4px);
    background: rgba(0,0,0,0.3);
}

/* ─── Select2 / Choices overrides ─── */
select.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
    padding-right: 36px;
}

/* ─── Alerts ─── */
.alert {
    padding: 14px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 20px;
}

.alert-success {
    background: var(--success-light);
    color: #065f46;
}

.alert-danger {
    background: var(--danger-light);
    color: #991b1b;
}

.alert-info {
    background: var(--info-light);
    color: #155e75;
}

.alert-warning {
    background: var(--warning-light);
    color: #92400e;
}

.theme-dark .alert-success {
    background: rgba(16,185,129,0.15);
    color: #34d399;
}

.theme-dark .alert-danger {
    background: rgba(239,68,68,0.15);
    color: #f87171;
}

.theme-dark .alert-info {
    background: rgba(6,182,212,0.15);
    color: #22d3ee;
}

.theme-dark .alert-warning {
    background: rgba(245,158,11,0.15);
    color: #fbbf24;
}

.btn-close {
    background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%236b7280'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg%3e") center/1em auto no-repeat;
    border: 0;
    border-radius: var(--radius-sm);
    opacity: 0.6;
    padding: 0.5em;
}

.btn-close:hover { opacity: 1; }

/* ─── Pagination ─── */
.pagination {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    gap: 4px;
}

.page-item .page-link {
    color: var(--text-secondary);
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all var(--transition);
    background: var(--card-bg);
}

.page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(79,110,247,0.3);
}

.page-item .page-link:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

/* ─── Progress ─── */
.progress {
    height: 8px;
    border-radius: 100px;
    background: var(--border-color);
    overflow: hidden;
}

.progress-bar {
    background: var(--primary);
    border-radius: 100px;
}

/* ─── Chart ─── */
.chart-area {
    position: relative;
    height: 300px;
    width: 100%;
}

/* ─── Dashboard Card Scroll ─── */
.dashboard-card .card-body {
    max-height: 360px;
    overflow-y: auto;
}

.dashboard-card .card-body::-webkit-scrollbar {
    width: 4px;
}

.dashboard-card .card-body::-webkit-scrollbar-track {
    background: transparent;
}

.dashboard-card .card-body::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

/* ─── Footer ─── */
.footer {
    padding: 20px 24px;
    background: var(--navbar-bg);
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-muted);
    margin-top: 32px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    font-size: 0.825rem;
}

/* ─── Filter Form ─── */
.filter-form .form-control,
.filter-form .form-select {
    padding: 8px 12px;
    font-size: 0.825rem;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    #sidebar {
        margin-left: -260px;
        position: fixed;
        height: 100%;
        z-index: 1050;
        box-shadow: var(--shadow-lg);
    }

    #sidebar.active {
        margin-left: 0;
    }

    #content {
        margin-left: 0;
        width: 100%;
        padding: 16px;
    }

    #sidebar.active ~ #content {
        margin-left: 0;
        width: 100%;
    }

    .navbar {
        flex-wrap: wrap;
        padding: 12px 16px;
    }

    .navbar .d-flex {
        width: 100%;
        justify-content: space-between;
        margin-top: 8px;
    }

    .navbar-text {
        margin-right: 0 !important;
    }

    .page-heading {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-heading .btn {
        width: 100%;
    }

    .stat-card .stat-value {
        font-size: 1.4rem;
    }
}

@media (max-width: 576px) {
    #content {
        padding: 12px;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .card-body {
        padding: 16px;
    }

    .table thead th,
    .table tbody td {
        padding: 10px 12px;
        font-size: 0.8rem;
    }

    .btn {
        padding: 8px 14px;
        font-size: 0.8rem;
    }
}

/* ─── Sidebar Overlay ─── */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1049;
    backdrop-filter: blur(4px);
}

.sidebar-overlay.active {
    display: block;
}

@media (max-width: 768px) {
    .sidebar-overlay.active {
        display: block;
    }
}

/* ─── Invoice Table (compact) ─── */
.invoice-table th,
.invoice-table td {
    white-space: nowrap;
    padding: 10px 12px;
}

.invoice-table th:first-child,
.invoice-table td:first-child {
    padding-left: 16px;
}

.invoice-table th:last-child,
.invoice-table td:last-child {
    padding-right: 16px;
}

.invoice-table th:nth-child(3),
.invoice-table td:nth-child(3) {
    width: 100px;
}

.invoice-table th:nth-child(4),
.invoice-table td:nth-child(4) {
    width: 100px;
}

.invoice-table th:nth-child(5),
.invoice-table td:nth-child(5) {
    width: 100px;
}

.invoice-table th:nth-child(6),
.invoice-table td:nth-child(6) {
    width: 100px;
}

.invoice-table th:nth-child(7),
.invoice-table td:nth-child(7) {
    width: 170px;
}

@media (max-width: 992px) {
    .invoice-table th,
    .invoice-table td {
        padding: 6px 6px;
        font-size: 0.72rem;
        word-break: break-word;
    }

    .invoice-table th:first-child,
    .invoice-table td:first-child {
        padding-left: 8px;
    }

    .invoice-table th:last-child,
    .invoice-table td:last-child {
        padding-right: 8px;
    }

    .invoice-table th:nth-child(2),
    .invoice-table td:nth-child(2) {
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .invoice-table th:nth-child(7),
    .invoice-table td:nth-child(7) {
        width: 110px;
    }

    .invoice-table .action-btns {
        gap: 5px !important;
    }

    .invoice-table .action-btns .btn {
        padding: 5px 8px !important;
        font-size: 0.7rem;
    }

    .invoice-table .badge {
        font-size: 0.58rem;
        padding: 2px 6px;
    }
}

/* Mobile: stack table as cards */
@media (max-width: 600px) {
    .table-responsive,
    .table-responsive .table,
    .table-responsive tbody,
    .table-responsive tr,
    .table-responsive td {
        display: block;
        width: 100%;
    }

    .table-responsive {
        overflow: visible;
    }

    .table-responsive thead {
        display: none;
    }

    .table-responsive tbody tr {
        position: relative;
        background: var(--card-bg);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-sm);
        padding: 14px 16px 12px;
        margin-bottom: 14px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.06);
        border-left: 4px solid var(--border-color);
        transition: transform 0.15s, box-shadow 0.15s;
    }

    .table-responsive tbody tr:active {
        transform: scale(0.99);
    }

    .table-responsive tbody tr[data-status="paid"] {
        border-left-color: #198754;
    }
    .table-responsive tbody tr[data-status="unpaid"] {
        border-left-color: #ffc107;
    }
    .table-responsive tbody tr[data-status="pending"] {
        border-left-color: #6c757d;
    }
    .table-responsive tbody tr[data-status="sent"] {
        border-left-color: #0dcaf0;
    }
    .table-responsive tbody tr[data-status="partially_paid"] {
        border-left-color: #0d6efd;
    }
    .table-responsive tbody tr[data-status="cancelled"],
    .table-responsive tbody tr[data-status="overdue"],
    .table-responsive tbody tr[data-status="refunded"] {
        border-left-color: #dc3545;
    }

    .table-responsive tbody td {
        display: inline;
        border: none;
        padding: 0;
        font-size: 0.8rem;
        line-height: 1.6;
    }

    .table-responsive tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        font-size: 0.6rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        display: inline;
    }

    .table-responsive tbody td::after {
        content: ": ";
        color: var(--text-muted);
        font-size: 0.6rem;
    }

    .table-responsive tbody td:nth-child(1) {
        display: block;
        font-size: 0.95rem;
        font-weight: 700;
        margin-bottom: 2px;
        padding-right: 90px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .table-responsive tbody td:nth-child(1)::before,
    .table-responsive tbody td:nth-child(1)::after {
        display: none;
    }

    .table-responsive tbody td:nth-child(2) {
        display: block;
        color: var(--text-color);
        font-size: 0.85rem;
    }

    .table-responsive tbody td:nth-child(2)::before,
    .table-responsive tbody td:nth-child(2)::after {
        display: none;
    }

    .table-responsive tbody td:nth-child(3) {
        display: block;
        font-size: 0.72rem;
        color: var(--text-muted);
        margin-bottom: 6px;
    }

    .table-responsive tbody td:nth-child(3)::before,
    .table-responsive tbody td:nth-child(3)::after {
        display: none;
    }

    .table-responsive tbody td:nth-child(4) {
        position: absolute;
        top: 14px;
        right: 16px;
        display: inline-block;
    }

    .table-responsive tbody td:nth-child(4)::before,
    .table-responsive tbody td:nth-child(4)::after {
        display: none;
    }

    .table-responsive tbody td:nth-child(5),
    .table-responsive tbody td:nth-child(6) {
        display: inline-block;
        width: 48%;
        font-size: 0.78rem;
        margin-top: 4px;
    }

    .table-responsive tbody td:nth-child(5) {
        text-align: left;
    }

    .table-responsive tbody td:nth-child(6) {
        text-align: right;
    }

    .table-responsive tbody td:nth-child(5)::before,
    .table-responsive tbody td:nth-child(6)::before {
        display: block;
        margin-bottom: 0;
    }

    .table-responsive tbody td:nth-child(5)::after,
    .table-responsive tbody td:nth-child(6)::after {
        display: none;
    }

    .table-responsive tbody td:nth-child(7) {
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid var(--border-color);
        text-align: center;
    }

    .table-responsive tbody td:nth-child(7)::before,
    .table-responsive tbody td:nth-child(7)::after {
        display: none;
    }

    .table-responsive tbody td:nth-child(7) .action-btns {
        gap: 8px;
    }

    .table-responsive .action-btns .btn {
        padding: 8px 12px !important;
        font-size: 0.85rem;
        min-width: 40px;
        text-align: center;
        border-radius: 6px !important;
    }

    .table-responsive tbody tr:hover {
        background: var(--card-bg);
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    }
}

/* ─── Pagination nav ─── */
.pagination-nav {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.pagination-nav .pagination {
    flex-wrap: nowrap;
    justify-content: center;
    width: max-content;
    margin: 0 auto;
}

/* ─── Table Info ─── */
.table-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 12px;
}

/* ─── Auth message display fix ─── */
body.login-page #content .alert {
    margin-bottom: 0;
}
