/* Global appearance control and theme tokens. Light is the default; dark follows the same Falepay teal/navy system. */
:root {
  color-scheme: light;
  --appearance-bg: #f7f8fa;
  --appearance-surface: #ffffff;
  --appearance-surface-soft: #f1f5f4;
  --appearance-ink: #102b35;
  --appearance-muted: #718187;
  --appearance-line: #dfe9e6;
  --appearance-accent: #138a76;
  --appearance-accent-strong: #0d6f62;
}

html[data-theme-effective="dark"] {
  color-scheme: dark;
  --appearance-bg: #0e1a1e;
  --appearance-surface: #14272d;
  --appearance-surface-soft: #1a3137;
  --appearance-ink: #edf8f5;
  --appearance-muted: #a4bbb9;
  --appearance-line: #2c474d;
  --appearance-accent: #52d3b5;
  --appearance-accent-strong: #76e4c8;
}

html[data-theme-effective="dark"] body {
  --ink: #edf8f5;
  --muted: #a4bbb9;
  --line: #2c474d;
  --paper: #0e1a1e;
  --card: #14272d;
  --teal: #52d3b5;
  --teal-dark: #76e4c8;
  background: var(--paper);
  color: var(--ink);
}

/* The control stays compact so it can live in both public and authenticated headers. */
.appearance-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--appearance-line);
  border-radius: 10px;
  background: var(--appearance-surface);
  background: color-mix(in srgb, var(--appearance-surface) 88%, transparent);
  color: var(--appearance-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, color .18s ease, transform .18s ease;
}
.appearance-trigger:hover { border-color: color-mix(in srgb, var(--appearance-accent) 44%, var(--appearance-line)); color: var(--appearance-ink); transform: translateY(-1px); }
.appearance-trigger:focus-visible { outline: 2px solid var(--appearance-accent); outline-offset: 3px; }
.appearance-trigger svg { width: 16px; height: 16px; flex: none; }
.appearance-trigger-state { color: var(--appearance-ink); font-weight: 700; }
.appearance-popover {
  position: fixed;
  top: 76px;
  right: 24px;
  z-index: 120;
  width: min(248px, calc(100vw - 32px));
  padding: 10px;
  border: 1px solid var(--appearance-line);
  border-radius: 16px;
  background: var(--appearance-surface);
  background: color-mix(in srgb, var(--appearance-surface) 94%, transparent);
  box-shadow: 0 18px 54px rgba(16, 43, 53, .18), 0 2px 10px rgba(16, 43, 53, .08);
  backdrop-filter: blur(18px);
}
.appearance-popover[hidden] { display: none; }
.appearance-popover > header { padding: 8px 10px 9px; }
.appearance-popover > header strong { display: block; color: var(--appearance-ink); font-size: 13px; }
.appearance-popover > header small { display: block; margin-top: 2px; color: var(--appearance-muted); font-size: 11px; line-height: 1.5; }
.appearance-options { display: grid; gap: 4px; margin: 0; padding: 0; border: 0; }
.appearance-option {
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 44px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--appearance-ink);
  text-align: left;
  cursor: pointer;
}
.appearance-option:hover { background: var(--appearance-surface-soft); }
.appearance-option:focus-visible { outline: 2px solid var(--appearance-accent); outline-offset: 2px; }
.appearance-option.active { border-color: color-mix(in srgb, var(--appearance-accent) 38%, var(--appearance-line)); background: var(--appearance-surface-soft); background: color-mix(in srgb, var(--appearance-accent) 12%, var(--appearance-surface)); }
.appearance-option svg { width: 18px; height: 18px; color: var(--appearance-muted); }
.appearance-option.active svg { color: var(--appearance-accent); }
.appearance-option span { font-size: 12px; font-weight: 650; }
.appearance-option small { color: var(--appearance-muted); font-size: 10px; }
.appearance-option-check { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; color: transparent; }
.appearance-option.active .appearance-option-check { background: var(--appearance-accent); color: #fff; }
.appearance-option-check svg { width: 12px; height: 12px; color: currentColor; }

/* A compact capsule keeps the choice visible without turning a utility
   control into a second navigation panel. The header remains available to
   assistive technology through the clipped title and description. */
.appearance-popover {
  width: 112px;
  min-width: 0;
  max-width: calc(100vw - 32px);
  padding: 5px;
  border-radius: 16px;
}
.appearance-popover > header {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.appearance-options {
  display: grid;
  gap: 3px;
}
.appearance-option {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: auto;
  min-width: 0;
  min-height: 34px;
  padding: 4px 11px;
  border-radius: 999px;
  color: var(--appearance-muted);
  white-space: nowrap;
}
.appearance-option svg,
.appearance-option-check {
  display: none;
}
.appearance-option span {
  font-size: 12px;
  font-weight: 650;
}
.appearance-option small {
  display: none;
}
.appearance-option:hover {
  background: var(--appearance-surface-soft);
  color: var(--appearance-ink);
}
.appearance-option.active {
  border-color: var(--appearance-accent);
  background: var(--appearance-accent);
  color: #092322;
  box-shadow: none;
}
.appearance-option.active:hover {
  background: var(--appearance-accent-strong);
  color: #092322;
}

/* Keep appearance as a utility at the edge of each action row. The setting
   remains easy to find without competing with the primary business actions. */
body.public-home #home .header-actions .login-link { order: 1; }
body.public-home #home .header-actions > .button-small { order: 2; }
body.public-home #home .header-actions .menu-toggle { order: 3; }
body.public-home #home .header-actions .appearance-trigger {
  order: 4;
  min-height: 36px;
  margin-left: 2px;
  padding: 7px 0 7px 18px;
  border: 0;
  border-left: 1px solid var(--appearance-line);
  border-radius: 0;
  background: transparent;
  color: var(--appearance-muted);
}
body.public-home #home .header-actions .appearance-trigger:hover {
  transform: none;
  border-color: var(--appearance-line);
  color: var(--appearance-ink);
}
body.public-home #home .header-actions .appearance-trigger-state {
  padding: 3px 7px;
  border: 1px solid var(--appearance-line);
  border-radius: 999px;
  background: var(--appearance-surface-soft);
  font-size: 11px;
}
body.public-home #appearance-popover {
  top: auto;
  right: auto;
}

html[data-theme-effective="dark"] body.public-home #home .header-actions .appearance-trigger {
  border-left-color: #2c474d;
}
html[data-theme-effective="dark"] body.public-home #home .header-actions .appearance-trigger-state {
  border-color: #2c474d;
  background: #1a3137;
}

/* The workbench and operations utility rows use the same right-edge rule. */
#dashboard .dash-tools .appearance-trigger,
#ops .ops-topbar-actions .appearance-trigger {
  order: 99;
  margin-left: 4px;
}

.auth-shell-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.auth-shell-top .brand { margin-bottom: 0; }

html[data-theme-effective="dark"] .auth-card,
html[data-theme-effective="dark"] #reset-password .auth-card { background: var(--appearance-surface); border-color: var(--appearance-line); box-shadow: 0 24px 70px rgba(0, 0, 0, .24); }
html[data-theme-effective="dark"] .tabs { background: var(--appearance-surface-soft); }
html[data-theme-effective="dark"] .tabs button { color: var(--appearance-muted); }
html[data-theme-effective="dark"] .tabs button.active { background: #203b40; color: var(--appearance-ink); box-shadow: 0 3px 10px rgba(0, 0, 0, .2); }
html[data-theme-effective="dark"] .auth-card :is(label, .row, .auth-foot) { color: var(--appearance-muted); }
html[data-theme-effective="dark"] .auth-card :is(input, select, textarea) { background: #102329; color: var(--appearance-ink); border-color: var(--appearance-line); }
html[data-theme-effective="dark"] .auth-card input::placeholder { color: #6f8b8b; }
html[data-theme-effective="dark"] .auth-card .optional-field { background: #193238; border-color: var(--appearance-line); }
html[data-theme-effective="dark"] .auth-card .optional-field input { background: #102329; }
html[data-theme-effective="dark"] .auth-card .social { background: #193b38; color: var(--appearance-accent-strong); }
html[data-theme-effective="dark"] .auth-card .btn.outline { background: transparent; color: var(--appearance-ink); border-color: var(--appearance-line); }

/* Authentication surfaces need their own contrast hierarchy. The legacy
   primary button used the now-light ink token as its fill while keeping
   white text, which produced a washed-out CTA in dark mode. */
html[data-theme-effective="dark"] #auth .auth-card,
html[data-theme-effective="dark"] #reset-password .auth-card {
  color: var(--appearance-ink);
}
html[data-theme-effective="dark"] #auth .auth-card h1,
html[data-theme-effective="dark"] #reset-password .auth-card h1 {
  color: #f2fff9;
}
html[data-theme-effective="dark"] #auth .auth-card > form > p,
html[data-theme-effective="dark"] #reset-password .auth-card > p,
html[data-theme-effective="dark"] #auth .auth-card .or,
html[data-theme-effective="dark"] #auth .auth-foot,
html[data-theme-effective="dark"] #reset-password .auth-foot {
  color: #a9c3c0;
}
html[data-theme-effective="dark"] #auth .auth-card label,
html[data-theme-effective="dark"] #reset-password .auth-card label,
html[data-theme-effective="dark"] #auth .auth-card .row,
html[data-theme-effective="dark"] #reset-password .auth-card .row {
  color: #c0d5d1;
}
html[data-theme-effective="dark"] #auth .auth-card .row a,
html[data-theme-effective="dark"] #reset-password .auth-card a,
html[data-theme-effective="dark"] #auth .auth-foot a {
  color: var(--appearance-accent-strong);
}
html[data-theme-effective="dark"] #auth .auth-card .auth-shell-top .brand-copy small,
html[data-theme-effective="dark"] #reset-password .auth-shell-top .brand-copy small {
  color: #a9c3c0;
}
html[data-theme-effective="dark"] #auth .tabs button.active {
  background: #24514f;
  color: #f2fff9;
  box-shadow: 0 3px 12px rgba(0, 0, 0, .26), inset 0 1px 0 rgba(255, 255, 255, .05);
}
html[data-theme-effective="dark"] #auth .auth-card :is(input, select, textarea):focus,
html[data-theme-effective="dark"] #reset-password .auth-card :is(input, select, textarea):focus {
  border-color: var(--appearance-accent);
  box-shadow: 0 0 0 3px rgba(82, 211, 181, .16);
}
html[data-theme-effective="dark"] #auth .auth-card input::placeholder,
html[data-theme-effective="dark"] #reset-password .auth-card input::placeholder {
  color: #8faead;
}
html[data-theme-effective="dark"] #auth .auth-card input[type="checkbox"],
html[data-theme-effective="dark"] #reset-password .auth-card input[type="checkbox"] {
  accent-color: var(--appearance-accent);
}
html[data-theme-effective="dark"] #auth .auth-card .optional-field {
  background: linear-gradient(145deg, #1a373c, #153039);
  border-color: #2c5960;
}
html[data-theme-effective="dark"] #auth .auth-card .optional-field .field-label {
  color: #d9efea;
}
html[data-theme-effective="dark"] #auth .auth-card .optional-field .field-label em {
  color: #e7fff8;
  background: #2b7f70;
  border: 1px solid #52d3b5;
}
html[data-theme-effective="dark"] #auth .auth-card .optional-field .field-help,
html[data-theme-effective="dark"] #auth .auth-card .field-hint {
  color: #a9c3c0;
}
html[data-theme-effective="dark"] #auth .auth-card .terms-check a {
  color: var(--appearance-accent-strong);
}
html[data-theme-effective="dark"] #auth .auth-card .btn.primary,
html[data-theme-effective="dark"] #reset-password .auth-card .btn.primary {
  min-height: 50px;
  border: 1px solid #76e4c8;
  border-radius: 12px;
  background: linear-gradient(135deg, #59d9bc 0%, #35b795 100%);
  color: #082622;
  box-shadow: 0 12px 26px rgba(35, 176, 145, .2), inset 0 1px 0 rgba(255, 255, 255, .28);
  letter-spacing: .01em;
}
html[data-theme-effective="dark"] #auth .auth-card .btn.primary:hover,
html[data-theme-effective="dark"] #reset-password .auth-card .btn.primary:hover {
  background: linear-gradient(135deg, #76e4c8 0%, #52d3b5 100%);
  color: #061d1b;
  box-shadow: 0 15px 30px rgba(35, 176, 145, .28), inset 0 1px 0 rgba(255, 255, 255, .32);
}
html[data-theme-effective="dark"] #auth .auth-card .btn.primary:focus-visible,
html[data-theme-effective="dark"] #reset-password .auth-card .btn.primary:focus-visible {
  outline: 3px solid rgba(118, 228, 200, .48);
  outline-offset: 3px;
}
html[data-theme-effective="dark"] #auth .auth-card .btn.primary:disabled,
html[data-theme-effective="dark"] #reset-password .auth-card .btn.primary:disabled {
  background: #2a4f4c;
  border-color: #3b6b65;
  color: #a9c3c0;
  box-shadow: none;
}

/* Dark public pages: preserve the editorial structure while changing surfaces, contrast and depth. */
html[data-theme-effective="dark"] body.public-home {
  --ink: #edf8f5;
  --muted: #a4bbb9;
  --accent: #52d3b5;
  --accent-hover: #76e4c8;
  --accent-soft: #1b3a39;
  --page: #0e1a1e;
  --surface: #14272d;
  --success: #66d9ad;
  --success-bg: #193b38;
  --warning: #e8c77f;
  --warning-bg: #3b3420;
  --danger: #f29d9d;
  --danger-bg: #3c2326;
  --accent-light: #203b3f;
  --paper: #0e1a1e;
  --ground: #13262c;
  --line: #2c474d;
  background: var(--paper);
  color: var(--ink);
}
html[data-theme-effective="dark"] body.public-home,
html[data-theme-effective="dark"] body.public-home #home {
  background-color: var(--page);
}
html[data-theme-effective="dark"] body.public-home::before {
  opacity: .035;
  mix-blend-mode: screen;
}
html[data-theme-effective="dark"] body.public-home #home .site-header { background: rgba(14, 26, 30, .9); border-color: var(--line); }
html[data-theme-effective="dark"] body.public-home #home .brand small,
html[data-theme-effective="dark"] body.public-home #home .header-inner nav a,
html[data-theme-effective="dark"] body.public-home #home .hero-note,
html[data-theme-effective="dark"] body.public-home #home .channel-note,
html[data-theme-effective="dark"] body.public-home #home .section-intro,
html[data-theme-effective="dark"] body.public-home #home .panel-copy > small,
html[data-theme-effective="dark"] body.public-home #home .steps p,
html[data-theme-effective="dark"] body.public-home #home .plan-top p,
html[data-theme-effective="dark"] body.public-home #home .rate > span,
html[data-theme-effective="dark"] body.public-home #home .pricing-note,
html[data-theme-effective="dark"] body.public-home #home .pricing-details,
html[data-theme-effective="dark"] body.public-home #home .visual-caption { color: var(--appearance-muted); }
html[data-theme-effective="dark"] body.public-home #home .hero-description,
html[data-theme-effective="dark"] body.public-home #home .panel-copy > p,
html[data-theme-effective="dark"] body.public-home #home .terminal-row small,
html[data-theme-effective="dark"] body.public-home #home .sample-order small,
html[data-theme-effective="dark"] body.public-home #home .reconcile-summary small { color: var(--appearance-muted); }
html[data-theme-effective="dark"] body.public-home #home .audience,
html[data-theme-effective="dark"] body.public-home #home .product-tabs,
html[data-theme-effective="dark"] body.public-home #home .steps-section,
html[data-theme-effective="dark"] body.public-home #home .rate,
html[data-theme-effective="dark"] body.public-home #home .terminal-row,
html[data-theme-effective="dark"] body.public-home #home .terminal-footer,
html[data-theme-effective="dark"] body.public-home #home .sample-order,
html[data-theme-effective="dark"] body.public-home #home .reconcile-line { border-color: var(--line); }
html[data-theme-effective="dark"] body.public-home #home .product-panel,
html[data-theme-effective="dark"] body.public-home #home .steps-section,
html[data-theme-effective="dark"] body.public-home #home .pricing-details > div,
html[data-theme-effective="dark"] body.public-home #home .reconcile-summary { background: var(--ground); }
html[data-theme-effective="dark"] body.public-home #home .terminal-demo,
html[data-theme-effective="dark"] body.public-home #home .price-card,
html[data-theme-effective="dark"] body.public-home #home .workspace { background: var(--appearance-surface); border-color: var(--line); }
html[data-theme-effective="dark"] body.public-home #home .terminal-icon,
html[data-theme-effective="dark"] body.public-home #home .mock-order-icon { background: var(--appearance-surface-soft); }
html[data-theme-effective="dark"] body.public-home #home .button { background: #dff8ef; color: #0c2425; }
html[data-theme-effective="dark"] body.public-home #home .button:hover { background: #fff; }
html[data-theme-effective="dark"] body.public-home #home .button-outline,
html[data-theme-effective="dark"] body.public-home #home .button-light { background: transparent; color: var(--ink); border-color: var(--line); }
html[data-theme-effective="dark"] body.public-home #home .button-outline:hover,
html[data-theme-effective="dark"] body.public-home #home .button-light:hover { background: var(--appearance-surface-soft); }
html[data-theme-effective="dark"] body.public-home #home .price-card.featured { border-color: var(--appearance-accent); box-shadow: 0 0 0 1px var(--appearance-accent); }
html[data-theme-effective="dark"] body.public-home #home .plan-label,
html[data-theme-effective="dark"] body.public-home #home .pill { background: var(--appearance-surface-soft); color: var(--appearance-muted); }
html[data-theme-effective="dark"] body.public-home #home .developer-section { background: #101d21; }
html[data-theme-effective="dark"] body.public-home #home .site-footer { background: #0b1518; border-color: var(--line); color: var(--appearance-muted); }

/* The atmosphere layer uses page-level IDs with higher specificity than the
   base component rules. Keep those surfaces in the same dark palette. */
html[data-theme-effective="dark"] body.public-home #home #start {
  border-color: var(--line);
  background:
    radial-gradient(ellipse at 1% 82%, rgba(82, 211, 181, .07) 0%, transparent 52%),
    radial-gradient(ellipse at 94% 18%, rgba(100, 151, 166, .13) 0%, transparent 60%),
    linear-gradient(135deg, #13262c 0%, #0f2025 65%, #12252a 100%);
}
html[data-theme-effective="dark"] body.public-home #home #developers {
  border-color: var(--line);
  background:
    radial-gradient(ellipse at 100% 8%, rgba(82, 211, 181, .08) 0%, transparent 48%),
    radial-gradient(ellipse at 6% 90%, rgba(100, 151, 166, .14) 0%, transparent 58%),
    linear-gradient(150deg, #13262c 0%, #0f2025 65%, #12252a 100%);
  color: var(--ink);
}
html[data-theme-effective="dark"] body.public-home #home #start::before,
html[data-theme-effective="dark"] body.public-home #home #developers::before {
  opacity: .035;
  mix-blend-mode: screen;
}
html[data-theme-effective="dark"] body.public-home #home #developers::after {
  background-image:
    linear-gradient(rgba(130, 177, 179, .08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(130, 177, 179, .08) 1px, transparent 1px);
  opacity: .45;
}
html[data-theme-effective="dark"] body.public-home #home :is(.eyebrow, .developer-copy .eyebrow) { color: var(--appearance-muted); }
html[data-theme-effective="dark"] body.public-home #home :is(.steps-section .text-link, .steps p, .developer-copy > p:not(.eyebrow), .developer-copy > small, .developer-features, .developer-text, .faq-intro, .faq-list details > p, .closing p, .footer-contact, .footer-links, .footer-bottom) { color: var(--appearance-muted); }
html[data-theme-effective="dark"] body.public-home #home :is(.steps li, .steps li::before, .hero-channels, .faq-list summary .icon) { border-color: var(--line); }
html[data-theme-effective="dark"] body.public-home #home .growth-line { stroke: var(--appearance-accent); }
html[data-theme-effective="dark"] body.public-home #home .growth-plot::before { background: radial-gradient(ellipse at 68% 60%, rgba(82, 211, 181, .12), transparent 65%); }
html[data-theme-effective="dark"] body.public-home #home .growth-toggle:hover { background: var(--appearance-surface-soft); color: var(--appearance-ink); }
html[data-theme-effective="dark"] body.public-home #home .payment-brand-link { background: rgba(255, 255, 255, .92); border-color: rgba(255, 255, 255, .12); }
html[data-theme-effective="dark"] body.public-home #home .payment-brand-link:hover { background: #fff; border-color: var(--appearance-accent); }
html[data-theme-effective="dark"] body.public-home #home .payment-brand-divider { background: var(--line); }
html[data-theme-effective="dark"] body.public-home #home .terminal-icon { color: var(--appearance-accent); background: var(--appearance-surface-soft); }
html[data-theme-effective="dark"] body.public-home #home .demo-tag,
html[data-theme-effective="dark"] body.public-home #home .code-header > span:last-child,
html[data-theme-effective="dark"] body.public-home #home .code-muted { color: var(--appearance-muted); }
html[data-theme-effective="dark"] body.public-home #home .price-card {
  background: var(--appearance-surface);
  border-color: var(--line);
}
html[data-theme-effective="dark"] body.public-home #home .price-card.featured,
html[data-theme-effective="dark"] body.public-home #home .price-card.is-selected { border-color: var(--appearance-accent); box-shadow: 0 0 0 1px var(--appearance-accent); }
html[data-theme-effective="dark"] body.public-home #home .price-card li,
html[data-theme-effective="dark"] body.public-home #home .plan-price > span,
html[data-theme-effective="dark"] body.public-home #home .plan-dialog-features li { color: var(--appearance-muted); }
html[data-theme-effective="dark"] body.public-home #home .price-card li .icon,
html[data-theme-effective="dark"] body.public-home #home .plan-dialog-features li::before { color: var(--appearance-accent); }
html[data-theme-effective="dark"] body.public-home #home .plan-label { background: var(--appearance-surface-soft); color: var(--appearance-muted); }
html[data-theme-effective="dark"] body.public-home #home .price-card .button,
html[data-theme-effective="dark"] body.public-home #home .price-card:not(.is-selected):not(.featured) .button,
html[data-theme-effective="dark"] body.public-home #home .price-card:hover .button {
  background: var(--appearance-surface-soft);
  color: var(--appearance-ink);
  border-color: var(--line);
}
html[data-theme-effective="dark"] body.public-home #home .price-card.featured .button,
html[data-theme-effective="dark"] body.public-home #home .price-card.is-selected .button,
html[data-theme-effective="dark"] body.public-home #home .price-card.is-selected:hover .button {
  background: var(--appearance-accent);
  color: #092322;
  border-color: var(--appearance-accent);
}
html[data-theme-effective="dark"] body.public-home #home .price-card .button:hover { background: var(--appearance-accent-strong); color: #092322; border-color: var(--appearance-accent-strong); }
html[data-theme-effective="dark"] body.public-home #home .plan-switcher { background: var(--appearance-surface-soft); }
html[data-theme-effective="dark"] body.public-home #home .plan-dialog-features li { color: var(--appearance-muted); }
html[data-theme-effective="dark"] body.public-home #home .plan-dialog-note { background: var(--ground); color: var(--appearance-muted); }
html[data-theme-effective="dark"] body.public-home #home .faq-list summary .icon { color: var(--appearance-muted); }
html[data-theme-effective="dark"] body.public-home #home .site-footer { background: #0b1518; }

/* Dark merchant workbench: the visual hierarchy stays identical to light mode. */
html[data-theme-effective="dark"] #dashboard {
  --dash-canvas: #0e1a1e;
  --dash-surface: #14272d;
  --dash-surface-soft: #1a3137;
  --dash-ink: #edf8f5;
  --dash-muted: #a4bbb9;
  --dash-muted-soft: #8eaaa9;
  --dash-line: #2c474d;
  --dash-primary: #52d3b5;
  --dash-primary-strong: #76e4c8;
  --dash-primary-soft: #1b3a39;
  background: radial-gradient(circle at 91% 4%, rgba(82,211,181,.10), transparent 26rem), linear-gradient(145deg, #102227 0%, var(--dash-canvas) 48%, #122429 100%);
  color: var(--dash-ink);
}
html[data-theme-effective="dark"] #dashboard .merchant-sidebar { background: #0a2028; border-right-color: #1e3a42; }
html[data-theme-effective="dark"] #dashboard .merchant-workspace { background: rgba(28, 69, 78, .72); border-color: rgba(150, 220, 204, .2); }
html[data-theme-effective="dark"] #dashboard .dash-header { background: rgba(14, 26, 30, .86); border-bottom-color: var(--dash-line); }
html[data-theme-effective="dark"] #dashboard .dash-tools .btn { background: rgba(20, 39, 45, .88); color: var(--dash-ink); border-color: var(--dash-line); }
html[data-theme-effective="dark"] #dashboard .dash-tools .btn.primary { background: var(--dash-primary); color: #092322; border-color: var(--dash-primary); }
html[data-theme-effective="dark"] #dashboard .overview-range,
html[data-theme-effective="dark"] #dashboard .overview-metric-toggle { background: var(--dash-surface-soft); border-color: var(--dash-line); }
html[data-theme-effective="dark"] #dashboard .overview-coverage-note { background: #2a2a1d; border-color: #5d5630; color: #e8d79c; }
html[data-theme-effective="dark"] #dashboard :is(.overview-kpi, .overview-section .overview-main-grid > .panel, .overview-section .overview-lower-grid > .panel, .dashboard-section:not(.overview-section) .panel) { background: var(--dash-surface); border-color: var(--dash-line); box-shadow: 0 10px 30px rgba(0, 0, 0, .18); }
html[data-theme-effective="dark"] #dashboard .overview-kpi-primary { background: linear-gradient(145deg, #173e3a, #19302f); border-color: #2d6e5e; }
html[data-theme-effective="dark"] #dashboard :is(.section-heading h2, .panel h2, .panel h3, .overview-kpi strong, .overview-kpi-label, .overview-channel-list b, table th, table td, .settings-list dd) { color: var(--dash-ink); }
html[data-theme-effective="dark"] #dashboard :is(.section-heading p, .panel small, .overview-kpi small, .overview-channel-panel small, .settings-note, .empty-state, .overview-sync-time, .overview-chart-labels) { color: var(--dash-muted); }
html[data-theme-effective="dark"] #dashboard :is(table th, table td, .dashboard-section:not(.overview-section) :is(table th, table td)) { border-color: #294247; }
html[data-theme-effective="dark"] #dashboard .dashboard-section:not(.overview-section) :is(input, select, textarea) { background: #102329; color: var(--dash-ink); border-color: var(--dash-line); }
html[data-theme-effective="dark"] #dashboard .overview-quick-grid button { background: var(--dash-surface-soft); border-color: var(--dash-line); color: var(--dash-ink); }
html[data-theme-effective="dark"] #dashboard .overview-quick-grid button:hover { background: var(--dash-primary-soft); border-color: var(--dash-primary); }
html[data-theme-effective="dark"] #dashboard .overview-grid-lines line { stroke: #315056; }
html[data-theme-effective="dark"] #dashboard .overview-trend-line { stroke: #67ddc0; }
html[data-theme-effective="dark"] #dashboard .overview-trend-area { fill: rgba(82, 211, 181, .18); }

/* The operations console uses the same surfaces and preserves its strong active state. */
html[data-theme-effective="dark"] #ops { background: var(--appearance-bg); color: var(--appearance-ink); }
html[data-theme-effective="dark"] #ops .ops-content,
html[data-theme-effective="dark"] #ops .ops-topbar { background: var(--appearance-bg); }
html[data-theme-effective="dark"] #ops .panel,
html[data-theme-effective="dark"] #ops .ops-header,
html[data-theme-effective="dark"] #ops .ops-readiness-banner { background: var(--appearance-surface); border-color: var(--appearance-line); color: var(--appearance-ink); }
html[data-theme-effective="dark"] #ops :is(h1, h2, h3, h4, strong, th, td) { color: var(--appearance-ink); }
html[data-theme-effective="dark"] #ops :is(p, small, label, .ops-muted) { color: var(--appearance-muted); }
html[data-theme-effective="dark"] #ops :is(input, select, textarea) { background: #102329; color: var(--appearance-ink); border-color: var(--appearance-line); }

@media (max-width: 720px) {
  .appearance-trigger { padding-inline: 8px; }
  .appearance-trigger > span:first-of-type { display: none; }
  .appearance-popover { top: 64px; right: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .appearance-trigger { transition: none; }
}

/* Auth is a destination in the same product journey as the homepage. Give it
   a full editorial frame so the form feels intentional instead of floating in
   an oversized empty canvas. */
#auth {
  position: relative;
  min-height: calc(100vh - 76px);
  overflow: hidden;
  background:
    radial-gradient(circle at 83% 14%, color-mix(in srgb, var(--appearance-accent) 13%, transparent), transparent 26rem),
    radial-gradient(circle at 8% 86%, color-mix(in srgb, #6d61ff 8%, transparent), transparent 22rem),
    var(--appearance-bg);
  color: var(--appearance-ink);
}
#auth::before,
#auth::after {
  content: "";
  position: absolute;
  border: 1px solid color-mix(in srgb, var(--appearance-accent) 18%, transparent);
  border-radius: 999px;
  pointer-events: none;
}
#auth::before { width: 36rem; height: 36rem; right: -18rem; top: 7rem; }
#auth::after { width: 25rem; height: 25rem; left: -15rem; bottom: -13rem; border-color: color-mix(in srgb, #6d61ff 13%, transparent); }
#auth .auth-shell {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 64px));
  min-height: calc(100vh - 76px);
  margin: 0 auto;
  padding: 48px 0 64px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(460px, 540px);
  grid-template-rows: auto 1fr auto;
  align-items: center;
  column-gap: clamp(64px, 5vw, 80px);
}
#auth .auth-shell-top {
  grid-column: 1 / -1;
  grid-row: 1;
  width: 100%;
  margin-bottom: 0;
}
#auth .auth-shell-top .brand-copy [data-brand-en] { color: var(--appearance-ink); }
#auth .auth-shell-top .brand-copy [data-brand-zh] { color: var(--appearance-muted); }
#auth .auth-shell-top .brand img { width: 38px; height: 38px; border-radius: 10px; }
#auth .auth-shell-top .brand-copy [data-brand-en] { font-size: 24px; line-height: 1; }
#auth .auth-shell-top .brand-copy [data-brand-zh] { font-size: 10px; letter-spacing: .08em; }
#auth .auth-intro {
  grid-column: 1;
  grid-row: 2 / span 2;
  align-self: start;
  max-width: 500px;
  padding: 32px 0 20px;
}
#auth .auth-kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 22px;
  color: var(--appearance-accent-strong);
  font: 700 12px/1.2 "DM Mono", monospace;
  letter-spacing: .1em;
}
#auth .auth-kicker::before { content: ""; width: 32px; height: 2px; border-radius: 999px; background: var(--appearance-accent); }
#auth .auth-intro h1 {
  margin: 0;
  color: var(--appearance-ink);
  font-size: clamp(42px, 5vw, 72px);
  line-height: 1.08;
  letter-spacing: -.07em;
}
#auth .auth-intro h1 span { color: var(--appearance-accent-strong); }
#auth .auth-intro-copy {
  max-width: 30em;
  margin: 28px 0 0;
  color: var(--appearance-muted);
  font-size: 16px;
  line-height: 1.9;
}
#auth .auth-benefits {
  display: grid;
  gap: 0;
  margin: 42px 0 0;
  padding: 0;
  list-style: none;
}
#auth .auth-benefits li {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-top: 1px solid var(--appearance-line);
}
#auth .auth-benefits li > span {
  flex: none;
  padding-top: 2px;
  color: var(--appearance-accent);
  font: 700 11px/1.2 "DM Mono", monospace;
}
#auth .auth-benefits strong { display: block; color: var(--appearance-ink); font-size: 14px; }
#auth .auth-benefits small { display: block; margin-top: 4px; color: var(--appearance-muted); font-size: 12px; line-height: 1.5; }
#auth .auth-card {
  grid-column: 2;
  grid-row: 2;
  width: 100%;
  padding: 40px;
  border: 1px solid var(--appearance-line);
  border-radius: 24px;
  background: color-mix(in srgb, var(--appearance-surface) 93%, transparent);
  box-shadow: 0 24px 70px color-mix(in srgb, #102b35 16%, transparent), 0 2px 12px color-mix(in srgb, #102b35 8%, transparent);
  backdrop-filter: blur(18px);
}
#auth .auth-foot {
  grid-column: 2;
  grid-row: 3;
  margin: 16px 0 0;
  color: var(--appearance-muted);
}
#auth .auth-foot a { color: var(--appearance-accent-strong); }
html[data-theme-effective="dark"] #auth {
  background:
    radial-gradient(circle at 86% 9%, rgba(82, 211, 181, .12), transparent 28rem),
    radial-gradient(circle at 6% 87%, rgba(105, 105, 255, .12), transparent 25rem),
    linear-gradient(145deg, #0d1b20 0%, #0e1a1e 55%, #10252a 100%);
}
html[data-theme-effective="dark"] #auth .auth-card {
  background: rgba(20, 39, 45, .86);
  border-color: #2c5960;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .28), inset 0 1px 0 rgba(255, 255, 255, .03);
}
html[data-theme-effective="dark"] #auth .auth-intro h1 { color: #edf8f5; }
html[data-theme-effective="dark"] #auth .auth-intro h1 span { color: #76e4c8; }

/* Align the desktop intro's kicker with the login card while keeping the text
   column close enough to read as one composition. */
@media (min-width: 901px) {
  #auth .auth-shell {
    grid-template-rows: auto auto auto;
    align-items: start;
    align-content: start;
  }
  #auth .auth-intro { grid-row: 2; transform: translateY(104px); }
  #auth .auth-card { grid-row: 2; align-self: start; margin-top: 136px; }
  #auth .auth-foot { grid-row: 3; align-self: start; }
}

@media (max-width: 900px) {
  #auth .auth-shell {
    width: min(620px, calc(100% - 32px));
    min-height: auto;
    padding: 34px 0 50px;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: 0;
  }
  #auth .auth-shell-top { grid-column: 1; grid-row: 1; margin-bottom: 30px; }
  #auth .auth-intro { display: none; }
  #auth .auth-card { grid-column: 1; grid-row: 2; padding: 32px; border-radius: 22px; }
  #auth .auth-foot { grid-column: 1; grid-row: 3; }
}
@media (max-width: 520px) {
  #auth .auth-shell { width: calc(100% - 24px); padding-top: 24px; }
  #auth .auth-card { padding: 24px 18px; border-radius: 20px; }
  #auth .auth-shell-top { margin-bottom: 22px; }
  #auth .auth-shell-top .brand img { width: 34px; height: 34px; border-radius: 9px; }
  #auth .auth-shell-top .brand-copy [data-brand-en] { font-size: 22px; }
}

html[data-theme-effective="dark"] body.public-home #home .start-preflight {
  border-color: var(--line);
  background: color-mix(in srgb, var(--appearance-surface) 72%, transparent);
  box-shadow: 0 18px 38px -34px rgba(0, 0, 0, .68);
}
html[data-theme-effective="dark"] body.public-home #home .start-preflight-copy strong,
html[data-theme-effective="dark"] body.public-home #home .start-preflight-items b { color: var(--appearance-ink); }
html[data-theme-effective="dark"] body.public-home #home .start-preflight-copy small,
html[data-theme-effective="dark"] body.public-home #home .start-preflight-items small { color: var(--appearance-muted); }
html[data-theme-effective="dark"] body.public-home #home .start-preflight-items span { border-color: var(--line); }

/* Product preview payment wordmarks use dark-mode variants so the icon colors stay intact
   while the baked-in brand names remain legible on the dark surface. */
html[data-theme-effective="dark"] body.public-home #home .payment-mini-logos img[src*="wechat-pay-logo"] {
  content: url("assets/wechat-pay-logo-dark.svg");
}
html[data-theme-effective="dark"] body.public-home #home .payment-mini-logos img[src*="alipay-logo"] {
  content: url("assets/alipay-logo-dark.png");
}

/* Legal pages share the public site's editorial rhythm instead of the older
   compact app-card treatment. Keep the document readable while giving the
   page the same surfaces, accent and appearance control as the homepage. */
html:has(> body > #legal:not(.hidden)) { scroll-padding-top: 96px; }
body:has(> #legal:not(.hidden)) {
  background:
    radial-gradient(circle at 86% 5%, rgba(22, 184, 151, .10), transparent 27rem),
    radial-gradient(circle at 6% 92%, rgba(109, 97, 255, .07), transparent 25rem),
    var(--appearance-bg);
  color: var(--appearance-ink);
}
body:has(> #legal:not(.hidden)) > .topbar:not(.hidden) {
  position: sticky;
  top: 0;
  z-index: 20;
  width: min(1184px, calc(100% - 96px));
  min-height: 82px;
  height: auto;
  margin: 0 auto;
  padding: 16px 0;
  gap: 32px;
  border-bottom: 1px solid var(--appearance-line);
  background: color-mix(in srgb, var(--appearance-bg) 92%, transparent);
  backdrop-filter: blur(14px);
}
body:has(> #legal:not(.hidden)) > .topbar:not(.hidden) .brand { gap: 9px; color: var(--appearance-ink); }
body:has(> #legal:not(.hidden)) > .topbar:not(.hidden) .brand img { width: 38px; height: 38px; border-radius: 9px; }
body:has(> #legal:not(.hidden)) > .topbar:not(.hidden) .brand-copy { display: grid; gap: 4px; line-height: 1; }
body:has(> #legal:not(.hidden)) > .topbar:not(.hidden) .brand-copy small { color: var(--appearance-muted); font-size: 10px; letter-spacing: 3px; }
body:has(> #legal:not(.hidden)) > .topbar:not(.hidden) .brand-copy span { color: var(--appearance-ink); font-size: 24px; letter-spacing: -1.1px; }
body:has(> #legal:not(.hidden)) > .topbar:not(.hidden) nav { display: flex; flex: 1; gap: 30px; margin-left: auto; font-size: 13px; }
body:has(> #legal:not(.hidden)) > .topbar:not(.hidden) nav a { color: var(--appearance-muted); }
body:has(> #legal:not(.hidden)) > .topbar:not(.hidden) nav a:hover { color: var(--appearance-accent); }
body:has(> #legal:not(.hidden)) > .topbar:not(.hidden) .nav-actions { display: flex; align-items: center; gap: 16px; margin-left: 0; }
body:has(> #legal:not(.hidden)) > .topbar:not(.hidden) .nav-actions .appearance-trigger { min-height: 36px; padding: 7px 0 7px 16px; border: 0; border-left: 1px solid var(--appearance-line); border-radius: 0; background: transparent; color: var(--appearance-muted); }
body:has(> #legal:not(.hidden)) > .topbar:not(.hidden) .nav-actions .appearance-trigger:hover { transform: none; border-color: var(--appearance-line); color: var(--appearance-ink); }
body:has(> #legal:not(.hidden)) > .topbar:not(.hidden) .nav-actions .appearance-trigger-state { padding: 3px 7px; border: 1px solid var(--appearance-line); border-radius: 999px; background: var(--appearance-surface-soft); font-size: 11px; }
body:has(> #legal:not(.hidden)) > .topbar:not(.hidden) .nav-actions .btn { border-radius: 9px; }
body:has(> #legal:not(.hidden)) > .topbar:not(.hidden) .nav-actions .btn.ghost { color: var(--appearance-ink); }
body:has(> #legal:not(.hidden)) > .topbar:not(.hidden) .nav-actions .btn.primary { background: var(--appearance-ink); color: var(--appearance-surface); box-shadow: 0 8px 22px color-mix(in srgb, var(--appearance-ink) 18%, transparent); }
body:has(> #legal:not(.hidden)) > .topbar:not(.hidden) .menu { display: none; }

body:has(> #legal:not(.hidden)) #legal.legal-page {
  display: block;
  min-height: calc(100vh - 82px);
  padding: clamp(54px, 8vw, 96px) 0 120px;
}
body:has(> #legal:not(.hidden)) #legal .legal-shell { width: min(900px, calc(100% - 48px)); max-width: none; margin: 0 auto; }
body:has(> #legal:not(.hidden)) #legal .legal-shell > .eyebrow { display: inline-flex; align-items: center; gap: 10px; margin: 0 0 20px; color: var(--appearance-accent); font: 700 11px/1.2 "DM Mono", monospace; letter-spacing: .13em; text-transform: uppercase; }
body:has(> #legal:not(.hidden)) #legal .legal-shell > .eyebrow::before { content: ""; width: 24px; height: 2px; background: currentColor; }
body:has(> #legal:not(.hidden)) #legal .legal-shell > h1 { margin: 0; color: var(--appearance-ink); font-size: clamp(38px, 5vw, 58px); line-height: 1.1; letter-spacing: -.065em; }
body:has(> #legal:not(.hidden)) #legal .legal-draft { margin: 14px 0 30px; color: var(--appearance-muted); font-size: 12px; line-height: 1.7; }
body:has(> #legal:not(.hidden)) #legal .legal-tabs { display: flex; gap: 8px; margin: 0 0 24px; border-bottom: 1px solid var(--appearance-line); }
body:has(> #legal:not(.hidden)) #legal .legal-tab { padding: 12px 16px 13px; border-bottom: 2px solid transparent; color: var(--appearance-muted); font-size: 13px; font-weight: 600; }
body:has(> #legal:not(.hidden)) #legal .legal-tab:hover { color: var(--appearance-ink); }
body:has(> #legal:not(.hidden)) #legal .legal-tab.active { border-bottom-color: var(--appearance-accent); color: var(--appearance-accent-strong); }
body:has(> #legal:not(.hidden)) #legal .legal-card { padding: clamp(28px, 5vw, 46px); border: 1px solid var(--appearance-line); border-radius: 18px; background: color-mix(in srgb, var(--appearance-surface) 94%, transparent); box-shadow: 0 24px 70px color-mix(in srgb, var(--appearance-ink) 10%, transparent); }
body:has(> #legal:not(.hidden)) #legal .legal-card > p:first-child { margin: 0 0 24px; }
body:has(> #legal:not(.hidden)) #legal .legal-card > p:first-child a { display: inline-flex; align-items: center; gap: 8px; color: var(--appearance-accent-strong); font-size: 12px; font-weight: 700; }
body:has(> #legal:not(.hidden)) #legal .legal-card > p:first-child a::after { content: "↗"; font-size: 14px; }
body:has(> #legal:not(.hidden)) #legal .legal-card h2 { margin: 0 0 12px; color: var(--appearance-ink); font-size: clamp(25px, 3vw, 31px); line-height: 1.25; letter-spacing: -.045em; }
body:has(> #legal:not(.hidden)) #legal .legal-card h3 { margin: 34px 0 10px; padding-top: 22px; border-top: 1px solid var(--appearance-line); color: var(--appearance-ink); font-size: 16px; line-height: 1.4; letter-spacing: -.02em; }
body:has(> #legal:not(.hidden)) #legal .legal-card h2 + p + h3 { margin-top: 30px; padding-top: 0; border-top: 0; }
body:has(> #legal:not(.hidden)) #legal .legal-card p { margin: 0 0 13px; color: var(--appearance-muted); font-size: 14px; line-height: 1.95; }
body:has(> #legal:not(.hidden)) #legal .legal-card strong { color: var(--appearance-ink); font-weight: 700; }
body:has(> #legal:not(.hidden)) #legal .legal-card a { color: var(--appearance-accent-strong); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--appearance-accent) 35%, transparent); text-underline-offset: 3px; }
body:has(> #legal:not(.hidden)) #legal .legal-card .table-scroll { overflow-x: auto; margin: 18px 0 22px; border: 1px solid var(--appearance-line); border-radius: 12px; }
body:has(> #legal:not(.hidden)) #legal .legal-card table { width: 100%; min-width: 620px; border-collapse: collapse; color: var(--appearance-muted); font-size: 12px; line-height: 1.75; }
body:has(> #legal:not(.hidden)) #legal .legal-card td { padding: 13px 14px; border-bottom: 1px solid var(--appearance-line); vertical-align: top; }
body:has(> #legal:not(.hidden)) #legal .legal-card tr:last-child td { border-bottom: 0; }
body:has(> #legal:not(.hidden)) #legal .legal-card tr:first-child td { color: var(--appearance-ink); font-weight: 700; background: var(--appearance-surface-soft); }
body:has(> #legal:not(.hidden)) #legal .legal-card :is(a, button):focus-visible { outline: 3px solid var(--appearance-accent); outline-offset: 4px; }

html[data-theme-effective="dark"] body:has(> #legal:not(.hidden)) > .topbar:not(.hidden) .nav-actions .btn.primary { background: var(--appearance-accent); color: #092322; }
html[data-theme-effective="dark"] body:has(> #legal:not(.hidden)) #legal .legal-card { background: var(--appearance-surface); box-shadow: 0 24px 70px rgba(0, 0, 0, .24); }
html[data-theme-effective="dark"] body:has(> #legal:not(.hidden)) #legal .legal-card tr:first-child td { background: var(--appearance-surface-soft); }

@media (max-width: 900px) {
  body:has(> #legal:not(.hidden)) > .topbar:not(.hidden) { width: calc(100% - 48px); }
  body:has(> #legal:not(.hidden)) > .topbar:not(.hidden) nav { gap: 18px; }
  body:has(> #legal:not(.hidden)) > .topbar:not(.hidden) .nav-actions { gap: 8px; }
}
@media (max-width: 650px) {
  body:has(> #legal:not(.hidden)) > .topbar:not(.hidden) { width: calc(100% - 30px); min-height: 68px; padding: 10px 0; }
  body:has(> #legal:not(.hidden)) > .topbar:not(.hidden) nav,
  body:has(> #legal:not(.hidden)) > .topbar:not(.hidden) .nav-actions .btn { display: none; }
  body:has(> #legal:not(.hidden)) > .topbar:not(.hidden) .nav-actions { margin-left: auto; }
  body:has(> #legal:not(.hidden)) > .topbar:not(.hidden) .nav-actions .appearance-trigger { border-left: 0; padding-left: 0; }
  body:has(> #legal:not(.hidden)) > .topbar:not(.hidden) .menu { display: block; margin-left: 0; color: var(--appearance-ink); }
  body:has(> #legal:not(.hidden)) #legal.legal-page { padding: 48px 0 80px; }
  body:has(> #legal:not(.hidden)) #legal .legal-shell { width: calc(100% - 30px); }
  body:has(> #legal:not(.hidden)) #legal .legal-tabs { overflow-x: auto; }
  body:has(> #legal:not(.hidden)) #legal .legal-tab { flex: none; padding-inline: 10px; }
  body:has(> #legal:not(.hidden)) #legal .legal-card { padding: 24px 20px; border-radius: 15px; }
  body:has(> #legal:not(.hidden)) #legal .legal-card p { font-size: 13px; line-height: 1.85; }
}

/* Backend visual system: use one fog-white / silver canvas for every
   authenticated and payment workflow view. Teal remains the semantic action
   color; the brand red is reserved for the quiet glow and active navigation. */
:root {
  --backend-brand: #c84b48;
  --backend-brand-soft: rgba(200, 75, 72, .09);
  --backend-canvas: #f6f8fa;
  --backend-canvas-deep: #edf1f4;
  --backend-surface: rgba(255, 255, 255, .86);
  --backend-surface-solid: #ffffff;
  --backend-surface-soft: #f2f5f7;
  --backend-ink: #102b35;
  --backend-muted: #718187;
  --backend-line: #dce5e9;
  --backend-shadow: 0 20px 56px rgba(16, 43, 53, .08);
  --backend-radius: 16px;
}

html[data-theme-effective="dark"] {
  --backend-brand: #ef8b83;
  --backend-brand-soft: rgba(239, 139, 131, .12);
  --backend-canvas: #0d1b20;
  --backend-canvas-deep: #10252a;
  --backend-surface: rgba(20, 39, 45, .9);
  --backend-surface-solid: #14272d;
  --backend-surface-soft: #1a3137;
  --backend-ink: #edf8f5;
  --backend-muted: #a4bbb9;
  --backend-line: #2c474d;
  --backend-shadow: 0 22px 64px rgba(0, 0, 0, .22);
}

body:has(> #dashboard:not(.hidden)),
body:has(> #ops:not(.hidden)),
body:has(> #checkout:not(.hidden)),
body:has(> #terminal:not(.hidden)) {
  background:
    radial-gradient(circle at 88% 4%, var(--backend-brand-soft), transparent 28rem),
    radial-gradient(circle at 4% 94%, rgba(148, 160, 169, .055), transparent 26rem),
    linear-gradient(135deg, var(--backend-canvas) 0%, var(--backend-canvas-deep) 56%, var(--backend-canvas) 100%);
  color: var(--backend-ink);
}

#dashboard,
#ops,
#checkout,
#terminal {
  position: relative;
  isolation: isolate;
  background-image:
    linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px);
  background-size: 44px 44px;
  background-blend-mode: soft-light;
}

#dashboard,
#ops,
#checkout,
#terminal,
#modal .modal-card {
  color: var(--backend-ink);
}

#modal .modal-card {
  border: 1px solid var(--backend-line);
  border-radius: var(--backend-radius);
  background: var(--backend-surface-solid);
  box-shadow: var(--backend-shadow);
}
#modal .modal-card :is(input, select, textarea) {
  border-color: var(--backend-line);
  background: var(--backend-surface-soft);
  color: var(--backend-ink);
}
#modal .modal-card :is(.table-scroll th, .table-scroll td) { border-color: var(--backend-line); }
#modal .modal-card .table-scroll th { background: var(--backend-surface-soft); color: var(--backend-muted); }
#modal .modal-card :is(.modal-close, .modal-tabs button, .account-tab) { color: var(--backend-muted); }
#modal .modal-card :is(.modal-close, .modal-tabs button, .account-tab):hover { color: var(--backend-ink); }

#dashboard .merchant-sidebar,
#ops .ops-sidebar {
  background: color-mix(in srgb, var(--backend-surface-solid) 82%, transparent);
  border-color: var(--backend-line);
  color: var(--backend-muted);
  box-shadow: 1px 0 0 color-mix(in srgb, var(--backend-brand) 8%, transparent);
  backdrop-filter: blur(18px);
}
#dashboard .merchant-brand,
#ops .ops-brand { color: var(--backend-ink); }
#dashboard .merchant-brand small,
#ops .ops-brand small { color: var(--backend-muted); }
#dashboard .merchant-workspace { background: var(--backend-surface-soft); border-color: var(--backend-line); box-shadow: none; }
#dashboard .merchant-workspace > b { background: var(--appearance-accent); color: #fff; }
#dashboard .merchant-navigation .merchant-nav-link,
#ops .ops-navigation .ops-nav-item { color: var(--backend-muted); }
#dashboard .merchant-navigation .merchant-nav-link:hover,
#ops .ops-navigation .ops-nav-item:hover { background: var(--backend-surface-soft); color: var(--backend-ink); }
#dashboard .merchant-navigation .merchant-nav-link.active,
#ops .ops-navigation .ops-nav-item.active {
  background: color-mix(in srgb, var(--backend-brand) 10%, var(--backend-surface));
  color: var(--backend-ink);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--backend-brand) 20%, transparent);
}
#dashboard .merchant-nav-link.active::before,
#ops .ops-navigation .ops-nav-item.active:before { background: var(--backend-brand); }
#dashboard .merchant-nav-link.active .merchant-icon,
#ops .ops-nav-item.active > .ops-icon { color: var(--backend-brand); }
#dashboard .merchant-sidebar-footer,
#ops .ops-sidebar-bottom { border-color: var(--backend-line); }

#dashboard .dash-header,
#ops .ops-topbar {
  background: color-mix(in srgb, var(--backend-canvas) 86%, transparent);
  border-color: var(--backend-line);
  backdrop-filter: blur(18px);
}
#dashboard .workbench-heading .eyebrow,
#ops .ops-header .eyebrow { color: var(--backend-brand); }
#dashboard .workbench-heading h1,
#dashboard .section-heading h2,
#ops .ops-header h1,
#ops .panel h2 { color: var(--backend-ink); }
#dashboard .section-heading p,
#ops .ops-header p,
#ops .ops-topbar-path > span,
#ops #ops-last-updated { color: var(--backend-muted); }

#dashboard :is(.panel, .overview-kpi, .overview-section .overview-main-grid > .panel, .overview-section .overview-lower-grid > .panel),
#dashboard :is(.account-card, .member-current, .member-plan, .member-balance-grid article, .member-rule-card, .member-invite, .member-legacy, .member-public-invite),
#dashboard :is(.docs-card, .docs-code, .docs-notice, .docs-endpoint, #docs-ai-integration),
#dashboard :is(.onboarding-channel-grid article, .onboarding-upload, .onboarding-sync-placeholder, .onboarding-gated-note, .onboarding-unified-flow, .onboarding-type-card, .onboarding-summary),
#ops :is(.panel, .ops-header, .ops-readiness-banner, .ops-stat-card),
#terminal .terminal-public-card,
#checkout .checkout-card {
  border-color: var(--backend-line);
  border-radius: var(--backend-radius);
  background: var(--backend-surface);
  box-shadow: var(--backend-shadow);
}

#dashboard :is(.secret-box, .app-row, .transaction-row, .ticket-row, .recon-card, .settings-grid),
#dashboard :is(.account-tabs, .account-tabpanel),
#dashboard .member-rate-details,
#dashboard .member-rate-item,
#dashboard .member-terms pre {
  border-color: var(--backend-line);
  background: var(--backend-surface-soft);
  color: var(--backend-ink);
}
#dashboard .member-plan.current { border-color: color-mix(in srgb, var(--backend-brand) 50%, var(--backend-line)); background: linear-gradient(145deg, color-mix(in srgb, var(--backend-brand) 8%, var(--backend-surface)), var(--backend-surface)); }
#dashboard :is(.member-invite input, [data-member-form] input:not([type=checkbox]), [data-member-form] select, [data-member-form] textarea),
#dashboard :is(input, select, textarea) {
  border-color: var(--backend-line);
  background: color-mix(in srgb, var(--backend-surface-solid) 88%, transparent);
  color: var(--backend-ink);
}
#dashboard :is(input, select, textarea)::placeholder { color: var(--backend-muted); }
#dashboard :is(.member-form-error, .member-load-error) { border-color: color-mix(in srgb, #c84b48 35%, var(--backend-line)); background: color-mix(in srgb, #c84b48 8%, var(--backend-surface)); color: var(--backend-brand); }
#dashboard .member-public-invite { background: color-mix(in srgb, var(--appearance-accent) 5%, var(--backend-surface)); }
#dashboard :is(.panel, .account-card, .member-plan, .docs-card, input, select, textarea, button, a):focus-visible,
#ops :is(.panel, input, select, textarea, button, a):focus-visible,
#checkout :is(button, a, input):focus-visible { outline-color: var(--appearance-accent); }

#dashboard-docs #docs-ai-integration {
  background: linear-gradient(145deg, color-mix(in srgb, var(--backend-brand) 4%, var(--backend-surface-solid)), var(--backend-surface-soft));
  border-color: color-mix(in srgb, var(--backend-brand) 20%, var(--backend-line));
}
#dashboard-docs #docs-ai-integration :is(.ai-integration-kicker, .ai-integration-links a:hover) { color: var(--backend-brand); }
#dashboard-docs #docs-ai-integration :is(.ai-integration-title, .ai-integration-description) { color: var(--backend-ink); }
#dashboard-docs #docs-ai-integration :is(.ai-integration-workflow li, .ai-integration-guard, .ai-integration-links a) { color: var(--backend-muted); }
#dashboard-docs #docs-ai-integration .ai-integration-symbol { background: color-mix(in srgb, var(--backend-brand) 12%, var(--backend-surface)); color: var(--backend-brand); }
#dashboard-docs #docs-ai-integration .ai-integration-footer { border-color: var(--backend-line); }

#ops .ops-menu-search { border-color: var(--backend-line); background: var(--backend-surface-soft); color: var(--backend-muted); }
#ops .ops-menu-search input { color: var(--backend-ink); }
#ops .ops-menu-search input::placeholder { color: var(--backend-muted); }
#ops .ops-topbar-path > b,
#ops .ops-stat-card strong,
#ops .ops-panel td b,
#ops .ops-panel h2 { color: var(--backend-ink); }
#ops .ops-stat-heading small,
#ops .ops-stat-caption,
#ops .ops-panel header p,
#ops .ops-muted { color: var(--backend-muted); }
#ops .ops-section-kicker { background: color-mix(in srgb, var(--appearance-accent) 8%, var(--backend-surface)); color: var(--appearance-accent-strong); }
#ops .ops-readiness-banner,
#ops .ops-readiness-banner.is-ready { background: linear-gradient(145deg, color-mix(in srgb, var(--backend-brand) 7%, var(--backend-surface-solid)), color-mix(in srgb, var(--appearance-accent) 7%, var(--backend-surface-solid))); border: 1px solid color-mix(in srgb, var(--backend-brand) 22%, var(--backend-line)); }
#ops .ops-readiness-heading h2 { color: var(--backend-ink); }
#ops .ops-readiness-heading p,
#ops .ops-readiness-heading .eyebrow,
#ops .ops-readiness-link { color: var(--backend-muted); }
#ops .ops-readiness-link:hover { background: var(--backend-surface-soft); color: var(--backend-ink); }
#ops .ops-todo,
#ops .ops-shortcut-grid button,
#ops .ops-page-size,
#ops .ops-page-button { border-color: var(--backend-line); background: var(--backend-surface-soft); color: var(--backend-ink); }
#ops .ops-todo:hover,
#ops .ops-shortcut-grid button:hover,
#ops .ops-page-button:hover:not(:disabled) { border-color: color-mix(in srgb, var(--appearance-accent) 45%, var(--backend-line)); background: color-mix(in srgb, var(--appearance-accent) 7%, var(--backend-surface)); }
#ops .ops-toolbar { border-color: var(--backend-line); }
#ops .ops-toolbar input,
#ops .ops-toolbar select,
#ops .ops-panel :is(input, select, textarea) { border-color: var(--backend-line); background: var(--backend-surface-solid); color: var(--backend-ink); }
#ops .ops-panel th { background: var(--backend-surface-soft); color: var(--backend-muted); border-color: var(--backend-line); }
#ops .ops-panel td { border-color: var(--backend-line); color: var(--backend-muted); }
#ops .ops-panel tbody tr:hover { background: color-mix(in srgb, var(--appearance-accent) 4%, var(--backend-surface)); }
#ops .ops-panel-error { border-color: color-mix(in srgb, #c84b48 30%, var(--backend-line)); background: color-mix(in srgb, #c84b48 7%, var(--backend-surface)); color: var(--backend-brand); }
#ops .account-list-summary > div,
#ops .ops-account-scope { border-color: var(--backend-line); background: var(--backend-surface-soft); color: var(--backend-ink); }

#checkout {
  --checkout-muted: var(--backend-muted);
  background:
    radial-gradient(circle at 88% 4%, var(--backend-brand-soft), transparent 28rem),
    linear-gradient(135deg, var(--backend-canvas) 0%, var(--backend-canvas-deep) 58%, var(--backend-canvas) 100%);
}
#checkout .checkout-top,
#checkout .checkout-footer { color: var(--backend-muted); }
#checkout .checkout-card { overflow: hidden; }
#checkout .checkout-summary { background: linear-gradient(160deg, color-mix(in srgb, var(--backend-brand) 6%, var(--backend-surface-solid)), var(--backend-surface-soft)); border-color: var(--backend-line); }
#checkout .checkout-payment { background: var(--backend-surface); }
#checkout .checkout-channels button,
#checkout .checkout-qr-frame { border-color: var(--backend-line); background: var(--backend-surface-solid); color: var(--backend-muted); }
#checkout .checkout-channels button.active { border-color: var(--appearance-accent); background: color-mix(in srgb, var(--appearance-accent) 9%, var(--backend-surface)); color: var(--appearance-accent-strong); }
#checkout .checkout-payment-status,
#checkout .checkout-order-summary,
#checkout .checkout-merchant { border-color: var(--backend-line); }
#checkout .checkout-result-symbol { background: color-mix(in srgb, var(--appearance-accent) 10%, var(--backend-surface)); color: var(--appearance-accent); }

html[data-theme-effective="dark"] #dashboard,
html[data-theme-effective="dark"] #ops,
html[data-theme-effective="dark"] #terminal {
  background:
    radial-gradient(circle at 88% 4%, var(--backend-brand-soft), transparent 28rem),
    radial-gradient(circle at 8% 94%, rgba(148, 160, 169, .08), transparent 26rem),
    linear-gradient(145deg, var(--backend-canvas-deep) 0%, var(--backend-canvas) 58%, #10252a 100%);
}
html[data-theme-effective="dark"] #dashboard .merchant-sidebar,
html[data-theme-effective="dark"] #ops .ops-sidebar { background: color-mix(in srgb, var(--backend-surface-solid) 90%, #091418); }
html[data-theme-effective="dark"] #dashboard .dash-header,
html[data-theme-effective="dark"] #ops .ops-topbar { background: color-mix(in srgb, var(--backend-canvas) 90%, transparent); }
html[data-theme-effective="dark"] #dashboard :is(.panel, .overview-kpi, .account-card, .member-current, .member-plan, .member-balance-grid article, .member-rule-card, .member-invite, .member-legacy, .member-public-invite, .docs-card, .docs-code, .docs-notice, .docs-endpoint, #docs-ai-integration, .onboarding-channel-grid article, .onboarding-upload, .onboarding-sync-placeholder, .onboarding-gated-note, .onboarding-unified-flow, .onboarding-type-card, .onboarding-summary),
html[data-theme-effective="dark"] #ops :is(.panel, .ops-header, .ops-readiness-banner, .ops-stat-card),
html[data-theme-effective="dark"] #terminal .terminal-public-card,
html[data-theme-effective="dark"] #checkout .checkout-card { background: var(--backend-surface-solid); border-color: var(--backend-line); box-shadow: var(--backend-shadow); }
html[data-theme-effective="dark"] #dashboard :is(.secret-box, .app-row, .transaction-row, .ticket-row, .recon-card, .settings-grid, .account-tabs, .account-tabpanel, .member-rate-details, .member-rate-item, .member-terms pre),
html[data-theme-effective="dark"] #ops :is(.ops-todo, .ops-shortcut-grid button, .ops-page-size, .ops-page-button, .account-list-summary > div, .ops-account-scope) { background: var(--backend-surface-soft); border-color: var(--backend-line); color: var(--backend-ink); }
html[data-theme-effective="dark"] #modal .modal-card { background: var(--backend-surface-solid); border-color: var(--backend-line); box-shadow: var(--backend-shadow); }
html[data-theme-effective="dark"] #modal .modal-card :is(input, select, textarea, .table-scroll th) { background: var(--backend-surface-soft); color: var(--backend-ink); border-color: var(--backend-line); }
html[data-theme-effective="dark"] #dashboard-docs #docs-ai-integration { background: linear-gradient(145deg, color-mix(in srgb, var(--backend-brand) 9%, var(--backend-surface-solid)), var(--backend-surface-soft)); }
html[data-theme-effective="dark"] #ops .ops-readiness-banner,
html[data-theme-effective="dark"] #ops .ops-readiness-banner.is-ready { background: linear-gradient(145deg, color-mix(in srgb, var(--backend-brand) 13%, var(--backend-surface-solid)), color-mix(in srgb, var(--appearance-accent) 10%, var(--backend-surface-solid))); }
html[data-theme-effective="dark"] #ops .ops-panel th,
html[data-theme-effective="dark"] #ops .ops-toolbar input,
html[data-theme-effective="dark"] #ops .ops-toolbar select,
html[data-theme-effective="dark"] #ops .ops-panel :is(input, select, textarea),
html[data-theme-effective="dark"] #dashboard :is(input, select, textarea),
html[data-theme-effective="dark"] #checkout .checkout-channels button,
html[data-theme-effective="dark"] #checkout .checkout-qr-frame { background: var(--backend-surface-soft); color: var(--backend-ink); border-color: var(--backend-line); }
html[data-theme-effective="dark"] #checkout .checkout-summary { background: linear-gradient(160deg, color-mix(in srgb, var(--backend-brand) 10%, var(--backend-surface-solid)), var(--backend-surface-soft)); }

@media (max-width: 800px) {
  #dashboard .merchant-sidebar,
  #ops .ops-sidebar { box-shadow: 12px 0 40px rgba(16, 43, 53, .12); }
  #dashboard .dash-header,
  #ops .ops-topbar { backdrop-filter: blur(14px); }
}

@media (prefers-reduced-motion: reduce) {
  #dashboard *, #ops *, #checkout *, #terminal * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* Dark backend controls: keep action hierarchy readable when legacy light
   component styles are still loaded before this theme layer. */
html[data-theme-effective="dark"] {
  --backend-action: #52d3b5;
  --backend-action-hover: #76e4c8;
  --backend-action-ink: #092322;
  --backend-control: #1a3137;
  --backend-control-hover: #203b40;
  --backend-control-ink: #edf8f5;
  --backend-control-muted: #a4bbb9;
  --backend-warning: #3b3420;
  --backend-warning-border: #66582b;
}

html[data-theme-effective="dark"] :is(#dashboard, #ops, #terminal, #checkout) .btn.primary {
  border-color: var(--backend-action) !important;
  background: var(--backend-action) !important;
  color: var(--backend-action-ink) !important;
  box-shadow: 0 8px 20px rgba(44, 215, 180, .14);
}
html[data-theme-effective="dark"] :is(#dashboard, #ops, #terminal, #checkout) .btn.primary:hover {
  border-color: var(--backend-action-hover) !important;
  background: var(--backend-action-hover) !important;
  color: var(--backend-action-ink) !important;
}
html[data-theme-effective="dark"] :is(#dashboard, #ops, #terminal, #checkout) .btn.outline,
html[data-theme-effective="dark"] :is(#dashboard, #ops, #terminal, #checkout) .btn.ghost {
  border-color: var(--backend-line) !important;
  background: var(--backend-control) !important;
  color: var(--backend-control-ink) !important;
}
html[data-theme-effective="dark"] :is(#dashboard, #ops, #terminal, #checkout) .btn.outline:hover,
html[data-theme-effective="dark"] :is(#dashboard, #ops, #terminal, #checkout) .btn.ghost:hover {
  border-color: var(--backend-action) !important;
  background: var(--backend-control-hover) !important;
  color: var(--backend-control-ink) !important;
}
html[data-theme-effective="dark"] :is(#dashboard, #ops, #terminal, #checkout) .btn.danger,
html[data-theme-effective="dark"] :is(#dashboard, #ops, #terminal, #checkout) .btn.error {
  border-color: #c84b48 !important;
  background: #4b2827 !important;
  color: #ffd9d4 !important;
}

/* Overview controls and recent-order table. */
html[data-theme-effective="dark"] #dashboard .overview-range-btn,
html[data-theme-effective="dark"] #dashboard .overview-metric-toggle button {
  border-color: transparent;
  color: var(--backend-control-muted);
}
html[data-theme-effective="dark"] #dashboard .overview-range-btn.active,
html[data-theme-effective="dark"] #dashboard .overview-metric-toggle button.active {
  background: var(--backend-control) !important;
  color: var(--backend-action-hover) !important;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .22);
}
html[data-theme-effective="dark"] #dashboard .overview-range-btn:hover,
html[data-theme-effective="dark"] #dashboard .overview-metric-toggle button:hover {
  background: var(--backend-control-hover);
  color: var(--backend-ink);
}
html[data-theme-effective="dark"] #dashboard .overview-donut::after {
  background: var(--backend-surface-solid);
}
html[data-theme-effective="dark"] #dashboard .overview-recent-panel :is(th, td) {
  border-bottom-color: var(--backend-line) !important;
}
html[data-theme-effective="dark"] #dashboard .overview-recent-panel th {
  background: var(--backend-control) !important;
  color: var(--backend-control-muted) !important;
}
html[data-theme-effective="dark"] #dashboard .overview-recent-panel td {
  color: var(--backend-ink);
}
html[data-theme-effective="dark"] #dashboard .overview-quick-grid button {
  background: var(--backend-control) !important;
  border-color: var(--backend-line) !important;
  color: var(--backend-ink) !important;
}
html[data-theme-effective="dark"] #dashboard .overview-quick-grid button:hover {
  background: var(--backend-control-hover) !important;
  border-color: var(--backend-action) !important;
}
html[data-theme-effective="dark"] #dashboard .overview-quick-icon {
  background: var(--backend-control-hover) !important;
  color: var(--backend-action-hover) !important;
}

/* Onboarding cards and notices contain legacy light fills with inherited
   light text, so give each surface an explicit dark foreground. */
html[data-theme-effective="dark"] #dashboard :is(.onboarding-notice, .onboarding-task, .onboarding-gated-note, .onboarding-sync-placeholder, .onboarding-unified-flow, .unified-flow-summary, .unified-flow-bound-note, .onboarding-type-card, .onboarding-upload, .onboarding-summary) {
  border-color: var(--backend-line) !important;
  background: var(--backend-surface-soft) !important;
  color: var(--backend-ink) !important;
}
html[data-theme-effective="dark"] #dashboard :is(.onboarding-notice, .onboarding-task, .onboarding-gated-note, .onboarding-sync-placeholder, .onboarding-unified-flow, .unified-flow-summary, .unified-flow-bound-note, .onboarding-type-card, .onboarding-upload, .onboarding-summary) :is(p, span, small, label) {
  color: var(--backend-control-muted) !important;
}
html[data-theme-effective="dark"] #dashboard :is(.onboarding-notice, .onboarding-task, .onboarding-gated-note, .onboarding-sync-placeholder, .onboarding-unified-flow, .unified-flow-summary, .unified-flow-bound-note, .onboarding-type-card, .onboarding-upload, .onboarding-summary) :is(h3, h4, b, strong) {
  color: var(--backend-ink) !important;
}
html[data-theme-effective="dark"] #dashboard .onboarding-type-card.active {
  border-color: var(--backend-action) !important;
  background: color-mix(in srgb, var(--backend-action) 12%, var(--backend-surface-soft)) !important;
}
html[data-theme-effective="dark"] #dashboard .onboarding-gated-note {
  background: var(--backend-warning) !important;
  border-color: var(--backend-warning-border) !important;
}

/* Docs assistant card: the footer, symbol and outline action should use the
   same dark control surface as the rest of the workbench. */
html[data-theme-effective="dark"] #dashboard-docs #docs-ai-integration .ai-integration-symbol {
  border-color: var(--backend-line) !important;
  background: var(--backend-control-hover) !important;
  color: var(--backend-action-hover) !important;
}
html[data-theme-effective="dark"] #dashboard-docs #docs-ai-integration .ai-integration-actions .btn.outline {
  background: var(--backend-control) !important;
  color: var(--backend-control-ink) !important;
  border-color: var(--backend-line) !important;
}
html[data-theme-effective="dark"] #dashboard-docs #docs-ai-integration .ai-integration-actions .btn.outline:hover {
  background: var(--backend-control-hover) !important;
  border-color: var(--backend-action) !important;
}
html[data-theme-effective="dark"] #dashboard-docs #docs-ai-integration .ai-integration-workflow {
  border-left-color: var(--backend-line) !important;
}
html[data-theme-effective="dark"] #dashboard-docs #docs-ai-integration .ai-integration-workflow li span {
  border-color: var(--backend-line) !important;
  background: var(--backend-control) !important;
  color: var(--backend-control-muted) !important;
}
html[data-theme-effective="dark"] #dashboard-docs #docs-ai-integration .ai-integration-footer {
  border-top-color: var(--backend-line) !important;
  background: var(--backend-control) !important;
}
html[data-theme-effective="dark"] #dashboard-docs #docs-ai-integration .ai-integration-guard,
html[data-theme-effective="dark"] #dashboard-docs #docs-ai-integration .ai-integration-links a {
  color: var(--backend-control-muted) !important;
}
html[data-theme-effective="dark"] #dashboard-docs .docs-env {
  border-color: var(--backend-line) !important;
  background: var(--backend-control) !important;
  color: var(--backend-action-hover) !important;
}

/* Ops toolbar and status surfaces use the same action/control pairing. */
html[data-theme-effective="dark"] #ops .ops-toolbar .btn.outline,
html[data-theme-effective="dark"] #ops .ops-header-return {
  background: var(--backend-control) !important;
  color: var(--backend-control-ink) !important;
  border-color: var(--backend-line) !important;
}
html[data-theme-effective="dark"] #ops .ops-panel-error {
  background: var(--backend-warning) !important;
  border-color: var(--backend-warning-border) !important;
  color: #f1d989 !important;
}
html[data-theme-effective="dark"] #ops .ops-panel-error button {
  background: var(--backend-control) !important;
  border-color: var(--backend-line) !important;
  color: var(--backend-control-ink) !important;
}

/* Account and nested form surfaces are reachable from the same dark shell. */
html[data-theme-effective="dark"] #modal .account-management {
  --account-border: var(--backend-line);
  color: var(--backend-ink);
  background: var(--backend-surface-solid);
}
html[data-theme-effective="dark"] #modal .account-management .account-shell-header {
  background: linear-gradient(115deg, #193b38 0%, var(--backend-surface-solid) 80%) !important;
}
html[data-theme-effective="dark"] #modal .account-management .account-tabs {
  background: var(--backend-control) !important;
  border-color: var(--backend-line) !important;
}
html[data-theme-effective="dark"] #modal .account-management .account-tabpanel {
  background: var(--backend-canvas) !important;
}
html[data-theme-effective="dark"] #modal .account-management :is(.account-card, .account-stat) {
  background: var(--backend-surface-solid) !important;
  border-color: var(--backend-line) !important;
}
html[data-theme-effective="dark"] #modal .account-management :is(th, td) {
  border-color: var(--backend-line) !important;
}
html[data-theme-effective="dark"] #modal .account-management th { background: var(--backend-control) !important; color: var(--backend-control-muted) !important; }
html[data-theme-effective="dark"] #modal .account-management td { color: var(--backend-ink) !important; }
html[data-theme-effective="dark"] #modal .account-management :is(input, select, textarea) {
  background: #102329 !important;
  border-color: var(--backend-line) !important;
  color: var(--backend-ink) !important;
}
html[data-theme-effective="dark"] #dashboard .merchant-legal-record[open],
html[data-theme-effective="dark"] #dashboard .onboarding-task,
html[data-theme-effective="dark"] #dashboard .unified-flow-summary {
  background: var(--backend-control) !important;
  border-color: var(--backend-line) !important;
}

/* The light sidebar keeps the same pale canvas as the rest of the workbench;
   explicitly reset the old dark-sidebar brand and workspace text tokens so
   they remain readable on that lighter surface. */
#dashboard .merchant-brand .brand-copy [data-brand-zh],
#dashboard .merchant-workspace small {
  color: var(--backend-muted) !important;
}
#dashboard .merchant-brand .brand-copy [data-brand-en],
#dashboard .merchant-workspace > span {
  color: var(--backend-ink) !important;
}
#dashboard .merchant-navigation .merchant-nav-link {
  color: var(--backend-muted);
}
#dashboard .merchant-sidebar-footer {
  color: var(--backend-muted);
}
#dashboard .merchant-sidebar-footer a {
  color: color-mix(in srgb, var(--backend-ink) 70%, var(--backend-muted));
}
html[data-theme-effective="light"] #dashboard .merchant-navigation .merchant-nav-count {
  background: var(--backend-surface-soft);
  border: 1px solid var(--backend-line);
  color: var(--backend-ink);
}

/* Scenario-led public homepage surfaces stay legible in the dark theme while
   preserving the same geometry and motion language as light mode. */
html[data-theme-effective="dark"] body.public-home #home {
  --scene-ink: var(--appearance-ink);
  --scene-muted: var(--appearance-muted);
  --scene-surface: var(--appearance-surface);
  --scene-soft: var(--appearance-surface-soft);
  --scene-line: var(--appearance-line);
  --scene-accent: var(--appearance-accent);
  --scene-accent-soft: color-mix(in srgb, var(--appearance-accent) 15%, var(--appearance-surface));
  --scene-shadow: 0 24px 58px -38px rgba(0, 0, 0, .72);
}
html[data-theme-effective="dark"] body.public-home #home .scenario-section {
  background: linear-gradient(180deg, #102126 0%, #0f2025 100%);
  border-color: var(--line);
}
html[data-theme-effective="dark"] body.public-home #home .scenario-section::before,
html[data-theme-effective="dark"] body.public-home #home .funds-section::before { border-color: rgba(82, 211, 181, .12); box-shadow: 0 0 0 72px rgba(82, 211, 181, .035), 0 0 0 144px rgba(82, 211, 181, .018); }
html[data-theme-effective="dark"] body.public-home #home .scenario-card,
html[data-theme-effective="dark"] body.public-home #home .method-card,
html[data-theme-effective="dark"] body.public-home #home .funds-visual { background: var(--scene-surface); border-color: var(--scene-line); }
html[data-theme-effective="dark"] body.public-home #home .scenario-card:hover,
html[data-theme-effective="dark"] body.public-home #home .scenario-card:focus-visible,
html[data-theme-effective="dark"] body.public-home #home .method-card:hover,
html[data-theme-effective="dark"] body.public-home #home .method-card:focus-within { border-color: color-mix(in srgb, var(--scene-accent) 52%, var(--scene-line)); }
html[data-theme-effective="dark"] body.public-home #home .scenario-tags span { background: var(--scene-soft); color: var(--scene-muted); }
html[data-theme-effective="dark"] body.public-home #home .scenario-footnote,
html[data-theme-effective="dark"] body.public-home #home .method-card > p,
html[data-theme-effective="dark"] body.public-home #home .method-card dt,
html[data-theme-effective="dark"] body.public-home #home .funds-copy > p:not(.eyebrow),
html[data-theme-effective="dark"] body.public-home #home .funds-points small { color: var(--scene-muted); }
html[data-theme-effective="dark"] body.public-home #home .method-card { background: linear-gradient(150deg, var(--appearance-surface), var(--appearance-surface-soft)); }
html[data-theme-effective="dark"] body.public-home #home .method-card dd,
html[data-theme-effective="dark"] body.public-home #home .funds-points strong { color: var(--scene-ink); }
html[data-theme-effective="dark"] body.public-home #home .funds-section { background: linear-gradient(180deg, #102126 0%, #0e1a1e 100%); border-color: var(--line); }
html[data-theme-effective="dark"] body.public-home #home .funds-visual { background: transparent; border: 0; box-shadow: none; }
html[data-theme-effective="dark"] body.public-home #home .funds-visual img { filter: drop-shadow(0 22px 34px rgba(0, 0, 0, .38)); }
html[data-theme-effective="dark"] body.public-home #home .steps li:not(:last-child)::after { background: var(--line); }
html[data-theme-effective="dark"] body.public-home #home .steps li .step-number { background: var(--scene-soft); }
html[data-theme-effective="dark"] body.public-home #home .footer-wechat { color: var(--appearance-muted); }
html[data-theme-effective="dark"] body.public-home #home .footer-wechat-popover { background: var(--appearance-surface); border-color: var(--appearance-line); box-shadow: 0 18px 45px rgba(0, 0, 0, .32); }
