/* =====================================================================================================
   Star Sleep Knowledge Hub: "Controlled document" theme layer (Nov 2026)
   Loaded after the built-in styles in index.html. Delete its <link> tag to return to the original look.

   Subject:  controlled SOPs for a sleep & wellness clinic. Staff need the CURRENT approved procedure,
             to read it comfortably, and to trust its revision.
   Palette:  brand navy #253568 + brand star orange #FF991D (orange only where it means something),
             deeper "night shift" navy sidebar, cool neutral canvas.
   Type:     Hanken Grotesk (the whole app, SOP text included),
             IBM Plex Mono (document-control data: SOP codes, revisions, dates).
   Signature: SOP codes as document-control labels (department notch), and a controlled-form header strip
             on every SOP page. Everything else stays quiet.
   ===================================================================================================== */

:root {
  --font: "Hanken Grotesk", "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  /* SOP text used to be Source Serif 4. It is now the app typeface - one voice across the product.
     The variable is kept so document text can still be sized and spaced apart from the UI. */
  --doc: var(--font);
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --canvas: #eceef5;  --surface: #ffffff;  --s2: #f6f7fb;  --s3: #e8ebf4;
  --ink: #131938;     --ink2: #4b5374;     --ink3: #7a83a3;  --line: #dfe2ed;  --line2: #c8cddf;
  --primary: #253568; --primary-h: #1a264d; --psoft: #e6e9f4;
  --accent: #ff991d;  --accentd: #a65800;  --asoft2: #fff0db;
  --side: #121939;    --side-ink: #dde2f5; --side-dim: #8c97c4;
  --sh1: none;
  --paper-x: 56px;
}
:root[data-theme=dark] {
  --canvas: #080c1e;  --surface: #0f1538;  --s2: #131a42;  --s3: #1a224d;
  --ink: #e9ecf8;     --ink2: #a8b0cf;     --ink3: #737d9f;  --line: #212955;  --line2: #2e3765;
  --primary: #a8b8f4; --primary-h: #c1cdf8; --psoft: rgba(168, 184, 244, .14);
  --accent: #ffa53a;  --accentd: #ffb866;  --asoft2: rgba(255, 165, 58, .14);
  --side: #060915;    --side-ink: #cfd5ee; --side-dim: #6f79a3;
  --sh1: none;
}

/* ---------- type ---------- */
body { font-family: var(--font); letter-spacing: -.003em; }
h1 { font-family: var(--font); font-weight: 760; letter-spacing: -.028em; }
.sub { font-size: 15.5px; }

/* ---------- sidebar: the night-shift navy ---------- */
.side { background: var(--side); border-right: 1px solid rgba(255, 255, 255, .06); }
.nl { text-transform: uppercase; letter-spacing: .1em; font-size: 10.5px; font-weight: 700; margin: 26px 12px 8px; }
.nv { border-radius: 7px; font-weight: 550; }
.nv.on { background: rgba(255, 255, 255, .07); color: #fff; }
.nv.on::before { background: var(--accent); }
.acct { background: rgba(255, 255, 255, .05); border-color: rgba(255, 255, 255, .08); }

/* ---------- top bar & search ---------- */
.top { background: var(--surface); }
.cmd { border-radius: 10px; background: var(--s2); }
.searchbar { border-radius: 10px; transition: border-color .15s, box-shadow .15s; }
.searchbar:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--psoft); }
.chipb { border-radius: 8px; }

/* ---------- surfaces: flat, hairline, no floating cards ---------- */
.card, .tbl { border-radius: 8px; box-shadow: none; }
.th { font-family: var(--mono); text-transform: uppercase; font-size: 11px; font-weight: 500; letter-spacing: .07em; color: var(--ink3); }
.th button, .th span { font: inherit; text-transform: inherit; letter-spacing: inherit; color: inherit; }
.trow:hover { background: var(--s2); }
.kpi b { font-weight: 760; letter-spacing: -.035em; }

/* ---------- buttons ---------- */
.btn { border-radius: 8px; font-weight: 600; }
.btn.primary { box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .18); }

/* ---------- SIGNATURE 1: SOP codes as document-control labels ---------- */
/* The coloured mark is the SOP's department (same colour as before), drawn as a notch instead of a dot. */
.cid {
  font-family: var(--mono); font-weight: 500; font-size: 12px; letter-spacing: .01em;
  gap: 7px; padding: 3px 8px 3px 6px; border: 1px solid var(--line2); border-radius: 4px; background: var(--s2);
}
.cid i { width: 3px; height: 13px; border-radius: 2px; }
.trow .cid { justify-self: start; width: max-content; }
.cid.big { font-size: 12.5px; padding: 0; border: 0; background: none; }

/* library rows: titles read like document titles */
.ct b { font-family: var(--doc); font-weight: 600; font-size: 17px; letter-spacing: -.005em; }

/* ---------- SIGNATURE 2: the SOP page as a controlled document ---------- */
.paper {
  border-radius: 6px; border: 1px solid var(--line); border-top: 3px solid var(--primary);
  box-shadow: 0 30px 60px -40px rgba(19, 25, 56, .35);
  padding-top: 0; padding-left: var(--paper-x); padding-right: var(--paper-x); overflow: hidden;
}
:root[data-theme=dark] .paper { box-shadow: none; }
.dochead {
  margin: 0 calc(-1 * var(--paper-x)) 34px; padding: 13px var(--paper-x);
  background: var(--s2); border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--ink2);
}
.dt { font-family: var(--doc); font-weight: 600; font-size: clamp(32px, 4vw, 46px); line-height: 1.08; letter-spacing: -.018em; }
.dmeta { font-size: 13.5px; }

/* the procedure itself */
.prose { font-family: var(--doc); font-size: 18px; line-height: 1.68; color: var(--ink); }
.prose h2, .prose h3 { font-family: var(--font); color: var(--ink); }
.prose h2 { font-size: 21px; font-weight: 760; letter-spacing: -.018em; }
.prose h3 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.prose strong, .prose b { font-weight: 650; }
.prose li::marker { color: var(--ink3); font-family: var(--mono); font-size: .82em; }
.prose code { font-family: var(--mono); font-size: .86em; background: var(--s3); padding: 1px 5px; border-radius: 4px; }
.prose img { border-radius: 6px; }
.prose a { text-decoration-thickness: 1px; }

@media (max-width: 1180px) { :root { --paper-x: 36px; } .paper { padding-top: 0; padding-left: var(--paper-x); padding-right: var(--paper-x); } }
@media (max-width: 640px)  { :root { --paper-x: 20px; } .paper { padding-top: 0; padding-left: var(--paper-x); padding-right: var(--paper-x); } .prose { font-size: 17.5px; } }

/* print: keep the document look, drop the strip background */
@media print { .dochead { background: none; } .paper { border-top-width: 2px; box-shadow: none; } }

/* print palette: a printed SOP is always the light document, never the dark UI.
   Both selectors are needed - a bare :root loses on specificity to :root[data-theme=dark].
   Values are the light palette above, copied verbatim. */
@media print {
  :root, :root[data-theme=dark] {
    --canvas: #ffffff;  --surface: #ffffff;  --s2: #f6f7fb;  --s3: #e8ebf4;
    --ink: #131938;     --ink2: #4b5374;     --ink3: #7a83a3;
    --line: #dfe2ed;    --line2: #c8cddf;    --accentd: #a65800;
    /* index.html sets color-scheme:dark on the dark root. That darkens the page
       canvas itself, which fills the whole sheet including the @page margins -
       body{background:#fff} cannot reach it. This is the "opaque" border. */
    color-scheme: light;
  }
  html, body { background: #fff; }
  .paper { background: #fff; }
}
