* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f4f6f8;
  color: #17202a;
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 28px;
  background: #111827;
  color: #ffffff;
}

.eyebrow {
  margin: 0 0 4px;
  color: #8bd3dd;
  font-size: 12px;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 16px;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-strip span {
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px;
}

main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px;
}

.toolbar,
.panel {
  background: #ffffff;
  border: 1px solid #d9e0e7;
  border-radius: 8px;
}

.toolbar {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px;
  margin-bottom: 14px;
}

label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: #4b5563;
}

input,
button,
select {
  min-height: 34px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #111827;
}

input {
  padding: 0 10px;
}

select {
  padding: 0 28px 0 10px;
}

button {
  padding: 0 14px;
  background: #0f766e;
  color: #ffffff;
  cursor: pointer;
}

button.secondary-button {
  background: #ffffff;
  color: #334155;
}

.toggle-label {
  min-width: 74px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #111827;
}

.toggle-row input {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 0;
  padding: 0;
}

.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-basis: 100%;
  min-height: 34px;
  padding-top: 2px;
}

.filter-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  max-width: 280px;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel {
  overflow: hidden;
  margin-bottom: 14px;
}

.panel h2 {
  padding: 12px;
  border-bottom: 1px solid #e5e7eb;
}

.panel h2 span {
  margin-left: 8px;
  color: #64748b;
  font-size: 12px;
  font-weight: 400;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid #edf2f7;
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

tr[data-route-id] {
  cursor: pointer;
}

tr[data-quality-flag],
tr[data-venue],
tr[data-outlier-coin] {
  cursor: pointer;
}

tr[data-route-id]:hover td,
tr[data-quality-flag]:hover td,
tr[data-venue]:hover td,
tr[data-outlier-coin]:hover td,
.selected-route td {
  background: #eef7f6;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-width: 58px;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 6px;
  background: #e2e8f0;
  color: #334155;
  font-weight: 700;
}

.status-ok {
  background: #dff3ea;
  color: #166534;
}

.status-stale {
  background: #fff1d6;
  color: #92400e;
}

.status-partial {
  background: #e0f2fe;
  color: #075985;
}

.status-missing {
  background: #fee2e2;
  color: #991b1b;
}

.status-degraded {
  background: #fff1d6;
  color: #92400e;
}

.status-blocking {
  background: #fee2e2;
  color: #991b1b;
}

.status-advisory {
  background: #e0f2fe;
  color: #075985;
}

th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
}

.chart-shell {
  padding: 12px;
  border-bottom: 1px solid #e5e7eb;
}

.ops-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 0;
}

.ops-grid table + table {
  border-left: 1px solid #e5e7eb;
}

.handoff-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  padding: 12px;
}

.handoff-item {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #f8fafc;
}

.handoff-wide {
  grid-column: span 2;
}

.handoff-label {
  display: block;
  margin-bottom: 6px;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.handoff-item code {
  display: block;
  overflow: hidden;
  color: #111827;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.handoff-wide code {
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
}

#spreadChart {
  display: block;
  width: 100%;
  height: 240px;
}

.alert-list {
  padding: 12px;
  min-height: 44px;
  font-size: 13px;
}

.alert-row {
  display: grid;
  grid-template-columns: 76px 72px 150px minmax(220px, 1fr) 150px;
  gap: 8px;
  align-items: center;
}

.alert-row + .alert-row {
  margin-top: 8px;
}

.alert-severity,
.alert-rule,
.alert-flags {
  overflow: hidden;
  color: #475569;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alert-severity {
  color: #92400e;
  font-weight: 700;
}

.alert-time {
  color: #64748b;
}

.alert-message {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  main {
    padding: 10px;
  }

  table {
    min-width: 760px;
  }

  .panel {
    overflow-x: auto;
  }

  .ops-grid {
    grid-template-columns: 1fr;
  }

  .handoff-grid {
    grid-template-columns: 1fr;
  }

  .handoff-wide {
    grid-column: span 1;
  }

  .ops-grid table + table {
    border-left: 0;
    border-top: 1px solid #e5e7eb;
  }

  .alert-row {
    grid-template-columns: 72px 70px minmax(180px, 1fr);
  }

  .alert-rule,
  .alert-flags {
    display: none;
  }
}
