:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --text: #1a1d23;
  --muted: #6b7280;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --green: #16a34a;
  --green-bg: #f0fdf4;
  --green-soft: #f7fdf9;
  --blue: #2563eb;
  --blue-bg: #eff6ff;
  --purple: #7c3aed;
  --purple-bg: #f5f3ff;
  --yellow: #ca8a04;
  --yellow-bg: #fefce8;
  --orange: #ea580c;
  --orange-bg: #fff7ed;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --gray: #9ca3af;
  --gray-bg: #f3f4f6;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

svg {
  display: block;
}

.page-shell {
  width: min(1200px, calc(100% - 48px));
  margin: 0 auto;
  padding: 20px 0 32px;
}

/* ── Top bar ── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  margin-bottom: 16px;
}

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

.brand-mark {
  display: block;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.18);
}

.eyebrow {
  margin: 0 0 1px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
}

.refresh {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: #4b5563;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gray);
}

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

.dot.slow {
  background: var(--yellow);
}

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

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

/* ── Overview banner ── */

.overview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 14px;
  padding: 18px 22px;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--green-soft), #ffffff);
}

.overview-main {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.status-symbol {
  display: grid;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 50%;
  background: var(--gray);
  color: #ffffff;
}

.status-symbol svg {
  width: 20px;
  height: 20px;
}

.status-symbol path,
.service-icon svg * {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.status-symbol.operational {
  background: var(--green);
}

.status-symbol.slow {
  background: var(--yellow);
}

.status-symbol.degraded {
  background: var(--orange);
}

.status-symbol.down {
  background: var(--red);
}

.overview h2 {
  margin-bottom: 3px;
  color: var(--green);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
}

.overview.slow h2 {
  color: var(--yellow);
}

.overview.degraded h2 {
  color: var(--orange);
}

.overview.down h2 {
  color: var(--red);
}

.overview p:last-child {
  max-width: 480px;
  margin-bottom: 0;
  color: #4b5563;
  font-size: 13px;
  font-weight: 400;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(90px, 1fr));
  gap: 10px;
  min-width: min(400px, 100%);
}

.metrics div {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 56px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.8);
  text-align: center;
}

.metrics span {
  color: var(--green);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
}

.metrics small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

/* ── Services panel ── */

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

.services-panel {
  overflow-x: auto;
}

.table-head,
.service-row {
  display: grid;
  grid-template-columns: 240px 82px 86px 86px 76px minmax(320px, 1fr) 88px;
  align-items: center;
  column-gap: 12px;
  min-width: 990px;
}

.table-head {
  height: 36px;
  padding: 0 16px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}

.service-list {
  padding: 0 8px 8px;
  min-width: 990px;
}

.service-row {
  height: 52px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-bottom-color: var(--border);
}

.service-row:last-child {
  border-bottom-color: transparent;
}

.service-row:hover {
  border-color: var(--border);
  border-radius: 6px;
  background: #f9fafb;
}

.service-divider {
  display: flex;
  align-items: center;
  min-width: 990px;
  height: 32px;
  margin: 6px 0 0;
  padding: 0 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.service-divider::before,
.service-divider::after {
  content: "";
  height: 1px;
  background: var(--border);
}

.service-divider::before {
  width: 12px;
  margin-right: 8px;
}

.service-divider::after {
  flex: 1;
  margin-left: 8px;
}

.service-cell {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}

.service-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.service-icon {
  display: grid;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 8px;
  color: var(--blue);
  background: var(--blue-bg);
}

.service-icon svg {
  width: 16px;
  height: 16px;
}

.service-icon-hk,
.service-icon-ai {
  color: var(--purple);
  background: var(--purple-bg);
}

.service-icon-kr {
  color: #157a3c;
  background: var(--green-bg);
}

.service-title {
  min-width: 0;
}

.service-title h3 {
  margin-bottom: 1px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}

.host,
.service-error {
  overflow: hidden;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.service-error {
  display: block;
  margin-top: 2px;
  color: var(--red);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.agent-latency {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.agent-latency.stale {
  opacity: 0.58;
}

.pending-text {
  color: var(--muted);
  background: var(--gray-bg);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.operational {
  background: var(--green-bg);
  color: var(--green);
}

.slow {
  background: var(--yellow-bg);
  color: var(--yellow);
}

.degraded {
  background: var(--orange-bg);
  color: var(--orange);
}

.down {
  background: var(--red-bg);
  color: var(--red);
}

.pending {
  background: var(--gray-bg);
  color: var(--gray);
}

.history {
  display: grid;
  grid-template-columns: repeat(44, minmax(2px, 1fr));
  gap: 2px;
  height: 18px;
}

.bar {
  height: 18px;
  border-radius: 2px;
  background: #e5e7eb;
}

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

.bar.slow {
  background: var(--yellow);
}

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

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

.bar.pending {
  background: #e5e7eb;
}

.build-cell {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
}

.build-cell strong {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.build-cell span {
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 400;
  white-space: nowrap;
}

/* ── Updates panel ── */

.updates-panel {
  margin-top: 12px;
  padding: 14px 18px 16px;
}

.section-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-title h2 {
  margin-bottom: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.section-title p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.updates-list {
  display: grid;
  gap: 6px;
}

.update-row {
  display: grid;
  grid-template-columns: minmax(170px, 0.85fr) minmax(160px, 0.75fr) minmax(220px, 1.3fr);
  align-items: center;
  gap: 12px;
  height: 44px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
}

.update-row small,
.version-change small {
  display: block;
  margin-bottom: 1px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
}

.update-row strong {
  font-size: 12px;
  font-weight: 500;
}

.version-change code {
  display: inline-flex;
  max-width: 120px;
  overflow: hidden;
  padding: 2px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #ffffff;
  color: var(--text);
  font-size: 11px;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.version-change span {
  margin: 0 6px;
  color: var(--muted);
  font-size: 11px;
}

.empty-updates {
  padding: 14px;
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  font-weight: 500;
}

/* ── Footer ── */

.history-actions {
  margin-top: 14px;
  text-align: center;
}

.history-actions p {
  margin-bottom: 0;
  color: #9ca3af;
  font-size: 11px;
  font-weight: 500;
}

/* ── Responsive ── */

@media (max-width: 1200px) {
  .table-head,
  .service-row {
    grid-template-columns: 220px 82px 86px 86px minmax(280px, 1fr) 88px;
    min-width: 880px;
  }

  .service-list,
  .service-divider {
    min-width: 880px;
  }

  .table-head span:nth-child(5),
  .uptime-cell {
    display: none;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(90px, 1fr));
  }
}

@media (max-width: 900px) {
  .page-shell {
    width: min(100% - 24px, 1200px);
    padding-top: 12px;
  }

  .topbar,
  .overview,
  .section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .refresh {
    width: fit-content;
  }

  .overview-main {
    align-items: flex-start;
  }

  .table-head {
    display: none;
  }

  .service-list {
    padding: 6px;
    min-width: 0;
  }

  .service-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
    gap: 10px;
    height: auto;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 6px;
  }

  .service-row:last-child {
    margin-bottom: 0;
    border-bottom-color: var(--border);
  }

  .service-identity,
  .history-cell {
    grid-column: 1 / -1;
  }

  .service-divider {
    min-width: 0;
  }

  .history {
    grid-template-columns: repeat(44, minmax(2px, 1fr));
  }

  .update-row {
    grid-template-columns: 1fr;
    height: auto;
    padding: 10px;
  }
}

@media (max-width: 560px) {
  .page-shell {
    width: min(100% - 16px, 1200px);
  }

  .brand-mark {
    width: 30px;
    height: 30px;
  }

  h1 {
    font-size: 16px;
  }

  .overview {
    padding: 14px;
  }

  .overview-main {
    gap: 12px;
  }

  .status-symbol {
    width: 34px;
    height: 34px;
  }

  .status-symbol svg {
    width: 18px;
    height: 18px;
  }

  .metrics,
  .service-row {
    grid-template-columns: 1fr;
  }

  .host,
  .service-error {
    white-space: normal;
  }

  .history {
    grid-template-columns: repeat(44, minmax(2px, 1fr));
    gap: 1px;
  }

  .bar {
    height: 14px;
  }

  .updates-panel {
    padding: 12px;
  }
}
