/* ============================================
   Sales Insight V2 — Design System
   Mobile-First · Dark Premium · Glassmorphism
   ============================================ */

:root {
    /* Base colors */
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: #1a1f35;
    --bg-card-hover: #222841;
    --bg-input: #151b2e;
    --bg-surface: #1e2235;
    --border: #2a3150;
    --border-active: #4f6dff;

    /* Text */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Accents */
    --accent-blue: #4f6dff;
    --accent-cyan: #06d6a0;
    --accent-purple: #a855f7;
    --accent-rose: #f43f5e;
    --accent-amber: #f59e0b;
    --accent-teal: #14b8a6;

    /* Gradients */
    --gradient-blue: linear-gradient(135deg, #4f6dff 0%, #7c3aed 100%);
    --gradient-cyan: linear-gradient(135deg, #06d6a0 0%, #14b8a6 100%);
    --gradient-rose: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
    --gradient-amber: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --gradient-purple: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
    --shadow-glow-blue: 0 0 20px rgba(79,109,255,0.2);

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

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

    /* Safe areas */
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --bottom-bar-h: 60px;
}

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

html { 
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    /* Mobile: pad bottom for tab bar */
    padding-bottom: calc(var(--bottom-bar-h) + var(--safe-bottom) + 8px);
}

/* ============================================
   TOP NAVIGATION (always visible)
   ============================================ */

.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 14, 26, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 0 1rem;
}

.nav-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
    flex-shrink: 0;
}

.nav-brand .icon {
    width: 32px;
    height: 32px;
    background: var(--gradient-blue);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

/* Desktop nav links — HIDDEN on mobile */
.nav-links {
    display: none;
    list-style: none;
    gap: 2px;
}

.nav-links a {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    transition: var(--transition);
    white-space: nowrap;
}

.nav-links a:hover { color: var(--text-primary); background: var(--bg-card); }
.nav-links a.active { color: var(--accent-blue); background: rgba(79,109,255,0.1); }

.nav-data-badge {
    display: none;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 16px;
    background: rgba(6,214,160,0.1);
    color: var(--accent-cyan);
    font-size: 0.7rem;
    font-weight: 600;
}

.nav-data-badge .dot {
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--accent-cyan);
    animation: pulse-dot 2s infinite;
}

.version-badge {
    font-size: 0.55rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 5px;
    background: linear-gradient(135deg, rgba(79,109,255,0.25), rgba(168,85,247,0.25));
    color: var(--accent-blue);
    border: 1px solid rgba(79,109,255,0.3);
    letter-spacing: 0.04em;
    margin-left: 2px;
    vertical-align: middle;
}

/* Hamburger — hidden on desktop, visible on mobile */
.hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1.2rem;
    width: 40px;
    height: 40px;
    cursor: pointer;
    transition: var(--transition);
}
.hamburger:hover { border-color: var(--accent-blue); background: rgba(79,109,255,0.1); }

/* User badge */
.user-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 6px 3px 3px;
    border-radius: 20px;
    background: rgba(79,109,255,0.1);
    border: 1px solid rgba(79,109,255,0.2);
}

.user-avatar {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--gradient-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: white;
}

.user-name {
    display: none;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.btn-logout {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 2px 4px;
    border-radius: 4px;
    transition: var(--transition);
}
.btn-logout:hover { color: var(--accent-rose); background: rgba(244,63,94,0.1); }

/* ============================================
   BOTTOM TAB BAR (Mobile only)
   ============================================ */

.bottom-tabs {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: rgba(10, 14, 26, 0.95);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid var(--border);
    padding-bottom: var(--safe-bottom);
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    height: calc(var(--bottom-bar-h) + var(--safe-bottom));
}

.bottom-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 1;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.62rem;
    font-weight: 600;
    padding: 6px 2px;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
    position: relative;
}

.bottom-tab .tab-icon { font-size: 1.2rem; line-height: 1; }
.bottom-tab .tab-label { letter-spacing: 0.02em; }
.bottom-tab.active { color: var(--accent-blue); }
.bottom-tab.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 25%;
    right: 25%;
    height: 2px;
    background: var(--accent-blue);
    border-radius: 0 0 2px 2px;
}

/* More menu overlay */
.more-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 199;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.more-menu-overlay.show { opacity: 1; pointer-events: auto; }

.more-menu {
    position: fixed;
    bottom: calc(var(--bottom-bar-h) + var(--safe-bottom));
    left: 0;
    right: 0;
    z-index: 201;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 1rem;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 60vh;
    overflow-y: auto;
}
.more-menu.show { transform: translateY(0); }

.more-menu-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.more-menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 500;
    transition: var(--transition);
    background: rgba(42,49,80,0.3);
}
.more-menu-item:hover { background: rgba(79,109,255,0.1); color: var(--text-primary); }
.more-menu-item .menu-icon { font-size: 1.3rem; }
.more-menu-item.active { color: var(--accent-blue); background: rgba(79,109,255,0.15); }

/* ============================================
   MAIN LAYOUT
   ============================================ */

.main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
    min-height: 60vh;
}

.page-header { margin-bottom: 1rem; }

.page-header h1 {
    font-size: 1.35rem;
    font-weight: 800;
    background: var(--gradient-blue);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 2px;
}

.page-header p { color: var(--text-secondary); font-size: 0.8rem; }

/* ============================================
   CARDS
   ============================================ */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem;
    transition: var(--transition);
    margin-bottom: 1rem;
}

.card:hover {
    border-color: rgba(79,109,255,0.3);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.card-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ============================================
   KPI CARDS — Mobile: 2 cols, Desktop: auto-fit
   ============================================ */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.85rem;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    border-radius: 3px 3px 0 0;
}

.kpi-card.blue::before { background: var(--gradient-blue); }
.kpi-card.green::before { background: var(--gradient-cyan); }
.kpi-card.cyan::before { background: var(--gradient-cyan); }
.kpi-card.purple::before { background: var(--gradient-purple); }
.kpi-card.amber::before { background: var(--gradient-amber); }
.kpi-card.rose::before, .kpi-card.red::before { background: var(--gradient-rose); }
.kpi-card.teal::before { background: linear-gradient(135deg, #14b8a6, #06d6a0); }

.kpi-card:active { transform: scale(0.98); }

.kpi-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.3rem;
    display: flex;
    align-items: center;
    gap: 4px;
}

.kpi-value {
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 0.15rem;
    word-break: break-word;
}

.kpi-card.blue .kpi-value { color: var(--accent-blue); }
.kpi-card.green .kpi-value, .kpi-card.cyan .kpi-value { color: var(--accent-cyan); }
.kpi-card.purple .kpi-value { color: var(--accent-purple); }
.kpi-card.amber .kpi-value { color: var(--accent-amber); }
.kpi-card.rose .kpi-value, .kpi-card.red .kpi-value { color: var(--accent-rose); }
.kpi-card.teal .kpi-value { color: var(--accent-teal); }

.kpi-change {
    font-size: 0.68rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 3px;
}

.kpi-change.positive, .positive { color: var(--accent-cyan); }
.kpi-change.negative, .negative { color: var(--accent-rose); }
.kpi-change.neutral { color: var(--text-muted); }
/* Legacy classes (unused but safe) */
.kpi-change.up { color: var(--accent-cyan); }
.kpi-change.down { color: var(--accent-rose); }

/* ============================================
   CHARTS
   ============================================ */

.charts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.chart-container {
    position: relative;
    height: 260px;
}

/* ============================================
   FILTER BAR — Horizontal scroll on mobile
   ============================================ */

.filter-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1 1 auto;
    min-width: 0;
}

.filter-label {
    display: block;
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.filter-select,
.form-input {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
    cursor: pointer;
    min-height: 44px;
    width: 100%;
    -webkit-appearance: none;
}

.filter-select:focus,
.form-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(79,109,255,0.15);
}

.form-input { cursor: text; }
.form-group { margin-bottom: 0.75rem; }

/* Filter Toggle Button (mobile) */
.filter-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    min-height: 40px;
}
.filter-toggle:hover { border-color: var(--accent-blue); }
.filter-toggle.has-filters { color: var(--accent-blue); border-color: rgba(79,109,255,0.4); }

/* Filter drawer (mobile) */
.filter-drawer {
    display: none;
    position: fixed;
    bottom: calc(var(--bottom-bar-h) + var(--safe-bottom));
    left: 0; right: 0;
    z-index: 150;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 1rem;
    max-height: 55vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    box-shadow: 0 -8px 30px rgba(0,0,0,0.4);
}
.filter-drawer.show { display: block; transform: translateY(0); }
.filter-drawer .filter-group { margin-bottom: 0.6rem; }
.filter-drawer .filter-select,
.filter-drawer .form-input { width: 100%; }

/* ============================================
   DATA TABLES — scrollable on mobile
   ============================================ */

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table th {
    text-align: left;
    padding: 0.6rem 0.5rem;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-card);
    white-space: nowrap;
}

.data-table td {
    padding: 0.55rem 0.5rem;
    font-size: 0.8rem;
    border-bottom: 1px solid rgba(42,49,80,0.4);
    color: var(--text-primary);
}

.data-table tbody tr { transition: background 0.2s; }
.data-table tbody tr:hover { background: var(--bg-card-hover); }
.data-table tbody tr:active { background: rgba(79,109,255,0.08); }

/* Mobile card layout for tables */
.mobile-cards { display: none; }

.m-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.85rem;
    margin-bottom: 0.5rem;
    transition: var(--transition);
}
.m-card:active { background: var(--bg-card-hover); transform: scale(0.99); }

.m-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.m-card-title {
    font-weight: 600;
    font-size: 0.85rem;
    line-height: 1.3;
    flex: 1;
}

.m-card-subtitle {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.m-card-metrics {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
}

.m-card-metric {
    display: flex;
    flex-direction: column;
}

.m-card-metric-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
}

.m-card-metric-value {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-primary);
}

.m-card-metric-value.highlight { color: var(--accent-blue); }

/* Rank badge */
.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px; height: 26px;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
    background: rgba(42,49,80,0.5);
    color: var(--text-secondary);
    flex-shrink: 0;
}

.rank-badge.gold { background: linear-gradient(135deg,#f59e0b,#d97706); color: #fff; }
.rank-badge.silver { background: linear-gradient(135deg,#94a3b8,#64748b); color: #fff; }
.rank-badge.bronze { background: linear-gradient(135deg,#cd7f32,#a0522d); color: #fff; }

/* Grade badge (ABC) */
.grade-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px; height: 22px;
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 700;
}

.grade-A { background: rgba(34,197,94,0.2); color: #22c55e; }
.grade-B { background: rgba(245,158,11,0.2); color: #f59e0b; }
.grade-C { background: rgba(239,68,68,0.2); color: #ef4444; }

/* ============================================
   BUTTONS — touch-friendly
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
}

.btn-primary {
    background: var(--gradient-blue);
    color: white;
    box-shadow: 0 2px 10px rgba(79,109,255,0.3);
}
.btn-primary:hover { box-shadow: 0 4px 15px rgba(79,109,255,0.5); }
.btn-primary:active { transform: scale(0.97); }

.btn-danger {
    background: rgba(244,63,94,0.15);
    color: var(--accent-rose);
    border: 1px solid rgba(244,63,94,0.3);
}
.btn-danger:hover { background: rgba(244,63,94,0.25); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text-primary); border-color: var(--border-active); }

/* ============================================
   PERIOD FILTER PILLS
   ============================================ */

.period-filter {
    display: flex;
    gap: 3px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 3px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.period-btn {
    padding: 8px 14px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    white-space: nowrap;
    min-height: 36px;
}
.period-btn:hover { color: var(--text-primary); }
.period-btn.active {
    background: var(--accent-blue);
    color: white;
    box-shadow: 0 2px 8px rgba(79,109,255,0.4);
}

/* ============================================
   BADGES
   ============================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge.success { background: rgba(6,214,160,0.15); color: var(--accent-cyan); }
.badge.error { background: rgba(244,63,94,0.15); color: var(--accent-rose); }
.badge.partial { background: rgba(245,158,11,0.15); color: var(--accent-amber); }
.badge-admin { background: rgba(124,58,237,0.15); color: #a78bfa; border: 1px solid rgba(124,58,237,0.3); }
.badge-user { background: rgba(20,184,166,0.15); color: #2dd4bf; border: 1px solid rgba(20,184,166,0.3); }

/* ============================================
   UPLOAD ZONE
   ============================================ */

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-xl);
    padding: 2rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-card);
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--accent-blue);
    background: rgba(79,109,255,0.05);
}
.upload-zone .icon { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.6; }
.upload-zone h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0.4rem; }
.upload-zone p { color: var(--text-secondary); font-size: 0.82rem; }

/* ============================================
   PROGRESS BAR
   ============================================ */

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
    margin: 0.75rem 0;
}
.progress-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }
.progress-fill.blue { background: var(--gradient-blue); }
.progress-fill.cyan { background: var(--gradient-cyan); }

/* ============================================
   SELECT INPUT
   ============================================ */

.select-input {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
    cursor: pointer;
    min-height: 44px;
}
.select-input:focus { border-color: var(--accent-blue); }

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 0.75rem; opacity: 0.4; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.4rem; }

/* ============================================
   LOADING SPINNER
   ============================================ */

.loading-spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

/* ============================================
   LOGIN CARD
   ============================================ */

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 2rem 1.5rem;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
    margin: 0 1rem;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast-container {
    position: fixed;
    top: 64px;
    left: 1rem; right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: none;
}

.toast {
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    font-weight: 500;
    animation: slideDown 0.3s ease-out;
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    text-align: center;
}

.toast.success { background: rgba(6,214,160,0.2); border: 1px solid rgba(6,214,160,0.3); color: var(--accent-cyan); }
.toast.error { background: rgba(244,63,94,0.2); border: 1px solid rgba(244,63,94,0.3); color: var(--accent-rose); }
.toast.info { background: rgba(79,109,255,0.2); border: 1px solid rgba(79,109,255,0.3); color: var(--accent-blue); }

/* ============================================
   FOOTER
   ============================================ */

.app-footer {
    margin-top: 2rem;
    border-top: 1px solid var(--border);
    background: rgba(17,24,39,0.6);
}

.footer-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.5rem;
}

.footer-brand { display: flex; align-items: center; gap: 0.6rem; }

.footer-logo {
    font-size: 1.2rem;
    width: 32px; height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-blue);
    border-radius: 8px;
}

.footer-title { font-weight: 700; font-size: 0.85rem; color: var(--text-primary); }
.footer-ver {
    font-size: 0.6rem; font-weight: 700;
    padding: 1px 5px; border-radius: 4px;
    background: rgba(79,109,255,0.2); color: var(--accent-blue);
    vertical-align: middle; margin-left: 3px;
}
.footer-sub { font-size: 0.7rem; color: var(--text-muted); margin-top: 1px; }
.footer-meta { text-align: center; }
.footer-author { font-size: 0.75rem; color: var(--text-secondary); }
.footer-author strong { color: var(--accent-purple); font-weight: 700; }
.footer-update { font-size: 0.65rem; color: var(--text-muted); margin-top: 1px; }

/* ============================================
   UTILITY CLASSES
   ============================================ */

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.78rem; }
.font-mono { font-family: 'JetBrains Mono', 'Fira Code', monospace; }

/* ============================================
   ANIMATIONS
   ============================================ */

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

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes spin { to { transform: rotate(360deg); } }

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.animate-fade-in { animation: fadeInUp 0.4s ease-out forwards; }

.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 infinite;
    border-radius: var(--radius-sm);
}

/* Heatmap / Store specific */
.row-highlight { background: rgba(99,102,241,0.08) !important; }
.heatmap-cell {
    font-size: 0.7rem; font-weight: 600;
    padding: 0.4rem 0.25rem !important;
    min-width: 55px;
    border-radius: 4px;
    transition: transform 0.2s;
    text-align: center;
}
.heatmap-cell:hover { transform: scale(1.05); }
.store-table th, .store-table td { padding: 0.5rem 0.4rem !important; }
.heatmap-table td, .heatmap-table th { text-align: center; }

/* Compare table */
.cmp-table th, .cmp-table td { padding: 0.5rem 0.5rem !important; }

/* ============================================
   DESKTOP BREAKPOINT (≥768px)
   ============================================ */

@media (min-width: 768px) {
    body {
        padding-bottom: 0; /* No bottom bar on desktop */
    }

    .nav { padding: 0 1.5rem; }
    .nav-inner { height: 64px; }
    .nav-brand { font-size: 1.2rem; gap: 10px; }
    .nav-brand .icon { width: 36px; height: 36px; font-size: 1.1rem; }

    /* Show desktop nav, hide hamburger & bottom tabs */
    .nav-links { display: flex; }
    .hamburger { display: none; }
    .bottom-tabs { display: none; }
    .more-menu-overlay, .more-menu { display: none !important; }

    .nav-data-badge { display: flex; }
    .user-name { display: inline; }

    .main { padding: 1.5rem; }

    .page-header h1 { font-size: 1.6rem; }
    .page-header p { font-size: 0.88rem; }

    .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
    .kpi-card { padding: 1.15rem; }
    .kpi-value { font-size: 1.6rem; }
    .kpi-label { font-size: 0.78rem; }
    .kpi-change { font-size: 0.72rem; }
    .kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

    .charts-grid { grid-template-columns: 2fr 1fr; }
    .chart-container { height: 320px; }

    .card { padding: 1.5rem; border-radius: var(--radius-lg); margin-bottom: 1.5rem; }
    .card:hover { border-color: var(--border-active); box-shadow: var(--shadow-glow-blue); }
    .card-title { font-size: 0.83rem; }

    .data-table th { padding: 0.7rem 0.8rem; font-size: 0.72rem; }
    .data-table td { padding: 0.65rem 0.8rem; font-size: 0.83rem; }

    .filter-bar { gap: 0.75rem; }
    .filter-group { flex: 0 1 auto; }
    .filter-select, .form-input { min-width: 130px; width: auto; padding: 8px 14px; min-height: 38px; }

    .filter-toggle { display: none; }
    .filter-drawer { display: none !important; }

    .toast-container { left: auto; right: 20px; max-width: 380px; }

    .footer-inner { flex-direction: row; justify-content: space-between; padding: 1.2rem 1.5rem; text-align: left; }
    .footer-meta { text-align: right; }

    .login-card { padding: 2.5rem; margin: 0; }

    .btn { min-height: 38px; }
}

/* ============================================
   LARGE DESKTOP (≥1200px)
   ============================================ */

@media (min-width: 1200px) {
    .nav-links a { padding: 8px 14px; font-size: 0.83rem; }
}

/* Mobile nav menu when hamburger is clicked (only visible at <768px via .show) */
@media (max-width: 767.98px) {
    .nav-links {
        display: none;
        position: absolute;
        top: 56px;
        left: 0; right: 0;
        background: rgba(10, 14, 26, 0.97);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        flex-direction: column;
        padding: 0.75rem;
        border-bottom: 1px solid var(--border);
        z-index: 200;
        max-height: 70vh;
        overflow-y: auto;
    }

    .nav-links.show { display: flex; }

    .nav-links a {
        padding: 12px 14px;
        border-radius: var(--radius-sm);
        font-size: 0.88rem;
        min-height: 44px;
    }

    /* Tables: add scroll hint */
    .table-scroll-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -0.5rem;
        padding: 0 0.5rem;
    }

    .version-badge { display: none; }
}

/* Very small screens */
@media (max-width: 374px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .kpi-value { font-size: 1.1rem; }
    .main { padding: 0.75rem; }
    .bottom-tab .tab-label { font-size: 0.58rem; }
}