/* TradersMill dark mode: semantic overrides only. Light mode remains component-owned. */
:root {
  --tm-theme-page: #f7f9fc;
  --tm-theme-elevated: #ffffff;
  --tm-theme-muted-surface: #f0f4f8;
  --tm-theme-text: #102a43;
  --tm-theme-text-secondary: #52677a;
  --tm-theme-text-faint: #718397;
  --tm-theme-border: #d9e2ec;
  --tm-theme-soft-border: rgba(51, 78, 104, 0.08);
  --tm-theme-input: #ffffff;
  --tm-theme-table-heading: #f0f4f8;
  --tm-theme-table-row: #ffffff;
  --tm-theme-sidebar: #061326;
  --tm-theme-header: rgba(248, 250, 252, 0.94);
  --tm-theme-cyan: #2176b8;
  --tm-theme-violet: #6f5bd3;
  --tm-theme-positive: #146c4a;
  --tm-theme-danger: #c23b47;
  --tm-theme-premium: #b38a32;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --tm-theme-page: #05070d;
  --tm-theme-elevated: #0a0f1c;
  --tm-theme-muted-surface: #0d1424;
  --tm-theme-text: #e7ecf6;
  --tm-theme-text-secondary: #8b95af;
  --tm-theme-text-faint: #66708b;
  --tm-theme-border: rgba(140, 170, 255, 0.14);
  --tm-theme-soft-border: rgba(140, 170, 255, 0.08);
  --tm-theme-input: #0c1322;
  --tm-theme-table-heading: #0c1320;
  --tm-theme-table-row: rgba(255, 255, 255, 0.018);
  --tm-theme-sidebar: #070b14;
  --tm-theme-header: rgba(10, 15, 28, 0.94);
  --tm-theme-cyan: #4cf3ff;
  --tm-theme-violet: #8b6bff;
  --tm-theme-positive: #3effc3;
  --tm-theme-danger: #ff5d7a;
  --tm-theme-premium: #e8c267;
}

:root[data-theme="dark"] body {
  background: var(--tm-theme-page);
}

:root[data-theme="dark"] .tm-aurora-shell {
  --tm-color-canvas: var(--tm-theme-page);
  --tm-color-surface: var(--tm-theme-elevated);
  --tm-color-surface-raised: #0e1627;
  --tm-color-surface-subtle: var(--tm-theme-muted-surface);
  --tm-color-surface-strong: #121b2e;
  --tm-color-text: var(--tm-theme-text);
  --tm-color-text-muted: var(--tm-theme-text-secondary);
  --tm-color-text-subtle: var(--tm-theme-text-faint);
  --tm-color-text-inverse: #05070d;
  --tm-color-link: var(--tm-theme-cyan);
  --tm-color-link-hover: #a89bff;
  --tm-color-border: var(--tm-theme-border);
  --tm-color-border-strong: rgba(140, 170, 255, 0.24);
  --tm-color-border-focus: var(--tm-theme-cyan);
  --tm-color-focus-ring: rgba(76, 243, 255, 0.28);
  --tm-color-selection: rgba(76, 243, 255, 0.14);
  --tm-color-positive: var(--tm-theme-positive);
  --tm-color-negative: var(--tm-theme-danger);
  --tm-color-neutral-data: #aab4ca;
  --tm-color-chart-grid: rgba(140, 170, 255, 0.12);
  --tm-color-chart-primary: var(--tm-theme-cyan);
  --tm-color-chart-secondary: var(--tm-theme-violet);
  --tm-success-700: var(--tm-theme-positive);
  --tm-success-600: #29dca8;
  --tm-success-100: rgba(62, 255, 195, 0.1);
  --tm-warning-800: var(--tm-theme-premium);
  --tm-warning-600: #d7aa49;
  --tm-warning-100: rgba(232, 194, 103, 0.1);
  --tm-danger-700: var(--tm-theme-danger);
  --tm-danger-600: #e84d6b;
  --tm-danger-100: rgba(255, 93, 122, 0.1);
  --tm-info-700: var(--tm-theme-cyan);
  --tm-info-600: #38cbd6;
  --tm-info-100: rgba(76, 243, 255, 0.09);
  --ws-bg: var(--tm-theme-page);
  --ws-panel: var(--tm-glass-surface);
  --ws-panel-solid: var(--tm-theme-elevated);
  --ws-border: var(--tm-theme-border);
  --ws-text: var(--tm-theme-text);
  --ws-muted: var(--tm-theme-text-secondary);
  --ws-blue: var(--tm-theme-cyan);
  --ws-green: var(--tm-theme-positive);
  --ws-red: var(--tm-theme-danger);
  --ws-cyan: var(--tm-theme-cyan);
  --ws-slate: #aab4ca;
  background: var(--tm-theme-page);
  color: var(--tm-theme-text);
}

:root[data-theme="dark"] .tm-aurora-shell .workspace-content {
  background:
    radial-gradient(circle at 12% 8%, rgba(76, 243, 255, 0.055), transparent 30rem),
    radial-gradient(circle at 88% 18%, rgba(139, 107, 255, 0.065), transparent 34rem),
    linear-gradient(rgba(140, 170, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(140, 170, 255, 0.018) 1px, transparent 1px),
    var(--tm-theme-page);
  background-size: auto, auto, 52px 52px, 52px 52px, auto;
}

:root[data-theme="dark"] .tm-aurora-shell .workspace-sidebar {
  border-right-color: var(--tm-theme-border);
  background:
    radial-gradient(ellipse 18rem 28rem at 8% 2%, rgba(76, 243, 255, 0.075), transparent 70%),
    radial-gradient(ellipse 20rem 24rem at 100% 54%, rgba(139, 107, 255, 0.065), transparent 72%),
    linear-gradient(180deg, #080d18, var(--tm-theme-sidebar) 66%, #050810);
  box-shadow: 0.8rem 0 2.8rem rgba(0, 0, 0, 0.28);
}

:root[data-theme="dark"] .tm-aurora-shell .workspace-topbar {
  border-bottom-color: var(--tm-theme-border);
  background: var(--tm-theme-header);
  box-shadow: inset 0 -1px 0 rgba(140, 170, 255, 0.04), 0 0.35rem 1.4rem rgba(0, 0, 0, 0.2);
  -webkit-backdrop-filter: blur(18px) saturate(120%);
  backdrop-filter: blur(18px) saturate(120%);
}

:root[data-theme="dark"] .tm-aurora-shell .workspace-nav-link.active,
:root[data-theme="dark"] .tm-aurora-shell .workspace-nav-link[aria-current="page"] {
  border-color: rgba(76, 243, 255, 0.24);
  background:
    linear-gradient(90deg, rgba(76, 243, 255, 0.14), rgba(139, 107, 255, 0.16)),
    rgba(255, 255, 255, 0.035);
  color: #f1f5ff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 2px 0 0 var(--tm-theme-cyan),
    var(--tm-glass-selected-glow);
}

:root[data-theme="dark"] .tm-aurora-shell .workspace-nav-link.active::before,
:root[data-theme="dark"] .tm-aurora-shell .workspace-nav-link[aria-current="page"]::before {
  background: linear-gradient(var(--tm-theme-cyan), var(--tm-theme-violet));
  box-shadow: 0 0 0.8rem rgba(76, 243, 255, 0.38);
}

:root[data-theme="dark"] .tm-aurora-shell :is(
  .workspace-card,
  .metric-card,
  .dashboard-executive-overview,
  .settings-panel,
  .commerce-hero,
  .trade-entry-panel,
  .import-form,
  .import-file-state,
  .broker-card,
  .account-mode-card,
  .entry-method-options label,
  .provider-choice
) {
  border-color: var(--tm-theme-border) !important;
  background: var(--tm-theme-elevated) !important;
  background: var(--tm-glass-surface) !important;
  color: var(--tm-theme-text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035), 0 0.75rem 2rem rgba(0, 0, 0, 0.2);
  -webkit-backdrop-filter: var(--tm-glass-backdrop);
  backdrop-filter: var(--tm-glass-backdrop);
}

:root[data-theme="dark"] .tm-aurora-shell :is(
  [role="tab"][aria-selected="true"],
  .settings-subnav-link.active,
  .import-progress li.is-active,
  .account-mode-card:has(input:checked),
  .entry-method-options label:has(input:checked),
  .broker-card:has(input:checked),
  .provider-choice.is-selected
) {
  border-color: rgba(76, 243, 255, 0.28) !important;
  background: var(--tm-theme-elevated) !important;
  background: linear-gradient(135deg, rgba(76, 243, 255, 0.075), rgba(139, 107, 255, 0.09)) !important;
  color: var(--tm-theme-text);
  box-shadow: var(--tm-glass-inner-shadow), var(--tm-glass-selected-glow);
}

:root[data-theme="dark"] .tm-aurora-shell .provider-choice {
  box-shadow: inset 3px 0 0 var(--provider-accent-edge), 0 0.45rem 1.2rem rgba(0, 0, 0, 0.16);
}

:root[data-theme="dark"] .tm-aurora-shell .provider-choice.is-selected {
  box-shadow: inset 4px 0 0 var(--provider-accent-edge), var(--tm-glass-inner-shadow), var(--tm-glass-selected-glow);
}

:root[data-theme="dark"] .tm-aurora-shell .provider-choice-check {
  border-color: var(--tm-theme-border);
  background: var(--tm-theme-input);
}

:root[data-theme="dark"] .tm-aurora-shell .provider-choice.is-selected .provider-choice-check {
  border-color: var(--provider-accent);
  background: var(--provider-accent);
  color: #fff;
}

:root[data-theme="dark"] .tm-aurora-shell .provider-choice :is(strong, small),
:root[data-theme="dark"] .tm-aurora-shell .account-mode-card :is(strong, small),
:root[data-theme="dark"] .tm-aurora-shell .entry-method-options label :is(strong, small) {
  color: inherit;
}

:root[data-theme="dark"] .tm-aurora-shell .trade-entry-progress__step.is-active span {
  border-color: rgba(76, 243, 255, 0.32);
  background: linear-gradient(145deg, rgba(76, 243, 255, 0.1), rgba(139, 107, 255, 0.12));
  color: var(--tm-theme-cyan);
}

:root[data-theme="dark"] .tm-aurora-shell :is(
  .workspace-main input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="submit"]):not([type="button"]):not([type="reset"]),
  .workspace-main select,
  .workspace-main textarea,
  .topbar-select select
) {
  border-color: var(--tm-theme-border) !important;
  background: var(--tm-theme-input) !important;
  color: var(--tm-theme-text) !important;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.22);
}

:root[data-theme="dark"] .tm-aurora-shell :is(input, textarea)::placeholder {
  color: var(--tm-theme-text-faint) !important;
  opacity: 1;
}

:root[data-theme="dark"] .tm-aurora-shell :is(input, select, textarea):disabled {
  border-color: var(--tm-theme-soft-border) !important;
  background: #090e19 !important;
  color: var(--tm-theme-text-faint) !important;
  opacity: 0.78;
}

:root[data-theme="dark"] .tm-aurora-shell .workspace-main table {
  border-color: var(--tm-theme-border);
  background: transparent;
  color: var(--tm-theme-text);
}

:root[data-theme="dark"] .tm-aurora-shell .workspace-main table thead th {
  border-color: var(--tm-theme-border) !important;
  background: var(--tm-theme-table-heading) !important;
  color: #b9c3d8 !important;
}

:root[data-theme="dark"] .tm-aurora-shell .workspace-main table tbody :is(th, td) {
  border-color: var(--tm-theme-soft-border) !important;
  background: var(--tm-theme-table-row);
  color: var(--tm-theme-text);
}

:root[data-theme="dark"] .tm-aurora-shell .workspace-main table tbody tr:hover :is(th, td) {
  background: rgba(76, 243, 255, 0.035);
}

:root[data-theme="dark"] .tm-aurora-shell :is(.workspace-dropdown, .dropdown-menu, .account-actions-menu) {
  border-color: var(--tm-theme-border) !important;
  background: var(--tm-glass-menu-solid) !important;
  background: linear-gradient(145deg, rgba(16, 23, 40, 0.96), rgba(8, 12, 22, 0.94)) !important;
  color: var(--tm-theme-text);
}

:root[data-theme="dark"] .tm-aurora-shell .account-actions-trigger {
  border-color: var(--tm-theme-border);
  background: var(--tm-theme-input);
  color: var(--tm-theme-text-secondary);
}

:root[data-theme="dark"] .tm-aurora-shell .account-actions-trigger:is(:hover, :focus-visible, [aria-expanded="true"]) {
  border-color: rgba(76, 243, 255, 0.3);
  background: rgba(76, 243, 255, 0.055);
  color: var(--tm-theme-cyan);
}

:root[data-theme="dark"] .tm-aurora-shell :is(.dropdown-item, .account-actions-menu a, .account-actions-menu button) {
  color: var(--tm-theme-text-secondary) !important;
}

:root[data-theme="dark"] .tm-aurora-shell :is(.dropdown-item, .account-actions-menu a, .account-actions-menu button):is(:hover, :focus, .active) {
  background: linear-gradient(90deg, rgba(76, 243, 255, 0.07), rgba(139, 107, 255, 0.08)) !important;
  color: var(--tm-theme-text) !important;
}

:root[data-theme="dark"] .tm-aurora-shell :is(.danger-link, .btn-danger, .danger-button, .account-actions-destructive, .text-danger) {
  color: var(--tm-theme-danger) !important;
}

:root[data-theme="dark"] .tm-aurora-shell .account-actions-menu .account-actions-destructive:hover {
  background: rgba(255, 93, 122, 0.09) !important;
  color: #ff8ba1 !important;
}

:root[data-theme="dark"] .tm-aurora-shell :is(.btn-danger, .danger-button) {
  border-color: rgba(255, 93, 122, 0.58) !important;
  background: #a82f4b !important;
  color: #fff !important;
}

:root[data-theme="dark"] .tm-aurora-shell :is(.nav-plan-badge--premium, .commerce-plan-badge, .pricing-card.current .section-kicker) {
  border-color: rgba(232, 194, 103, 0.3) !important;
  background: rgba(232, 194, 103, 0.09) !important;
  color: var(--tm-theme-premium) !important;
}

:root[data-theme="dark"] .tm-aurora-shell :is(.positive-text, .is-positive, .account-status.is-active) {
  color: var(--tm-theme-positive) !important;
}

:root[data-theme="dark"] .tm-aurora-shell :is(.chart-shell, .chart-frame, .analytics-chart, canvas) {
  background-color: transparent !important;
}

:root[data-theme="dark"] .tm-aurora-shell svg :is(text, .chart-label) {
  fill: var(--tm-theme-text-secondary);
}

/* Authentication surfaces share the same preference without adding a second control. */
:root[data-theme="dark"] .auth-experience-shell {
  --auth-ink: var(--tm-theme-text);
  --auth-copy: var(--tm-theme-text-secondary);
  --auth-blue: var(--tm-theme-cyan);
  --auth-blue-hover: #82f7ff;
  color: var(--tm-theme-text);
  background:
    radial-gradient(circle at 18% 12%, rgba(76, 243, 255, 0.07), transparent 30rem),
    radial-gradient(circle at 82% 22%, rgba(139, 107, 255, 0.09), transparent 34rem),
    var(--tm-theme-page);
}

:root[data-theme="dark"] .auth-experience-shell::before {
  background-image:
    linear-gradient(rgba(140, 170, 255, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(140, 170, 255, 0.022) 1px, transparent 1px);
}

:root[data-theme="dark"] .auth-card--premium {
  border-color: var(--tm-theme-border);
  background: var(--tm-theme-elevated);
  background: rgba(255, 255, 255, 0.035);
  color: var(--tm-theme-text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 1.75rem 4.5rem rgba(0, 0, 0, 0.34);
}

:root[data-theme="dark"] .auth-card--premium :is(h1, .login-welcome-back, .form-label, .form-check-label) {
  color: var(--tm-theme-text);
}

:root[data-theme="dark"] .auth-card--premium :is(.auth-muted, .auth-reassurance, .auth-switch, .password-hint, .auth-consent) {
  color: var(--tm-theme-text-secondary);
}

:root[data-theme="dark"] .morning-focus-card {
  border-color: var(--tm-theme-border);
  border-left-color: var(--tm-theme-cyan);
  background: linear-gradient(135deg, rgba(76, 243, 255, 0.045), rgba(139, 107, 255, 0.055));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.035);
}

:root[data-theme="dark"] .morning-focus-card :is(span, p) {
  color: var(--tm-theme-text-secondary);
}

:root[data-theme="dark"] .auth-experience .form-control {
  border-color: var(--tm-theme-border);
  background: var(--tm-theme-input);
  color: var(--tm-theme-text);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
}

:root[data-theme="dark"] .auth-experience .form-control::placeholder {
  color: var(--tm-theme-text-faint);
}

:root[data-theme="dark"] .auth-experience .form-control:is(:hover, :focus) {
  border-color: rgba(76, 243, 255, 0.38);
  background: #0e1728;
  color: var(--tm-theme-text);
}

:root[data-theme="dark"] .auth-experience .password-toggle {
  border-color: var(--tm-theme-border);
  background: #0e1626;
  color: var(--tm-theme-text-secondary);
}

:root[data-theme="dark"] .auth-experience .password-toggle:is(:hover, :focus-visible),
:root[data-theme="dark"] .auth-experience .form-link,
:root[data-theme="dark"] .auth-kicker {
  color: var(--tm-theme-cyan);
}

:root[data-theme="dark"] .auth-experience .form-check-input {
  border-color: rgba(140, 170, 255, 0.28);
  background-color: var(--tm-theme-input);
}

:root[data-theme="dark"] .auth-experience .form-check-input:checked {
  border-color: #5260cf;
  background-color: #5260cf;
}

:root[data-theme="dark"] .auth-status,
:root[data-theme="dark"] .auth-experience .invalid-feedback {
  border-color: rgba(255, 93, 122, 0.3);
  background: rgba(255, 93, 122, 0.08);
  color: #ff8ba1;
}

:root[data-theme="dark"] .auth-benefit-panel {
  border-color: rgba(140, 170, 255, 0.18);
  background:
    radial-gradient(circle at 14% 4%, rgba(76, 243, 255, 0.1), transparent 38%),
    radial-gradient(circle at 90% 82%, rgba(139, 107, 255, 0.13), transparent 36%),
    linear-gradient(145deg, rgba(16, 24, 44, 0.96), rgba(7, 11, 22, 0.98));
}

:root[data-theme="dark"] :is(.tm-aurora-shell, .auth-experience-shell, .auth-card--premium) {
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  :root[data-theme="dark"] .tm-aurora-shell :is(
    .workspace-card,
    .metric-card,
    .dashboard-executive-overview,
    .settings-panel,
    .commerce-hero,
    .trade-entry-panel,
    .import-form,
    .import-file-state,
    .broker-card,
    .account-mode-card,
    .entry-method-options label,
    .provider-choice
  ),
  :root[data-theme="dark"] .auth-card--premium {
    background: var(--tm-theme-elevated) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root[data-theme="dark"] :is(.tm-aurora-shell, .auth-experience-shell, .auth-card--premium) {
    transition: none !important;
  }
}
