:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --panel: #ffffff;
  --ink: #1d252c;
  --muted: #6d7881;
  --line: #dce2e7;
  --line-strong: #c7d0d7;
  --blue: #2167b1;
  --blue-soft: #e8f1fb;
  --green: #237b58;
  --amber: #9a6400;
  --red: #a93f3f;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input { font: inherit; }
button { cursor: pointer; }
.app-shell { width: min(1480px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 48px; }
.topbar { display: flex; justify-content: space-between; gap: 32px; align-items: flex-end; margin-bottom: 22px; }
.eyebrow, .section-kicker { margin: 0 0 6px; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .12em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: clamp(28px, 4vw, 42px); letter-spacing: 0; }
h2 { margin-bottom: 0; font-size: 20px; }
h3 { margin-bottom: 5px; font-size: 16px; }
.subtitle, .muted { color: var(--muted); font-size: 13px; }
.subtitle { margin: 0; }
.key-box { width: min(450px, 100%); }
.key-box label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.key-row { display: flex; gap: 8px; }
input { min-width: 0; width: 100%; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--panel); color: var(--ink); padding: 10px 11px; outline: none; }
input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.key-box .muted { display: block; margin-top: 6px; }
.button, .icon-button, .tab { border: 1px solid var(--line-strong); border-radius: 5px; background: var(--panel); color: var(--ink); padding: 9px 13px; font-weight: 700; white-space: nowrap; }
.button:hover, .tab:hover, .icon-button:hover { border-color: var(--blue); color: var(--blue); }
.button.primary { border-color: var(--blue); background: var(--blue); color: #fff; }
.button.primary:hover { background: #184f8a; color: #fff; }
.notice { margin-bottom: 16px; border: 1px solid #efd59d; border-radius: 5px; background: #fff8e8; color: var(--amber); padding: 11px 13px; font-size: 13px; }
.notice.error { border-color: #e7b4b4; background: #fff0f0; color: var(--red); }
.main-grid { display: grid; grid-template-columns: minmax(420px, .9fr) minmax(520px, 1.1fr); gap: 16px; align-items: start; }
.workspace-panel, .detail-panel { min-width: 0; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); }
.detail-panel { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
.panel-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; border-bottom: 1px solid var(--line); padding: 18px 20px; }
.detail-head { position: sticky; top: 0; z-index: 1; background: var(--panel); }
.toolbar, .tabs, .filters, .pagination, .key-row { display: flex; align-items: center; }
.toolbar { gap: 9px; }
.tabs { gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
.tab { border: 0; background: transparent; padding: 7px 11px; font-size: 13px; }
.tab.active { background: var(--panel); box-shadow: 0 1px 3px rgb(0 0 0 / 10%); color: var(--blue); }
.filters { flex-wrap: wrap; gap: 8px; padding: 14px 20px; border-bottom: 1px solid var(--line); background: #fafbfc; }
.filters label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.filters input { width: 150px; padding: 8px 9px; font-size: 13px; }
.list-summary { padding: 13px 20px 3px; color: var(--muted); font-size: 12px; }
.data-list { display: grid; gap: 8px; padding: 10px 12px 12px; }
.record { width: 100%; border: 1px solid var(--line); border-radius: 5px; background: var(--panel); padding: 14px; text-align: left; }
.record:hover, .record.selected { border-color: var(--blue); background: #fbfdff; }
.record-top, .record-meta, .match-sides { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.record-top strong { font-size: 15px; }
.record p { margin: 7px 0 10px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.record-meta { flex-wrap: wrap; align-items: flex-start; color: var(--muted); font-size: 12px; }
.record-meta > span { min-width: 0; overflow-wrap: anywhere; }
.pill { display: inline-flex; align-items: center; border-radius: 999px; background: var(--blue-soft); color: var(--blue); padding: 3px 7px; font-size: 11px; font-weight: 800; }
.pill.green { background: #e7f4ee; color: var(--green); }
.pill.gray { background: #edf0f2; color: var(--muted); }
.pagination { justify-content: space-between; border-top: 1px solid var(--line); padding: 12px 20px; color: var(--muted); font-size: 12px; }
.pagination .button { padding: 6px 10px; font-size: 12px; }
.detail-content { padding: 18px 20px 24px; }
.empty-state, .loading, .error-state { display: grid; gap: 6px; padding: 44px 12px; color: var(--muted); text-align: center; font-size: 13px; }
.empty-state strong, .error-state strong { color: var(--ink); font-size: 15px; }
.detail-section { margin-top: 22px; }
.detail-section:first-child { margin-top: 0; }
.detail-section h3 { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 18px; }
.detail-item { border-bottom: 1px solid #eef1f3; padding: 7px 0; }
.detail-item dt { color: var(--muted); font-size: 11px; }
.detail-item dd { margin: 3px 0 0; overflow-wrap: anywhere; font-size: 13px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 5px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { border-bottom: 1px solid var(--line); padding: 8px 9px; text-align: left; vertical-align: top; white-space: nowrap; }
th { background: #f7f9fa; color: var(--muted); font-size: 11px; font-weight: 800; }
tr:last-child td { border-bottom: 0; }
.code-block { max-height: 190px; overflow: auto; margin: 0; border-radius: 5px; background: #202a33; color: #dce8f0; padding: 12px; font: 11px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.match-card { border: 1px solid var(--line); border-radius: 5px; padding: 12px; }
.match-card + .match-card { margin-top: 8px; }
.match-side { min-width: 0; }
.match-side strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match-side small { color: var(--muted); }
.match-result { color: var(--green); font-size: 12px; font-weight: 800; }

@media (max-width: 1050px) {
  .main-grid { grid-template-columns: 1fr; }
  .detail-panel { position: static; max-height: none; }
}
@media (max-width: 680px) {
  .app-shell { width: min(100% - 20px, 1480px); padding-top: 18px; }
  .topbar { display: block; }
  .key-box { margin-top: 18px; width: 100%; }
  .panel-head { padding: 15px; }
  .toolbar { align-items: flex-end; flex-direction: column; }
  .filters { align-items: stretch; padding: 12px 15px; }
  .filters label { width: 100%; }
  .filters input { flex: 1; width: auto; }
  .filters .button { width: 100%; }
  .detail-content { padding: 15px; }
  .detail-grid { grid-template-columns: 1fr; }
  th, td { padding: 7px; }
}
