:root {
  color-scheme: dark;
  --bg: #0b1020;
  --panel: #111827;
  --panel-2: #141e31;
  --line: #263244;
  --text: #e5eefb;
  --muted: #94a3b8;
  --good: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --info: #38bdf8;
  --accent: #2dd4bf;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Noto Sans TC", system-ui, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 16, 32, 0.94);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--accent);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
}

.status-pill.good {
  border-color: rgba(34, 197, 94, 0.45);
  color: #86efac;
}

.status-pill.warn {
  border-color: rgba(245, 158, 11, 0.55);
  color: #fcd34d;
}

.status-pill.bad {
  border-color: rgba(239, 68, 68, 0.55);
  color: #fca5a5;
}

.status-pill.muted {
  color: var(--muted);
}

.layout {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 22px 24px 40px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric-card {
  min-height: 116px;
  padding: 16px;
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
  line-height: 1.1;
}

.metric-card small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.panel {
  margin-bottom: 18px;
}

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

.panel-header h2 {
  margin: 0;
  font-size: 16px;
}

.panel-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.65fr);
  gap: 18px;
}

.split .panel {
  margin-bottom: 0;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

.table-wrap.tall {
  max-height: 620px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  position: sticky;
  top: 0;
  background: var(--panel-2);
  color: #cbd5e1;
  font-weight: 600;
}

td {
  color: #dbeafe;
}

tr:last-child td {
  border-bottom: 0;
}

.filter-input,
.metric-select {
  width: min(260px, 100%);
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f172a;
  color: var(--text);
  padding: 7px 10px;
}

.value {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.source {
  color: var(--muted);
  font-size: 12px;
}

.temp-hot {
  color: #fca5a5;
}

.temp-warm {
  color: #fcd34d;
}

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

.chart {
  min-height: 358px;
  padding: 16px;
}

.chart svg {
  display: block;
  width: 100%;
  height: 326px;
}

.chart text {
  fill: var(--muted);
  font-size: 12px;
}

@media (max-width: 1080px) {
  .summary-grid,
  .split {
    grid-template-columns: 1fr 1fr;
  }

  .split {
    display: block;
  }

  .split .panel + .panel {
    margin-top: 18px;
  }
}

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

  .layout {
    padding: 16px;
  }

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

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }
}
