:root {
  --bg: #0a1118;
  --surface: #111c26;
  --surface-2: #162330;
  --surface-3: #1b2a38;
  --border: #243544;
  --text: #e6edf3;
  --muted: #8ea4b6;
  --ok: #6dd58c;
  --warn: #ffce56;
  --bad: #ff4d6d;
  --accent: #4db6ff;
  --radius: 10px;
  --space: 1rem;
}

.text-h1 {
  font-size: clamp(1.3rem, 3vw, 2rem);
  font-weight: 700;
}

.text-h2 {
  font-size: 1.05rem;
  font-weight: 650;
}

.text-h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.text-body {
  font-size: 0.9rem;
}

.text-sm {
  font-size: 0.82rem;
}

.text-caption {
  font-size: 0.74rem;
  color: var(--muted);
}

.stack {
  display: grid;
}

.stack-sm {
  gap: 0.4rem;
}

.stack-md {
  gap: 0.8rem;
}

.stack-lg {
  gap: 1.2rem;
}

.btn {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.btn-sm {
  padding: 0.3rem 0.55rem;
  font-size: 0.76rem;
}

.btn-md {
  padding: 0.42rem 0.72rem;
  font-size: 0.82rem;
}

.btn-lg {
  padding: 0.55rem 0.9rem;
  font-size: 0.9rem;
}

.btn-primary {
  border-color: rgba(77, 182, 255, 0.55);
  background: rgba(77, 182, 255, 0.18);
}

.btn-ghost {
  background: transparent;
}

.btn-outline {
  background: rgba(255, 255, 255, 0.02);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 5% 0%, rgba(77, 182, 255, 0.13), transparent 30%),
    radial-gradient(
      circle at 90% 10%,
      rgba(109, 213, 140, 0.11),
      transparent 26%
    ),
    var(--bg);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: var(--space);
  align-items: flex-end;
  padding: 1.2rem 1.4rem;
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.3rem, 3vw, 2rem);
}

.topbar p {
  margin: 0.3rem 0 0;
  color: var(--muted);
}

.topbar-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.topbar-controls label,
.filter-control {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.topbar-controls select,
.filters select,
.filters input,
button[data-action],
[data-ui="auto-refresh"] {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 0.34rem 0.56rem;
}

.summary {
  margin: 0;
  font-size: 0.86rem;
}

.status-strip,
.filters {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.8rem 1.4rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
}

.drilldown-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.7rem 1.4rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.015);
}

.drilldown-nav p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.drilldown-actions {
  display: flex;
  gap: 0.5rem;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  padding: 0.35rem 0.58rem;
  font-size: 0.78rem;
}

.status-chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.status-chip.ok {
  background: rgba(109, 213, 140, 0.11);
  border-color: rgba(109, 213, 140, 0.36);
}

.status-chip.warn {
  background: rgba(255, 206, 86, 0.11);
  border-color: rgba(255, 206, 86, 0.36);
}

.status-chip.bad {
  background: rgba(255, 77, 109, 0.12);
  border-color: rgba(255, 77, 109, 0.36);
}

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

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

.status-chip.bad .dot {
  background: var(--bad);
}

.dashboard-grid {
  max-width: 1460px;
  margin: 1rem auto 2rem;
  padding: 0 1.3rem;
  display: grid;
  gap: 1rem;
}

.section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space);
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, rgba(77, 182, 255, 0.1), transparent 35%);
}

.section-header h2 {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.section-content {
  padding: 0.9rem;
}

.section-content.is-collapsed {
  display: none;
}

[data-ui="section-details"].is-collapsed {
  display: none;
}

.panel-grid {
  display: grid;
  gap: 0.8rem;
}

.panel-grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.panel-grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem;
}

.panel > header {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.55rem;
}

.panel > header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
}

.panel > header strong {
  font-size: 1rem;
}

.panel > p {
  margin: 0;
  font-size: 0.85rem;
}

.panel > small {
  display: block;
  margin-top: 0.45rem;
  color: var(--muted);
}

.metric-bar {
  display: grid;
  grid-template-columns: 70px 1fr 44px;
  gap: 0.45rem;
  align-items: center;
  font-size: 0.82rem;
  margin-bottom: 0.42rem;
}

.metric-bar .bar-track {
  background: #0d1720;
  border-radius: 999px;
  border: 1px solid #1c2a36;
  height: 8px;
}

.metric-bar .bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.metric-bar[data-tone="cpu"] .bar-fill {
  background: var(--ok);
}

.metric-bar[data-tone="mem"] .bar-fill {
  background: var(--warn);
}

.metric-bar[data-tone="disk"] .bar-fill {
  background: #ffa860;
}

.metric-bar .pct {
  color: var(--muted);
  text-align: right;
  font-style: normal;
}

.node-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.domain-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.domain-card {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 0.75rem;
}

.domain-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.domain-card h3 {
  margin: 0;
  font-size: 0.95rem;
}

.domain-card p {
  color: var(--muted);
  margin: 0.55rem 0;
  font-size: 0.82rem;
}

.domain-card .ok {
  color: var(--ok);
}

.domain-card .warn {
  color: var(--warn);
}

.domain-card.is-active {
  border-color: rgba(77, 182, 255, 0.65);
  box-shadow: 0 0 0 1px rgba(77, 182, 255, 0.25) inset;
}

.service-drilldown {
  display: grid;
  gap: 0.8rem;
}

.service-detail-stack {
  display: grid;
  gap: 0.8rem;
}

.node-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 0.7rem;
  min-width: 180px;
  cursor: pointer;
  transition:
    box-shadow 150ms ease,
    transform 120ms ease;
  outline: none;
}

.node-card:focus,
.node-card:hover {
  box-shadow: 0 8px 24px rgba(2, 6, 23, 0.12);
  transform: translateY(-2px);
  border-color: rgba(77, 182, 255, 0.12);
}

.node-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.node-title {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}

.node-name {
  font-size: 0.95rem;
  line-height: 1;
}

.node-role {
  color: var(--muted);
  font-size: 0.8rem;
}

.node-card-metrics {
  display: grid;
  gap: 0.45rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
}

@media (max-width: 520px) {
  .node-card-metrics {
    grid-template-columns: 1fr;
  }
}

.node-card-meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.node-card-footer {
  display: flex;
  justify-content: flex-end;
}

.node-card:focus-visible {
  box-shadow: 0 0 0 3px rgba(77, 182, 255, 0.12);
  border-color: rgba(77, 182, 255, 0.18);
}

.node-card.ok {
  border-left: 3px solid var(--ok);
}

.node-card.warn {
  border-left: 3px solid var(--warn);
}

.node-card.bad {
  border-left: 3px solid var(--bad);
}

/* modal (native <dialog>) styling */
.modal {
  border: none;
  border-radius: 10px;
  padding: 0;
  width: min(880px, 96%);
  max-height: 92vh;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(2, 6, 23, 0.6);
  background: var(--surface-3);
  color: inherit;
}

.modal.modal-sm {
  width: min(520px, 96%);
}

.modal.modal-md {
  width: min(880px, 96%);
}

.modal.modal-lg {
  width: min(1120px, 98%);
}

.modal.modal-danger .modal-header h3 {
  color: var(--bad);
}

.modal::backdrop {
  background: rgba(2, 6, 23, 0.6);
  backdrop-filter: blur(2px);
}

.modal .modal-content {
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.modal header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal .modal-header {
  padding-bottom: 0.35rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.modal h3 {
  margin: 0;
  font-size: 1.05rem;
}

/* modal body becomes a responsive grid so node details and raw output can sit side-by-side */
.modal .modal-body {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
  max-height: 60vh;
  overflow: auto;
  padding-bottom: 0.5rem;
}

@media (min-width: 780px) {
  .modal .modal-body {
    grid-template-columns: 1fr 320px;
  }
  .node-modal-raw {
    grid-column: 2;
  }
}

.modal footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.modal .modal-footer {
  position: sticky;
  bottom: 0;
  background: var(--surface-3);
}

.modal .modal-close {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--muted);
}
.modal .modal-close:focus {
  outline: 2px solid rgba(77, 182, 255, 0.28);
  border-radius: 4px;
}

/* node-modal specific */
.node-modal-overview {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}
.node-modal-title {
  margin: 0;
  font-size: 1.05rem;
}
.node-modal-state [data-ui="badge"] {
  font-weight: 600;
  text-transform: uppercase;
}
.node-modal-stats {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 0.5rem;
}
.node-modal-stats .metric-bar {
  margin: 0;
}
.node-modal-pods {
  margin-bottom: 0.5rem;
}
.node-modal-raw pre {
  margin: 0;
  padding: 0.6rem;
  border-radius: 6px;
  background: var(--surface-2);
  font-size: 0.86rem;
  overflow: auto;
}

@media (max-width: 520px) {
  .node-modal-stats {
    grid-template-columns: 1fr;
  }
}

.chart-wrap {
  min-height: 180px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

th,
td {
  text-align: left;
  padding: 0.4rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

[data-ui="badge"] {
  display: inline-flex;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.75rem;
}

[data-ui="badge"][data-state="ok"] {
  color: var(--ok);
}

[data-ui="badge"][data-state="warn"] {
  color: var(--warn);
}

[data-ui="badge"][data-state="bad"] {
  color: var(--bad);
}

.issues {
  margin: 0;
  padding-left: 1rem;
  display: grid;
  gap: 0.35rem;
}

.issues li[data-state="warn"] {
  color: var(--warn);
}

.issues li[data-state="bad"] {
  color: var(--bad);
}

.row-issue {
  background: rgba(255, 255, 255, 0.02);
}

.row-issue.warn {
  box-shadow: inset 3px 0 0 rgba(255, 206, 86, 0.7);
}

.row-issue.bad {
  box-shadow: inset 3px 0 0 rgba(255, 77, 109, 0.7);
}

[data-ui="auto-refresh"].active {
  border-color: rgba(77, 182, 255, 0.5);
  color: var(--accent);
}

.is-hidden {
  display: none !important;
}

.netdash {
  display: grid;
  gap: 0.9rem;
}

.netdash-filters {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
}

.netdash-filters input[type="search"] {
  margin-left: 0.3rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 0.3rem 0.45rem;
}

.netdash-metrics-hint {
  margin: 0;
  color: var(--warn);
  font-size: 0.8rem;
}

.netdash-cards {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.netdash-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem;
  background: var(--surface-2);
}

.netdash-card header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.netdash-card.ok {
  border-color: rgba(109, 213, 140, 0.4);
}

.netdash-card.warn {
  border-color: rgba(255, 206, 86, 0.5);
}

.netdash-card.bad {
  border-color: rgba(255, 77, 109, 0.5);
}

.netdash-grid-two {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.netdash-table-wrap {
  overflow: auto;
}

.netdash-graph {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.netdash-graph-proxy {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  background: rgba(255, 255, 255, 0.02);
}

.netdash-pill {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.05rem 0.35rem;
  font-size: 0.72rem;
  margin-right: 0.35rem;
  color: var(--muted);
}

.netdash-tree details {
  border-left: 2px solid rgba(77, 182, 255, 0.3);
  padding-left: 0.55rem;
  margin-bottom: 0.45rem;
}

.is-flash {
  animation: flash 0.9s ease;
}

.wg-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-end;
  padding: 1.2rem 1.4rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, rgba(77, 182, 255, 0.12), transparent 45%);
}

.wg-header h1 {
  margin: 0;
}

.wg-header p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.wg-header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.wg-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.wg-graph-canvas {
  min-height: 160px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.005));
  padding: 0.75rem;
}

.wg-edge-list {
  display: grid;
  gap: 0.45rem;
}

.wg-edge-row {
  display: grid;
  grid-template-columns: 140px 1fr auto;
  gap: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  background: var(--surface-2);
  font-size: 0.82rem;
  align-items: center;
}

.wg-edge-type {
  display: inline-flex;
  justify-content: center;
  border: 1px solid rgba(77, 182, 255, 0.4);
  border-radius: 999px;
  padding: 0.12rem 0.4rem;
  color: var(--accent);
  font-size: 0.74rem;
}

.wg-node-list {
  display: grid;
  gap: 0.55rem;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}

.wg-node-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 0.55rem;
}

.wg-node-card h3 {
  margin: 0 0 0.4rem;
  font-size: 0.9rem;
}

.wg-node-card p {
  margin: 0.2rem 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.wg-validation-list {
  display: grid;
  gap: 0.5rem;
}

.wg-validation {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  display: grid;
  gap: 0.2rem;
  background: var(--surface-2);
}

.wg-validation.ok {
  border-color: rgba(109, 213, 140, 0.45);
}

.wg-validation.warn {
  border-color: rgba(255, 206, 86, 0.45);
}

.wg-actions-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.65rem;
}

.wg-action-log {
  margin: 0;
  padding: 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0d1720;
  min-height: 130px;
  overflow: auto;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: pre-wrap;
}

@keyframes flash {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
  }
  30% {
    box-shadow: 0 0 0 6px rgba(77, 182, 255, 0.16);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
  }
}

@media (max-width: 980px) {
  .panel-grid.cols-4,
  .panel-grid.cols-2 {
    grid-template-columns: 1fr;
  }

  .netdash-grid-two {
    grid-template-columns: 1fr;
  }

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

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

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

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

  .wg-edge-row {
    grid-template-columns: 1fr;
  }
}
