@import url("./tokens.css");

:root {
  --fs-good: #13705f;
  --fs-bad: #d25f6a;
  --fs-chart-1: #3370ff;
  --fs-chart-2: #14c9c9;
  --fs-chart-3: #ffc60a;
  --fs-chart-4: #7f8a9e;
  --fs-input-border: #c9cdd4;
  --fs-section: 18px;
  --fs-kpi: 28px;
  --fs-kpi-line: 36px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--fs-font);
  font-size: var(--fs-body-size);
  line-height: var(--fs-body-line);
  color: var(--fs-text);
  background:
    radial-gradient(1200px 480px at 12% -8%, rgba(51, 112, 255, 0.07), transparent 58%),
    radial-gradient(900px 420px at 92% 0%, rgba(20, 201, 201, 0.05), transparent 52%),
    var(--fs-canvas);
}
button, select, input { font: inherit; }
button { cursor: pointer; }
a { color: var(--fs-action); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell {
  display: grid;
  grid-template-columns: var(--fs-sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--fs-surface);
  border-right: 1px solid var(--fs-divider);
  padding: var(--fs-space-6) var(--fs-space-4);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--fs-space-6);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--fs-space-3);
  padding-bottom: var(--fs-space-4);
  border-bottom: 1px solid var(--fs-divider);
  text-decoration: none;
  color: inherit;
  min-height: 72px;
}
.brand:hover { text-decoration: none; }
.brand:focus-visible,
.nav button:focus-visible,
.text-btn:focus-visible,
.mobile-toggle:focus-visible,
select:focus-visible,
.bar-row.store-pick:focus-visible,
.gap-row:focus-visible {
  outline: 2px solid var(--fs-brand);
  outline-offset: 2px;
}
.mobile-brand {
  display: none;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.mobile-brand .brand-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 600;
  color: var(--fs-text);
}
.tone-warn { color: var(--fs-warning); }
.text-btn {
  border: 0;
  background: transparent;
  color: var(--fs-action);
  font-weight: 600;
  font-size: var(--fs-caption-size);
  cursor: pointer;
  min-height: var(--fs-control-height);
  padding: 0 8px;
}
.split-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--fs-space-4);
}
.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--fs-divider);
  font-size: var(--fs-body-size);
}
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--fs-muted); flex: none; }
.kv strong { text-align: right; font-weight: 600; word-break: break-word; }
.brand-logo {
  width: 32px;
  height: 32px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--fs-control-radius);
  box-shadow: 0 1px 0 rgba(20, 86, 240, 0.18);
}
.brand-logo svg {
  display: block;
  width: 32px;
  height: 32px;
  border-radius: var(--fs-control-radius);
}
.brand-logo.sm,
.brand-logo.sm svg {
  width: 28px;
  height: 28px;
}
.brand-name {
  font-size: 17px;
  line-height: 24px;
  font-weight: 600;
  color: var(--fs-text);
  letter-spacing: 0.01em;
}
.brand-sub {
  font-size: var(--fs-caption-size);
  line-height: var(--fs-caption-line);
  color: var(--fs-muted);
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button {
  position: relative;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 10px 12px 10px 14px;
  border-radius: var(--fs-control-radius);
  color: var(--fs-muted);
  font-weight: 500;
  min-height: var(--fs-control-height);
  transition: background var(--fs-motion) ease, color var(--fs-motion) ease;
}
.nav button::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: transparent;
  transition: background var(--fs-motion) ease, transform var(--fs-motion) ease;
  transform: scaleY(0.4);
}
.nav button:hover { background: var(--fs-canvas); color: var(--fs-text); }
.nav button.active {
  background: var(--fs-selected);
  color: var(--fs-action);
  font-weight: 600;
}
.nav button.active::before {
  background: var(--fs-brand);
  transform: scaleY(1);
}


.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  min-height: 56px;
  background: var(--fs-surface);
  border-bottom: 1px solid var(--fs-divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--fs-space-4);
  padding: 10px var(--fs-page-padding);
  flex-wrap: wrap;
}
.topbar-row {
  display: flex;
  align-items: center;
  gap: var(--fs-space-3);
  min-width: 0;
}
.topbar-brand-row { flex: 1; min-width: 0; }
.topbar .scope {
  color: var(--fs-muted);
  font-size: var(--fs-caption-size);
  white-space: nowrap;
}
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--fs-space-3);
  flex-wrap: wrap;
  padding: 6px 10px;
  background: var(--fs-canvas);
  border: 1px solid var(--fs-divider);
  border-radius: var(--fs-panel-radius);
}
.filter-group {
  display: inline-flex;
  align-items: center;
  gap: var(--fs-space-2);
}
.filter-group label {
  color: var(--fs-muted);
  font-size: var(--fs-caption-size);
  font-weight: 500;
}
.filter-bar select {
  height: var(--fs-control-height);
  border: 1px solid var(--fs-input-border);
  border-radius: var(--fs-control-radius);
  background: var(--fs-surface);
  padding: 0 12px;
  color: var(--fs-text);
  min-width: 128px;
  transition: border-color var(--fs-motion) ease, box-shadow var(--fs-motion) ease;
}
.filter-bar select:hover { border-color: #aeb3bc; }
.filter-bar select:focus-visible {
  border-color: var(--fs-brand);
  box-shadow: 0 0 0 3px rgba(51, 112, 255, 0.16);
  outline: none;
}
.filter-meta {
  display: inline-flex;
  align-items: center;
  gap: var(--fs-space-2);
  flex-wrap: wrap;
  margin-left: auto;
}
.meta-chip {
  font-size: var(--fs-caption-size);
  color: var(--fs-muted);
  border: 1px solid var(--fs-divider);
  border-radius: 4px;
  padding: 6px 10px;
  background: var(--fs-surface);
}
.meta-chip.warn { color: var(--fs-warning); border-color: #f0d9a8; background: var(--fs-warning-bg); }

.content {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: var(--fs-space-6) var(--fs-page-padding) var(--fs-space-12);
}
.page-stack {
  display: flex;
  flex-direction: column;
  gap: var(--fs-space-4);
}
.page-stack > .page-head { margin-bottom: 0; }
.page-stack > .footnote { margin-top: var(--fs-space-2); }
.content.page-enter .page-stack > * {
  animation: fsRise 220ms ease both;
}
.content.page-enter .page-stack > *:nth-child(1) { animation-delay: 0ms; }
.content.page-enter .page-stack > *:nth-child(2) { animation-delay: 40ms; }
.content.page-enter .page-stack > *:nth-child(3) { animation-delay: 80ms; }
.content.page-enter .page-stack > *:nth-child(4) { animation-delay: 110ms; }
.content.page-enter .page-stack > *:nth-child(5) { animation-delay: 140ms; }
.content.page-enter .page-stack > *:nth-child(n+6) { animation-delay: 160ms; }
@keyframes fsRise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.page-head { margin-bottom: var(--fs-space-6); }
.page-head h1 {
  margin: 0 0 var(--fs-space-2);
  font-size: var(--fs-heading-size);
  line-height: var(--fs-heading-line);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.page-head .lead {
  color: var(--fs-muted);
  margin: 0;
  max-width: 46rem;
}

.panel {
  background: var(--fs-surface);
  border: 1px solid var(--fs-divider);
  border-radius: var(--fs-panel-radius);
  box-shadow: 0 1px 0 rgba(31, 35, 41, 0.03);
}
.panel + .panel { margin-top: 0; }
.panel-hd {
  padding: var(--fs-space-4) var(--fs-space-6);
  border-bottom: 1px solid var(--fs-divider);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--fs-space-3);
  background: linear-gradient(180deg, #fafbfc 0%, var(--fs-surface) 100%);
}
.panel-hd h2 {
  margin: 0;
  font-size: var(--fs-section);
  line-height: 28px;
  font-weight: 600;
}
.panel-bd { padding: var(--fs-space-6); }
.panel.chart-panel .panel-bd { padding-top: var(--fs-space-4); }

.judge {
  border-left: 3px solid var(--fs-brand);
  padding: var(--fs-space-6);
  background:
    linear-gradient(90deg, rgba(51, 112, 255, 0.04), transparent 42%),
    var(--fs-surface);
}
.judge .eyebrow {
  font-size: var(--fs-caption-size);
  color: var(--fs-muted);
  margin-bottom: var(--fs-space-2);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.judge p {
  margin: 0;
  font-size: 18px;
  line-height: 28px;
  font-weight: 600;
  max-width: 52rem;
}
.judge .sub { margin-top: var(--fs-space-3); font-size: var(--fs-body-size); font-weight: 400; color: var(--fs-muted); }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--fs-divider);
  border-radius: var(--fs-panel-radius);
  background: var(--fs-surface);
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(31, 35, 41, 0.03);
}
.metrics.metrics-brain {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.metrics.metrics-brain .metric:nth-child(4n) { border-right: 0; }
.metrics.metrics-brain .metric:nth-child(n+5) {
  border-top: 1px solid var(--fs-divider);
}
.metric {
  position: relative;
  padding: var(--fs-space-6);
  border-right: 1px solid var(--fs-divider);
  background: var(--fs-surface);
  transition: background var(--fs-motion) ease;
}
.metric:last-child { border-right: 0; }
.metric:hover { background: #fafbfd; }
.metric .label {
  color: var(--fs-muted);
  font-size: var(--fs-caption-size);
  font-weight: 500;
}
.metric .value {
  margin-top: var(--fs-space-2);
  font-size: var(--fs-kpi);
  line-height: var(--fs-kpi-line);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.metric .hint { margin-top: var(--fs-space-1); font-size: var(--fs-caption-size); color: var(--fs-muted); }
.metric .hint.up { color: var(--fs-good); }
.metric .hint.down { color: var(--fs-bad); }
.metric::after {
  content: "";
  position: absolute;
  left: var(--fs-space-6);
  right: var(--fs-space-6);
  bottom: 0;
  height: 2px;
  background: transparent;
  transition: background var(--fs-motion) ease;
}
.metric:hover::after { background: var(--fs-brand); }

.table-wrap { overflow: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-body-size);
}
table.data th {
  text-align: left;
  color: var(--fs-muted);
  font-weight: 600;
  background: var(--fs-canvas);
  padding: 12px 14px;
  border-bottom: 1px solid var(--fs-divider);
  white-space: nowrap;
}
table.data td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--fs-divider);
  white-space: nowrap;
}
table.data td.num, table.data th.num { text-align: right; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover td { background: #f8f9fa; }
table.data tbody tr.active td { background: var(--fs-selected); }

.bars { display: flex; flex-direction: column; gap: var(--fs-space-3); }
.bar-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) 96px;
  gap: var(--fs-space-3);
  align-items: center;
}
.bar-track {
  height: 12px;
  background: var(--fs-canvas);
  border-radius: 2px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #4c82ff, var(--fs-chart-1));
  border-radius: 2px;
  min-width: 0;
  transform-origin: left center;
  animation: fsBarIn 320ms ease both;
}
@keyframes fsBarIn {
  from { transform: scaleX(0.08); opacity: 0.55; }
  to { transform: scaleX(1); opacity: 1; }
}

/* 趋势柱图区（四周花费 / 近窗） */
.chart-area {
  border: 1px dashed var(--fs-divider);
  border-radius: var(--fs-panel-radius);
  background:
    linear-gradient(180deg, rgba(245, 246, 247, 0.65), transparent 48%),
    var(--fs-surface);
  padding: var(--fs-space-4) var(--fs-space-4) var(--fs-space-3);
}
.chart-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: var(--fs-space-3);
  align-items: end;
  min-height: 168px;
}
.chart-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.chart-col-val {
  font-size: var(--fs-caption-size);
  line-height: var(--fs-caption-line);
  color: var(--fs-muted);
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.chart-col-track {
  width: 100%;
  max-width: 36px;
  height: 120px;
  display: flex;
  align-items: flex-end;
  background: var(--fs-canvas);
  border-radius: 4px 4px 2px 2px;
  overflow: hidden;
}
.chart-col-fill {
  width: 100%;
  background: linear-gradient(180deg, #5b8cff, var(--fs-chart-1));
  border-radius: 4px 4px 2px 2px;
  min-height: 4px;
  transform-origin: bottom center;
  animation: fsColIn 360ms ease both;
}
.chart-col-label {
  font-size: var(--fs-caption-size);
  color: var(--fs-text);
  font-weight: 500;
  text-align: center;
}
@keyframes fsColIn {
  from { transform: scaleY(0.12); opacity: 0.5; }
  to { transform: scaleY(1); opacity: 1; }
}
.bar-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.bar-row.store-pick {
  padding: 6px 8px;
  border-radius: var(--fs-control-radius);
  cursor: pointer;
}
.bar-row.store-pick:hover { background: var(--fs-canvas); }
.bar-row.store-pick.active-store { background: var(--fs-selected); }
.bar-val .up { color: var(--fs-good); }
.bar-val .down { color: var(--fs-bad); }
.fee-track {
  position: relative;
  height: 12px;
  min-width: 120px;
  background: var(--fs-canvas);
  border-radius: 2px;
  overflow: hidden;
}
.fee-fill {
  height: 100%;
  background: linear-gradient(90deg, #4c82ff, var(--fs-chart-1));
  border-radius: 2px;
  transform-origin: left center;
  animation: fsBarIn 320ms ease both;
}
.fee-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 55%;
  width: 2px;
  background: var(--fs-bad);
}
.caliber-note {
  margin-top: var(--fs-space-4);
  padding: 12px 16px;
  border: 1px solid var(--fs-divider);
  border-left: 3px solid var(--fs-action);
  border-radius: var(--fs-panel-radius);
  background: var(--fs-selected);
  font-size: var(--fs-caption-size);
  line-height: var(--fs-caption-line);
  color: var(--fs-text);
}
.caliber-note strong { font-weight: 600; margin-right: 6px; }
.caliber-note em { font-style: normal; font-weight: 600; color: var(--fs-action); }
.sample-banner {
  margin-bottom: var(--fs-space-4);
  padding: 12px 16px;
  border-radius: var(--fs-panel-radius);
  border: 1px solid #f0d9a8;
  background: var(--fs-warning-bg);
  color: var(--fs-warning);
  font-size: var(--fs-body-size);
  line-height: var(--fs-body-line);
}
.sample-banner strong { font-weight: 600; }

/* 经营全貌 · 要你拍板（只读，不回写） */
.ask {
  display: flex;
  flex-wrap: wrap;
  gap: var(--fs-space-3) var(--fs-space-4);
  align-items: center;
  margin-top: 0;
  padding: var(--fs-space-4) var(--fs-space-6);
  background: linear-gradient(90deg, var(--fs-selected), #f7f9ff);
  border: 1px solid #d6e2ff;
  border-radius: var(--fs-panel-radius);
}
.ask b {
  color: var(--fs-action);
  font-size: var(--fs-body-size);
  font-weight: 600;
  flex: none;
}
.ask .grow {
  flex: 1;
  min-width: 12em;
  color: var(--fs-text);
  font-size: var(--fs-body-size);
  line-height: var(--fs-body-line);
}
.ask .ask-acts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--fs-space-2);
  align-items: center;
}

.figs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--fs-space-4);
  margin-top: 0;
  align-items: start;
}
.fig-no {
  font-size: var(--fs-caption-size);
  line-height: var(--fs-caption-line);
  color: var(--fs-muted);
}
.fig-title {
  margin: 4px 0 var(--fs-space-4);
  font-size: 16px;
  line-height: 24px;
  font-weight: 600;
  color: var(--fs-text);
}
.gap-row {
  display: grid;
  grid-template-columns: 7.5em minmax(0, 1fr) 5.5em 4.5em;
  gap: var(--fs-space-2);
  align-items: center;
  min-height: 40px;
  padding: 4px 8px;
  border-radius: var(--fs-control-radius);
  cursor: pointer;
  color: inherit;
}
.gap-row:hover { background: var(--fs-canvas); }
.gap-row .clip {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.gap-bar {
  position: relative;
  height: 14px;
  background: var(--fs-canvas);
  border-radius: 2px;
}
.gap-bar::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -6px;
  bottom: -6px;
  border-left: 1px solid var(--fs-divider);
}
.gap-bar i {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 2px;
  animation: fsBarIn 300ms ease both;
}
.gap-bar i.g { background: var(--fs-good); }
.gap-bar i.r { background: var(--fs-bad); }
.gap-row .v { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gap-row .v.up { color: var(--fs-good); }
.gap-row .v.down { color: var(--fs-bad); }
.gap-row .go {
  color: var(--fs-action);
  font-size: var(--fs-caption-size);
  font-weight: 600;
  white-space: nowrap;
}
.gap-hint {
  margin-top: var(--fs-space-3);
  font-size: var(--fs-caption-size);
  line-height: var(--fs-caption-line);
  color: var(--fs-muted);
}
.priority-list {
  display: flex;
  flex-direction: column;
  gap: var(--fs-space-3);
}
.priority-item {
  display: flex;
  justify-content: space-between;
  gap: var(--fs-space-3);
  align-items: baseline;
  padding-bottom: var(--fs-space-3);
  border-bottom: 1px solid var(--fs-divider);
}
.priority-item:last-child { border-bottom: 0; padding-bottom: 0; }
.priority-item .who { font-weight: 600; }
.priority-item .why { color: var(--fs-muted); font-size: var(--fs-caption-size); margin-top: 2px; }
.priority-item .tag {
  flex: none;
  font-size: var(--fs-caption-size);
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--fs-danger-bg);
  color: var(--fs-bad);
  font-weight: 600;
}
.priority-item .tag.ok {
  background: var(--fs-success-bg);
  color: var(--fs-good);
}

.footnote {
  margin-top: var(--fs-space-4);
  font-size: var(--fs-caption-size);
  line-height: var(--fs-caption-line);
  color: var(--fs-muted);
}
.state {
  padding: var(--fs-space-8);
  text-align: center;
  color: var(--fs-muted);
}
.mobile-toggle { display: none; }

@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--fs-divider); }
  .metrics.metrics-brain .metric:nth-child(2n) { border-right: 0; }
  .metrics.metrics-brain .metric:nth-child(n+3) { border-top: 1px solid var(--fs-divider); }
  .metrics.metrics-brain .metric:nth-child(4n) { border-right: 1px solid var(--fs-divider); }
  .metrics.metrics-brain .metric:nth-child(2n) { border-right: 0; }
}
@media (max-width: 1100px) {
  .split-2 { grid-template-columns: 1fr; }
  .figs { grid-template-columns: 1fr; }
}
@media (max-width: 767px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    display: none;
    position: fixed;
    inset: 0 auto 0 0;
    top: 0;
    width: min(80vw, 240px);
    z-index: 30;
    box-shadow: 0 8px 24px rgba(31, 35, 41, 0.12);
    padding-top: var(--fs-space-6);
  }
  .sidebar.open { display: flex; }
  .mobile-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--fs-touch-size);
    min-height: var(--fs-touch-size);
    border: 1px solid var(--fs-input-border);
    border-radius: var(--fs-control-radius);
    background: var(--fs-surface);
    flex: none;
  }
  .mobile-brand { display: inline-flex; }
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: var(--fs-space-2);
    padding: 8px 16px 12px;
  }
  .topbar-brand-row { width: 100%; }
  .topbar .scope { display: none; }
  .filter-bar {
    width: 100%;
    padding: 8px;
    gap: var(--fs-space-2);
  }
  .filter-group { flex: 1; min-width: 0; }
  .filter-bar select { min-width: 0; flex: 1; width: 100%; }
  .filter-meta { margin-left: 0; width: 100%; }
  .filter-meta .meta-chip { max-width: 100%; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric .value { font-size: 24px; line-height: 32px; }
  .bar-row { grid-template-columns: 72px minmax(0, 1fr) 72px; }
  .gap-row { grid-template-columns: 5.5em minmax(0, 1fr) 4.5em; }
  .gap-row .go { display: none; }
  .ask { padding: var(--fs-space-4); }
  .chart-cols { min-height: 148px; }
  .chart-col-track { height: 96px; }
}

@media (prefers-reduced-motion: reduce) {
  .content.page-enter .page-stack > *,
  .bar-fill,
  .fee-fill,
  .gap-bar i,
  .chart-col-fill {
    animation: none !important;
  }
  .nav button,
  .metric,
  .filter-bar select {
    transition: none !important;
  }
}
