/**
 * tokens.css — TeleTCM / Swasthya Usadha Design Tokens
 *
 * Extracted from qrma-dashboard-v6.html.
 * Both the dashboard (iframe) and all shell pages reference these.
 * Do NOT edit the dashboard's :root block — edit here and keep in sync.
 *
 * Import order in pages:
 *   1. tokens.css      ← this file
 *   2. shell.css       ← nav, layout, page chrome
 *   3. components.css  ← badges, tables, cards, banners
 */

/* ─── Fonts ─────────────────────────────────────────────────────────────── */
@import url('https://api.fontshare.com/v2/css?f[]=satoshi@400,500,700&f[]=cabinet-grotesk@400,500,700,800&display=swap');

/* ─── Light theme (default) ─────────────────────────────────────────────── */
:root,
[data-theme="light"] {

  /* Typography scale — fluid clamp */
  --text-xs:   clamp(.75rem,  .7rem  + .25vw, .875rem);
  --text-sm:   clamp(.875rem, .8rem  + .35vw, 1rem);
  --text-base: clamp(1rem,    .95rem + .25vw, 1.125rem);
  --text-lg:   clamp(1.125rem,1rem   + .75vw, 1.5rem);
  --text-xl:   clamp(1.5rem,  1.2rem + 1.25vw,2.25rem);
  --text-2xl:  clamp(1.75rem, 1.4rem + 1.5vw, 2.75rem);

  /* Spacing scale */
  --sp1: .25rem;  --sp2: .5rem;   --sp3: .75rem;  --sp4: 1rem;
  --sp5: 1.25rem; --sp6: 1.5rem;  --sp8: 2rem;    --sp10: 2.5rem;
  --sp12: 3rem;   --sp16: 4rem;

  /* Not a static design token like the ones above -- JS-updated layout state. .topbar's actual
     rendered height used to be assumed fixed at 57px in three places (sidebar/session-shell
     sizing, #app's min-height in index.html) even though nothing enforced that assumption; the
     grace-period-banner's own wrapping fix (shell.css's .topbar, added alongside this) can make
     the topbar genuinely taller when it wraps to multiple lines. index.html's boot sequence
     (and the resize handler next to it) measures .topbar's real height and updates this variable
     whenever it might have changed; 57px is only the pre-measurement default. */
  --topbar-h: 57px;

  /* Surface & background */
  --bg:    #f7f6f2;
  --surf:  #f9f8f5;
  --surf2: #fbfbf9;
  --sOff:  #f3f0ec;
  --sOff2: #edeae5;

  /* Borders & dividers */
  --div: #dcd9d5;
  --brd: #d4d1ca;

  /* Text */
  --txt:  #28251d;
  --txtM: #7a7974;
  --txtF: #bab9b4;

  /* Brand — teal primary */
  --pri:   #01696f;
  --priH:  #0c4e54;
  --priHi: #cedcd8;

  /* Semantic colours */
  --ok:     #437a22;  --okHi:   #d4dfcc;
  --warn:   #964219;  --warnHi: #f5e8df;
  --err:    #a13544;  --errHi:  #f5dde1;
  --gold:   #d19900;  --goldHi: #f5efd0;
  --blue:   #006494;  --blueHi: #d0e5f0;
  --purp:   #7a39bb;  --purpHi: #e5d8f5;

  /* Border radii */
  --rsm:  .375rem;
  --rmd:  .5rem;
  --rlg:  .75rem;
  --rxl:  1rem;
  --rfull: 9999px;

  /* Shadows */
  --shsm: 0 1px  2px  oklch(.2 .01 80 / .06);
  --shmd: 0 4px  12px oklch(.2 .01 80 / .09);
  --shlg: 0 12px 32px oklch(.2 .01 80 / .13);

  /* Motion */
  --tr: 180ms cubic-bezier(.16, 1, .3, 1);

  /* Font families */
  --fD: 'Cabinet Grotesk', 'Helvetica Neue', sans-serif;
  --fB: 'Satoshi', 'Inter', sans-serif;

  /* da-vinci.js's own carousel typography -- distinct from --fD/--fB (the app shell's fonts) by
     design, not an oversight. Values match the fallback stacks already hardcoded at each call
     site, so defining them here changes nothing visually -- it only satisfies
     robots/checks/token-check.mjs, which flags a referenced token as undefined even when a
     fallback value is present. */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Zodiak', Georgia, serif;

  /* Same rationale as --font-sans/--font-serif above: cdss-pharmacodynamics.js and
     inventory-reports.js both already use var(--font-mono, monospace) for CPT codes and
     high-precision timestamps -- this just satisfies token-check.mjs without changing anything
     visually, since the value matches the fallback already hardcoded at every call site. */
  --font-mono: monospace;
}

/* ─── Dark theme ─────────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:    #171614;  --surf:  #1c1b19;  --surf2: #201f1d;
  --sOff:  #1d1c1a;  --sOff2: #22211f;
  --div:   #262523;  --brd:   #393836;

  --txt:  #cdccca;   --txtM: #797876;  --txtF: #5a5957;

  --pri:   #4f98a3;  --priH:  #227f8b;  --priHi: #313b3b;

  --ok:     #6daa45;  --okHi:   #3a4435;
  --warn:   #bb653b;  --warnHi: #3d2e22;
  --err:    #dd6974;  --errHi:  #3d2428;
  --gold:   #e8af34;  --goldHi: #3d3220;
  --blue:   #5591c7;  --blueHi: #1e3040;
  --purp:   #a86fdf;  --purpHi: #2e2040;

  --shsm: 0 1px  2px  oklch(0 0 0 / .25);
  --shmd: 0 4px  12px oklch(0 0 0 / .35);
  --shlg: 0 12px 32px oklch(0 0 0 / .45);
}

/* ─── System dark preference (when no data-theme set) ───────────────────── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg:    #171614;  --surf:  #1c1b19;  --surf2: #201f1d;
    --sOff:  #1d1c1a;  --sOff2: #22211f;
    --div:   #262523;  --brd:   #393836;
    --txt:  #cdccca;   --txtM: #797876;  --txtF: #5a5957;
    --pri:   #4f98a3;  --priH:  #227f8b;  --priHi: #313b3b;
    --ok:     #6daa45;  --okHi:   #3a4435;
    --warn:   #bb653b;  --warnHi: #3d2e22;
    --err:    #dd6974;  --errHi:  #3d2428;
    --gold:   #e8af34;  --goldHi: #3d3220;
    --blue:   #5591c7;  --blueHi: #1e3040;
    --purp:   #a86fdf;  --purpHi: #2e2040;
    --shsm: 0 1px  2px  oklch(0 0 0 / .25);
    --shmd: 0 4px  12px oklch(0 0 0 / .35);
    --shlg: 0 12px 32px oklch(0 0 0 / .45);
  }
}

/* ─── Global resets (applied to all pages using tokens) ─────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
  scroll-padding-top: var(--sp16);
}

body {
  min-height: 100dvh;
  font-family: var(--fB);
  font-size: var(--text-base);
  color: var(--txt);
  background: var(--bg);
  line-height: 1.6;
}

img  { display: block; max-width: 100%; }
h1, h2, h3, h4 { text-wrap: balance; line-height: 1.15; font-family: var(--fD); }
p, li { text-wrap: wrap; max-width: 72ch; }

button { cursor: pointer; background: none; border: none; font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--pri);
  outline-offset: 3px;
  border-radius: var(--rsm);
}

a, button, input, select {
  transition: color var(--tr), background var(--tr),
              border-color var(--tr), box-shadow var(--tr);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
