:root {
  --background: #0b1020;
  --surface: #111827;
  --surface-2: #162033;
  --surface-3: #1d283a;
  --foreground: #f8fafc;
  --muted: #9aa8bd;
  --muted-strong: #cbd5e1;
  --border: #334155;
  --border-soft: rgba(148, 163, 184, 0.22);
  --accent: #22c55e;
  --accent-strong: #16a34a;
  --accent-soft: rgba(34, 197, 94, 0.14);
  --cyan: #38bdf8;
  --amber: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 20px 45px rgba(0, 0, 0, 0.24);
  --radius: 8px;
  --font-body: Inter, "Segoe UI", Arial, sans-serif;
  --font-mono: "Fira Code", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--background);
}

body {
  margin: 0;
  color: var(--foreground);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  background:
    linear-gradient(180deg, rgba(56, 189, 248, 0.08), transparent 320px),
    var(--background);
}

body.is-locked {
  min-height: 100vh;
  overflow: hidden;
}

body.is-locked .topbar,
body.is-locked .workspace,
body.is-locked .toast-region {
  display: none;
}

.lock-screen {
  display: none;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

body.is-locked .lock-screen {
  display: grid;
}

.lock-card {
  display: grid;
  gap: 16px;
  width: min(460px, 100%);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 22px;
  background: rgba(17, 24, 39, 0.96);
  box-shadow: var(--shadow);
}

.lock-card .brand-mark {
  width: 48px;
  height: 48px;
}

.lock-card h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.lock-card p {
  margin: 6px 0 0;
  color: var(--muted);
}

.lock-error {
  margin: 0;
  border: 1px solid rgba(239, 68, 68, 0.44);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: #fecaca;
  background: rgba(239, 68, 68, 0.12);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.7);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: 16px;
  z-index: 1000;
  transform: translateY(-150%);
  border: 1px solid var(--cyan);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--foreground);
  background: var(--surface);
  text-decoration: none;
  transition: transform 180ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 82px;
  border-bottom: 1px solid var(--border-soft);
  padding: 14px 24px;
  background: rgba(11, 16, 32, 0.92);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(34, 197, 94, 0.42);
  border-radius: var(--radius);
  color: var(--accent);
  background: var(--accent-soft);
}

.brand h1,
.panel h2,
.subheading h3 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 19px;
  line-height: 1.2;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.topbar-actions,
.form-actions,
.panel-actions,
.toolbar,
.subheading {
  display: flex;
  align-items: center;
  gap: 10px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  width: min(1560px, 100%);
  margin: 0 auto;
  padding: 18px 24px 32px;
}

.main-column {
  display: grid;
  order: -1;
  gap: 18px;
  min-width: 0;
}

.grid-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  min-width: 0;
}

.panel {
  min-width: 0;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: rgba(17, 24, 39, 0.9);
  box-shadow: var(--shadow);
}

.server-panel {
  align-self: start;
}

.server-panel.is-collapsed .server-panel-body {
  display: none;
}

.server-panel.is-collapsed .panel-heading {
  border-bottom: 0;
}

.server-panel-toggle {
  cursor: pointer;
  user-select: none;
  transition: background 180ms ease, border-color 180ms ease;
}

.server-panel-toggle:hover {
  background: rgba(56, 189, 248, 0.06);
}

.server-panel-toggle:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.7);
  outline-offset: -3px;
}

.server-panel-toggle-meta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.server-panel-chevron {
  color: var(--muted);
  transition: transform 180ms ease, color 180ms ease;
}

.server-panel-toggle:hover .server-panel-chevron {
  color: var(--foreground);
}

.server-panel:not(.is-collapsed) .server-panel-chevron {
  transform: rotate(180deg);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 70px;
  border-bottom: 1px solid var(--border-soft);
  padding: 16px;
}

.panel h2 {
  font-size: 18px;
  line-height: 1.25;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.counter,
.status-pill,
.tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--muted-strong);
  background: rgba(15, 23, 42, 0.76);
  font-size: 13px;
  white-space: nowrap;
}

.status-pill.is-ok {
  border-color: rgba(34, 197, 94, 0.38);
  color: #bbf7d0;
  background: rgba(34, 197, 94, 0.12);
}

.status-pill.is-error {
  border-color: rgba(239, 68, 68, 0.42);
  color: #fecaca;
  background: rgba(239, 68, 68, 0.13);
}

.stacked-form,
.saved-profiles {
  display: grid;
  gap: 14px;
  padding: 16px;
}

label,
fieldset {
  display: grid;
  gap: 7px;
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 0;
}

label span,
legend {
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 650;
}

label small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

input,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--foreground);
  background: rgba(15, 23, 42, 0.92);
}

.check-row {
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.58);
}

.check-row input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  margin: 3px 0 0;
  accent-color: var(--accent);
}

.check-row span {
  color: var(--muted-strong);
  line-height: 1.35;
}

textarea {
  min-height: 148px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 13px;
}

input::placeholder,
textarea::placeholder {
  color: #64748b;
}

.field-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px;
  gap: 10px;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 5px;
  background: rgba(15, 23, 42, 0.72);
}

.segment,
.primary-button,
.secondary-button,
.ghost-button,
.icon-button,
.copy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 10px 12px;
  color: var(--foreground);
  background: transparent;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.segment {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}

.segment.is-active {
  border-color: rgba(34, 197, 94, 0.38);
  color: #dcfce7;
  background: rgba(34, 197, 94, 0.14);
}

.primary-button {
  border-color: rgba(34, 197, 94, 0.42);
  color: #052e16;
  background: var(--accent);
  font-weight: 750;
}

.primary-button:hover:not(:disabled) {
  background: #4ade80;
}

.secondary-button,
.ghost-button,
.copy-button {
  border-color: var(--border);
  color: var(--muted-strong);
  background: rgba(15, 23, 42, 0.76);
}

.ghost-button:hover:not(:disabled),
.secondary-button:hover:not(:disabled),
.copy-button:hover:not(:disabled),
.icon-button:hover:not(:disabled),
.segment:hover:not(:disabled) {
  border-color: rgba(56, 189, 248, 0.44);
  color: var(--foreground);
  background: rgba(56, 189, 248, 0.11);
}

.icon-button {
  width: 44px;
  padding: 0;
  border-color: var(--border-soft);
  color: var(--muted);
  background: rgba(15, 23, 42, 0.62);
}

.auth-pane.is-hidden,
.is-hidden {
  display: none;
}

.saved-profiles {
  border-top: 1px solid var(--border-soft);
}

.subheading {
  justify-content: space-between;
}

.subheading h3 {
  font-size: 15px;
}

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

.profile-button,
.select-row {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 12px;
  color: var(--foreground);
  background: rgba(15, 23, 42, 0.64);
  text-align: left;
  transition: border-color 180ms ease, background 180ms ease;
}

.profile-button:hover,
.select-row:hover {
  border-color: rgba(56, 189, 248, 0.42);
  background: rgba(56, 189, 248, 0.08);
}

.select-row.is-selected {
  border-color: rgba(34, 197, 94, 0.68);
  background: rgba(34, 197, 94, 0.12);
}

.row-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.row-title strong {
  overflow-wrap: anywhere;
}

.row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.toolbar {
  border-bottom: 1px solid var(--border-soft);
  padding: 12px 16px;
}

.search-box {
  position: relative;
  width: 100%;
}

.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  color: var(--muted);
}

.search-box input {
  padding-left: 40px;
}

.list {
  max-height: 430px;
  overflow: auto;
  padding: 16px;
}

.scan-diagnostics {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--border-soft);
  padding: 12px 16px 16px;
}

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

.diagnostic-grid div,
.diagnostic-warning {
  min-width: 0;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 9px 10px;
  background: rgba(15, 23, 42, 0.62);
}

.diagnostic-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.diagnostic-grid strong {
  display: block;
  margin-top: 2px;
  color: var(--muted-strong);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.diagnostic-warning {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: #fde68a;
}

.diagnostic-warning p {
  margin: 0;
  white-space: pre-wrap;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 180px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  color: var(--muted);
  text-align: center;
}

.empty-state svg {
  color: var(--cyan);
}

.empty-state p {
  max-width: 520px;
  margin: 0;
}

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

.migration-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  border-bottom: 1px solid var(--border-soft);
  padding: 16px;
}

.migration-summary div {
  min-width: 0;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 12px;
  background: rgba(15, 23, 42, 0.62);
}

.migration-summary span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.migration-summary strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

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

.snippet-card {
  min-width: 0;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: rgba(15, 23, 42, 0.72);
}

.snippet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border-soft);
  padding: 10px 12px;
}

.snippet-header h3 {
  margin: 0;
  font-size: 15px;
}

pre {
  max-height: 340px;
  margin: 0;
  overflow: auto;
  padding: 14px;
  color: #dbeafe;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.checklist {
  margin: 0;
  padding: 14px 14px 14px 32px;
  color: var(--muted-strong);
}

.checklist li + li {
  margin-top: 8px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
}

.result-grid div {
  min-width: 0;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 10px;
  background: rgba(15, 23, 42, 0.62);
}

.result-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.result-grid strong {
  display: block;
  margin-top: 3px;
  color: var(--foreground);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  display: grid;
  gap: 10px;
  width: min(420px, calc(100vw - 36px));
}

.toast {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--foreground);
  background: #172033;
  box-shadow: var(--shadow);
}

.toast.is-error {
  border-color: rgba(239, 68, 68, 0.48);
}

.toast.is-success {
  border-color: rgba(34, 197, 94, 0.48);
}

svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  stroke-width: 2;
}

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

  .server-panel {
    align-self: stretch;
  }
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 16px;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .workspace {
    padding: 14px 14px 24px;
  }

  .grid-row,
  .snippet-grid,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .migration-summary {
    grid-template-columns: 1fr;
  }

  .migration-summary > svg {
    transform: rotate(90deg);
    justify-self: center;
  }
}

@media (max-width: 520px) {
  .brand {
    align-items: flex-start;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .brand h1 {
    font-size: 17px;
  }

  .field-grid,
  .segmented-control,
  .diagnostic-grid {
    grid-template-columns: 1fr;
  }

  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button,
  .secondary-button,
  .ghost-button {
    width: 100%;
  }
}

@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;
  }
}
