:root {
  --purple-900: #382a27;
  --purple-800: #5a3f38;
  --purple-700: #6c4d44;
  --purple-600: #666a8f;
  --purple-500: #638b8b;
  --purple-200: #d8ccca;
  --purple-100: #eee7e4;
  --purple-050: #fbf8f4;
  --pink: #682628;
  --pink-soft: #f2e2df;
  --green: #4e7474;
  --green-soft: #e5eeee;
  --amber: #8b5d32;
  --amber-soft: #f7eadb;
  --red: #a13d47;
  --ink: #383637;
  --muted: #706a68;
  --line: #e4dbd4;
  --surface: #fffdfa;
  --canvas: #fffbf5;
  --season-white: #ffffff;
  --season-lavender: #666a8f;
  --season-brown: #5a3f38;
  --season-blue-gray: #a7b1bb;
  --season-pink: #d3a29e;
  --season-wine: #682628;
  --season-green: #638b8b;
  --season-charcoal: #383637;
  --nav-brown: #382a27;
  --nav-cream: #fff8ef;
  --dashboard-hero-bg: #fbe9e1;
  --dashboard-sales-bg: #fffbf5;
  --font-rounded: "GenSenRounded TW", "GenSenRounded", ui-rounded, "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  --shadow: 0 16px 42px rgba(73, 54, 47, 0.09);
  --shadow-hover: 0 20px 52px rgba(73, 54, 47, 0.14);
  --radius: 24px;
  --radius-sm: 15px;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(145deg, #fffbf5 0%, #fffbf5 68%, #fbe9e1 140%);
  font-family: var(--font-rounded);
  font-weight: 400;
  font-size: 15px;
  line-height: 1.55;
}
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(99, 139, 139, .34);
  outline-offset: 3px;
}
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-size: clamp(28px, 3vw, 38px); font-weight: 900; line-height: 1.2; letter-spacing: -0.03em; }
h2 { margin-bottom: 4px; font-size: 19px; font-weight: 900; line-height: 1.35; }
small { color: var(--muted); }
.site-title { display: inline-grid; min-width: 0; vertical-align: top; }
.site-title > span { display: block; white-space: nowrap; word-break: keep-all; }

.app-shell {
  min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr);
  transition: grid-template-columns .22s ease;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  color: var(--ink);
  background: #fffbf5;
  border-right: 1px solid rgba(90,62,58,.08);
  border-radius: 0 30px 30px 0;
  box-shadow: 4px 0 20px rgba(90,62,58,.06);
  display: flex;
  flex-direction: column;
  z-index: 5;
  transition: padding .22s ease, width .22s ease, transform .22s ease;
}
.brand { position: relative; display: grid; justify-items: center; gap: 11px; padding: 0 8px 24px; text-align: center; }
.brand-logo {
  display: block; width: 100%; max-width: 184px; height: auto;
  border-radius: 15px;
}
.brand-title { color: #383637; font-size: 13px; font-weight: 700; letter-spacing: .04em; }
.sidebar-toggle, .sidebar-close {
  border: 1px solid rgba(90,62,58,.14); border-radius: 999px;
  color: #383637; background: #f5efe9; font-weight: 700;
}
.sidebar-toggle {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 36px; padding: 7px 11px;
}
.sidebar-toggle:hover, .sidebar-close:hover { background: #fbe9e1; }
.sidebar-toggle-icon { font-size: 22px; line-height: .8; transition: transform .22s ease; }
.sidebar-close { display: none; padding: 7px 12px; }
.nav-list { display: grid; align-content: start; flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0 12px; }
.nav-item {
  position: relative; width: 100%; border: 0; border-radius: 0; padding: 32px 0;
  color: #383637; background: transparent;
  display: flex; align-items: center; gap: 11px; text-align: left; font-weight: 700;
  transition: color .18s ease;
}
.nav-item::after {
  content: ""; position: absolute; left: 39px; right: 0; bottom: 20px;
  height: 2px; border-radius: 999px; background: transparent;
}
.nav-symbol {
  width: 28px; height: auto; display: block;
  flex: 0 0 28px; border: 0; border-radius: 0; color: #a7b1bd; font-size: 10px; font-weight: 700;
}
.nav-item:hover { color: var(--season-wine); }
.nav-item.active { color: #383637; background: transparent; }
.nav-item.active::after { background: #d3a29e; }
.nav-item.active .nav-symbol { color: #a7b1bd; background: transparent; }
.nav-divider {
  display: block; margin: 12px 12px 2px; color: rgba(255,255,255,.52);
  font-size: 10px; font-weight: 800; letter-spacing: .14em;
}
.hq-nav { color: rgba(255,255,255,.92); }
.sidebar-note {
  margin-top: auto; padding: 16px; border-radius: 18px;
  background: #f5efe9; border: 1px solid rgba(90,62,58,.08);
}
.sidebar-note span, .sidebar-note small { display: block; color: var(--muted); font-size: 11px; }
.sidebar-note strong { display: block; margin: 4px 0; color: #383637; font-size: 14px; }
.sidebar-overlay { display: none; }
.app-shell.sidebar-collapsed { grid-template-columns: 88px minmax(0, 1fr); }
.sidebar-collapsed .sidebar { padding-inline: 13px; }
.sidebar-collapsed .brand { justify-items: center; padding-inline: 0; }
.sidebar-collapsed .brand-logo { width: 58px; }
.sidebar-collapsed .brand-title, .sidebar-collapsed .nav-label, .sidebar-collapsed .sidebar-note, .sidebar-collapsed .sidebar-toggle-label { display: none; }
.sidebar-collapsed .sidebar-toggle { width: 40px; min-width: 40px; padding-inline: 0; }
.sidebar-collapsed .sidebar-toggle-icon { transform: rotate(180deg); }
.sidebar-collapsed .nav-list { padding-inline: 8px; }
.sidebar-collapsed .nav-item { justify-content: center; padding: 24px 0; }
.sidebar-collapsed .nav-item::after { left: 10px; right: 10px; bottom: 14px; }

.main-content { min-width: 0; }
.topbar {
  min-height: 76px; padding: 10px 34px; display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); background: rgba(255,253,250,.88); border-bottom: 1px solid rgba(90,63,56,.10);
  position: sticky; top: 0; z-index: 4; backdrop-filter: blur(16px);
}
.store-context { display: flex; align-items: center; gap: 10px; }
.store-context label { color: var(--muted); font-size: 12px; }
.store-context select {
  appearance: none; min-width: 112px; padding: 8px 32px 8px 12px; border: 1px solid var(--line);
  border-radius: 999px; color: var(--purple-800); background: var(--purple-050);
  font-weight: 800;
}
.campaign-tag, .prototype-badge, .account-role, .confidential, .low-stock-label {
  display: inline-flex; align-items: center; white-space: nowrap;
  padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 800;
}
.campaign-tag, .prototype-badge { color: var(--purple-700); background: var(--purple-100); }
.account { display: flex; align-items: center; gap: 12px; text-align: right; }
.account strong, .account span { display: block; }
.account > div span { color: var(--muted); font-size: 11px; }
.account-role { color: var(--green); background: var(--green-soft); }
.mobile-menu { display: none; }

.view { display: none; padding: 30px 34px 60px; max-width: 1500px; margin: 0 auto; }
.view.active { display: block; }
#dashboardView { overflow: visible; background: var(--dashboard-sales-bg); }
.dashboard-hero-zone {
  margin: -30px -34px 0; padding: 30px 34px 20px;
  background: linear-gradient(135deg, #fffbf5 0%, #fbe9e1 100%);
}
.dashboard-wave-divider {
  height: 72px; margin: 0 -34px; overflow: hidden;
  background: var(--dashboard-hero-bg); pointer-events: none;
}
.dashboard-wave-divider svg { display: block; width: 100%; height: 100%; }
.dashboard-wave-divider path { fill: var(--dashboard-sales-bg); }
.dashboard-sales-zone {
  margin: 0 -34px -60px; padding: 10px 34px 60px;
  border-radius: 24px 24px 0 0; background: var(--dashboard-sales-bg);
  box-shadow: 0 4px 20px rgba(90,62,58,.06);
}
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.eyebrow { margin-bottom: 5px; color: var(--pink); font-size: 12px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.subcopy, .section-heading p, .panel-heading p { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.heading-actions { display: flex; align-items: center; gap: 10px; }
.season-hero {
  position: relative; isolation: isolate; overflow: hidden; width: 100%; max-width: 1040px; margin: 0 auto;
  border: 1px solid rgba(90,63,56,.08); border-radius: 24px;
  background: linear-gradient(135deg, #fffbf5 0%, #fbe9e1 100%);
  box-shadow: 0 4px 20px rgba(90,62,58,.06);
}
.season-carousel-stage {
  position: relative; width: 100%; height: auto; aspect-ratio: 16 / 8.2; overflow: hidden;
  background: linear-gradient(135deg, #fffbf5 0%, #fbe9e1 100%); touch-action: pan-y;
}
.season-slide {
  position: absolute; inset: 0; z-index: 0; margin: 0;
  background: transparent; opacity: 0; transition: opacity 400ms ease;
}
.season-slide.is-active { z-index: 1; opacity: 1; }
.season-slide[hidden] { display: none; }
.season-slide > img {
  display: block; width: 100%; height: 100%; object-fit: contain;
  object-position: center; background: transparent;
}
.season-slide--wide, .season-slide--portrait { background: transparent; }
.season-slide--pair {
  display: flex; align-items: stretch; justify-content: center; gap: 10px; padding: 0 10px;
}
.season-slide--pair > img {
  width: auto; max-width: calc(50% - 5px); height: 100%; object-fit: contain;
}
.season-carousel-controls {
  position: relative; z-index: 3; min-height: 52px; display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 7px 18px; color: #383637; background: #f5efe9;
  border-top: 1px solid rgba(90,62,58,.07);
}
.carousel-button {
  min-width: 36px; min-height: 36px; border: 1px solid rgba(90,62,58,.12); border-radius: 50%;
  color: #5a3f38; background: rgba(255,255,255,.58); font-weight: 700;
}
.carousel-button { font-size: 25px; line-height: 1; }
.carousel-button:hover { background: rgba(255,255,255,.90); }
.carousel-dots { display: flex; align-items: center; gap: 8px; }
.carousel-dot {
  width: 9px; height: 9px; padding: 0; border: 1px solid #d3a29e; border-radius: 999px;
  background: transparent; transition: width .2s ease, background .2s ease;
}
.carousel-dot.is-active { width: 24px; background: #d3a29e; }
.carousel-count { min-width: 38px; color: #706a68; text-align: center; font-size: 11px; font-variant-numeric: tabular-nums; }
.carousel-pause {
  min-height: 36px; padding: 6px 12px; border: 1px solid rgba(90,62,58,.12); border-radius: 999px;
  color: #5a3f38; background: rgba(255,255,255,.58); font-size: 11px; font-weight: 700;
}
.carousel-pause:hover { background: rgba(255,255,255,.90); }
.season-hero button:focus-visible { outline-color: rgba(90,63,56,.42); }
.data-recency {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px;
}
.data-recency > div {
  padding: 12px 15px; border: 1px solid var(--line); border-radius: 17px;
  background: var(--surface); box-shadow: 0 8px 24px rgba(73,54,47,.04);
}
.data-recency span, .data-recency strong { display: block; }
.data-recency span { color: var(--muted); font-size: 10px; }
.data-recency strong { margin-top: 3px; color: var(--purple-800); font-size: 13px; }
.dashboard-alerts { display: grid; gap: 7px; margin-bottom: 16px; }
.dashboard-alerts p {
  margin: 0; padding: 10px 13px; border-left: 4px solid var(--amber); border-radius: 14px;
  color: #7a4b0d; background: var(--amber-soft); font-size: 12px;
}
.dashboard-alerts p::before { content: "！"; margin-right: 6px; font-weight: 900; }
.dashboard-alerts p.success { border-left-color: var(--green); color: var(--green); background: var(--green-soft); }
.dashboard-alerts p.success::before { content: "✓"; }

.button {
  border: 0; border-radius: 999px; padding: 10px 18px; font-weight: 800;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.button:hover { transform: translateY(-2px); }
.button:active { transform: translateY(0) scale(.985); }
.button.primary { color: white; background: var(--purple-800); box-shadow: 0 9px 22px rgba(90,63,56,.22); }
.button.secondary { color: var(--purple-700); background: var(--purple-100); }
.button.light { color: var(--purple-800); background: white; box-shadow: inset 0 0 0 1px var(--line); }
.button.full { width: 100%; }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.text-button { border: 0; color: var(--purple-700); background: transparent; font-weight: 800; }

.goal-card {
  display: grid; grid-template-columns: minmax(190px, .65fr) minmax(280px, 1.3fr) auto;
  align-items: center; gap: 28px; margin-bottom: 30px; padding: 22px 24px;
  color: white; background: linear-gradient(118deg, var(--purple-900), var(--purple-800) 66%, var(--pink));
  border-radius: 27px; box-shadow: 0 18px 42px rgba(73,54,47,.19);
}
.goal-card span, .goal-card small { color: rgba(255,255,255,.74); }
.goal-card > div:first-child strong { display: block; margin: 3px 0; font-size: 27px; }
.goal-label { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.goal-label strong { font-size: 24px; }
.progress-track { height: 10px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.18); }
.progress-fill { height: 100%; border-radius: inherit; background: white; transition: width .4s ease; }
.progress-scale { display: flex; justify-content: space-between; margin-top: 5px; font-size: 10px; color: rgba(255,255,255,.55); }

.section-heading, .panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-heading { margin: 28px 0 14px; }
.date-tabs { display: flex; flex-wrap: wrap; padding: 4px; border-radius: 999px; background: var(--purple-100); }
.date-tab { border: 0; border-radius: 999px; padding: 7px 12px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 800; }
.date-tab.active { color: white; background: var(--purple-800); }

.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); gap: 12px; }
.kpi-card {
  min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 21px;
  background: var(--surface); box-shadow: 0 9px 25px rgba(73,54,47,.045);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.kpi-card:hover { transform: translateY(-3px); border-color: rgba(99,139,139,.34); box-shadow: var(--shadow-hover); }
.kpi-card.featured { border-color: rgba(90,63,56,.22); background: linear-gradient(135deg, #fff, #f3ece7); }
.kpi-card span { display: block; color: var(--muted); font-size: 12px; }
.kpi-card strong { display: block; margin: 5px 0 2px; font-size: clamp(19px, 2.1vw, 27px); line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-card small { display: block; font-size: 10px; }
.category-summary { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-top: 12px; }
.category-item { padding: 13px 15px; border: 1px solid rgba(90,63,56,.08); border-radius: 17px; background: var(--purple-100); }
.category-item.excluded { background: #f2eff2; }
.category-item.gift { background: var(--pink-soft); }
.category-item span, .category-item small { display: block; color: var(--muted); font-size: 10px; }
.category-item strong { display: block; margin: 3px 0; color: var(--purple-800); font-size: 15px; }

.dashboard-grid { display: grid; gap: 16px; margin-top: 16px; }
.dashboard-grid.two-thirds { grid-template-columns: minmax(0, 1.75fr) minmax(280px, .75fr); }
.dashboard-grid.equal { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel {
  min-width: 0; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
  transition: transform .2s ease, box-shadow .2s ease;
}
#dashboardView .panel:hover, #uploadView .upload-layout > .panel:hover { box-shadow: var(--shadow-hover); }
.panel-heading { margin-bottom: 18px; }
.legend { color: var(--muted); font-size: 11px; }
.legend i { display: inline-block; width: 9px; height: 9px; margin-right: 5px; border-radius: 3px; background: var(--purple-600); }
.scope-summary { margin-top: 16px; }
.scope-summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.scope-summary-grid > div { padding: 12px 14px; border-left: 3px solid var(--purple-200); background: var(--purple-050); }
.scope-summary-grid span, .scope-summary-grid small { display: block; color: var(--muted); font-size: 10px; }
.scope-summary-grid strong { display: block; margin-top: 4px; color: var(--purple-800); font-size: 16px; font-variant-numeric: tabular-nums; }
.scope-summary-grid .reconciliation-pending { border-left-color: var(--amber); background: var(--amber-soft); }
.selling-dates-panel { margin-bottom: 24px; }
.selling-date-entry { display: grid; grid-template-columns: minmax(180px, 280px) auto; align-items: end; gap: 12px; }
.selling-dates-panel table { margin-top: 12px; }
.selling-dates-panel .check-label { font-weight: 700; }
.selling-dates-panel .status-message.warning { color: var(--amber); }
.chart { display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; gap: 18px; height: 166px; margin-bottom: 22px; padding: 12px 20px 9px; border-bottom: 1px solid var(--line); }
.chart-column { height: 100%; display: flex; flex-direction: column; justify-content: end; align-items: center; gap: 7px; }
.chart-value { color: var(--purple-700); font-size: 11px; font-weight: 800; }
.chart-bar { width: min(74px, 75%); min-height: 8px; border-radius: 14px 14px 4px 4px; background: linear-gradient(180deg, var(--season-pink), var(--season-brown)); transition: height .35s ease; }
.chart-date { color: var(--muted); font-size: 11px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 12px 9px; color: var(--muted); background: rgba(167,177,187,.10); text-align: left; font-weight: 800; white-space: nowrap; }
td { padding: 12px 9px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr { transition: background .16s ease; }
tbody tr:hover { background: rgba(99,139,139,.055); }
.number { text-align: right; font-variant-numeric: tabular-nums; }

.payment-list { display: grid; gap: 15px; }
.payment-row { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; }
.payment-row .payment-symbol {
  width: 32px; height: 32px; display: grid; place-items: center; padding: 0;
  border-radius: 11px; color: var(--purple-800); background: rgba(102,106,143,.12);
}
.payment-row .payment-symbol svg {
  display: block; margin: auto;
  width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.payment-row span { display: block; color: var(--muted); font-size: 11px; }
.payment-row strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.payment-total { display: flex; justify-content: space-between; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.payment-total strong { color: var(--purple-800); font-size: 19px; }
.panel-note { margin: 12px 0 0; padding: 11px 13px; border-radius: 14px; color: var(--amber); background: var(--amber-soft); font-size: 11px; }

.ranking-list { display: grid; gap: 13px; }
.rank-row { display: grid; grid-template-columns: 25px minmax(130px, 1fr) auto; align-items: center; gap: 10px; }
.rank-number { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 9px; color: var(--purple-800); background: var(--purple-100); font-size: 11px; font-weight: 900; }
.rank-name { min-width: 0; }
.rank-name strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.rank-track { height: 5px; margin-top: 5px; border-radius: 99px; background: var(--purple-100); }
.rank-fill { height: 100%; border-radius: inherit; background: var(--purple-600); }
.rank-value { text-align: right; }
.rank-value strong { display: block; font-size: 13px; }
.rank-value span { color: var(--muted); font-size: 10px; }
.low-stock-label { color: var(--amber); background: var(--amber-soft); }
.ranking-controls {
  display: grid; grid-template-columns: repeat(3, minmax(130px, 190px)) minmax(220px, 1fr) auto;
  align-items: end; gap: 12px; margin-top: 16px; padding: 15px 17px;
}
.ranking-controls p { margin: 0; color: var(--muted); font-size: 11px; }
.ranking-zero-filter { display: flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 700; }
.ranking-zero-filter input { width: 18px; height: 18px; accent-color: var(--purple-700); }
.ranking-zero-filter small { display: block; max-width: 220px; font-weight: 400; }
.ranking-help { justify-self: end; }
.ranking-limit { display: flex; grid-auto-flow: column; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; }
.ranking-limit select { width: auto; min-width: 76px; padding: 6px 24px 6px 8px; font-size: 11px; }

.margin-panel { margin-top: 16px; background: linear-gradient(135deg, white 45%, var(--purple-050)); }
.confidential { color: var(--pink); background: var(--pink-soft); }
.margin-grid, .inventory-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.margin-grid > div, .inventory-summary > div { padding: 15px; border-left: 3px solid var(--purple-200); background: rgba(255,255,255,.68); }
.margin-grid span, .inventory-summary span { display: block; color: var(--muted); font-size: 11px; }
.margin-grid strong, .inventory-summary strong { display: block; margin: 4px 0; color: var(--purple-800); font-size: 18px; }
.margin-grid small, .inventory-summary small { display: block; font-size: 10px; }
.margin-grid .effective-margin { border-left-color: var(--pink); }

.workflow-steps { display: flex; align-items: center; max-width: 720px; margin: 0 auto 24px; }
.workflow-step { display: flex; align-items: center; gap: 8px; color: var(--muted); white-space: nowrap; }
.workflow-step span { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--line); font-size: 11px; font-weight: 900; }
.workflow-step.active { color: var(--purple-700); }
.workflow-step.active span { color: white; background: var(--purple-700); }
.workflow-line { flex: 1; height: 1px; margin: 0 14px; background: var(--purple-200); }
.workflow-guides {
  display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 14px; margin-bottom: 20px;
}
.workflow-guides.single { grid-template-columns: 1fr; }
.workflow-guides.single .workflow-guide ol { justify-content: space-between; }
.workflow-guide {
  padding: 20px; border: 1px solid rgba(90,63,56,.16); border-radius: 24px;
  background: linear-gradient(135deg, var(--surface), #f4ece8);
}
.workflow-guide h2 { margin-bottom: 12px; color: var(--purple-800); font-size: 16px; }
.workflow-guide ol { display: flex; flex-wrap: wrap; gap: 10px 18px; margin: 0; padding: 0; list-style: none; }
.workflow-guide li {
  display: flex; align-items: center; gap: 8px; min-width: 0; padding: 8px 13px;
  border-radius: 999px; color: var(--ink); background: rgba(255,255,255,.72); font-size: 12px;
}
.workflow-guide li span {
  flex: 0 0 26px; width: 26px; height: 26px; display: grid; place-items: center;
  border-radius: 50%; color: white; background: var(--purple-800); font-size: 11px; font-weight: 900;
}
.upload-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(270px, .65fr); gap: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
label { display: grid; gap: 6px; color: var(--ink); font-size: 12px; font-weight: 800; }
input, select, textarea {
  width: 100%; border: 1px solid #d8cec7; border-radius: 14px; padding: 10px 12px;
  color: var(--ink); background: white; font-weight: 500;
}
textarea { resize: vertical; }
.drop-zone {
  min-height: 230px; margin: 18px 0; padding: 30px; place-items: center; align-content: center;
  border: 2px dashed rgba(99,139,139,.42); border-radius: 24px; color: var(--purple-800);
  background: linear-gradient(145deg, rgba(99,139,139,.08), rgba(211,162,158,.10)); text-align: center; cursor: pointer;
}
.drop-zone.dragging { border-color: var(--pink); background: var(--pink-soft); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.drop-zone strong, .drop-zone small { display: block; }
.drop-symbol {
  width: 58px; height: 58px; display: grid; place-items: center; border-radius: 19px;
  color: white; background: linear-gradient(135deg, var(--season-brown), var(--season-wine));
  font-size: 12px; font-weight: 900; box-shadow: 0 12px 24px rgba(90,63,56,.18);
}
.password-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 12px; }
.security-note { display: flex; gap: 9px; margin-top: 14px; padding: 11px 13px; border-radius: 12px; color: var(--green); background: var(--green-soft); font-size: 11px; }
.status-message { margin: 13px 0 0; color: var(--muted); font-size: 12px; }
.status-message.error { color: var(--red); }
.status-message.error::before { content: "✕ "; font-weight: 900; }
.status-message.success { color: var(--green); }
.status-message.success::before { content: "✓ "; font-weight: 900; }
.import-summary dl { margin: 0; }
.import-summary dl div { display: flex; justify-content: space-between; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.import-summary dt { color: var(--muted); }
.import-summary dd { margin: 0; text-align: right; font-weight: 800; }
.import-summary .button { margin-top: 20px; }

.input-table input { min-width: 100px; padding: 8px; }
.input-table input[type="number"] { text-align: right; }
.inventory-count-save { display: block; margin-top: 7px; white-space: nowrap; }
#inventoryTable td > small { display: block; min-width: 190px; margin-top: 6px; }
#inventoryTable input[type="datetime-local"] { min-width: 176px; }
#inventoryTable [data-field="count-difference"] { display: block; min-width: 110px; color: var(--muted); font-size: 11px; }
[aria-invalid="true"] { border-color: var(--red); background: #fff4f5; }
.save-status { margin: 14px 0 0; color: var(--muted); font-size: 12px; }
.save-status.success { color: var(--green); }
.inventory-summary { grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 16px; }
.inventory-summary > div { border: 1px solid var(--line); border-left: 4px solid var(--purple-500); border-radius: 15px; background: white; box-shadow: var(--shadow); }
.eligibility { display: inline-flex; padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; }
.eligibility.yes { color: var(--green); background: var(--green-soft); }
.eligibility.no { color: var(--red); background: #fae9eb; }
.settings-grid { display: grid; grid-template-columns: minmax(280px, .65fr) minmax(0, 1.35fr); gap: 18px; }
.settings-grid .panel:first-child { display: grid; align-content: start; gap: 15px; }
.product-list { display: grid; gap: 9px; }
.product-row { display: grid; grid-template-columns: minmax(200px, 1fr) 88px 120px 78px; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.product-row:first-child { border-top: 0; }
.product-title strong, .product-title span { display: block; }
.product-title span { color: var(--muted); font-size: 10px; }
.check-label { display: flex; align-items: center; gap: 6px; }
.check-label input { width: 16px; height: 16px; accent-color: var(--purple-700); }
.import-choice { align-items: flex-start; margin-bottom: 9px; }
.import-choice input { flex: 0 0 auto; margin-top: 4px; }
.import-choice span, .import-choice strong, .import-choice small { display: block; }
.import-choice small { margin-top: 2px; font-weight: 400; }
.inventory-entry-panel { margin-bottom: 28px; }
.inventory-transfer-shortcut { display: block; margin-top: 7px; white-space: nowrap; }
.movement-log { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.movement-log summary { color: var(--purple-800); font-weight: 800; cursor: pointer; }
.movement-log .table-wrap { margin-top: 10px; }
.title-with-help { display: flex; align-items: center; gap: 6px; min-width: 0; }
.title-with-help h2, .title-with-help strong { margin: 0; }
.info-button {
  flex: 0 0 44px; width: 44px; height: 44px; display: inline-grid; place-items: center;
  padding: 0; border: 0; border-radius: 50%; color: var(--season-wine); background: transparent;
}
.info-button:hover { background: var(--pink-soft); }
.info-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.info-popover {
  position: fixed; z-index: 1000; width: min(320px, calc(100vw - 20px)); padding: 13px 15px;
  border: 1px solid var(--line); border-radius: 16px; color: var(--ink); background: #fffdfa;
  box-shadow: 0 14px 36px rgba(73,54,47,.16); font-size: 12px; line-height: 1.55;
}
.info-popover[hidden] { display: none; }
.info-popover div { position: relative; padding-left: 13px; }
.info-popover div::before { content: "•"; position: absolute; left: 0; color: var(--season-pink); }
.visually-hidden {
  position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important;
  margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important;
  white-space: nowrap !important; border: 0 !important;
}
.addon-price { min-width: 0; }
.addon-price input { padding: 7px 8px; text-align: right; }
.cloud-panel { margin-top: 18px; }
.cloud-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.cloud-grid > div { padding: 14px; border-radius: 14px; background: var(--purple-050); }
.cloud-grid span, .cloud-grid small { display: block; color: var(--muted); font-size: 10px; }
.cloud-grid strong { display: block; margin: 4px 0; color: var(--purple-800); font-size: 14px; }

dialog { width: min(430px, calc(100% - 30px)); padding: 0; border: 0; border-radius: 24px; box-shadow: 0 24px 70px rgba(73,54,47,.24); }
dialog::backdrop { background: rgba(40,20,45,.42); backdrop-filter: blur(3px); }
.dialog-content { display: grid; gap: 18px; padding: 24px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; max-width: 320px; padding: 12px 16px; border-radius: 16px; color: white; background: var(--purple-900); box-shadow: 0 14px 35px rgba(44,20,54,.22); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .22s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

.hq-filter-bar {
  display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)) minmax(220px, 1.25fr);
  gap: 12px; margin-bottom: 16px; padding: 16px 18px; border: 1px solid var(--purple-200);
  border-radius: 18px; background: linear-gradient(135deg, var(--surface), var(--purple-050));
}
.hq-filter-bar label { color: var(--muted); font-size: 11px; font-weight: 800; }
.hq-filter-bar select {
  width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 11px; color: var(--ink); background: var(--surface); font: inherit;
}
.hq-sync-note { align-self: stretch; padding: 10px 14px; border-left: 3px solid var(--purple-500); }
.hq-sync-note span, .hq-sync-note small { display: block; color: var(--muted); font-size: 10px; }
.hq-sync-note strong { display: block; margin: 4px 0; color: var(--purple-800); font-size: 15px; }
.hq-overview-grid { margin-top: 0; }
.hq-coverage-panel .panel-heading { align-items: end; }
.hq-coverage-panel .panel-heading > strong { color: var(--purple-800); font-size: 30px; }
.hq-coverage-track { height: 14px; overflow: hidden; border-radius: 999px; background: var(--purple-100); }
.hq-coverage-track div { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--purple-600), var(--pink)); transition: width .35s ease; }
.hq-coverage-scale { display: flex; justify-content: space-between; gap: 16px; margin-top: 10px; color: var(--muted); font-size: 11px; }
.hq-attention-list { display: grid; gap: 10px; }
.hq-attention-item { display: flex; justify-content: space-between; gap: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.hq-attention-item:last-child { padding-bottom: 0; border-bottom: 0; }
.hq-attention-item span { color: var(--muted); font-size: 11px; }
.hq-attention-item strong { text-align: right; color: var(--purple-800); font-size: 13px; }
.hq-kpi-grid { margin-bottom: 16px; }
.hq-table th, .hq-table td { white-space: nowrap; }
.hq-table tbody tr[data-group] { cursor: pointer; }
.hq-table tbody tr[data-group]:hover { background: var(--purple-050); }
.hq-status { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 8px; font-size: 10px; font-weight: 800; }
.hq-status.uploaded { color: #226238; background: #e6f4e9; }
.hq-status.pending { color: #8a4d14; background: #fff0d8; }
.hq-mini-track { width: 86px; height: 7px; overflow: hidden; border-radius: 999px; background: var(--purple-100); }
.hq-mini-track div { height: 100%; border-radius: inherit; background: var(--purple-600); }
.hq-progress-list { display: grid; gap: 15px; }
.hq-progress-row { display: grid; grid-template-columns: 72px minmax(120px, 1fr) 92px; align-items: center; gap: 12px; }
.hq-progress-row > strong { color: var(--purple-800); }
.hq-progress-bars { display: grid; gap: 6px; }
.hq-progress-line { display: grid; grid-template-columns: 64px 1fr 56px; align-items: center; gap: 8px; color: var(--muted); font-size: 10px; }
.hq-progress-line i { display: block; height: 7px; border-radius: 999px; background: var(--purple-100); overflow: hidden; }
.hq-progress-line i span { display: block; height: 100%; border-radius: inherit; background: var(--purple-600); }
.hq-progress-line.inventory i span { background: var(--pink); }
.hq-progress-row > span { text-align: right; color: var(--muted); font-size: 10px; }
.hq-store-panel { margin-top: 16px; }

@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .category-summary { grid-template-columns: repeat(3, 1fr); }
  .margin-grid { grid-template-columns: repeat(2, 1fr); }
  .cloud-grid { grid-template-columns: repeat(2, 1fr); }
  .hq-filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 920px) {
  .app-shell, .app-shell.sidebar-collapsed { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; width: min(286px, calc(100vw - 44px)); padding: 22px 18px;
    z-index: 7; transform: translateX(-110%); transition: transform .22s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: none; }
  .sidebar-close { display: inline-flex; position: absolute; top: 0; right: 8px; }
  .sidebar-collapsed .brand { justify-items: center; padding: 0 8px 24px; text-align: center; }
  .sidebar-collapsed .brand-logo { width: 100%; }
  .sidebar-collapsed .brand-title, .sidebar-collapsed .nav-label, .sidebar-collapsed .sidebar-note { display: block; }
  .sidebar-collapsed .nav-list { padding-inline: 12px; }
  .sidebar-collapsed .nav-item { justify-content: flex-start; padding: 24px 0; }
  .sidebar-collapsed .nav-item::after { left: 39px; right: 0; bottom: 14px; }
  .sidebar-overlay {
    position: fixed; inset: 0; z-index: 6; display: block;
    border: 0; background: rgba(40,30,27,.46); opacity: 0; pointer-events: none;
    transition: opacity .2s ease;
  }
  body.nav-open { overflow: hidden; }
  body.nav-open .sidebar-overlay { opacity: 1; pointer-events: auto; }
  .mobile-menu { display: inline-flex; border: 0; border-radius: 999px; padding: 8px 13px; color: var(--purple-800); background: var(--purple-100); font-weight: 700; }
  .dashboard-grid.two-thirds, .dashboard-grid.equal, .upload-layout, .settings-grid, .workflow-guides { grid-template-columns: 1fr; }
  .ranking-controls { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ranking-controls p, .ranking-zero-filter, .ranking-help { grid-column: 1 / -1; }
  .ranking-help { justify-self: start; }
  .topbar { padding: 0 20px; }
  .view { padding: 24px 20px 44px; }
  .dashboard-hero-zone { margin: -24px -20px 0; padding: 24px 20px 18px; }
  .dashboard-wave-divider { margin-inline: -20px; }
  .dashboard-sales-zone { margin: 0 -20px -44px; padding: 8px 20px 44px; }
  .season-carousel-stage { height: auto; max-height: none; aspect-ratio: 16 / 7; }
  .goal-card { grid-template-columns: 1fr; gap: 16px; }
  .goal-card .button { justify-self: start; }
  .hq-filter-bar { grid-template-columns: 1fr; }
}
@media (max-width: 660px) {
  .account > div { display: none; }
  .store-context label { display: none; }
  .page-heading, .section-heading { align-items: flex-start; flex-direction: column; }
  .heading-actions { width: 100%; justify-content: space-between; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-card:last-child { grid-column: span 2; }
  .margin-grid, .inventory-summary, .form-grid, .scope-summary-grid, .data-recency { grid-template-columns: 1fr; }
  .ranking-panel .panel-heading { align-items: flex-start; }
  .ranking-controls { grid-template-columns: 1fr; }
  .ranking-controls p { grid-column: auto; }
  .inventory-entry-panel { margin-bottom: 22px; }
  .category-summary, .cloud-grid { grid-template-columns: repeat(2, 1fr); }
  .password-row { grid-template-columns: 1fr; }
  .selling-date-entry { grid-template-columns: 1fr; }
  .workflow-step strong { display: none; }
  .product-row { grid-template-columns: 1fr 76px 106px 68px; }
  .hq-progress-row { grid-template-columns: 58px 1fr; }
  .hq-progress-row > span { grid-column: 2; text-align: left; }
  .toast { left: 16px; right: 16px; bottom: 16px; }
  .topbar { min-height: 68px; gap: 8px; padding: 8px 14px; }
  .store-context { min-width: 0; gap: 6px; }
  .store-context select { min-width: 0; max-width: 146px; }
  .campaign-tag { padding-inline: 7px; }
  .season-hero { border-radius: 25px; }
  .season-carousel-stage { height: auto; aspect-ratio: 1 / 1; }
  .dashboard-wave-divider { height: 56px; }
  .season-carousel-controls { gap: 8px; padding-inline: 10px; }
  .carousel-button { min-width: 36px; min-height: 36px; }
  .carousel-pause { display: none; }
}

@media (max-height: 720px) {
  .sidebar { padding-block: 14px; }
  .brand { gap: 7px; padding-bottom: 12px; }
  .brand-logo { max-width: 148px; }
  .nav-item { padding-block: 18px; }
  .nav-item::after { bottom: 10px; }
  .sidebar-note { padding: 10px 12px; }
  .sidebar-collapsed .nav-item { padding-block: 18px; }
  .sidebar-collapsed .nav-item::after { bottom: 9px; }
}

/* Firebase Authentication gate */
body.auth-loading .app-shell,
body.signed-out .app-shell { visibility: hidden; }
body.authenticated .app-shell { visibility: visible; }
.auth-gate {
  position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 18%, rgba(211,162,158,.34), transparent 24rem),
    radial-gradient(circle at 85% 75%, rgba(99,139,139,.20), transparent 28rem),
    var(--canvas);
}
.auth-gate[hidden] { display: none; }
.auth-card {
  width: min(460px, 100%); padding: 38px; border: 1px solid var(--purple-200);
  border-radius: 30px; background: var(--surface); background: rgba(255,253,250,.96);
  box-shadow: 0 24px 70px rgba(73,54,47,.16);
}
.auth-brand-logo { display: block; width: 190px; max-width: 100%; height: auto; margin-bottom: 24px; padding: 8px 10px; border-radius: 15px; background: #000; }
.auth-card h1 { margin: 6px 0 12px; color: var(--ink); font-size: clamp(28px, 4vw, 36px); line-height: 1.2; }
.auth-copy { margin: 0 0 24px; color: var(--muted); line-height: 1.75; }
.auth-google-button { width: 100%; justify-content: center; min-height: 48px; font-size: 14px; }
.auth-google-button:disabled { opacity: .6; cursor: wait; }
.auth-status { min-height: 22px; margin: 14px 0 0; color: var(--purple-700); font-size: 12px; text-align: center; }
.auth-security-note {
  display: grid; gap: 4px; margin-top: 22px; padding: 14px 16px; border-radius: 14px;
  background: var(--purple-050); color: var(--muted); font-size: 11px; line-height: 1.55;
}
.auth-security-note strong { color: var(--purple-800); font-size: 12px; }
.account { gap: 10px; }
.account-signout {
  border: 1px solid var(--purple-200); border-radius: 10px; padding: 7px 10px;
  background: var(--surface); color: var(--purple-700); font: inherit; font-size: 10px; font-weight: 800; cursor: pointer;
}
.account-signout:hover { background: var(--purple-050); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  .season-slide { transition: none !important; }
}
@media (max-width: 660px) {
  .auth-card { padding: 28px 22px; border-radius: 22px; }
  .account-signout { padding: 6px 8px; }
}
