:root {
  color-scheme: light;
  --ui-font-family: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  --ui-font-mono: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  --ui-font-size-100: 0.75rem;
  --ui-font-size-200: 0.8125rem;
  --ui-font-size-300: 0.875rem;
  --ui-font-size-400: 1rem;
  --ui-font-size-500: 1.25rem;
  --ui-font-size-600: 1.5rem;
  --ui-line-height-compact: 1.25;
  --ui-line-height-body: 1.45;
  --ui-space-1: 2px;
  --ui-space-2: 4px;
  --ui-space-3: 6px;
  --ui-space-4: 8px;
  --ui-space-5: 12px;
  --ui-space-6: 16px;
  --ui-space-7: 24px;
  --ui-space-8: 32px;
  --ui-radius-control: 4px;
  --ui-radius-compact: 2px;
  --ui-radius-surface: 6px;
  --ui-border-width: 1px;
  --ui-control-height: 30px;
  --ui-control-padding-inline: 10px;
  --ui-icon-size: 20px;
  --ui-color-canvas: #f5f5f5;
  --ui-color-surface-1: #ffffff;
  --ui-color-surface-2: #fafafa;
  --ui-color-surface-3: #f0f0f0;
  --ui-color-surface-hover: #f3f3f3;
  --ui-color-surface-pressed: #e8e8e8;
  --ui-color-text: #242424;
  --ui-color-text-secondary: #616161;
  --ui-color-text-disabled: #a6a6a6;
  --ui-color-border: #d1d1d1;
  --ui-color-border-strong: #8a8886;
  --ui-color-accent: #0f6cbd;
  --ui-color-accent-hover: #115ea3;
  --ui-color-accent-pressed: #0c3b5e;
  --ui-color-accent-subtle: #ebf3fc;
  --ui-color-on-accent: #ffffff;
  --ui-color-focus: #0f6cbd;
  --ui-color-success: #107c10;
  --ui-color-success-subtle: #e9f5e9;
  --ui-color-warning: #8a5d00;
  --ui-color-warning-subtle: #fff4ce;
  --ui-color-danger: #c50f1f;
  --ui-color-danger-hover: #b10e1c;
  --ui-color-danger-subtle: #fde7e9;
  --ui-color-info: #0f6cbd;
  --ui-color-info-subtle: #ebf3fc;
  --ui-color-overlay: rgb(0 0 0 / 40%);
  --ui-shadow-flyout: 0 8px 24px rgb(0 0 0 / 14%), 0 2px 6px rgb(0 0 0 / 10%);
  --ui-shadow-raised: 0 2px 6px rgb(0 0 0 / 10%);
  --ui-focus-ring: 0 0 0 2px var(--ui-color-surface-1), 0 0 0 4px var(--ui-color-focus);
  --ui-motion-fast: 100ms;
  --ui-motion-normal: 160ms;
  --ui-z-sticky: 100;
  --ui-z-flyout: 500;
  --ui-z-dialog: 1000;
}
:root[data-density="touch"] {
  --ui-control-height: 40px;
  --ui-control-padding-inline: 12px;
  --ui-space-control-gap: 8px;
}

:root[data-density="compact"] {
  --ui-space-control-gap: 4px;
}

@media (prefers-contrast: more) {
  :root {
    --ui-color-border: #616161;
    --ui-color-border-strong: #242424;
    --ui-focus-ring: 0 0 0 3px var(--ui-color-focus);
  }
}

/* User-selectable accent palettes. CSS variables update live without rebuilding
   the ERP shell or the shared SpreadsheetGrid component. Keep a fixed, readable
   color ramp per palette rather than generating unverified contrast at runtime. */
:root[data-ui-accent="jade"] {
  --user-theme-main: #0b7076;
  --user-theme-hover: #095b60;
  --user-theme-pressed: #064347;
  --user-theme-subtle: #e8f5f4;
  --user-theme-rgb: 11 112 118;
}
:root[data-ui-accent="green"] {
  --user-theme-main: #286b39;
  --user-theme-hover: #1f552e;
  --user-theme-pressed: #153d21;
  --user-theme-subtle: #ecf6ee;
  --user-theme-rgb: 40 107 57;
}
:root[data-ui-accent="purple"] {
  --user-theme-main: #6844a5;
  --user-theme-hover: #543584;
  --user-theme-pressed: #3d2666;
  --user-theme-subtle: #f1ebfa;
  --user-theme-rgb: 104 68 165;
}
:root[data-ui-accent="coral"] {
  --user-theme-main: #a84636;
  --user-theme-hover: #8e352b;
  --user-theme-pressed: #69231d;
  --user-theme-subtle: #fdf0ed;
  --user-theme-rgb: 168 70 54;
}
:root[data-ui-accent="amber"] {
  --user-theme-main: #89540d;
  --user-theme-hover: #6e4307;
  --user-theme-pressed: #533107;
  --user-theme-subtle: #fff4db;
  --user-theme-rgb: 137 84 13;
}
:root[data-ui-accent]:not([data-ui-accent="blue"]) {
  --ui-color-accent: var(--user-theme-main);
  --ui-color-accent-hover: var(--user-theme-hover);
  --ui-color-accent-pressed: var(--user-theme-pressed);
  --ui-color-accent-subtle: var(--user-theme-subtle);
  --ui-color-focus: var(--user-theme-main);
  --ui-color-info: var(--user-theme-main);
  --ui-color-info-subtle: var(--user-theme-subtle);

  /* Grid variables are declared in its existing component stylesheet.
     This selector has greater specificity, so it takes precedence without
     editing the component or changing any spreadsheet interaction code. */
  --grid-brand: var(--user-theme-main);
  --grid-brand-strong: var(--user-theme-hover);
  --grid-brand-soft: rgb(var(--user-theme-rgb) / 10%);
  --grid-brand-surface: var(--user-theme-subtle);
  --grid-axis-soft: rgb(var(--user-theme-rgb) / 5.5%);
  --grid-selection-soft: rgb(var(--user-theme-rgb) / 7.5%);
}
