:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-muted: #f7f9fb;
  --text: #1d2733;
  --muted: #687587;
  --line: #dce3ea;
  --primary: #0f766e;
  --primary-dark: #0b5f59;
  --blue: #2563eb;
  --amber: #b7791f;
  --red: #b42318;
  --green: #157347;
  --shadow: 0 10px 24px rgba(29, 39, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft JhengHei", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden],
.is-hidden {
  display: none !important;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 16px;
  border-right: 1px solid var(--line);
  background: #ffffff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 24px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 13px;
}

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

.nav-item {
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.nav-item:hover,
.nav-item.is-active {
  background: #e8f3f1;
  color: var(--primary-dark);
}

.main {
  min-width: 0;
  padding: 20px 24px 36px;
}

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

.search-wrap {
  flex: 1;
  max-width: 520px;
}

.search-wrap input,
.module-form input,
.module-form select {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
}

.user-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-box {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-muted);
}

.auth-box form {
  display: grid;
  gap: 8px;
}

.auth-box form input {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.auth-box label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.auth-inline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.auth-inline input {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.full-width-button {
  width: 100%;
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-heading h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}

.page-heading p {
  margin: 4px 0 0;
  color: var(--muted);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  margin-bottom: 16px;
}

.panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel + .panel {
  margin-top: 16px;
}

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

.panel-header h2 {
  margin: 0;
  font-size: 18px;
}

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

.empty-state {
  display: grid;
  gap: 6px;
  min-height: 120px;
  align-content: center;
  padding: 20px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--panel-muted);
  text-align: center;
}

.system-card {
  display: grid;
  gap: 12px;
  min-height: 178px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.system-card:hover {
  border-color: #b7c8d7;
}

.system-card-header {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.system-icon {
  display: grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: #eef6ff;
  color: var(--blue);
  font-weight: 700;
}

.system-title {
  margin: 0;
  font-size: 16px;
}

.system-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.login-method-select {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.login-method-select select {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink, #1f2937);
  font-size: 13px;
}

.status-pill,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2f7;
  color: #475569;
  font-size: 12px;
  font-weight: 600;
}

.success {
  background: #e8f5ed;
  color: var(--green);
}

.warning {
  background: #fff4da;
  color: var(--amber);
}

.danger {
  background: #fdecea;
  color: var(--red);
}

.neutral {
  background: #eef2f7;
  color: #475569;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
}

.primary-button {
  background: var(--primary);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--primary-dark);
}

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

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.ghost-button {
  border-color: transparent;
  background: #eef2f7;
  color: var(--text);
}

.danger-button {
  border-color: #f3b8b2;
  background: #fff5f5;
  color: var(--red);
}

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

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

.status-list dt {
  color: var(--muted);
}

.status-list dd {
  margin: 0;
  font-weight: 700;
}

.mini-section {
  margin-top: 18px;
}

.mini-section h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

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

.compact-list li {
  padding: 10px;
  border-radius: 8px;
  background: var(--panel-muted);
}

.table-like {
  display: grid;
  gap: 8px;
}

.row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 52px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.row.header {
  min-height: auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.module-row {
  grid-template-columns: 1.2fr 1fr 0.6fr 0.8fr auto;
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.audit-row {
  grid-template-columns: 1fr 1.4fr 1.2fr 0.9fr 1fr;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -8px 0 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.admin-tabs .is-active {
  border-color: #a9d6cf;
  background: #e8f3f1;
  color: var(--primary-dark);
}

.account-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.account-summary > div {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-muted);
}

.account-summary strong,
.account-summary span {
  display: block;
}

.credential-rows,
.admin-user-rows {
  margin-top: 16px;
}

.credential-row {
  grid-template-columns: 1.3fr 1fr 0.8fr 0.9fr auto;
}

.admin-user-row {
  grid-template-columns: 1.5fr 0.8fr 0.7fr 0.7fr 1fr auto;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.revealed-password {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-muted);
  font-family: Consolas, "Courier New", monospace;
  word-break: break-all;
}

.tutorial-dialog-body label {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.tutorial-dialog-body input {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.filter-bar .is-active {
  border-color: #a9d6cf;
  background: #e8f3f1;
  color: var(--primary-dark);
}

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

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

.field-heading {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
}

.field-heading-actions {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 8px;
  align-items: center;
}

.field-quick-link {
  flex: 0 0 auto;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.field-quick-link:hover,
.field-quick-link:focus-visible {
  text-decoration: underline;
}

.field-tutorial-button {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

.field-tutorial-button:hover,
.field-tutorial-button:focus-visible {
  text-decoration: underline;
}

.setup-tutorial-dialog {
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

.setup-tutorial-dialog::backdrop {
  background: rgba(29, 39, 51, 0.48);
}

.tutorial-dialog-header,
.tutorial-dialog-actions {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
}

.tutorial-dialog-header {
  border-bottom: 1px solid var(--line);
}

.tutorial-dialog-header h2 {
  margin: 2px 0 0;
  font-size: 20px;
}

.tutorial-eyebrow {
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 700;
}

.dialog-close-button {
  display: grid;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
}

.tutorial-dialog-body {
  max-height: calc(100vh - 230px);
  padding: 18px 20px;
  overflow-y: auto;
}

.tutorial-dialog-body > p {
  margin: 0 0 14px;
  color: var(--muted);
}

.tutorial-dialog-body ol {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 22px;
}

.tutorial-note {
  margin-top: 16px;
  padding: 12px;
  border-left: 3px solid var(--primary);
  background: var(--panel-muted);
  color: var(--muted);
}

.tutorial-dialog-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
}

.form-actions {
  display: flex;
  align-items: end;
  gap: 8px;
}

.result-box {
  display: none;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid #badbcc;
  border-radius: 8px;
  background: #eefaf2;
  color: #14532d;
}

.result-box.is-visible {
  display: block;
}

.result-box.is-error {
  border-color: #f3b8b2;
  background: #fff5f5;
  color: var(--red);
}

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

.connector-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.connector-card h3 {
  margin: 0;
  font-size: 16px;
}

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

.wizard-summary {
  display: grid;
  gap: 12px;
}

.wizard-summary > div {
  display: grid;
  gap: 6px;
}

.fallback-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.fallback-details summary {
  cursor: pointer;
  padding: 10px 12px;
  color: var(--muted);
  font-weight: 700;
}

.fallback-details .command-box {
  display: grid;
  gap: 6px;
  padding: 0 12px 12px;
}

.wizard-summary code,
.command-box pre {
  display: block;
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-muted);
  color: var(--text);
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

.wizard-check-grid {
  display: grid;
  gap: 8px;
}

.deploy-setup-grid {
  margin: 12px 0;
}

.wizard-check-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.check-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.compact-link {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}

.deployment-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.deploy-targets {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.checkbox-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
}

.checkbox-line input {
  width: auto;
  min-height: auto;
  margin: 0;
}

.setup-note {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-muted);
  color: var(--muted);
}

.setup-note code {
  color: var(--text);
  font-family: Consolas, "Courier New", monospace;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

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

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

@media (max-width: 700px) {
  .main {
    padding: 16px;
  }

  .topbar,
  .page-heading,
  .user-area {
    align-items: stretch;
    flex-direction: column;
  }

  .card-grid,
  .connector-grid,
  .nav-list {
    grid-template-columns: 1fr;
  }

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

  .row,
  .row.header,
  .credential-row,
  .admin-user-row {
    grid-template-columns: 1fr;
  }

  .field-heading {
    flex-wrap: wrap;
    align-items: flex-start;
  }
}

/* Theme tokens keep the static portal lightweight while allowing a full visual reset. */
body.theme-ant {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-muted: #f7f9fc;
  --text: #1f1f1f;
  --muted: #667085;
  --line: #d9e2f3;
  --primary: #1677ff;
  --primary-dark: #0958d9;
  --blue: #1677ff;
  --amber: #d89614;
  --red: #d4380d;
  --green: #389e0d;
  --shadow: 0 6px 16px rgba(31, 56, 85, 0.08);
  --theme-surface: #ffffff;
  --theme-surface-muted: #f5f7fa;
  --theme-input: #ffffff;
  --theme-soft: #e6f4ff;
  --theme-radius: 6px;
  --theme-radius-sm: 4px;
  --theme-focus: rgba(22, 119, 255, 0.24);
}

body.theme-shadcn {
  color-scheme: light;
  --bg: #fafafa;
  --panel: #ffffff;
  --panel-muted: #f4f4f5;
  --text: #18181b;
  --muted: #71717a;
  --line: #e4e4e7;
  --primary: #18181b;
  --primary-dark: #27272a;
  --blue: #2563eb;
  --amber: #a16207;
  --red: #b91c1c;
  --green: #15803d;
  --shadow: 0 1px 2px rgba(24, 24, 27, 0.06);
  --theme-surface: #ffffff;
  --theme-surface-muted: #f4f4f5;
  --theme-input: #ffffff;
  --theme-soft: #f4f4f5;
  --theme-radius: 6px;
  --theme-radius-sm: 4px;
  --theme-focus: rgba(24, 24, 27, 0.2);
}

body.theme-daisy {
  color-scheme: light;
  --bg: #f7f8fc;
  --panel: #ffffff;
  --panel-muted: #f1f5f9;
  --text: #1f2937;
  --muted: #64748b;
  --line: #cbd5e1;
  --primary: #e11d48;
  --primary-dark: #be123c;
  --blue: #2563eb;
  --amber: #d97706;
  --red: #dc2626;
  --green: #16a34a;
  --shadow: 0 8px 20px rgba(15, 23, 42, 0.1);
  --theme-surface: #ffffff;
  --theme-surface-muted: #f1f5f9;
  --theme-input: #ffffff;
  --theme-soft: #fff1f2;
  --theme-radius: 8px;
  --theme-radius-sm: 6px;
  --theme-focus: rgba(225, 29, 72, 0.24);
}

body.theme-chakra {
  color-scheme: light;
  --bg: #f7fafc;
  --panel: #ffffff;
  --panel-muted: #edf2f7;
  --text: #1a202c;
  --muted: #718096;
  --line: #e2e8f0;
  --primary: #3182ce;
  --primary-dark: #2b6cb0;
  --blue: #319795;
  --amber: #d69e2e;
  --red: #e53e3e;
  --green: #38a169;
  --shadow: 0 8px 20px rgba(26, 32, 44, 0.08);
  --theme-surface: #ffffff;
  --theme-surface-muted: #edf2f7;
  --theme-input: #ffffff;
  --theme-soft: #ebf8ff;
  --theme-radius: 8px;
  --theme-radius-sm: 6px;
  --theme-focus: rgba(49, 130, 206, 0.3);
}

body.theme-magic {
  color-scheme: dark;
  --bg: #0b0f16;
  --panel: #111827;
  --panel-muted: #172033;
  --text: #f8fafc;
  --muted: #9ca3af;
  --line: #2b3a55;
  --primary: #22d3ee;
  --primary-dark: #06b6d4;
  --blue: #a78bfa;
  --amber: #fbbf24;
  --red: #fb7185;
  --green: #34d399;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.3);
  --theme-surface: #0e1622;
  --theme-surface-muted: #172033;
  --theme-input: #0c121d;
  --theme-soft: rgba(34, 211, 238, 0.12);
  --theme-radius: 8px;
  --theme-radius-sm: 6px;
  --theme-focus: rgba(34, 211, 238, 0.34);
}

body[class*="theme-"]:not(.theme-default) {
  transition: background-color 180ms ease, color 180ms ease;
}

body[class*="theme-"]:not(.theme-default) :is(.sidebar, .panel, .system-card, .row:not(.header), .connector-card, .wizard-check-row, .checkbox-line, .fallback-details, .auth-box, .dialog-close-button) {
  border-color: var(--line);
  background: var(--theme-surface);
}

body[class*="theme-"]:not(.theme-default) :is(.panel, .system-card, .row:not(.header), .connector-card, .wizard-check-row, .fallback-details, .auth-box) {
  border-radius: var(--theme-radius);
  box-shadow: var(--shadow);
}

body[class*="theme-"]:not(.theme-default) :is(.search-wrap input, .module-form input, .module-form select, .auth-box form input, .auth-inline input, .login-method-select select, .tutorial-dialog-body input, .theme-switcher select) {
  border-color: var(--line);
  border-radius: var(--theme-radius-sm);
  background: var(--theme-input);
  color: var(--text);
}

body[class*="theme-"]:not(.theme-default) :is(input, select, button):focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--theme-focus);
}

body[class*="theme-"]:not(.theme-default) :is(.primary-button, .secondary-button, .ghost-button, .danger-button) {
  border-radius: var(--theme-radius-sm);
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

body[class*="theme-"]:not(.theme-default) .primary-button {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

body[class*="theme-"]:not(.theme-default) .primary-button:hover {
  background: var(--primary-dark);
}

body[class*="theme-"]:not(.theme-default) .secondary-button {
  border-color: var(--line);
  background: var(--theme-surface);
  color: var(--text);
}

body[class*="theme-"]:not(.theme-default) .ghost-button {
  border-color: transparent;
  background: var(--theme-soft);
  color: var(--text);
}

body[class*="theme-"]:not(.theme-default) .danger-button {
  border-color: color-mix(in srgb, var(--red) 35%, var(--line));
  background: color-mix(in srgb, var(--red) 9%, var(--theme-surface));
  color: var(--red);
}

body[class*="theme-"]:not(.theme-default) :is(.nav-item:hover, .nav-item.is-active, .admin-tabs .is-active, .filter-bar .is-active) {
  background: var(--theme-soft);
  color: var(--primary-dark);
}

body[class*="theme-"]:not(.theme-default) :is(.brand-mark, .system-icon) {
  background: var(--theme-soft);
  color: var(--primary);
}

body[class*="theme-"]:not(.theme-default) .brand-mark {
  background: var(--primary);
  color: #ffffff;
  border-radius: var(--theme-radius);
}

body[class*="theme-"]:not(.theme-default) :is(.status-pill, .badge) {
  border-radius: 999px;
}

body[class*="theme-"]:not(.theme-default) :is(.compact-list li, .account-summary > div, .revealed-password, .setup-note, .wizard-summary code, .command-box pre) {
  border-color: var(--line);
  background: var(--theme-surface-muted);
}

body[class*="theme-"]:not(.theme-default) :is(.setup-tutorial-dialog, .setup-tutorial-dialog .dialog-close-button) {
  border-color: var(--line);
  border-radius: var(--theme-radius);
  background: var(--theme-surface);
  color: var(--text);
}

body[class*="theme-"]:not(.theme-default) .tutorial-note {
  border-color: var(--primary);
  background: var(--theme-surface-muted);
  color: var(--muted);
}

.theme-switcher {
  display: grid;
  min-width: 168px;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.theme-switcher select {
  min-height: 36px;
  padding: 6px 28px 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font-size: 13px;
}

body.theme-magic {
  position: relative;
  overflow-x: hidden;
}

body.theme-magic::before {
  position: fixed;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  content: "";
  opacity: 0.2;
  background-image: linear-gradient(rgba(34, 211, 238, 0.08) 1px, transparent 1px), linear-gradient(90deg, rgba(34, 211, 238, 0.08) 1px, transparent 1px);
  background-size: 36px 36px;
  animation: magic-grid-drift 28s linear infinite;
}

body.theme-magic .app-shell {
  position: relative;
  z-index: 1;
}

body.theme-magic .sidebar {
  background: rgba(14, 22, 34, 0.92);
  backdrop-filter: blur(12px);
}

body.theme-magic :is(.panel, .system-card, .row:not(.header), .connector-card, .wizard-check-row) {
  border-color: rgba(34, 211, 238, 0.2);
  background: rgba(17, 24, 39, 0.92);
}

body.theme-magic .primary-button {
  color: #06242a;
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.28);
}

body.theme-magic .brand-mark {
  box-shadow: 0 0 28px rgba(34, 211, 238, 0.28);
}

body.theme-magic .system-card {
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

body.theme-magic .system-card:hover {
  border-color: rgba(34, 211, 238, 0.58);
  box-shadow: 0 0 26px rgba(34, 211, 238, 0.14);
  transform: translateY(-2px);
}

body.theme-magic .success {
  background: rgba(52, 211, 153, 0.16);
  color: #6ee7b7;
}

body.theme-magic .warning {
  background: rgba(251, 191, 36, 0.16);
  color: #fcd34d;
}

body.theme-magic .danger {
  background: rgba(251, 113, 133, 0.16);
  color: #fda4af;
}

body.theme-magic .neutral {
  background: rgba(156, 163, 175, 0.16);
  color: #d1d5db;
}

@keyframes magic-grid-drift {
  from {
    background-position: 0 0;
  }

  to {
    background-position: 36px 36px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.theme-magic::before,
  body.theme-magic .system-card {
    animation: none;
    transition: none;
  }
}

@media (max-width: 1100px) {
  .theme-switcher {
    min-width: 0;
  }
}

@media (max-width: 700px) {
  .theme-switcher {
    width: 100%;
  }
}
