/* =====================================================================================================================
   HD ERP design tokens: the single source of truth for the look of every HD Holding app (the ERP portal and each module).
   GitLab: itw/devops/theme/theme-hd-erp. Apps copy this file unchanged (CRM: frontend/src/theme/tokens.css) and never
   edit their copy: a change is made here, versioned, and copied out again.

   Rules (also in CLAUDE.md): screens use these tokens only. No hex or rgb() literal, no pixel font size, no custom
   shadow, no radius outside the scale, anywhere else. Colours are "R G B" triplets so a token takes an opacity:
   rgb(var(--color-primary))  or  rgb(var(--color-primary) / .12).   Contrast is checked: text 4.5:1 or more, control
   borders 3:1 or more, in both themes (values in the comments are the light ones).
   ===================================================================================================================== */
:root{
  color-scheme:light;

  /* ---- neutrals: slate page, white surfaces, hairline borders ---------------------------------------------------- */
  --color-bg:241 244 248;              /* #F1F4F8 page background                                                     */
  --color-bg-subtle:247 249 251;       /* #F7F9FB table header, hover row, zebra, read-only field                     */
  --color-surface:255 255 255;         /* #FFFFFF cards, panels, tables, inputs                                       */
  --color-surface-raised:255 255 255;  /* #FFFFFF menus, popovers, dialogs, drawers                                   */
  --color-border:225 230 236;          /* #E1E6EC 1px card, table and divider lines                                   */
  --color-border-strong:201 209 219;   /* #C9D1DB section dividers, disabled control edge                             */
  --color-border-input:124 138 154;    /* #7C8A9A input, select and checkbox edge (3.5:1 on white, 3.2:1 on the page) */

  /* ---- text --------------------------------------------------------------------------------------------------- */
  --color-text:15 27 45;               /* #0F1B2D body and headings (17.3:1)                                          */
  --color-text-muted:70 86 107;        /* #46566B secondary text, table headers, labels (7.5:1)                       */
  --color-text-subtle:92 107 126;      /* #5C6B7E hints, placeholders, timestamps (5.4:1; 4.9:1 on the page; 4.6:1 on primary-subtle) */
  --color-text-inverse:255 255 255;    /* #FFFFFF text on primary and on the navigation                               */
  --color-link:36 80 127;              /* #24507F links in text                                                       */
  --color-text-on-status:255 255 255;  /* #FFFFFF text on a solid success or danger button (7.5:1; dark theme: navy)  */
  --color-text-on-light:15 27 45;      /* #0F1B2D text on a light data colour (a workspace colour), both themes      */

  /* ---- brand: deep navy primary ----------------------------------------------------------------------------------*/
  --color-primary:30 58 95;            /* #1E3A5F primary buttons, active states, focus (white on it 11.5:1)          */
  --color-primary-hover:22 45 75;      /* #162D4B                                                                     */
  --color-primary-active:16 34 58;     /* #10223A                                                                     */
  --color-primary-subtle:231 237 245;  /* #E7EDF5 selected row, active tab, chosen option                             */
  --color-focus:62 110 168;            /* #3E6EA8 the 2px focus ring                                                  */
  --color-brand-gold:201 174 79;       /* #C9AE4F the HD monogram plate only, never a control                         */
  --color-brand-gold-ink:27 22 8;      /* #1B1608 letters on the gold plate                                           */

  /* ---- navigation (the sidebar panel): deep navy in both themes ------------------------------------------------- */
  --color-nav-bg:15 27 45;             /* #0F1B2D                                                                     */
  --color-nav-fg:227 233 241;          /* #E3E9F1 (14.2:1)                                                            */
  --color-nav-fg-muted:154 168 186;    /* #9AA8BA group labels, hints (7.2:1)                                         */
  --color-nav-hover:255 255 255;       /* used at .06                                                                 */
  --color-nav-active:30 51 82;         /* #1E3352 the current page                                                    */
  --color-nav-indicator:127 163 207;   /* #7FA3CF the current page's icon, the on switch, badges on the navigation   */
  --color-nav-border:255 255 255;      /* used at .08 for dividers                                                    */
  --color-nav-border-input:96 112 134; /* #607086 edge of a control on the rail (3.4:1; dark theme rail 3.5:1)       */
  /* status dots on the navigation (a page's state, the only cue left in the dock): the panel is navy in both themes, so
     one set, the dark-theme dots. On nav-bg / nav-active / a hovered item, light theme (the dark theme's are higher): */
  --color-nav-dot-success:74 190 124;  /* 7.4 / 5.4 / 6.3                                                             */
  --color-nav-dot-warning:230 160 70;  /* 7.8 / 5.7 / 6.7                                                             */
  --color-nav-dot-danger:232 110 110;  /* 5.7 / 4.2 / 4.8                                                             */
  --color-nav-dot-info:110 158 220;    /* 6.2 / 4.6 / 5.3                                                             */
  --color-nav-dot-neutral:140 154 173; /* 6.0 / 4.5 / 5.2 the default dot                                             */

  /* ---- status: muted, always with a word or an icon, never colour alone ---------------------------------------- */
  --color-success:23 96 58;     --color-success-bg:234 246 239; --color-success-border:187 222 202; --color-success-dot:31 148 88;
  --color-warning:138 75 10;    --color-warning-bg:253 243 227; --color-warning-border:240 214 168; --color-warning-dot:214 132 26;
  --color-danger:155 44 44;     --color-danger-bg:252 237 237;  --color-danger-border:240 196 196;  --color-danger-dot:206 64 64;
  --color-info:31 78 140;       --color-info-bg:234 241 251;    --color-info-border:194 212 238;    --color-info-dot:62 110 168;
  --color-neutral:58 74 94;     --color-neutral-bg:238 242 246; --color-neutral-border:214 221 230; --color-neutral-dot:120 134 152;

  /* ---- categories: owner-chosen colours of modules and tiles, never a status. Generic names; the ERP's tile colours
     are 1 gold, 2 charcoal, 3 green, 4 blue, 5 red, 6 plum. Muted; the six dots are 10 or more apart from each other
     (OKLab ΔE×100) in both themes. Some sit near a status colour (charcoal and neutral, blue and info, red and danger),
     accepted because a category always shows its name and a status its word (rule 8). Text on its bg
     4.5:1 or more and the dot 3:1 or more on the surface, in both themes; the border is decorative. ------------- */
  --color-category-1-bg:250 243 224; --color-category-1-border:225 212 172; --color-category-1-fg:95 76 6;   --color-category-1-dot:157 128 18;  /* gold: text 7.5:1, dot 3.8:1 */
  --color-category-2-bg:245 243 240; --color-category-2-border:217 211 205; --color-category-2-fg:86 78 70;  --color-category-2-dot:137 126 115; /* charcoal: 7.4:1, 4.0:1   */
  --color-category-3-bg:238 248 229; --color-category-3-border:201 220 183; --color-category-3-fg:50 75 16;  --color-category-3-dot:79 115 30;   /* green: 8.9:1, 5.5:1      */
  --color-category-4-bg:228 247 254; --color-category-4-border:180 220 235; --color-category-4-fg:9 89 110;  --color-category-4-dot:34 141 172;  /* blue: 7.1:1, 3.8:1       */
  --color-category-5-bg:255 237 242; --color-category-5-border:245 198 209; --color-category-5-fg:119 57 76; --color-category-5-dot:186 95 123;  /* red: 7.5:1, 4.2:1        */
  --color-category-6-bg:247 240 255; --color-category-6-border:220 204 243; --color-category-6-fg:90 66 119; --color-category-6-dot:144 109 186; /* plum: 7.6:1, 4.1:1       */

  /* ---- charts: one navy ramp for ordered series, status colours for outcomes ------------------------------------ */
  --color-chart-1:30 58 95;  --color-chart-2:62 110 168;  --color-chart-3:127 163 207;  --color-chart-4:185 205 229;
  --color-chart-muted:148 160 176;  --color-chart-grid:225 230 236;

  --color-backdrop:9 15 25;            /* used at .5 behind dialogs and drawers                                       */
  --color-skeleton:229 233 239;        /* #E5E9EF a loading placeholder block (1.2:1 on white: a shape, not text)       */
  --color-scroll-edge:201 209 219;     /* #C9D1DB the soft edge on the side of a table that scrolls further             */

  /* ---- typography: one sans family, a strict scale, tabular figures for data ------------------------------------ */
  --font-sans:"Inter Variable","Inter",system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  --font-mono:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
  --font-numeric:tabular-nums;          /* font-variant-numeric for every figure, amount, date and id column          */
  --weight-regular:400; --weight-medium:500; --weight-semibold:600; --weight-bold:700;

  --text-page-title:20px;   --leading-page-title:28px;   --tracking-page-title:-.01em;  /* h1, one per page          */
  --text-section:15px;      --leading-section:22px;                                      /* h2, card and dialog titles */
  --text-subsection:13px;   --leading-subsection:20px;                                   /* h3, group titles           */
  --text-body:14px;         --leading-body:20px;                                         /* body, inputs, buttons      */
  --text-table:13px;        --leading-table:18px;                                        /* table cells                */
  --text-table-head:11px;   --leading-table-head:16px;   --tracking-table-head:.04em;    /* uppercase column headers   */
  --text-label:12px;        --leading-label:16px;                                        /* field labels, badges       */
  --text-caption:12px;      --leading-caption:16px;                                      /* help, hints, timestamps    */
  --text-kpi:22px;          --leading-kpi:28px;                                          /* figures on stat tiles      */
  --text-touch-input:16px;                                    /* inputs on touch screens, so phones do not zoom       */

  /* ---- spacing: one 4px scale; tables and forms are compact ------------------------------------------------------ */
  --space-0-5:2px; --space-1:4px; --space-1-5:6px; --space-2:8px; --space-3:12px; --space-4:16px; --space-5:20px;
  --space-6:24px;  --space-8:32px; --space-10:40px;

  --control-h:32px;  --control-h-sm:28px;  --control-h-lg:36px;  --control-h-touch:40px;  --control-px:10px;
  --table-head-h:32px;  --table-cell-py:6px;  --table-cell-px:12px;
  --field-gap:12px;       /* between fields in a form                                                                 */
  --card-pad:16px;        /* inside cards and panels                                                                  */
  --badge-h:20px;         /* status badges, tags and chips                                                            */
  --badge-h-sm:16px;      /* counters on icons and on navigation items                                                */

  /* ---- radii: subtle and few ------------------------------------------------------------------------------------ */
  --radius-sm:4px;        /* controls, buttons, badges, chips, table and menu items                                   */
  --radius-md:6px;        /* cards, panels, tables, menus, dialogs, drawers                                           */
  --radius-full:999px;    /* avatars, status dots and switches only                                                   */
  --radius-nav:28px;      /* the floating navigation panel only                                                       */
  --radius-nav-item:999px;/* pill items, workspace box, dock and strip of the navigation only                           */

  /* ---- elevation: borders give structure; shadows only for things that float ------------------------------------- */
  --shadow-overlay:0 8px 24px rgb(15 27 45 / .14),0 2px 6px rgb(15 27 45 / .08);  /* menus, popovers, dialogs, drawers, floating nav */
  --shadow-focus:0 0 0 2px rgb(var(--color-focus) / .55);                          /* keyboard focus on controls       */
  --shadow-focus-nav:inset 0 0 0 2px rgb(var(--color-nav-indicator));              /* keyboard focus on the rail (6.6:1) */
  --blur-chrome:12px;  /* frosted sticky top bar (backdrop-filter); off under prefers-reduced-motion                 */

  /* ---- layout ------------------------------------------------------------------------------------------------ */
  --layout-nav-w:272px;  --layout-nav-w-slim:64px;  --layout-topbar-h:48px;  --layout-content-max:1600px;
  --layout-content-pad:20px;  --layout-content-pad-sm:12px;  --layout-drawer-w:760px;  --layout-dialog-w:560px;
  --layout-dialog-w-wide:800px;  --layout-popover-w:384px;  --layout-popover-h:560px;  --layout-menu-w:220px;
  --layout-topbar-select-w:120px;  /* a select in the phone top bar, so it does not squeeze the breadcrumb            */
  --layout-dialog-w-sm:416px;  /* a short dialog: a confirmation, one or two fields                                    */
  --layout-palette-w:640px;    /* the command palette (search and jump)                                                 */
  --layout-nav-inset:16px;  --layout-nav-inset-sm:12px;  /* gap between the floating navigation and the page edges      */
  --layout-nav-item-h:42px; /* a navigation item in the sidebar                                                        */

  /* ---- layers and motion ------------------------------------------------------------------------------------- */
  --z-sticky:20; --z-nav:40; --z-backdrop:50; --z-drawer:55; --z-dialog:60; --z-popover:65; --z-toast:70;
  --duration-fast:120ms; --duration:180ms; --ease:cubic-bezier(.2,.8,.2,1);
  --duration-pop:280ms;   /* a dialog box popping in                                                                 */
  --duration-nav:350ms;   /* the sidebar folding into the dock and back                                              */
  --duration-drawer:380ms;/* a drawer sliding in                                                                     */
  --duration-enter:500ms; /* page content rising in on every page open                                               */
  --stagger-step:50ms;    /* delay between the page's first blocks rising in                                          */
  --duration-loop:1.2s;   /* one turn of a looping cue: a skeleton shimmer, a spinner                                 */
}

/* Dark theme: same names, darker steps. Depth is a lighter surface, not a shadow. Set by theme-init.js on <html>. */
:root[data-theme="dark"]{
  color-scheme:dark;
  --color-bg:12 20 32;  --color-bg-subtle:16 26 40;  --color-surface:19 30 45;  --color-surface-raised:25 38 56;
  --color-border:36 51 74;  --color-border-strong:51 70 95;  --color-border-input:95 115 144;
  --color-text:230 236 243;  --color-text-muted:169 182 198;  --color-text-subtle:140 154 173;  --color-link:141 180 230;
  --color-text-on-status:15 27 45;     /* navy on the light dark-theme success (9.6:1) and danger (8.6:1) fills        */
  --color-primary:62 110 168;  --color-primary-hover:76 124 182;  --color-primary-active:52 96 150;
  --color-primary-subtle:28 46 72;  --color-focus:141 180 230;
  --color-nav-bg:16 26 40;  --color-nav-active:28 46 72;   /* the panel a step lighter than the page, so its shape shows */
  --color-success:126 211 162; --color-success-bg:18 53 38;  --color-success-border:33 84 60;  --color-success-dot:74 190 124;
  --color-warning:240 190 121; --color-warning-bg:58 43 20;  --color-warning-border:94 70 34;  --color-warning-dot:230 160 70;
  --color-danger:242 163 163;  --color-danger-bg:61 29 34;   --color-danger-border:99 46 54;   --color-danger-dot:232 110 110;
  --color-info:157 192 240;    --color-info-bg:21 43 72;     --color-info-border:38 70 112;    --color-info-dot:110 158 220;
  --color-neutral:195 206 219; --color-neutral-bg:28 40 57;  --color-neutral-border:46 62 84;  --color-neutral-dot:140 154 173;
  /* categories (gold, charcoal, green, blue, red, plum): text on its bg, then the dot on the surface #131E2D */
  --color-category-1-bg:50 43 19;  --color-category-1-border:81 68 28;  --color-category-1-fg:205 189 134; --color-category-1-dot:170 135 51;  /* 7.5:1, 5.0:1 (dot clear of brand gold) */
  --color-category-2-bg:46 43 40;  --color-category-2-border:73 68 63;  --color-category-2-fg:212 204 196; --color-category-2-dot:173 163 152; /* 8.9:1, 6.8:1 */
  --color-category-3-bg:37 48 25;  --color-category-3-border:58 75 40;  --color-category-3-fg:199 226 174; --color-category-3-dot:160 198 121; /* 9.8:1, 8.7:1 */
  --color-category-4-bg:23 47 55;  --color-category-4-border:34 75 89;  --color-category-4-fg:160 216 236; --color-category-4-dot:91 178 207;  /* 9.0:1, 7.0:1 */
  --color-category-5-bg:60 35 42;  --color-category-5-border:96 55 66;  --color-category-5-fg:249 186 202; --color-category-5-dot:222 135 159; /* 8.8:1, 6.5:1 */
  --color-category-6-bg:47 38 60;  --color-category-6-border:75 61 96;  --color-category-6-fg:214 194 247; --color-category-6-dot:177 148 223; /* 8.8:1, 6.5:1 */
  --color-chart-1:141 180 230; --color-chart-2:94 143 203; --color-chart-3:62 110 168; --color-chart-4:40 74 117;
  --color-chart-muted:110 124 143; --color-chart-grid:36 51 74;
  --color-backdrop:0 0 0;
  --color-skeleton:33 47 67;  --color-scroll-edge:51 70 95;   /* placeholder 1.2:1 on the surface; edge as border-strong */
  --shadow-overlay:0 10px 28px rgb(0 0 0 / .45),0 2px 6px rgb(0 0 0 / .3);
}

/* Touch screens: finger-sized controls and 16px inputs (iOS zooms the page on smaller ones). */
@media (pointer:coarse){
  :root{--control-h:var(--control-h-touch);--control-h-sm:var(--control-h-touch)}
}
