:root {
    /* Solid Dark UI Colors - High End Premium Edition */
    --bg-main: #05070e;
    --bg-sidebar: rgba(11, 14, 27, 0.85);
    --bg-card: rgba(15, 20, 35, 0.5);
    --bg-input: rgba(0, 0, 0, 0.3);
    
    --border-color: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.15);
    
    --text-primary: #f1f5f9;
    --text-secondary: #8b95a5;
    
    --accent-blue: #3b82f6;
    --accent-blue-hover: #2563eb;
    --accent-blue-bg: #1d2b4a;
    --accent-green: #10b981;
    --accent-yellow: #f59e0b;
    --accent-red: #ef4444;
    --accent-purple: #8b5cf6;
    
    --font-inter: 'Inter', -apple-system, sans-serif;
    --card-radius: 8px;
}

:root.theme-light {
    --bg-main: #f1f5f9;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #e2e8f0;
    
    --border-color: #e2e8f0;
    --border-light: #cbd5e1;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    
    --accent-blue-bg: rgba(59,130,246,0.08);
    
    --shadow-color: rgba(0, 0, 0, 0.06);
}

/* ── Light-mode overrides ── */
:root.theme-light body { background: #f1f5f9; }
:root.theme-light body::before { display: none !important; }  /* kill scan-lines */

:root.theme-light .sidebar {
    background: #ffffff !important;
    border-right: 1px solid #e2e8f0 !important;
    backdrop-filter: none !important;
    box-shadow: 2px 0 12px rgba(0,0,0,0.04);
}
:root.theme-light .sidebar nav a { color: #475569; }
:root.theme-light .sidebar nav a:hover { color: #0f172a; background: #f1f5f9; }
:root.theme-light .sidebar nav a.active { color: #1e40af; background: rgba(59,130,246,0.08); border-left-color: #3b82f6; }
:root.theme-light .logo img { filter: none !important; }

:root.theme-light .topbar,
:root.theme-light .ki-topbar {
    background: rgba(255,255,255,0.85) !important;
    border-bottom: 1px solid #e2e8f0 !important;
    backdrop-filter: blur(8px);
}

:root.theme-light .card,
:root.theme-light .chart-card,
:root.theme-light .kpi-cards .card,
:root.theme-light .shop-card,
:root.theme-light .log-card,
:root.theme-light .sys-kpi-card {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.02) !important;
}

:root.theme-light .welcome-toast { background: rgba(255,255,255,0.95)!important; border-color: #c4b5fd !important; }
:root.theme-light .welcome-toast .toast-name { color: #6d28d9; }

:root.theme-light select,
:root.theme-light input[type="text"],
:root.theme-light input[type="password"],
:root.theme-light input[type="date"],
:root.theme-light .inv-search,
:root.theme-light #searchInput {
    background: #f8fafc !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
}

:root.theme-light .quick-dates button {
    background: #ffffff; border-color: #cbd5e1; color: #475569;
}
:root.theme-light .quick-dates button:hover { background: #f1f5f9; color: #0f172a; border-color: #94a3b8; }

:root.theme-light .modal-box {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    color: #0f172a !important;
}

/* Table rows */
:root.theme-light table tr { border-color: #e2e8f0 !important; }
:root.theme-light table th { background: #f8fafc !important; color: #334155 !important; }
:root.theme-light table td { color: #1e293b !important; }

/* ── Single-shop dashboard (ki-*) light overrides ── */
:root.theme-light .ki-bg { background: #f1f5f9 !important; }
:root.theme-light .ki-card {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.02) !important;
}
:root.theme-light .ki-topbar {
    background: rgba(255,255,255,0.9) !important;
    border-bottom: 1px solid #e2e8f0 !important;
}
:root.theme-light .ki-section-title { color: #0f172a !important; }
:root.theme-light .ki-ful-item { background: #f8fafc !important; }

/* Product cards */
:root.theme-light .ki-pcard {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04) !important;
}
:root.theme-light .ki-pcard:hover { background: #f8fafc !important; }
:root.theme-light .ki-pcard-name { color: #0f172a !important; }
:root.theme-light .ki-pcard-sku { color: #64748b !important; }
:root.theme-light .ki-pcard-img { background: #f1f5f9 !important; }
:root.theme-light .ki-pcard-kpi { background: #f8fafc !important; }
:root.theme-light .ki-pcard-kpi-label { color: #64748b !important; }
:root.theme-light .ki-pcard-rates { border-top-color: #e2e8f0 !important; color: #64748b !important; }
:root.theme-light .ki-pcard-rates span { color: #0f172a !important; }
:root.theme-light .ki-pcard-footer { color: #64748b !important; }
:root.theme-light .ki-pcard-footer span { color: #0f172a !important; }

/* Top-ranked product cards in light mode */
:root.theme-light .ki-pcard.top-1 { border-color: rgba(255,215,0,0.4) !important; background: rgba(255,215,0,0.06) !important; }
:root.theme-light .ki-pcard.top-2 { border-color: rgba(192,192,192,0.4) !important; background: rgba(192,192,192,0.06) !important; }
:root.theme-light .ki-pcard.top-3 { border-color: rgba(205,127,50,0.4) !important; background: rgba(205,127,50,0.06) !important; }

/* Loading overlay */
:root.theme-light .loading-overlay { background: rgba(241,245,249,0.9) !important; }

/* ── Comprehensive white text → dark text overrides ── */

/* Section titles & hero names */
:root.theme-light .section-title { color: #0f172a !important; }
:root.theme-light .hero-name { color: #0f172a !important; }

/* KPI cards */
:root.theme-light .kpi-card .kpi-value { color: #0f172a !important; text-shadow: none !important; }
:root.theme-light .kpi-card h2 { color: #0f172a !important; }

/* Topbar date picker & quick dates */
:root.theme-light .date-picker input { color: #0f172a !important; }
:root.theme-light .quick-dates button { color: #334155 !important; border-color: #e2e8f0 !important; }
:root.theme-light .quick-dates button:hover { color: #0f172a !important; border-color: #94a3b8 !important; }

/* Form selects */
:root.theme-light select option { background: #ffffff !important; color: #0f172a !important; }

/* Logo text in sidebar */
:root.theme-light .logo { color: #0f172a !important; }

/* Nav hover */
:root.theme-light nav a:hover { color: #0f172a !important; background: rgba(0,0,0,0.04) !important; }

/* Shop card values & metric values */
:root.theme-light .shop-card .metric-val { color: #0f172a !important; }
:root.theme-light .shop-card-compact .name { color: #0f172a !important; }
:root.theme-light .shop-card-compact .orders { color: #0f172a !important; }
:root.theme-light .shop-card-compact .sub-metric .val { color: #0f172a !important; }

/* Product name */
:root.theme-light .product-name { color: #0f172a !important; }

/* Pagination active */
:root.theme-light .page-btn.active { color: #ffffff !important; }

/* View toggle hovered buttons */
:root.theme-light .view-toggle button:hover { color: #0f172a !important; }

/* Chart card — ensure ECharts axis labels visible */
:root.theme-light .chart-card { background: #ffffff !important; border: 1px solid #e2e8f0 !important; }
:root.theme-light .glass { background: #ffffff !important; border: 1px solid #e2e8f0 !important; box-shadow: 0 1px 3px rgba(0,0,0,0.04) !important; }

/* Orders topbar controls layout fix */
:root.theme-light .controls { flex-wrap: wrap !important; }
:root.theme-light .filter-group { flex-wrap: wrap !important; }
:root.theme-light .search-input-wrap { background: #f8fafc !important; border: 1px solid #e2e8f0 !important; }
:root.theme-light .search-input-wrap input { color: #0f172a !important; }

/* Export button text */
:root.theme-light .btn-export { color: #ffffff !important; }

/* General content */
:root.theme-light .content-body { color: #0f172a; }
:root.theme-light h2, :root.theme-light h3, :root.theme-light h4 { color: #0f172a !important; }

* { margin: 0; padding: 0; box-sizing: border-box; font-family: var(--font-inter); }
body { background-color: var(--bg-main); color: var(--text-primary); overflow: hidden; -webkit-font-smoothing: antialiased; }

/* Scan-line overlay on dashboard */
body::before {
    content: '';
    position: fixed; inset: 0; z-index: 9999; pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px, transparent 3px,
        rgba(0,0,0,0.055) 3px, rgba(0,0,0,0.055) 4px
    );
}

/* Welcome toast */
.welcome-toast {
    position: fixed; top: 24px; right: 24px; z-index: 10000;
    background: rgba(15, 20, 40, 0.92);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(167,139,250,0.3);
    border-radius: 14px;
    padding: 14px 22px;
    display: flex; align-items: center; gap: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 20px rgba(139,92,246,0.15);
    animation: toastIn 0.5s cubic-bezier(0.2,0.8,0.4,1);
    font-size: 14px;
}
.welcome-toast .toast-icon { font-size: 22px; }
.welcome-toast .toast-name { font-weight: 700; color: #c4b5fd; }
.welcome-toast .toast-sub  { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }
@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px) scale(0.95); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0) scale(1); }
    to   { opacity: 0; transform: translateX(40px) scale(0.95); }
}

/* Sidebar real-time clock */
.sidebar-clock {
    font-size: 11px; color: var(--text-secondary);
    letter-spacing: 1px; font-variant-numeric: tabular-nums;
    margin-top: 4px; font-weight: 600;
}

/* Card slide-in animation */
@keyframes cardSlideIn {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
}
.kpi-cards .card,
.chart-card {
    animation: cardSlideIn 0.55s cubic-bezier(0.2,0.8,0.4,1) both;
}
.kpi-cards .card:nth-child(1) { animation-delay: 0.05s; }
.kpi-cards .card:nth-child(2) { animation-delay: 0.12s; }
.kpi-cards .card:nth-child(3) { animation-delay: 0.19s; }
.kpi-cards .card:nth-child(4) { animation-delay: 0.26s; }
.kpi-cards .card:nth-child(5) { animation-delay: 0.33s; }
.kpi-cards .card:nth-child(6) { animation-delay: 0.40s; }

/* Dashboard Layout */
.dashboard-container { display: flex; height: 100vh; }
.mobile-bottom-nav { display: none; }

.sidebar {
    width: 240px; background: var(--bg-sidebar); border-right: 1px solid var(--border-color);
    display: flex; flex-direction: column; z-index: 10;
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.logo { padding: 20px 24px 16px; font-size: 20px; font-weight: 800; display: flex; align-items: center; justify-content: center; color: #fff; }
.logo img { max-width: 150px; max-height: 72px; width: auto; object-fit: contain; filter: drop-shadow(0 0 14px rgba(167,139,250,0.5)); border-radius: 8px; }

nav { flex: 1; overflow-y: auto; }
nav a {
    padding: 14px 24px; text-decoration: none; color: var(--text-secondary);
    display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 500; transition: background 0.2s, color 0.2s;
}
nav a:hover { color: #fff; background: rgba(255,255,255,0.03); }
nav a.active { color: var(--text-primary); background: var(--accent-blue-bg); border-left: 3px solid var(--accent-blue); padding-left: 21px; font-weight: 600; }

.main-content {
    flex: 1; display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden;
}

/* Topbar */
.topbar {
    height: 64px; display: flex; align-items: center; padding: 0 24px;
    background: rgba(5, 7, 14, 0.4); border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    position: sticky; top: 0; z-index: 100;
}
.controls { display: flex; align-items: center; gap: 12px; width: 100%; flex-wrap: wrap; }
.controls select, .filter-group select, .date-picker, .inv-search, #searchInput, .inv-search-row select {
    background: var(--bg-input); border: 1px solid var(--border-color); color: var(--text-primary);
    padding: 8px 12px; border-radius: 4px; outline: none; font-size: 13px; transition: border-color 0.2s;
}
.controls select:hover, .filter-group select:hover, .date-picker:hover, .inv-search:focus, #searchInput:focus, .inv-search-row select:hover { border-color: var(--border-light); }
.date-picker { display: flex; align-items: center; gap: 8px; }
.date-picker input { background: transparent; border: none; color: #fff; outline: none; }
.quick-dates button {
    background: transparent; border: 1px solid var(--border-color); color: var(--text-secondary);
    padding: 6px 10px; border-radius: 4px; font-size: 12px; cursor: pointer; transition: 0.2s;
}
.quick-dates button:hover { border-color: var(--border-light); color: #fff; }

.btn-primary, .btn-export { background: var(--accent-blue); color: #fff; border: none; padding: 8px 16px; border-radius: 4px; font-weight: 500; font-size: 13px; cursor: pointer; transition: 0.2s; display: inline-flex; align-items: center; gap: 6px; }
.btn-primary:hover, .btn-export:hover { background: var(--accent-blue-hover); }

#mobileMenuBtn { display: none; background: transparent; border: 1px solid var(--border-color); color: var(--text-primary); padding: 8px; border-radius: 4px; cursor: pointer; }
#mobileMenuBtn:hover { background: rgba(255,255,255,0.05); }

/* Content Areas */
.content-body { padding: 24px; }
.content { padding: 24px; } /* For sub-pages */

.section-title { font-size: 16px; font-weight: 600; color: #fff; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }

/* Single Shop Dashboard Grids (ki-prefix) */
.ki-top-grid { display: block; margin-bottom: 24px; }
.ki-hero-grid { display: flex; gap: 24px; margin-bottom: 24px; min-height: 380px; }
.ki-mid-grid { display: flex; gap: 24px; margin-bottom: 24px; align-items: stretch; }
.ki-mid-grid > div { flex: 1; min-width: 0; }

.ki-product-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
}

/* ── Product Card Classes (index.html "SKU热卖榜") ── */
.ki-pcard {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: transform 0.2s, background 0.2s;
    min-width: 0; /* prevent grid blowout */
    overflow: hidden;
}
.ki-pcard:hover { background: rgba(255,255,255,0.04); transform: translateY(-2px); }
.ki-pcard-rank {
    position: absolute; top: 12px; right: 12px;
    background: rgba(251,191,36,0.1); color: #fbbf24;
    padding: 2px 8px; border-radius: 12px;
    font-size: 12px; font-weight: 700;
}
.ki-pcard-head { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; padding-right: 45px; }
.ki-pcard-img { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; background: #1a1d2e; }
.ki-pcard-info { flex: 1; overflow: hidden; }
.ki-pcard-name { font-weight: 600; font-size: 13px; color: #fff; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; max-height: 2.6em; word-break: break-all; }
.ki-pcard-sku { font-size: 11px; color: #8b92a5; margin-top: 4px; }
.ki-pcard-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.ki-pcard-kpi { padding: 10px; border-radius: 8px; }
.ki-pcard-kpi-label { font-size: 10px; color: #8b92a5; margin-bottom: 4px; }
.ki-pcard-kpi-val { font-size: 15px; font-weight: 700; }
.ki-pcard-rates { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; font-size: 12px; color: #8b92a5; border-top: 1px solid rgba(255,255,255,0.04); padding-top: 12px; margin-top: auto; }
.ki-pcard-rates span { color: #fff; font-weight: 600; }
.ki-pcard-footer { display: flex; justify-content: space-between; font-size: 12px; color: #8b92a5; padding-top: 8px; }
.ki-pcard-footer span { font-weight: 600; }

/* TOP 1/2/3 Medal Styling */
.ki-pcard.top-1 { border-color: rgba(255,215,0,0.3); background: rgba(255,215,0,0.04); }
.ki-pcard.top-1 .ki-pcard-rank { background: linear-gradient(135deg, #ffd700, #ffaa00); color: #1a1100; font-size: 13px; font-weight: 800; padding: 3px 10px; }
.ki-pcard.top-2 { border-color: rgba(192,192,192,0.3); background: rgba(192,192,192,0.03); }
.ki-pcard.top-2 .ki-pcard-rank { background: linear-gradient(135deg, #c0c0c0, #e0e0e0); color: #1a1a1a; font-size: 13px; font-weight: 800; padding: 3px 10px; }
.ki-pcard.top-3 { border-color: rgba(205,127,50,0.3); background: rgba(205,127,50,0.03); }
.ki-pcard.top-3 .ki-pcard-rank { background: linear-gradient(135deg, #cd7f32, #e8a040); color: #1a1100; font-size: 13px; font-weight: 800; padding: 3px 10px; }

/* Premium Glassmorphism Cards */
.glass, .chart-card, .card, .kpi-card, .shop-card, .product-card, .inv-card, .inv-stat-pill {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius); padding: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.05);
    min-width: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s;
}

.glass:hover, .chart-card:hover, .card:hover, .kpi-card:hover, .shop-card:hover, .product-card:hover, .inv-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 40px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.15);
    border-color: rgba(255, 255, 255, 0.15);
}

/* KPI Grid with colored accent tops */
.kpi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi-card { position: relative; padding: 20px 24px; }
.kpi-card:nth-child(1) { border-top: 3px solid var(--accent-blue); }
.kpi-card:nth-child(2) { border-top: 3px solid var(--accent-green); }
.kpi-card:nth-child(3) { border-top: 3px solid var(--accent-yellow); }
.kpi-card:nth-child(4) { border-top: 3px solid var(--accent-red); }
.kpi-card:nth-child(5) { border-top: 3px solid var(--accent-purple); }
.kpi-card .kpi-label { color: var(--text-secondary); font-size: 12px; font-weight: 500; margin-bottom: 12px; }
.kpi-card .kpi-value { font-size: 24px; font-weight: 700; color: #fff; line-height: 1.2; margin-bottom: 6px; text-shadow: 0 0 15px rgba(255, 255, 255, 0.15); }
.kpi-header { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-secondary); margin-bottom: 10px; }

/* Flex layout for equal-height KPI cards */
.kpi-flex { display: flex; flex-direction: column; justify-content: space-between; }
.kpi-sub-row { display: flex; justify-content: space-between; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--border-color); }
.kpi-sub-item { text-align: center; flex: 1; }
.kpi-sub-label { font-size: 11px; color: var(--text-secondary); margin-bottom: 2px; }
.kpi-sub-val { font-size: 13px; font-weight: 600; }

/* Shop Recap Grid */
.store-recap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 24px; }
.shop-card { border-top: 3px solid var(--accent-blue); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.shop-card .name { font-size: 13px; font-weight: 600; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.shop-card .name i { color: var(--accent-blue); width: 14px; }
.shop-card .metric { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-secondary); }
.shop-card .metric-val { font-size: 14px; font-weight: 700; color: #fff; }

/* Trends & Charts */
.dynamic-charts-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-bottom: 24px; min-width: 0; }
.charts-grid { display: grid; gap: 16px; min-width: 0; }
.chart-container { height: 320px; width: 100%; min-width: 0; min-height: 0; }

/* Secondary 3-Charts */
.charts-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; min-width: 0; }
.chart-card h3 { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 16px; }

/* Product Ranking Horizontal List */
.product-card { padding: 12px 16px; display: flex; align-items: center; gap: 16px; cursor: pointer; transition: background 0.2s; }
.product-card:hover { background: var(--bg-input); }
.product-rank { width: 28px; height: 28px; border-radius: 4px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; background: var(--bg-input); color: var(--text-secondary); }
.rank-1 { background: var(--accent-yellow); color: #000; }
.rank-2 { background: #94a3b8; color: #000; }
.rank-3 { background: #b45309; color: #fff; }
.product-img, .inv-card-img { width: 48px; height: 48px; border-radius: 4px; object-fit: cover; background: var(--bg-input); }
.product-body { flex: 1; min-width: 0; }
.product-name { font-size: 13px; font-weight: 500; color: #fff; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-stats { display: flex; gap: 16px; font-size: 12px; color: var(--text-secondary); }
.product-stats b { font-weight: 600; }

/* --- Subpage Fixes: orders.html --- */
.table-container { overflow-x: auto; }
table.orders-table, table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; text-align: left; }
table th { color: var(--text-secondary); border-bottom: 1px solid var(--border-color); padding: 12px 16px; font-weight: 500; }
table td { color: var(--text-primary); border-bottom: 1px solid var(--border-color); padding: 12px 16px; }
table tr:hover td { background: rgba(255,255,255,0.02); }
table.orders-table img, table.data-table img { max-width: 40px; max-height: 40px; border-radius: 4px; object-fit: cover; }
.user-profile img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }

.pagination-bar { display: flex; justify-content: center; gap: 8px; margin-top: 16px; }
.page-btn { background: var(--bg-input); border: 1px solid var(--border-color); color: var(--text-secondary); padding: 4px 10px; border-radius: 4px; cursor: pointer; }
.page-btn.active { background: var(--accent-blue); color: #fff; border-color: var(--accent-blue); }

/* --- Subpage Fixes: product.html --- */
.product-hero { display: flex; gap: 24px; align-items: stretch; margin-bottom: 24px; }
.hero-img { width: 240px; height: 240px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border-color); cursor: zoom-in; flex-shrink: 0; }
.hero-info { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.hero-sku { font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.hero-name { font-size: 20px; font-weight: 600; color: #fff; margin-bottom: 24px; line-height: 1.3; }
.hero-stats { display: flex; gap: 32px; flex-wrap: wrap; }
.hero-stat { display: flex; flex-direction: column; gap: 8px; }
.hero-stat span { font-size: 12px; color: var(--text-secondary); }
.hero-stat b { font-size: 20px; font-weight: 700; }

/* --- Subpage Fixes: inventory.html --- */
.inv-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.inv-search-row { display: flex; gap: 8px; }
.inv-stats-bar { display: flex; gap: 16px; margin-bottom: 24px; }
.status-chips { display: flex; gap: 8px; margin-bottom: 24px; }
.s-chip { padding: 6px 12px; border-radius: 4px; font-size: 12px; cursor: pointer; background: var(--bg-input); border: 1px solid var(--border-color); color: var(--text-secondary); }
.s-chip.active { background: var(--accent-blue-bg); border-color: var(--accent-blue); color: var(--text-primary); }
.inv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.inv-card { display: flex; gap: 16px; padding: 16px; position: relative; border-radius: var(--card-radius); }
.inv-card-body { flex: 1; min-width: 0; }
.inv-card-name { font-size: 13px; font-weight: 500; margin-bottom: 8px; }
.inv-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; font-size: 12px; color: var(--text-secondary); }
.inv-badge-wrap { position: absolute; top: 16px; right: 16px; }
.inv-badge { padding: 2px 6px; border-radius: 2px; font-size: 10px; font-weight: 600; }
.badge-critical { background: rgba(239, 68, 68, 0.1); color: var(--accent-red); }
.badge-warning { background: rgba(245, 158, 11, 0.1); color: var(--accent-yellow); }
.badge-healthy { background: rgba(16, 185, 129, 0.1); color: var(--accent-green); }
.badge-overstock { background: rgba(139, 92, 246, 0.1); color: var(--accent-purple); }
.badge-dead { background: rgba(100,116,139,0.2); color: #94a3b8; border-color: rgba(100,116,139,0.3); }

select option { background: var(--bg-card); color: #fff; }

/* Utilities */
.text-blue { color: var(--accent-blue) !important; }
.text-green { color: var(--accent-green) !important; }
.text-yellow { color: var(--accent-yellow) !important; }
.text-purple { color: var(--accent-purple) !important; }
.text-red { color: var(--accent-red) !important; }

.trend { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.trend.up { color: var(--accent-green); }
.trend.down { color: var(--accent-red); }
.trend.neutral { color: var(--text-secondary); }

/* Toast Pill Loader */
.loading-overlay { position: fixed; top: 20px; right: 50%; transform: translateX(50%); width: auto; height: auto; padding: 10px 20px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 30px; box-shadow: 0 4px 12px rgba(0,0,0,0.5); z-index: 10000; display: none; align-items: center; justify-content: center; flex-direction: row; gap: 12px; }
.spinner { width: 20px; height: 20px; border: 2px solid var(--border-color); border-top: 2px solid var(--accent-blue); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* Lightbox */
.lightbox-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(15,17,26,0.95); z-index: 10000; display: none; align-items: center; justify-content: center; opacity: 0; transition: 0.2s; }
.lightbox-overlay.active { display: flex; opacity: 1; }
.lightbox-overlay img { max-width: 90%; max-height: 90%; border-radius: 8px; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — Tablet (≤1400px)
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 1400px) {
    .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .dynamic-charts-grid, .charts-grid-3 { grid-template-columns: minmax(0, 1fr); }
    
    /* single shop dashboard tablet scale */
    .ki-top-grid { display: block; }
    .ki-hero-grid { flex-direction: column; }
    .ki-mid-grid { flex-direction: column; }
    .ki-product-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — Small Tablet (≤900px)
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .inv-grid { grid-template-columns: minmax(0, 1fr); }
    
    /* single shop dashboard small tablet scale */
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — Mobile (≤768px)
   All content preserved, only layout reflowed.
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

    /* ── Body ── */
    body { overflow: auto; }

    /* ── Dashboard shell ── */
    .dashboard-container { position: relative; flex-direction: column; }

    /* ── Sidebar → slide-out drawer ── */
    .sidebar {
        position: fixed; left: -280px; top: 0; bottom: 0; width: 260px;
        background: linear-gradient(180deg, #0f111a 0%, #161925 100%);
        box-shadow: 10px 0 30px rgba(0,0,0,0.8);
        border-right: 1px solid rgba(255,255,255,0.05);
        transition: left 0.35s cubic-bezier(0.16, 1, 0.3, 1);
        z-index: 9999;
    }
    .sidebar.open { left: 0; }
    nav a { padding: 16px 24px; font-size: 15px; min-height: 48px; } /* touch-friendly */

    /* ── Mobile menu button ── */
    #mobileMenuBtn {
        display: flex !important;
        background: linear-gradient(135deg, var(--accent-blue) 0%, #8b5cf6 100%);
        color: white; border: none; padding: 8px 12px; border-radius: 8px;
        box-shadow: 0 4px 12px rgba(59,130,246,0.3); transition: transform 0.2s;
    }
    #mobileMenuBtn:active { transform: scale(0.92); }

    /* ── Main content full width ── */
    .main-content { margin-left: 0 !important; width: 100%; }

    /* ── Topbar ── */
    .topbar {
        height: auto; padding: 12px 14px;
        border-bottom: 1px solid rgba(255,255,255,0.05);
        background: rgba(15,17,26,0.85);
        backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    }
    .controls { flex-direction: column; align-items: stretch; gap: 10px; }
    .controls > div { flex-wrap: wrap; gap: 8px; }
    .controls select { width: 100%; min-height: 42px; font-size: 14px; }

    /* ── Date picker ── */
    .date-picker { flex-direction: column; align-items: stretch; gap: 8px; }
    .date-picker input { width: 100%; min-height: 40px; }
    .date-picker span { display: none; }
    .quick-dates {
        display: flex; overflow-x: auto; white-space: nowrap;
        padding-bottom: 6px; gap: 6px;
        scrollbar-width: none; -ms-overflow-style: none;
    }
    .quick-dates::-webkit-scrollbar { display: none; }
    .quick-dates button { min-height: 38px; padding: 8px 14px; font-size: 13px; flex-shrink: 0; }

    /* ── Content body ── */
    .content-body, .content { padding: 12px; }

    /* ── PREMIUM App-like Header ── */
    .topbar {
        background: transparent !important;
        border: none !important;
        backdrop-filter: none !important;
        padding: 16px 12px 0 12px !important;
    }
    .controls select, .inv-search, .date-picker input {
        background: rgba(255, 255, 255, 0.03) !important;
        border: 1px solid rgba(255, 255, 255, 0.08) !important;
        border-radius: 12px !important;
        color: #fff !important;
    }

    /* ── KPI Grid: Horizontal Snap Scroll ── */
    .kpi-grid {
        display: flex !important;
        flex-wrap: nowrap;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        padding-bottom: 12px;
        -webkit-overflow-scrolling: touch;
        margin-right: -12px; /* bleed edge */
        padding-right: 12px;
        gap: 12px;
    }
    .kpi-grid::-webkit-scrollbar { display: none; }
    
    .kpi-card {
        scroll-snap-align: start;
        flex: 0 0 85%; /* SHOW 85% OF SCREEN, PEEKS NEXT */
        min-width: 240px;
        background: linear-gradient(145deg, rgba(30,41,59,0.7) 0%, rgba(15,20,35,0.7) 100%) !important;
        border: 1px solid rgba(255,255,255,0.1) !important;
        box-shadow: 0 10px 30px rgba(0,0,0,0.5), inset 0 2px 20px rgba(255,255,255,0.03) !important;
        border-radius: 20px !important;
        padding: 18px 20px !important;
        position: relative;
        overflow: hidden;
    }
    .kpi-card::before {
        content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 50%;
        background: radial-gradient(circle at 50% 0%, rgba(167, 139, 250, 0.12) 0%, transparent 80%);
        pointer-events: none;
    }
    .kpi-card .kpi-value { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
    .kpi-card .kpi-label { font-size: 13px; margin-bottom: 8px; color: rgba(255,255,255,0.7); }
    .kpi-sub-row { flex-direction: row; justify-content: space-between; gap: 8px; border-color: rgba(255,255,255,0.06); }
    .kpi-sub-item { text-align: left; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 4px; padding: 4px; }
    
    /* single shop dashboard mobile scale premium */
    .ki-topbar {
        background: transparent !important;
        border: none !important;
        backdrop-filter: none !important;
        padding: 16px 12px 0 12px !important;
        height: auto !important;
    }
    .ki-topbar > div { flex-wrap: wrap !important; gap: 10px !important; padding-bottom: 12px; }
    .ki-topbar select, .ki-topbar input { 
        padding: 8px 12px !important; 
        font-size: 13px !important; 
        border-radius: 10px !important; 
        background: rgba(255,255,255,0.04) !important;
        border: 1px solid rgba(255,255,255,0.08) !important;
    }

    .ki-topbar h1 { font-size: 20px !important; text-shadow: 0 0 15px rgba(255,255,255,0.2); }

    .ki-top-grid, .ki-mid-grid, .ki-hero-grid { gap: 16px; margin-bottom: 16px; }
    .ki-product-grid { grid-template-columns: 1fr; gap: 12px; }
    
    .ki-card, .ki-pcard {
        background: linear-gradient(160deg, rgba(20,25,40,0.85) 0%, rgba(10,12,20,0.95) 100%) !important;
        border: 1px solid rgba(255,255,255,0.06) !important;
        box-shadow: 0 15px 35px rgba(0,0,0,0.6), inset 0 1px 1px rgba(255,255,255,0.08) !important;
        border-radius: 20px !important;
        padding: 20px !important;
        position: relative;
        overflow: hidden;
    }
    .ki-card::before, .ki-pcard::before {
        content: ''; position: absolute; top: -50px; left: -50px; width: 150px; height: 150px;
        background: radial-gradient(circle, rgba(167, 139, 250, 0.25) 0%, transparent 70%);
        pointer-events: none;
        z-index: 0;
    }
    .ki-card > *, .ki-pcard > * { position: relative; z-index: 1; }
    
    /* Value text premium styling */
    .ki-card .text-blue, .ki-card .text-green, .ki-card .text-yellow, .ki-card .text-red, .ki-card .text-purple {
        text-shadow: 0 0 16px currentColor !important;
        font-weight: 800 !important;
        letter-spacing: -0.5px;
    }

    /* ── Charts: Premium Stack ── */
    .dynamic-charts-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .charts-grid-3 {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .chart-container { height: 260px; }
    .chart-card { 
        padding: 16px; 
        background: linear-gradient(145deg, rgba(20,25,40,0.8), rgba(10,15,25,0.9)) !important;
        border-radius: 24px !important;
        box-shadow: 0 12px 36px rgba(0,0,0,0.6), inset 0 2px 10px rgba(255,255,255,0.02) !important;
        border: 1px solid rgba(255,255,255,0.06) !important;
    }
    .chart-card h3 { font-size: 15px; margin-bottom: 12px; font-weight: 700; display:flex; align-items:center; gap:8px; }

    /* ── Store recap cards ── */
    .store-recap-grid { grid-template-columns: 1fr; gap: 10px; }
    .shop-cards-wrapper { max-height: none; padding-right: 0; }
    .shop-card-compact .sub-metrics { grid-template-columns: repeat(2, 1fr); }

    /* ── Product ranking ── */
    .product-card { padding: 12px; }
    .product-stats { flex-wrap: wrap; gap: 8px; }

    /* ── Tables: horizontal scroll with sticky first column ── */
    .table-container, .shop-table-wrapper {
        width: 100%; overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
        border: 1px solid rgba(255,255,255,0.05);
    }
    table.orders-table, table.data-table { min-width: 600px; }
    table th, table td { padding: 10px 12px; font-size: 12px; white-space: nowrap; }
    table th:first-child, table td:first-child {
        position: sticky; left: 0; z-index: 2;
        background: var(--bg-card);
    }

    /* ── Pagination: bigger touch targets ── */
    .pagination-bar { flex-wrap: wrap; }
    .page-btn { min-width: 38px; min-height: 38px; font-size: 13px; display: flex; align-items: center; justify-content: center; }

    /* ── Product hero: vertical stack ── */
    .product-hero {
        flex-direction: column;
        gap: 16px;
        padding: 14px;
        border-radius: 12px;
        background: rgba(255,255,255,0.02);
        border: 1px solid rgba(255,255,255,0.05);
    }
    .hero-img { width: 100%; height: auto; aspect-ratio: 1; border-radius: 10px; }
    .hero-name { font-size: 17px; margin-bottom: 14px; }
    .hero-stats { gap: 16px; }
    .hero-stat b { font-size: 17px; }

    /* ── Inventory page ── */
    .inv-topbar { flex-direction: column; gap: 10px; align-items: stretch; }
    .inv-search-row { flex-direction: column; gap: 8px; }
    .inv-search-row select, .inv-search { width: 100%; min-height: 42px; font-size: 14px; }
    .inv-stats-bar {
        display: grid; grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .inv-stat-pill { padding: 12px; border-radius: 10px; }
    .status-chips { flex-wrap: wrap; gap: 6px; }
    .s-chip { padding: 8px 14px; font-size: 13px; min-height: 38px; }
    .inv-grid { grid-template-columns: 1fr; gap: 10px; }
    .inv-card { padding: 12px; border-radius: 10px; }
    .inv-meta { grid-template-columns: 1fr 1fr; gap: 6px; }

    /* ── Buttons: touch-friendly 44px min ── */
    .btn-primary, .btn-export { min-height: 44px; font-size: 14px; padding: 10px 18px; width: 100%; justify-content: center; border-radius: 10px; }

    /* ── View toggle ── */
    .view-toggle { width: 100%; }
    .view-toggle button { flex: 1; justify-content: center; min-height: 40px; }

    /* ── Modal / dialogs ── */
    .modal-overlay .modal-content,
    .lightbox-overlay img { max-width: 95vw; }

    /* ── Section titles ── */
    .section-title { font-size: 15px; }

    /* ── Cards: remove hover lift on touch ── */
    .glass:hover, .chart-card:hover, .card:hover, .kpi-card:hover,
    .shop-card:hover, .product-card:hover, .inv-card:hover {
        transform: none;
    }

    /* ── Loading overlay ── */
    .loading-overlay { right: auto; left: 50%; transform: translateX(-50%); }

    /* ── Floating Mobile Bottom Nav (Premium App Mode) ── */
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0; left: 0; right: 0;
        height: 70px;
        background: rgba(10, 15, 25, 0.85);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid rgba(255, 255, 255, 0.05);
        z-index: 1000;
        justify-content: space-around;
        align-items: center;
        padding-bottom: env(safe-area-inset-bottom, 12px);
    }
    .mobile-bottom-nav a {
        display: flex; flex-direction: column; align-items: center; gap: 4px;
        color: var(--text-secondary); text-decoration: none; font-size: 10px; font-weight: 600;
        transition: 0.3s;
    }
    .mobile-bottom-nav a.active {
        color: var(--accent-blue);
        text-shadow: 0 0 10px rgba(59,130,246,0.5);
    }
    .mobile-bottom-nav a.active i {
        filter: drop-shadow(0 0 6px var(--accent-blue));
    }
    .mobile-bottom-nav a i { width: 22px; height: 22px; }

    /* Global mobile padding to avoid covering by bottom nav */
    .dashboard-container { padding-bottom: 75px !important; }
}

/* ── Sidebar Backdrop (shared) ── */
.sidebar-backdrop {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6); z-index: 9998;
    opacity: 0; transition: opacity 0.3s;
}
.sidebar-backdrop.show { display: block; opacity: 1; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-main); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* --- Subpage Fixes: View Toggle & Scrollable Wrappers --- */
.view-toggle { display: flex; gap: 4px; background: var(--bg-input); padding: 4px; border-radius: 6px; border: 1px solid var(--border-color); }
.view-toggle button { background: transparent; color: var(--text-secondary); border: none; padding: 6px 12px; border-radius: 4px; font-size: 13px; font-weight: 500; cursor: pointer; transition: 0.2s; display: flex; align-items: center; gap: 6px; }
.view-toggle button:hover { color: #fff; }
.view-toggle button.active { background: var(--bg-card); color: var(--accent-blue); box-shadow: 0 1px 3px rgba(0,0,0,0.2); }

.shop-cards-wrapper { max-height: 380px; overflow-y: auto; padding-right: 8px; margin-bottom: 24px; }
.shop-cards-wrapper .store-recap-grid { margin-bottom: 0; }
.shop-table-wrapper { margin-bottom: 24px; border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; }

.shop-card-compact { 
    padding: 16px; display: flex; flex-direction: column; gap: 10px; 
    border-radius: 16px !important;
    background: linear-gradient(145deg, rgba(30,41,59,0.7) 0%, rgba(15,20,35,0.7) 100%) !important;
    border: 1px solid rgba(255,255,255,0.06) !important;
}
.shop-card-compact:hover { transform: none !important; }
.shop-card-compact .name { font-size: 15px; font-weight: 700; color: #fff; display: flex; align-items: center; gap: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shop-card-compact .name-inner { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: inline-block; width: calc(100% - 20px); }
.shop-card-compact .main-metrics { display: flex; justify-content: space-between; align-items: baseline; margin-top: 4px; }
.shop-card-compact .gmv { font-size: 18px; font-weight: 800; color: var(--accent-blue); }
.shop-card-compact .orders { font-size: 15px; font-weight: 600; color: #fff; }
.shop-card-compact .sub-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; border-top: 1px solid rgba(255,255,255,0.06); padding-top: 8px; margin-top: 6px; }
.shop-card-compact .sub-metric { display: flex; flex-direction: column; gap: 2px; align-items: center; text-align: center; background: rgba(0,0,0,0.2); padding: 4px 2px; border-radius: 6px; overflow: hidden; }
.shop-card-compact .sub-metric .lbl { font-size: 9px; line-height: 1.1; color: var(--text-secondary); text-transform: uppercase; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; box-sizing: border-box; padding: 0 1px; margin-bottom: 2px; }
.shop-card-compact .sub-metric .val { font-size: 11px; line-height: 1.1; font-weight: 700; color: #fff; }

table th.num-col, table td.num-col { text-align: right; }
