:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --ok: #10b981;
  --warn: #f59e0b;
  --down: #ef4444;
  --maint: #94a3b8;
  --unknown: #cbd5e1;
}

[data-bs-theme="dark"] {
  --bg: #0f172a;
  --surface: #111827;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --border: #1f2937;
  --unknown: #334155;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, sans-serif;
}

.page-shell {
  max-width: 820px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.topbar,
.panel-header,
.service-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  margin-bottom: 16px;
}

.brand,
.panel-title,
.summary-title,
.service-name {
  margin: 0;
}

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

.theme-toggle {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.summary,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.summary {
  margin-bottom: 16px;
}

.summary-title {
  padding: 12px 14px;
  font-size: 16px;
  background: rgba(16, 185, 129, 0.12);
}

.summary-text,
.panel-header,
.service-row {
  padding: 12px 14px;
}

.summary-text,
.service-row,
.panel-header {
  border-top: 1px solid var(--border);
}

.summary .summary-text {
  border-top: 0;
}

.panel-title {
  font-size: 16px;
}

.panel-subtitle,
.status-label,
.service-meta {
  color: var(--muted);
  font-size: 13px;
}

.service-row + .service-row {
  border-top: 1px solid var(--border);
}

.service-line {
  justify-content: flex-start;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.service-name {
  font-size: 15px;
  font-weight: 600;
}

.service-meta {
  margin-left: auto;
}

.service-action {
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.dot-operational {
  background: var(--ok);
}

.dot-degraded {
  background: var(--warn);
}

.dot-outage {
  background: var(--down);
}

.dot-maintenance {
  background: var(--maint);
}

.dot-unknown {
  background: var(--unknown);
}

.mini-bars {
  display: grid;
  grid-template-columns: repeat(60, minmax(0, 1fr));
  gap: 3px;
}

.mini-bar {
  height: 16px;
  border-radius: 2px;
}

.bar-operational {
  background: var(--ok);
}

.bar-degraded {
  background: var(--warn);
}

.bar-outage {
  background: var(--down);
}

.bar-maintenance {
  background: var(--maint);
}

.bar-unknown {
  background: var(--unknown);
}

.empty-history {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
}

.records-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.records-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.records-panel {
  position: relative;
  z-index: 1;
  width: min(720px, calc(100% - 24px));
  max-height: calc(100vh - 40px);
  margin: 20px auto;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

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

.records-list {
  padding: 0 14px 14px;
}

.record-row {
  display: grid;
  grid-template-columns: 160px 110px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

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

.record-time,
.record-latency {
  color: var(--muted);
  font-size: 13px;
}

.record-status {
  font-weight: 600;
}

.record-empty {
  padding: 14px 0;
  color: var(--muted);
}

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

  .service-meta {
    margin-left: 0;
    width: 100%;
  }

  .record-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
