/* Executive Slate + Cobalt
 * Approved application palette. Loaded last to keep legacy workspace colors
 * from overriding the shared light/dark design system.
 */

:root,
html[data-theme="light"],
html[data-theme-resolved="light"] {
  color-scheme: light;
  --primary-50: #eef4ff;
  --primary-100: #dce9ff;
  --primary-200: #bfd5ff;
  --primary-300: #94b9ff;
  --primary-400: #6698f2;
  --primary-500: #3978df;
  --primary-600: #245fc7;
  --primary-700: #1e4da5;
  --primary-800: #1d4285;
  --primary-900: #1c386b;
  --bg-app: #f4f7fb;
  --bg-subtle: #edf2f7;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #e9eff6;
  --text-primary: #172033;
  --text-secondary: #44546a;
  --text-muted: #627188;
  --text-disabled: #8997a9;
  --text-onbrand: #ffffff;
  --border-default: #d7e0ea;
  --border-soft: #e7edf3;
  --border-strong: #bac7d5;
  --topbar-bg: #ffffff;
  --topbar-text: #172033;
  --topbar-border: #d7e0ea;
  --input-bg: #ffffff;
  --input-border: #bac7d5;
  --input-border-hover: #899aaf;
  --input-border-focus: #3978df;
  --input-placeholder: #8997a9;
  --input-text: #172033;
  --input-ring: rgba(57, 120, 223, .2);
  --btn-primary-bg: #245fc7;
  --btn-primary-hover: #1e4da5;
  --btn-primary-text: #ffffff;
  --btn-secondary-bg: #ffffff;
  --btn-secondary-hover: #f2f6fa;
  --btn-secondary-text: #26354a;
  --btn-secondary-border: #bac7d5;
  --btn-ghost-hover: #eaf1fb;
  --link-default: #245fc7;
  --link-hover: #1e4da5;
  --table-header-bg: #f1f5f9;
  --table-header-text: #3c4d63;
  --table-row-bg: #ffffff;
  --table-row-alt: #fafbfd;
  --table-row-hover: #edf3fa;
  --table-border: #dce4ed;
  --table-text: #172033;
  --table-text-muted: #627188;
  --card-bg: #ffffff;
  --card-border: #d7e0ea;
  --card-shadow: 0 1px 2px rgba(23, 32, 51, .04), 0 8px 22px rgba(23, 32, 51, .055);
  --popover-bg: #ffffff;
  --popover-border: #d7e0ea;
  --modal-bg: #ffffff;
  --modal-border: #d7e0ea;
  --focus-ring: #7ba7f3;
  --selection-bg: #dce9ff;
  --selection-text: #1c386b;
  --sidebar-bg-top: #132b46;
  --sidebar-bg-mid: #10243b;
  --sidebar-bg-bottom: #0c1c2f;
  --sidebar-text: #d4dfed;
  --sidebar-text-muted: #96a9bf;
  --sidebar-icon: #a4b7cc;
  --sidebar-accent: #d9e8ff;
  --sidebar-active-accent: #6fa3ef;
  --sidebar-hover-border: #2c4965;
  --sidebar-active-border: rgba(117, 166, 239, .5);
}

html[data-theme="dark"],
html[data-theme-resolved="dark"] {
  color-scheme: dark;
  --primary-50: #121c2a;
  --primary-100: #17253a;
  --primary-200: #1d3150;
  --primary-300: #294a78;
  --primary-400: #4272b8;
  --primary-500: #5f91df;
  --primary-600: #78a7ed;
  --primary-700: #9abfff;
  --primary-800: #bfd6ff;
  --primary-900: #dbe8ff;
  --bg-app: #0e1521;
  --bg-subtle: #111b29;
  --surface: #162131;
  --surface-2: #111b29;
  --surface-3: #1d2a3c;
  --text-primary: #edf2f8;
  --text-secondary: #c3cfdd;
  --text-muted: #9aaac0;
  --text-disabled: #6f7f93;
  --text-onbrand: #0e1521;
  --border-default: #2a394d;
  --border-soft: #223044;
  --border-strong: #3b4d63;
  --topbar-bg: #162131;
  --topbar-text: #edf2f8;
  --topbar-border: #2a394d;
  --input-bg: #111b29;
  --input-border: #3b4d63;
  --input-border-hover: #52657d;
  --input-border-focus: #78a7ed;
  --input-placeholder: #78889c;
  --input-text: #edf2f8;
  --input-ring: rgba(120, 167, 237, .26);
  --btn-primary-bg: #3b70bd;
  --btn-primary-hover: #3466ad;
  --btn-primary-text: #ffffff;
  --btn-secondary-bg: #182435;
  --btn-secondary-hover: #213044;
  --btn-secondary-text: #e4ebf4;
  --btn-secondary-border: #3b4d63;
  --btn-ghost-hover: rgba(120, 167, 237, .13);
  --link-default: #78a7ed;
  --link-hover: #9abfff;
  --table-header-bg: #131e2d;
  --table-header-text: #c3cfdd;
  --table-row-bg: #162131;
  --table-row-alt: #141f2e;
  --table-row-hover: #1e2d40;
  --table-border: #2a394d;
  --table-text: #e7edf5;
  --table-text-muted: #9aaac0;
  --card-bg: #162131;
  --card-border: #2a394d;
  --card-shadow: 0 1px 2px rgba(0, 0, 0, .24), 0 12px 28px rgba(0, 0, 0, .22);
  --popover-bg: #182435;
  --popover-border: #35475d;
  --modal-bg: #182435;
  --modal-border: #35475d;
  --focus-ring: #78a7ed;
  --selection-bg: rgba(95, 145, 223, .32);
  --selection-text: #e3edff;
  --sidebar-bg-top: #10243a;
  --sidebar-bg-mid: #0c1929;
  --sidebar-bg-bottom: #09131f;
  --sidebar-text: #d6e1ef;
  --sidebar-text-muted: #91a4ba;
  --sidebar-icon: #9db0c6;
  --sidebar-accent: #dbe8ff;
  --sidebar-active-accent: #78a7ed;
  --sidebar-hover-border: #294761;
  --sidebar-active-border: rgba(120, 167, 237, .5);
}

/* Shared shell and core surfaces. */
html,
body,
.layout,
.content { background-color: var(--bg-app); color: var(--text-primary); }

.content-topbar,
.card,
.soft-card,
.modal-content,
.offcanvas,
.dropdown-menu { background-color: var(--surface); border-color: var(--border-default); color: var(--text-primary); }

.content-topbar { box-shadow: 0 1px 2px rgba(23, 32, 51, .035); }

.sidebar { background: var(--surface); border-color: var(--border-default); color: var(--text-primary); }
.sidebar-rail { background: color-mix(in srgb, var(--primary-50) 72%, var(--surface-2)); border-color: var(--border-default); }
.sidebar-module-btn.active { color: var(--primary-700) !important; background: var(--primary-50) !important; border-left-color: var(--primary-600) !important; }
.sidebar-rail-btn.active,
.sidebar-brand-mark,
.topbar-account-btn { background: var(--primary-600); color: var(--text-onbrand); }

html[data-theme-resolved="dark"] .sidebar { background: var(--surface-2); }
html[data-theme-resolved="dark"] .sidebar-rail { background: #0c1929; }
html[data-theme-resolved="dark"] .sidebar-module-btn.active { color: var(--primary-800) !important; background: var(--primary-200) !important; }

/* Finance, receivables, payables, and dashboard workspaces share one accent. */
.fin-workspace,
.fc-workspace,
.pay-workspace,
.recv-workspace {
  --fin-blue: var(--primary-600);
  --fin-blue-soft: var(--primary-50);
  --fin-ink: var(--text-primary);
  --fin-muted: var(--text-muted);
  --fin-line: var(--border-default);
  --fin-surface: var(--surface);
  --fin-subtle: var(--surface-2);
  --fc-blue: var(--primary-600);
  --fc-ink: var(--text-primary);
  --fc-muted: var(--text-muted);
  --fc-line: var(--border-default);
  --fc-surface: var(--surface);
  --fc-subtle: var(--surface-2);
  --pay-blue: var(--primary-600);
  --recv-accent: var(--primary-600);
  color: var(--text-primary);
}

html[data-theme-resolved="dark"] .fin-workspace,
html[data-theme-resolved="dark"] .fc-workspace,
html[data-theme-resolved="dark"] .pay-workspace,
html[data-theme-resolved="dark"] .recv-workspace { --fin-blue-soft: rgba(120, 167, 237, .13); }

.fc-scope-notice,
.fc-callout {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--text-primary);
}
.fc-scope-notice > div strong,
.fc-callout strong { color: var(--text-primary); }
.fc-scope-notice > div span,
.fc-callout span { color: var(--text-secondary); }

/* Communications previously carried a separate hard-coded palette. */
.comm-workspace {
  --comm-border: var(--border-default);
  --comm-muted: var(--text-muted);
  --comm-blue: var(--primary-600);
  --comm-bg: var(--bg-app);
  color: var(--text-primary);
}

.comm-section,
.comm-stage,
.comm-builder-rail,
.comm-stepper,
.comm-type-option,
.comm-action-list > button,
.comm-link-stack button,
.comm-metric,
.comm-overview-metrics,
.comm-preview-recipients button,
.comm-search,
.comm-context span { background: var(--surface); color: var(--text-primary); border-color: var(--border-default); }

.comm-table thead th { background: var(--table-header-bg); color: var(--table-header-text); border-color: var(--table-border); }
.comm-table tbody td { color: var(--table-text); border-color: var(--table-border); }
.comm-table tbody tr.is-selected,
.comm-type-option.is-selected,
.comm-preview-recipients button.is-active { background: var(--primary-50); }

html[data-theme-resolved="dark"] .comm-section,
html[data-theme-resolved="dark"] .comm-stage,
html[data-theme-resolved="dark"] .comm-builder-rail,
html[data-theme-resolved="dark"] .comm-stepper,
html[data-theme-resolved="dark"] .comm-type-option,
html[data-theme-resolved="dark"] .comm-action-list > button,
html[data-theme-resolved="dark"] .comm-link-stack button,
html[data-theme-resolved="dark"] .comm-metric,
html[data-theme-resolved="dark"] .comm-overview-metrics,
html[data-theme-resolved="dark"] .comm-preview-recipients button,
html[data-theme-resolved="dark"] .comm-search,
html[data-theme-resolved="dark"] .comm-context span { background: var(--surface); color: var(--text-primary); border-color: var(--border-default); }

/* The theme picker is one control: only the wrapper receives focus chrome. */
.theme-switcher { background: var(--surface-2); border-color: var(--border-default); }
.theme-switcher .theme-switcher-select.form-select,
.theme-switcher .theme-switcher-select.form-select:hover,
.theme-switcher .theme-switcher-select.form-select:focus,
.theme-switcher .theme-switcher-select.form-select:focus-visible {
  background: transparent;
  border-color: transparent;
  color: var(--text-primary);
  box-shadow: none;
  outline: none;
}

::selection { background: var(--selection-bg); color: var(--selection-text); }

/* Navigation shell owns its semantic active-state colors in both themes. */
html[data-theme-resolved="dark"] .sidebar-module-btn.active {
  color: var(--nav-active-fg) !important;
  background: var(--nav-sidebar-active) !important;
  border-left-color: transparent !important;
}

html[data-theme-resolved="dark"] .sidebar-module-btn.active i {
  color: var(--nav-active-fg) !important;
}
