/* CRM library, file 1 of 7: tokens. The library sits between ds.css and app.css; the pages link its files one by one in a fixed
   order (LIB_FILES in scripts/ui-lint.mjs): tokens, base, chip, controls, surface, timeline, data.

   Belongs here: custom properties and nothing else. The --crm-* tokens the library adds to those of ds.css (the missing inks, one
   hue palette, names for surface, elevation and radius, density, control heights, icon sizes, weights, stacking, motion, the focus
   ring), the compact density scope ([data-density]) and the coarse-pointer and reduced-motion overrides of those tokens.

   Contract: a token is defined in :root, a colour also in html[data-theme="dark"]; hex appears only inside those two blocks.
   No rule in this file styles anything; a value one component can adjust is not a token but a --k-* knob in that component's file. */

:root {
  /* The two inks ds.css lacks: text on --blue-soft and on --coral-soft. ds has --green-ink, --amber-ink and --violet-ink, but
     --blue-dark gets darker in dark mode (2.7:1 on --blue-soft there) and --coral on --coral-soft is 3.2:1 in light.
     Contrast on the soft colour: info 5.9:1 light, 7.0:1 dark; bad 5.4:1 light, 7.4:1 dark (dark measured over --surface-2). */
  --crm-info-ink: var(--blue-dark);
  --crm-bad-ink: #be123c;

  /* One categorical palette of eight hues, three steps each:
       <hue>        the colour itself: a dot, an icon, a rail, a border, the source of a tint (color-mix 14 % with the surface)
       <hue>-ink    text on that tint and on a surface: at least 4.5:1 on the 14 % tint over --surface and --surface-2, both themes
       <hue>-solid  a fill under --crm-on-solid text
     <hue> is what a kind of activity and a status of a task had as their own tokens in app.css (--crm-act-*, --crm-st-*; gone
     since the tone table of lib/chip.css reads the palette). As text
     on its own tint <hue> is under 4.5:1 in light (slate 4.0, blue 4.2, amber 4.2, green 3.7, red 3.9), which is why text takes
     the ink step. <hue>-solid is the colour of a pipeline tag (crm-tag c1..c6 in lib/chip.css; they were --crm-tag-1..6 in
     app.css). White on every solid is at least 4.5:1 in both themes; for that green is a shade darker than the old tag colour
     (light 4.4 -> 4.7, dark 3.9 -> 4.7) and so is amber in dark (4.0 -> 4.7). */
  --crm-hue-slate: #64748b;  --crm-hue-slate-ink: var(--muted);          --crm-hue-slate-solid: #475569;
  --crm-hue-blue: #2563eb;   --crm-hue-blue-ink: var(--crm-info-ink);    --crm-hue-blue-solid: #2563eb;
  --crm-hue-amber: #b45309;  --crm-hue-amber-ink: #92400e;               --crm-hue-amber-solid: #b45309;
  --crm-hue-violet: #7c3aed; --crm-hue-violet-ink: var(--violet-ink);    --crm-hue-violet-solid: #7c3aed;
  --crm-hue-green: #0f8a5f;  --crm-hue-green-ink: #065f46;               --crm-hue-green-solid: #0e8459;
  --crm-hue-pink: #be185d;   --crm-hue-pink-ink: #9d174d;                --crm-hue-pink-solid: #be185d;
  --crm-hue-red: #dc2626;    --crm-hue-red-ink: var(--crm-bad-ink);      --crm-hue-red-solid: #dc2626;
  /* teal is the sixth colour of the avatars (--crm-av-6 in app.css), so a record whose avatar is teal has a tint of its own (the head
     of the quick view, 12-11-2026); ink on its tint 6.0 light, 9.8 dark; white on the solid 5.4 light, 5.0 dark */
  --crm-hue-teal: #0e7490;   --crm-hue-teal-ink: #155e75;                --crm-hue-teal-solid: #0e7490;

  --crm-on-solid: #ffffff;        /* text on a solid fill; the same in both themes, every solid is dark enough for it */

  /* An action only admins have (Marley 18-11-2026: "kunnen we een kleur uitkiezen voor admin acties zodat je als admin direct ziet dat
     enkel admins op bepaalde knoppen kunnen drukken?"): its ink (the icon, the label, the shield of crm-admin-mark) and the soft field
     under it. A hue none of the tones and hues has (fuchsia, Dealleader plum), never the only signal: the shield and the tooltip "Alleen
     beheerders" say it too (lib/controls.css, components/admin.js). Ink on the surface 8.2:1, on the soft field 7.1:1; dark 10.1 and 7.1 */
  --crm-admin: #86198f;
  --crm-admin-soft: #fae8ff;

  /* Surface, elevation and radius: names for roles, values from ds.css (they follow dark mode by themselves). */
  --crm-surface-card: var(--surface);
  --crm-surface-sunken: var(--surface-2);
  --crm-surface-float: var(--surface);
  --crm-surface-selected: var(--blue-soft);
  --crm-elev-card: var(--sh-sm);
  --crm-elev-raised: var(--sh);
  --crm-elev-float: var(--sh-lg);
  --crm-radius-card: var(--r-lg);
  --crm-radius-box: var(--r);
  --crm-radius-ctl: var(--r-sm);
  --crm-radius-tag: .375rem;       /* a square chip (pipeline, deal stage, a free label): clearly not a pill, also at the small size */
  /* a control with round ends: the search field, a filter chip, a segmented control, an icon button, an item of the menu, the Create
     button. A badge, a count, a dot and an avatar stay round in every theme: their shape is what they are. */
  --crm-radius-pill: var(--pill);
  --crm-chosen: var(--crm-hue-blue-solid); /* the chosen part of a segmented control, under --crm-on-solid */
  --crm-card-ruled: 0;             /* 1: a line under the head of a card, and the head's room again above the body */

  /* Density: read by cards, entries and tables; [data-density="compact"] below remaps it. The values are today's card and cell
     padding and the small avatar. */
  --crm-pad-x: var(--sp-6);
  --crm-pad-y: var(--sp-5);
  --crm-gap: var(--sp-5);
  --crm-row-y: var(--sp-3);
  --crm-cell-x: var(--sp-4);
  --crm-av-sm: 1.9rem;

  /* Controls: the height of a search field, a filter chip, a segmented control and a select; icon buttons; static chips; icons. */
  --crm-ctl-h: 2.25rem;
  --crm-ctl-h-sm: 1.75rem;
  --crm-ib-xs: 1.5rem;
  --crm-ib-sm: 1.75rem;
  --crm-ib-md: 2rem;
  --crm-ib-lg: 2.5rem;
  --crm-chip-h: 1.5rem;
  --crm-chip-h-sm: 1.25rem;
  --crm-icon-xs: .9375rem;
  --crm-icon-sm: 1.125rem;
  --crm-icon-md: 1.25rem;
  --crm-icon-lg: 1.25rem;        /* Hutspot 18-11-2026 (Marley): was 1.5rem; Dealleader keeps 1.5rem */
  --crm-brand-mark: 2rem;        /* the square of the logo in the menu (Hutspot; was 3rem, Dealleader keeps 3rem) */
  --crm-hit: 0rem;                 /* the least touch area of a small control; a coarse pointer raises it */
  --crm-fs-input: var(--fs-md);    /* the type size of a field; a coarse pointer and a phone raise it past the size where iOS zooms in */

  /* The frame of a phone (Marley 12-11-2026): the height of the dock at the bottom (crm-dock in lib/controls.css), without the safe
     area under it, and the room under the content of a page (on a phone so its last line is not under the dock). The hub's pill
     (#aptw-hub-back of auth.js) is hidden in the CRM since 13-11-2026: the user menu has the way back to the hub. */
  --crm-dock-h: 3.5rem;
  --crm-foot-clear: var(--sp-7);

  /* The shell: the menu at the left and the top bar (moved from app.css on 17-11-2026, so a theme can change them). The menu is dark
     in light and dark alike, like HubSpot; in Hutspot the top bar stands on the menu's colour and the content is a panel with one
     rounded corner, in Dealleader the top bar is a light bar of its own. The shape of an item of the menu is tokens too: its icon
     beside its label (row) or above it (column, the rail of Dealleader on a desktop). */
  --crm-nav-bg: #1d2530;
  --crm-nav-ink: #e8edf3;
  --crm-nav-muted: #9ba7b6;
  --crm-nav-hover: #2a3442;
  --crm-nav-active: #3a4656;
  --crm-nav-line: #35404f;
  --crm-nav-field: #2a3442;
  --crm-nav-w: 14rem;
  --crm-nav-w-collapsed: 4.25rem;
  --crm-nav-pad: var(--sp-4);      /* the room around the items */
  --crm-nav-dir: row;
  --crm-nav-gap: var(--sp-4);      /* between the icon and the label of an item, and of the brand */
  --crm-nav-item-h: 2.5rem;
  --crm-nav-item-pad: 0 var(--sp-4);
  --crm-nav-fs: var(--fs-md);
  --crm-nav-align: start;
  --crm-nav-justify: normal;       /* an item along its axis; center in the rail of Dealleader (17-11-2026) */
  --crm-nav-chevron: inline-block; /* the arrow of a group (Marketing, Logistiek); none where the label stands under its icon */
  --crm-nav-brand-fs: var(--fs-xl);
  --crm-nav-brand-pad: 0 var(--sp-3);
  --crm-nav-brand-text: inline;    /* the name next to the mark; none in the rail of Dealleader (17-11-2026) */
  --crm-brand-glyph: 'skillet';    /* the Material Symbol in the mark of the menu: the skillet of Hutspot (18-11-2026, was the stockpot) */
  --crm-panel-r: 1rem;             /* the corner of the content where it meets the menu and the top bar */
  --crm-top-bg: transparent;
  --crm-top-ink: var(--crm-nav-ink);
  --crm-top-muted: var(--crm-nav-muted);
  --crm-top-field: var(--crm-nav-field);
  --crm-top-line: var(--crm-nav-line);
  --crm-top-edge: transparent;     /* the line under the top bar */

  /* Type: three weights (ds.css and app.css write 550, 600, 650 and 700 as numbers), the tracking of capitals, the mono stack. */
  --crm-fw-medium: 550;
  --crm-fw-semibold: 650;
  --crm-fw-bold: 700;
  --crm-track-caps: .05em;
  --crm-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* A skeleton (lib/surface.css): the grey of a shape that stands where content comes, and the lighter band that runs over it.
     --line-strong, not --line: --line on the sunken surface of a table head or a lane is 1.14:1 and as good as gone (review 12-11). */
  --crm-skel: var(--line-strong);
  --crm-skel-shine: var(--line);

  /* Motion and focus: the .12s of ds.css, one slower step, the ring of a ds field. */
  --crm-dur-fast: .12s;
  --crm-dur: .18s;
  --crm-ring: 0 0 0 .1875rem var(--blue-soft);

  /* Stacking: the numbers app.css uses today, named. Inside one component 1, 2 and 3 stay plain numbers. The hub's own layers sit
     between them: ds-combo list 70, ds-table menu 90, ds-select list above the toasts. */
  --crm-z-sticky: 5;               /* the frozen corner cells of a table */
  --crm-z-top: 50;                 /* the top bar */
  --crm-z-scrim: 55;               /* the scrim under the phone drawer */
  --crm-z-nav: 60;                 /* the navigation */
  --crm-z-flyout: 70;              /* the panel of a collapsed navigation item */
  --crm-z-dropdown: 120;           /* the results under the search field of the top bar */
  --crm-z-popover: 140;            /* popovers and menus */
  --crm-z-skip: 300;               /* the skip link */
  --crm-z-toast: 2147482000;       /* toasts, above an open dialog */
}

html[data-theme="dark"] {
  --crm-info-ink: #93c5fd;
  --crm-bad-ink: #fda4af;
  --crm-hue-slate: #8b9bb0;                                              --crm-hue-slate-solid: #5b6b82;
  --crm-hue-blue: #6aa6ff;                                               --crm-hue-blue-solid: #2f6fe0;
  --crm-hue-amber: #e0a23b;  --crm-hue-amber-ink: var(--amber-ink);      --crm-hue-amber-solid: #b25d0d;
  --crm-hue-violet: #a98bff;                                             --crm-hue-violet-solid: #7a45e0;
  --crm-hue-green: #43c59e;  --crm-hue-green-ink: var(--green-ink);      --crm-hue-green-solid: #10845e;
  --crm-hue-pink: #e06aa8;   --crm-hue-pink-ink: #f9a8d4;                --crm-hue-pink-solid: #c4357f;
  --crm-hue-red: #f87171;                                                --crm-hue-red-solid: #cf3a3a;
  --crm-hue-teal: #2cb5c9;   --crm-hue-teal-ink: #67e8f9;                --crm-hue-teal-solid: #0f7a91;
  --crm-admin: #f0abfc;
  --crm-admin-soft: rgba(217, 70, 239, .22);
  /* the same step as in light: --line is 9 % white in dark, too faint for a shape on --surface-2 */
  --crm-skel: var(--line-strong);
  --crm-skel-shine: var(--line);
  --crm-nav-bg: #07090d;
  --crm-nav-ink: #dde1e8;
  --crm-nav-muted: #7f8a9a;
  --crm-nav-hover: #131820;
  --crm-nav-active: #212936;
  --crm-nav-line: #1b222c;
  --crm-nav-field: #131820;
}

/* ── The themes of the CRM ──────────────────────────────────────────────────────────────────────────────────────────────────────────
   Everyone picks one in the user menu, next to light and dark (Marley 17-11-2026): Hutspot is the style above (:root and the dark
   block), HubSpot-like; Dealleader is the CRM after Teamleader, where the sales team came from. public/app/crm-theme.js sets it on
   <html> as data-crm-theme before the first paint; the account keeps it (PUT /api/settings/theme). A theme is token values and
   nothing else: no screen and no building block knows which theme it is in.

   Dealleader: square corners (the radii of ds.css, the controls with round ends), cards with a line instead of a shadow and a line
   under their head, a grey page, teal for what acts (the blue of ds.css: buttons, links, the chosen tab, focus), slate for a chosen
   segment, a slate menu whose active item is a teal block, a light top bar with a line under it, and on a desktop a narrow rail with
   the label under its icon. It also sets tokens of ds.css (--r*, --sh*, --bg, --line-soft, --blue*), so the buttons and fields of
   ds.css follow. This block weighs as much as html[data-theme="dark"] and comes after it, so every colour it sets is set again in its
   dark twin below (lint theme-twin). The teal of what acts is #00b2b2 in both (Marley 18-11-2026, was #007c80): white on it 2.6:1 and
   the teal as text on the page 2.4:1, under AA by choice; the label of the menu on its slate 11.6:1 (dark 13.3:1), white on the active
   item 5.0:1 (dark 5.6:1), the info ink on the soft teal 5.9:1. */
html[data-crm-theme="dealleader"] {
  --crm-brand-glyph: 'hub';
  --crm-icon-lg: 1.5rem;
  --crm-brand-mark: 3rem;
  --r-sm: .1875rem;
  --r: .1875rem;
  --r-lg: .25rem;
  --sh-sm: 0 0 0 transparent;
  --sh: 0 .0625rem .125rem rgba(16, 24, 40, .08);
  --bg: #f2f4f7;
  --line-soft: #e6e9ee;
  --blue: #00b2b2;
  --blue-dark: #009494;
  --blue-soft: #e0f6f6;
  --crm-radius-tag: .1875rem;
  --crm-radius-pill: .1875rem;
  --crm-chosen: var(--crm-hue-slate-solid);
  --crm-card-ruled: 1;
  --crm-pad-x: var(--sp-5);
  --crm-pad-y: var(--sp-4);
  --crm-row-y: var(--sp-4);
  --crm-nav-bg: #2b3a4a;
  --crm-nav-ink: #ffffff;
  --crm-nav-muted: #c9d3de;
  --crm-nav-hover: #354759;
  --crm-nav-active: #007c80;
  --crm-nav-line: #3d4e61;
  --crm-nav-field: #354759;
  --crm-panel-r: 0rem;
  --crm-top-bg: var(--surface);
  --crm-top-ink: var(--ink);
  --crm-top-muted: var(--muted);
  --crm-top-field: var(--surface);
  --crm-top-line: var(--line-strong);
  --crm-top-edge: var(--line);
  /* the actions of admins in plum next to the teal of what acts: ink 8.7:1 on the surface, 7.4:1 on its soft field */
  --crm-admin: #6b21a8;
  --crm-admin-soft: #f3e8ff;
}
html[data-crm-theme="dealleader"][data-theme="dark"] {
  --sh: 0 .125rem .5rem rgba(0, 0, 0, .5);
  --bg: #0e1318;
  --line-soft: rgba(255, 255, 255, .06);
  --blue: #00b2b2;
  --blue-dark: #009494;
  --blue-soft: rgba(0, 178, 178, .22);
  --crm-info-ink: #7fdadc;
  --crm-nav-bg: #1a2430;
  --crm-nav-ink: #e8edf3;
  --crm-nav-muted: #a7b4c3;
  --crm-nav-hover: #243142;
  --crm-nav-active: #0d7377;
  --crm-nav-line: #2b3949;
  --crm-nav-field: #243142;
  --crm-admin: #d8b4fe;
  --crm-admin-soft: rgba(168, 85, 247, .22);
}
/* The rail of Dealleader, from a tablet up: narrow, the label under its icon, the active item a block from edge to edge. A phone keeps
   the drawer with its items in a row (the shape tokens of :root), in the colours of the theme. */
@media (width >= 48rem) {
  html[data-crm-theme="dealleader"] {
    --crm-nav-w: 7.5rem;
    --crm-nav-pad: 0rem;
    --crm-nav-dir: column;
    --crm-nav-gap: var(--sp-1);
    --crm-nav-item-h: 4.25rem;
    --crm-nav-item-pad: var(--sp-3) var(--sp-1);
    --crm-nav-fs: var(--fs-xs);
    --crm-nav-align: center;
    --crm-nav-justify: center;
    --crm-nav-chevron: none;
    --crm-nav-brand-fs: var(--fs-sm);
    --crm-nav-brand-pad: var(--sp-4) var(--sp-1);
    --crm-nav-brand-text: none;
  }
}

/* A denser part of a page (a table, a side panel, a card): the same tokens, one step tighter. */
.crm [data-density="compact"] {
  --crm-pad-x: var(--sp-5);
  --crm-pad-y: var(--sp-3);
  --crm-gap: var(--sp-4);
  --crm-row-y: var(--sp-2);
  --crm-cell-x: var(--sp-3);
  --crm-av-sm: 1.5rem;
}

/* A finger instead of a mouse: a touch area of 2.75rem, taller controls, and fields at 1.125rem (16.2px at the 90 % root). */
@media (pointer: coarse) {
  :root { --crm-hit: 2.75rem; --crm-ctl-h: 2.5rem; --crm-fs-input: 1.125rem; }
}
/* A phone (under 48rem; after the coarse pointer, so it wins there): a card gives some of its padding to what is in it (these were two
   lines for crm-card-head and crm-card-body in the phone block of app.css); a field is 1rem, 16px at the root of 100 % of a phone
   (Marley 12-11-2026), the least size at which iOS does not zoom in; the content keeps room for the dock and its safe area. */
@media (width < 48rem) {
  :root { --crm-pad-x: var(--sp-5); --crm-pad-y: var(--sp-4); --crm-fs-input: 1rem; --crm-foot-clear: calc(var(--crm-dock-h) + env(safe-area-inset-bottom) + var(--sp-5)); }
}
@media (prefers-reduced-motion: reduce) {
  :root { --crm-dur-fast: 0s; --crm-dur: 0s; }
}
