:root {
    --sidebar-w: 220px;
    --topbar-h: 56px;
    --brand-color: #1565C0;
    --sidebar-bg: #0d1b2a;
    --sidebar-text: #cdd5e0;
    --sidebar-active: #1976D2;
}

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

body {
    background: #f4f6f9;
    min-height: 100vh;
    font-family: 'Segoe UI', system-ui, sans-serif;
}

/* ── Mobile topbar ───────────────────────────────────────────────────────── */
.mobile-topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: var(--sidebar-bg);
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 0 1rem;
    z-index: 1030;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: .25rem;
    display: flex;
    align-items: center;
}

.sidebar-toggle .material-symbols-outlined { font-size: 1.5rem; }

/* ── Sidebar overlay ─────────────────────────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1040;
}
.sidebar-overlay.visible { display: block; }

/* ── Layout wrapper ──────────────────────────────────────────────────────── */
.layout-wrapper {
    display: flex;
    min-height: 100vh;
    padding-top: var(--topbar-h);
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
#sidebar {
    display: none !important;
    position: fixed;
    top: var(--topbar-h);
    left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    z-index: 1050;
    overflow-y: auto;
    flex-direction: column;
    padding: 1rem;
}

#sidebar.open {
    display: flex !important;
    animation: slideInLeft .22s ease;
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); }
    to   { transform: translateX(0); }
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    color: #fff;
    text-decoration: none;
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: .02em;
}

#sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: .5rem;
    color: var(--sidebar-text);
    border-radius: 8px;
    padding: .45rem .75rem;
    font-size: .9rem;
    transition: background .15s, color .15s;
}

#sidebar .nav-link:hover,
#sidebar .nav-link.active {
    background: var(--sidebar-active);
    color: #fff;
}

/* ── Main content ────────────────────────────────────────────────────────── */
main { flex: 1; min-width: 0; width: 100%; }

/* ── Desktop (>=992px) ───────────────────────────────────────────────────── */
@media (min-width: 992px) {
    .layout-wrapper { padding-top: 0; }

    #sidebar {
        display: flex !important;
        position: sticky;
        top: 0;
        height: 100vh;
        flex-shrink: 0;
        animation: none;
    }

    .sidebar-overlay { display: none !important; }
}

/* ── Table Card Component ────────────────────────────────────────────────── */
/*
 * Usage:
 *   <div class="table-card">
 *     <div class="table-card-header">Title <span class="badge ...">N</span></div>
 *     <div class="table-responsive">
 *       <table class="table table-hover mb-0">...</table>
 *     </div>
 *   </div>
 */
.table-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    overflow: hidden;
}

.table-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 1rem;
    font-weight: 600;
    border-bottom: 1px solid rgba(0,0,0,.06);
    background: #fff;
}

.table-card .table { margin-bottom: 0; }

/* ── Stat cards ──────────────────────────────────────────────────────────── */
.stat-card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.stat-card .stat-icon { font-size: 2.2rem; opacity: .75; }

/* ── Status badges ───────────────────────────────────────────────────────── */
.badge-connected    { background: #2e7d32; }
.badge-disconnected { background: #757575; }
.badge-pending      { background: #e65100; }
.badge-in_transit   { background: #1565C0; }
.badge-delivered    { background: #2e7d32; }
.badge-failed       { background: #b71c1c; }
.badge-open         { background: #e65100; }
.badge-solved       { background: #2e7d32; }
.badge-not_solvable { background: #757575; }

/* ── Table ───────────────────────────────────────────────────────────────── */
.table th {
    font-weight: 600;
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #607d8b;
}

.table-responsive { -webkit-overflow-scrolling: touch; }

/* ── Misc ────────────────────────────────────────────────────────────────── */
.material-symbols-outlined {
    font-size: 1.2em;
    vertical-align: middle;
    line-height: 1;
}
