/* ═══════════════════════════════════════════════════════
   KranCatalog — Industrial Dark Theme
   ═══════════════════════════════════════════════════════ */

:root {
    /* Colors */
    --bg-primary: #070a0f;
    --bg-secondary: #0e131c;
    --bg-card: #151d2b;
    --bg-card-hover: #1c2536;
    --bg-input: #1a2332;
    --bg-elevated: #1e283a;
    --border: #273040;
    --border-light: #1f2838;
    --border-active: #f59e0b;
    --text: #e2e8f0;
    --text-secondary: #8899b4;
    --text-muted: #4d5c72;
    --accent: #f59e0b;
    --accent-hover: #e59500;
    --accent-glow: rgba(245, 158, 11, 0.15);
    --accent-subtle: rgba(245, 158, 11, 0.08);
    --danger: #ef4444;
    --success: #22c55e;
    --info: #3b82f6;
    --warning: #f59e0b;

    /* Spacing (4px system) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;

    /* Typography */
    --font-heading: 'Inter', 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', monospace;

    /* Radii */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(245, 158, 11, 0.15);

    /* Z-index */
    --z-base: 0;
    --z-sidebar: 100;
    --z-mobile-nav: 110;
    --z-modal: 200;
    --z-toast: 300;

    /* Transitions */
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed: 0px;
    --max-content: 1200px;
    --mobile-header-height: 56px;
    --mobile-nav-height: 64px;
}

/* ══ Reset ══ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; }

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ══ Scrollbar ══ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ══ Selection ══ */
::selection { background: var(--accent-glow); color: var(--accent); }

/* ══ Typography ══ */
h1, h2, h3, h4, h5 { font-family: var(--font-heading); line-height: 1.25; letter-spacing: -0.02em; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ══ Layout ══ */
.app-container { display: none; min-height: 100vh; }
body.app-mode .app-container { display: flex; }
body.app-mode .auth-page { display: none; }

/* ══ Sidebar (desktop) ══ */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: var(--space-6) var(--space-4);
    display: flex;
    flex-direction: column;
    z-index: var(--z-sidebar);
    overflow-y: auto;
    transition: transform var(--transition-slow);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: var(--space-8);
    text-decoration: none;
    letter-spacing: -0.5px;
}
.sidebar-logo svg { width: 28px; height: 28px; flex-shrink: 0; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.sidebar-section {
    padding: var(--space-4) var(--space-3) var(--space-1);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    transition: all var(--transition);
}
.sidebar-link:hover { background: var(--bg-card); color: var(--text); }
.sidebar-link.active { background: var(--accent-subtle); color: var(--accent); }
.sidebar-link svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-user {
    padding: var(--space-3);
    border-top: 1px solid var(--border);
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.sidebar-user-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--accent-subtle);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px;
    flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* ══ Main Content ══ */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: var(--space-8);
    max-width: var(--max-content);
    width: calc(100% - var(--sidebar-width));
}

.page { display: none; }
.page.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ══ Page Header ══ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-6);
    gap: var(--space-4);
}
.page-header-left { }
.page-title { font-size: 26px; font-weight: 700; }
.page-subtitle { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }

/* ══ Cards ══ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-5);
    transition: border-color var(--transition);
}
.card:hover { border-color: var(--border-active); }
.card-inner {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-5);
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
}
.card-title { font-size: 17px; font-weight: 600; }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-4);
}

/* ══ Stats ══ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-6);
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-5);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--accent);
    opacity: 0.3;
}
.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--accent);
    font-family: var(--font-heading);
}
.stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

/* ══ Buttons ══ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    text-decoration: none;
    font-family: var(--font-body);
    line-height: 1.2;
    white-space: nowrap;
    min-height: 40px;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--shadow-glow); }
.btn-secondary { background: var(--bg-input); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--text-muted); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-card); color: var(--text); }
.btn-sm { padding: 5px 12px; font-size: 13px; min-height: 32px; }
.btn-lg { padding: 12px 24px; font-size: 15px; min-height: 48px; }
.btn-icon { padding: 8px; min-height: 36px; min-width: 36px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:disabled:active { transform: none; }

/* ══ Forms ══ */
.form-group { margin-bottom: var(--space-4); }
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    font-family: var(--font-body);
    transition: all var(--transition);
    min-height: 42px;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-textarea { resize: vertical; min-height: 90px; }
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}
.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238899b4' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}
.form-input::placeholder { color: var(--text-muted); }

.form-check {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 14px;
    cursor: pointer;
    min-height: 40px;
}
.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ══ Badges ══ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}
.badge-open { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.badge-progress { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.badge-closed { background: rgba(107, 114, 128, 0.15); color: #9ca3af; }
.badge-cancelled { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.badge-pending { background: var(--accent-glow); color: var(--accent); }
.badge-accepted { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.badge-rejected { background: rgba(239, 68, 68, 0.15); color: #f87171; }

.badge-tower { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.badge-mobile { background: rgba(59, 130, 246, 0.12); color: #60a5fa; }
.badge-crawler { background: rgba(34, 197, 94, 0.12); color: #4ade80; }
.badge-truck { background: rgba(139, 92, 246, 0.12); color: #a78bfa; }
.badge-gantry { background: rgba(236, 72, 153, 0.12); color: #f472b6; }

/* ══ Tables ══ */
.table-container { overflow-x: auto; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; }
th {
    text-align: left;
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}
td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-card-hover); }

/* ══ Filter Bar ══ */
.filter-bar {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin-bottom: var(--space-5);
    padding: var(--space-4);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    align-items: flex-end;
}
.filter-bar .form-group { margin-bottom: 0; min-width: 150px; }
.filter-bar .btn { min-height: 42px; }

/* ══ Equipment Params Grid ══ */
.equip-params {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: var(--space-2);
    margin: var(--space-4) 0;
}
.equip-param {
    background: var(--bg-input);
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}
.equip-param-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.equip-param-value { font-size: 17px; font-weight: 700; margin-top: 2px; font-family: var(--font-mono); }

/* ══ Empty State ══ */
.empty-state {
    text-align: center;
    padding: var(--space-12) var(--space-4);
    color: var(--text-muted);
}
.empty-state svg { width: 56px; height: 56px; margin-bottom: var(--space-4); opacity: 0.25; }
.empty-state h3 { font-size: 18px; margin-bottom: var(--space-1); color: var(--text-secondary); }
.empty-state p { font-size: 14px; }

/* ══ Modal / Overlay ══ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    animation: fadeIn 0.15s;
}
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: var(--space-5); }
.modal-actions { display: flex; gap: var(--space-3); justify-content: flex-end; margin-top: var(--space-5); }

/* ══ Auth Page ══ */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
    padding: var(--space-4);
}
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-8);
    width: 100%;
    max-width: 420px;
    animation: fadeIn 0.3s ease;
}
.auth-logo { text-align: center; margin-bottom: var(--space-6); }
.auth-logo svg { width: 56px; height: 56px; margin: 0 auto var(--space-3); }
.auth-logo h1 { font-size: 24px; color: var(--accent); font-weight: 800; }
.auth-logo p { color: var(--text-muted); font-size: 14px; margin-top: 2px; }
.auth-tabs {
    display: flex;
    margin-bottom: var(--space-5);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.auth-tab {
    flex: 1;
    padding: var(--space-2) var(--space-3);
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    background: var(--bg-input);
    color: var(--text-muted);
    border: none;
    transition: all var(--transition);
}
.auth-tab.active { background: var(--accent-subtle); color: var(--accent); }
.auth-tab + .auth-tab { border-left: 1px solid var(--border); }
.auth-error { color: var(--danger); font-size: 13px; margin-bottom: var(--space-3); display: none; }

/* ══ Toast ══ */
.toast {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    z-index: var(--z-toast);
    animation: slideIn 0.25s ease;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
    line-height: 1.4;
}
.toast-success { background: var(--success); color: #000; }
.toast-error { background: var(--danger); color: #fff; }
.toast-info { background: var(--bg-elevated); color: var(--text); border: 1px solid var(--border); }

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

/* ══ Hero ══ */
.hero {
    text-align: center;
    padding: var(--space-12) var(--space-4) var(--space-8);
    position: relative;
}
.hero::before {
    content: '';
    position: absolute;
    top: 0; left: 50%;
    transform: translateX(-50%);
    width: 500px; height: 500px;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 65%);
    pointer-events: none;
}
.hero h1 {
    font-size: clamp(28px, 5vw, 48px);
    font-weight: 800;
    margin-bottom: var(--space-3);
    position: relative;
}
.hero h1 span { color: var(--accent); }
.hero p {
    font-size: clamp(15px, 2vw, 18px);
    color: var(--text-secondary);
    max-width: 560px;
    margin: 0 auto var(--space-6);
    position: relative;
    line-height: 1.7;
}
.hero-actions {
    display: flex;
    gap: var(--space-3);
    justify-content: center;
    flex-wrap: wrap;
    position: relative;
}

/* ══ Search Hero ══ */
.search-hero {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-5);
    margin-bottom: var(--space-6);
}
.search-hero h2 { font-size: 18px; font-weight: 600; margin-bottom: var(--space-4); }

/* ══ Map ══ */
.map-mode-btn.active {
    background: var(--accent-subtle) !important;
    color: var(--accent) !important;
    border-color: var(--accent) !important;
}
.map-popup .leaflet-popup-content-wrapper {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.map-popup .leaflet-popup-tip {
    background: var(--bg-card);
    border: 1px solid var(--border);
}
/* Fix Leaflet container on dark theme */
.leaflet-container {
    background: #1a1a2e !important;
}

/* ══ Responsive: Mobile (< 768px) ══ */
@media (max-width: 767px) {
    /* Hide desktop sidebar */
    .sidebar {
        transform: translateX(-100%);
        width: 300px;
        display: none;
        -webkit-tap-highlight-color: transparent;
    }
    .sidebar.open {
        transform: translateX(0);
        display: flex;
    }
    .sidebar-link {
        min-height: 48px;
        padding: var(--space-3) var(--space-4);
        font-size: 15px;
        gap: var(--space-3);
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    .sidebar-link:active {
        background: var(--accent-subtle);
    }
    .sidebar-link svg { width: 20px; height: 20px; }

    .main-content {
        margin-left: 0;
        padding: var(--space-4);
        padding-top: calc(var(--mobile-header-height) + env(safe-area-inset-top, 0px) + var(--space-3));
        padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px) + var(--space-3));
        width: 100%;
    }

    /* Mobile header bar — touch-optimised */
    .mobile-header {
        display: flex !important;
        position: fixed;
        top: 0; left: 0; right: 0;
        height: var(--mobile-header-height);
        /* Safe area for notched phones */
        padding-top: env(safe-area-inset-top, 0px);
        height: calc(var(--mobile-header-height) + env(safe-area-inset-top, 0px));
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border);
        z-index: calc(var(--z-sidebar) - 1);
        padding-left: var(--space-4);
        padding-right: var(--space-4);
        align-items: center;
        gap: var(--space-3);
        -webkit-tap-highlight-color: transparent;
    }
    .mobile-header-title {
        font-size: 17px;
        font-weight: 700;
        color: var(--accent);
        flex: 1;
    }
    .mobile-hamburger {
        background: none;
        border: none;
        color: var(--text);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        border-radius: var(--radius-sm);
        transition: background var(--transition);
        flex-shrink: 0;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    .mobile-hamburger:active {
        background: var(--accent-subtle);
    }
    /* Mobile header AI button — match hamburger touch area */
    #mobile-ai-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: var(--radius-sm);
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    #mobile-ai-btn:active {
        background: var(--accent-subtle);
    }
    #mobile-ai-btn svg {
        width: 22px;
        height: 22px;
    }

    /* Mobile bottom nav — touch-optimised */
    .mobile-nav {
        display: flex !important;
        position: fixed;
        bottom: 0; left: 0; right: 0;
        /* Safe area for notched phones */
        height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: var(--bg-secondary);
        border-top: 1px solid var(--border);
        z-index: var(--z-mobile-nav);
        padding-left: 0;
        padding-right: 0;
        align-items: stretch;
        justify-content: space-evenly;
        -webkit-tap-highlight-color: transparent;
        user-select: none;
        /* Subtle top shadow for depth */
        box-shadow: 0 -2px 12px rgba(0,0,0,0.25);
    }
    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        flex: 1;
        min-width: 0;
        max-width: 80px;
        padding: 4px 2px;
        background: none;
        border: none;
        color: var(--text-muted);
        cursor: pointer;
        font-size: 10px;
        font-weight: 500;
        line-height: 1.2;
        transition: color var(--transition), background var(--transition);
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
        position: relative;
        /* Minimum 48px tap target width */
        min-width: 48px;
    }
    .mobile-nav-item:active {
        background: var(--accent-subtle);
    }
    .mobile-nav-item svg {
        width: 24px;
        height: 24px;
        display: block;
        transition: transform 0.15s ease;
        flex-shrink: 0;
    }
    .mobile-nav-item:active svg {
        transform: scale(0.9);
    }
    .mobile-nav-item.active {
        color: var(--accent);
    }
    .mobile-nav-item.active::after {
        content: '';
        position: absolute;
        top: -1px;
        left: 50%;
        transform: translateX(-50%);
        width: 24px;
        height: 3px;
        border-radius: 0 0 3px 3px;
        background: var(--accent);
        transition: width var(--transition);
    }
    /* Label text */
    .mobile-nav-item span {
        font-size: 9px;
        font-weight: 600;
        letter-spacing: -0.1px;
        opacity: 0.85;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
    .mobile-nav-item.active span {
        opacity: 1;
    }
    /* Reduce spacing when too many items */
    @media (max-width: 360px) {
        .mobile-nav-item svg { width: 20px; height: 20px; }
        .mobile-nav-item span { font-size: 8px; }
        .mobile-nav-item { padding: 4px 1px; }
    }
    /* Larger phones can have more spacing */
    @media (min-width: 400px) {
        .mobile-nav-item svg { width: 26px; height: 26px; }
        .mobile-nav-item span { font-size: 10px; }
        .mobile-nav-item { gap: 4px; }
    }

    /* Page header stack */
    .page-header { flex-direction: column; align-items: stretch; gap: var(--space-3); }

    /* Card grid single column */
    .card-grid { grid-template-columns: 1fr; gap: var(--space-3); }

    /* Form rows */
    .form-row { grid-template-columns: 1fr; gap: var(--space-3); }

    /* Stats grid */
    .stats-grid { grid-template-columns: 1fr 1fr; gap: var(--space-2); }

    /* Filter bar */
    .filter-bar { flex-direction: column; padding: var(--space-3); }
    .filter-bar .form-group { min-width: unset; width: 100%; }
    .filter-bar .btn { width: 100%; }

    /* Equipment params */
    .equip-params { grid-template-columns: 1fr 1fr; gap: var(--space-2); }

    /* Auth card */
    .auth-card { padding: var(--space-6); }

    /* Modal */
    .modal { padding: var(--space-4); margin: var(--space-2); }

    /* Messages on mobile */
    #messages-layout { grid-template-columns: 1fr !important; height: calc(100vh - 300px) !important; }
    #messages-sidebar { display: block; }
    #messages-content { display: none; }
    #messages-layout.show-chat #messages-sidebar { display: none; }
    #messages-layout.show-chat #messages-content { display: flex; }

    /* Touch-optimised form elements */
    .form-input, .form-select, .form-textarea {
        min-height: 44px;
        font-size: 16px !important;  /* Prevent iOS zoom on focus */
        padding: var(--space-3) var(--space-3);
    }
    .btn {
        min-height: 44px;
        padding: 11px 20px;
    }
    .btn-sm {
        min-height: 36px;
        padding: 7px 14px;
    }
}

/* ══ Responsive: Tablet (768–1024px) ══ */
@media (min-width: 768px) and (max-width: 1023px) {
    .card-grid { grid-template-columns: 1fr 1fr; }
    .main-content { padding: var(--space-5); }
}

/* ══ Desktop only helpers ══ */
.mobile-header { display: none; }
.mobile-nav { display: none; }

/* ══ Sidebar overlay for mobile ══ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--z-sidebar) - 1);
}
.sidebar-overlay.open { display: block; }

/* ══ Utilities ══ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.font-bold { font-weight: 700; }
.font-mono { font-family: var(--font-mono); }
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid { display: grid; }
.hidden { display: none; }

/* ══ Loading spinner ══ */
.spinner {
    display: inline-flex;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══ Skeleton loading ══ */
.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
