:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #edf2f6;
  --text: #17202a;
  --muted: #667281;
  --line: #d8e0e7;
  --green: #087f5b;
  --red: #b42318;
  --amber: #9a5b09;
  --blue: #225ea8;
  --ink: #0e1116;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px clamp(16px, 3vw, 36px);
  background: var(--ink);
  color: #fff;
  border-bottom: 4px solid #2f80ed;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(22px, 2.2vw, 32px);
  font-weight: 760;
}

h2 {
  font-size: 16px;
  font-weight: 720;
}

.subtitle {
  margin-top: 6px;
  color: #b8c4d3;
  font-size: 14px;
}

.connection {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 8px;
  white-space: nowrap;
}

.timestamp {
  color: #c9d3df;
  font-size: 13px;
}

main {
  display: grid;
  gap: 16px;
  width: min(1680px, 100%);
  margin: 0 auto;
  padding: 18px clamp(12px, 2.5vw, 28px) 32px;
}

.controls,
.status-band,
.summary-grid,
.panel,
.risk-strip {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.controls {
  display: grid;
  grid-template-columns: repeat(5, minmax(118px, 1fr)) minmax(88px, auto);
  gap: 10px;
  padding: 12px;
  align-items: end;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

input {
  width: 100%;
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #fff;
  font: inherit;
  font-size: 14px;
}

select {
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #fff;
  font: inherit;
  font-size: 14px;
}

button {
  min-height: 36px;
  border: 1px solid #1b5aa6;
  border-radius: 6px;
  background: #256fc2;
  color: #fff;
  font: inherit;
  font-weight: 720;
  cursor: pointer;
}

button:hover {
  background: #1e61ac;
}

button.secondary,
.record-tools button {
  background: #fff;
  color: var(--blue);
  border-color: #b7c9de;
}

button.secondary:hover,
.record-tools button:hover {
  background: #eef6ff;
}

.status-band {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.status-band > div {
  min-width: 0;
  padding: 13px 16px;
  border-right: 1px solid var(--line);
}

.status-band > div:last-child {
  border-right: 0;
}

.label,
.metric span,
.muted {
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

.status-band strong {
  display: block;
  margin: 4px 0;
  font-size: 17px;
}

.status-band span:last-child {
  color: var(--muted);
  font-size: 13px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

.metric {
  min-height: 82px;
  padding: 16px;
  border-right: 1px solid var(--line);
}

.metric:last-child {
  border-right: 0;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(20px, 2vw, 30px);
  line-height: 1.05;
}

.panel,
.risk-strip {
  padding: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-foot {
  padding: 10px 16px;
  border-top: 1px solid var(--line);
}

.record-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.checkline {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  white-space: nowrap;
}

.checkline input {
  width: auto;
  min-height: auto;
}

.search {
  width: min(260px, 35vw);
}

.status-filter {
  width: min(150px, 24vw);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 1480px;
  border-collapse: collapse;
  font-size: 13px;
}

.records-table {
  min-width: 1280px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--surface-2);
  color: #465260;
  font-size: 12px;
  font-weight: 760;
}

tbody tr:hover {
  background: #f8fbfd;
}

.empty {
  height: 88px;
  color: var(--muted);
  text-align: center;
}

.num {
  font-variant-numeric: tabular-nums;
}

.positive {
  color: var(--green);
  font-weight: 760;
}

.negative {
  color: var(--red);
  font-weight: 760;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  min-height: 26px;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 760;
}

.ok {
  background: #e7f6ef;
  border-color: #a8dec8;
  color: var(--green);
}

.bad {
  background: #fdecec;
  border-color: #f0b6b2;
  color: var(--red);
}

.warn {
  background: #fff4df;
  border-color: #f1ce91;
  color: var(--amber);
}

.neutral {
  background: #e9eef4;
  border-color: #cad5e2;
  color: #395066;
}

.match-list {
  display: grid;
}

.match-row {
  display: grid;
  grid-template-columns: minmax(110px, 0.7fr) minmax(260px, 1.8fr) minmax(220px, 1.2fr) minmax(150px, 0.7fr);
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  align-items: center;
}

.match-row:last-child {
  border-bottom: 0;
}

.match-title {
  font-weight: 740;
}

.match-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.stack {
  display: grid;
  gap: 3px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.actions button {
  min-height: 30px;
  padding: 4px 8px;
  font-size: 12px;
}

.mini-select,
.mini-input {
  min-height: 30px;
  font-size: 12px;
}

.mini-input {
  margin-top: 6px;
  min-width: 150px;
}

.risk-strip {
  padding: 14px 16px 16px;
}

.risk-strip ul {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 1100px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .connection {
    align-items: flex-start;
  }

  .controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .status-band,
  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .status-band > div,
  .metric {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .match-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .controls,
  .status-band,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .panel-head,
  .record-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .search {
    width: 100%;
  }
}
