:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-soft: #fbfcfe;
  --surface-map: #f8fafc;
  --border: #d8e0ea;
  --border-soft: #e0e7ef;
  --text: #162033;
  --muted: #637083;
  --button-bg: #ffffff;
  --shadow: rgba(22, 32, 51, 0.06);
  --log-bg: #111827;
  --log-text: #d7dde8;
  --zone-ui: #f6f9ff;
  --zone-core: #fbfcfe;
  --zone-external: #fffaf0;
  background: var(--bg);
  color: var(--text);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f141b;
  --surface: #171d26;
  --surface-soft: #1d2530;
  --surface-map: #121821;
  --border: #2b3543;
  --border-soft: #334052;
  --text: #e7edf5;
  --muted: #9aa7b6;
  --button-bg: #202938;
  --shadow: rgba(0, 0, 0, 0.28);
  --log-bg: #080b10;
  --log-text: #d7dde8;
  --zone-ui: #142033;
  --zone-core: #151c26;
  --zone-external: #251f13;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

button {
  border: 1px solid var(--border);
  background: var(--button-bg);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 12px;
  font: inherit;
  cursor: pointer;
}

button:hover {
  border-color: var(--muted);
}

.shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

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

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}

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

h1 {
  margin-bottom: 0;
  font-size: 30px;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

h3 {
  margin-bottom: 8px;
  font-size: 16px;
}

.status-card,
.panel,
.summary-card,
.service-button {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 2px var(--shadow);
}

.theme-toggle {
  min-width: 86px;
  font-weight: 800;
}

.status-card {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  font-weight: 700;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #9aa7b6;
}

.dot.ok {
  background: #1f9d61;
}

.dot.degraded {
  background: #c98313;
}

.dot.down {
  background: #c93535;
}

.dot.muted {
  background: #9aa7b6;
}

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

.summary-card {
  padding: 14px;
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.summary-card strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
}

.layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.panel {
  padding: 16px;
}

.map-panel {
  margin-bottom: 14px;
}

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

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

.service-button {
  width: 100%;
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 12px;
}

.service-button.active {
  border-color: #3f6fb5;
  box-shadow: 0 0 0 2px rgba(63, 111, 181, 0.16);
}

.service-title {
  font-weight: 800;
}

.service-role,
.meta,
.check-target {
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  background: #edf2f7;
  color: #526173;
}

.badge.ok {
  background: #e5f7ee;
  color: #177346;
}

.badge.degraded {
  background: #fff3d8;
  color: #8f5b00;
}

.badge.down {
  background: #ffe7e7;
  color: #9d2424;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.info-box,
.check-row,
.container-row,
.link-row {
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
}

.check-row,
.container-row,
.link-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.checks,
.links,
.containers {
  display: grid;
  gap: 8px;
}

.service-map {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--surface-map);
  -webkit-overflow-scrolling: touch;
}

.service-map svg {
  display: block;
  min-width: 860px;
  width: 100%;
  height: auto;
}

.map-zone {
  fill: var(--surface);
  stroke: var(--border);
  stroke-width: 1;
}

.map-zone-ui {
  fill: var(--zone-ui);
}

.map-zone-core {
  fill: var(--zone-core);
}

.map-zone-external {
  fill: var(--zone-external);
}

.map-zone-label {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.map-link {
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  marker-end: url(#arrow);
}

.map-link.active {
  stroke: #3f6fb5;
  stroke-width: 3;
}

.map-node {
  cursor: pointer;
}

.map-node rect {
  fill: var(--surface);
  stroke: var(--border);
  stroke-width: 1.5;
  filter: drop-shadow(0 1px 1px rgba(22, 32, 51, 0.08));
}

.map-node:hover rect,
.map-node.active rect {
  stroke: #3f6fb5;
  stroke-width: 2.5;
}

.map-node-title {
  fill: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.map-node-meta {
  fill: var(--muted);
  font-size: 11px;
}

.empty,
.error {
  color: var(--muted);
}

.error {
  color: #9d2424;
}

.logs-panel {
  margin-top: 14px;
  border-top: 1px solid var(--border-soft);
  padding-top: 14px;
}

.log-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.log-actions select {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--button-bg);
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 10px;
  background: var(--button-bg);
  font-size: 13px;
  font-weight: 800;
}

.log-filters {
  display: grid;
  grid-template-columns: minmax(180px, 1.6fr) minmax(120px, 0.7fr) minmax(170px, 1fr) minmax(170px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}

.log-filters label {
  display: grid;
  gap: 5px;
}

.log-filters span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.log-filters input,
.log-filters select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--button-bg);
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
}

.log-output {
  min-height: 240px;
  max-height: 520px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  background: var(--log-bg);
  color: var(--log-text);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 980px) {
  .shell {
    width: min(100% - 20px, 720px);
    padding: 14px 0 28px;
  }

  h1 {
    font-size: 24px;
  }

  .summary-grid,
  .layout,
  .details-grid,
  .log-filters {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-card,
  .theme-toggle {
    width: 100%;
    justify-content: center;
  }

  .summary-card {
    padding: 12px;
  }

  .summary-card strong {
    font-size: 22px;
  }

  .panel {
    padding: 12px;
  }

  .panel-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .service-map svg {
    min-width: 760px;
  }

  .service-button {
    grid-template-columns: 14px minmax(0, 1fr);
  }

  .service-button .badge {
    grid-column: 2;
    width: max-content;
  }

  .check-row,
  .container-row,
  .link-row {
    grid-template-columns: 1fr;
  }

  .log-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 82px 1fr;
  }

  .log-output {
    min-height: 190px;
    max-height: 360px;
    font-size: 11px;
  }
}

@media (max-width: 520px) {
  .shell {
    width: min(100% - 12px, 520px);
    padding-top: 10px;
  }

  .service-map svg {
    min-width: 700px;
  }

  .log-actions {
    grid-template-columns: 1fr;
  }

  button,
  .log-filters input,
  .log-filters select,
  .log-actions select,
  .switch {
    min-height: 42px;
  }
}
