:root {
  color-scheme: light;
  --surface-0: #f2f7f5;
  --surface-1: #fffffe;
  --surface-2: #e8f1ee;
  --surface-3: #d8e9e4;
  --border-subtle: #c7d8d2;
  --border-strong: #9db8b0;
  --text: #00473e;
  --text-muted: #475d5b;
  --text-soft: #6b837e;
  --primary: #faae2b;
  --primary-strong: #00473e;
  --primary-bg: rgba(250, 174, 43, 0.22);
  --success: #078062;
  --success-bg: rgba(7, 128, 98, 0.12);
  --warning: #9a5f00;
  --warning-bg: rgba(250, 174, 43, 0.28);
  --danger: #fa5246;
  --danger-bg: rgba(250, 82, 70, 0.14);
  --info: #d8779a;
  --info-bg: rgba(216, 119, 154, 0.16);
  --shadow: 0 18px 44px rgba(0, 71, 62, 0.14);
  --radius: 8px;
  --focus-ring: 0 0 0 3px rgba(250, 174, 43, 0.42);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface-0);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button,
a,
summary,
input {
  transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible,
input:focus-visible {
  outline: 0;
  box-shadow: var(--focus-ring);
}

.shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--border-subtle);
  background: #00473e;
  padding: 22px 18px;
}

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

.brand-mark {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(250, 174, 43, 0.82);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(250, 174, 43, 0.88), rgba(255, 168, 186, 0.54)),
    #f2f7f5;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 254, 0.42);
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--text-soft);
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav a {
  color: #cfe2dc;
  text-decoration: none;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
}

.nav a.active,
.nav a:hover {
  color: #fffffe;
  border-color: rgba(250, 174, 43, 0.48);
  background: rgba(250, 174, 43, 0.16);
}

.mobile-nav {
  display: none;
}

.workspace {
  min-width: 0;
  padding: 22px;
}

.topbar,
.metrics-strip,
.panel {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--surface-1);
  box-shadow: var(--shadow);
}

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

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 16px;
  line-height: 1.3;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 118px;
  min-height: 36px;
  border: 1px solid rgba(7, 128, 98, 0.36);
  border-radius: 999px;
  color: var(--success);
  background: var(--success-bg);
  padding: 8px 12px;
  white-space: nowrap;
}

.status-pill span {
  width: 8px;
  height: 8px;
  background: currentColor;
  border-radius: 50%;
}

.metrics-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 14px;
  overflow: hidden;
}

.metrics-strip article {
  min-width: 0;
  padding: 14px 16px;
  border-right: 1px solid var(--border-subtle);
}

.metrics-strip article:last-child {
  border-right: 0;
}

.metrics-strip span {
  display: block;
  color: var(--text-soft);
  font-size: 12px;
  text-transform: uppercase;
}

.metrics-strip strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
  line-height: 1.15;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.9fr);
  gap: 14px;
  margin-top: 14px;
}

.panel {
  min-width: 0;
  padding: 16px;
}

.wide {
  grid-column: 1 / -1;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.panel-header p,
.panel-header span {
  color: var(--text-soft);
  font-size: 13px;
  margin-top: 4px;
}

.compact {
  align-items: center;
}

.icon-button,
.text-button,
.ghost-button {
  min-height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--primary-bg);
  color: var(--primary-strong);
  cursor: pointer;
  font-weight: 600;
}

.icon-button {
  min-width: 36px;
  padding: 0 11px;
}

.icon-button.danger {
  color: var(--danger);
  border-color: rgba(250, 82, 70, 0.42);
  background: var(--danger-bg);
}

.text-button {
  padding: 0 14px;
}

.ghost-button {
  padding: 0 14px;
  background: var(--surface-2);
  color: var(--text-muted);
}

.icon-button:hover,
.text-button:hover,
.ghost-button:hover {
  background: rgba(250, 174, 43, 0.34);
  border-color: var(--primary);
  color: var(--text);
}

.icon-button.danger:hover {
  background: rgba(250, 82, 70, 0.2);
  border-color: var(--danger);
}

.text-button:disabled,
.icon-button:disabled,
.ghost-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

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

input {
  min-width: 250px;
  height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: #fffffe;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

input::placeholder {
  color: var(--text-soft);
}

.live-map {
  position: relative;
  min-height: 360px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(0, 71, 62, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 71, 62, 0.055) 1px, transparent 1px),
    #e8f1ee;
  background-size: 36px 36px;
  overflow: hidden;
}

.service-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(88px, 1fr));
  gap: 10px;
  padding: 16px;
}

.service-building {
  position: relative;
  min-height: 74px;
  text-align: left;
  color: var(--primary-strong);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: rgba(255, 255, 254, 0.82);
  padding: 10px;
}

.empty-state {
  grid-column: 1 / -1;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-muted);
  padding: 22px;
  text-align: center;
  background: rgba(255, 255, 254, 0.66);
}

.building-shape {
  width: 34px;
  height: 28px;
  margin: 0 0 8px;
  border: 1px solid currentColor;
  border-radius: 4px;
  background: currentColor;
  opacity: 0.24;
}

.building-shape::before,
.windows {
  display: none;
}

.windows span {
  width: 8px;
  height: 8px;
  background: currentColor;
  opacity: 0.45;
}

.service-building strong {
  display: block;
  color: var(--text);
  font-size: 12px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.service-building small {
  color: var(--text-muted);
}

.service-building.healthy {
  border-color: rgba(7, 128, 98, 0.35);
  color: var(--success);
}

.service-building.degraded {
  border-color: rgba(250, 174, 43, 0.58);
  color: var(--warning);
}

.service-building.unknown {
  border-color: rgba(216, 119, 154, 0.5);
  color: var(--info);
}

.traffic-stage {
  position: absolute;
  inset: 120px 0 0;
}

.gateway-node {
  position: absolute;
  left: 50%;
  top: 35%;
  transform: translate(-50%, -50%);
  width: 260px;
  text-align: center;
  color: var(--primary-strong);
}

.gateway-body {
  position: relative;
  height: 60px;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  background: var(--primary-bg);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 254, 0.44);
}

.lens {
  position: absolute;
  width: 42px;
  height: 42px;
  left: calc(50% - 21px);
  top: -24px;
  border-radius: 50%;
  border: 2px solid var(--danger);
  background: radial-gradient(circle, #fffffe, rgba(255, 168, 186, 0.72) 42%, transparent 62%);
}

.port {
  position: relative;
  display: inline-block;
  width: 10px;
  height: 10px;
  margin: 40px 8px 0;
  border-radius: 50%;
  background: var(--danger);
}

.antenna {
  position: absolute;
  top: -18px;
  width: 18px;
  height: 84px;
  border: 1px solid var(--primary);
  border-radius: 5px;
  background: rgba(250, 174, 43, 0.16);
}

.antenna.left {
  left: -20px;
}

.antenna.right {
  right: -20px;
}

.gateway-node strong {
  display: block;
  margin-top: 8px;
  color: var(--text);
  font-size: 14px;
}

.client-dots {
  position: absolute;
  left: 50%;
  bottom: 52px;
  transform: translateX(-50%);
  display: flex;
  gap: 72px;
}

.client-dots span {
  width: 42px;
  height: 42px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background:
    radial-gradient(circle, var(--text-soft) 2px, transparent 3px) 9px 9px / 11px 11px,
    rgba(255, 255, 254, 0.82);
}

.client-label {
  position: absolute;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  color: var(--text-soft);
  font-size: 11px;
  letter-spacing: 0.12em;
}

.counter {
  position: absolute;
  bottom: 94px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid currentColor;
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(255, 255, 254, 0.88);
}

.counter strong {
  color: var(--text);
  font-size: 16px;
}

.counter span {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 10px;
}

.counter.routed {
  left: 8%;
  color: var(--success);
}

.counter.blocked {
  right: 8%;
  color: var(--danger);
}

.pulse-line {
  position: absolute;
  left: 50%;
  bottom: 92px;
  width: 1px;
  height: 150px;
  transform-origin: bottom;
  background: linear-gradient(transparent, rgba(216, 119, 154, 0.5), transparent);
  opacity: 0.55;
}

.pulse-line.one {
  transform: rotate(-28deg);
}

.pulse-line.two {
  transform: rotate(0deg);
}

.pulse-line.three {
  transform: rotate(28deg);
}

.request-pulse {
  position: absolute;
  left: 50%;
  bottom: 100px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 16px var(--primary);
  animation: fly 1.1s linear infinite;
}

@keyframes fly {
  from {
    transform: translate(-50%, 0);
    opacity: 0;
  }
  18% {
    opacity: 1;
  }
  to {
    transform: translate(-50%, -150px);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

.alert-list,
.service-list {
  display: grid;
  gap: 10px;
}

.catalog-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.domain-discovery {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.domain-chip {
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  padding: 7px 10px;
  font-size: 12px;
  line-height: 1.2;
}

.domain-chip.discovered {
  color: var(--success);
  border-color: rgba(7, 128, 98, 0.36);
  background: var(--success-bg);
}

.domain-chip.not_discovered {
  color: var(--warning);
  border-color: rgba(250, 174, 43, 0.58);
  background: var(--warning-bg);
}

.catalog-stats article,
.alert-item,
.service-item,
.managed-service {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.catalog-stats article {
  min-width: 0;
  padding: 10px 12px;
}

.catalog-stats span {
  display: block;
  color: var(--text-soft);
  font-size: 11px;
  text-transform: uppercase;
}

.catalog-stats strong {
  display: block;
  margin-top: 5px;
  font-size: 19px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.alert-item,
.service-item {
  padding: 12px;
}

.alert-item strong,
.service-item strong {
  display: block;
  margin-bottom: 5px;
}

.alert-item p,
.service-item p {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.severity-critical {
  border-color: rgba(250, 82, 70, 0.45);
  background: linear-gradient(0deg, var(--danger-bg), var(--danger-bg)), var(--surface-2);
}

.severity-warning {
  border-color: rgba(250, 174, 43, 0.58);
  background: linear-gradient(0deg, var(--warning-bg), var(--warning-bg)), var(--surface-2);
}

.table-wrap {
  overflow: auto;
  max-height: 430px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
}

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

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  font-size: 13px;
  line-height: 1.4;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #d8e9e4;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 11px;
}

tbody tr:hover {
  background: rgba(250, 174, 43, 0.12);
}

.mono {
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  overflow-wrap: anywhere;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.ok {
  color: var(--success);
  background: var(--success-bg);
}

.warn {
  color: var(--warning);
  background: var(--warning-bg);
}

.bad {
  color: var(--danger);
  background: var(--danger-bg);
}

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

pre {
  max-height: 260px;
  overflow: auto;
  padding: 12px;
  margin: 0;
  border: 1px solid var(--border-subtle);
  border-radius: 0 0 var(--radius) var(--radius);
  background: #00473e;
  color: #f2f7f5;
  font-size: 12px;
  line-height: 1.5;
}

.service-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 8px;
}

.service-form label {
  color: var(--text-muted);
  font-size: 12px;
}

.service-form input {
  width: 100%;
  min-width: 0;
  margin-top: 5px;
}

.service-form button {
  align-self: end;
}

.connection-form {
  padding-bottom: 0;
}

.form-actions {
  display: flex;
  gap: 8px;
  align-self: end;
}

.form-actions button {
  align-self: auto;
}

.config-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.85fr);
  gap: 14px;
  align-items: start;
}

.config-block {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.config-block-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.config-block-header h3 {
  margin: 0;
  color: var(--text);
  font-size: 14px;
}

.config-block-header span,
.field-note {
  color: var(--text-muted);
  font-size: 12px;
}

.field-note {
  margin-bottom: 4px;
  line-height: 1.45;
}

.config-preview-panel {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
}

.config-preview-panel summary {
  cursor: pointer;
  color: var(--primary-strong);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.config-preview-panel:not([open]) summary {
  border-bottom: 0;
}

.gateway-status-card {
  display: grid;
  gap: 4px;
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.gateway-status-card span {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.managed-services {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.managed-service {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.managed-actions {
  display: flex;
  gap: 8px;
}

.managed-service strong,
.managed-service span {
  display: block;
}

.managed-title {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 4px;
}

.managed-title strong {
  margin-right: 2px;
}

.route-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.route-chip {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 2px 7px;
  color: var(--text-muted);
  background: rgba(255, 255, 254, 0.58);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.managed-service span {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 36px));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 254, 0.98);
  color: var(--text);
  padding: 11px 13px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.ok {
  border-color: rgba(7, 128, 98, 0.42);
}

.toast.bad {
  border-color: rgba(250, 82, 70, 0.5);
}

@media (max-width: 1120px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .mobile-nav {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    gap: 8px;
    margin-top: 14px;
    overflow-x: auto;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    background: rgba(255, 255, 254, 0.96);
    padding: 8px;
  }

  .mobile-nav a {
    flex: 0 0 auto;
    color: var(--text-muted);
    text-decoration: none;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 8px 10px;
  }

  .mobile-nav a:hover {
    color: var(--text);
    background: var(--surface-2);
  }

  .grid,
  .config-layout {
    grid-template-columns: 1fr;
  }

  .service-row {
    grid-template-columns: repeat(3, minmax(96px, 1fr));
  }

  .live-map {
    min-height: 430px;
  }

  .traffic-stage {
    inset: 190px 0 0;
  }
}

@media (max-width: 720px) {
  .workspace {
    padding: 12px;
  }

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

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

  .metrics-strip article {
    border-bottom: 1px solid var(--border-subtle);
  }

  .metrics-strip article:nth-child(2n) {
    border-right: 0;
  }

  .service-row,
  .catalog-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .live-map {
    min-height: 470px;
  }

  .traffic-stage {
    inset: 230px 0 0;
  }

  .gateway-node {
    width: min(210px, calc(100vw - 112px));
  }

  .client-dots {
    gap: 42px;
  }

  .counter {
    bottom: 88px;
    padding: 7px 9px;
  }

  .counter.routed {
    left: 4%;
  }

  .counter.blocked {
    right: 4%;
  }

  .panel-header {
    flex-direction: column;
  }

  input {
    width: 100%;
    min-width: 0;
  }

  .catalog-actions {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .service-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 460px) {
  h1 {
    font-size: 24px;
  }

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

  .metrics-strip article {
    border-right: 0;
  }

  .client-dots {
    gap: 22px;
  }

  .counter {
    font-size: 10px;
    gap: 6px;
  }
}
