/* POS Portal v2.62: shared Warm Ivory / Deep Teal themes + phone-only dashboard and compact dock. */
/* Unified POS Portal theme variables.
   nav-theme-v263.css is the single source of truth for Light/Dark colours. */
:root,
html[data-theme="light"] {
  color-scheme: light;
  --theme-bg: #FFFFFF;
  --theme-ink: #24272C;
  --theme-accent: #526783;
  --theme-accent-hover: #435872;
  --theme-surface: #F5F6F8;
  --theme-surface-2: #EAEDF2;
  --theme-muted: #66717F;
  --theme-border: #DDE1E6;
  --theme-nav: #F5F6F8;
  --theme-positive: #267C57;
  --theme-negative: #B34C4C;
  --theme-chart-line: #526783;
  --theme-chart-muted: #91A4BE;

  /* Legacy aliases retained for mobile-only components. */
  --navy: #526783;
  --navy-2: #435872;
  --bg: #FFFFFF;
  --card: #F5F6F8;
  --ink: #24272C;
  --muted: #66717F;
  --line: #DDE1E6;
  --accent: #526783;
  --accent-2: #435872;
  --positive: #267C57;
  --negative: #B34C4C;
  --warning: #9A7957;
  --shadow: 0 12px 30px rgba(36,39,44,.065);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --theme-bg: #181A1D;
  --theme-ink: #E7E9ED;
  --theme-accent: #91A4BE;
  --theme-accent-hover: #A9B9CC;
  --theme-surface: #23262B;
  --theme-surface-2: #2D3138;
  --theme-muted: #AEB5BF;
  --theme-border: #3A4048;
  --theme-nav: #23262B;
  --theme-positive: #78C6A0;
  --theme-negative: #F08A8A;
  --theme-chart-line: #91A4BE;
  --theme-chart-muted: #66778D;

  /* Legacy aliases retained for mobile-only components. */
  --navy: #23262B;
  --navy-2: #181A1D;
  --bg: #181A1D;
  --card: #23262B;
  --ink: #E7E9ED;
  --muted: #AEB5BF;
  --line: #3A4048;
  --accent: #91A4BE;
  --accent-2: #A9B9CC;
  --positive: #78C6A0;
  --negative: #F08A8A;
  --warning: #D7B879;
  --shadow: 0 14px 34px rgba(0,0,0,.22);
}
html[data-theme] body { background:var(--theme-bg); color:var(--theme-ink); transition:background-color .23s ease,color .23s ease; }
html[data-theme] .card { background:var(--theme-surface); border-color:var(--theme-border); color:var(--theme-ink); }
html[data-theme] .sidebar { background:linear-gradient(180deg,var(--navy), var(--navy-2)); }
html[data-theme="light"] .sidebar { color:#F4F0E8; }
html[data-theme] .brand-mark, html[data-theme] .btn.primary { background:var(--theme-accent); color:var(--theme-bg); }
html[data-theme="light"] .brand-mark, html[data-theme="light"] .btn.primary { color:#fff; }
html[data-theme] .btn.primary:hover { background:var(--theme-accent-hover); }
html[data-theme] .btn.dark { background:var(--navy); color:#fff; }
html[data-theme="dark"] .btn.dark { background:var(--theme-accent); color:#10272D; }
html[data-theme] .nav-btn.active { background:color-mix(in srgb, var(--theme-accent) 22%, transparent); box-shadow:inset 3px 0 var(--theme-accent); }
html[data-theme] .subtitle, html[data-theme] .card-head p, html[data-theme] .filter-group label,
html[data-theme] .kpi .label, html[data-theme] .kpi .hint, html[data-theme] .range-summary,
html[data-theme] .cell-sub, html[data-theme] .empty-table { color:var(--theme-muted); }
html[data-theme] .kpi .value,html[data-theme] .cell-main,html[data-theme] .bar-meta strong { color:var(--theme-ink); }
html[data-theme] th { background:var(--theme-surface-2); color:var(--theme-muted); border-bottom-color:var(--theme-border); }
html[data-theme] td { border-bottom-color:var(--theme-border); }
html[data-theme] tr:hover td { background:color-mix(in srgb, var(--theme-accent) 8%, transparent); }
html[data-theme] .card-head { border-bottom-color:var(--theme-border); }
html[data-theme] .grid-line { stroke:var(--theme-border); }
html[data-theme] .bar { fill:var(--theme-accent); }
html[data-theme] .bar:hover { fill:var(--theme-accent-hover); }
html[data-theme] .line-path { stroke:var(--theme-chart-line); }
html[data-theme] .dot { fill:var(--theme-chart-line); }
html[data-theme] .bar-track { background:var(--theme-surface-2); }
html[data-theme] .bar-fill { background:var(--theme-accent); }
html[data-theme] .settings-tab.active,html[data-theme] .voucher-config-tab.active {
  border-color:var(--theme-accent); background:color-mix(in srgb,var(--theme-accent) 17%,var(--theme-surface));
  color:var(--theme-ink);
}
html[data-theme] .settings-tab, html[data-theme] .voucher-config-tab, html[data-theme] .btn.secondary,
html[data-theme] .btn.ghost, html[data-theme] .mini-btn, html[data-theme] .menu,
html[data-theme] .scan-item, html[data-theme] .voucher-store-box {
  background:var(--theme-surface); color:var(--theme-ink); border-color:var(--theme-border);
}
html[data-theme] .menu button { color:var(--theme-ink); }
html[data-theme] .menu button:hover { background:var(--theme-surface-2); }
html[data-theme] input,html[data-theme] select,html[data-theme] textarea {
  background:var(--theme-surface); border-color:var(--theme-border); color:var(--theme-ink);
}
html[data-theme] input:focus,html[data-theme] select:focus,html[data-theme] textarea:focus {
  border-color:var(--theme-accent); box-shadow:0 0 0 3px color-mix(in srgb,var(--theme-accent) 17%,transparent);
}
html[data-theme] .week-comparison {
  background:linear-gradient(135deg, var(--theme-surface-2), var(--theme-surface));
  color:var(--theme-ink); border-color:var(--theme-border);
}
html[data-theme] .comparison-metrics>div { background:color-mix(in srgb, var(--theme-accent) 9%, var(--theme-surface));border-color:var(--theme-border); }
html[data-theme] .comparison-metrics span, html[data-theme] .comparison-metrics small,html[data-theme] .week-comparison p { color:var(--theme-muted); }
html[data-theme] .comparison-kicker, html[data-theme] .pos-text { color:var(--theme-positive); }
html[data-theme] .neg-text { color:var(--theme-negative); }
html[data-theme] .axis-text { fill:var(--theme-muted); }
html[data-theme] .modal-card, html[data-theme] .progress-box,html[data-theme] .portal-login-card {
  background:var(--theme-surface); color:var(--theme-ink); border-color:var(--theme-border);
}
html[data-theme] .portal-login-overlay { background:color-mix(in srgb,var(--theme-bg) 85%, #000); }
html[data-theme] .settings-hero,html[data-theme] .settings-section-card { background:var(--theme-surface); }
html[data-theme] .safe-note { border-color:var(--theme-border); }
html[data-theme="dark"] .safe-note { background:color-mix(in srgb,var(--theme-accent) 9%,var(--theme-surface)); color:var(--theme-ink); }
html[data-theme="dark"] .settings-kicker { color:var(--theme-accent); }
html[data-theme="dark"] .portal-stat strong, html[data-theme="dark"] .settings-tab strong { color:var(--theme-ink); }
html[data-theme="dark"] .voucher-current-location,html[data-theme="dark"] .voucher-config-tab {
  background:var(--theme-surface); color:var(--theme-ink); border-color:var(--theme-border);
}
html[data-theme="dark"] .voucher-config-tab small,html[data-theme="dark"] .voucher-store-box label { color:var(--theme-muted); }
html[data-theme] .btn:focus-visible, html[data-theme] button:focus-visible { outline:2px solid var(--theme-accent); outline-offset:2px; }
.portal-theme-toggle {
  display:inline-flex; flex:0 0 auto; align-items:center; justify-content:center; gap:7px;
  border:1px solid var(--theme-border); border-radius:13px; min-height:40px; padding:8px 12px;
  background:var(--theme-surface); color:var(--theme-ink); font-weight:800; font-size:12px;
  box-shadow:0 3px 12px rgba(0,0,0,.055); cursor:pointer;
}
.portal-theme-toggle svg { display:block; width:18px; height:18px; stroke:currentColor; }
.portal-theme-toggle:hover { border-color:var(--theme-accent); }

/* Mobile-specific changes: desktop placement and components stay untouched. */
@media (max-width:760px) {
  html[data-theme] {
    --mobile-text:var(--theme-ink);
    --mobile-muted:var(--theme-muted);
    --mobile-blue:var(--theme-accent);
    --mobile-blue-2:var(--theme-accent-hover);
    --mobile-line:var(--theme-border);
  }
  html[data-theme] body { background:var(--theme-bg); color:var(--theme-ink); }
  html[data-theme="dark"] body {
    background:radial-gradient(circle at 25% 0%, rgba(114,183,176,.085),transparent 35%), var(--theme-bg);
  }
  html[data-theme="light"] body {
    background:radial-gradient(circle at 25% 0%,rgba(154,121,87,.055),transparent 35%), var(--theme-bg);
  }
  .main { padding-bottom:calc(80px + env(safe-area-inset-bottom,0px)); }
  .topbar { align-items:center; gap:8px; }
  .top-actions { align-items:center; gap:6px; }
  .portal-theme-toggle { height:36px; min-height:36px; width:36px; padding:0; border-radius:12px; }
  .portal-theme-toggle svg { width:18px;height:18px; }
  .theme-toggle-text { display:none; }
  html[data-theme] .mobile-header-btn,html[data-theme] .mobile-profile-btn {
    width:36px; height:36px; border-radius:13px;
    background:var(--theme-surface); color:var(--theme-ink); border-color:var(--theme-border);
    box-shadow:0 4px 14px rgba(0,0,0,.06);
  }
  html[data-theme] .mobile-profile-btn { background:var(--theme-accent); color:var(--theme-bg); }
  html[data-theme="light"] .mobile-profile-btn { color:#fff; }
  .mobile-profile-btn span { font-size:17px; }
  .mobile-header-btn span { font-size:16px; }
  h1 { font-size:24px; color:var(--theme-ink); }
  html[data-theme] .mobile-section-tabs .mobile-chip {
    background:var(--theme-surface); border-color:var(--theme-border); color:var(--theme-ink);
  }
  html[data-theme] .mobile-section-tabs .mobile-chip.active {
    background:var(--theme-accent); color:var(--theme-bg); border-color:var(--theme-accent);
  }
  html[data-theme="light"] .mobile-section-tabs .mobile-chip.active { color:#fff; }
  html[data-theme] body .card,html[data-theme] body .kpi,html[data-theme] body .scan-item,
  html[data-theme] body .portal-stat, html[data-theme] body .empty-state,
  html[data-theme] body .voucher-store-box,html[data-theme] body .voucher-current-location,
  html[data-theme] body .modal-card {
    background:var(--theme-surface); border-color:var(--theme-border); color:var(--theme-ink);
    box-shadow:0 7px 24px rgba(0,0,0,.055),inset 0 1px 0 rgba(255,255,255,.02);
  }
  html[data-theme] .card-head h2,html[data-theme] .kpi .value,html[data-theme] .cell-main,
  html[data-theme] .bar-meta strong, html[data-theme] th, html[data-theme] td,
  html[data-theme] .portal-stat strong { color:var(--theme-ink); }
  html[data-theme] .card-head p,html[data-theme] .kpi .label,html[data-theme] .kpi .hint,
  html[data-theme] .range-summary,html[data-theme] .axis-text,html[data-theme] .cell-sub,
  html[data-theme] .bar-meta { color:var(--theme-muted); }
  html[data-theme] .btn.secondary,html[data-theme] .btn.ghost,
  html[data-theme] .mini-btn,html[data-theme] .voucher-config-tab,html[data-theme] .settings-tab {
    background:var(--theme-surface); color:var(--theme-ink); border-color:var(--theme-border);
  }
  html[data-theme] input,html[data-theme] select,html[data-theme] textarea {
    background:var(--theme-surface); color:var(--theme-ink); border-color:var(--theme-border);
  }
  html[data-theme] .grid-line { stroke:var(--theme-border); }
  html[data-theme] .line-path { stroke:var(--theme-chart-line);fill:none; }
  html[data-theme] .dot { fill:var(--theme-chart-line); }
  html[data-theme] .bar { fill:var(--theme-chart-line); }
  html[data-theme] .bar-track { background:var(--theme-surface-2); }

  /* ~half-height five-button dock. The single glass capsule slides to the active tab. */
  html[data-theme] .mobile-bottom-nav {
    left:8px; right:8px; bottom:calc(5px + env(safe-area-inset-bottom,0px));
    height:60px; min-height:60px; padding:4px 5px; gap:1px;
    border-radius:20px; background:color-mix(in srgb,var(--theme-surface) 86%,transparent);
    border:1px solid var(--theme-border); box-shadow:0 14px 34px rgba(0,0,0,.16),inset 0 1px rgba(255,255,255,.08);
  }
  html[data-theme] .mobile-bottom-nav-glow {
    top:3px;bottom:3px;border-radius:16px;
    background:linear-gradient(115deg,color-mix(in srgb,var(--theme-accent) 24%,var(--theme-surface)),color-mix(in srgb,var(--theme-accent) 9%,var(--theme-surface)));
    border:1px solid color-mix(in srgb,var(--theme-accent) 65%,transparent);
    box-shadow:0 0 0 1px rgba(255,255,255,.12) inset,0 0 16px color-mix(in srgb,var(--theme-accent) 23%,transparent),0 4px 12px rgba(0,0,0,.12);
  }
  html[data-theme] .mobile-bottom-nav-glow::after {
    background:radial-gradient(ellipse at 20% 2%,rgba(255,255,255,.65),transparent 64%); opacity:.38;
  }
  html[data-theme] .mobile-nav-btn {
    min-height:50px; height:50px; padding:5px 1px 4px; gap:3px;
    border-radius:15px; color:var(--theme-muted);
  }
  html[data-theme] .mobile-nav-btn.active { color:var(--theme-accent); }
  html[data-theme] .mobile-nav-btn .mobile-nav-icon { display:grid; place-items:center; height:19px; line-height:1; }
  .mobile-nav-icon svg { display:block; width:19px;height:19px; }
  .mobile-nav-label { font-size:9.5px;line-height:1.1;font-weight:750; white-space:nowrap;max-width:100%; }
  .mobile-nav-location .mobile-nav-label { max-width:calc(100% - 13px); }
  .mobile-nav-caret { position:absolute;right:1px;bottom:7px;font-size:9px;margin:0; color:var(--theme-muted); }
  html[data-theme] .mobile-location-menu { bottom:59px; background:var(--theme-surface);border-color:var(--theme-border);color:var(--theme-ink); }
  html[data-theme] .mobile-location-menu button { color:var(--theme-ink); }
  html[data-theme] .mobile-location-menu button small { color:var(--theme-muted); }
  html[data-theme] .mobile-location-menu button.active, html[data-theme] .mobile-location-menu button:hover { background:var(--theme-surface-2); }
  html[data-theme] .mobile-profile-menu { background:var(--theme-surface);color:var(--theme-ink);border-color:var(--theme-border); }
  html[data-theme] .mobile-profile-menu button { color:var(--theme-ink); }
  html[data-theme] .mobile-profile-menu button:hover { background:var(--theme-surface-2); }
  html[data-theme] .mobile-profile-head small { color:var(--theme-muted); }
  html[data-theme] .toast { bottom:calc(76px + env(safe-area-inset-bottom,0px)); background:var(--theme-surface);color:var(--theme-ink);border:1px solid var(--theme-border); }

  /* This compact two-column arrangement applies to phone Dashboard only. */
  #view-overview #kpis {
    display:grid; grid-template-columns:repeat(2,minmax(0,1fr)) !important;
    align-items:stretch; gap:10px; margin-bottom:12px;
  }
  #view-overview #kpis .kpi { min-width:0;min-height:112px;padding:12px 11px;border-radius:15px; }
  #view-overview #kpis .kpi:nth-child(1) { order:1; }
  #view-overview #kpis .kpi:nth-child(2) { order:2; }
  #view-overview #kpis .kpi:nth-child(3) { order:3; }
  #view-overview #kpis .kpi:nth-child(4) { order:5; }
  #view-overview #kpis .kpi:nth-child(5) { order:4; }
  #view-overview #kpis .kpi:nth-child(6) { order:6; }
  #view-overview #kpis .kpi .label { font-size:11px;line-height:1.2;font-weight:700; }
  #view-overview #kpis .kpi .value { font-size:21px;line-height:1.12; margin-top:9px; overflow-wrap:anywhere; }
  #view-overview #kpis .kpi .compare { font-size:9px;margin-top:8px;padding:3px 5px; }
  #view-overview #kpis .kpi .hint { font-size:9px;line-height:1.3; margin-top:5px; }
  #view-overview #overviewSalesSourceStatus, #view-overview #weekComparisonSummary { display:none; }
  .mobile-week-chart {
    display:block; padding:17px 14px 12px;margin:0 0 16px;border-radius:16px;
  }
  .mobile-week-chart-top { display:flex;align-items:flex-start;justify-content:space-between;gap:9px; }
  .mobile-chart-eyebrow { display:block;font-size:9px;letter-spacing:.08em;color:var(--theme-muted);font-weight:850; }
  .mobile-week-chart-top h2 { font-size:15px;margin:5px 0 0;color:var(--theme-ink);line-height:1.25; }
  .mobile-week-delta { flex-shrink:0;font-size:12px;font-weight:850;padding:6px 7px;border-radius:9px;background:var(--theme-surface-2);color:var(--theme-ink); }
  .mobile-week-delta.positive { color:var(--theme-positive); }
  .mobile-week-delta.negative { color:var(--theme-negative); }
  .mobile-week-chart-graph { margin-top:10px;min-height:160px; }
  .mobile-week-chart-graph svg { display:block;width:100%;height:auto;overflow:visible; }
  .mobile-week-chart-graph p { color:var(--theme-muted);font-size:12px; }
  .mobile-week-chart-graph text { font-size:10px;fill:var(--theme-muted);font-family:inherit; }
  .mobile-week-chart-graph .week-grid { stroke:var(--theme-border);stroke-width:1;stroke-dasharray:3 5; }
  .mobile-week-chart-graph .current-line { stroke:var(--theme-chart-line);stroke-width:3;stroke-linecap:round;stroke-linejoin:round;fill:none; }
  .mobile-week-chart-graph .previous-line { stroke:var(--theme-chart-muted);stroke-width:2;stroke-dasharray:5 5;stroke-linecap:round;stroke-linejoin:round;fill:none;opacity:.82; }
  .mobile-week-chart-graph .week-dot { fill:var(--theme-chart-line);stroke:var(--theme-surface);stroke-width:1.5; }
  .mobile-week-chart-legend { display:flex;flex-wrap:wrap;justify-content:center;gap:18px;color:var(--theme-muted);font-size:9px;font-weight:700; }
  .mobile-week-chart-legend span { display:flex;align-items:center;gap:5px; }
  .mobile-week-chart-legend i {width:14px;height:0;border-top:2px solid var(--theme-chart-line);display:block;}
  .mobile-week-chart-legend .legend-previous { border-color:var(--theme-chart-muted);border-top-style:dashed; }

  /* On phone, the main dashboard keeps the default This Week, with details one tap away. */
  #salesDateFilters.mobile-dashboard-filters {
    display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;
    align-items:end; padding:11px 12px;margin-bottom:15px;
  }
  #salesDateFilters.mobile-dashboard-filters .mobile-period-caption {
    grid-column:1 / -1;display:block;margin:0;color:var(--theme-muted);font-size:10px;font-weight:800;
  }
  #salesDateFilters.mobile-dashboard-filters .period-group {grid-column:1;grid-row:2;min-width:0;}
  #salesDateFilters.mobile-dashboard-filters .period-group label {display:none;}
  #salesDateFilters.mobile-dashboard-filters .period-group select { min-width:0; width:100%;min-height:37px;font-size:12px; }
  #salesDateFilters.mobile-dashboard-filters .mobile-dates-expand {
    display:flex;align-items:center;justify-content:center;gap:7px;
    grid-column:2;grid-row:2;min-height:37px;padding:7px 10px;
    border-radius:10px;border:1px solid var(--theme-border);
    background:var(--theme-surface-2);color:var(--theme-ink);font-size:11px;font-weight:800;
  }
  #salesDateFilters.mobile-dashboard-filters:not(.expanded) > .filter-group:not(.period-group),
  #salesDateFilters.mobile-dashboard-filters:not(.expanded) > #applyBtn,
  #salesDateFilters.mobile-dashboard-filters:not(.expanded) > #latestWeekBtn,
  #salesDateFilters.mobile-dashboard-filters:not(.expanded) > #rangeSummary,
  #salesDateFilters.mobile-dashboard-filters:not(.expanded) > .filter-spacer { display:none!important; }
  #salesDateFilters.mobile-dashboard-filters.expanded > .filter-group:not(.period-group) {grid-column:1 / -1;}
  #salesDateFilters.mobile-dashboard-filters.expanded > #rangeSummary {grid-column:1 / -1;font-size:11px;}
  #salesDateFilters.mobile-dashboard-filters.expanded > #applyBtn {grid-column:1;}
  #salesDateFilters.mobile-dashboard-filters.expanded > #latestWeekBtn {grid-column:2;white-space:nowrap;font-size:11px;}
  #salesDateFilters.mobile-dashboard-filters.expanded .mobile-dates-expand span { transform:rotate(180deg); }
  #salesDateFilters:not(.mobile-dashboard-filters) .mobile-dates-expand,
  #salesDateFilters:not(.mobile-dashboard-filters) .mobile-period-caption { display:none!important; }

  /* Entering Online Vouchers from the Vouchers chip does not expose other Settings navigation. */
  body.mobile-online-vouchers #view-settings .settings-nav {display:none!important;}
  body.mobile-online-vouchers #view-settings .settings-shell {display:block;grid-template-columns:minmax(0,1fr)!important;}
  body.mobile-online-vouchers #view-settings .settings-content {width:100%;min-width:0;}
}
.mobile-week-chart {display:block;}
@media(min-width:761px){
  .mobile-week-chart{
    margin-bottom:16px;
  }
  .mobile-week-chart-graph{
    min-height:190px;
  }
}
@media(max-width:360px){
  .mobile-nav-icon svg{width:17px;height:17px}
  .mobile-nav-label{font-size:8.5px}
  #view-overview #kpis .kpi{padding:10px 9px}
  #view-overview #kpis .kpi .value{font-size:19px}
}
@media(prefers-reduced-motion:reduce){
  html[data-theme] body,.mobile-nav-btn,.portal-theme-toggle{transition:none!important}
  .mobile-bottom-nav-glow{transition:none!important}
}

/* Shared theme finishing touches for desktop header, settings details, and notices. */
html[data-theme] .portal-user-chip,
html[data-theme] .top-location-menu,
html[data-theme] .settings-detail-grid,
html[data-theme] .portal-security-note,
html[data-theme] .portal-permission-section,
html[data-theme] .portal-group-checks {
  background:var(--theme-surface); color:var(--theme-ink); border-color:var(--theme-border);
}
html[data-theme] .portal-user-chip strong,
html[data-theme] .top-location-single,
html[data-theme] .top-location-button { color:var(--theme-ink); }
html[data-theme] .top-location-placeholder,
html[data-theme] .portal-user-chip small,
html[data-theme] .portal-access-summary,
html[data-theme] .portal-role-help { color:var(--theme-muted); }
html[data-theme] .top-location-button:hover { color:var(--theme-accent-hover); }
html[data-theme] .badge { background:var(--theme-surface-2); color:var(--theme-accent-hover); }
html[data-theme] .portal-status { background:var(--theme-surface-2); color:var(--theme-muted); }
html[data-theme] .portal-status.online,
html[data-theme] .portal-status.active { color:var(--theme-positive); }
html[data-theme] .portal-status.offline,
html[data-theme] .portal-status.disabled { color:var(--theme-negative); }
html[data-theme] .settings-detail-grid span { color:var(--theme-muted); }
html[data-theme] .settings-detail-grid strong { color:var(--theme-ink); }
