:root {
  --bg: #1b1a8d;
  --surface: #ffffff;
  --surface-strong: #fbfaf7;
  --text: #f1f1f1;
  --muted: #f3f3f3;
  --line: #ded8cd;
  --focus: #315847;
  --focus-soft: #e6eee8;
  --accent: #b88945;
  --warning: #a16207;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --success: #315847;
  --success-soft: #e6eee8;
  --shadow: 0 18px 46px rgba(18, 20, 17, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
}

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

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.site-header {
  display: flex;
  width: min(1180px, calc(100vw - 32px));
  min-height: 78px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin: 0 auto;
  border-bottom: 1px solid rgba(18, 20, 17, 0.12);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font-size: 0.98rem;
  font-weight: 850;
  text-decoration: none;
}

.brand-initials {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--text);
  color: var(--surface);
  background: var(--text);
  font-size: 0.88rem;
  letter-spacing: 0.04em;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 24px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.site-nav a {
  color: inherit;
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--text);
}

.site-nav .nav-button {
  border: 1px solid var(--text);
  border-radius: 0;
  padding: 10px 16px;
  color: var(--surface);
  background: var(--text);
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 54px 0 42px;
}

.workspace-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 28px;
}

.workspace-heading h1,
.panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.workspace-heading h1 {
  max-width: 760px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.6rem, 6vw, 5.35rem);
  font-weight: 500;
  line-height: 0.96;
}

.workspace-heading p:last-child {
  max-width: 430px;
  margin: 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.65;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.32fr) minmax(340px, 0.78fr);
  gap: 20px;
  align-items: start;
}

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  padding: 20px 24px;
}

.auth-panel h2 {
  margin: 0 0 8px;
}

.auth-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 10px;
}

.secondary-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0 16px;
  color: #171914;
  background: #ffffff;
  font-weight: 850;
}

.secondary-button:hover {
  background: var(--surface-strong);
}

.icon-button,
.danger-button {
  min-height: 38px;
  border-radius: 0;
  padding: 0 12px;
  font-weight: 850;
}

.icon-button {
  border: 1px solid var(--line);
  color: #171914;
  background: #ffffff;
}

.danger-button {
  border: 1px solid var(--danger);
  color: #ffffff;
  background: var(--danger);
}

.icon-button:hover:not(:disabled) {
  background: var(--surface-strong);
}

.danger-button:hover:not(:disabled) {
  background: #8f1d14;
}

.icon-button:disabled,
.danger-button:disabled {
  opacity: 0.68;
}

.side-stack {
  display: grid;
  gap: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 0;
  box-shadow: var(--shadow);
}

.onboarding-form,
.result-panel,
.recent-panel,
.tenants-panel {
  padding: 26px;
}

.form-header,
.result-header,
.tenant-panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--focus);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.route-label,
.status-pill {
  flex: 0 0 auto;
  border-radius: 0;
  border: 1px solid var(--line);
  padding: 7px 10px;
  color: var(--muted);
  /* background: var(--surface-strong); */
  font-size: 0.78rem;
  font-weight: 700;
}

.field-grid {
  display: grid;
  gap: 16px;
}

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

.field,
.segmented-field {
  display: grid;
  gap: 7px;
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

.field span,
.segmented-field legend,
.toggle span {
  color: #f1f1f1;
  font-size: 0.9rem;
  font-weight: 750;
}

.toggle span {
  color: #111111;
}

.field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cfc7bb;
  border-radius: 0;
  padding: 11px 12px;
  color: #171914;
  background: #fff;
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.field input:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 4px var(--focus-soft);
}

.field input:disabled {
  color: #7b8780;
  background: #f1eee8;
  cursor: not-allowed;
}

.field input[readonly] {
  color: #34443b;
  background: #f1eee8;
}

.field input[aria-invalid="true"] {
  border-color: var(--danger);
}

.hidden-field {
  display: none;
}

.error {
  min-height: 1rem;
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 700;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-height: 44px;
  overflow: hidden;
  border: 1px solid #cfc7bb;
  border-radius: 0;
  background: #f1eee8;
}

.segmented-control label {
  display: grid;
  place-items: center;
  min-width: 0;
  border-right: 1px solid #cfc7bb;
  color: #34443b;
  font-weight: 800;
  cursor: pointer;
}

.segmented-control label:last-child {
  border-right: 0;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
}

.segmented-control input:checked + span {
  color: #f1f1f1;
  background-color: var(--bg);
}

.segmented-control span {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 44px;
  place-items: center;
}

.toggles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 6px 0 20px;
}

.toggle {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 12px;
  background: var(--surface-strong);
}

.toggle input {
  width: 46px;
  height: 26px;
  flex: 0 0 auto;
  accent-color: var(--focus);
}

.submit-button {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 0;
  color: #ffffff;
  background: blue;
  font-weight: 850;
  transition:
    background 160ms ease,
    transform 160ms ease;
}

.submit-button:hover:not(:disabled) {
  background: var(--focus);
  transform: translateY(-1px);
}

.submit-button:disabled {
  opacity: 0.68;
}

.empty-result {
  min-height: 220px;
}

.result-panel {
  border-top: 5px solid var(--accent);
}

.status-active,
.status-provisioning {
  border-top-color: var(--success);
}

.status-failed,
.status-validation_error,
.status-lambda_invoke_error {
  border-top-color: var(--danger);
}

.status-suspended {
  border-top-color: var(--warning);
}

.result-grid {
  display: grid;
  gap: 12px;
  margin: 0;
}

.result-grid div {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
  align-items: baseline;
}

.result-grid dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.result-grid dd {
  min-width: 0;
  margin: 0;
  font-weight: 750;
}

.breakable {
  overflow-wrap: anywhere;
}

.raw-details {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.raw-details summary {
  color: var(--focus);
  font-weight: 850;
}

.raw-details pre {
  max-height: 280px;
  overflow: auto;
  border-radius: 0;
  padding: 14px;
  color: #f8f7f2;
  background: #171914;
  font-size: 0.82rem;
  line-height: 1.45;
}

.muted {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.recent-panel ul {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.recent-panel li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 10px;
  background: var(--surface-strong);
}

.recent-panel li div {
  display: grid;
  min-width: 0;
}

.recent-panel li strong,
.recent-panel li span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-panel li div span {
  color: var(--muted);
  font-size: 0.82rem;
}

.tenant-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tenant-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 12px;
  background: var(--surface-strong);
}

.tenant-summary {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.tenant-summary strong,
.tenant-summary span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tenant-summary strong {
  color: #171914;
}

.tenant-summary span {
  color: #5f6b64;
  font-size: 0.82rem;
}

.tenant-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tenant-status {
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 5px 8px;
  color: var(--success);
  background: var(--success-soft);
  font-size: 0.75rem;
  font-weight: 850;
}

.error-message {
  margin: 0;
  color: var(--danger);
  font-weight: 750;
  line-height: 1.5;
}

.attempt-ok,
.attempt-failed {
  flex: 0 0 auto;
  border-radius: 0;
  padding: 5px 8px;
  font-size: 0.75rem;
  font-weight: 850;
}

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

.attempt-failed {
  color: var(--danger);
  background: var(--danger-soft);
}

@media (max-width: 920px) {
  .site-header {
    align-items: start;
  }

  .site-nav {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 12px 18px;
  }

  .workspace-heading,
  .workspace-grid {
    display: grid;
  }

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

@media (max-width: 640px) {
  .site-header {
    width: min(100vw - 20px, 1180px);
    min-height: auto;
    align-items: stretch;
    padding: 14px 0;
  }

  .brand-mark,
  .site-header,
  .site-nav {
    display: grid;
  }

  .brand-mark {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .site-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
  }

  .site-nav .nav-button {
    grid-column: 1 / -1;
    text-align: center;
  }

  .app-shell {
    width: min(100vw - 20px, 1180px);
    padding: 28px 0;
  }

  .workspace-heading {
    gap: 14px;
  }

  .workspace-heading h1 {
    font-size: 2.9rem;
  }

  .onboarding-form,
  .result-panel,
  .recent-panel,
  .tenants-panel {
    padding: 16px;
  }

  .form-header,
  .result-header,
  .tenant-panel-header,
  .two-col,
  .toggles {
    grid-template-columns: 1fr;
  }

  .form-header,
  .result-header,
  .tenant-panel-header {
    display: grid;
  }

  .tenant-list li,
  .tenant-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .route-label,
  .status-pill {
    width: fit-content;
  }
}
