:root {
  color-scheme: dark;
  --bg: #03050a;
  --bg-grid: rgba(68, 118, 255, .08);
  --panel: rgba(9, 16, 30, .88);
  --panel-strong: rgba(12, 24, 43, .94);
  --line: #23375d;
  --line-hot: #2dd9ff;
  --text: #eaf3ff;
  --muted: #8fa4c2;
  --subtle: #526781;
  --cyan: #2dd9ff;
  --blue: #4b7bff;
  --green: #51ffb6;
  --amber: #ffd166;
  --red: #ff4d7d;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(45, 217, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(45, 217, 255, .026) 1px, transparent 1px),
    radial-gradient(circle at 18% -6%, rgba(45, 217, 255, .18), transparent 34%),
    radial-gradient(circle at 88% 6%, rgba(81, 255, 182, .11), transparent 30%),
    linear-gradient(180deg, #06101b 0%, var(--bg) 38%, #010208 100%);
  background-size: 36px 36px, 36px 36px, auto, auto, auto;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(45,217,255,.045) 50%, transparent);
  mix-blend-mode: screen;
  opacity: .35;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(1, 4, 10, .82);
  backdrop-filter: blur(14px);
}
.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  border: 1px solid rgba(45, 217, 255, .34);
  border-radius: 8px;
  padding: 22px;
  background: linear-gradient(135deg, rgba(8, 18, 32, .97), rgba(5, 9, 18, .94));
  box-shadow: 0 28px 90px rgba(0,0,0,.56), 0 0 44px rgba(45,217,255,.09);
}
.login-card h2 {
  font-size: 20px;
  text-transform: none;
  letter-spacing: 0;
}
.login-card p {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.45;
}
.login-error {
  min-height: 18px;
  color: var(--red);
}

.shell {
  width: min(1880px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 20px 0 26px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border: 1px solid rgba(45, 217, 255, .16);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px;
  background: linear-gradient(135deg, rgba(8, 18, 32, .92), rgba(5, 9, 18, .8));
  box-shadow: 0 0 0 1px rgba(45, 217, 255, .04), 0 24px 70px rgba(0,0,0,.35);
}
h1, h2, p { margin: 0; }
h1 { font-size: 30px; letter-spacing: 0; line-height: 1; }
.product-kicker {
  color: var(--cyan);
  font-size: 13px;
  font-weight: 600;
  margin-left: 10px;
}
h2 { font-size: 14px; color: #f7fbff; text-transform: uppercase; letter-spacing: .04em; }
p, label, .status-pill, span { color: var(--muted); }
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.lang-switch {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid rgba(45, 217, 255, .32);
  border-radius: 999px;
  padding: 3px;
  background: rgba(5, 12, 22, .82);
}
.lang-switch button {
  min-width: 42px;
  border: 0;
  border-radius: 999px;
  padding: 6px 9px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}
.lang-switch button:hover {
  color: #fff;
  box-shadow: none;
}
.lang-switch button.is-active {
  background: linear-gradient(135deg, rgba(45,217,255,.95), rgba(81,255,182,.95));
  color: #03101d;
}

.grid {
  display: grid;
  grid-template-columns: minmax(860px, 1fr) minmax(440px, 540px);
  gap: 18px;
  align-items: start;
}
.panel {
  background: var(--panel);
  border: 1px solid rgba(78, 111, 177, .62);
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03), 0 24px 80px rgba(0,0,0,.38);
  padding: 18px;
  backdrop-filter: blur(12px);
}
.panel-main { display: grid; gap: 16px; }
.side {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 12px;
  align-content: start;
}
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-title.compact { margin-top: 10px; padding-top: 12px; border-top: 1px solid rgba(78, 111, 177, .32); }
.section-title.flush { margin-top: 0; padding-top: 0; border-top: 0; }
.status-pill, .section-title span {
  border: 1px solid rgba(45, 217, 255, .32);
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(5, 12, 22, .82);
  color: #b7c9e4;
}
.session-pill {
  color: var(--green);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

label { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; margin-bottom: 6px; }
.help-label { cursor: help; }
.help-label::after {
  content: "?";
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border: 1px solid rgba(45,217,255,.4);
  border-radius: 50%;
  color: var(--cyan);
  font-size: 11px;
  line-height: 1;
}

input, textarea, select {
  width: 100%;
  border: 1px solid #293f66;
  background: rgba(3, 8, 16, .9);
  color: var(--text);
  border-radius: 7px;
  padding: 10px 11px;
  outline: none;
  font: inherit;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.015);
}
textarea {
  resize: vertical;
  min-height: 44px;
  overflow: hidden;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(45,217,255,.12), 0 0 28px rgba(45,217,255,.08);
}
.route-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 14px;
  align-items: end;
}
.desktop-fields {
  display: grid;
  grid-template-columns: minmax(0, 1.42fr) minmax(320px, .78fr);
  gap: 18px;
  align-items: start;
}
.field-group {
  display: grid;
  gap: 12px;
  min-width: 0;
}
.routing-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.ports-row {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}
.ports-row label { margin-bottom: 0; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.split.three { grid-template-columns: repeat(3, 1fr); }
.actions {
  display: grid;
  gap: 10px;
}
button {
  border: 1px solid #31507d;
  background: linear-gradient(180deg, #12233d, #0b1628);
  color: var(--text);
  border-radius: 7px;
  padding: 10px 13px;
  font-weight: 700;
  cursor: pointer;
}
button:hover { border-color: var(--cyan); color: white; box-shadow: 0 0 18px rgba(45,217,255,.14); }
button.primary { background: linear-gradient(135deg, #2dd9ff, #51ffb6); border-color: transparent; color: #03101d; }
button.danger { border-color: rgba(255,77,125,.58); color: #ffd9e3; background: linear-gradient(180deg, rgba(72,18,39,.84), rgba(23,10,20,.92)); }
button.ghost { padding: 7px 10px; font-size: 12px; }
.toggle { display: flex; gap: 8px; align-items: center; margin: 0; }
.toggle input { width: auto; accent-color: var(--cyan); }
.auto-refresh {
  justify-content: flex-start;
  color: var(--muted);
  margin-top: -4px;
}

.endpoint-card {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(50, 76, 120, .78);
  border-radius: 8px;
  padding: 12px;
  background: rgba(2, 6, 13, .72);
}
.endpoint-card div {
  display: grid;
  gap: 4px;
}
.endpoint-card span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--subtle);
}
.endpoint-card strong {
  color: #eaf3ff;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.endpoint-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.user-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; margin-bottom: 10px; }
pre {
  background: rgba(2, 6, 13, .95);
  border: 1px solid rgba(50, 76, 120, .78);
  border-radius: 8px;
  padding: 12px;
  color: #cae6ff;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: visible;
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
}
#statusBox { min-height: 128px; }
#logBox { color: #baf8dc; }
#previewBox { min-height: 220px; }
#tooltip {
  position: fixed;
  z-index: 1000;
  display: none;
  max-width: 360px;
  padding: 9px 10px;
  border: 1px solid rgba(45,217,255,.48);
  border-radius: 7px;
  background: rgba(4, 12, 23, .96);
  color: #dceeff;
  font-size: 12px;
  line-height: 1.4;
  box-shadow: 0 12px 34px rgba(0,0,0,.45), 0 0 24px rgba(45,217,255,.12);
  pointer-events: none;
}
.docs-panel {
  margin-top: 18px;
  overflow: visible;
}
.docs-panel header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-bottom: 16px;
}
.docs-panel header span {
  display: grid;
  gap: 4px;
}
.docs-panel header strong {
  color: #f7fbff;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: 14px;
}
.docs-panel header small {
  color: var(--muted);
  font-size: 12px;
}
.docs-body {
  border-top: 1px solid rgba(78, 111, 177, .32);
  padding-top: 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, .7fr);
  gap: 18px 28px;
}
.docs-body h1,
.docs-body h2,
.docs-body h3 {
  color: #f7fbff;
  text-transform: none;
  letter-spacing: 0;
}
.docs-body h1 {
  grid-column: 1 / -1;
  font-size: 24px;
  line-height: 1.2;
}
.docs-body h2 {
  border-top: 1px solid rgba(78, 111, 177, .32);
  padding-top: 16px;
  font-size: 16px;
}
.docs-body h2:first-child,
.docs-body h1 + h2 {
  border-top: 0;
  padding-top: 0;
}
.docs-body h3 { font-size: 14px; }
.docs-body p,
.docs-body li {
  color: #b7c9e4;
  font-size: 13px;
  line-height: 1.6;
}
.docs-body ul,
.docs-body ol {
  margin: 0;
  padding-left: 20px;
}
.docs-body code {
  border: 1px solid rgba(45,217,255,.18);
  border-radius: 5px;
  padding: 1px 5px;
  background: rgba(2, 6, 13, .9);
  color: #d7f9ff;
}
.docs-body pre {
  max-height: none;
  grid-column: 1 / -1;
}
.docs-body pre code {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
}
.generated-panel {
  margin-top: 18px;
}
.generated-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
}
.generated-panel summary::-webkit-details-marker { display: none; }
.generated-panel summary span {
  display: grid;
  gap: 4px;
}
.generated-panel summary strong {
  color: #f7fbff;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: 13px;
}
.generated-panel summary small {
  color: var(--muted);
  font-size: 12px;
}
.generated-controls {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
}
.generated-panel pre {
  margin-top: 12px;
}

@media (min-width: 1600px) {
  .grid { grid-template-columns: minmax(1020px, 1fr) minmax(520px, 640px); gap: 22px; }
  .routing-grid { gap: 14px; }
  .panel { padding: 20px; }
  #previewBox { min-height: 420px; }
}
@media (max-width: 1500px) {
  .routing-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1320px) {
  .grid { grid-template-columns: minmax(0, 1fr) 430px; }
  .desktop-fields { grid-template-columns: 1fr; }
  .route-entry { grid-template-columns: 1fr; align-items: stretch; }
  .actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1040px) {
  .shell { width: min(100% - 28px, 1000px); }
  .grid { grid-template-columns: 1fr; }
  .side { position: static; }
  .actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .docs-body { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .shell { width: min(100% - 20px, 620px); padding: 10px 0 18px; }
  .split, .split.three, .routing-grid, .ports-row, .user-row, .actions { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .panel { padding: 14px; }
  .docs-panel header { align-items: flex-start; flex-direction: column; }
  .generated-controls { grid-template-columns: 1fr; }
  #previewBox { min-height: 260px; }
}
