:root {
  color-scheme: dark;
  font-family: system-ui, 'Microsoft YaHei', sans-serif;
  color: #f0f6fb;
  background: #0b121b;
  --panel: #101b27;
  --inset: #0c1520;
  --border: #243446;
  --muted: #a8b8c9;
  --mint: #73e7bf;
  --amber: #f8cc85;
  --red: #ff9ba5;
}

* { box-sizing: border-box; }
body { min-width: 300px; margin: 0; }
[hidden] { display: none !important; }
button, input, select { font: inherit; }
button, input, select, [tabindex] { outline-offset: 4px; }
:focus-visible { outline: 2px solid var(--mint); }
h1, h2, p { margin: 0; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem max(1.25rem, calc((100vw - 1140px) / 2));
  border-bottom: 1px solid var(--border);
  background: #0d1722;
}
.brand { display: flex; align-items: center; gap: .65rem; font-weight: 700; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 27px; height: 27px; border: 1px solid #3d8a75; border-radius: 7px; background: #14352f; }
.brand-mark::before { content: ''; width: 9px; height: 9px; border: 2px solid var(--mint); transform: rotate(45deg); border-radius: 2px; }
.sources { color: var(--muted); font-size: .875rem; text-align: right; }
.sources span { margin: 0 .4rem; color: #6d879e; }

main { max-width: 1180px; margin: auto; padding: clamp(1.5rem, 5vw, 3.5rem) 1.25rem 3rem; }
.intro { margin-bottom: 1.65rem; }
h1 { font-size: clamp(2rem, 5vw, 3rem); letter-spacing: -.045em; line-height: 1.2; }
.intro p { color: var(--muted); margin-top: .7rem; line-height: 1.65; }
.board { display: grid; grid-template-columns: minmax(290px, .86fr) minmax(0, 1.14fr); gap: 1rem; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 13px; overflow: hidden; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 60px; padding: .8rem 1.25rem; border-bottom: 1px solid var(--border); }
h2 { font-size: 1.05rem; font-weight: 700; }
form, .result-body { padding: 1.25rem; }
.fields { min-width: 0; margin: .9rem 0 0; border: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.wide { grid-column: 1 / -1; }
.field { display: grid; gap: .38rem; min-width: 0; font-size: .875rem; color: #d4e0ec; }
.field input { min-width: 0; width: 100%; height: 42px; border: 1px solid #324458; border-radius: 7px; background: var(--inset); padding: .5rem .65rem; color: #f0f6fb; }
.field input::placeholder { color: #8fa4b8; }
.toggle { display: flex; align-items: center; gap: .55rem; font-size: .875rem; min-height: 32px; }
.toggle input { width: 1.05rem; height: 1.05rem; margin: 0; accent-color: var(--mint); }
.actions { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: .8rem; }
button { cursor: pointer; border: 1px solid transparent; border-radius: 7px; min-height: 42px; padding: .45rem 1rem; background: var(--mint); color: #092018; font-weight: 700; }
button:hover { filter: brightness(1.12); }
button:disabled { cursor: wait; opacity: .7; }
button.secondary { background: #192837; color: #e3edf7; border-color: #375069; white-space: nowrap; }
.hint { color: var(--muted); margin-top: .85rem; font-size: .875rem; line-height: 1.65; }
.country-status { margin: 0; }

.state, .score { display: inline-block; border-radius: 6px; padding: .23rem .5rem; background: #1b2c3e; color: #c5d5e6; white-space: nowrap; font-size: .875rem; }
.state.running { background: #17354c; color: #a8dafe; }
.state.matched, .score { background: #14392f; color: var(--mint); }
.state.stopped, .state.exhausted { background: #392d1c; color: var(--amber); }
.progress-label { display: flex; align-items: start; justify-content: space-between; gap: 1rem; font-size: .9rem; line-height: 1.5; }
.numbers { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
progress { appearance: none; display: block; width: 100%; height: 6px; margin: .6rem 0 1rem; border: 0; border-radius: 99px; background: #233548; accent-color: var(--mint); }
progress::-webkit-progress-bar { border-radius: 99px; background: #233548; }
progress::-webkit-progress-value { border-radius: 99px; background: var(--mint); transition: width .2s ease; }
progress::-moz-progress-bar { border-radius: 99px; background: var(--mint); }
.empty { display: grid; justify-items: center; align-content: center; gap: .5rem; min-height: 232px; padding: 1rem; border: 1px dashed #364b60; border-radius: 9px; color: var(--muted); text-align: center; }
.empty p { color: #e8f2fa; font-weight: 650; }
.empty span { font-size: .875rem; }
.scan-mark { display: grid; place-items: center; width: 45px; height: 45px; border: 1px solid #334c61; border-radius: 10px; background: #142434; margin-bottom: .3rem; }
.scan-mark span { width: 19px; height: 19px; border: 1px solid #81a7c1; border-radius: 4px; position: relative; }
.scan-mark span::after { content: ''; position: absolute; left: 2px; right: 2px; top: 8px; height: 1px; background: #94d9ca; }
.match { background: var(--inset); border: 1px solid #315849; border-radius: 9px; padding: .9rem 1rem; }
.result-toolbar, .metrics { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; }
.result-toolbar { justify-content: space-between; margin-bottom: .7rem; }
.sort { display: flex; align-items: center; gap: .5rem; font-size: .875rem; color: var(--muted); }
.sort select { color: #e3edf7; background: var(--inset); border: 1px solid #375069; border-radius: 7px; padding: .45rem .5rem; }
.match-list { display: grid; gap: .65rem; }
.match-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .35rem; }
.match-head strong { overflow-wrap: anywhere; font: 650 clamp(1.1rem, 2.5vw, 1.6rem) ui-monospace, monospace; }
.latency { font-size: .875rem; color: var(--muted); white-space: nowrap; }
.details { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .65rem 1rem; font-size: .875rem; }
.details dt { color: var(--muted); }
.details dd { margin: .2rem 0 0; overflow-wrap: anywhere; }
.copy-row { display: flex; gap: .45rem; }
.copy-row input { font-family: ui-monospace, monospace; }

.history { margin-top: 1rem; }
.muted { color: var(--muted); font-size: .875rem; }
.table-wrap { overflow-x: auto; }
.table-wrap:focus-visible { outline-offset: -2px; }
table { border-collapse: collapse; width: 100%; min-width: 850px; text-align: left; font-size: .875rem; }
th, td { padding: .75rem .8rem; border-bottom: 1px solid var(--border); }
th:first-child, td:first-child { padding-left: 1.25rem; }
th { color: var(--muted); background: #132030; font-weight: 600; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td:nth-child(2) { font-family: ui-monospace, monospace; }
td:nth-child(5), td:nth-child(6), td:nth-child(7) { font-variant-numeric: tabular-nums; }
td small { display: block; color: var(--muted); font-size: .8125rem; margin-top: .25rem; }
td.matched { color: var(--mint); }
td.error { color: var(--red); }
#empty-row { text-align: center; padding: 1.25rem; color: var(--muted); }

@media (max-width: 760px) {
  .board { grid-template-columns: minmax(0, 1fr); }
  .empty { min-height: 175px; }
}
@media (prefers-reduced-motion: reduce) {
  progress::-webkit-progress-value { transition: none; }
}
