:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #17201b;
  background: #f3f6f4;
  font-synthesis: none;
  --ink: #17201b;
  --muted: #68746d;
  --line: #dbe4df;
  --surface: #ffffff;
  --green: #0f8a64;
  --green-soft: #e4f5ee;
  --amber: #d0782d;
  --red: #cf4b52;
  --shadow: 0 8px 28px rgba(23, 32, 27, .055);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-width: 320px;
  background-color: #f3f6f4;
  background-image:
    linear-gradient(rgba(40, 65, 51, .032) 1px, transparent 1px),
    linear-gradient(90deg, rgba(40, 65, 51, .032) 1px, transparent 1px);
  background-size: 28px 28px;
}
button { font: inherit; }
.topbar { position: relative; z-index: 10; background: rgba(17, 24, 20, .97); color: #f8fbf9; border-bottom: 1px solid rgba(255,255,255,.1); box-shadow: 0 10px 30px rgba(17,24,20,.12); }
.topbar-inner { max-width: 1240px; height: 76px; margin: auto; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.18); border-radius: 8px; background: #e8b75d; color: #17201b; font: 750 17px/1 ui-sans-serif, system-ui, sans-serif; box-shadow: inset 0 1px rgba(255,255,255,.35); }
h1, h2, p { margin: 0; }
h1 { font-size: 17px; line-height: 1.25; font-weight: 720; letter-spacing: 0; }
.brand p { margin-top: 2px; color: #aebbb4; font-size: 12px; }
.topbar-meta { display: flex; align-items: center; gap: 16px; color: #b9c4be; font-size: 12px; white-space: nowrap; }
.mode-badge { display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; border: 1px solid rgba(255,255,255,.12); border-radius: 6px; color: #dce6e1; text-transform: uppercase; }
.mode-dot, .status-dot { width: 7px; height: 7px; border-radius: 50%; background: #56c78e; box-shadow: 0 0 0 3px rgba(86,199,142,.13); }
.icon-button { width: 34px; height: 34px; border: 1px solid rgba(255,255,255,.16); border-radius: 7px; background: rgba(255,255,255,.04); color: #d9e2dd; display: grid; place-items: center; cursor: pointer; transition: background .18s ease, border-color .18s ease; }
.icon-button:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.28); }
.icon-button:disabled { opacity: .45; cursor: wait; }
.icon-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-button.loading svg { animation: rotate .8s linear infinite; }

main { max-width: 1240px; margin: auto; padding: 30px 28px 56px; }
.status-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); overflow: hidden; background: rgba(255,255,255,.94); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.metric { min-width: 0; padding: 18px 20px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric-label { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; min-height: 31px; margin-top: 7px; overflow-wrap: anywhere; font-size: 22px; font-weight: 680; line-height: 1.45; font-variant-numeric: tabular-nums; letter-spacing: 0; }
.metric-note { display: block; margin-top: 3px; color: #8a958f; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source-value { display: flex !important; align-items: center; gap: 9px; }
.source-value.delayed .status-dot { background: #dc932f; box-shadow: 0 0 0 3px rgba(220,147,47,.13); }
.source-value.offline .status-dot { background: #d75555; box-shadow: 0 0 0 3px rgba(215,85,85,.13); }
.source-value.waiting .status-dot { background: #98a39d; box-shadow: none; }

.page-state { min-height: 44px; margin-top: 14px; padding: 10px 14px; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-size: 13px; }
.page-state.ready { visibility: hidden; }
.page-state.error { color: var(--red); background: #fff1f1; border: 1px solid #f1cccc; border-radius: 7px; }
.page-state button { padding: 5px 10px; border: 1px solid #e2b1b1; background: #fff; color: #9b2e2e; cursor: pointer; }
.spinner { width: 14px; height: 14px; border: 2px solid #cbd5d0; border-top-color: var(--green); border-radius: 50%; animation: rotate .8s linear infinite; }
@keyframes rotate { to { transform: rotate(360deg); } }

.quick-products { overflow: hidden; }
.quick-products-scroll { display: grid; grid-template-columns: repeat(5, minmax(190px, 1fr)); gap: 12px; min-width: 990px; overflow-x: auto; padding: 2px 1px 10px; scrollbar-width: thin; }
.quick-loading { grid-column: 1 / -1; min-height: 170px; display: grid; place-items: center; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 13px; }
.product-card { min-width: 0; min-height: 176px; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.96); box-shadow: var(--shadow); transition: transform .18s ease, box-shadow .18s ease; }
.product-card::before { content: ""; display: block; width: 34px; height: 3px; margin: -16px 0 13px; border-radius: 0 0 3px 3px; background: var(--product-color); }
.product-card:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(23,32,27,.09); }
.product-card-head { min-height: 38px; display: flex; align-items: center; gap: 9px; }
.product-icon { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; border: 1px solid color-mix(in srgb, var(--product-color) 22%, white); border-radius: 8px; background: color-mix(in srgb, var(--product-color) 9%, white); color: var(--product-color); }
.product-icon svg { width: 18px; height: 18px; }
.product-name { min-width: 0; font-size: 12px; font-weight: 650; line-height: 1.35; }
.product-price-row { margin-top: 13px; display: flex; align-items: baseline; gap: 4px; }
.product-price-row strong { font-size: 24px; line-height: 1; font-variant-numeric: tabular-nums; }
.product-price-row > span:not(.movement) { color: var(--muted); font-size: 11px; }
.movement { margin-left: auto; display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-variant-numeric: tabular-nums; }
.movement svg { width: 13px; height: 13px; }
.up { color: var(--red) !important; }
.down { color: var(--green) !important; }
.flat { color: #7a8580 !important; }
.product-stats { margin: 13px 0 0; padding-top: 10px; border-top: 1px solid #e5eae7; }
.product-stats div { margin-top: 5px; display: flex; justify-content: space-between; gap: 7px; font-size: 10px; }
.product-stats div:first-child { margin-top: 0; }
.product-stats dt { color: #7d8982; }
.product-stats dd { margin: 0; color: #3f4d45; text-align: right; font-variant-numeric: tabular-nums; }
.product-stats small { font-size: 9px; }

.section-block { margin-top: 34px; padding-top: 26px; border-top: 1px solid rgba(111,130,120,.28); }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.section-heading.compact { margin-bottom: 14px; }
.eyebrow { margin-bottom: 6px; color: var(--green); font: 750 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; }
h2 { font-size: 21px; font-weight: 720; line-height: 1.35; letter-spacing: 0; }
.section-description { margin-top: 5px; color: var(--muted); font-size: 12px; }
.segmented { display: inline-grid; grid-template-columns: repeat(4, 1fr); padding: 3px; border: 1px solid #d4ddd8; border-radius: 8px; background: rgba(229,235,231,.85); }
.segmented button { min-width: 70px; height: 32px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; color: #59665f; cursor: pointer; font-size: 12px; transition: color .16s ease, background .16s ease, box-shadow .16s ease; }
.segmented button:last-child { border-right: 0; }
.segmented button:hover { color: var(--ink); }
.segmented button.active { background: #fff; color: #176b51; box-shadow: 0 2px 8px rgba(23,32,27,.09); font-weight: 650; }
.chart-wrap, .session-chart-wrap { position: relative; min-width: 0; overflow: hidden; background: rgba(255,255,255,.96); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.chart { width: 100%; height: 430px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.detail-panel { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.96); box-shadow: var(--shadow); }
.detail-panel:last-child:nth-child(odd) { grid-column: 1 / -1; }
.detail-panel-head { min-height: 66px; padding: 12px 15px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid #e4e9e6; }
.detail-title { min-width: 0; flex: 1; }
.detail-title h3, .analysis-panel h3 { margin: 0; color: var(--ink); font-size: 13px; letter-spacing: 0; }
.detail-title p { margin-top: 4px; color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.detail-extremes { display: grid; grid-template-columns: auto auto; gap: 3px 12px; color: var(--muted); font-size: 10px; text-align: right; font-variant-numeric: tabular-nums; }
.detail-extremes strong { color: var(--ink); font-size: 11px; font-weight: 600; }
.detail-chart { width: 100%; height: 270px; }
.analytics-chart-wrap { min-height: 360px; }
.analytics-chart { width: 100%; height: 360px; }
.analysis-grid, .analysis-tables { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.analysis-tables { margin-top: 14px; }
.analysis-panel { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.96); box-shadow: var(--shadow); }
.analysis-panel > h3 { height: 44px; padding: 0 16px; display: flex; align-items: center; border-bottom: 1px solid #e4e9e6; }
.analysis-chart { width: 100%; height: 300px; }
.compact-table-scroll { overflow-x: auto; }
.compact-table { min-width: 620px; font-size: 11px; }
.compact-table th, .compact-table td { height: 44px; padding: 0 12px; }
.spread-list { min-height: 220px; padding: 4px 16px; }
.spread-row { min-height: 98px; padding: 15px 0; border-bottom: 1px solid #e7ece9; }
.spread-row:last-child { border-bottom: 0; }
.spread-row-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
.spread-row-head strong { font-size: 13px; }
.spread-row-head span { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
.spread-row dl { margin: 10px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.spread-row dl div { min-width: 0; }
.spread-row dt { color: var(--muted); font-size: 10px; }
.spread-row dd { margin: 3px 0 0; font-size: 11px; font-variant-numeric: tabular-nums; }
.analysis-empty { min-height: 210px; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.empty-overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 28px; background: rgba(255,255,255,.94); color: var(--muted); text-align: center; font-size: 13px; }
.source-label { color: var(--muted); font-size: 12px; }

.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.96); box-shadow: var(--shadow); }
table { width: 100%; min-width: 1080px; border-collapse: collapse; font-size: 13px; }
th, td { height: 52px; padding: 0 18px; border-bottom: 1px solid #e6ebe8; text-align: left; white-space: nowrap; }
th { height: 40px; background: #f3f6f4; color: #59675f; font-size: 11px; font-weight: 650; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfb; }
td:first-child { font-weight: 600; }
.movement-text { font-weight: 600; }
.price-number { font-variant-numeric: tabular-nums; }
.difference.positive { color: var(--red); }
.difference.negative { color: var(--green); }
.table-empty { height: 100px; color: var(--muted); text-align: center; font-weight: 400 !important; }

.session-layout { display: grid; grid-template-columns: minmax(270px, .72fr) minmax(0, 1.55fr); gap: 16px; }
.session-progress-panel { min-height: 280px; padding: 30px 26px; background: rgba(255,255,255,.96); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.progress-header { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; color: var(--muted); font-size: 13px; }
.progress-header strong { color: var(--ink); font-size: 28px; font-variant-numeric: tabular-nums; }
.progress-track { height: 10px; margin-top: 42px; overflow: hidden; border-radius: 5px; background: #e7ece9; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: 5px; background: var(--green); transition: width .45s ease; }
.progress-track.over span { background: var(--amber); }
.progress-scale { display: flex; justify-content: space-between; gap: 14px; margin-top: 10px; color: #7c8881; font-size: 11px; }
.progress-note { margin-top: 50px; padding-top: 16px; border-top: 1px solid #e3e8e5; color: var(--muted); font-size: 12px; line-height: 1.7; }
.session-reliability { margin: 18px 0 0; padding-top: 14px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; border-top: 1px solid #e3e8e5; }
.session-reliability div { min-width: 0; }
.session-reliability dt { color: var(--muted); font-size: 10px; }
.session-reliability dd { margin: 3px 0 0; color: var(--ink); font-size: 11px; font-variant-numeric: tabular-nums; }
.session-chart-wrap { min-height: 280px; }
.session-chart { width: 100%; height: 280px; }
footer { max-width: 1240px; margin: auto; padding: 20px 28px 34px; display: flex; justify-content: space-between; border-top: 1px solid rgba(111,130,120,.28); color: #7b8880; font-size: 11px; }

@media (max-width: 760px) {
  .topbar-inner { height: 68px; padding: 0 16px; }
  .brand p, #generated-at { display: none; }
  .topbar-meta { gap: 10px; }
  main { padding: 18px 14px 36px; }
  .status-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { min-height: 113px; padding: 15px 14px; }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .metric strong { font-size: 17px; }
  .section-block { margin-top: 23px; padding-top: 20px; }
  .quick-products-scroll { min-width: 0; display: flex; gap: 9px; scroll-snap-type: x proximity; }
  .product-card { flex: 0 0 218px; scroll-snap-align: start; }
  .section-heading { align-items: stretch; flex-direction: column; gap: 12px; }
  .section-heading.compact { flex-direction: row; align-items: flex-end; }
  .segmented { width: 100%; }
  .segmented button { min-width: 0; padding: 0 5px; }
  .chart { height: 360px; }
  .detail-grid, .analysis-grid, .analysis-tables { grid-template-columns: 1fr; }
  .detail-panel:last-child:nth-child(odd) { grid-column: auto; }
  .detail-chart { height: 250px; }
  .analytics-chart, .analytics-chart-wrap { height: 330px; min-height: 330px; }
  .analysis-chart { height: 280px; }
  .session-layout { grid-template-columns: 1fr; }
  th:first-child, td:first-child { position: sticky; left: 0; z-index: 1; background: #fff; box-shadow: 1px 0 #e2e8e4; }
  th:first-child { background: #f0f3f1; z-index: 2; }
  .session-progress-panel { min-height: 245px; padding: 24px 18px; }
  .progress-track { margin-top: 32px; }
  .progress-note { margin-top: 38px; }
  footer { margin: 0 14px; padding: 18px 0 26px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
