:root {
  --bg: #101013;
  --bg-raised: #18181d;
  --surface: rgba(28, 28, 34, 0.88);
  --surface-strong: #222229;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #f5f3ef;
  --muted: #a9a7af;
  --faint: #77757e;
  --accent: #ff563c;
  --accent-hot: #ff826e;
  --stock: #42d98b;
  --warning: #ffc45b;
  --danger: #ff676f;
  --info: #65a8ff;
  --radius: 18px;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.28);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(255, 86, 60, 0.045) 0 1px, transparent 1px 28px),
    linear-gradient(45deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 28px),
    var(--bg);
  background-size: 40px 40px;
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
}
button, input, select { font: inherit; }
button, select { color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.skip-link {
  position: fixed;
  z-index: 100;
  left: 1rem;
  top: -5rem;
  padding: .7rem 1rem;
  border-radius: 8px;
  color: #111;
  background: #fff;
}
.skip-link:focus { top: 1rem; }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

.ambient { position: fixed; z-index: -1; border-radius: 50%; filter: blur(100px); opacity: .12; pointer-events: none; }
.ambient-one { width: 34rem; height: 34rem; right: -12rem; top: -12rem; background: var(--accent); }
.ambient-two { width: 28rem; height: 28rem; left: -14rem; bottom: 10%; background: #7645ff; opacity: .07; }

.site-header, .view-nav, main, footer, .config-errors {
  width: min(1480px, calc(100% - 48px));
  margin-inline: auto;
}
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 34px 0 22px;
}
.brand-block { display: flex; align-items: center; gap: 14px; }
.brand-block h1 { margin: 1px 0 0; font-size: clamp(1.55rem, 3vw, 2.15rem); letter-spacing: -.045em; line-height: 1; }
.eyebrow { margin: 0; color: var(--accent-hot); font-size: .72rem; font-weight: 800; letter-spacing: .16em; }
.brand-mark { width: 48px; height: 48px; display: grid; place-content: center; gap: 4px; transform: skewX(-10deg); border: 1px solid rgba(255,86,60,.5); background: rgba(255,86,60,.09); border-radius: 12px; }
.brand-mark span { display: block; width: 22px; height: 3px; background: var(--accent); border-radius: 99px; }
.brand-mark span:nth-child(2) { width: 16px; }
.brand-mark span:nth-child(3) { width: 10px; }
.header-status { display: flex; align-items: center; gap: 9px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 999px; background: rgba(20,20,24,.72); color: var(--muted); font-size: .86rem; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 5px rgba(255,196,91,.1); }
.header-status.is-good .pulse { background: var(--stock); box-shadow: 0 0 0 5px rgba(66,217,139,.1); }
.header-status.is-bad .pulse { background: var(--danger); box-shadow: 0 0 0 5px rgba(255,103,111,.1); }

.view-nav { display: flex; gap: 5px; padding: 5px; border: 1px solid var(--line); border-radius: 14px; background: rgba(20,20,24,.72); backdrop-filter: blur(16px); position: sticky; top: 12px; z-index: 20; box-shadow: 0 8px 30px rgba(0,0,0,.2); }
.view-tab { flex: 0 1 180px; border: 0; border-radius: 10px; padding: 10px 16px; background: transparent; color: var(--muted); font-weight: 700; }
.view-tab:hover { color: var(--text); background: rgba(255,255,255,.04); }
.view-tab.is-active { color: #fff; background: linear-gradient(135deg, var(--accent), #d63b2b); box-shadow: 0 7px 22px rgba(255,86,60,.2); }

.config-errors { margin-top: 18px; padding: 16px 18px; border: 1px solid rgba(255,103,111,.45); border-radius: 14px; background: rgba(113,23,31,.23); }
.config-errors h2 { margin: 0 0 8px; font-size: 1rem; }
.config-errors ul { margin: 0; padding-left: 1.25rem; color: #ffd2d5; }
.config-errors code { word-break: break-all; color: #fff; }

main { padding: 28px 0 70px; }
.view[hidden] { display: none; }
.surface { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.summary-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.metric { position: relative; min-height: 142px; padding: 19px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(150deg, rgba(38,38,45,.96), rgba(23,23,28,.92)); }
.metric::after { content: ""; position: absolute; width: 110px; height: 110px; right: -45px; bottom: -55px; border: 1px solid var(--line); border-radius: 50%; }
.metric-primary { border-color: rgba(255,86,60,.38); background: linear-gradient(150deg, rgba(98,35,29,.7), rgba(29,25,28,.96)); }
.metric-stock { border-color: rgba(66,217,139,.3); }
.metric-warning { border-color: rgba(255,196,91,.24); }
.metric-label { display: block; color: var(--muted); font-size: .86rem; font-weight: 650; }
.metric strong { display: block; margin-top: 12px; font-size: 2.3rem; line-height: 1; letter-spacing: -.05em; }
.metric-note { display: block; margin-top: 11px; color: var(--faint); font-size: .75rem; }

.toolbar { margin-top: 16px; padding: 12px; display: flex; align-items: center; gap: 14px; justify-content: space-between; box-shadow: none; }
.search-field { flex: 1 1 360px; max-width: 540px; display: flex; align-items: center; gap: 10px; padding: 0 13px; border: 1px solid var(--line); border-radius: 12px; background: rgba(10,10,13,.52); }
.search-field:focus-within { border-color: rgba(255,86,60,.65); box-shadow: 0 0 0 3px rgba(255,86,60,.09); }
.search-field svg { width: 19px; fill: none; stroke: var(--muted); stroke-width: 1.7; }
.search-field input { width: 100%; min-height: 43px; border: 0; outline: 0; color: var(--text); background: transparent; }
.search-field input::placeholder { color: var(--faint); }
.filter-group { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.filter-chip { border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; background: transparent; color: var(--muted); font-size: .82rem; font-weight: 700; }
.filter-chip:hover { border-color: var(--line-strong); color: var(--text); }
.filter-chip.is-active { border-color: rgba(255,86,60,.45); color: #fff; background: rgba(255,86,60,.13); }

.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 1.5rem; margin: 30px 2px 15px; }
.section-heading h2 { margin: 3px 0 0; font-size: 1.35rem; letter-spacing: -.025em; }
.section-meta { margin: 0; color: var(--muted); font-size: .82rem; text-align: right; }
.product-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.product-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(155deg, rgba(34,34,41,.97), rgba(23,23,28,.97)); box-shadow: 0 12px 34px rgba(0,0,0,.18); transition: transform .18s ease, border-color .18s ease; }
.product-card:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.product-card.is-stock { border-color: rgba(66,217,139,.36); }
.product-card.is-stale { border-color: rgba(255,196,91,.38); }
.product-image { aspect-ratio: 1.65; display: grid; place-items: center; position: relative; overflow: hidden; background: radial-gradient(circle at 55% 38%, #35353e, #19191e 68%); }
.product-image::after { content: ""; position: absolute; inset: auto -8% 8% 40%; height: 1px; background: linear-gradient(90deg, transparent, rgba(255,255,255,.2)); transform: rotate(-12deg); }
.product-image img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; object-position: center 53%; }
.image-placeholder { font-size: 1.05rem; font-weight: 900; letter-spacing: .08em; color: rgba(255,255,255,.18); text-transform: uppercase; transform: skewX(-8deg); }
.status-badge { position: absolute; z-index: 2; top: 12px; left: 12px; padding: 5px 9px; border-radius: 999px; border: 1px solid var(--line); background: rgba(12,12,15,.82); color: var(--muted); font-size: .72rem; font-weight: 800; backdrop-filter: blur(10px); }
.status-badge.in_stock { color: #85f0b7; border-color: rgba(66,217,139,.38); }
.status-badge.not_live { color: #a9cfff; border-color: rgba(101,168,255,.35); }
.status-badge.stale { top: 12px; left: auto; right: 12px; color: #ffe0a0; border-color: rgba(255,196,91,.42); }
.product-body { padding: 16px; }
.product-kicker { display: flex; justify-content: space-between; gap: 1rem; color: var(--faint); font-size: .73rem; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; }
.product-body h3 { min-height: 2.9em; margin: 8px 0 12px; font-size: 1rem; line-height: 1.42; letter-spacing: -.012em; }
.product-body h3 a { text-decoration: none; }
.product-body h3 a:hover { color: var(--accent-hot); }
.price { margin: 0 0 14px; font-size: 1.35rem; font-weight: 850; letter-spacing: -.03em; }
.price del { margin-left: 6px; color: var(--faint); font-size: .78rem; font-weight: 500; }
.size-label { margin: 0 0 7px; color: var(--muted); font-size: .75rem; }
.sizes { display: flex; flex-wrap: wrap; gap: 5px; min-height: 31px; }
.size { display: inline-grid; place-items: center; min-width: 31px; height: 27px; padding: 0 6px; border: 1px solid rgba(66,217,139,.3); border-radius: 7px; color: #a8f4ca; background: rgba(66,217,139,.07); font-size: .74rem; font-weight: 750; }
.no-sizes { color: var(--faint); font-size: .78rem; }
.product-meta { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); display: grid; gap: 4px; color: var(--faint); font-size: .71rem; }
.empty-state { grid-column: 1 / -1; padding: 60px 24px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); text-align: center; }

.history-title { margin-top: 5px; }
.history-controls { display: flex; gap: 12px; padding: 13px; box-shadow: none; }
.history-controls label { display: grid; gap: 5px; min-width: 190px; color: var(--muted); font-size: .75rem; font-weight: 700; }
select { width: 100%; min-width: 0; max-width: 100%; min-height: 41px; padding: 0 36px 0 11px; border: 1px solid var(--line); border-radius: 10px; background: #16161a; outline: 0; }
select:focus { border-color: rgba(255,86,60,.65); box-shadow: 0 0 0 3px rgba(255,86,60,.09); }
.history-layout, .pattern-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, .75fr); gap: 14px; margin-top: 14px; }
.table-surface, .events-surface, .chart-surface, .candidate-surface { padding: 18px; min-width: 0; }
.surface-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 14px; }
.surface-heading h3 { margin: 0; font-size: 1rem; }
.surface-heading span { color: var(--faint); font-size: .75rem; }
.table-scroll { overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: .77rem; }
th { position: sticky; top: 0; background: #202026; color: var(--muted); font-weight: 800; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255,255,255,.025); }
.run-status { display: inline-flex; align-items: center; gap: 5px; font-weight: 800; }
.run-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.run-status.complete::before { background: var(--stock); }
.run-status.incomplete::before { background: var(--warning); }
.run-status.missed::before { background: var(--danger); }
.event-list, .candidate-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.event-item { padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; background: rgba(9,9,12,.24); }
.event-item strong { display: block; font-size: .8rem; }
.event-item span { display: block; margin-top: 3px; color: var(--muted); font-size: .72rem; }
.event-item.restock { border-color: rgba(66,217,139,.28); }
.event-item.price_changed { border-color: rgba(255,196,91,.27); }
.empty-list { padding: 20px 10px; color: var(--faint); text-align: center; }

.sample-gate { display: flex; align-items: center; gap: 15px; padding: 18px; margin-bottom: 14px; box-shadow: none; }
.sample-gate.is-ready { border-color: rgba(66,217,139,.38); background: rgba(30,72,50,.2); }
.gate-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; color: var(--warning); background: rgba(255,196,91,.09); font-size: 1.7rem; }
.sample-gate.is-ready .gate-icon { color: var(--stock); background: rgba(66,217,139,.09); }
.sample-gate h3, .sample-gate p { margin: 0; }
.sample-gate h3 { font-size: .95rem; }
.sample-gate p { margin-top: 3px; color: var(--muted); font-size: .78rem; }
.hourly-chart { height: 310px; display: grid; grid-template-columns: repeat(24, minmax(12px, 1fr)); align-items: end; gap: 4px; padding: 24px 3px 0; border-top: 1px solid var(--line); }
.hour-column { height: 100%; display: flex; flex-direction: column; justify-content: end; align-items: stretch; gap: 6px; }
.hour-bar { min-height: 2px; border-radius: 5px 5px 2px 2px; background: linear-gradient(180deg, var(--accent-hot), var(--accent)); box-shadow: 0 0 18px rgba(255,86,60,.12); }
.hour-column.is-candidate .hour-bar { background: linear-gradient(180deg, #7ef4b3, var(--stock)); box-shadow: 0 0 20px rgba(66,217,139,.16); }
.hour-label { color: var(--faint); font-size: .6rem; text-align: center; writing-mode: vertical-rl; transform: rotate(180deg); }
.candidate-list { counter-reset: candidate; }
.candidate-item { counter-increment: candidate; display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 10px; padding: 13px 10px; border-bottom: 1px solid var(--line); }
.candidate-item::before { content: counter(candidate, decimal-leading-zero); color: var(--faint); font-size: .7rem; font-weight: 900; }
.candidate-item strong { font-size: 1.05rem; }
.candidate-item span { color: var(--muted); font-size: .75rem; }
.candidate-item em { color: var(--stock); font-style: normal; font-weight: 850; }
.coverage-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.coverage-card { padding: 16px; box-shadow: none; }
.coverage-card span, .coverage-card small { display: block; color: var(--muted); font-size: .75rem; }
.coverage-card strong { display: block; margin: 8px 0 6px; font-size: 1.8rem; letter-spacing: -.04em; }

footer { display: flex; justify-content: space-between; gap: 2rem; padding: 24px 0 34px; border-top: 1px solid var(--line); color: var(--faint); font-size: .72rem; }
footer p { margin: 0; max-width: 680px; }

@media (max-width: 1180px) {
  .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .site-header, .view-nav, main, footer, .config-errors { width: min(100% - 28px, 1480px); }
  .site-header { align-items: flex-start; }
  .header-status { max-width: 50%; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar { align-items: stretch; flex-direction: column; }
  .search-field { max-width: none; flex-basis: auto; }
  .filter-group { justify-content: flex-start; }
  .history-layout, .pattern-layout { grid-template-columns: 1fr; }
  .coverage-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .site-header { padding-top: 22px; flex-direction: column; gap: 14px; }
  .header-status { max-width: none; align-self: stretch; }
  .view-nav { overflow-x: auto; }
  .view-tab { flex: 1 0 120px; }
  .summary-grid, .product-grid, .coverage-grid { grid-template-columns: 1fr; }
  .metric { min-height: 118px; }
  .history-controls { flex-direction: column; }
  .history-controls label { min-width: 0; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 7px; }
  .section-meta { text-align: left; }
  .hourly-chart { height: 260px; gap: 2px; }
  .hour-label { font-size: .52rem; }
  footer { flex-direction: column; gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
