:root {
  color-scheme: dark;
  --bg: #111034;
  --bg-2: #171640;
  --surface: #282a56;
  --surface-2: #22244d;
  --surface-3: #313362;
  --line: rgba(205, 213, 255, .12);
  --line-strong: rgba(205, 213, 255, .22);
  --text: #f3f4ff;
  --muted: #c4c7dc;
  --faint: #8d92b5;
  --traffic: #5bd5ff;
  --traffic-soft: rgba(91, 213, 255, .18);
  --errors: #ff626d;
  --latency: #62e57a;
  --peak: #ecd85c;
  --accent: #5ee16f;
  --ok: #62e57a;
  --ok-soft: rgba(98, 229, 122, .14);
  --warn: #ecd85c;
  --warn-soft: rgba(236, 216, 92, .14);
  --bad: #ff626d;
  --bad-soft: rgba(255, 98, 109, .14);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(91, 213, 255, .08), transparent 28rem),
    linear-gradient(135deg, var(--bg), #15123a 58%, #0f0e2c);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
input,
textarea {
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: rgba(17, 16, 52, .58);
  color: var(--text);
}

button {
  min-height: 38px;
  padding: 0 13px;
  font-weight: 850;
  cursor: pointer;
}

button:hover,
select:hover,
input:hover,
textarea:hover {
  border-color: rgba(91, 213, 255, .5);
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--traffic);
  outline-offset: 2px;
}

button {
  background: var(--traffic);
  border-color: var(--traffic);
  color: #08132d;
}

button.ghost,
.nav-item {
  background: transparent;
  color: var(--text);
}

canvas {
  display: block;
  width: 100%;
  max-width: 100%;
}

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

h1 {
  font-size: 34px;
  line-height: 1.05;
}

h2 {
  font-size: 20px;
  line-height: 1.2;
}

h3 {
  font-size: 15px;
}

p {
  color: var(--muted);
  font-size: 13px;
}

.shell {
  width: min(1780px, calc(100vw - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 0 28px;
}

.login-panel {
  width: min(760px, calc(100vw - 28px));
  margin: 10vh auto 0;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, .34);
}

.login-copy,
.sidebar-brand,
.panel-head,
.chart-head,
.view-head,
.form-actions,
.login-row,
.route-title,
.metric-pair {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-copy {
  align-items: flex-start;
  margin-bottom: 24px;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--accent);
  color: #0c1e20;
  font-weight: 950;
  font-size: 24px;
}

.brand {
  color: var(--text);
  font-weight: 950;
}

.login-form {
  display: grid;
  gap: 10px;
}

.login-form label,
.host-filter,
.time-control,
.sidebar-controls label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.login-row input {
  min-height: 40px;
  padding: 8px 10px;
  flex: 1 1 0;
  min-width: 0;
}

.login-row button:disabled {
  cursor: progress;
  opacity: .72;
}

.login-row input:disabled {
  opacity: .72;
}

.login-status {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.login-status.is-loading {
  color: var(--traffic);
}

.login-status.is-error {
  color: var(--bad);
}

.app-layout {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 18px;
  min-height: calc(100vh - 36px);
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 22px;
  padding: 18px;
  background: rgba(23, 22, 64, .78);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .28);
  backdrop-filter: blur(12px);
}

.sidebar-brand {
  min-width: 0;
}

.sidebar-brand > div:last-of-type {
  min-width: 0;
}

.mobile-menu-toggle {
  display: none;
  margin-left: auto;
}

.sidebar-menu {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 22px;
  min-height: 0;
}

.side-nav,
.sidebar-controls {
  display: grid;
  gap: 8px;
  align-content: start;
}

.nav-item {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  border-color: transparent;
}

.nav-item.active {
  background: var(--surface);
  border-color: var(--line-strong);
  box-shadow: inset 3px 0 0 var(--traffic);
}

.sidebar-controls select {
  min-height: 38px;
  padding: 0 10px;
}

.workspace {
  min-width: 0;
}

.view-panel {
  min-width: 0;
}

.view-head {
  display: block;
  margin-bottom: 16px;
}

.panel-actions {
  display: flex;
  align-items: end;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 10px;
}

.view-actions {
  display: grid;
  grid-template-columns: minmax(260px, 420px) minmax(260px, 1fr);
  align-items: end;
  gap: 10px;
  width: 100%;
  margin-top: 12px;
}

.view-actions-right {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  justify-self: end;
}

.eyebrow {
  color: var(--traffic);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.host-filter,
.time-control {
  display: grid;
  gap: 6px;
}

.host-filter {
  min-width: 0;
}

.host-filter select,
.time-control select {
  min-height: 40px;
  padding: 0 10px;
  width: 100%;
}

.time-control {
  min-width: 112px;
}

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

.kpi,
.chart-panel,
.config-panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.kpi {
  min-height: 136px;
  padding: 16px;
  display: grid;
  align-content: space-between;
}

.kpi-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.kpi-value {
  margin-top: 8px;
  color: var(--text);
  font-size: clamp(30px, 3.2vw, 54px);
  line-height: 1;
  font-weight: 950;
  overflow-wrap: anywhere;
}

.kpi-note {
  color: var(--muted);
  font-size: 12px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr) minmax(300px, .75fr);
  gap: 14px;
}

.chart-panel {
  padding: 16px;
}

.chart-wide {
  grid-column: span 2;
}

.health-panel {
  grid-row: span 2;
}

.chart-head {
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.chart-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.health-list,
.routes,
.host-workspace,
.users-layout {
  display: grid;
  gap: 10px;
}

.health-list {
  max-height: 550px;
  overflow: auto;
  padding-right: 2px;
}

.health-item,
.route-card {
  width: 100%;
  min-width: 0;
  display: grid;
  gap: 8px;
  padding: 12px;
  text-align: left;
  background: rgba(17, 16, 52, .34);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
}

.health-item {
  cursor: default;
}

.route-card.active {
  border-color: rgba(91, 213, 255, .75);
  box-shadow: inset 3px 0 0 var(--traffic);
}

.route-title {
  justify-content: space-between;
  align-items: flex-start;
}

.route-name {
  font-weight: 950;
  overflow-wrap: anywhere;
}

.route-host {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 950;
  white-space: nowrap;
}

.pill.ok {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: rgba(98, 229, 122, .28);
}

.pill.warn {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: rgba(236, 216, 92, .28);
}

.pill.bad {
  color: var(--bad);
  background: var(--bad-soft);
  border-color: rgba(255, 98, 109, .28);
}

.metric-pair {
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.hosts-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.host-workspace {
  align-content: start;
}

.host-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
  padding: 4px;
  background: rgba(17, 16, 52, .36);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.host-tab {
  min-height: 34px;
  padding: 0 16px;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.host-tab.active {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--traffic);
}

.host-tab-panel {
  min-height: 280px;
}

.config-panel {
  padding: 16px;
}

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

.routes {
  max-height: calc(100vh - 220px);
  overflow: auto;
  padding-right: 2px;
}

.route-form {
  display: grid;
  gap: 12px;
}

.route-form label,
.route-section legend,
.certificate-config legend {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.route-form input,
.route-form select,
.route-form textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--text);
  font-weight: 500;
}

.route-form textarea {
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.route-form input[type="file"] {
  padding: 7px 8px;
  color: var(--muted);
  border-style: dashed;
  font-size: 12px;
}

.route-form input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 6px 10px;
  color: var(--text);
  font-weight: 800;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(91, 213, 255, .12);
}

.route-section,
.certificate-config {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(17, 16, 52, .22);
}

.route-section legend,
.certificate-config legend {
  padding: 0 6px;
  color: var(--traffic);
  text-transform: uppercase;
}

.route-main-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.route-head-grid {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.host-entries {
  display: grid;
  gap: 18px;
}

.host-entry {
  position: relative;
  display: grid;
  gap: 12px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.host-entry:first-child {
  padding-top: 0;
  border-top: none;
}

.host-entry-head {
  display: flex;
  align-items: center;
}

.host-entry-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  text-transform: uppercase;
}

.remove-host-entry {
  position: absolute;
  top: 0;
  right: 0;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.remove-host-entry:hover,
.remove-host-entry:focus-visible {
  border-color: var(--bad);
  color: var(--bad);
  background: var(--bad-soft);
}

.field-hint {
  color: var(--faint);
  font-size: 12px;
}

.field-label {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  max-width: 100%;
}

.info-help {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  color: var(--traffic);
  font-size: 11px;
  font-weight: 950;
  line-height: 1;
  border: 1px solid rgba(91, 213, 255, .45);
  border-radius: 50%;
  background: rgba(91, 213, 255, .10);
}

.info-help::after {
  content: attr(data-help);
  position: absolute;
  z-index: 12;
  left: 50%;
  bottom: calc(100% + 8px);
  width: min(270px, calc(100vw - 48px));
  padding: 9px 10px;
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
  text-transform: none;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-50%) translateY(4px);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(10, 10, 28, .98);
  box-shadow: 0 14px 30px rgba(0, 0, 0, .35);
  transition: opacity .12s ease, transform .12s ease;
}

.info-help:hover::after,
.info-help:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.route-main-grid label:nth-child(3n) .info-help::after,
.form-grid label:nth-child(5n) .info-help::after,
.certificate-fields label:nth-child(2n) .info-help::after,
.certificate-fields-three label:nth-child(3n) .info-help::after {
  right: 0;
  left: auto;
  transform: translateY(4px);
}

.route-main-grid label:nth-child(3n) .info-help:hover::after,
.route-main-grid label:nth-child(3n) .info-help:focus-visible::after,
.form-grid label:nth-child(5n) .info-help:hover::after,
.form-grid label:nth-child(5n) .info-help:focus-visible::after,
.certificate-fields label:nth-child(2n) .info-help:hover::after,
.certificate-fields label:nth-child(2n) .info-help:focus-visible::after,
.certificate-fields-three label:nth-child(3n) .info-help:hover::after,
.certificate-fields-three label:nth-child(3n) .info-help:focus-visible::after {
  transform: translateY(0);
}

.certificate-panel {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(17, 16, 52, .28);
}

.certificate-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, .55fr);
  gap: 8px;
}

.certificate-fields-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.check {
  display: flex !important;
  align-items: center;
  gap: 8px;
}

.check input {
  width: auto;
  min-height: auto;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.danger {
  color: #fff;
  background: var(--bad);
  border-color: var(--bad);
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

.api-keys-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(340px, .95fr);
  gap: 14px;
  align-items: start;
}

.api-call-list {
  min-height: 160px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--faint);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.compact-table {
  font-size: 13px;
}

.compact-table th,
.compact-table td {
  padding: 9px 7px;
}

.selected-row {
  background: rgba(91, 213, 255, .08);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  color: var(--traffic);
}

td.path {
  max-width: 520px;
  overflow-wrap: anywhere;
}

td.actions-cell {
  min-width: 230px;
}

.table-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.table-action-row button {
  min-height: 32px;
  padding: 0 9px;
}

.table-action-row button:disabled {
  cursor: not-allowed;
  opacity: .5;
}

.owner-pill {
  margin-left: 6px;
  vertical-align: middle;
}

.log-stream {
  display: grid;
  gap: 8px;
}

.log-row {
  display: grid;
  grid-template-columns: 76px 64px auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding: 10px 12px;
  background: rgba(17, 16, 52, .34);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}

.log-time,
.log-meta {
  color: var(--faint);
}

.log-method {
  color: var(--traffic);
  font-weight: 900;
}

.log-path {
  min-width: 0;
  color: var(--text);
  overflow-wrap: anywhere;
}

.users-layout {
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  align-items: start;
}

.empty {
  color: var(--muted);
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 7px;
  background: rgba(17, 16, 52, .2);
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  background: #f3f4ff;
  color: #111034;
  border-radius: 7px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 7, 34, .74);
  backdrop-filter: blur(8px);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  width: min(460px, 100%);
  background: #2b2d60;
  border: 1px solid rgba(205, 213, 255, .18);
  border-radius: 8px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, .42);
  padding: 22px;
}

.modal-card.modal-wide {
  width: min(1040px, 100%);
  max-height: min(820px, calc(100vh - 40px));
  overflow: auto;
}

.modal-card h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.modal-card p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.45;
}

.modal-card label {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.modal-card input,
.modal-card select {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
}

.modal-form {
  display: grid;
  gap: 12px;
}

.modal-card .modal-check {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-card .modal-check input {
  width: auto;
  min-height: auto;
}

.modal-content {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.modal-calls {
  display: grid;
  gap: 10px;
}

.modal-subhead {
  display: grid;
  gap: 4px;
}

.modal-subhead h3 {
  color: var(--text);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 1280px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .health-panel {
    grid-row: auto;
  }
}

@media (max-width: 1040px) {
  .shell {
    width: min(100vw - 20px, 1780px);
    padding-top: 10px;
  }

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

  .sidebar {
    position: static;
    min-height: auto;
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .side-nav,
  .sidebar-controls {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .sidebar-controls label {
    display: none;
  }
}

@media (max-width: 820px) {
  .view-head,
  .login-row,
  .hosts-layout,
  .users-layout,
  .api-keys-layout,
  .dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

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

  .view-actions-right {
    justify-self: start;
  }

  .sidebar {
    gap: 12px;
    padding: 14px;
  }

  .sidebar-brand {
    justify-content: space-between;
  }

  .mobile-menu-toggle {
    display: inline-grid;
    place-items: center;
    min-width: 78px;
  }

  .sidebar-menu {
    display: none;
  }

  .sidebar.menu-open .sidebar-menu {
    display: grid;
    gap: 12px;
  }

  .sidebar.menu-open .side-nav,
  .sidebar.menu-open .sidebar-controls {
    grid-template-columns: 1fr;
  }

  .chart-wide {
    grid-column: auto;
  }

  .kpi-grid,
  .form-grid,
  .route-main-grid,
  .certificate-fields,
  .certificate-fields-three,
  .log-row {
    grid-template-columns: 1fr;
  }

  .routes {
    max-height: none;
  }
}

@media (max-width: 620px) {
  h1 {
    font-size: 28px;
  }

  .sidebar {
    padding: 14px;
  }

  .login-panel {
    margin-top: 24px;
  }
}
