/* =============================================================================
   campistry_snacks.css — Campistry Snacks Manager Dashboard Styles
   Product Color: #EA580C (Orange — Snacks brand)
   Layout: sidebar-left + main content area, matching campistry_live / campistry_health
   ============================================================================= */

:root {
    /* Snacks Brand — Orange */
    --snacks: #EA580C;
    --snacks-dark: #C2410C;
    --snacks-darker: #9A3412;
    --snacks-light: #F97316;
    --snacks-50: #FFF7ED;
    --snacks-100: #FFEDD5;
    --snacks-200: #FED7AA;
    --snacks-300: #FDBA74;
    --snacks-400: #FB923C;

    /* Neutrals */
    --bg-primary: #F8FAFC;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #F1F5F9;
    --text-primary: #0F172A;
    --text-secondary: #334155;
    --text-muted: #64748B;
    --border-light: #E2E8F0;
    --border-medium: #CBD5E1;

    /* Slate scale */
    --slate-50: #F8FAFC; --slate-100: #F1F5F9; --slate-200: #E2E8F0; --slate-300: #CBD5E1;
    --slate-400: #94A3B8; --slate-500: #64748B; --slate-600: #475569; --slate-700: #334155;
    --slate-800: #1E293B; --slate-900: #0F172A;

    /* Semantic */
    --red-50: #FEF2F2; --red-100: #FEE2E2; --red-500: #EF4444; --red-600: #DC2626;
    --amber-50: #FFFBEB; --amber-100: #FEF3C7; --amber-500: #F59E0B; --amber-600: #D97706;
    --blue-50: #EFF6FF; --blue-100: #DBEAFE; --blue-500: #3B82F6; --blue-600: #2563EB;
    --green-50: #F0FDF4; --green-100: #DCFCE7; --green-500: #22C55E; --green-600: #16A34A;
    --purple-50: #FAF5FF; --purple-500: #A855F7;

    /* Type */
    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'DM Sans', system-ui, sans-serif;

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

    /* Shadow */
    --shadow-sm: 0 1px 3px rgba(0,0,0,.04);
    --shadow-md: 0 4px 8px rgba(0,0,0,.07);
    --shadow-lg: 0 8px 20px rgba(0,0,0,.10);

    --ease: cubic-bezier(.16, 1, .3, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: var(--font-body); font-size: 15px; line-height: 1.6; color: var(--text-primary); background: var(--bg-primary); -webkit-font-smoothing: antialiased; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* ==================== HEADER ==================== */
.app-header {
    display: flex; align-items: center; justify-content: space-between;
    height: 56px; padding: 0 16px;
    background: #fff;
    border-bottom: 1px solid var(--border-light);
    position: sticky; top: 0; z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.header-right { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
/* Quick-switch app bar: the one zone allowed to shrink and internally
   scroll — never the nav controls or the sync badge/avatar either side. */
.app-header-center { display: flex; align-items: center; justify-content: center; min-width: 0; overflow: hidden; flex: 1 1 auto; }
.app-header .quick-switch-bar { position: static; transform: none; max-width: 100%; }

.snacks-back-btn {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: .77rem; font-weight: 600; color: var(--slate-400);
    text-decoration: none; padding: 5px 9px;
    border-radius: var(--radius-sm);
    transition: color .15s, background .15s;
    flex-shrink: 0;
}
.snacks-back-btn:hover { color: var(--slate-700); background: var(--slate-100); }
.snacks-back-btn svg { flex-shrink: 0; }

.snacks-logo-link { display: flex; align-items: center; flex-shrink: 0; }

.header-app-switch {
    display: flex; align-items: center; margin-left: 4px;
    text-decoration: none; opacity: .85; transition: opacity .2s;
}
.header-app-switch:hover { opacity: .55; }

.hamburger-btn {
    display: flex; flex-direction: column; justify-content: center; gap: 4px;
    width: 36px; height: 36px; padding: 8px;
    border: 1px solid var(--border-light); border-radius: var(--radius-sm);
    background: #fff; flex-shrink: 0;
}
.hamburger-btn span { display: block; height: 2px; background: var(--slate-600); border-radius: 1px; }
.hamburger-btn:hover { border-color: var(--snacks); background: var(--snacks-50); }

.sync-badge {
    display: flex; align-items: center; gap: .375rem;
    padding: .25rem .65rem;
    background: var(--bg-tertiary); border-radius: 100px;
    font-size: .7rem; font-weight: 500; color: var(--text-muted);
}
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green-500); }

.snacks-user-name { font-size: .78rem; font-weight: 500; color: var(--slate-400); }

/* ==================== SIDEBAR ==================== */
.sidebar-backdrop {
    display: none; position: fixed; inset: 0;
    background: rgba(2,6,23,.5); z-index: 45;
}
body.sidebar-open .sidebar-backdrop { display: block; }

/* Dark sidebar shell — matches Flow's #sidebar (styles.css) exactly:
   same navy gradient, same rgba(slate) item/label/dot values. Only the
   "active" accent swaps to Snacks' own orange instead of Flow's teal. */
.sidebar {
    position: fixed; top: 56px; left: 0; bottom: 0; width: 240px;
    background: linear-gradient(180deg, #0a0f1e 0%, #020617 100%);
    border-right: 1px solid rgba(148,163,184,.08);
    padding: 1rem .85rem; z-index: 50; overflow-y: auto;
    display: flex; flex-direction: column; gap: .5rem;
    transform: translateX(-100%);
    transition: transform .25s var(--ease);
}
body.sidebar-open .sidebar { transform: translateX(0); }

.sidebar-label {
    font-size: .65rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .08em;
    color: rgba(148,163,184,.5);
    padding: 10px 12px 4px;
}

.sidebar-item {
    display: flex; align-items: center; gap: .6rem;
    padding: .55rem .7rem;
    border-radius: var(--radius-sm);
    font-size: .85rem; font-weight: 500;
    color: rgba(203,213,225,.7);
    cursor: pointer; border: 1px solid transparent;
    background: none; width: 100%; text-align: left;
    transition: all .2s var(--ease);
    font-family: var(--font-body);
    text-decoration: none;
    margin-bottom: .2rem;
}
.sidebar-item:hover { background: rgba(148,163,184,.08); color: rgba(241,245,249,.95); }
.sidebar-item.active {
    background: rgba(234,88,12,0.15);
    color: #fff;
    border-color: rgba(234,88,12,0.3);
    font-weight: 600;
}
.sidebar-item.active .sidebar-dot { background: var(--snacks); box-shadow: 0 0 8px rgba(234,88,12,.4); transform: scale(1.3); }

.sidebar-dot {
    width: 8px; height: 8px; border-radius: 999px;
    background: rgba(100,116,139,.4); flex-shrink: 0;
    transition: all .2s var(--ease);
}
.sidebar-item:hover .sidebar-dot { background: rgba(148,163,184,.5); transform: scale(1.2); }

.sidebar-item-link { color: rgba(203,213,225,.7); }

/* ==================== APP CONTENT ==================== */
.app-content {
    padding: 24px 28px 80px;
    min-height: calc(100vh - 58px);
}

/* ==================== PAGES ==================== */
.snacks-page { display: none; }
.snacks-page.active { display: block; animation: fadeUp .25s var(--ease); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ==================== PAGE HERO ==================== */
.snacks-page-hero, .page-hero {
    display: flex; align-items: center; gap: 14px;
    margin-bottom: 22px; padding-bottom: 18px;
    border-bottom: 1px solid var(--slate-100);
}
.snacks-page-hero-icon, .page-hero-icon {
    width: 48px; height: 48px; border-radius: 12px;
    background: var(--snacks-50);
    color: var(--snacks);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.snacks-page-hero h1, .page-hero h1 {
    font-family: var(--font-body);
    font-size: 1.35rem; font-weight: 800;
    color: var(--slate-900); line-height: 1.2;
}
.snacks-page-hero p, .page-hero p { font-size: .82rem; color: var(--slate-500); margin-top: 3px; }

/* ==================== STATS GRID ==================== */
.stats-grid {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 1rem; margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--bg-secondary); border: 1px solid var(--border-light);
    border-radius: var(--radius-lg); padding: 1.15rem 1.25rem;
    display: flex; align-items: center; gap: 1rem;
    transition: all .2s; box-shadow: var(--shadow-sm);
}
.stat-card:hover { border-color: var(--border-medium); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius-md); display: flex; align-items: center;
    justify-content: center; flex-shrink: 0;
}
.stat-icon.blue  { background: #EFF6FF; color: #2563EB; }
.stat-icon.green { background: #F0FDF4; color: #16A34A; }
.stat-icon.red   { background: #FEF2F2; color: #DC2626; }
.stat-icon.amber { background: #FFFBEB; color: #D97706; }
.stat-icon.orange, .stat-icon:not([class*=" "]) { background: var(--snacks-50); color: var(--snacks); }
.stat-value { font-family: var(--font-body); font-size: 1.5rem; font-weight: 800; line-height: 1; color: var(--slate-900); }
.stat-label { font-size: .7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }

/* ==================== CARDS ==================== */
.card {
    background: var(--bg-secondary); border: 1px solid var(--border-light);
    border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
}
.card-header {
    padding: 1rem 1.25rem; display: flex; align-items: center;
    justify-content: space-between; border-bottom: 1px solid var(--border-light);
}
.card-header h2 { font-size: 1rem; font-weight: 600; color: var(--slate-800); }
.card-body { padding: 1.25rem; }
.card-count {
    font-size: .75rem; font-weight: 600; color: var(--text-muted);
    background: var(--bg-tertiary); padding: .15rem .6rem; border-radius: 100px;
}

/* ==================== TABLE ==================== */
.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .8125rem; }
.data-table thead { background: var(--bg-tertiary); }
.data-table th {
    padding: .625rem 1rem; text-align: left;
    font-size: .69rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .06em;
    color: var(--text-muted); border-bottom: 1px solid var(--border-light);
}
.data-table td { padding: .7rem 1rem; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.data-table tbody tr:hover { background: var(--snacks-50); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ==================== BADGES ==================== */
.badge {
    display: inline-flex; padding: .2rem .6rem;
    font-size: .7rem; font-weight: 600;
    border-radius: var(--radius-full);
    text-transform: uppercase; letter-spacing: .03em;
}
.badge-green { background: var(--green-50); color: var(--green-600); }
.badge-amber { background: var(--amber-50); color: var(--amber-600); }
.badge-red { background: var(--red-50); color: var(--red-600); }
.badge-neutral { background: var(--bg-tertiary); color: var(--text-muted); }

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-flex; align-items: center; gap: .375rem;
    padding: .5rem 1rem; border-radius: var(--radius-sm);
    font-size: .8125rem; font-weight: 600;
    border: 1px solid transparent; transition: all .15s;
    white-space: nowrap; font-family: var(--font-body);
    cursor: pointer;
}
.btn-primary { background: var(--snacks); color: white; box-shadow: 0 1px 2px rgba(234,88,12,.2); }
.btn-primary:hover { background: var(--snacks-dark); }
.btn-secondary { background: var(--bg-secondary); color: var(--text-secondary); border-color: var(--border-light); }
.btn-secondary:hover { background: var(--bg-tertiary); }
.btn-sm { padding: .35rem .75rem; font-size: .75rem; }

/* ==================== FORMS ==================== */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.25rem; }
.form-group { display: flex; flex-direction: column; gap: .35rem; }
.form-label { font-size: .8125rem; font-weight: 600; color: var(--text-secondary); }
.form-input, .form-select {
    width: 100%; padding: .6rem .875rem;
    border: 1px solid var(--border-light); border-radius: var(--radius-sm);
    font-family: inherit; font-size: .875rem;
    color: var(--text-primary); background: var(--bg-secondary);
    transition: border-color .15s, box-shadow .15s;
}
.form-input:focus, .form-select:focus {
    outline: none; border-color: var(--snacks);
    box-shadow: 0 0 0 3px rgba(234,88,12,.1);
}
.form-hint { font-size: .72rem; color: var(--text-muted); line-height: 1.45; }
/* Payment-method toggles (Settings) */
.pay-row {
    display: flex; align-items: center; gap: .6rem;
    padding: .55rem .75rem;
    border: 1px solid var(--border-light); border-radius: var(--radius-sm);
    background: var(--bg-secondary); font-size: .85rem;
    cursor: pointer;
}
.pay-row input { width: 16px; height: 16px; accent-color: var(--snacks); cursor: pointer; }
.pay-row.blocked { cursor: not-allowed; opacity: .72; background: var(--bg-tertiary); }
.pay-row-note { margin-left: auto; font-size: .72rem; color: var(--text-muted); }
.search-bar {
    display: flex; align-items: center; gap: 8px;
    padding: .5rem .875rem;
    background: var(--bg-tertiary); border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
}
.search-bar:focus-within { border-color: var(--snacks); box-shadow: 0 0 0 3px rgba(234,88,12,.1); background: white; }
.search-bar svg { color: var(--text-muted); flex-shrink: 0; }
.search-bar input { border: none; background: none; outline: none; font-family: inherit; font-size: .875rem; color: var(--text-primary); width: 100%; }

/* ==================== ANALYTICS ==================== */
.analytics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-bottom: 1.25rem; }
.metric-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.metric-card { background: white; border: 1px solid var(--border-light); border-radius: var(--radius-md); padding: 1rem 1.15rem; box-shadow: var(--shadow-sm); }
.metric-card-label { font-size: .7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; margin-bottom: .25rem; }
.metric-card-value { font-size: 1.35rem; font-weight: 700; font-family: var(--font-display); }
.metric-card-sub { font-size: .7rem; color: var(--text-muted); margin-top: .15rem; }

/* Popularity ranking */
.rank-item { display: flex; align-items: center; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--border-light); }
.rank-item:last-child { border-bottom: none; }
.rank-pos { font-size: .8rem; font-weight: 800; color: var(--text-muted); min-width: 20px; text-align: center; }
.rank-info { flex: 1; min-width: 0; }
.rank-name { font-size: .8125rem; font-weight: 600; }
.rank-bar-track { height: 6px; background: var(--snacks-50); border-radius: 3px; margin-top: 3px; overflow: hidden; }
.rank-bar-fill { height: 100%; border-radius: 3px; background: var(--snacks); transition: width .6s var(--ease); }
.rank-count { font-size: .8125rem; font-weight: 700; min-width: 40px; text-align: right; }
.rank-revenue { font-size: .7rem; color: var(--text-muted); text-align: right; }

/* Category breakdown */
.cat-row { display: flex; align-items: center; gap: .75rem; padding: .65rem 0; border-bottom: 1px solid var(--border-light); }
.cat-row:last-child { border-bottom: none; }
.cat-dot { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.cat-name { flex: 1; font-size: .8125rem; font-weight: 600; }
.cat-value { font-size: .8125rem; font-weight: 700; min-width: 50px; text-align: right; }
.cat-pct { font-size: .7rem; color: var(--text-muted); min-width: 40px; text-align: right; }

/* Camper spending leaderboard */
.spend-row { display: flex; align-items: center; gap: .75rem; padding: .55rem 0; border-bottom: 1px solid var(--border-light); }
.spend-row:last-child { border-bottom: none; }
.spend-avatar { width: 30px; height: 30px; border-radius: var(--radius-full); background: var(--snacks-50); display: flex; align-items: center; justify-content: center; font-size: .7rem; font-weight: 700; color: var(--snacks); flex-shrink: 0; }
.spend-name { flex: 1; font-size: .8125rem; font-weight: 600; }
.spend-amount { font-size: .8125rem; font-weight: 700; }

/* Hourly heatmap */
.heat-cell { width: 32px; height: 32px; border-radius: var(--radius-xs); display: flex; align-items: center; justify-content: center; font-size: .6rem; font-weight: 700; transition: all .2s; }
.heat-cell:hover { transform: scale(1.15); }
.heat-label { font-size: .6rem; color: var(--text-muted); width: 32px; text-align: center; }

/* Bar chart */
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 8px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bar { width: 100%; border-radius: 4px 4px 0 0; transition: height .4s var(--ease); min-height: 2px; }
.bar-label { font-size: .65rem; color: var(--text-muted); font-weight: 500; }
.bar-value { font-size: .65rem; color: var(--text-primary); font-weight: 700; }

/* ==================== MODAL ==================== */
.modal-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.35); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: white; border-radius: var(--radius-xl); box-shadow: 0 20px 60px rgba(0,0,0,.15); width: 480px; max-width: 95vw; max-height: 90vh; overflow-y: auto; animation: slideUp .25s var(--ease); }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.modal-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border-light); display: flex; align-items: center; justify-content: space-between; }
.modal-header h2 { font-size: 1.1rem; font-weight: 600; }
.modal-close { width: 32px; height: 32px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; color: var(--text-muted); cursor: pointer; }
.modal-close:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border-light); display: flex; justify-content: flex-end; gap: .5rem; }

/* ==================== TOAST ==================== */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(100px); background: #1e293b; color: white; padding: 10px 20px; border-radius: var(--radius-sm); font-size: .8125rem; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 300; opacity: 0; transition: all .25s ease; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error, .toast.err { background: #DC2626; }

/* ==================== BOTTOM NAV (mobile) ==================== */
.snacks-bnav {
    display: none; position: fixed; bottom: 0; left: 0; right: 0;
    height: 60px; background: rgba(255,255,255,.97);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-light); z-index: 100;
}
.snacks-bnav-inner { display: flex; align-items: center; justify-content: space-around; height: 100%; max-width: 540px; margin: 0 auto; }
.snacks-bnav-item {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    background: none; border: none; cursor: pointer;
    color: var(--slate-400);
    font-size: .59rem; font-weight: 600;
    padding: 4px 8px;
    font-family: var(--font-body);
    transition: color .2s ease;
    text-decoration: none;
}
.snacks-bnav-item.active, .snacks-bnav-item:hover { color: var(--snacks); }
.snacks-bnav-item svg { flex-shrink: 0; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .snacks-back-btn { display: none; }
    .app-content { padding: 16px 14px 80px; }
    .snacks-bnav { display: block; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: .75rem; }
    .analytics-grid { grid-template-columns: 1fr; }
    .metric-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .header-app-switch { display: none; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .metric-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .metric-row { grid-template-columns: 1fr; }
}

/* Account transaction-history modal (opened from the Accounts tab) */
.acct-name-link { color: var(--text-primary); text-decoration: none; border-bottom: 1px dashed var(--border, #cbd5e1); cursor: pointer; }
.acct-name-link:hover { color: var(--snacks, #EA580C); border-bottom-color: currentColor; }
.hist-summary { font-size: .85rem; color: var(--text-muted); margin-bottom: 12px; }
.hist-summary strong { color: var(--text-primary); font-size: 1rem; }
.hist-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border, #e2e8f0); }
.hist-row:last-child { border-bottom: none; }
.hist-label { font-weight: 600; font-size: .85rem; color: var(--text-primary); }
.hist-when { font-size: .7rem; color: var(--text-muted); margin-top: 2px; }
.hist-amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.hist-tag { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; font-size: .58rem; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; background: var(--snacks, #EA580C); color: #fff; vertical-align: middle; }

/* Bigger transaction-history modal + In/Out filter */
.hist-modal { max-width: 680px; width: 92vw; }
.hist-scroll { max-height: 60vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.hist-filter { display: flex; gap: 6px; margin-bottom: 14px; }
.hist-filter-btn { flex: 1; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--border, #e2e8f0); background: var(--bg, #f8fafc); color: var(--text-muted); font-size: .8rem; font-weight: 700; cursor: pointer; transition: all .12s; }
.hist-filter-btn:hover { border-color: var(--snacks, #EA580C); color: var(--snacks-dark, #C2410C); }
.hist-filter-btn.active { background: var(--snacks, #EA580C); border-color: var(--snacks, #EA580C); color: #fff; }
