/* ============================================================
   ChaaChaa Malatang — "Midnight Ember" Design System
   Premium Dashboard Experience
   ============================================================ */

:root {
    /* Brand Palette */
    --primary: #E8553D;
    --primary-hover: #D4432C;
    --primary-light: rgba(232, 85, 61, 0.08);
    --primary-glow: rgba(232, 85, 61, 0.25);
    --accent: #F09E54;

    /* Sidebar — Deep Charcoal */
    --sidebar-bg: #0C0F1A;
    --sidebar-surface: rgba(255, 255, 255, 0.04);
    --sidebar-text: rgba(255, 255, 255, 0.45);
    --sidebar-active-bg: rgba(232, 85, 61, 0.12);
    --sidebar-active-text: #ffffff;
    --sidebar-border: rgba(255, 255, 255, 0.06);
    --sidebar-width: 260px;

    /* Canvas */
    --background: #F4F6FA;
    --surface: #ffffff;
    --surface-alt: #F0F2F7;
    --surface-hover: #EBEDF3;

    /* Text */
    --text-primary: #111827;
    --text-secondary: #4B5563;
    --text-tertiary: #9CA3AF;
    --text-inverse: #ffffff;

    /* Borders */
    --border: #E5E7EB;
    --border-light: #F3F4F6;
    --border-focus: var(--primary);

    /* Semantic */
    --success: #059669;
    --success-light: #D1FAE5;
    --danger: #DC2626;
    --danger-light: #FEE2E2;
    --warning: #D97706;
    --warning-light: #FEF3C7;
    --info: #2563EB;
    --info-light: #DBEAFE;

    /* Elevation */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --shadow-glow: 0 0 20px rgba(232, 85, 61, 0.15);

    /* Radius */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius-full: 9999px;

    /* Transitions */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --transition-fast: 150ms var(--ease-out);
    --transition-base: 250ms var(--ease-out);
    --transition-slow: 400ms var(--ease-out);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 14px;
    line-height: 1.5;
}

ul { list-style: none; }
a { text-decoration: none; color: inherit; }
.bg-orbs { display: none; }

/* ============================================================
   LAYOUT: APP SHELL
   ============================================================ */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar-overlay { display: none; }

/* ============================================================
   SIDEBAR — Premium Dark
   ============================================================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    background-image: linear-gradient(180deg, rgba(232, 85, 61, 0.03) 0%, transparent 40%);
    display: flex;
    flex-direction: column;
    padding: 28px 16px 20px;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
    overflow-x: hidden;
    border-right: 1px solid var(--sidebar-border);
}

/* Custom scrollbar for sidebar */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 36px;
    padding: 0 10px;
}

.sidebar-logo .logo-icon {
    font-size: 18px;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(232, 85, 61, 0.3);
    flex-shrink: 0;
}

.sidebar-logo h2 {
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: -0.01em;
    line-height: 1.3;
}

/* Nav Menu */
.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    padding: 11px 14px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--sidebar-text);
    font-weight: 500;
    font-size: 13.5px;
    transition: all var(--transition-fast);
    position: relative;
}

.nav-item i { font-size: 20px; transition: color var(--transition-fast); }

.nav-item:hover {
    background: var(--sidebar-surface);
    color: rgba(255, 255, 255, 0.85);
}

.nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: linear-gradient(180deg, var(--primary), var(--accent));
    border-radius: 0 4px 4px 0;
}

.nav-item.active i {
    color: var(--primary);
}

/* Sidebar Footer */
.sidebar-footer {
    margin-top: auto;
    padding-top: 24px;
    border-top: 1px solid var(--sidebar-border);
    display: grid;
    gap: 12px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--sidebar-text);
    padding: 0 10px;
}

.user-info i { font-size: 20px; }

.btn-block { width: 100%; justify-content: flex-start; }

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px 40px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 1600px;
    min-width: 0;
    overflow-x: hidden;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.hamburger-btn {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.hamburger-btn:hover { background: var(--surface-alt); }

.header-title h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

.header-title p {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

/* ============================================================
   CARDS — Elevated Surfaces
   ============================================================ */
.glass-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

/* Stats Grid */
.stats-grid, .daily-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

/* Stat Cards */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--border-light);
    transition: background var(--transition-base);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: transparent;
}

.stat-card:hover::before {
    background: linear-gradient(90deg, var(--primary), var(--accent));
}

.stat-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stat-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    font-size: 18px;
}

.stat-icon.sales { background: var(--success-light); color: var(--success); }
.stat-icon.orders { background: var(--primary-light); color: var(--primary); }
.stat-icon.expenses { background: var(--warning-light); color: var(--warning); }
.stat-icon.net { background: var(--success-light); color: var(--success); }
.stat-icon.commission, .stat-icon.ads { background: var(--danger-light); color: var(--danger); }
.stat-icon.total { background: var(--info-light); color: var(--info); }

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.stat-value-warning { color: var(--warning); }
.stat-value-success { color: var(--success); }

/* Summary Cards (Daily View) */
.summary-card {
    padding: 22px 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    transition: all var(--transition-base);
}

.summary-card:hover {
    box-shadow: var(--shadow-md);
}

.summary-card.highlight {
    background: linear-gradient(135deg, var(--primary) 0%, #C9392A 100%);
    border-color: transparent;
    box-shadow: 0 8px 24px rgba(232, 85, 61, 0.25);
}

.summary-title {
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 600;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.summary-value {
    font-size: 24px;
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.summary-card.highlight .summary-title { color: rgba(255, 255, 255, 0.7); }
.summary-card.highlight .summary-value { color: #ffffff; }

/* ============================================================
   DAILY SUMMARY STRIP — Compact 3-column hero layout
   ============================================================ */
.ds-strip {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

/* Left: Sales Hero */
.ds-strip-hero {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 22px 28px;
    background: linear-gradient(135deg, var(--primary) 0%, #C9392A 100%);
    color: #fff;
}

.ds-hero-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.ds-hero-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.7;
    margin-bottom: 4px;
}

.ds-hero-value {
    font-size: 26px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.03em;
    line-height: 1.1;
    white-space: nowrap;
}

.ds-hero-sub {
    font-size: 11.5px;
    opacity: 0.6;
    margin-top: 4px;
}

/* Middle: Deductions */
.ds-strip-deductions {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0;
    padding: 12px 0;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    min-width: 240px;
}

.ds-deduct-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 24px;
    position: relative;
}

.ds-deduct-item + .ds-deduct-item {
    border-top: 1px solid var(--border-light);
}

.ds-deduct-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.ds-deduct-icon.red    { background: var(--danger-light); color: var(--danger); }
.ds-deduct-icon.orange { background: var(--warning-light); color: var(--warning); }
.ds-deduct-icon.gray   { background: var(--surface-alt); color: var(--text-tertiary); }

.ds-deduct-body {
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.ds-deduct-label {
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 500;
    flex-shrink: 0;
    width: 48px;
}

.ds-deduct-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.ds-deduct-pct {
    font-size: 11px;
    color: var(--text-tertiary);
    white-space: nowrap;
}

.ds-deduct-bar {
    position: absolute;
    bottom: 0;
    left: 24px;
    right: 24px;
    height: 2px;
    background: var(--border-light);
    border-radius: 1px;
    overflow: hidden;
}

.ds-deduct-item + .ds-deduct-item .ds-deduct-bar {
    /* only show bar on last deduction item for cleanliness */
}

.ds-deduct-bar-fill {
    height: 100%;
    border-radius: 1px;
    transition: width 0.6s var(--ease-out);
}

.ds-deduct-bar-fill.red    { background: var(--danger); }
.ds-deduct-bar-fill.orange { background: var(--warning); }
.ds-deduct-bar-fill.gray   { background: var(--text-tertiary); }

/* Right: Net Result */
.ds-strip-net {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 22px 28px;
    background: rgba(5, 150, 105, 0.04);
}

.ds-net-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    background: var(--success-light);
    color: var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.ds-net-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--success);
    margin-bottom: 4px;
}

.ds-net-value {
    font-size: 26px;
    font-weight: 800;
    color: var(--success);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.03em;
    line-height: 1.1;
    white-space: nowrap;
}

.ds-net-margin {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.ds-net-bar {
    height: 4px;
    background: var(--border-light);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 6px;
}

.ds-net-bar-fill {
    height: 100%;
    border-radius: 2px;
    background: var(--success);
    transition: width 0.6s var(--ease-out);
}

/* Responsive: stack on tablet */
@media (max-width: 1100px) {
    .ds-strip {
        grid-template-columns: 1fr;
    }
    .ds-strip-deductions {
        flex-direction: row;
        border-left: none;
        border-right: none;
        border-top: 1px solid var(--border);
        border-bottom: 1px solid var(--border);
        padding: 0;
        min-width: unset;
    }
    .ds-deduct-item {
        flex: 1;
        padding: 12px 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    .ds-deduct-item + .ds-deduct-item {
        border-top: none;
        border-left: 1px solid var(--border-light);
    }
    .ds-deduct-body { flex-direction: column; gap: 2px; }
    .ds-deduct-label { width: auto; }
    .ds-deduct-bar { display: none; }
}

@media (max-width: 640px) {
    .ds-strip-hero, .ds-strip-net { padding: 16px 20px; }
    .ds-hero-value, .ds-net-value { font-size: 22px; }
    .ds-hero-icon, .ds-net-icon { width: 40px; height: 40px; font-size: 18px; }
    .ds-strip-deductions { flex-direction: column; }
    .ds-deduct-item + .ds-deduct-item { border-left: none; border-top: 1px solid var(--border-light); }
    .ds-deduct-item { flex-direction: row; padding: 10px 20px; }
    .ds-deduct-body { flex-direction: row; gap: 6px; }
    .ds-deduct-label { width: 48px; }
}

/* Summary Card V2 (with icon + secondary + pct bar) */
.summary-card-v2 {
    padding: 18px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.summary-card-v2:hover { box-shadow: var(--shadow-md); }

.summary-card-v2 .sc-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.summary-card-v2 .sc-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.summary-card-v2 .sc-icon.green  { background: var(--success-light); color: var(--success); }
.summary-card-v2 .sc-icon.red    { background: var(--danger-light); color: var(--danger); }
.summary-card-v2 .sc-icon.orange { background: var(--warning-light); color: var(--warning); }
.summary-card-v2 .sc-icon.gray   { background: var(--surface-alt); color: var(--text-tertiary); }
.summary-card-v2 .sc-icon.blue   { background: var(--info-light); color: var(--info); }

.summary-card-v2 .sc-title {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.summary-card-v2 .sc-value {
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin-bottom: 6px;
    white-space: nowrap;
}

.summary-card-v2 .sc-secondary {
    font-size: 11.5px;
    color: var(--text-tertiary);
    font-weight: 500;
    margin-bottom: 8px;
}

.summary-card-v2 .sc-bar-track {
    height: 4px;
    background: var(--surface-alt);
    border-radius: 2px;
    overflow: hidden;
}

.summary-card-v2 .sc-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.6s var(--ease-out);
}

.summary-card-v2 .sc-bar-fill.green  { background: var(--success); }
.summary-card-v2 .sc-bar-fill.red    { background: var(--danger); }
.summary-card-v2 .sc-bar-fill.orange { background: var(--warning); }
.summary-card-v2 .sc-bar-fill.gray   { background: var(--text-tertiary); }
.summary-card-v2 .sc-bar-fill.blue   { background: var(--info); }

.summary-card-v2.card-highlight {
    background: linear-gradient(135deg, var(--primary) 0%, #C9392A 100%);
    border-color: transparent;
    box-shadow: 0 8px 24px rgba(232, 85, 61, 0.25);
}

.summary-card-v2.card-highlight .sc-title { color: rgba(255,255,255,0.7); }
.summary-card-v2.card-highlight .sc-value { color: #fff; }
.summary-card-v2.card-highlight .sc-secondary { color: rgba(255,255,255,0.6); }
.summary-card-v2.card-highlight .sc-icon { background: rgba(255,255,255,0.15); color: #fff; }
.summary-card-v2.card-highlight .sc-bar-track { background: rgba(255,255,255,0.15); }
.summary-card-v2.card-highlight .sc-bar-fill { background: rgba(255,255,255,0.6); }

.summary-card-v2.card-net {
    border-color: var(--success);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.1);
}

/* ============================================================
   BREADCRUMB NAVIGATION
   ============================================================ */
.daily-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    font-size: 13px;
    flex-wrap: wrap;
}

.breadcrumb-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--info);
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 13px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.breadcrumb-item:hover {
    background: var(--info-light);
    color: var(--info);
}

.breadcrumb-separator {
    color: var(--text-tertiary);
    font-size: 10px;
    user-select: none;
}

.breadcrumb-current {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: var(--text-primary);
    padding: 4px 8px;
    font-size: 13px;
}

/* ============================================================
   FILTER CHIPS
   ============================================================ */
.filter-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 0 20px 12px;
    background: var(--surface);
}

.filter-chips:empty { display: none; }

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 12px;
    background: var(--info-light);
    color: var(--info);
    border-radius: var(--radius-full);
    font-size: 11.5px;
    font-weight: 500;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.filter-chip-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--info);
    font-size: 12px;
    padding: 0;
    transition: all var(--transition-fast);
}

.filter-chip-close:hover {
    background: var(--danger-light);
    color: var(--danger);
}

/* ============================================================
   LEVEL 1 — Enhanced Date Table Rows
   ============================================================ */
.daily-date-row { cursor: pointer; transition: all var(--transition-fast); }

.daily-date-row td { position: relative; }

.daily-date-row:hover td {
    background: var(--primary-light) !important;
}

.daily-date-row.row-weekend td {
    background: rgba(249, 250, 251, 0.6);
}

.daily-date-row .date-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.daily-date-row .date-num {
    min-width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
    background: var(--surface-alt);
    color: var(--text-primary);
}

.daily-date-row .date-num .day-label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.6;
    margin-top: 1px;
}

.daily-date-row .date-num.today {
    background: var(--primary);
    color: #fff;
}

.daily-date-row .date-num.today .day-label { opacity: 0.8; }

.daily-date-row .date-num.weekend {
    background: var(--warning-light);
    color: var(--warning);
}

.daily-date-row .date-info-text {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
}

.daily-date-row .date-meta-text {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.platform-dots {
    display: inline-flex;
    gap: 3px;
    align-items: center;
}

.platform-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

/* Net amount bar (thin bar at bottom of net column cell) */
.net-cell-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.net-bar-track {
    width: 100%;
    height: 3px;
    background: var(--border-light);
    border-radius: 2px;
    overflow: hidden;
}

.net-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s var(--ease-out);
}

.net-bar-fill.positive { background: var(--success); }
.net-bar-fill.negative { background: var(--danger); }

/* Trend indicator */
.trend-indicator {
    display: inline-flex;
    align-items: center;
    font-size: 10px;
    margin-left: 4px;
    vertical-align: middle;
}

.trend-indicator.up { color: var(--success); }
.trend-indicator.down { color: var(--danger); }

/* Column semantic tints */
.col-sales { background: rgba(5, 150, 105, 0.025); }
.col-deduction { background: rgba(220, 38, 38, 0.02); }
.col-net { background: rgba(37, 99, 235, 0.025); }

/* Drill arrow column */
.col-arrow {
    text-align: right;
    width: 38px;
}

.col-arrow i {
    color: var(--text-tertiary);
    transition: transform var(--transition-fast), color var(--transition-fast);
}

.daily-date-row:hover .col-arrow i,
.daily-open-row:hover .col-arrow i {
    transform: translateX(3px);
    color: var(--primary);
}

/* ============================================================
   LEVEL 2 — Detail View Enhancements
   ============================================================ */
.detail-header {
    padding: 20px 24px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.detail-header-left h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-header-left p {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

/* Deduction Flow Visualization */
.deduction-flow {
    display: flex;
    align-items: stretch;
    border-radius: var(--radius-md);
    overflow: hidden;
    height: 8px;
    background: var(--surface-alt);
    margin: 0 24px 8px;
}

.flow-segment {
    height: 100%;
    transition: width 0.6s var(--ease-out);
    min-width: 2px;
}

.flow-segment.seg-sales { background: var(--success); }
.flow-segment.seg-ads { background: var(--danger); }
.flow-segment.seg-gp { background: var(--warning); }
.flow-segment.seg-others { background: var(--text-tertiary); }
.flow-segment.seg-net { background: var(--info); }

.flow-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    padding: 4px 24px 16px;
    font-size: 11.5px;
    color: var(--text-tertiary);
}

.flow-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.flow-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* Platform group header row in Level 2 table */
.platform-group-row td {
    background: var(--surface-alt) !important;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    padding: 8px 20px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.platform-group-row td i {
    font-size: 14px;
    vertical-align: -1px;
    margin-right: 6px;
}

/* Level 2 open row (clickable) */
.daily-open-row { cursor: pointer; transition: all var(--transition-fast); }

.daily-open-row:hover td {
    background: var(--primary-light) !important;
}

/* ============================================================
   FILTER BAR — Clean Toolbar
   ============================================================ */
.filter-bar, .filters {
    padding: 16px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.filter-row, .filters-row-primary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.filter-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

/* Search Field */
.search-field {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-alt);
    border: 1px solid transparent;
    padding: 0 14px;
    border-radius: var(--radius-md);
    min-width: 240px;
    height: 38px;
    transition: all var(--transition-fast);
}

.search-field:focus-within {
    background: var(--surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.search-field i { color: var(--text-tertiary); font-size: 16px; }

.search-field input {
    border: none;
    background: transparent;
    outline: none;
    font-family: inherit;
    font-size: 13px;
    width: 100%;
    color: var(--text-primary);
}

.search-field input::placeholder { color: var(--text-tertiary); }

/* Filter Controls (Selects, Dates) */
.filter-control, .date-input {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0 32px 0 12px;
    border-radius: var(--radius-md);
    height: 38px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px;
    transition: all var(--transition-fast);
}

.filter-control:hover { border-color: var(--text-tertiary); }

.filter-control:focus, .date-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Date Range */
.date-range-picker, .date-range {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0 14px;
    background: var(--surface);
    transition: border-color var(--transition-fast);
}

.date-range-picker:focus-within, .date-range:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.date-range-picker input[type="date"],
.date-range input[type="date"] {
    height: 100%;
    padding: 0;
    border: none;
    font-family: inherit;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    background: transparent;
    outline: none;
}

.date-range-picker span, .date-range span {
    color: var(--text-tertiary);
    font-size: 13px;
    user-select: none;
}

/* Advanced Filters */
.advanced-filters, .filters-row-secondary {
    display: none;
    padding-top: 14px;
    border-top: 1px dashed var(--border);
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* Table Meta Bar */
.table-meta-bar, .filters-meta {
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-tertiary);
    min-height: 42px;
}

.filters-meta-left { display: flex; gap: 16px; align-items: center; }
.export-buttons { display: flex; gap: 8px; }

/* View Switch */
.daily-view-switch {
    display: inline-flex;
    padding: 3px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    gap: 2px;
}

.daily-view-switch .btn {
    box-shadow: none;
    border: none;
    background: transparent;
    height: 30px;
    border-radius: 7px;
}

.daily-view-switch .btn.active {
    background: var(--text-primary);
    color: var(--text-inverse);
    box-shadow: var(--shadow-xs);
}

/* Date Presets */
.date-presets { display: flex; gap: 6px; }

/* ============================================================
   DATA TABLES — Clean & Spacious
   ============================================================ */
.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.data-table, .daily-data-table, .transaction-data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
    background: var(--surface);
}

.data-table th, .daily-data-table th, .transaction-data-table th {
    text-align: left;
    padding: 12px 20px;
    background: var(--surface-alt);
    color: var(--text-tertiary);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table td, .daily-data-table td, .transaction-data-table td {
    padding: 13px 20px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    font-size: 13.5px;
    vertical-align: middle;
}

.data-table tr:hover td,
.daily-data-table tr:hover td,
.transaction-data-table tr:hover td {
    background-color: var(--primary-light);
}

.data-table tr:last-child td,
.daily-data-table tr:last-child td,
.transaction-data-table tr:last-child td {
    border-bottom: none;
}

/* Number formatting */
.data-table .number, .daily-data-table .number, .transaction-data-table .number {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    white-space: nowrap;
}

.data-table .positive, .daily-data-table .positive, .transaction-data-table .positive { color: var(--success); }
.data-table .negative, .daily-data-table .negative, .transaction-data-table .negative { color: var(--danger); }
.data-table .highlight-text, .daily-data-table .highlight-text, .transaction-data-table .highlight-text { font-weight: 600; }

/* Prevent money values and signs from wrapping */
.data-table td span, .daily-data-table td span, .transaction-data-table td span {
    white-space: nowrap;
}

/* Group Rows */
.daily-group-row td {
    background: var(--surface-alt) !important;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 10px 20px;
    letter-spacing: 0.01em;
}

.trans-group-row td {
    background: var(--surface-alt) !important;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-tertiary);
    padding: 10px 20px;
}

.trans-row-missing-detail td {
    background: var(--danger-light) !important;
}

/* ============================================================
   BADGES & CHIPS
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.badge.bg-success { background: var(--success-light); color: var(--success); }
.badge.bg-warning { background: var(--warning-light); color: var(--warning); }
.badge.default { background: var(--surface-alt); color: var(--text-tertiary); }

/* Platform Badges */
.badge.platform-grab { background: #DCFCE7; color: #15803D; }
.badge.platform-shopee { background: #FEE2E2; color: #B91C1C; }
.badge.platform-lineman { background: #DCFCE7; color: #15803D; }
.badge.platform-foodstory { background: #FFEDD5; color: #C2410C; }

.branch-badge {
    padding: 4px 10px;
    background: var(--surface-alt);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Detail State Badges */
.detail-state-badge {
    display: inline-flex;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.detail-state-badge.ready { background: var(--success-light); color: var(--success); }
.detail-state-badge.missing { background: var(--warning-light); color: var(--warning); }
.detail-state-badge.no-order { background: var(--surface-alt); color: var(--text-tertiary); }

/* Order ID Link */
.order-id-link {
    color: var(--text-primary);
    font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
    font-size: 12.5px;
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: none;
    padding: 2px 4px;
    border-radius: var(--radius-xs);
    transition: all var(--transition-fast);
}

.order-id-link:hover {
    color: var(--primary);
    background: var(--primary-light);
}

/* ============================================================
   BUTTONS — Refined
   ============================================================ */
.btn {
    height: 38px;
    padding: 0 18px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-xs);
    white-space: nowrap;
}

.btn:hover {
    background: var(--surface-alt);
    border-color: var(--text-tertiary);
}

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-light);
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #D4432C 100%);
    color: var(--text-inverse);
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(232, 85, 61, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, #BE3A26 100%);
    box-shadow: 0 4px 12px rgba(232, 85, 61, 0.35);
    border-color: transparent;
}

.btn-primary:focus-visible {
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.btn-secondary {
    background: transparent;
    box-shadow: none;
    border-color: transparent;
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: var(--surface-alt);
    color: var(--text-primary);
    border-color: transparent;
}

.btn-sm {
    height: 34px;
    padding: 0 14px;
    font-size: 12.5px;
    border-radius: var(--radius-sm);
}

/* ============================================================
   TABS — Platform Tabs
   ============================================================ */
.platform-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border-light);
    padding-bottom: 0;
}

.tab-btn {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-tertiary);
    font-weight: 500;
    font-size: 13.5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: -2px;
    transition: all var(--transition-fast);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--surface-alt);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

/* ============================================================
   LOGIN PAGE — Striking Split Screen
   ============================================================ */
.login-container {
    min-height: 100vh;
    display: flex;
    background: var(--background);
}

.login-graphic {
    display: none;
}

@media (min-width: 900px) {
    .login-graphic {
        display: flex;
        flex: 1.2;
        background: var(--sidebar-bg);
        background-image:
            radial-gradient(ellipse at 20% 80%, rgba(232, 85, 61, 0.15) 0%, transparent 50%),
            radial-gradient(ellipse at 80% 20%, rgba(240, 158, 84, 0.1) 0%, transparent 50%),
            linear-gradient(180deg, rgba(232, 85, 61, 0.04) 0%, transparent 40%);
        align-items: center;
        justify-content: center;
        padding: 60px;
        color: white;
        position: relative;
        overflow: hidden;
    }

    .login-graphic::before {
        content: '';
        position: absolute;
        top: -50%;
        right: -30%;
        width: 600px;
        height: 600px;
        border-radius: 50%;
        background: radial-gradient(circle, rgba(232, 85, 61, 0.08) 0%, transparent 70%);
    }

    .graphic-content {
        max-width: 420px;
        position: relative;
        z-index: 1;
    }

    .graphic-content h2 {
        font-size: 36px;
        font-weight: 700;
        margin-bottom: 20px;
        letter-spacing: -0.03em;
        line-height: 1.15;
        background: linear-gradient(135deg, #ffffff 0%, rgba(255,255,255,0.7) 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
    }

    .graphic-content p {
        color: rgba(255, 255, 255, 0.4);
        line-height: 1.7;
        font-size: 15px;
    }
}

.login-form-side {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: transparent;
    box-shadow: none;
    border: none;
}

.login-card .logo { margin-bottom: 40px; }

.login-card .logo h1 {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.03em;
}

.login-card .logo p {
    color: var(--text-tertiary);
    font-size: 14px;
    margin-top: 6px;
}

/* Form Inputs */
.input-wrapper { margin-bottom: 20px; position: relative; }

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.01em;
}

.form-input {
    width: 100%;
    height: 48px;
    padding: 0 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    font-family: inherit;
    font-size: 14px;
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.form-input:hover {
    border-color: var(--text-tertiary);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
}

.form-input::placeholder { color: var(--text-tertiary); }

.input-wrapper i { display: none; }

/* Login Button */
.login-btn-wrapper { margin-top: 28px; }

.login-btn-wrapper .btn {
    height: 48px;
    width: 100%;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* ============================================================
   UTILITIES
   ============================================================ */
.hidden { display: none !important; }
.flex-1 { flex: 1; }
.mt-4 { margin-top: 16px; }
.mt-2 { margin-top: 8px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-primary { color: var(--primary); }

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.fade-in { animation: fadeIn 0.35s var(--ease-out) forwards; }

/* ============================================================
   CHART AREA
   ============================================================ */
.chart-grid {
    display: grid;
    gap: 16px;
    margin-bottom: 24px;
}

.chart-grid-wide {
    grid-template-columns: 2fr 1fr;
}

.chart-grid-split {
    grid-template-columns: 1fr 1fr;
}

.chart-card {
    padding: 24px;
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding: 16px 20px 0;
}

.chart-card .card-title {
    padding: 0;
    margin-bottom: 20px;
}

.chart-canvas {
    height: 280px;
    position: relative;
}

.chart-canvas-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================================
   HEALTH / QUALITY VIEWS
   ============================================================ */
.health-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.health-card {
    padding: 20px;
}

.sync-health-item {
    border: 1px solid var(--border);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background var(--transition-fast);
}

.sync-health-item:hover { background: var(--surface-alt); }

.quality-health-summary { display: flex; flex-direction: column; gap: 12px; }

.quality-kpis {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.quality-kpi {
    background: var(--surface-alt);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    text-align: center;
}

.quality-kpi-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 500;
}

.quality-kpi-value {
    font-size: 22px;
    font-weight: 700;
}

.quality-kpi-value.ok { color: var(--success); }
.quality-kpi-value.warn { color: var(--warning); }
.quality-kpi-value.err { color: var(--danger); }

.quality-detail {
    background: var(--surface-alt);
    border-radius: var(--radius-md);
    padding: 14px 16px;
}

.quality-detail-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.quality-detail-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    padding: 4px 0;
}

.quality-detail-row i {
    font-size: 14px;
    flex-shrink: 0;
}

.quality-detail-row .ok { color: var(--success); }
.quality-detail-row .warn { color: var(--warning); }

@media (max-width: 640px) {
    .quality-kpis { grid-template-columns: repeat(3, 1fr); gap: 6px; }
    .quality-kpi { padding: 10px 8px; }
    .quality-kpi-value { font-size: 18px; }
}

/* Calendar */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-day {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 8px;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    transition: all var(--transition-fast);
}

.calendar-day:hover { box-shadow: var(--shadow-sm); }
.calendar-day-empty { border: none; }

.calendar-day-today {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 1px var(--primary);
}

/* Upload Zone */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 48px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base);
}

.upload-zone:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

/* ============================================================
   TOOLBAR CARD
   ============================================================ */
.toolbar-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    margin-bottom: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}

.toolbar-group { display: flex; align-items: center; gap: 12px; }
.toolbar-dates { display: flex; gap: 8px; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
}

.pagination-size {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-tertiary);
    font-size: 13px;
}

.pagination-nav {
    display: flex;
    gap: 4px;
    align-items: center;
}

.pagination-summary {
    font-size: 13px;
    color: var(--text-tertiary);
}

/* ============================================================
   TRANSACTION VIEW (V2)
   ============================================================ */
.trans-topbar-v2 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.trans-topbar-v2 .daily-breadcrumb {
    margin-bottom: 0;
    flex: 1;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 14px;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.back-link:hover {
    background: var(--surface-alt);
    color: var(--primary);
}

/* Date Header Card */
.trans-date-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.trans-date-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.trans-date-badge {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    background: var(--primary);
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.trans-date-num {
    font-size: 22px;
    font-weight: 800;
    line-height: 1;
}

.trans-date-day {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    opacity: 0.8;
    margin-top: 1px;
}

/* Platform pills in header */
.trans-platform-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.trans-platform-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--surface-alt);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: 12px;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.trans-platform-pill:hover { box-shadow: var(--shadow-sm); }

.trans-platform-pill .pill-orders {
    font-weight: 700;
    color: var(--text-primary);
}

.trans-platform-pill .pill-net {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.trans-platform-pill .pill-coverage {
    font-size: 11px;
    color: var(--text-tertiary);
}

.transaction-head { margin-bottom: 20px; }
.transaction-head h2 { font-size: 20px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.02em; }
.transaction-head p { color: var(--text-tertiary); font-size: 13px; margin-top: 4px; }

.trans-platform-breakdown { display: flex; gap: 12px; align-items: center; font-size: 12px; flex-wrap: wrap; }
.transaction-meta { flex-wrap: wrap; gap: 12px; }
.trans-page-size { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--text-tertiary); }

/* Transaction row improvements */
.trans-row { transition: all var(--transition-fast); }
.trans-row:hover td { background: var(--primary-light) !important; }
.trans-row td { vertical-align: middle; }

.transaction-label-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12.5px;
    color: var(--text-secondary);
}

.order-id-cell .order-id-link {
    font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
    font-size: 12px;
}

/* Trans action button — compact view link */
.trans-action-cell .btn { padding: 0 10px; height: 30px; font-size: 12px; }

/* ============================================================
   MODALS — Overlay
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 24px;
}

.modal-overlay[aria-hidden="false"] { display: flex; }

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    max-width: 800px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 28px;
    animation: fadeInUp 0.3s var(--ease-out);
}

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-close {
    width: 36px; height: 36px; border-radius: var(--radius-md);
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text-tertiary); cursor: pointer; font-size: 18px;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--transition-fast);
}
.modal-close:hover { background: var(--surface-alt); color: var(--text-primary); }
.modal-body { margin-bottom: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding-top: 16px; border-top: 1px solid var(--border); }

/* Order Modal V2 */
.order-modal-v2 {
    max-width: 720px;
    padding: 0;
    overflow: hidden;
}

.order-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-alt);
}

.order-modal-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.order-modal-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.order-modal-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.order-modal-body {
    padding: 24px;
}

/* Order detail head (inside modal) */
.order-detail-head {
    margin-bottom: 20px;
}

.order-detail-head-main {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.order-detail-head-main b {
    color: var(--text-primary);
    font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
    font-size: 13px;
    background: var(--surface-alt);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
}

.order-detail-meta-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.order-detail-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    background: var(--surface-alt);
    border-radius: var(--radius-full);
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Order detail table (inside modal) */
.order-detail-table {
    min-width: unset !important;
}

.order-detail-table th {
    background: var(--surface) !important;
    font-size: 11px;
    padding: 10px 16px;
}

.order-detail-table td {
    padding: 12px 16px;
    font-size: 13px;
}

.order-detail-name {
    font-weight: 600;
    color: var(--text-primary);
    max-width: 340px;
}

.order-detail-option-row td {
    padding: 4px 16px 4px 32px !important;
    font-size: 12px;
    color: var(--text-tertiary);
    border-bottom: none !important;
}

.order-detail-note-row td {
    padding: 4px 16px 4px 32px !important;
    font-size: 12px;
    color: var(--warning);
    font-style: italic;
    border-bottom: none !important;
}

/* Order summary (price breakdown inside modal) */
.order-detail-summary {
    margin-top: 20px;
    padding: 16px 20px;
    background: var(--surface-alt);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
}

.order-detail-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.order-detail-summary-row + .order-detail-summary-row {
    border-top: 1px solid var(--border-light);
}

.order-detail-summary-row strong {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.order-detail-summary-row.negative strong { color: var(--danger); }
.order-detail-summary-row.total {
    padding: 10px 0 4px;
    border-top: 2px solid var(--border);
    font-weight: 700;
    color: var(--text-primary);
    font-size: 14px;
}

.order-detail-summary-row.total strong { color: var(--success); font-size: 15px; }

/* FoodStory Items Modal */
.fs-items-modal-content { max-width: 900px; padding: 0; }
.fs-items-modal-header { padding: 24px 28px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: flex-start; }
.fs-items-modal-title { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.fs-items-modal-subtitle { font-size: 13px; color: var(--text-tertiary); margin-top: 4px; }
.fs-items-modal-body { padding: 24px 28px; }
.fs-items-modal-footer { padding: 16px 28px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.fs-items-summary-grid { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.fs-items-summary-chip {
    padding: 10px 16px;
    background: var(--surface-alt);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 120px;
}
.fs-items-summary-chip .chip-label { font-size: 11px; color: var(--text-tertiary); text-transform: uppercase; font-weight: 600; letter-spacing: 0.04em; }
.fs-items-summary-chip strong { font-size: 15px; color: var(--text-primary); }

.fs-items-discount-alert {
    padding: 12px 16px;
    background: var(--warning-light);
    border-radius: var(--radius-md);
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 13px;
    margin-bottom: 20px;
}

.fs-modal-section { margin-bottom: 24px; }
.fs-modal-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.fs-meta-table-wrap { max-height: 300px; overflow-y: auto; }

/* ============================================================
   ALERTS & STATUS
   ============================================================ */
.alert-error {
    background: var(--danger-light);
    color: var(--danger);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 500;
    border: 1px solid rgba(220, 38, 38, 0.15);
}

/* Loading */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(6px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 250;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

/* Loading Skeleton */
.loading-skeleton { padding: 24px; display: flex; flex-direction: column; gap: 12px; }

.skeleton-row {
    height: 16px;
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, var(--surface-alt) 25%, var(--border-light) 50%, var(--surface-alt) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.skeleton-row:nth-child(2) { width: 75%; }
.skeleton-row:nth-child(3) { width: 60%; }

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

/* Empty State */
.empty-state {
    padding: 48px 24px;
    text-align: center;
    color: var(--text-tertiary);
}

.empty-state i {
    font-size: 48px;
    opacity: 0.4;
    margin-bottom: 12px;
    display: block;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#toastContainer {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-md);
    background: var(--text-primary);
    color: var(--text-inverse);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateX(20px);
    transition: all var(--transition-base);
    max-width: 400px;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }
.toast-info { background: var(--info); }

/* ============================================================
   FOODSTORY SPECIFIC
   ============================================================ */
.foodstory-view .summary-value-foodstory { color: #E65100; }
.foodstory-view .summary-value-lg { font-size: 28px; }
.foodstory-view .summary-value-danger { color: var(--danger); }
.foodstory-view .summary-value-success { color: var(--success); }

.foodstory-view .bill-note {
    color: var(--text-tertiary);
    font-size: 12px;
    max-width: 320px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

/* Calendar Toolbar */
.calendar-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
}

.calendar-content {
    padding: 0 20px 20px;
}

/* ============================================================
   SCRAPER CARDS
   ============================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.card:hover {
    box-shadow: var(--shadow-sm);
}

/* Modal info bar */
.modal-info-bar {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

/* ============================================================
   TRANSACTION SUMMARY GRID (JS-rendered)
   ============================================================ */
.transaction-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
    max-width: 100%;
}

.mini-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all var(--transition-fast);
}

.mini-card:hover {
    box-shadow: var(--shadow-sm);
}

.mini-label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.mini-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

/* ============================================================
   CALENDAR VIEW (JS-rendered)
   ============================================================ */
.calendar-header {
    margin-bottom: 16px;
}

.calendar-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.calendar-meta {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 4px;
}

.calendar-weekday {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 8px 4px;
}

.calendar-day {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px;
    min-height: 110px;
    display: flex;
    flex-direction: column;
    transition: all var(--transition-fast);
    cursor: default;
    background: var(--surface);
    font-family: inherit;
    font-size: inherit;
    text-align: left;
    color: inherit;
}

button.calendar-day {
    cursor: pointer;
}

button.calendar-day:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
    background: var(--primary-light);
}

.calendar-day-empty {
    border: 1px dashed var(--border-light);
    background: transparent;
    min-height: 110px;
}

.calendar-day-has-data {
    background: var(--surface-alt);
}

.calendar-day-today {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 1px var(--primary);
}

.calendar-day-num {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.calendar-day-metric {
    font-size: 11.5px;
    color: var(--text-secondary);
    font-weight: 500;
    line-height: 1.6;
    font-variant-numeric: tabular-nums;
}

.calendar-day-metric-net {
    color: var(--success);
    font-weight: 600;
}

.calendar-day-count {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: auto;
    padding-top: 4px;
}

.calendar-day-empty-label {
    font-size: 11px;
    color: var(--text-tertiary);
    opacity: 0.6;
}

/* ============================================================
   PAGINATION EXTRAS (JS-rendered)
   ============================================================ */
.page-dots {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 34px;
    font-size: 13px;
    color: var(--text-tertiary);
    user-select: none;
}

.page-info {
    font-size: 13px;
    color: var(--text-tertiary);
    padding: 0 8px;
}

/* ============================================================
   EMPTY STATE EXTRAS (JS-rendered)
   ============================================================ */
.empty-state-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.empty-state-hint {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-bottom: 16px;
}

.empty-state-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ============================================================
   TABLE SECTION (shared)
   ============================================================ */
.table-section {
    overflow: hidden;
    max-width: 100%;
}

.table-section .table-responsive,
.table-section .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
}


/* Ensure glass-card tables don't overflow */
.glass-card.table-section {
    overflow-x: auto;
}

/* View panels must not exceed viewport */
.view-panel {
    min-width: 0;
    max-width: 100%;
}

.transaction-view {
    min-width: 0;
    max-width: 100%;
}

.transaction-table-section {
    overflow-x: auto;
}

/* ============================================================
   BACKWARD COMPAT — old CSS variable names used in inline styles
   ============================================================ */
:root {
    /* Map old variable names to new ones */
    --text-main: var(--text-primary);
    --text-muted: var(--text-tertiary);
    --card-border: var(--border);
    --card-bg: var(--surface);
}

/* ============================================================
   DAILY TOOLBAR V2 — Compact unified filter toolbar
   ============================================================ */
.daily-toolbar {
    border-bottom: 1px solid var(--border);
}

/* Breadcrumb inside card — hidden by default, shown at Level 2+ */
.tb-breadcrumb {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
    font-size: 12.5px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.tb-breadcrumb.active { display: flex; }

/* Toolbar row */
.tb-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
}

.tb-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.tb-divider {
    width: 1px;
    height: 22px;
    background: var(--border);
    flex-shrink: 0;
    margin: 0 2px;
}

.tb-spacer { flex: 1; min-width: 8px; }

/* Compact date range */
.tb-date-range {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 10px;
    background: var(--surface);
    font-size: 12.5px;
    transition: border-color var(--transition-fast);
}

.tb-date-range:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.tb-date-range i { color: var(--text-tertiary); font-size: 14px; }

.tb-date-range input[type="date"] {
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 12.5px;
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
    padding: 0;
    height: 100%;
}

.tb-date-range span { color: var(--text-tertiary); font-size: 12px; user-select: none; }

/* Preset segmented control */
.tb-presets {
    display: flex;
    gap: 1px;
    background: var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.tb-preset {
    padding: 6px 10px;
    border: none;
    background: var(--surface-alt);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 11.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.tb-preset:hover { background: var(--surface); color: var(--text-primary); }
.tb-preset:active { background: var(--primary-light); color: var(--primary); }
.tb-preset:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

/* Compact select */
.tb-select {
    height: 32px;
    padding: 0 26px 0 10px;
    background: var(--surface-alt);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 7px center;
    background-size: 12px;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.tb-select:hover { background-color: var(--surface); border-color: var(--border); }
.tb-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }

/* Compact search */
.tb-search {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 10px;
    background: var(--surface-alt);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    min-width: 140px;
    transition: all var(--transition-fast);
}

.tb-search:focus-within {
    background: var(--surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.tb-search i { color: var(--text-tertiary); font-size: 13px; flex-shrink: 0; }

.tb-search input {
    border: none;
    background: transparent;
    outline: none;
    font-family: inherit;
    font-size: 12.5px;
    width: 100%;
    color: var(--text-primary);
    min-width: 0;
}

.tb-search input::placeholder { color: var(--text-tertiary); }

/* Reset button */
.tb-reset {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--surface-alt);
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 14px;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.tb-reset:hover { background: var(--danger-light); color: var(--danger); }
.tb-reset:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

/* Compact chips */
.tb-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding: 0 16px 8px;
}

.tb-chips:empty { display: none; }

/* ============================================================
   METRICS BAR — Compact horizontal summary strip
   ============================================================ */
.metrics-bar {
    display: flex;
    align-items: stretch;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 16px;
}

.metric-cell {
    flex: 1;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    border-right: 1px solid var(--border);
}

.metric-cell:last-child { border-right: none; }

.metric-cell.highlight {
    background: rgba(5, 150, 105, 0.04);
}

.metric-label {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.metric-label i { font-size: 12px; }

.metric-value {
    font-size: 17px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.metric-sub {
    font-size: 10px;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Focus-visible for interactive elements */
.btn:focus-visible, button:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ============================================================
   RESPONSIVE — Mobile First
   ============================================================ */
/* ── Tablet ≤ 1024px ────────────────────────────────── */
@media (max-width: 1024px) {
    .main-content {
        padding: 20px 16px;
        margin-left: 0;
        width: 100%;
    }

    /* Sidebar → slide-in overlay */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s var(--ease-out);
        width: 280px;
        box-shadow: none;
    }
    .sidebar.active, .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }
    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(2px);
        z-index: 99;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s var(--ease-out);
    }
    .sidebar-overlay.active { opacity: 1; pointer-events: auto; }
    .hamburger-btn { display: flex; }

    /* Header */
    .header-title h1 { font-size: 18px; }
    .header-title p { font-size: 11px; }

    /* Grids */
    .stats-grid, .daily-summary-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 10px;
    }
    .stat-card { padding: 16px; }
    .stat-value { font-size: 22px; }
    .health-grid { grid-template-columns: 1fr; }
    .chart-grid-wide, .chart-grid-split { grid-template-columns: 1fr; }

    /* Old filter bar */
    .filter-row { flex-direction: column; align-items: stretch; }
    .filter-group { flex-wrap: wrap; }
    .search-field { min-width: unset; width: 100%; }

    /* Tables — allow horizontal scroll */
    .data-table, .daily-data-table, .transaction-data-table { min-width: 700px; }

    /* Daily detail */
    .daily-breadcrumb { font-size: 12px; padding: 8px 14px; }
    .detail-header { flex-direction: column; padding: 16px; }
    .flow-legend { padding: 4px 16px 12px; }
    .deduction-flow { margin: 0 16px 8px; }

    /* Toolbar V2 */
    .tb-row { flex-wrap: wrap; }
    .tb-spacer { display: none; }
    .tb-actions { flex: 1; }
    .tb-search { flex: 1; min-width: 120px; }
    .metrics-bar { flex-wrap: wrap; }
    .metric-cell { flex: 1 1 calc(33.33% - 1px); min-width: 100px; }

    /* Modal — bottom-sheet pattern */
    .modal-overlay { padding: 0; align-items: flex-end; }
    .modal-content {
        max-width: 100%;
        width: 100%;
        max-height: 94vh;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        animation: slideUp 0.3s var(--ease-out);
    }
    .order-modal-v2 {
        max-width: 100%;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    }
    .order-modal-body { padding: 16px; }
    .order-modal-header { padding: 16px 20px; }
    .order-detail-table td { padding: 10px 12px; font-size: 12px; }
    .order-detail-table th { padding: 8px 12px; }
    .order-detail-option-row td { padding: 3px 12px 3px 24px !important; }
    .order-detail-note-row td { padding: 3px 12px 3px 24px !important; }
    .order-detail-name { max-width: 200px; }
    .order-detail-summary { padding: 12px 16px; margin-top: 16px; }

    /* FoodStory modal — bottom-sheet */
    .fs-items-modal-content { max-width: 100%; border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
    .fs-items-modal-header { padding: 16px 20px; }
    .fs-items-modal-body { padding: 16px 20px; }
    .fs-items-modal-footer { padding: 12px 20px; }
    .fs-items-summary-grid { gap: 8px; }
    .fs-items-summary-chip { padding: 8px 12px; }

    /* Transaction view — compact */
    .trans-topbar-v2 { flex-direction: column; align-items: flex-start; gap: 8px; }
    .trans-date-header { flex-direction: column; align-items: flex-start; gap: 12px; }
}

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

/* ── Mobile ≤ 640px ─────────────────────────────────── */
@media (max-width: 640px) {
    /* Main content tight padding */
    .main-content { padding: 12px 10px; }

    /* Header compact */
    .header { margin-bottom: 8px; }
    .header-title h1 { font-size: 16px; }
    .header-title p { display: none; }
    .header-left { gap: 10px; }

    /* Sidebar full-width on small phones */
    .sidebar { width: 85vw; max-width: 300px; }

    /* Summary grids — 2 columns */
    .stats-grid, .daily-summary-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .stat-card { padding: 12px; }
    .stat-value { font-size: 18px; }
    .stat-label { font-size: 10.5px; }

    /* FoodStory summary cards */
    .summary-card { padding: 14px 16px; }
    .summary-title { font-size: 10.5px; margin-bottom: 6px; }
    .summary-value { font-size: 20px !important; }

    /* DS Strip — stack vertically */
    .ds-strip { border-radius: var(--radius-lg); }

    /* Old filter bar */
    .date-presets { display: none; }
    .export-buttons { flex-direction: column; }
    .daily-breadcrumb { gap: 4px; padding: 8px 12px; }
    .breadcrumb-item, .breadcrumb-current { font-size: 12px; padding: 3px 6px; }
    .filter-chips { padding: 0 12px 10px; gap: 6px; }

    /* Toolbar V2 — compact mobile */
    .tb-presets { display: none; }
    .tb-row { gap: 6px; padding: 8px 12px; }
    .tb-breadcrumb { padding: 6px 12px; font-size: 12px; }
    .tb-chips { padding: 0 12px 6px; }
    .tb-select { height: 36px; font-size: 13px; padding: 0 28px 0 10px; }
    .tb-search { height: 36px; }
    .tb-search input { font-size: 13px; }
    .tb-reset { width: 36px; height: 36px; font-size: 16px; }
    .tb-date-range { height: 36px; }
    .tb-divider { display: none; }
    .tb-dates { width: 100%; }
    .tb-selects { width: 100%; flex-wrap: wrap; }
    .tb-selects .tb-select { flex: 1; min-width: 0; }
    .tb-actions { width: 100%; }
    .tb-search { flex: 1; min-width: 0; }

    /* Metrics bar — stack vertically */
    .metrics-bar { flex-direction: column; }
    .metric-cell { border-right: none; border-bottom: 1px solid var(--border); padding: 10px 16px; }
    .metric-cell:last-child { border-bottom: none; }
    .metric-value { font-size: 16px; }

    /* Tables — reduce min-width, better scroll UX */
    .data-table, .daily-data-table, .transaction-data-table { min-width: 560px; }
    .data-table th, .data-table td { padding: 10px 12px; font-size: 12px; }
    .table-wrap, .table-responsive {
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
    }

    /* Glass card — tighter */
    .glass-card { border-radius: var(--radius-md); }
    .glass-card.table-section { border-radius: var(--radius-md); }

    /* Transaction date header — compact */
    .trans-date-header { padding: 14px 16px; gap: 10px; margin-bottom: 10px; border-radius: var(--radius-md); }
    .trans-date-badge { width: 44px; height: 44px; border-radius: var(--radius-md); }
    .trans-date-num { font-size: 18px; }
    .trans-date-day { font-size: 9px; }
    .trans-date-header-left { gap: 12px; }
    .trans-date-header-left h2 { font-size: 16px !important; }
    .trans-date-header-left p { font-size: 12px !important; }

    /* Platform pills — compact */
    .trans-platform-pills { gap: 6px; }
    .trans-platform-pill { padding: 6px 10px; font-size: 11px; gap: 6px; }
    .trans-platform-pill .pill-coverage { display: none; }

    /* Transaction breadcrumb */
    .trans-topbar-v2 { padding: 0 0 10px; }
    .trans-topbar-v2 .daily-breadcrumb { font-size: 12px; padding: 8px 12px; }

    /* Pagination — stack on mobile */
    .pagination-controls {
        flex-direction: column;
        gap: 8px;
        padding: 10px 12px;
        align-items: stretch;
    }
    .pagination-nav { justify-content: center; flex-wrap: wrap; }
    .pagination-nav .btn { min-width: 36px; height: 36px; padding: 0 8px; }
    .pagination-size { justify-content: center; }
    .pagination-summary { text-align: center; font-size: 12px; }

    /* Filters meta bar — stack */
    .filters-meta, .table-meta-bar {
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
        padding: 10px 12px;
    }
    .filters-meta-left { font-size: 12px; }
    .daily-view-switch { align-self: flex-start; }
    .daily-view-switch .btn { font-size: 12px; padding: 5px 10px; }

    /* Export buttons — icon only on mobile */
    .btn-text { display: none; }

    /* Modal — full bottom-sheet */
    .modal-content { padding: 16px; max-height: 96vh; border-radius: 16px 16px 0 0; }
    .modal-header { margin-bottom: 12px; }
    .modal-close { width: 32px; height: 32px; }

    /* Order modal mobile */
    .order-modal-header { padding: 14px 16px; }
    .order-modal-icon { width: 36px; height: 36px; font-size: 16px; }
    .order-modal-header h3 { font-size: 14px; }
    .order-modal-body { padding: 14px; }
    .order-detail-head-main { font-size: 13px; }
    .order-detail-meta-badges { gap: 4px; }
    .order-detail-chip { font-size: 10.5px; padding: 2px 8px; }
    .order-detail-table { min-width: unset !important; }
    .order-detail-table th { font-size: 10px; padding: 8px 10px; }
    .order-detail-table td { padding: 8px 10px; font-size: 12px; }
    .order-detail-option-row td { padding: 2px 10px 2px 20px !important; font-size: 11px; }
    .order-detail-note-row td { padding: 2px 10px 2px 20px !important; font-size: 11px; }
    .order-detail-name { max-width: 160px; font-size: 12px; }
    .order-detail-summary { padding: 10px 14px; }
    .order-detail-summary-row { font-size: 12px; padding: 5px 0; }
    .order-detail-summary-row.total { font-size: 13px; }

    /* FoodStory modal mobile */
    .fs-items-modal-content { border-radius: 16px 16px 0 0; max-height: 96vh; }
    .fs-items-modal-header { padding: 14px 16px; }
    .fs-items-modal-title { font-size: 15px; }
    .fs-items-modal-subtitle { font-size: 12px; }
    .fs-items-modal-body { padding: 14px 16px; }
    .fs-items-modal-footer { padding: 10px 16px; }
    .fs-items-summary-grid { gap: 6px; }
    .fs-items-summary-chip { padding: 8px 10px; min-width: unset; flex: 1 1 calc(50% - 3px); }
    .fs-items-summary-chip strong { font-size: 13px; }
    .fs-modal-section-title { font-size: 13px; }
    .fs-meta-table-wrap { max-height: 200px; }

    /* Deduction flow — compact */
    .deduction-flow { margin: 0 12px 6px; height: 8px; border-radius: 4px; }
    .flow-legend { padding: 4px 12px 10px; font-size: 11px; flex-wrap: wrap; gap: 4px 12px; }

    /* Calendar view */
    .calendar-header h3 { font-size: 16px; }

    /* Level 2 platform group rows */
    .platform-group-row td { padding: 8px 12px !important; font-size: 12px; }

    /* Login page */
    .login-form-side { padding: 24px 20px; }
    .login-card { padding: 24px 0; }
    .login-card .logo h1 { font-size: 22px; }
    .form-input { height: 44px; font-size: 15px; }
    .login-btn-wrapper .btn { height: 46px; font-size: 15px; }

    /* Toast — full width on mobile */
    .toast-container { left: 10px; right: 10px; max-width: unset; }
}
