:root {
  color-scheme: light;
  --ink: #28313b;
  --muted: #687383;
  --surface: #fffdf8;
  --line: rgba(40, 49, 59, 0.12);
  --shadow: 0 18px 45px rgba(78, 63, 37, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 224, 163, 0.35), transparent 34rem),
    linear-gradient(135deg, #fff9ef 0%, #f7fbff 52%, #fff4f7 100%);
}

.dashboard-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0;
}

.hero {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: end;
  gap: 20px;
  margin-bottom: 28px;
}

.eyebrow {
  align-self: start;
  margin: 6px 0 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: #7b5d21;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4.5rem);
  line-height: 1;
  letter-spacing: -0.05em;
}

.subtitle {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.25rem);
  font-weight: 700;
}

.fixture-meta {
  margin: 8px 0 0;
  color: #7c8794;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.5;
}

.safety-note {
  margin: 0;
  max-width: 230px;
  color: #7c8794;
  font-size: 0.85rem;
  line-height: 1.45;
  text-align: right;
}

.date-selector {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin: 0 0 18px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 30px rgba(49, 61, 76, 0.07);
}

.date-selector[hidden] {
  display: none;
}

.date-selector label {
  font-weight: 900;
}

.date-selector select {
  min-height: 42px;
  padding: 8px 40px 8px 12px;
  border: 1px solid rgba(40, 49, 59, 0.22);
  border-radius: 12px;
  background: #fffdf8;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
}

.date-selector p {
  flex-basis: 100%;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.freshness-panel {
  margin: 0 0 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 10px 30px rgba(49, 61, 76, 0.07);
}

.freshness-panel[hidden] {
  display: none;
}

.freshness-panel__header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 14px;
  margin-bottom: 14px;
}

.freshness-panel__eyebrow {
  margin: 0;
  color: #7b5d21;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.freshness-panel h2 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.freshness-panel__status {
  margin: 0 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  background: #ecfdf3;
  color: #166534;
  font-size: 0.86rem;
  font-weight: 900;
}

.freshness-panel[data-freshness-state="stale"] .freshness-panel__status,
.freshness-panel[data-freshness-state="partial"] .freshness-panel__status {
  background: #fff7ed;
  color: #9a3412;
}

.freshness-panel[data-freshness-state="missing"] .freshness-panel__status,
.freshness-panel[data-freshness-state="error"] .freshness-panel__status {
  background: #fef2f2;
  color: #991b1b;
}

.freshness-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.freshness-metrics div {
  padding: 12px 14px;
  border: 1px solid rgba(40, 49, 59, 0.08);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.82);
}

.freshness-warning {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 16px;
  background: #fff7ed;
  color: #9a3412;
  font-weight: 900;
  line-height: 1.45;
}

.state-banner {
  margin-bottom: 18px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 30px rgba(49, 61, 76, 0.07);
  font-weight: 800;
}

.state-banner.error {
  color: #9a3412;
  background: #fff7ed;
}

.revenue-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  align-items: stretch;
}

.revenue-grid[hidden] {
  display: none;
}

.revenue-card {
  min-height: 260px;
  display: flex;
  flex-direction: column;
  padding: clamp(22px, 3vw, 34px);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 32px;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}

.revenue-card::after {
  content: "";
  position: absolute;
  inset: auto -30px -45px auto;
  width: 150px;
  height: 150px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.34);
}

.revenue-card.tone-yellow {
  background: linear-gradient(145deg, #fff1b8, #ffe39b);
}

.revenue-card.tone-green {
  background: linear-gradient(145deg, #dff6cf, #c6ebb7);
}

.revenue-card.tone-pink {
  background: linear-gradient(145deg, #ffdbe4, #ffc6d3);
}

.revenue-card.tone-blue {
  background: linear-gradient(145deg, #dcecff, #c4ddff);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.store-label {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2rem);
  font-weight: 900;
  letter-spacing: -0.03em;
}

.updated-at {
  white-space: nowrap;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
  color: #40505f;
  font-size: 0.85rem;
  font-weight: 800;
}

.metric-label {
  margin: auto 0 8px;
  color: rgba(40, 49, 59, 0.78);
  font-weight: 800;
}

.primary-value {
  margin: 0;
  font-size: clamp(3rem, 7vw, 5.3rem);
  line-height: 0.96;
  font-weight: 950;
  letter-spacing: -0.075em;
}

.data-note {
  margin: 10px 0 0;
  color: #7b3f18;
  font-weight: 800;
}

.revenue-split,
.secondary-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 24px 0 0;
  padding: 0;
}

.revenue-split {
  margin-top: 18px;
}

.revenue-split div,
.secondary-metrics div {
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.45);
  min-width: 0;
}

.revenue-split dd {
  overflow-wrap: anywhere;
}

.revenue-split .split-percent {
  display: block;
  margin-top: 2px;
  color: rgba(40, 49, 59, 0.62);
  font-size: 0.82rem;
  font-weight: 900;
}

.revenue-split-note {
  margin: 10px 0 0;
  color: #7b3f18;
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.4;
}

dt {
  color: rgba(40, 49, 59, 0.64);
  font-size: 0.82rem;
  font-weight: 800;
}

dd {
  margin: 4px 0 0;
  font-size: 1.08rem;
  font-weight: 900;
  line-height: 1.25;
}

dd.is-missing {
  color: #7b3f18;
  font-size: 0.9rem;
  letter-spacing: 0;
}

.revenue-card.is-loading .store-label,
.revenue-card.is-loading .updated-at,
.revenue-card.is-loading .metric-label,
.revenue-card.is-loading .primary-value,
.revenue-card.is-loading .secondary-metrics {
  color: transparent;
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(255,255,255,0.24), rgba(255,255,255,0.66), rgba(255,255,255,0.24));
  background-size: 220% 100%;
  animation: shimmer 1.25s infinite linear;
}

@keyframes shimmer {
  to { background-position-x: -220%; }
}

@media (max-width: 767px) {
  .dashboard-shell {
    width: min(100% - 24px, 560px);
    padding: 28px 0;
  }

  .hero {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .safety-note {
    text-align: left;
    max-width: none;
  }

  .freshness-panel__status {
    margin-left: 0;
  }

  .freshness-metrics {
    grid-template-columns: 1fr;
  }

  .revenue-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .revenue-card {
    min-height: 230px;
    border-radius: 26px;
  }
}


.entry-nav {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 18px;
}

.entry-nav a,
.pill-switcher a,
.period-switcher a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  font-weight: 900;
  text-decoration: none;
  box-shadow: 0 10px 24px rgba(49, 61, 76, 0.06);
}

.entry-nav a[aria-current="page"],
.pill-switcher a[aria-current="page"],
.period-switcher a[aria-current="page"] {
  background: #28313b;
  color: #fffdf8;
}

.panel-view {
  margin-top: 22px;
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid var(--line);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 14px 36px rgba(49, 61, 76, 0.08);
}

.panel-view[hidden] { display: none; }

.view-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}

.eyebrow.compact { display: inline-block; margin: 0 0 8px; }
.view-header h2 { margin: 0; font-size: clamp(1.55rem, 3vw, 2.35rem); letter-spacing: -0.04em; }
.view-copy, .ranking-contract { margin: 8px 0 0; color: var(--muted); font-weight: 700; line-height: 1.5; }
.pill-switcher, .period-switcher { display: flex; flex-wrap: wrap; gap: 8px; }
.period-switcher { margin: 0 0 18px; }

.store-summary-grid,
.comparison-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.summary-tile,
.comparison-tile {
  padding: 16px;
  border-radius: 22px;
  background: rgba(255, 253, 248, 0.9);
  border: 1px solid rgba(40, 49, 59, 0.08);
}
.summary-tile dt, .comparison-tile dt { color: var(--muted); }
.summary-tile dd, .comparison-tile dd { font-size: 1.35rem; }

.ranking-grid,
.comparison-rankings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.ranking-card,
.comparison-ranking-card {
  padding: 18px;
  border-radius: 24px;
  background: rgba(255, 253, 248, 0.9);
  border: 1px solid rgba(40, 49, 59, 0.08);
}
.ranking-card h3,
.comparison-ranking-card h3 { margin: 0; font-size: 1.15rem; }
.ranking-list { margin: 14px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.ranking-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid rgba(40, 49, 59, 0.08);
}
.rank-badge {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: #fff1b8;
  font-weight: 950;
}
.item-name { font-weight: 900; }
.item-meta { display: block; margin-top: 2px; color: var(--muted); font-size: 0.86rem; font-weight: 700; }
.sales-count { font-weight: 950; white-space: nowrap; }
.empty-ranking { color: #7b3f18; font-weight: 900; line-height: 1.45; }

@media (max-width: 920px) {
  .entry-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .view-header { grid-template-columns: 1fr; }
  .store-summary-grid, .comparison-summary-grid, .ranking-grid, .comparison-rankings { grid-template-columns: 1fr; }
}

@media (max-width: 767px) {
  .entry-nav { grid-template-columns: 1fr; }
  .ranking-row { grid-template-columns: auto 1fr; }
  .sales-count { grid-column: 2; }
}
