:root {
  color-scheme: light;
  --ink-900: #0f172a;
  --ink-800: #1e293b;
  --ink-700: #334155;
  --ink-600: #475569;
  --ink-500: #64748b;
  --ink-300: #cbd5e1;
  --ink-200: #e2e8f0;
  --ink-100: #f1f5f9;
  --surface: #ffffff;
  --canvas: #f8fafc;
  --blue-700: #0369a1;
  --blue-800: #075985;
  --green-700: #047857;
  --amber-700: #b45309;
  --red-700: #b91c1c;
  --shadow-card: 0 12px 32px rgba(15, 23, 42, .07);
  --radius-xl: 24px;
  --z-header: 40;
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--canvas); scroll-behavior: smooth; }

body {
  min-height: 100dvh;
  margin: 0;
  color: var(--ink-900);
  background: var(--canvas);
  line-height: 1.5;
}

button, select { font: inherit; }
button, a, select { touch-action: manipulation; }

button:focus-visible,
a:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(2, 132, 199, .42);
  outline-offset: 3px;
}

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

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  color: #fff;
  background: var(--ink-900);
  border-radius: 8px;
  transform: translateY(-160%);
}

.skip-link:focus { transform: translateY(0); }

.app-header {
  position: sticky;
  z-index: var(--z-header);
  top: 0;
  color: #fff;
  background: rgba(15, 23, 42, .96);
  border-bottom: 1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(14px);
}

.header-inner {
  width: min(100%, 1440px);
  min-height: 76px;
  margin: 0 auto;
  padding: 12px clamp(16px, 3vw, 36px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-block,
.header-actions,
.header-navigation,
.back-link,
.live-badge,
.field-label,
.filter-helper,
.loading-heading,
.refresh-button { display: flex; align-items: center; }

.brand-block { gap: 12px; min-width: 0; }
.header-actions { justify-content: flex-end; gap: 10px; }
.header-navigation { gap: 8px; }

.brand-mark {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: #38bdf8;
  background: rgba(14, 165, 233, .12);
  border: 1px solid rgba(125, 211, 252, .24);
  border-radius: 12px;
}

.brand-mark svg { width: 27px; height: 27px; }

.eyebrow,
.section-kicker {
  margin: 0 0 1px;
  color: var(--ink-500);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.brand-block .eyebrow { color: #7dd3fc; }
.brand-block h1 { margin: 0; font-size: clamp(18px, 2.5vw, 22px); line-height: 1.2; letter-spacing: -.02em; }

.back-link {
  min-height: 44px;
  padding: 8px 12px;
  justify-content: center;
  gap: 6px;
  color: #e0f2fe;
  background: rgba(3, 105, 161, .3);
  border: 1px solid rgba(125, 211, 252, .34);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  transition: background-color 180ms ease, border-color 180ms ease;
}

.back-link svg { width: 19px; height: 19px; }
.back-link:hover { color: #fff; background: rgba(3, 105, 161, .5); border-color: rgba(125, 211, 252, .56); }
.back-link:active { background: rgba(7, 89, 133, .7); }

.live-badge {
  min-height: 36px;
  padding: 7px 12px;
  gap: 8px;
  color: #dbeafe;
  background: rgba(30, 41, 59, .88);
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #38bdf8;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(56, 189, 248, .12);
}

.page-shell { width: min(100%, 1440px); margin: 0 auto; padding: clamp(18px, 3vw, 36px); }

.filter-panel {
  padding: clamp(18px, 3vw, 28px);
  background: var(--surface);
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
}

.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-heading h2 { margin: 0; font-size: clamp(20px, 3vw, 26px); line-height: 1.25; letter-spacing: -.02em; }

.record-count {
  padding: 6px 10px;
  color: var(--ink-700);
  background: var(--ink-100);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.field-control { max-width: 520px; margin-top: 20px; display: block; }
.field-label { margin-bottom: 8px; gap: 7px; color: var(--ink-700); font-size: 14px; font-weight: 700; }
.field-label svg, .filter-helper svg { width: 19px; height: 19px; flex: 0 0 auto; color: var(--blue-700); }

.select-wrap { position: relative; display: block; }
.select-wrap select {
  width: 100%;
  min-height: 50px;
  padding: 10px 44px 10px 14px;
  color: var(--ink-900);
  background: var(--surface);
  border: 1px solid var(--ink-300);
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  appearance: none;
  cursor: pointer;
}

.select-wrap select:disabled { color: var(--ink-500); background: var(--ink-100); cursor: wait; }
.select-wrap > svg { position: absolute; top: 50%; right: 14px; width: 20px; height: 20px; color: var(--ink-500); pointer-events: none; transform: translateY(-50%); }

.filter-helper { margin: 14px 0 0; gap: 8px; color: var(--ink-600); font-size: 14px; }
.results-section { margin-top: 32px; }
.results-heading { margin-bottom: 16px; }

.refresh-button {
  min-height: 44px;
  padding: 8px 12px;
  justify-content: center;
  gap: 7px;
  color: var(--blue-800);
  background: #fff;
  border: 1px solid #bae6fd;
  border-radius: 10px;
  font-weight: 800;
  cursor: pointer;
}

.refresh-button svg { width: 19px; height: 19px; }
.refresh-button:hover { background: #f0f9ff; }

.loading-state,
.empty-state {
  padding: clamp(24px, 5vw, 48px);
  color: var(--ink-600);
  background: var(--surface);
  border: 1px solid var(--ink-200);
  border-radius: 18px;
  box-shadow: var(--shadow-card);
}

.loading-heading { justify-content: center; gap: 12px; text-align: left; }
.loading-heading strong, .loading-heading span { display: block; }
.loading-heading strong { color: var(--ink-800); }
.loading-heading span { margin-top: 2px; font-size: 14px; }

.loading-spinner {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border: 3px solid #bae6fd;
  border-top-color: var(--blue-700);
  border-radius: 50%;
  animation: spin .85s linear infinite;
}

.skeleton-list { margin-top: 28px; display: grid; gap: 10px; }
.skeleton-list div {
  height: 52px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 37%, #f1f5f9 63%);
  background-size: 220% 100%;
  border-radius: 10px;
  animation: skeleton-sweep 1.3s linear infinite;
}

.empty-state { text-align: center; }
.empty-illustration { width: 64px; height: 64px; margin: 0 auto 12px; color: var(--ink-300); }
.empty-state h3 { margin: 0; color: var(--ink-800); font-size: 20px; }
.empty-state p { max-width: 560px; margin: 7px auto 0; }

.history-card-list { display: grid; grid-template-columns: 1fr; gap: 14px; }
.history-card {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--ink-200);
  border-radius: 18px;
  box-shadow: var(--shadow-card);
}

.history-card-head { padding: 16px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--ink-200); }
.history-date { margin: 0; color: var(--ink-900); font-size: 17px; font-weight: 900; }
.history-time { display: block; margin-top: 2px; color: var(--ink-500); font-size: 13px; }
.group-badge { padding: 5px 9px; color: var(--blue-800); background: #f0f9ff; border: 1px solid #bae6fd; border-radius: 999px; font-size: 13px; font-weight: 800; }

.history-identifiers { padding: 15px 16px 0; display: grid; gap: 10px; }
.identifier-label { display: block; color: var(--ink-500); font-size: 12px; font-weight: 700; }
.identifier-value { display: block; margin-top: 2px; color: var(--ink-900); font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 16px; line-height: 1.35; overflow-wrap: anywhere; }
.style-value { color: var(--blue-800); font-weight: 800; }

.history-metrics { margin: 15px 16px 16px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.history-metrics > div { min-width: 0; padding: 11px; background: var(--ink-100); border: 1px solid var(--ink-200); border-radius: 12px; }
.history-metrics dt { color: var(--ink-500); font-size: 12px; font-weight: 700; }
.history-metrics dd { min-height: 28px; margin: 3px 0 0; color: var(--ink-900); font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 19px; font-weight: 900; font-variant-numeric: tabular-nums; }
.history-metrics .actual dd { color: var(--green-700); }
.history-metrics .target dd { color: var(--blue-700); }
.history-metrics .difference dd { color: var(--amber-700); }

.history-table-wrap { overflow: hidden; background: var(--surface); border: 1px solid var(--ink-200); border-radius: 16px; box-shadow: var(--shadow-card); }
.history-table-wrap table { width: 100%; border-collapse: collapse; table-layout: auto; }
.history-table-wrap th { padding: 12px 10px; color: var(--ink-600); background: var(--ink-100); border-bottom: 1px solid var(--ink-200); font-size: 12px; font-weight: 800; text-align: left; white-space: nowrap; }
.history-table-wrap td { padding: 13px 10px; color: var(--ink-800); border-bottom: 1px solid var(--ink-200); font-size: 13px; vertical-align: middle; }
.history-table-wrap tbody tr:last-child td { border-bottom: 0; }
.history-table-wrap tbody tr:hover { background: #f8fafc; }
.history-table-wrap .number-cell { text-align: right; font-variant-numeric: tabular-nums; }
.history-table-wrap td.number-cell { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-weight: 800; }
.history-table-wrap .report-column { color: var(--green-700); }
.table-order, .table-style { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-weight: 800; overflow-wrap: anywhere; }
.table-style { color: var(--blue-800); }

[hidden] { display: none !important; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes skeleton-sweep { to { background-position: -120% 0; } }

@media (min-width: 640px) and (max-width: 899px) {
  .history-card-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 900px) {
  .history-card-list { display: none !important; }
  .history-table-wrap:not([hidden]) { display: block; }
}

@media (max-width: 899px) {
  .history-table-wrap { display: none !important; }
  .history-card-list:not([hidden]) { display: grid; }
}

@media (max-width: 700px) {
  .header-inner {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand badge" "nav nav";
    gap: 8px 12px;
  }
  .brand-block { grid-area: brand; }
  .header-actions { display: contents; }
  .header-navigation {
    grid-area: nav;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .brand-mark { width: 40px; height: 40px; }
  .back-link { min-width: 0; padding: 8px; }
  .live-badge { grid-area: badge; padding: 6px 9px; font-size: 11px; }
  .status-dot { display: none; }
  .page-shell { padding: 16px; }
  .filter-panel { padding: 17px; border-radius: 18px; }
  .section-heading { align-items: flex-start; }
  .results-section { margin-top: 28px; }
  .skeleton-list div:nth-child(n+3) { display: none; }
}

@media (max-width: 430px) {
  .eyebrow { font-size: 10px; letter-spacing: .09em; }
  .back-link { font-size: 13px; }
  .live-badge { white-space: normal; line-height: 1.15; text-align: center; }
  .section-heading h2 { font-size: 20px; }
  .record-count { font-size: 12px; }
}

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