:root {
  --bg: #0f1419;
  --panel: #1a222c;
  --panel-2: #222c38;
  --line: #2e3a48;
  --text: #e8eef4;
  --muted: #8b9aab;
  --accent: #3d9cf0;
  --ok: #3ecf8e;
  --bad: #ff4d4f;
  --warn: #f5a623;
  --up: #f5c542;
  --down: #3ecf8e;
  --mono: "Cascadia Code", "SF Mono", Consolas, monospace;
  --sans: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
}

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 20px 12px;
  background: rgba(15, 20, 25, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
}

.top-bar-end {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.clock-box {
  padding: 5px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 108px;
  text-align: center;
}

.clock-label {
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.clock-now {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--accent);
  margin-top: 1px;
  tabular-nums: true;
  font-variant-numeric: tabular-nums;
}

.status {
  flex: 1;
  min-width: 160px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--panel-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.pill.ok {
  color: var(--ok);
  border-color: #2a6b4f;
  background: rgba(62, 207, 142, 0.08);
}

.pill.bad {
  color: var(--bad);
  border-color: #7a2e30;
  background: rgba(255, 77, 79, 0.08);
}

.top-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
  padding-top: 2px;
}

.stat {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 0.78rem;
  line-height: 1.3;
  color: var(--text);
}

.stat .k {
  color: var(--muted);
  font-size: 0.72rem;
}

.stat .v {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.stat.muted {
  color: var(--muted);
}

.stat.run {
  border-color: #2a6b4f;
  color: var(--ok);
}

.stat.pause {
  border-color: #a06a20;
  color: #ffe0a6;
}

.stat.warn-stat {
  border-color: #5a4a28;
}

.stat.order-on {
  border-color: #2a5080;
}

.meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-family: var(--mono);
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 0.8rem;
  color: var(--muted);
  user-select: none;
  cursor: pointer;
}

.toggle:hover {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.toggle input {
  margin: 0;
}

.pause-btn {
  flex-shrink: 0;
  padding: 5px 11px;
  font-size: 0.8rem;
}

.pause-btn.is-paused {
  background: #5a3a12;
  border-color: #a06a20;
  color: #ffe0a6;
}

body.is-paused .feed {
  opacity: 0.92;
}

body.is-paused .sub::after {
  content: " · 已暂停";
  color: #ffe0a6;
}

@media (max-width: 900px) {
  .top-bar-end {
    margin-left: 0;
    width: 100%;
  }
}

.banner {
  margin: 12px 20px 0;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  line-height: 1.45;
}

.banner.error {
  background: #3a1518;
  border: 1px solid #7a2e30;
  color: #ffc9c9;
}

.banner.warn {
  background: #3a2a10;
  border: 1px solid #7a5a20;
  color: #ffe0a6;
}

.banner.warn.flash {
  animation: flashWarn 0.8s ease;
}

@keyframes flashWarn {
  0%,
  100% {
    background: #3a2a10;
  }
  50% {
    background: #5a4018;
  }
}

.hidden {
  display: none !important;
}

.feed {
  padding: 16px 20px 48px;
  max-width: 1280px;
}

.snap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.snap.has-change {
  border-color: #5a4a28;
}

.snap-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
}

.snap-time {
  font-family: var(--mono);
  font-size: 0.85rem;
}

.snap-stat {
  color: var(--muted);
  font-size: 0.8rem;
}

.snap-stat strong.up {
  color: var(--up);
}

.snap-body {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

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

.table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.table tr:last-child > td {
  border-bottom: none;
}

.table tr.row-changed {
  background: rgba(245, 197, 66, 0.05);
}

.table tr.history-row td {
  background: #141b22;
  padding: 0;
  border-bottom: 1px solid var(--line);
}

.teams {
  font-weight: 600;
  min-width: 140px;
}

.score,
.clock {
  font-family: var(--mono);
  white-space: nowrap;
}

.cell {
  font-family: var(--mono);
  white-space: nowrap;
}

.cell .cur {
  font-weight: 650;
}

.cell .cur.up {
  color: var(--up);
}

.cell .cur.down {
  color: var(--down);
}

.cell .cur.change {
  color: var(--warn);
}

.cell .prev {
  display: block;
  margin-top: 2px;
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 400;
  opacity: 0.9;
}

.expand-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  transition: transform 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.expand-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.expand-btn.open {
  color: var(--accent);
  transform: rotate(180deg);
}

.expand-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.history-panel {
  padding: 10px 14px 14px;
}

.history-panel h4 {
  margin: 0 0 8px;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
  font-family: var(--mono);
}

.history-table th,
.history-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.history-table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.68rem;
}

.history-table .dir-up {
  color: var(--up);
}

.history-table .dir-down {
  color: var(--down);
}

.history-empty {
  color: var(--muted);
  font-size: 0.8rem;
  padding: 8px 0;
}

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}

.legend {
  display: flex;
  gap: 14px;
  font-size: 0.75rem;
  color: var(--muted);
}

.legend span.up {
  color: var(--up);
}

.legend span.down {
  color: var(--down);
}

.nav {
  display: flex;
  gap: 8px;
  align-items: center;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
}

.nav a:hover {
  color: var(--text);
  border-color: var(--line);
}

.nav a.active {
  color: var(--accent);
  border-color: #2a4a6a;
  background: var(--panel-2);
}

.settings-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  gap: 16px;
}

.settings-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
}

.settings-card h2 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.hint-list {
  margin: 0;
  padding-left: 1.2em;
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.88rem;
}

.hint-list strong {
  color: var(--text);
}

.settings-form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 6px;
  font-size: 0.88rem;
}

.field span {
  color: var(--muted);
}

.field input[type="number"] {
  width: 100%;
  max-width: 280px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-family: var(--mono);
}

.field.check {
  display: flex;
  align-items: center;
  gap: 10px;
}

.field.check span {
  color: var(--text);
}

.form-note {
  margin: 0 0 12px;
  color: var(--warn);
  font-size: 0.82rem;
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel-2);
}

.history-block.open {
  border-color: #2a6aa0;
}

.history-item {
  text-align: left;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  border-radius: 0;
  padding: 10px 12px;
  cursor: pointer;
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.history-item.active {
  box-shadow: inset 3px 0 0 #2a6aa0;
}

.history-item-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.85rem;
}

.history-item-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-family: var(--mono);
}

.history-detail.inline {
  margin: 0;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
}

.history-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.history-detail h3 {
  margin: 0;
  font-size: 0.95rem;
}

.history-detail-close {
  padding: 4px 10px;
  font-size: 0.78rem;
}

.history-detail-meta {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.empty-mini {
  color: var(--muted);
  font-size: 0.85rem;
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.mini-table th,
.mini-table td {
  border-bottom: 1px solid var(--line);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}

.mini-table th {
  color: var(--muted);
  font-weight: 600;
}

.mini-table .ok {
  color: var(--ok);
}

.mini-table .bad {
  color: var(--bad);
}

.field input[type="text"] {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.82rem;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 0.88rem;
  text-decoration: none;
  line-height: 1.2;
}

.btn:hover {
  border-color: #4a5a6a;
  background: #263040;
}

.btn.primary {
  background: #1e4d7a;
  border-color: #2a6aa0;
}

.btn.primary:hover {
  filter: brightness(1.08);
}

.form-msg {
  font-size: 0.85rem;
  color: var(--muted);
}

.form-msg.ok {
  color: var(--ok);
}

.form-msg.bad {
  color: var(--bad);
}

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 18px 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.modal h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.modal p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.modal .modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
}

.order-chip {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  border: 1px solid #2a6aa0;
  color: var(--accent);
}
