/* ── Reset & Base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --bg: #0b0d14;
    --surface: #161923;
    --surface-2: #1e2230;
    --surface-3: #262b3d;
    --border: #2a2f42;
    --border-light: #353b52;
    --text: #e4e7f0;
    --text-muted: #8389a0;
    --primary: #5b95ff;
    --primary-hover: #4780f0;
    --primary-subtle: rgba(91,149,255,0.1);
    --success: #34d399;
    --success-subtle: rgba(52,211,153,0.1);
    --warning: #fbbf24;
    --warning-subtle: rgba(251,191,36,0.1);
    --danger: #ef4444;
    --danger-subtle: rgba(239,68,68,0.1);
    --secondary: #6b7280;
    --radius: 8px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.35);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.45);
    --sidebar-width: 240px;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}
::selection { background: var(--primary); color: #fff; }
a { color: var(--primary); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--primary-hover); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ── Login page ─────────────────────────────────────────────── */
.login-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
    background: radial-gradient(ellipse at 50% 20%, var(--surface) 0%, var(--bg) 70%);
}
.login-container {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 2.5rem; width: 380px; max-width: 90vw;
    box-shadow: var(--shadow-lg);
}
.login-header { text-align: center; margin-bottom: 2rem; }
.login-header h1 { font-size: 1.8rem; font-weight: 700; background: linear-gradient(135deg, var(--primary), #a78bfa); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.login-header p { color: var(--text-muted); font-size: 0.9rem; }
.login-form .form-group { margin-bottom: 1.25rem; }

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
    position: fixed; top: 0; left: 0; width: var(--sidebar-width);
    height: 100vh; background: var(--surface); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; z-index: 10;
}
.sidebar-header { padding: 1.5rem; border-bottom: 1px solid var(--border); }
.sidebar-header h2 { font-size: 1.2rem; font-weight: 700; background: linear-gradient(135deg, var(--primary), #a78bfa); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.sidebar-subtitle { font-size: 0.75rem; color: var(--text-muted); }
.sidebar-nav { list-style: none; flex: 1; padding: 0.5rem 0; }
.sidebar-nav li a {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.65rem 1.5rem; color: var(--text-muted);
    font-size: 0.875rem; transition: all 0.15s; text-decoration: none;
    border-left: 3px solid transparent;
}
.sidebar-nav li a:hover { background: var(--surface-2); color: var(--text); }
.sidebar-footer {
    padding: 1rem 1.5rem; border-top: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
}
.user-badge { font-size: 0.8rem; color: var(--text-muted); }
.logout-link { font-size: 0.8rem; color: var(--danger); cursor: pointer; }
.logout-link:hover { color: #ff6b6b; }

/* ── Main content ───────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width); padding: 2rem;
}
.page-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1.5rem; flex-wrap: wrap; gap: 0.75rem;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.timestamp { font-size: 0.8rem; color: var(--text-muted); }
.count { font-size: 0.85rem; color: var(--text-muted); }

/* ── Stats grid ─────────────────────────────────────────────── */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem; margin-bottom: 2rem;
}
.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.25rem; text-align: center;
    font-size: 2rem; font-weight: 700; box-shadow: var(--shadow-sm);
}
.stat-card .stat-label { display: block; font-size: 0.8rem; font-weight: 400;
    color: var(--text-muted); margin-top: 0.25rem; }
.stat-card.warning { border-color: var(--warning); color: var(--warning); }
.stat-card.danger { border-color: var(--danger); color: var(--danger); }

/* ── Cards & Sections ───────────────────────────────────────── */
.section { margin-bottom: 2rem; }
.section h2 {
    font-size: 1.1rem; font-weight: 600; margin-bottom: 0.75rem; color: var(--text);
    padding-left: 0.75rem; border-left: 3px solid var(--primary);
}
.section h2.no-accent { padding-left: 0; border-left: none; }
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}
.card-accent-top {
    border-top: 3px solid var(--primary);
    border-radius: var(--radius);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    padding: 1.5rem; margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}
.hidden { display: none !important; }

/* ── Tables ─────────────────────────────────────────────────── */
.table-container { overflow-x: auto; width: 100%; max-width: 100%;
    border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th, td { padding: 0.65rem 0.85rem; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 0.75rem;
     text-transform: uppercase; letter-spacing: 0.06em; background: var(--surface-2); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }
tbody tr:nth-child(even) td { background: rgba(255,255,255,0.015); }
tbody tr:nth-child(even):hover td { background: var(--surface-2); }
.empty { text-align: center; color: var(--text-muted); padding: 2rem !important; }
code { font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace; font-size: 0.8rem;
       background: var(--surface-3); padding: 0.15rem 0.4rem; border-radius: 4px; }
td code, td a code { max-width: 100%; display: inline-block;
                     overflow: hidden; text-overflow: ellipsis;
                     vertical-align: middle; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 0.2rem 0.55rem; border-radius: 999px;
         font-size: 0.68rem; font-weight: 600; text-transform: uppercase;
         letter-spacing: 0.03em; white-space: nowrap; }
.badge-success { background: var(--success-subtle); color: var(--success); border: 1px solid rgba(52,211,153,0.2); }
.badge-warning { background: var(--warning-subtle); color: var(--warning); border: 1px solid rgba(251,191,36,0.2); }
.badge-danger { background: var(--danger-subtle); color: var(--danger); border: 1px solid rgba(239,68,68,0.2); }
.badge-secondary { background: rgba(107,114,128,0.12); color: var(--secondary); border: 1px solid rgba(107,114,128,0.2); }

/* ── Disabled row ──────────────────────────────────────────── */
tr.disabled { opacity: 0.45; }
tr.disabled td { text-decoration: line-through; text-decoration-color: var(--danger); }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.8rem; font-weight: 500; color: var(--text-muted);
                    margin-bottom: 0.35rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
             gap: 1rem; }
.form-row { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }
.inline-form { display: flex; align-items: center; gap: 0.5rem; white-space: nowrap; }
input, select, textarea {
    background: var(--bg); border: 1px solid var(--border); color: var(--text);
    padding: 0.55rem 0.8rem; border-radius: var(--radius-sm); font-size: 0.875rem;
    width: 100%; outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-subtle); }
.input-sm { width: auto; max-width: 100px; }

/* ── Checkbox label ─────────────────────────────────────────── */
.checkbox-label {
    display: flex; align-items: center; gap: 0.5rem; cursor: pointer;
    font-size: 0.8rem; color: var(--text-muted);
}
.checkbox-label input[type="checkbox"] {
    width: auto; cursor: pointer; accent-color: var(--primary);
}
.form-actions { display: flex; gap: 0.75rem; align-items: center;
                grid-column: 1 / -1; padding-top: 0.5rem; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 0.35rem; padding: 0.55rem 1.1rem; border: none;
    border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 500;
    cursor: pointer; text-align: center;
    line-height: 1.4; text-decoration: none;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.btn:hover { box-shadow: var(--shadow-md); filter: brightness(1.15); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface-3); border-color: var(--border-light); }
.btn-success { background: var(--success); color: #000; }
.btn-success:hover { background: #2ec48a; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: var(--warning); color: #000; }
.btn-warning:hover { background: #f59e0b; }
.btn-info { background: #06b6d4; color: #000; }
.btn-info:hover { background: #0891b2; }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.72rem; gap: 0.2rem; white-space: nowrap; }
.btn-sm:hover { box-shadow: var(--shadow-sm); filter: brightness(1.15); }
.btn-block { width: 100%; }

/* ── Action button groups in tables ─────────────────────────── */
.action-buttons { display: flex; gap: 0.4rem; flex-wrap: nowrap; }
.action-buttons .btn { white-space: nowrap; }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert { padding: 0.75rem 1rem; border-radius: var(--radius-sm);
         margin-bottom: 1rem; font-size: 0.85rem; display: flex;
         align-items: center; gap: 0.5rem; }
.alert-success { background: var(--success-subtle); border: 1px solid rgba(52,211,153,0.25); color: var(--success); }
.alert-error { background: var(--danger-subtle); border: 1px solid rgba(239,68,68,0.25); color: var(--danger); }
.alert-info { background: var(--primary-subtle); border: 1px solid rgba(91,149,255,0.25); color: var(--primary); }

/* ── Active nav link ────────────────────────────────────────── */
.sidebar-nav li a.active {
    background: var(--primary-subtle); color: var(--primary);
    border-left-color: var(--primary); font-weight: 600;
}

/* ── Sidebar nav indicator dot ─────────────────────────────── */
.nav-indicator {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--text-muted); flex-shrink: 0;
    transition: background 0.15s;
}
a:hover .nav-indicator { background: var(--text); }
a.active .nav-indicator { background: var(--primary); }

/* ── Breadcrumbs ────────────────────────────────────────────── */
.breadcrumbs {
    display: flex; align-items: center; gap: 0.35rem;
    font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.75rem;
}
.breadcrumbs a { color: var(--text-muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--primary); }
.breadcrumbs .separator { color: var(--border-light); font-size: 0.7rem; }

/* ── Progress bars ──────────────────────────────────────────── */
.progress-bar {
    width: 100%; height: 6px; background: var(--surface-2);
    border-radius: 999px; overflow: hidden; margin-top: 0.5rem;
}
.progress-bar-fill {
    height: 100%; border-radius: 999px; transition: width 0.6s ease;
    position: relative;
}
.progress-bar-fill::after {
    content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1));
    border-radius: 999px;
}
.progress-bar-fill.success { background: var(--success); }
.progress-bar-fill.warning { background: var(--warning); }
.progress-bar-fill.danger { background: var(--danger); }
.progress-bar-fill.primary { background: var(--primary); }

/* ── Enhanced stat cards ────────────────────────────────────── */
.stat-card {
    position: relative; overflow: hidden;
}
.stat-card .stat-value {
    font-size: 2rem; font-weight: 700; line-height: 1.1;
}
.stat-card .stat-sub {
    font-size: 0.7rem; color: var(--text-muted); margin-top: 0.15rem;
}
.stat-card.has-progress { padding-bottom: 0.75rem; }
.stat-card.accent-primary { border-left: 3px solid var(--primary); }
.stat-card.accent-success { border-left: 3px solid var(--success); }
.stat-card.accent-warning { border-left: 3px solid var(--warning); }
.stat-card.accent-danger { border-left: 3px solid var(--danger); }

/* ── Stat card medium (for device detail) ───────────────────── */
.stat-card-md {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1rem; text-align: center;
    font-size: 0.95rem; box-shadow: var(--shadow-sm);
}
.stat-card-md .stat-value { font-weight: 600; word-break: break-all; }
.stat-card-md .stat-label {
    display: block; font-size: 0.7rem; font-weight: 400;
    color: var(--text-muted); margin-top: 0.15rem;
}
.stats-grid-md {
    display: grid; gap: 0.75rem;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    margin-bottom: 2rem;
}

/* ── Device detail grouping ─────────────────────────────────── */
.device-section-title {
    font-size: 0.8rem; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.06em;
    grid-column: 1 / -1; margin-top: 0.5rem; padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
}

/* ── Modal overlay ──────────────────────────────────────────── */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.65); display: flex; align-items: center;
    justify-content: center; z-index: 1000;
    animation: fadeIn 0.15s ease;
}
.modal {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px;
    min-width: 380px; max-width: 90vw;
    max-height: 85vh;
    box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column;
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 1.5rem; border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 600; }
.modal-body {
    overflow-y: auto; flex: 1; padding: 1rem 1.5rem;
}
.edit-code-label {
    margin-bottom: 1rem; padding: 0.6rem 0.75rem;
    background: var(--surface-2); border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.9rem; color: var(--primary); word-break: break-all;
}
.modal-close {
    background: none; border: none; color: var(--text-muted);
    font-size: 1.5rem; cursor: pointer; line-height: 1; padding: 0.25rem;
    border-radius: 4px; transition: color 0.15s, background 0.15s;
}
.modal-close:hover { color: var(--text); background: var(--surface-2); }
.modal-footer {
    display: flex; justify-content: flex-end; gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border); flex-shrink: 0;
}

/* ── Toast notifications ────────────────────────────────────── */
.toast-container {
    position: fixed; top: 1rem; right: 1rem; z-index: 9999;
    display: flex; flex-direction: column; gap: 0.5rem;
    pointer-events: none;
}
.toast {
    pointer-events: auto; padding: 0.75rem 1rem;
    border-radius: var(--radius-sm); font-size: 0.85rem;
    box-shadow: var(--shadow-lg);
    animation: toast-in 0.3s ease; max-width: 380px;
    display: flex; align-items: center; gap: 0.5rem;
}
.toast-success { background: #065f46; border: 1px solid rgba(52,211,153,0.3); color: #6ee7b7; }
.toast-error { background: #7f1d1d; border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.toast-info { background: #1e3a5f; border: 1px solid rgba(91,149,255,0.3); color: #93c5fd; }
.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-message { flex: 1; }
.toast-close {
    background: none; border: none; color: inherit; cursor: pointer;
    font-size: 1rem; opacity: 0.6; padding: 0; line-height: 1;
}
.toast-close:hover { opacity: 1; }
.toast-leave { animation: toast-out 0.25s ease forwards; }
@keyframes toast-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes toast-out {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* ── Loading spinner ────────────────────────────────────────── */
.btn-loading {
    position: relative; pointer-events: none; color: transparent !important;
}
.btn-loading::after {
    content: ''; position: absolute; inset: 50% auto auto 50%;
    width: 1rem; height: 1rem; margin: -0.5rem 0 0 -0.5rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white; border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-sm {
    display: inline-block; width: 1rem; height: 1rem;
    border: 2px solid var(--border); border-top-color: var(--primary);
    border-radius: 50%; animation: spin 0.6s linear infinite;
}

/* ── Sortable table headers ─────────────────────────────────── */
th.sortable {
    cursor: pointer; user-select: none;
}
th.sortable:hover { color: var(--text); }
th.sortable::after {
    content: ' ↕'; font-size: 0.7rem; opacity: 0.3; margin-left: 0.15rem;
}
th.sortable.sort-asc::after { content: ' ↑'; opacity: 1; }
th.sortable.sort-desc::after { content: ' ↓'; opacity: 1; }

/* ── Sticky columns ─────────────────────────────────────────── */
th.sticky-col, td.sticky-col {
    position: sticky; left: 0; z-index: 2;
    background: var(--surface);
}
tr:hover td.sticky-col { background: var(--surface-2); }
th.sticky-col { z-index: 3; }

/* ── Text truncation ────────────────────────────────────────── */
td.text-truncate {
    max-width: 140px; overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap;
}
td.text-truncate-sm { max-width: 90px; }
td.text-truncate-lg { max-width: 200px; }
td.text-truncate code, td.text-truncate a code,
td.text-truncate-sm code, td.text-truncate-sm a code,
td.text-truncate-lg code, td.text-truncate-lg a code {
    max-width: 100%; display: inline-block; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap; vertical-align: middle;
}

/* ── Form validation ────────────────────────────────────────── */
input.error, select.error, textarea.error {
    border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-subtle);
}
.error-message {
    font-size: 0.75rem; color: var(--danger); margin-top: 0.2rem;
}
.form-hint {
    display: block; font-size: 0.7rem; color: var(--text-muted);
    margin-top: 0.2rem;
}

/* ── Slide animation for toggle forms ────────────────────────── */
.slide-form {
    overflow: hidden; transition: max-height 0.35s ease, opacity 0.3s ease, margin 0.3s ease;
    max-height: 0; opacity: 0; margin-top: 0 !important;
}
.slide-form.open {
    max-height: 500px; opacity: 1; margin-top: 0.75rem !important;
}

/* ── Fade-in animations ─────────────────────────────────────── */
.fade-in { animation: fadeIn 0.35s ease both; }
.fade-in-up { animation: fadeInUp 0.35s ease both; }
.stagger-1 { animation-delay: 0.04s; }
.stagger-2 { animation-delay: 0.08s; }
.stagger-3 { animation-delay: 0.12s; }
.stagger-4 { animation-delay: 0.16s; }
.stagger-5 { animation-delay: 0.2s; }
.stagger-6 { animation-delay: 0.24s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Pagination ─────────────────────────────────────────────── */
.pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 0.4rem; margin-top: 1.5rem;
}
.pagination a, .pagination span {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 2rem; height: 2rem; padding: 0 0.5rem;
    border-radius: var(--radius-sm); font-size: 0.85rem;
    background: var(--surface); border: 1px solid var(--border);
    color: var(--text); transition: all 0.15s; text-decoration: none;
}
.pagination a:hover { background: var(--surface-2); border-color: var(--primary); }
.pagination .current {
    background: var(--primary); border-color: var(--primary); color: white;
}

/* ── Customer mini-card ─────────────────────────────────────── */
.customer-mini-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1rem;
    display: flex; flex-direction: column; gap: 0.5rem;
    transition: all 0.2s; text-decoration: none !important; color: inherit !important;
    box-shadow: var(--shadow-sm);
}
.customer-mini-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.customer-mini-card .cmc-header {
    display: flex; justify-content: space-between; align-items: center;
}
.customer-mini-card .cmc-name { font-weight: 600; font-size: 0.95rem; color: var(--text); }
.customer-mini-card .cmc-stats {
    display: flex; justify-content: space-between; font-size: 0.8rem;
    color: var(--text-muted);
}
.customer-mini-card .cmc-stats span { display: flex; align-items: center; gap: 0.25rem; }

/* ── Mobile top bar ─────────────────────────────────────────── */
.mobile-top-bar {
    display: none; align-items: center; gap: 0.75rem;
    padding: 0.75rem 0; margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}
.mobile-top-bar .mobile-title {
    font-size: 1rem; font-weight: 600;
    background: linear-gradient(135deg, var(--primary), #a78bfa);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── Responsive: hamburger & mobile sidebar ─────────────────── */
.hamburger {
    display: none; background: none; border: none; color: var(--text);
    font-size: 1.5rem; cursor: pointer; padding: 0.25rem; line-height: 1;
    border-radius: 4px;
}
.hamburger:hover { background: var(--surface-2); }
.sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.55);
    z-index: 9; animation: fadeIn 0.2s ease;
}
.sidebar-overlay.open { display: block; }

/* ── Filter card improvements ───────────────────────────────── */
.filter-badge {
    display: inline-flex; align-items: center; gap: 0.3rem;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 999px; padding: 0.2rem 0.6rem; font-size: 0.75rem;
}
.filter-badge .remove {
    cursor: pointer; opacity: 0.5; font-size: 1rem; line-height: 1;
}
.filter-badge .remove:hover { opacity: 1; }

/* ── Scrollbar styling ──────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ── Details / summary styling ───────────────────────────────── */
details summary { cursor: pointer; font-size: 0.9rem; color: var(--text-muted);
    user-select: none; padding: 0.15rem 0; transition: color 0.15s; }
details summary:hover { color: var(--text); }
details summary::marker { color: var(--text-muted); }

/* ── Responsive breakpoints ──────────────────────────────────── */
@media (max-width: 768px) {
    .hamburger { display: block; }
    .sidebar {
        transform: translateX(-100%); transition: transform 0.3s ease;
    }
    .sidebar.open { transform: translateX(0); }
    .mobile-top-bar { display: flex; }
    .main-content { margin-left: 0; padding: 1rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
    .stats-grid-md { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
    .form-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    table { font-size: 0.8rem; }
    th, td { padding: 0.45rem 0.5rem; }
    .toast-container { left: 1rem; right: 1rem; bottom: auto; }
    .toast { max-width: 100%; }
    .modal { min-width: auto; width: 95vw; }
    .action-buttons { flex-direction: column; gap: 0.25rem; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
    .stat-card { padding: 0.75rem; }
    .stat-card .stat-value { font-size: 1.5rem; }
    
    .stats-grid-md { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
    .stat-card-md { padding: 0.75rem; }
    .btn { padding: 0.5rem 1rem; font-size: 0.8rem; }
    .login-container { padding: 1.5rem; }
}
