:root {
  color-scheme: dark;
  --bg: #101413;
  --surface: #171d1b;
  --surface-soft: #1f2a27;
  --text: #eef5f2;
  --muted: #9caaa6;
  --line: #2c3935;
  --accent: #50b5a6;
  --accent-strong: #7ed4c7;
  --blue: #2f5fbd;
  --amber: #e0aa4f;
  --red: #e06f61;
  --green: #48c17d;
  --input-bg: #111715;
  --sidebar-bg: #101817;
  --sidebar-panel: #17211f;
  --sidebar-line: #31423e;
  --sidebar-text: #dce8e5;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #eef4f3;
  --text: #1b1f23;
  --muted: #667085;
  --line: #d8dee4;
  --accent: #0f766e;
  --accent-strong: #0b4f4a;
  --amber: #b7791f;
  --red: #b42318;
  --green: #157347;
  --input-bg: #ffffff;
  --sidebar-bg: #16201f;
  --sidebar-panel: #1d2a28;
  --sidebar-line: #344844;
  --sidebar-text: #dce8e5;
  --shadow: 0 18px 45px rgba(27, 31, 35, 0.08);
}

:root[data-theme="system"] {
  color-scheme: dark light;
}

@media (prefers-color-scheme: light) {
  :root[data-theme="system"] {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-soft: #eef4f3;
    --text: #1b1f23;
    --muted: #667085;
    --line: #d8dee4;
    --accent: #0f766e;
    --accent-strong: #0b4f4a;
    --amber: #b7791f;
    --red: #b42318;
    --green: #157347;
    --input-bg: #ffffff;
    --sidebar-bg: #16201f;
    --sidebar-panel: #1d2a28;
    --sidebar-line: #344844;
    --sidebar-text: #dce8e5;
    --shadow: 0 18px 45px rgba(27, 31, 35, 0.08);
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

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

button {
  cursor: pointer;
}

code,
pre {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px 18px;
  background: var(--sidebar-bg);
  color: #f4fbf9;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e8f6f4;
  color: var(--accent-strong);
  font-weight: 800;
}

.brand-name {
  font-weight: 760;
}

.brand-subtitle,
.plan-panel span,
.router-row span,
small {
  color: var(--muted);
}

.sidebar .brand-subtitle,
.sidebar .plan-panel span {
  color: #aebdba;
}

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

.nav-item {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--sidebar-text);
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: var(--surface-soft);
  border-color: var(--sidebar-line);
  color: #ffffff;
}

.plan-panel {
  margin-top: auto;
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--sidebar-line);
  border-radius: 8px;
  background: var(--sidebar-panel);
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}

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

h1 {
  font-size: 30px;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 18px;
}

h4 {
  font-size: 16px;
}

.account {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.preference-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.preference-control {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.preference-control select {
  width: auto;
  min-width: 82px;
  min-height: 38px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--green);
}

.muted-dot {
  background: var(--muted);
}

.compact-button {
  min-height: 32px;
  padding: 5px 9px;
  font-size: 12px;
}

.api-panel,
.auth-layout {
  margin-bottom: 18px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 126px;
  display: grid;
  align-content: space-between;
  gap: 10px;
  padding: 16px;
}

.metric-card span,
.metric-card small {
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  font-size: 26px;
}

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

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.profile-layout {
  grid-template-columns: minmax(360px, 0.95fr) minmax(320px, 0.7fr);
}

.generator-layout,
.custom-layout {
  grid-template-columns: minmax(320px, 0.75fr) minmax(0, 1.25fr);
}

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

.ghost-button,
.primary-button,
.danger-button {
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  white-space: nowrap;
}

.ghost-button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

.danger-button {
  border-color: #f2c3bd;
  color: var(--red);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.chip,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #eef2f6;
  color: #344054;
  font-size: 12px;
  font-weight: 700;
}

.chip.low,
.badge.ok {
  background: #e7f6ed;
  color: var(--green);
}

.chip.medium {
  background: #fff4df;
  color: var(--amber);
}

.chip.high {
  background: #fde8e5;
  color: var(--red);
}

.badge.muted {
  background: #f1f3f5;
  color: var(--muted);
}

.summary-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.summary-list div {
  display: grid;
  grid-template-columns: minmax(140px, 0.55fr) minmax(0, 1fr);
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.summary-list div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 650;
}

.router-list,
.preset-grid,
.category-checklist,
.instruction-grid,
.workspace-grid,
.custom-form,
.form-grid {
  display: grid;
  gap: 12px;
}

.api-quick-links,
.workspace-grid {
  display: grid;
  gap: 12px;
}

.api-quick-links {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-top: 14px;
}

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

.api-workspace-panel {
  margin: 14px 0;
}

.router-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.router-row:last-child {
  border-bottom: 0;
}

.router-row.active {
  margin: 0 -10px;
  padding: 12px 10px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.router-row div {
  display: grid;
  gap: 2px;
}

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}

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

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

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

td span:not(.chip):not(.badge) {
  display: block;
  color: var(--muted);
}

.preset-button,
.check-row,
.confirm-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.preset-button {
  display: grid;
  gap: 4px;
  padding: 13px;
  text-align: left;
}

.preset-button.active {
  border-color: var(--accent);
  background: var(--surface-soft);
}

.preset-button span {
  color: var(--muted);
  font-size: 13px;
}

.check-row,
.confirm-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
}

.check-row input,
.confirm-row input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent);
}

.check-row span {
  display: grid;
  gap: 2px;
}

.warning,
.notice,
.empty {
  display: grid;
  gap: 6px;
  margin: 14px 0;
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
}

.warning {
  border: 1px solid #f6c5bd;
  background: #fff0ee;
  color: #7a271a;
}

.notice,
.empty {
  border: 1px solid #c6e5df;
  background: #edf8f6;
  color: #134e48;
}

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

.instruction-grid div {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.instruction-grid span {
  color: var(--muted);
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
}

textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.45;
}

.compact-select {
  width: auto;
  min-width: 180px;
}

.code-panel {
  display: grid;
  grid-template-rows: auto auto minmax(420px, 1fr);
}

pre {
  min-height: 420px;
  max-height: calc(100vh - 220px);
  max-width: 100%;
  margin: 0;
  overflow: auto;
  padding: 16px;
  border-radius: 8px;
  background: #101817;
  color: #e7fff9;
  font-size: 13px;
  line-height: 1.45;
  -webkit-overflow-scrolling: touch;
}

.custom-form {
  margin-top: 14px;
}

.scroll-hint,
.copy-hint {
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.scroll-hint {
  display: none;
}

.wizard-panel {
  margin-top: 18px;
}

.wizard-steps {
  display: grid;
  gap: 16px;
}

.wizard-step,
.subpanel,
.method-card,
.code-block-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.wizard-step {
  display: grid;
  gap: 14px;
  background: var(--surface-soft);
}

.wizard-step-head {
  display: flex;
  gap: 10px;
  align-items: center;
}

.step-index {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
}

.method-card {
  display: grid;
  gap: 10px;
}

.method-card p,
.hint-text {
  margin: 0;
  color: var(--muted);
}

.compact-summary {
  font-size: 14px;
}

.compact-checklist {
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.plain-list {
  margin: 8px 0 0;
  padding-left: 18px;
}

.plain-list li {
  margin-bottom: 5px;
}

.code-block-card {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.compact-code-panel {
  grid-template-rows: auto auto auto auto minmax(260px, 1fr);
}

.compact-code-panel pre,
.code-block-card pre {
  min-height: 220px;
  max-height: 420px;
}

.generator-preview-grid {
  align-items: start;
}

.custom-route-list {
  display: grid;
  gap: 4px;
  margin-top: 14px;
}

.route-source-admin-page,
.bird-lab-page {
  margin-bottom: 18px;
}

.route-source-admin-grid,
.bird-lab-grid {
  align-items: start;
  margin-bottom: 18px;
}

.admin-card-list,
.admin-result-grid,
.check-grid {
  display: grid;
  gap: 12px;
}

.admin-card-list {
  max-height: 680px;
  overflow: auto;
  padding-right: 4px;
}

.admin-row {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.admin-row.active {
  border-color: var(--accent);
  background: var(--surface-soft);
}

.admin-row-main,
.admin-row-main > div:first-child {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.admin-row-main span,
.status-line,
.bird-lab-grid code {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.status-line {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.admin-row-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.admin-summary {
  margin-top: 4px;
}

.two-column-form,
.admin-result-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-filters {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
}

.inline-confirm {
  align-self: end;
  min-height: 42px;
}

.compact-plain-list,
.compact-pre {
  overflow-wrap: anywhere;
}

.compact-pre {
  min-height: 120px;
  max-height: 280px;
  white-space: pre;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: #eef2f6;
  color: #344054;
}

.health-healthy,
.build-approved,
.build-published {
  background: #e7f6ed;
  color: var(--green);
}

.health-warning,
.build-risky,
.build-dry_run {
  background: #fff4df;
  color: var(--amber);
}

.health-failing,
.build-rejected,
.build-failed {
  background: #fde8e5;
  color: var(--red);
}

.health-unknown {
  background: #f1f3f5;
  color: var(--muted);
}

@media (max-width: 1180px) {
  .dashboard-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .split,
  .profile-layout,
  .generator-layout,
  .custom-layout,
  .two-column-form,
  .admin-result-grid,
  .admin-filters {
    grid-template-columns: 1fr;
  }
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .main {
    padding: 18px;
  }

  .topbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .preference-controls,
  .preference-control,
  .preference-control select {
    width: 100%;
  }

  .preference-controls {
    align-items: stretch;
  }

  .preference-control {
    justify-content: space-between;
  }

  .dashboard-grid,
  .workspace-grid,
  .instruction-grid {
    grid-template-columns: 1fr;
  }

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

  .router-row,
  .row-actions,
  .admin-row-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .row-actions {
    justify-content: flex-start;
  }

  .scroll-hint {
    display: block;
  }

  .table-wrap {
    border: 1px solid var(--line);
    border-radius: 8px;
  }

  .table-wrap table {
    border-radius: 8px;
  }

  .code-panel {
    grid-template-rows: auto auto minmax(320px, 1fr);
  }

  pre {
    min-height: 320px;
    max-height: 60vh;
    font-size: 12px;
  }

  textarea {
    min-height: 220px;
  }

  .admin-card-list {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .compact-pre {
    min-height: 120px;
  }
}
