:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-muted: #f1f3f6;
  --line: #dde2e8;
  --line-strong: #c7d0dc;
  --text: #111827;
  --muted: #64748b;
  --subtle: #94a3b8;
  --sidebar: #111827;
  --sidebar-2: #0f172a;
  --sidebar-line: rgba(255, 255, 255, 0.08);
  --blue: #2563eb;
  --green: #16a34a;
  --yellow: #f59e0b;
  --red: #ef4444;
  --violet: #8b5cf6;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    linear-gradient(180deg, rgba(17, 24, 39, 0.04), transparent 42%),
    var(--bg);
}

.auth-panel {
  width: min(100%, 460px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 34px;
}

.auth-brand,
.portal-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  color: var(--blue);
  background: rgba(37, 99, 235, 0.12);
  border-radius: 8px;
}

.brand-mark svg {
  width: 20px;
  height: 20px;
}

.auth-copy {
  margin: 36px 0 26px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

.auth-copy h1,
.portal-header h1 {
  margin-bottom: 10px;
  font-size: 30px;
  line-height: 1.12;
  letter-spacing: 0;
}

.auth-copy p,
.portal-header p,
.section-heading p,
.security-note span {
  color: var(--muted);
  line-height: 1.55;
}

.auth-form,
.form-grid,
.settings-layout {
  display: grid;
  gap: 16px;
}

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

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

input:focus {
  border-color: rgba(37, 99, 235, 0.7);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

input:disabled {
  color: var(--muted);
  background: var(--surface-muted);
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-text-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 750;
}

.primary-button {
  background: var(--text);
  color: #ffffff;
  padding: 0 16px;
}

.primary-button:hover {
  background: #020617;
}

.primary-button:disabled,
.secondary-button:disabled,
.icon-text-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.secondary-button,
.icon-text-button {
  background: #ffffff;
  color: var(--text);
  border-color: var(--line);
  padding: 0 14px;
}

.secondary-button:hover,
.icon-text-button:hover {
  border-color: var(--line-strong);
}

.ghost-button {
  background: transparent;
  color: var(--blue);
  padding: 0 12px;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.form-message.error {
  color: var(--red);
}

.form-message.success {
  color: var(--green);
}

.security-note {
  margin-top: 24px;
  padding: 14px;
  display: grid;
  gap: 4px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.portal-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 22px;
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
  color: #e5e7eb;
  padding: 22px 16px;
  border-right: 1px solid var(--sidebar-line);
}

.portal-nav {
  display: grid;
  gap: 4px;
}

.nav-link {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 11px;
  color: #cbd5e1;
  text-decoration: none;
  padding: 0 11px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
}

.nav-link svg {
  width: 19px;
  height: 19px;
}

.nav-link:hover,
.nav-link.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.nav-link.disabled {
  color: rgba(203, 213, 225, 0.48);
  cursor: default;
}

.identity-panel {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  border-top: 1px solid var(--sidebar-line);
  padding-top: 16px;
}

.identity-panel strong,
.identity-panel span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.identity-panel span {
  color: #94a3b8;
  font-size: 12px;
}

.avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e5e7eb;
  color: #111827;
  font-size: 12px;
  font-weight: 800;
}

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

.portal-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 24px;
}

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

.save-state {
  min-width: 88px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.icon-text-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.icon-text-button svg {
  width: 18px;
  height: 18px;
}

.settings-layout {
  max-width: 1080px;
}

.wizard-shell {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 820px);
  gap: 22px;
  align-items: start;
}

.wizard-stepper {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 16px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.wizard-step {
  min-height: 48px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  color: var(--muted);
  padding: 8px;
  border-radius: 8px;
}

.wizard-step span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-muted);
  font-size: 12px;
  font-weight: 800;
}

.wizard-step strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.wizard-step.active,
.wizard-step.complete {
  color: var(--text);
  background: rgba(37, 99, 235, 0.07);
}

.wizard-step.active span,
.wizard-step.complete span {
  color: #ffffff;
  background: var(--blue);
  border-color: var(--blue);
}

.wizard-card {
  min-height: 520px;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.wizard-panel {
  display: none;
}

.wizard-panel.active {
  display: grid;
  gap: 22px;
  align-content: start;
}

.wizard-panel-heading h2 {
  margin-bottom: 8px;
  font-size: 22px;
  letter-spacing: 0;
}

.wizard-status-card {
  display: grid;
  gap: 12px;
  max-width: 560px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.wizard-status-card p {
  margin: 0;
  color: var(--muted);
}

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

.readiness-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.readiness-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
}

.readiness-item.complete .readiness-icon {
  background: #dcfce7;
  color: #166534;
}

.readiness-item.failed .readiness-icon {
  background: #fee2e2;
  color: #991b1b;
}

.readiness-item strong,
.readiness-item span {
  display: block;
}

.readiness-item strong {
  font-size: 14px;
}

.readiness-item span {
  color: var(--muted);
  font-size: 12px;
}

.readiness-state {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.wizard-finish {
  min-height: 360px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  text-align: center;
}

.finish-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #166534;
  background: #dcfce7;
}

.finish-mark svg {
  width: 30px;
  height: 30px;
}

.wizard-finish h2 {
  max-width: 560px;
  margin-bottom: 0;
  font-size: 28px;
  letter-spacing: 0;
}

.wizard-finish p {
  color: var(--muted);
}

.finish-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.primary-link-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--text);
  color: #ffffff;
  padding: 0 18px;
  font-weight: 800;
  text-decoration: none;
}

.secondary-link-button {
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--line);
}

.compact-status {
  max-width: 520px;
  padding: 14px;
  text-align: left;
}

.wizard-actions {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

.wizard-actions > div {
  display: flex;
  gap: 10px;
  align-items: center;
}

.large-action {
  min-height: 48px;
  min-width: 168px;
  padding: 0 22px;
}

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

.clients-list-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  padding: 18px;
}

.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-toolbar h2 {
  margin: 0;
  font-size: 15px;
}

.clients-list {
  display: grid;
  gap: 8px;
}

.client-list-button {
  width: 100%;
  min-height: 68px;
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 11px;
  text-align: left;
}

.client-list-button:hover,
.client-list-button.active {
  border-color: rgba(37, 99, 235, 0.55);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.client-list-button strong,
.client-list-button span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-list-button span {
  color: var(--muted);
  font-size: 12px;
}

.client-editor {
  max-width: none;
}

.settings-section {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
  gap: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.section-heading h2 {
  margin-bottom: 8px;
  font-size: 16px;
  letter-spacing: 0;
}

.section-heading p {
  margin-bottom: 0;
  font-size: 13px;
}

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

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

.secret-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.integration-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.integration-strip span {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-muted);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
}

.connection-panel {
  display: grid;
  gap: 12px;
  align-content: start;
}

.connection-panel p {
  margin: 0;
  color: var(--muted);
}

.status-badge {
  width: fit-content;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.status-badge.connected {
  color: #166534;
  background: #dcfce7;
}

.status-badge.failed {
  color: #991b1b;
  background: #fee2e2;
}

.status-badge.queued,
.status-badge.running {
  color: #1e3a8a;
  background: #dbeafe;
}

.status-badge.unknown {
  color: #475569;
  background: #e2e8f0;
}

.empty-state {
  color: var(--muted);
  font-size: 13px;
}

.form-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 18px;
  padding-bottom: 24px;
}

@media (max-width: 900px) {
  .portal-shell {
    grid-template-columns: 1fr;
  }

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

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

  .portal-header,
  .form-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .settings-section {
    grid-template-columns: 1fr;
  }

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

  .wizard-shell {
    grid-template-columns: 1fr;
  }

  .wizard-stepper {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .wizard-step {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }
}

@media (max-width: 620px) {
  .auth-page,
  .portal-main {
    padding: 18px;
  }

  .auth-panel,
  .settings-section {
    padding: 20px;
  }

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

  .secret-field {
    grid-template-columns: 1fr;
  }

  .wizard-card {
    padding: 20px;
  }

  .wizard-stepper {
    grid-template-columns: 1fr;
  }

  .wizard-actions,
  .wizard-actions > div {
    flex-direction: column;
    align-items: stretch;
  }

  .readiness-item {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .readiness-state {
    grid-column: 2;
  }

  .auth-copy h1,
  .portal-header h1 {
    font-size: 25px;
  }
}
