:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #e6eaf0;
  --line-strong: #d5dce6;
  --text: #18212f;
  --text-muted: #6d7888;
  --text-faint: #98a3b2;
  --navy: #183450;
  --blue: #2e6fae;
  --blue-soft: #eaf3fb;
  --green: #177754;
  --green-soft: #e8f6ef;
  --red: #bf5149;
  --red-soft: #fff0ee;
  --amber: #a36b0a;
  --amber-soft: #fff6dd;
  --shadow: 0 1px 2px rgba(21, 39, 61, .03), 0 8px 26px rgba(21, 39, 61, .035);
  --radius: 10px;
  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; }
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button { cursor: pointer; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.app-shell { min-height: 100vh; }
.topbar {
  height: 66px; padding: 0 40px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line); background: rgba(255,255,255,.88);
}
.brand-lockup { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 42px; border-radius: 9px;
  background: var(--navy); box-shadow: 0 7px 18px rgba(20, 48, 78, .16);
}
.brand-mark svg { width: 32px; height: 32px; overflow: visible; }
.brand-mark__letters, .brand-mark__slash { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.brand-mark__letters { stroke: #fff; stroke-width: 2.7; }
.brand-mark__slash { stroke: #d4aa58; stroke-width: 2.6; }
.brand-name { color: var(--navy); font-size: 15px; font-weight: 720; letter-spacing: .01em; }
.brand-subtitle { margin-top: 3px; color: var(--text-faint); font-size: 10px; letter-spacing: .04em; }
.topbar-meta { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 12px; }
.topbar-divider { width: 1px; height: 13px; margin: 0 3px; background: var(--line-strong); }
.health-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.health-dot.is-loading { background: var(--amber); animation: pulse 1.2s ease-in-out infinite; }
.health-dot.is-error { background: var(--red); }

.page-content { width: min(1440px, calc(100% - 80px)); margin: 0 auto; padding: 46px 0 34px; }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 8px; color: var(--blue); font-size: 10px; font-weight: 750; letter-spacing: .16em; }
h1 { margin: 0; color: var(--navy); font-size: clamp(25px, 3vw, 34px); line-height: 1.2; letter-spacing: -.045em; }
.hero-copy { margin: 11px 0 0; color: var(--text-muted); font-size: 13px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 18px; }
.metric-card { min-height: 125px; padding: 19px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.metric-card--accent { border-color: #d4e4f2; background: linear-gradient(135deg, #fff 0%, #f7fbff 100%); }
.metric-label { color: var(--text-muted); font-size: 12px; }
.metric-value { min-height: 39px; margin-top: 7px; color: var(--navy); font-size: 29px; font-weight: 720; line-height: 1.35; letter-spacing: -.045em; }
.metric-value--small { font-size: 21px; letter-spacing: -.025em; }
.metric-note { color: var(--text-faint); font-size: 11px; line-height: 1.45; }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.search-wrap { position: relative; flex: 1; min-width: 180px; }
.search-wrap input { width: 100%; height: 38px; padding: 0 36px; border: 1px solid var(--line-strong); border-radius: 7px; outline: none; background: var(--surface); color: var(--text); font-size: 12px; transition: border .16s, box-shadow .16s; }
.search-wrap input::placeholder { color: var(--text-faint); }
.search-wrap input:focus, select:focus { border-color: #7ca9ce; box-shadow: 0 0 0 3px rgba(55, 120, 177, .11); }
.search-icon { position: absolute; z-index: 1; left: 13px; top: 12px; width: 12px; height: 12px; border: 1.6px solid var(--text-faint); border-radius: 50%; pointer-events: none; }
.search-icon::after { content: ""; position: absolute; width: 5px; height: 1.6px; right: -4px; bottom: -2px; transform: rotate(45deg); background: var(--text-faint); }
.clear-search { position: absolute; right: 8px; top: 7px; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 5px; background: transparent; color: var(--text-faint); font-size: 19px; line-height: 1; }
.clear-search:hover { background: var(--surface-soft); color: var(--text); }
.filter-group { display: flex; align-items: center; gap: 7px; }
.filter-group label { color: var(--text-muted); font-size: 11px; white-space: nowrap; }
select { height: 38px; padding: 0 30px 0 11px; border: 1px solid var(--line-strong); border-radius: 7px; outline: none; background: var(--surface); color: var(--text); font-size: 12px; }

.table-section { padding: 0 0 2px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.section-heading > div { display: flex; align-items: baseline; gap: 10px; }
h2 { margin: 0; color: var(--navy); font-size: 17px; letter-spacing: -.025em; }
.result-count { color: var(--text-faint); font-size: 11px; }
.refresh-button { display: inline-flex; align-items: center; gap: 6px; padding: 7px 9px; border: 0; border-radius: 6px; background: transparent; color: var(--blue); font-size: 12px; }
.refresh-button:hover { background: var(--blue-soft); }
.refresh-icon { font-size: 17px; line-height: 12px; }

.table-wrap { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.data-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.data-table th { padding: 13px 15px; border-bottom: 1px solid var(--line); background: #fbfcfd; color: var(--text-faint); font-size: 10px; font-weight: 650; letter-spacing: .03em; text-align: left; white-space: nowrap; }
.data-table td { padding: 15px; border-bottom: 1px solid #edf0f4; vertical-align: middle; font-size: 12px; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fbfdff; }
.col-stock { width: 22%; }.col-price { width: 12%; }.col-premium { width: 13%; }.col-range { width: 15%; }.col-percentile { width: 11%; }.col-state { width: 10%; }.col-data { width: 9%; }
.stock-main { color: var(--navy); font-weight: 680; line-height: 1.4; }
.stock-sub { margin-top: 3px; color: var(--text-faint); font-size: 10px; line-height: 1.3; }
.price-main { color: var(--text); font-variant-numeric: tabular-nums; }
.price-change { margin-top: 3px; font-size: 10px; font-variant-numeric: tabular-nums; }
.price-change.is-up { color: var(--red); }.price-change.is-down { color: var(--green); }.price-change.is-flat { color: var(--text-faint); }
.premium-value { color: var(--navy); font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.premium-value.is-positive { color: var(--red); }.premium-value.is-negative { color: var(--green); }
.range-line { display: flex; align-items: center; gap: 7px; color: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.range-track { position: relative; width: 68px; height: 3px; border-radius: 4px; background: #e9eef3; }
.range-track::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: var(--range-width, 50%); border-radius: inherit; background: #aecde5; }
.range-marker { position: absolute; z-index: 1; top: 50%; left: var(--range-position, 50%); width: 7px; height: 7px; border: 2px solid #fff; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 1px var(--blue); transform: translate(-50%, -50%); }
.percentile-value { display: inline-block; color: var(--navy); font-weight: 680; font-variant-numeric: tabular-nums; }
.percentile-bar { width: 58px; height: 3px; margin-top: 7px; overflow: hidden; border-radius: 5px; background: #edf0f4; }
.percentile-bar > span { display: block; width: var(--percentile-width, 0%); height: 100%; border-radius: inherit; background: var(--blue); }
.status-badge, .data-badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 7px; border-radius: 5px; font-size: 10px; font-weight: 650; white-space: nowrap; }
.status-badge::before, .data-badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status-badge--low { color: var(--green); background: var(--green-soft); }.status-badge--fair { color: var(--blue); background: var(--blue-soft); }.status-badge--high { color: var(--red); background: var(--red-soft); }.status-badge--unknown { color: var(--text-muted); background: #f1f3f5; }
.data-badge--ok { color: var(--green); background: var(--green-soft); }.data-badge--stale { color: var(--amber); background: var(--amber-soft); }.data-badge--missing, .data-badge--error { color: var(--red); background: var(--red-soft); }

.state-panel { min-height: 228px; padding: 35px 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text-muted); text-align: center; }
.state-panel strong { color: var(--navy); font-size: 14px; }.state-panel span { font-size: 12px; }.state-panel--error { border-color: #f0d7d4; background: #fffdfd; }.state-panel--error strong { color: var(--red); }
.loading-spinner { width: 24px; height: 24px; margin-bottom: 4px; border: 2px solid #dce8f1; border-top-color: var(--blue); border-radius: 50%; animation: spin .75s linear infinite; }
.state-symbol { display: grid; place-items: center; width: 28px; height: 28px; margin-bottom: 3px; border-radius: 50%; background: var(--red-soft); color: var(--red); font-size: 15px; font-weight: 800; }.state-symbol--muted { background: #f1f3f5; color: var(--text-faint); }
.retry-button { margin-top: 8px; padding: 7px 12px; border: 1px solid #e4bebb; border-radius: 6px; background: #fff; color: var(--red); font-size: 12px; }.retry-button:hover { background: var(--red-soft); }

.page-footer { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--text-faint); font-size: 11px; line-height: 1.6; }
.methodology { display: flex; gap: 18px; }.footer-label { flex: 0 0 auto; color: var(--text-muted); font-weight: 700; }.methodology p { margin: 0; max-width: 900px; }.footer-meta { display: flex; gap: 8px; margin-top: 10px; color: var(--text-faint); font-size: 10px; }.footer-separator { color: var(--line-strong); }
.methodology--secondary { margin-top: 7px; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .45; } }

@media (max-width: 960px) {
  .topbar { padding: 0 24px; }
  .page-content { width: min(100% - 48px, 900px); padding-top: 35px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar { flex-wrap: wrap; }.search-wrap { flex-basis: 100%; order: -1; }
  .col-range { width: 16%; }.col-stock { width: 22%; }.col-price { width: 12%; }.col-premium { width: 13%; }.col-percentile { width: 11%; }.col-state { width: 11%; }.col-data { width: 9%; }
  .data-table th, .data-table td { padding-left: 11px; padding-right: 11px; }
}

@media (max-width: 680px) {
  .topbar { height: 58px; padding: 0 16px; }.topbar-meta { font-size: 10px; }.topbar-meta #updatedAt, .topbar-divider { display: none; }
  .page-content { width: calc(100% - 32px); padding: 28px 0 24px; }
  .hero { align-items: flex-start; flex-direction: column; gap: 14px; margin-bottom: 22px; }.hero-copy { font-size: 12px; }
  .metric-grid { gap: 8px; }.metric-card { min-height: 107px; padding: 14px; }.metric-label { font-size: 10px; }.metric-value { min-height: 34px; margin-top: 5px; font-size: 22px; }.metric-value--small { font-size: 16px; }.metric-note { font-size: 9px; }
  .toolbar { align-items: stretch; gap: 8px; }.filter-group { flex: 1; flex-direction: column; align-items: stretch; gap: 4px; }.filter-group label { font-size: 10px; }.filter-group select { width: 100%; }
  .section-heading { margin-bottom: 9px; }.section-heading > div { gap: 7px; }h2 { font-size: 15px; }.refresh-button { padding-right: 0; }
  .table-wrap { overflow-x: auto; }.data-table { min-width: 780px; }.data-table th, .data-table td { padding-top: 12px; padding-bottom: 12px; }
  .page-footer { margin-top: 22px; }.methodology { gap: 10px; flex-direction: column; }.footer-meta { flex-wrap: wrap; }
}
