/* ============================================================
   LabInstrument — Design System
   Warm "Claude.ai"-inspired aesthetic: cream paper, terracotta
   accent, editorial type. Original UI; not a copy of any product.
   ============================================================ */


:root {
  /* accent — overridable by Tweaks (terracotta default) */
  --accent-h: 28;
  --accent-c: 0.105;
  --accent-l: 0.585;
  --accent:        oklch(var(--accent-l) var(--accent-c) var(--accent-h));
  /* capped so accent-colored words stay >= 4.5:1 on light surfaces even for the bright presets */
  --accent-strong: oklch(min(calc(var(--accent-l) - 0.08), 0.52) var(--accent-c) var(--accent-h));
  /* accent behind white text (buttons, chips, badges, initials): capped so the text stays >= 4.5:1;
     fills without text (marks, bars, charts) keep the brighter --accent */
  --accent-fill:   oklch(min(var(--accent-l), 0.55) var(--accent-c) var(--accent-h));
  /* accent as plain TEXT (links, active labels, step numbers) */
  --accent-ink:    var(--accent-strong);
  --accent-soft:   oklch(0.95 0.03 var(--accent-h));
  --accent-softer: oklch(0.972 0.018 var(--accent-h));
  --accent-ring:   oklch(var(--accent-l) var(--accent-c) var(--accent-h) / 0.28);
  --on-accent:     #fff;

  /* paper / neutrals (warm) */
  --bg:        oklch(0.953 0.008 86);
  --bg-sunk:   oklch(0.935 0.009 86);
  --surface:   oklch(0.995 0.004 86);
  --surface-2: oklch(0.978 0.006 86);
  --line:      oklch(0.855 0.012 78);
  --line-soft: oklch(0.905 0.009 80);

  --ink:       oklch(0.265 0.012 60);
  --ink-2:     oklch(0.44 0.012 65);
  /* secondary text: >= 4.5:1 on every light surface (bg, sunk, none-soft, accent-soft) */
  --ink-3:     oklch(0.48 0.012 70);
  --ink-4:     oklch(0.515 0.010 75);

  /* semantic status */
  --ok-h: 150; --ok-c: 0.07; --ok-l: 0.56;
  --ok:        oklch(var(--ok-l) var(--ok-c) var(--ok-h));
  --ok-soft:   oklch(0.95 0.035 var(--ok-h));
  --warn-h: 70; --warn:  oklch(0.66 0.11 var(--warn-h));
  --warn-soft: oklch(0.945 0.06 var(--warn-h));
  --danger-h: 28; --danger: oklch(0.585 0.16 var(--danger-h));
  --danger-soft: oklch(0.945 0.05 var(--danger-h));
  /* "in transit" blue (dispatch: ส่งแล้ว) — a neutral step, not good/bad news */
  --info-h: 252; --info: oklch(0.525 0.105 var(--info-h));
  --info-soft: oklch(0.945 0.03 var(--info-h));
  /* a status fill that carries WHITE text (badges, step dots, alert bar): deep enough for
     4.5:1 in every theme, while the plain fills above may brighten on dark surfaces */
  --ok-solid:     oklch(0.50 0.10 var(--ok-h));
  --danger-solid: oklch(0.55 0.18 var(--danger-h));
  /* status as TEXT (words, numbers, icons): the fills above are too light to
     read, these stay >= 5:1 on every surface and soft tint. Fills keep --ok etc. */
  --ok-ink:     oklch(0.42 0.09 var(--ok-h));
  --warn-ink:   oklch(0.46 0.10 var(--warn-h));
  --danger-ink: oklch(0.50 0.15 var(--danger-h));
  --info-ink:   oklch(0.45 0.10 var(--info-h));
  --none:      oklch(0.62 0.006 70);
  --none-soft: oklch(0.93 0.004 80);

  --radius:    14px;
  --radius-sm: 9px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px oklch(0.4 0.02 70 / 0.07), 0 1px 1px oklch(0.4 0.02 70 / 0.05);
  --shadow:    0 1px 3px oklch(0.4 0.02 70 / 0.09), 0 8px 24px -12px oklch(0.4 0.02 70 / 0.22);
  --shadow-lg: 0 4px 12px oklch(0.4 0.02 70 / 0.10), 0 24px 60px -20px oklch(0.4 0.02 70 / 0.32);

  /* type scale from the reader's base size (--fs, set in Tweaks 13–18px; 15 by default).
     Nothing on screen goes below 11px. New code takes sizes from here, not raw px. */
  --fs-xs:   max(11px, calc(var(--fs, 15px) * .74));   /* 11   — captions, counts, badges */
  --fs-sm:   calc(var(--fs, 15px) * .87);              /* 13   — secondary lines */
  --fs-base: var(--fs, 15px);                           /* 15   — body */
  --fs-md:   calc(var(--fs, 15px) * 1.07);             /* 16   — card titles */
  --fs-lg:   calc(var(--fs, 15px) * 1.33);             /* 20   — page titles */

  --sans: 'IBM Plex Sans Thai', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --serif: 'Newsreader', Georgia, serif;
}

[data-theme="dark"] {
  --accent-soft:   oklch(0.33 0.05 var(--accent-h));
  --accent-softer: oklch(0.28 0.035 var(--accent-h));
  --accent-l: 0.66;
  --accent-strong: oklch(calc(var(--accent-l) - 0.08) var(--accent-c) var(--accent-h));
  --accent-ink:    var(--accent);
  --accent-ring:   oklch(var(--accent-l) var(--accent-c) var(--accent-h) / 0.40);

  --bg:        oklch(0.225 0.006 70);
  --bg-sunk:   oklch(0.198 0.006 70);
  --surface:   oklch(0.262 0.007 72);
  --surface-2: oklch(0.295 0.008 74);
  --line:      oklch(0.345 0.008 72);
  --line-soft: oklch(0.31 0.007 72);

  --ink:       oklch(0.945 0.006 80);
  --ink-2:     oklch(0.80 0.008 78);
  --ink-3:     oklch(0.74 0.009 76);   /* >= 4.5:1 on every dark surface */
  --ink-4:     oklch(0.70 0.009 74);

  --ok-soft:   oklch(0.34 0.05 var(--ok-h));
  --warn-soft: oklch(0.36 0.06 var(--warn-h));
  --danger-soft: oklch(0.35 0.06 var(--danger-h));
  --info-soft: oklch(0.34 0.05 var(--info-h));
  --none-soft: oklch(0.32 0.004 75);
  /* fills for bars, rings and chart marks: the light-theme values sank to ~3.4:1 on these
     surfaces and read as grey, so dark mode gets brighter, more saturated ones */
  --ok-l: 0.70; --ok-c: 0.12;
  --warn:   oklch(0.78 0.13 var(--warn-h));
  --danger: oklch(0.68 0.17 var(--danger-h));
  --info:   oklch(0.72 0.11 var(--info-h));
  --ok-ink:     oklch(0.85 0.10 var(--ok-h));
  --warn-ink:   oklch(0.86 0.11 var(--warn-h));
  --danger-ink: oklch(0.80 0.13 var(--danger-h));
  --info-ink:   oklch(0.84 0.08 var(--info-h));

  --shadow-sm: 0 1px 2px #0006;
  --shadow:    0 2px 6px #0007, 0 12px 32px -16px #000a;
  --shadow-lg: 0 6px 20px #0008, 0 30px 70px -24px #000b;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: var(--fs, 15px);
  line-height: 1.5;
  transition: background .35s ease, color .35s ease;
}
#root { min-height: 100vh; }

::selection { background: var(--accent-soft); }

/* scrollbars */
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-thumb { background: var(--line); border: 3px solid transparent; background-clip: padding-box; border-radius: 99px; }
*::-webkit-scrollbar-thumb:hover { background: var(--ink-4); background-clip: padding-box; }

/* ---------- layout shell ---------- */
.app { display: grid; grid-template-columns: var(--rail, 252px) 1fr; min-height: 100vh; }
.app.rail-collapsed { --rail: 76px; }

.rail {
  position: sticky; top: 0; height: 100vh;
  background: var(--bg-sunk);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 18px 14px;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 4px; min-height: 40px; }
.brand-mark {
  width: 34px; height: 34px; flex: none; border-radius: 10px;
  background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center;
  box-shadow: inset 0 1px 0 #ffffff30, var(--shadow-sm);
}
.brand-name { font-weight: 600; letter-spacing: -.01em; font-size: 15.5px; line-height: 1.1; }
.brand-sub { font-size: 11px; color: var(--ink-3); letter-spacing: .02em; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 18px; flex: 1; overflow-y: auto; min-height: 0; }
.nav-label { font-size: var(--fs-xs); font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-4); padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: 10px;
  color: var(--ink-2); font-weight: 500; font-size: 14px;
  cursor: pointer; border: none; background: none; width: 100%; text-align: left;
  position: relative; transition: background .14s, color .14s;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
[data-theme="dark"] .nav-item.active { color: var(--ink); }
.nav-item .ico { flex: none; }
.nav-item .badge-count {
  margin-left: auto; font-size: 11px; font-weight: 600; font-family: var(--mono);
  background: var(--danger-solid); color: #fff; border-radius: 99px; padding: 1px 7px; min-width: 20px; text-align: center;
}
.rail-collapsed .nav-item span.txt, .rail-collapsed .nav-label, .rail-collapsed .brand-text, .rail-collapsed .badge-count { display: none; }
.rail-collapsed .nav-item { justify-content: center; }

/* collapsible department sub-menu */
/* the caret is a separate button laid over the right end of the nav item */
.nav-item-row { display: flex; align-items: center; }
.nav-caret { flex: none; margin-left: -33px; margin-right: 9px; position: relative; z-index: 1;
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; color: var(--ink-4);
  border: none; background: none; padding: 0; cursor: pointer; font: inherit; }
.nav-caret:hover { background: var(--line-soft); color: var(--ink-2); }
.rail-collapsed .nav-caret { display: none; }
.nav-sub { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 4px; padding-left: 6px; }
.nav-subitem {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 7px 10px 7px 16px; border: none; background: none; cursor: pointer; font-family: inherit;
  font-size: 13px; font-weight: 500; color: var(--ink-3); border-radius: 8px; position: relative;
  transition: background .12s, color .12s;
}
.nav-subitem::before { content: ""; position: absolute; left: 6px; top: 0; bottom: 0; width: 1.5px; background: var(--line); }
.nav-subitem:hover { background: var(--surface-2); color: var(--ink); }
.nav-subitem.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.nav-subitem.active::before { background: var(--accent); }
.nav-subitem .dept-dot { flex: none; }
.nav-subitem .txt { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-subcount { font-size: 11px; color: var(--ink-4); font-weight: 600; }
.nav-subitem.active .nav-subcount { color: var(--accent-strong); }
.rail-collapsed .nav-sub { display: none; }

/* topbar notification bell */
.topbell { position: relative; }
.topbell-dot {
  position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 99px; background: var(--accent-fill); color: #fff; font-size: var(--fs-xs); font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--bg); line-height: 1;
}

.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding-top: 12px; }

/* main column */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 15;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 30px;
  background: oklch(from var(--bg) l c h / 0.82);
  backdrop-filter: blur(12px) saturate(1.4);
  border-bottom: 1px solid var(--line-soft);
}
.page-title { font-size: 20px; font-weight: 600; letter-spacing: -.015em; margin: 0; }
/* card / section titles are real headings now — they keep the look they had as divs */
.sec-title { margin: 0; font-family: inherit; line-height: inherit; color: inherit; }

/* keyboard focus on the things pressable() makes reachable (buttons get the browser's own) */
[role="button"]:focus-visible, [role="checkbox"]:focus-visible, .nav-caret:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
tr[tabindex]:focus-visible, td[tabindex]:focus-visible, th[tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.page-sub { font-size: 12.5px; color: var(--ink-3); margin-top: 1px; }
.content { padding: 28px 30px 64px; max-width: 1320px; width: 100%; margin: 0 auto; }

/* data-load error banner: GAS mode failed to load real data (see app.jsx
   `dataUnavailable`) — sticky at the very top of the page, always visible
   while scrolling. z-index deliberately higher than .rail (20) / .topbar (15)
   so once scrolled it simply paints over their top edge instead of both
   clamping to the same y:0 and fighting for the same pixels. */
.data-err-banner {
  position: sticky; top: 0; z-index: 25;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 20px;
  background: var(--danger-solid); color: #fff;
  font-size: 13px; font-weight: 500; line-height: 1.4;
}
.data-err-banner .deb-msg { flex: 1 1 220px; min-width: 0; }
.data-err-banner .btn { flex: none; background: #fff; color: var(--danger-solid); border-color: transparent; }   /* -ink turns light in dark mode; the button stays white */
.data-err-banner .btn:hover { background: #fff; opacity: .88; }
@media (max-width: 900px) {
  .data-err-banner { padding: 9px 14px; font-size: 12.5px; }
}

/* ---------- primitives ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px 22px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  font-family: inherit; font-size: 14px; font-weight: 600; letter-spacing: -.005em;
  padding: 9px 15px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer;
  transition: background .14s, border-color .14s, transform .08s, box-shadow .14s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-4); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent-fill); border-color: transparent; color: var(--on-accent); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: color-mix(in oklab, var(--accent-fill) 86%, #000); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-icon { padding: 8px; border-radius: 9px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 500; padding: 4px 10px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  cursor: pointer; transition: all .14s; white-space: nowrap; font-family: inherit;
}
.chip:hover { border-color: var(--ink-4); color: var(--ink); }
.chip.on { background: var(--accent-fill); border-color: transparent; color: var(--on-accent); }

/* status pill */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 3px 9px 3px 8px; border-radius: 99px;
  white-space: nowrap; letter-spacing: -.005em;
}
.pill .dot { width: 7px; height: 7px; border-radius: 99px; background: currentColor; flex: none; }
.pill.ok     { background: var(--ok-soft);     color: var(--ok-ink); }
.pill.warn   { background: var(--warn-soft);   color: var(--warn-ink); }
.pill.danger { background: var(--danger-soft); color: var(--danger-ink); }
.pill.none   { background: var(--none-soft);   color: var(--ink-3); }

/* mono code token */
.code {
  font-family: var(--mono); font-size: .92em; letter-spacing: -.01em;
  font-weight: 500; color: var(--ink);
}
.kbd-code {
  font-family: var(--mono); font-weight: 600; font-size: 13px;
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 2px 7px; border-radius: 7px; color: var(--ink);
  display: inline-flex; gap: 1px;
}

.field-label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; display: block; letter-spacing: -.005em; }
.input, .select {
  width: 100%; font-family: inherit; font-size: 14px; color: var(--ink);
  background: var(--surface-2); border: 1px solid color-mix(in oklch, var(--line), var(--ink) 18%); border-radius: 10px;
  padding: 9px 12px; transition: border-color .14s, box-shadow .14s, background .14s; outline: none;
}
.input:hover, .select:hover { border-color: color-mix(in oklch, var(--line), var(--ink) 32%); }
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.input::placeholder { color: var(--ink-4); }

/* search */
.search { position: relative; display: flex; align-items: center; }
.search .ico { position: absolute; left: 12px; color: var(--ink-4); pointer-events: none; }
.search input {
  font-family: inherit; font-size: 14px; color: var(--ink); width: 100%;
  background: var(--surface-2); border: 1px solid color-mix(in oklch, var(--line), var(--ink) 18%); border-radius: 11px;
  padding: 9px 12px 9px 36px; outline: none; transition: border-color .14s, box-shadow .14s;
}
.search input:hover { border-color: color-mix(in oklch, var(--line), var(--ink) 32%); }
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

/* table */
.tbl-wrap { overflow-x: auto; border-radius: var(--radius); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl thead th {
  text-align: left; font-weight: 600; font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-3); padding: 11px 14px; border-bottom: 1px solid var(--line);
  background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; cursor: pointer; user-select: none;
}
.tbl thead th:hover { color: var(--ink); }
.tbl tbody td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl tbody tr { cursor: pointer; transition: background .12s; }
.tbl tbody tr:hover { background: var(--accent-softer); }
.tbl tbody tr:last-child td { border-bottom: none; }

/* dept color dot */
.dept-dot { width: 9px; height: 9px; border-radius: 3px; flex: none; display: inline-block; }

/* stat figure */
.figure { font-family: var(--serif); font-weight: 500; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

/* progress bar */
.bar { height: 7px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; transition: width .6s cubic-bezier(.2,.7,.2,1); }

.divider { height: 1px; background: var(--line-soft); border: none; margin: 0; }

.muted { color: var(--ink-3); }
.tnum { font-variant-numeric: tabular-nums; }

/* fade/slide entrance */
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.enter { animation: pop .4s cubic-bezier(.2,.7,.2,1) both; }
/* modals are centered with transform: translate(...) — animate opacity only so
   the centering isn't clobbered (which pushed modals off-screen on mobile) */
@keyframes modalfade { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* drawer / modal */
.scrim { position: fixed; inset: 0; background: oklch(0.2 0.01 70 / 0.42); backdrop-filter: blur(2px); z-index: 50; animation: fade .2s ease both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(560px, 94vw);
  background: var(--bg); border-left: 1px solid var(--line); box-shadow: var(--shadow-lg);
  z-index: 51; display: flex; flex-direction: column; animation: slidein .32s cubic-bezier(.2,.7,.2,1) both;
}
@keyframes slidein { from { transform: translateX(40px); opacity: .4; } to { transform: none; opacity: 1; } }

/* segmented control */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  font-family: inherit; font-size: 13px; font-weight: 600; color: var(--ink-3);
  border: none; background: none; padding: 6px 13px; border-radius: 7px; cursor: pointer; transition: all .14s;
}
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

.rail-toggle { display: none !important; }

/* dropdown menu item */
.menu-item {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  padding: 9px 10px; border-radius: 9px; border: none; background: none; cursor: pointer;
  font-family: inherit; color: var(--ink); transition: background .12s;
}
.menu-item:hover { background: var(--surface-2); }
.doc-row:hover { border-color: var(--accent) !important; background: var(--accent-softer) !important; }

/* toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 9px; z-index: 80;
  background: var(--ink); color: var(--bg); font-size: 13.5px; font-weight: 600;
  padding: 11px 18px; border-radius: 12px; box-shadow: var(--shadow-lg);
}

/* ---------- print report ---------- */
#print-area { display: none; }
@media print {
  /* the developer credit is screen chrome — temp/repair modes print the whole .content,
     and those sheets are ISO-controlled forms, so it never goes to paper */
  .credit { display: none !important; }
  /* so is the phone nav: a printed page is narrower than its 900px breakpoint */
  .bottombar { display: none !important; }
  /* the phone rules' overflow-x makes a long document scroll, and its scrollbar gutter cuts the right edge */
  html, body { overflow: visible !important; }
  /* the system's own print modes stay white in every theme, also with "background graphics" on
     (not a plain Ctrl+P of an app page: its text keeps the theme's ink and needs its own backdrop) */
  body.printing, body.printing-label, body.printing-temp, body.printing-repair { background: #fff !important; }
  /* hide the entire app (display:none removes layout height → no blank pages) */
  body.printing > #root, body.printing .app { display: none !important; }
  body.printing #print-area, body.printing #print-area * { visibility: visible !important; }
  /* scope to body.printing — otherwise #print-area's stale report content would
     force itself visible on top of temp/repair/label prints (different modes) */
  body.printing #print-area {
    display: block !important; position: static; width: 100%;
    padding: 10mm; color: #1a1714; font-family: 'IBM Plex Sans Thai', sans-serif;
  }
  .rpt-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #137977; padding-bottom: 10px; }
  .rpt-org { display: block; flex: none; width: 54px; height: 54px; object-fit: contain; margin-right: 12px; }
  .rpt-org + div { flex: 1; min-width: 0; }
  .rh .rpt-org, .pmp-rh .rpt-org { margin-right: 0; }   /* those two headers already have a gap */
  .rpt-title { font-size: 18px; font-weight: 700; }
  .rpt-sub { font-size: 11px; color: #666; margin-top: 3px; }
  .rpt-brand { display: flex; align-items: center; gap: 6px; flex: none; color: #137977; font-family: 'Inter', 'IBM Plex Sans Thai', sans-serif; font-size: 16px; font-weight: 600; letter-spacing: -.03em; line-height: 1; }
  .rpt-brand svg { display: block; width: 24px; height: 24px; }
  .rpt-summary { display: flex; gap: 18px; font-size: 11.5px; margin: 12px 0; }
  .rpt-summary b { font-size: 13px; }
  .rpt-tbl { width: 100%; border-collapse: collapse; font-size: 10px; }
  .rpt-tbl th { text-align: left; background: #eef3ef; padding: 6px 8px; border-bottom: 1.5px solid #ddd; font-size: 9.5px; text-transform: uppercase; letter-spacing: .03em; color: #555; }
  .rpt-tbl td { padding: 6px 8px; border-bottom: 1px solid #eee; vertical-align: top; }
  .rpt-tbl .mono { font-family: 'IBM Plex Mono', monospace; }
  .rpt-tbl .sub { color: #666; font-size: 9px; }
  .rpt-foot { margin-top: 14px; font-size: 9px; color: #666; text-align: center; }
  /* instrument label */
  /* instrument label — overlay is portaled to <body>, so hide the whole app */
  body.printing-label > #root, body.printing-label .app { display: none !important; }
  body.printing-label #label-print, body.printing-label #label-print * { visibility: visible !important; }
  body.printing-label #label-print { position: static !important; inset: auto !important; background: #fff; display: block; padding: 0; overflow: visible; z-index: auto; }
  body.printing-label #label-print .scrim, body.printing-label .label-toolbar { display: none !important; }
  /* standard labels flow several per A4 (no forced page break per label) */
  /* each per-sheet group is its own printed page → consistent margins on every page */
  body.printing-label .label-stack { display: block !important; padding: 0 !important; gap: 0 !important; min-height: 0 !important; }
  body.printing-label .label-pagewrap { display: flex !important; flex-wrap: wrap !important; align-content: flex-start; justify-content: center; gap: 6mm !important; padding: 8mm !important; break-after: page; }
  body.printing-label .label-pagewrap:last-child { break-after: auto; }
  body.printing-label .label-sheet { box-shadow: none !important; margin: 0 !important; }
  body.printing-label .label-page { break-inside: avoid; display: flex; justify-content: center; flex: none; }
  /* mini stickers flow many-per-page instead of one page each */
  body.printing-label .label-stack.mini { display: flex !important; flex-direction: row !important; flex-wrap: wrap !important; align-content: flex-start; gap: 4mm !important; padding: 6mm !important; justify-content: flex-start !important; }
  body.printing-label .mini-wrap { break-inside: avoid; }
  body.printing-label .mini-label { box-shadow: none !important; }
  /* the screen's full-height shell plus the sheet's top margin overflowed onto a blank page 2 */
  body.printing-temp #root, body.printing-temp .app, body.printing-repair #root, body.printing-repair .app { min-height: 0 !important; }
  /* temperature log */
  body.printing-temp .rail, body.printing-temp .topbar, body.printing-temp .tl-noprint, body.printing-temp .scrim, body.printing-temp .drawer { display: none !important; }
  body.printing-temp .app { display: block !important; position: static !important; }
  body.printing-temp .main, body.printing-temp .content, body.printing-temp .tl-sheetwrap { display: block !important; position: static !important; max-width: none !important; width: auto !important; margin: 0 !important; padding: 0 !important; overflow: visible !important; }
  body.printing-temp .temp-sheet { zoom: 0.72; margin: 6mm auto !important; box-shadow: none !important; border: 2px solid #111 !important; }
  body.printing-temp .tl-printonly { display: block !important; break-inside: avoid; margin-top: 2mm; padding: 0 6mm 3mm; }
  body.printing-temp .tl-printgraph svg { max-width: 680px; margin: 0 auto; }
  /* auditor accounts render these inputs disabled — keep the printed FM-CL-00-045
     form legible (not browser's grayed-out disabled text) */
  body.printing-temp .ts-meta input, body.printing-temp table.tl-grid input, body.printing-temp table.tl-corr input { color: #111 !important; opacity: 1 !important; }
  body.printing-temp table.tl-grid td.held input, body.printing-temp table.tl-corr td.held input { visibility: hidden !important; }
  body.printing-temp table.tl-grid td.held, body.printing-temp table.tl-corr td.held { outline: none; }
  /* a field shows one line and scrolls; paper can't, so the text itself goes on the form */
  body.printing-temp table.tl-corr input { display: none !important; }
  body.printing-temp .tl-corr-print { display: block !important; min-height: 23px; padding: 2px 1px; color: #111; line-height: 19px; white-space: pre-wrap; overflow-wrap: anywhere; }
  body.printing-temp table.tl-corr tr { break-inside: avoid; }
  /* margin 0 → the browser has no room to draw its date/title/URL header & footer,
     so they disappear on every print. Each mode keeps its own inner padding below. */
  @page { size: A4 landscape; margin: 0; }
  /* repair / maintenance log */
  body.printing-repair .rail, body.printing-repair .topbar, body.printing-repair .tl-noprint, body.printing-repair .rp-del, body.printing-repair .scrim, body.printing-repair .drawer { display: none !important; }
  body.printing-repair .app { display: block !important; position: static !important; }
  body.printing-repair .main, body.printing-repair .content, body.printing-repair .tl-sheetwrap { display: block !important; position: static !important; max-width: none !important; width: auto !important; margin: 0 !important; padding: 0 !important; overflow: visible !important; }
  body.printing-repair .repair-sheet { zoom: 0.78; margin: 8mm auto !important; box-shadow: none !important; border: 2px solid #111 !important; }
  body.printing-repair .rp-date, body.printing-repair .rp-status, body.printing-repair .rp-stcol .pill { display: none !important; }
  body.printing-repair .rp-date-print, body.printing-repair .rp-status-print { display: inline !important; font-size: 11.5px; padding: 4px 6px; }
  body.printing-repair table.rp-tbl textarea, body.printing-repair table.rp-tbl input { display: none !important; }
  body.printing-repair .rp-text-print { display: block !important; min-height: 34px; padding: 4px 6px; color: #111; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
  body.printing-repair table.rp-tbl tr { break-inside: avoid; }
  /* a long form: whole sheets made as printing starts (repair.jsx) */
  body.rp-paged #root { display: none !important; }
  body.rp-paged .rp-print-pages { display: block !important; }
  .rp-print-pages .repair-sheet + .repair-sheet { break-before: page; }
}

/* ============================================================
   INSTRUMENT LABEL (FR-QP-0012 — ISO 15189)
   ============================================================ */
#label-print { position: fixed; inset: 0; z-index: 70; overflow: auto; }
.label-stack { display: flex; flex-direction: column; align-items: center; gap: 30px; padding: 30px 28px 60px; min-height: 100%; }
.label-pagewrap { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: center; gap: 18px; }
.label-page { display: flex; justify-content: center; }
.label-toolbar { position: fixed; top: 18px; right: 22px; z-index: 72; display: flex; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; box-shadow: var(--shadow); }
.label-sheet {
  width: 1040px; background: #fff; color: #111; border: 2px solid #111; zoom: var(--lblz, 1);
  font-family: 'IBM Plex Sans Thai', sans-serif; box-shadow: var(--shadow-lg); position: relative; flex: none;
}
.lbl-logo-img { width: 158px; height: auto; display: block; }
.label-sheet * { box-sizing: border-box; }
.lbl-head { display: grid; grid-template-columns: 200px 1fr 300px; border-bottom: 2px solid #111; }
.lbl-logo { border-right: 2px solid #111; padding: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; }
.lbl-logo .emblem { width: 62px; height: 62px; }
.lbl-logo .hn { font-size: 11px; font-weight: 700; color: #1a6b2f; line-height: 1.2; }
.lbl-logo .hn small { display: block; font-size: 8.5px; color: #555; font-weight: 500; letter-spacing: .5px; }
.lbl-title-c { border-right: 2px solid #111; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 14px; text-align: center; gap: 3px; line-height: 1.3; }
.lbl-title-c b { font-size: 21px; font-weight: 700; }
.lbl-title-c span { font-size: 19px; font-weight: 700; }
.lbl-doc { padding: 10px 14px; display: flex; flex-direction: column; justify-content: center; gap: 8px; font-size: 14px; }
.lbl-doc .dl { border-bottom: 1px solid #bbb; padding-bottom: 6px; }
.lbl-doc .dl:last-child { border-bottom: 0; }
.lbl-band { text-align: center; padding: 12px; background: #ededed; border-bottom: 2px solid #111; font-size: 25px; font-weight: 700; }
.lbl-body { display: grid; grid-template-columns: 1fr 360px; }
.lbl-fields { padding: 22px 26px; display: flex; flex-direction: column; gap: 17px; }
.lbl-fields .fr { font-size: 18px; line-height: 1.35; }
.lbl-fields .fr b { font-weight: 700; }
.lbl-fields .fr .val { font-weight: 400; }
.lbl-fields .fr .code { font-family: var(--mono); font-weight: 700; letter-spacing: .3px; color: #111; }   /* .code follows the theme's ink; this sheet is always white paper */
.lbl-qr { border-left: 1px dashed #999; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 22px; }
.lbl-qr .cap { font-family: var(--mono); font-weight: 700; font-size: 17px; letter-spacing: .5px; }
.lbl-foot { border-top: 2px solid #111; text-align: center; padding: 9px; font-size: 12.5px; font-style: italic; color: #555; }

/* guest (read-only) top bar — responsive for phones */
.guest-bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 20; }
.guest-bar .gb-mark { width: 34px; height: 34px; flex: none; border-radius: 9px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; }
.guest-bar .gb-brand { display: flex; align-items: center; gap: 10px; flex: 1 1 auto; min-width: 0; }
.guest-bar .gb-title { font-weight: 600; font-size: 14.5px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.guest-bar .gb-sub { font-size: 11px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.guest-bar .gb-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.guest-bar .gb-ro { white-space: nowrap; font-size: 11px; }
.guest-main { max-width: 1120px; margin: 0 auto; padding: 20px 18px 60px; }
@media (max-width: 560px) {
  .guest-bar { gap: 8px; padding: 8px 12px; }
  .guest-bar .gb-sub { display: none; }
  .guest-bar .gb-ro-text { display: none; }
  .guest-bar .gb-login-text { display: none; }
  .guest-main { padding: 14px 12px 50px; }
}
@media (max-width: 360px) {
  .guest-bar .gb-ro { display: none; }
}

/* mini sticker (small instruments) */
.label-stack.mini { flex-direction: row; flex-wrap: wrap; align-items: flex-start; justify-content: center; gap: 12px; padding: 28px 24px 60px; }
.mini-wrap { flex: none; }
.mini-label {
  zoom: var(--lblz, 1);
  width: 250px; min-height: 116px; box-sizing: border-box;
  background: #fff; color: #111; border: 1.5px solid #111; border-radius: 9px;
  display: flex; align-items: center; gap: 11px; padding: 11px 13px;
  font-family: 'IBM Plex Sans Thai', sans-serif; box-shadow: var(--shadow-sm);
}
.mini-label * { box-sizing: border-box; }
.mini-label .mini-qr { flex: none; }
.mini-label .mini-info { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.mini-label .mini-code { font-family: var(--mono); font-weight: 700; font-size: 14.5px; letter-spacing: .3px; }
.mini-label .mini-name { font-size: 12px; font-weight: 600; line-height: 1.2; height: 30px; overflow: hidden; word-break: break-word; }
.mini-label .mini-due { font-size: 10.5px; color: #555; }
.mini-label .mini-due b { font-weight: 700; color: #111; }
.lbl-logo { gap: 8px; }
.sel-check { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* ============================================================
   TEMPERATURE LOG (FM-CL-00-045)
   ============================================================ */
.tl-bar { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 18px; }
.tl-bar .fld { display: flex; flex-direction: column; gap: 5px; }
.tl-bar label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.tl-sheetwrap { overflow-x: auto; }
.tl-printonly { display: none; }   /* shown only when printing the temp form */
.temp-sheet { width: 1180px; background: #fff; color: #111; border: 2px solid #111; font-family: 'IBM Plex Sans Thai', sans-serif; box-shadow: var(--shadow); margin: 0 auto; }
.temp-sheet .lbl-doc { font-size: 12px; }
.temp-sheet .lbl-head { grid-template-columns: 150px 1fr 280px; }
.temp-sheet .lbl-logo { padding: 6px; gap: 4px; }
.temp-sheet .lbl-logo-img { width: 84px; }
.temp-sheet .lbl-logo .hn { font-size: 9px; }
.temp-sheet .lbl-title-c { padding: 8px 10px; gap: 2px; }
.temp-sheet .lbl-title-c b { font-size: 16px; }
.temp-sheet .lbl-title-c span { font-size: 14px; }
.temp-sheet .lbl-doc { padding: 6px 12px; gap: 5px; }
.temp-sheet .lbl-doc .dl { padding-bottom: 4px; font-size: 11.5px; }
.ts-meta { padding: 12px 16px; border-bottom: 2px solid #111; font-size: 13.5px; line-height: 2; }
.ts-meta .uline { border-bottom: 1px dotted #555; padding: 0 8px; font-weight: 600; display: inline-block; min-width: 60px; text-align: center; }
.ts-meta input { border: none; border-bottom: 1px dotted #777; font-family: inherit; font-size: 13px; font-weight: 600; text-align: center; padding: 0 4px; background: transparent; color: #111; outline: none; }
.ts-meta input:focus { border-bottom-color: var(--accent); }
table.tl-grid { border-collapse: collapse; width: 100%; }
table.tl-grid th, table.tl-grid td { border: 1px solid #333; text-align: center; font-size: 11px; padding: 0; height: 26px; }
table.tl-grid thead th { background: #ededed; font-weight: 700; padding: 4px 2px; }
.tl-rowlab { background: #f5f5f5; font-weight: 600; white-space: nowrap; padding: 0 8px !important; text-align: left !important; }
.tl-sesslab { background: #e6efe6; font-weight: 700; writing-mode: vertical-rl; text-orientation: mixed; }
.tl-cell input { width: 100%; height: 24px; border: none; background: transparent; text-align: center; font-family: var(--mono); font-size: 11px; color: #111; outline: none; padding: 0; }
.tl-cell input:focus { background: color-mix(in srgb, var(--accent) 14%, #fff); }
.tl-cell.oor { background: #ffd9d4; }
.tl-cell.oor input { color: #c0271a; font-weight: 700; }
/* on this device only, not on the sheet (see the note above the form): never printed */
.tl-cell.held, table.tl-corr td.held { outline: 2px dashed var(--warn); outline-offset: -2px; }
.ts-notes { padding: 8px 16px; font-size: 11.5px; line-height: 1.55; border-bottom: 2px solid #111; }
.ts-corr { padding: 9px 16px; }
.ts-corr h4 { margin: 0 0 6px; font-size: 13px; }
table.tl-corr { border-collapse: collapse; width: 100%; }
table.tl-corr th, table.tl-corr td { border: 1px solid #333; font-size: 12px; padding: 4px 6px; }
table.tl-corr th { background: #ededed; }
.tl-corr-print { display: none; }
table.tl-corr input { width: 100%; border: none; background: transparent; font-family: inherit; font-size: 12px; outline: none; color: #111; }
/* auditor account: cursor-only lock hint (color stays #111 above so print never changes) */
.ts-meta input:disabled, .tl-cell input:disabled, table.tl-corr input:disabled { cursor: not-allowed; }
.ts-review { padding: 9px 16px; font-size: 13px; text-align: right; }
[data-skin="midnight"] .temp-sheet, [data-skin="midnight"] .label-sheet { color: #111; }

/* ---------- repair / maintenance log ---------- */
.rp-queue { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.rp-queue-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rp-queue-empty { display: flex; align-items: center; gap: 8px; color: var(--ok-ink); font-size: 13.5px; font-weight: 600; margin-top: 12px; }
.rp-queue-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.rp-chip { display: flex; align-items: center; gap: 9px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; padding: 8px 12px; cursor: pointer; font-family: inherit; transition: border-color .14s, background .14s; max-width: 360px; }
.rp-chip:hover { border-color: var(--accent); }
.rp-chip.on { border-color: var(--accent); background: var(--accent-soft); }
.rp-chip-name { font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.rp-chip-code { font-size: 11.5px; color: var(--ink-3); }

.repair-sheet { width: 1180px; background: #fff; color: #111; border: 2px solid #111; font-family: 'IBM Plex Sans Thai', sans-serif; box-shadow: var(--shadow); margin: 0 auto; }
.repair-sheet .lbl-doc { font-size: 12px; }
.repair-sheet .lbl-head { grid-template-columns: 150px 1fr 280px; }
.repair-sheet .lbl-logo { padding: 6px; gap: 4px; }
.repair-sheet .lbl-logo-img { width: 77px; }
.repair-sheet .lbl-doc { padding: 6px 12px; gap: 5px; }
.repair-sheet .lbl-doc .dl { padding-bottom: 4px; font-size: 11.5px; }
.rp-band { text-align: center; font-weight: 700; font-size: 16px; padding: 9px; border-bottom: 2px solid #111; background: #f3f3f3; }
.rp-id { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 2px solid #111; }
.rp-id-row { display: flex; gap: 8px; padding: 7px 16px; align-items: baseline; }
.rp-id-row:nth-child(odd) { border-right: 1px solid #bbb; }
.rp-id-k { font-weight: 700; font-size: 12.5px; white-space: nowrap; }
.rp-id-v { font-size: 12.5px; color: #222; }
.rp-id-v.code { font-weight: 600; }
table.rp-tbl { border-collapse: collapse; width: 100%; table-layout: fixed; }
table.rp-tbl th, table.rp-tbl td { border: 1px solid #333; font-size: 12px; padding: 0; vertical-align: top; }
table.rp-tbl th { background: #ededed; font-weight: 700; padding: 5px 4px; text-align: center; }
table.rp-tbl td { padding: 2px; }
.rp-c-num { text-align: center; vertical-align: middle; font-weight: 600; }
table.rp-tbl textarea, table.rp-tbl input { width: 100%; border: none; background: transparent; font-family: inherit; font-size: 12px; color: #111; outline: none; resize: none; padding: 4px 6px; line-height: 1.4; overflow: hidden; min-height: 34px; }
table.rp-tbl input { min-height: 0; }
table.rp-tbl textarea:focus, table.rp-tbl input:focus { background: color-mix(in srgb, var(--accent) 12%, #fff); }
/* auditor account: cursor-only lock hint (color forced #111 in print rules above regardless) */
table.rp-tbl textarea:disabled, table.rp-tbl input:disabled { cursor: not-allowed; }
.rp-date { font-family: var(--mono); font-size: 11px !important; }
.rp-date-print, .rp-status-print, .rp-text-print { display: none; }
.rp-print-pages { display: none; }
/* paper's layout, for the moment repair.jsx measures a long form (the same as the print rules) */
body.rp-measure .repair-sheet .tl-noprint, body.rp-measure .rp-date, body.rp-measure .rp-status, body.rp-measure .rp-stcol .pill { display: none !important; }
body.rp-measure .rp-date-print, body.rp-measure .rp-status-print { display: inline !important; font-size: 11.5px; padding: 4px 6px; }
body.rp-measure table.rp-tbl textarea, body.rp-measure table.rp-tbl input { display: none !important; }
body.rp-measure .rp-text-print { display: block !important; min-height: 34px; padding: 4px 6px; color: #111; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.rp-stcol { position: relative; }
.rp-status { width: 100%; border: none; background: transparent; font-family: inherit; font-size: 11.5px; font-weight: 700; padding: 6px 4px; outline: none; cursor: pointer; -webkit-appearance: none; appearance: none; text-align: center; }
.rp-status-warn { color: #8a700e; }
.rp-status-danger { color: #c0271a; }
.rp-status-ok { color: #1c8054; }
.rp-del { position: absolute; top: 2px; right: 2px; width: 19px; height: 19px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 5px; color: var(--ink-3); cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 1; }
.rp-del:hover { background: var(--danger-soft); color: var(--danger-ink); border-color: var(--danger); }

/* on-screen the status select looks like a clickable colored pill; its text colors are for
   this always-white form, so the background stays white in every theme */
.rp-status { border: 1px solid var(--line) !important; border-radius: 7px; background:
  #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23999' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 7px center !important;
  padding-right: 20px !important; }
.rp-status:hover { border-color: var(--ink-4) !important; }

/* repair workflow stepper */
.rp-flow { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px 16px; margin-bottom: 14px; }
.rp-flow-title { font-size: 12.5px; font-weight: 700; color: var(--ink-2); margin-bottom: 12px; }
.rp-flow-steps { display: flex; align-items: center; gap: 4px; }
.rp-step { display: flex; align-items: center; gap: 10px; flex: none; }
.rp-step-dot { width: 36px; height: 36px; border-radius: 99px; display: grid; place-items: center; flex: none; border: 2px solid var(--line); background: var(--surface-2); color: var(--ink-4); transition: all .2s; }
.rp-step-tx { display: flex; flex-direction: column; line-height: 1.25; }
.rp-step-tx b { font-size: 13px; color: var(--ink-3); white-space: nowrap; }
.rp-step-tx span { font-size: 11px; color: var(--ink-4); white-space: nowrap; }
.rp-step-bar { flex: 1; height: 3px; border-radius: 99px; background: var(--line); min-width: 24px; }
.rp-step-bar.done { background: var(--ok); }
.rp-step.current .rp-step-dot { border-color: var(--accent-fill); background: var(--accent-fill); color: var(--on-accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.rp-step.current .rp-step-tx b { color: var(--ink); }
.rp-step.done .rp-step-dot { border-color: var(--ok-solid); background: var(--ok-solid); color: #fff; }
.rp-step.done .rp-step-tx b { color: var(--ink-2); }
/* phones: three steps side by side need ~500px — stack them, the bar turns into a short
   vertical link under each dot (after the rules above, so it wins without !important) */
@media (max-width: 640px) {
  .rp-flow-steps { flex-direction: column; align-items: stretch; gap: 0; }
  .rp-step-bar { flex: none; width: 3px; min-width: 0; height: 12px; margin: 3px 0 3px 16.5px; }
}

.rp-hint { display: flex; align-items: flex-start; gap: 9px; background: var(--accent-softer); border: 1px solid var(--accent-soft); border-radius: 11px; padding: 10px 14px; margin-bottom: 14px; font-size: 12.5px; color: var(--ink-2); line-height: 1.55; }
.rp-hint > svg { color: var(--accent); flex: none; margin-top: 2px; }
.rp-hint-warn { color: var(--warn-ink); } .rp-hint-danger { color: var(--danger-ink); } .rp-hint-ok { color: var(--ok-ink); }

/* responsive */
@media (max-width: 1040px) {
  .topbar-search { display: none !important; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  /* stop any stray wide child from triggering iOS shrink-to-fit zoom */
  html, body { overflow-x: hidden; }
  /* pad the drawer bottom so the fixed bottom bar (z-30) never hides the last
     nav items (e.g. จัดการผู้ใช้ in admin mode); .nav still scrolls above it */
  .rail { position: fixed; left: 0; transform: translateX(-100%); transition: transform .3s; width: 252px;
    padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  .app.rail-open .rail { transform: none; }
  .content { padding: 20px 18px 60px; overflow-x: hidden; }
  .topbar { padding: 12px 16px; gap: 8px; }
  /* hamburger removed on mobile — the bottom bar "เมนู" opens the drawer instead */
  .rail-toggle { display: none !important; }
  .add-label { display: none; }
  /* tidy, single-line title; drop the verbose subtitle so the top bar stays clean */
  .topbar .page-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 18px; }
  .topbar .page-sub { display: none; }
  /* add-instrument wizard: single column + non-sticky rail, form first.
     !important is required — .wiz/.wiz-rail are (re)defined LATER in the file
     (line ~834) so an equal-specificity media rule here would otherwise lose
     the source-order tie-break and the desktop 2-column layout would win. */
  .wiz { grid-template-columns: 1fr !important; }
  .wiz-rail { position: static !important; top: auto !important; order: 2; }
  .wmain { order: 1; min-width: 0; }
  /* two-column inner grids stack (!important defeats the inline 1fr 1fr) */
  .grid2, .dash-grid { grid-template-columns: 1fr !important; }
  /* wide data tables (user management, etc.) scroll inside their card instead
     of pushing the whole page wider than the viewport */
  .tbl { display: block; overflow-x: auto; white-space: nowrap; }
  /* while the drawer is open, hide the bottom bar so it can't cover the last
     nav items (จัดการผู้ใช้); the scrim tap still closes the drawer */
  .app.rail-open .bottombar { display: none !important; }
}

/* ---------- mobile bottom navigation bar (phones/tablets, ≤900px) ---------- */
.bottombar { display: none; }
@media (max-width: 900px) {
  .bottombar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 5px 4px calc(5px + env(safe-area-inset-bottom));
    box-shadow: 0 -3px 14px rgba(0, 0, 0, .07);
  }
  .bb-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    background: none; border: none; padding: 4px 2px; color: var(--ink-3); cursor: pointer;
    font-family: inherit; -webkit-tap-highlight-color: transparent; }
  .bb-item.active { color: var(--accent-ink); }
  .bb-ico { position: relative; display: grid; place-items: center; }
  .bb-lbl { font-size: var(--fs-xs); font-weight: 600; line-height: 1; }
  .bb-badge { position: absolute; top: -6px; right: -10px; min-width: 17px; height: 17px; padding: 0 4px;
    border-radius: 8px; background: var(--danger-solid); color: #fff; font-size: var(--fs-xs); font-weight: 700;
    display: grid; place-items: center; box-sizing: border-box; }
  /* raised center "add instrument" FAB */
  .bb-fab { flex: 1; display: flex; justify-content: center; align-items: flex-start; }
  .bb-fab > button { width: 54px; height: 54px; border-radius: 50%; background: var(--accent); color: #fff;
    border: 4px solid var(--surface); box-shadow: 0 8px 20px -6px var(--accent); transform: translateY(-18px);
    display: grid; place-items: center; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .bb-fab > button:active { transform: translateY(-16px) scale(.95); }
  .content { padding-bottom: 74px !important; }   /* clear the fixed bar */
}

/* login card icon — HPV-style centered mark on mobile */
/* centered login card (used on both desktop-over-landing and mobile) */
.auth-card-icon { display: grid; place-items: center; width: 60px; height: 60px; border-radius: 17px;
  background: var(--accent); color: #fff; margin: 0 auto 16px; box-shadow: 0 10px 28px -8px var(--accent); }
/* hospital emblem: kept on its own white tile so it reads the same in light and dark */
.auth-org-logo { display: block; width: 112px; height: auto; margin: 0 auto 14px; padding: 6px; border-radius: 16px;
  background: #fff; box-shadow: var(--shadow-sm); }
.auth-card .auth-title, .auth-card .auth-sub, .auth-card .auth-sub2 { text-align: center; }
.auth-sub2 { font-size: 11.5px; color: var(--ink-4); margin-top: 3px; line-height: 1.4; }
@media (max-width: 600px) {
  /* mobile keeps the same animated landing + floating card as desktop,
     just with tighter padding so the card fits narrow phones */
  .auth-form { padding: 18px; }
  .auth-card { padding: 28px 22px; }
}

@media (max-width: 720px) {
  .dash-grid, .detail-grid { grid-template-columns: 1fr !important; }
  .detail-grid > * { min-width: 0; }
  /* ID card must not stay sticky in single-column mobile — it overlapped content */
  .detail-grid > .card:first-child { position: static !important; top: auto !important; }
  /* two-column info grids stack to one column so long Thai text never overflows */
  .info-grid, .cal-pm-grid, .doc-grid { grid-template-columns: 1fr !important; }
  .info-row { grid-template-columns: 118px 1fr !important; }
  /* safety net: keep all detail content within the viewport width */
  .content, .guest-main { overflow-x: hidden; }
  /* wide calibration-results table scrolls inside its card instead of widening the page */
  .cal-res-tbl { display: block; overflow-x: auto; white-space: nowrap; }
}

/* ============================================================
   AUTH — login & lock screen
   ============================================================ */
.auth {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
  background: var(--bg); color: var(--ink); overflow-x: hidden; overflow-y: auto; animation: fade .35s ease both;
}
/* animated landing background — fills the whole screen behind the card
   (fixed, so it stays put when a short screen scrolls the card; no pointer events, or a
   wheel/swipe over it would scroll the page instead of .auth) */
.auth-show {
  position: fixed; inset: 0; overflow: hidden; pointer-events: none;
  background:
    radial-gradient(90% 70% at 12% 8%, color-mix(in srgb, var(--accent) 26%, transparent) 0%, transparent 55%),
    radial-gradient(80% 80% at 100% 100%, color-mix(in srgb, var(--accent) 16%, transparent) 0%, transparent 50%),
    var(--bg-sunk);
}
.auth-show::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: linear-gradient(var(--line-soft) 1px, transparent 1px), linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 38px 38px; mask-image: radial-gradient(70% 70% at 30% 30%, #000 0%, transparent 75%);
}
.auth-scan {
  content: ""; position: absolute; left: 0; right: 0; height: 140px; pointer-events: none;
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--accent) 13%, transparent), transparent);
  animation: scanline 5.5s linear infinite; opacity: .8;
}
@keyframes scanline { 0% { top: -160px; } 100% { top: 100%; } }
.auth-brand { display: flex; align-items: center; gap: 13px; position: relative; }
.auth-mark {
  width: 46px; height: 46px; border-radius: 13px; background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; box-shadow: var(--shadow), inset 0 1px 0 #ffffff30;
}
[data-skin="midnight"] .auth-mark { box-shadow: 0 0 28px color-mix(in srgb, var(--accent) 55%, transparent), inset 0 1px 0 #ffffff30; }
.auth-headline {
  font-family: var(--serif); font-size: 38px; font-weight: 600; line-height: 1.14;
  letter-spacing: -.02em; margin-top: auto; max-width: 560px;
}
.auth-tag { font-size: 14.5px; color: var(--ink-2); margin-top: 16px; max-width: 600px; line-height: 1.6; }
.auth-stats { display: flex; gap: 10px; margin-top: 26px; flex-wrap: wrap; position: relative; }
.auth-stat {
  background: color-mix(in srgb, var(--surface) 70%, transparent); border: 1px solid var(--line);
  border-radius: 13px; padding: 12px 16px; backdrop-filter: blur(6px); min-width: 92px;
}
.auth-stat .v { font-family: var(--mono); font-size: 22px; font-weight: 600; }
.auth-stat .l { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.auth-foot { margin-top: 30px; font-size: 12px; color: var(--ink-4); display: flex; gap: 14px; align-items: center; position: relative; }

/* the floating login card, centered over the animated background */
.auth-form { position: relative; z-index: 1; display: grid; place-items: center; padding: 40px; }

/* ---------- developer credit (AppCredit in shared.jsx) ---------- */
.credit-login { display: flex; flex-direction: column; align-items: center; gap: 1px; margin-top: 20px;
  text-align: center; font-size: 12px; line-height: 1.5; color: var(--ink-3); }
.credit-login .credit-label { font-size: var(--fs-xs); letter-spacing: .02em; }
.credit-login .credit-name { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.credit-app { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 24px; margin-top: 44px;
  padding-top: 16px; border-top: 1px solid var(--line-soft); font-size: 12px; line-height: 1.55; color: var(--ink-3); }
.credit-app b { font-weight: 600; color: var(--ink-2); }
.credit-app span span, .credit-login .credit-role span { white-space: nowrap; }
@media (max-width: 720px) { .credit-app { flex-direction: column; align-items: center; text-align: center; margin-top: 32px; } }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 22px; padding: 34px 30px; box-shadow: 0 26px 64px -22px rgba(0, 0, 0, .55); }
/* short screens (a 1366×768 laptop leaves ~620–660px of page): smaller emblem and tighter
   spacing so card + credit fit, or nearly; whatever is still taller scrolls (.auth overflow-y) */
@media (max-height: 760px) {
  .auth-form { padding-top: 12px; padding-bottom: 12px; }
  .auth-card { padding-top: 24px; padding-bottom: 24px; }
  .auth-org-logo { width: 76px; margin-bottom: 10px; }
  .credit-login { margin-top: 12px; }
}
.auth-title { font-size: 25px; font-weight: 600; letter-spacing: -.02em; }
.auth-sub { font-size: 13.5px; color: var(--ink-3); margin-top: 5px; }
.auth-field { margin-top: 16px; }
.auth-inputwrap { position: relative; display: flex; align-items: center; }
.auth-inputwrap > .ico { position: absolute; left: 13px; color: var(--ink-4); pointer-events: none; }
.auth-inputwrap input {
  width: 100%; font-family: inherit; font-size: 14.5px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
  padding: 12px 13px 12px 40px; outline: none; transition: border-color .14s, box-shadow .14s;
}
.auth-inputwrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.auth-eye { position: absolute; right: 8px; background: none; border: none; color: var(--ink-4); cursor: pointer; padding: 6px; border-radius: 8px; display: grid; }
.auth-eye:hover { color: var(--ink-2); background: var(--surface-2); }
.auth-row { display: flex; align-items: center; justify-content: space-between; margin-top: 15px; font-size: 13px; }
.auth-check { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); cursor: pointer; user-select: none; white-space: nowrap; }
.auth-check input { accent-color: var(--accent); width: 15px; height: 15px; }
.auth-link { color: var(--accent-ink); cursor: pointer; font-weight: 600; white-space: nowrap; }
.auth-submit {
  width: 100%; margin-top: 20px; padding: 13px; font-size: 15px; font-weight: 600;
  border: none; border-radius: 12px; background: var(--accent-fill); color: var(--on-accent);
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 9px;
  transition: filter .14s, transform .08s; box-shadow: var(--shadow-sm);
}
[data-skin="midnight"] .auth-submit { box-shadow: 0 0 26px color-mix(in srgb, var(--accent) 40%, transparent); }
.auth-submit:hover { filter: brightness(1.06); }
.auth-submit:active { transform: translateY(1px); }
.auth-or { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--ink-4); font-size: 12px; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-sso { display: flex; gap: 10px; }
.auth-sso button {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
  font-family: inherit; font-size: 13px; font-weight: 600; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 11px; cursor: pointer; transition: all .14s;
}
.auth-sso button:hover { border-color: var(--ink-4); color: var(--ink); }
.auth-demo { margin-top: 18px; font-size: 12px; color: var(--ink-3); text-align: center; background: var(--surface-2); border: 1px dashed var(--line); border-radius: 10px; padding: 9px; }
.auth-segrole { display: flex; gap: 7px; }
.auth-segrole button {
  flex: 1; font-family: inherit; font-size: 12.5px; font-weight: 600; color: var(--ink-3); line-height: 1.3;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 6px; cursor: pointer; transition: all .14s; white-space: nowrap;
}
.auth-segrole button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
[data-skin="midnight"] .auth-segrole button.on { color: var(--accent); }

/* lock screen */
.lock {
  position: fixed; inset: 0; z-index: 210; display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: blur(18px) saturate(1.2);
  animation: fade .3s ease both;
}
.lock-card { text-align: center; width: min(360px, 90vw); }
.lock-clock { font-family: var(--mono); font-size: 74px; font-weight: 600; letter-spacing: -.03em; line-height: 1; }
.lock-date { font-size: 15px; color: var(--ink-2); margin-top: 8px; }
.lock-user { display: inline-flex; align-items: center; gap: 11px; margin: 32px 0 18px; }
.lock-avatar { width: 52px; height: 52px; border-radius: 99px; background: var(--accent-fill); color: var(--on-accent); display: grid; place-items: center; font-weight: 700; font-size: 18px; box-shadow: var(--shadow); }
[data-skin="midnight"] .lock-avatar { box-shadow: 0 0 26px color-mix(in srgb, var(--accent) 50%, transparent); }

/* ============================================================
   DENSITY — global spacing modes (compact / monitor)
   ============================================================ */
[data-density="compact"] .content { padding: 18px 22px 48px; }
[data-density="compact"] .card-pad { padding: 15px 17px; }
[data-density="compact"] .topbar { padding: 10px 24px; }
[data-density="compact"] .tbl tbody td, [data-density="compact"] .tbl thead th { padding: 8px 12px; }
[data-density="compact"] .nav-item { padding: 7px 10px; }

[data-density="monitor"] .content { padding: 14px 18px 40px; max-width: none; }
[data-density="monitor"] .card-pad { padding: 12px 14px; }
[data-density="monitor"] .topbar { padding: 8px 18px; }
[data-density="monitor"] .page-title { font-size: 16px; }
[data-density="monitor"] .page-sub { font-size: 11px; }
[data-density="monitor"] .tbl { font-size: 12.5px; }
[data-density="monitor"] .tbl tbody td { padding: 6px 11px; }
[data-density="monitor"] .tbl thead th { padding: 7px 11px; font-size: var(--fs-xs); }
[data-density="monitor"] .nav-item { padding: 6px 10px; font-size: 13px; }
[data-density="monitor"] .topbar .page-title + .page-sub { display: none; }
[data-density="monitor"] .card { border-radius: 11px; }
[data-density="monitor"] .pill { font-size: 11px; padding: 2px 8px; }

/* ============================================================
   AMBIENT BACKGROUND — glow + grid + grain (borrowed from RM-LIS)
   ============================================================ */
.amb, .amb-grain { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.amb::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(900px 600px at 12% -5%, color-mix(in srgb, var(--accent) 15%, transparent), transparent 60%),
    radial-gradient(820px 700px at 100% 0%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 55%),
    radial-gradient(720px 720px at 50% 118%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 60%);
}
.amb::after {
  content: ""; position: absolute; inset: 0; opacity: .5;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: radial-gradient(ellipse 82% 60% at 50% 26%, #000 28%, transparent 80%);
  mask-image: radial-gradient(ellipse 82% 60% at 50% 26%, #000 28%, transparent 80%);
}
.amb-grain {
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
[data-skin="midnight"] .amb-grain { opacity: .05; }
.app { position: relative; z-index: 1; }
/* let ambient show through main column gaps */
.has-amb .main { background: transparent; }
.has-amb .rail { background: color-mix(in srgb, var(--bg-sunk) 86%, transparent); backdrop-filter: blur(6px); }
.has-amb .topbar { background: color-mix(in srgb, var(--bg) 72%, transparent); }

/* ============================================================
   STEPPER WIZARD (borrow RM-LIS report form)
   ============================================================ */
.wiz { display: grid; grid-template-columns: 280px 1fr; gap: 24px; align-items: start; }
.wiz-rail { position: sticky; top: 88px; display: flex; flex-direction: column; gap: 16px; }
.wiz-ringcard { padding: 18px; display: flex; align-items: center; gap: 15px; border-bottom: 1px solid var(--line); }
.wiz-meta { padding: 16px 18px; }
.wiz-meta .row { display: flex; justify-content: space-between; align-items: baseline; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.wiz-meta .row:last-child { border-bottom: 0; padding-bottom: 0; }
.wiz-meta .k { font-family: var(--mono); font-size: var(--fs-xs); letter-spacing: .6px; color: var(--ink-3); text-transform: uppercase; }
.wiz-meta .v { font-family: var(--mono); font-size: 12.5px; color: var(--ink); font-weight: 500; }
.wiz-meta .v.accent { color: var(--accent-ink); }
.wiz-steps { padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.wstep { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; cursor: pointer; color: var(--ink-2); transition: background .16s, color .16s; position: relative; border: none; background: none; width: 100%; text-align: left; font-family: inherit; }
.wstep:hover { background: var(--accent-softer); color: var(--ink); }
.wstep.active { background: var(--accent-soft); color: var(--ink); }
.wstep.active::before { content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 3px; height: 22px; background: var(--accent); border-radius: 3px; }
[data-skin="midnight"] .wstep.active::before { box-shadow: 0 0 10px var(--accent); }
.wstep .idx { font-family: var(--mono); font-size: 11px; width: 26px; height: 26px; flex: none; border: 1px solid var(--line-2, var(--line)); border-radius: 8px; display: grid; place-items: center; color: var(--ink-3); transition: .16s; }
.wstep.active .idx { border-color: var(--accent); color: var(--accent-ink); }
.wstep.done .idx { background: var(--ok-soft); border-color: var(--ok); color: var(--ok-ink); }
.wstep .nm { font-size: 13px; font-weight: 500; flex: 1; }
.wstep .nm small { display: block; font-size: var(--fs-xs); color: var(--ink-3); font-weight: 400; }
.wmain { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; scroll-margin-top: 88px; }
.block-head { display: flex; align-items: center; gap: 14px; padding: 17px 22px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, var(--accent-softer), transparent); }
.block-head .num { font-family: var(--mono); font-size: 12px; color: var(--accent-ink); border: 1px solid var(--accent-soft); background: var(--accent-soft); border-radius: 9px; padding: 7px 10px; }
.block-head h3 { font-size: 16px; font-weight: 600; margin: 0; }
.block-head h3 small { display: block; font-family: var(--mono); font-size: var(--fs-xs); color: var(--ink-3); font-weight: 400; letter-spacing: .5px; margin-top: 2px; }
.block-head .chk { margin-left: auto; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; transition: .2s; color: var(--ok-ink); }
.block-head .chk svg { opacity: 0; transform: scale(.5); transition: .2s; }
.block.complete .block-head .chk { border-color: var(--ok); background: var(--ok-soft); }
.block.complete .block-head .chk svg { opacity: 1; transform: scale(1); }
.block-body { padding: 22px; display: flex; flex-direction: column; gap: 20px; }
.flabel { font-size: 12.5px; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.flabel .tag { font-family: var(--mono); font-size: var(--fs-xs); letter-spacing: .5px; color: var(--ink-3); border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px; }
.flabel .req { color: var(--danger-ink); }

/* dropzone */
.dropzone { border: 1.5px dashed var(--line-2, var(--line)); border-radius: 12px; padding: 22px; text-align: center; cursor: pointer; transition: border-color .16s, background .16s; background: var(--surface-2); }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-softer); }
.dz-ic { width: 44px; height: 44px; border-radius: 12px; background: var(--surface); display: grid; place-items: center; margin: 0 auto 10px; color: var(--accent); }
.dropzone p { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 0; }
.dropzone span { font-size: 11.5px; color: var(--ink-3); }
/* the upload box's real button (wizard + instrument docs): reads as the box's own headline */
.dz-pick { font: inherit; color: inherit; background: none; border: 0; padding: 2px 6px; margin: -2px -6px; border-radius: 6px; cursor: pointer; }
.dz-pick[aria-disabled="true"] { cursor: default; }   /* not :disabled — that would drop keyboard focus mid-upload */
.dz-pick:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.filelist { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.fileitem { display: flex; align-items: center; gap: 11px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; }

/* review grid */
.review-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 22px; }
.rev-row { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.rev-row .rk { font-size: 11.5px; color: var(--ink-3); }
.rev-row .rv { font-size: 13.5px; font-weight: 600; }

/* ============================================================
   ANALYTICS (borrow RM-LIS dashboard patterns)
   ============================================================ */
.tag-h { font-family: var(--mono); font-size: var(--fs-xs); letter-spacing: .6px; color: var(--ink-3); border: 1px solid var(--line); border-radius: 5px; padding: 2px 7px; text-transform: uppercase; }
.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut-legend { display: flex; flex-direction: column; gap: 7px; flex: 1; min-width: 160px; }
.dleg { display: flex; align-items: center; gap: 9px; font-size: 12.5px; min-height: 24px; }
.dleg .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.dleg .nm { color: var(--ink-2); flex: 1; }
.dleg .vv { font-family: var(--mono); font-weight: 600; color: var(--ink); }
.dleg .pp { font-family: var(--mono); font-size: 11px; color: var(--ink-3); width: 40px; text-align: right; }
.vbars { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 10px; }
.vbar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; height: 100%; justify-content: flex-end; }
.vbar { width: 100%; max-width: 46px; border-radius: 7px 7px 3px 3px; background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 55%, transparent)); transition: height .6s cubic-bezier(.2,.7,.2,1); position: relative; }
[data-skin="midnight"] .vbar { box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 30%, transparent); }
.vbar-v { font-family: var(--mono); font-size: 12px; font-weight: 600; }
.vbar-l { font-size: var(--fs-xs); color: var(--ink-3); }
.hbars { display: flex; flex-direction: column; gap: 11px; }
.hbar-row { display: grid; grid-template-columns: 150px 1fr 38px; gap: 12px; align-items: center; }
.hbar-nm { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { height: 9px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 99px; transition: width .6s cubic-bezier(.2,.7,.2,1); }
.hbar-v { font-family: var(--mono); font-size: 12.5px; font-weight: 600; text-align: right; }

/* ============================================================
   PIN MODAL + admin badge
   ============================================================ */
.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 60;
  width: min(380px, 92vw); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 28px; text-align: center;
  animation: modalfade .22s ease both;
}
.modal-ic { width: 54px; height: 54px; border-radius: 15px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin: 0 auto 14px; }
.pin-input { width: 100%; text-align: center; font-size: 24px; letter-spacing: 10px; font-family: var(--mono); padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); color: var(--ink); outline: none; margin-top: 6px; }
.pin-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.admin-badge { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: var(--fs-xs); font-weight: 600; letter-spacing: .5px; color: var(--ok-ink); background: var(--ok-soft); border: 1px solid var(--ok); border-radius: 99px; padding: 4px 10px; }

/* topbar cluster (RM-LIS style) */
.topclock { font-family: var(--mono); font-size: 12.5px; color: var(--ink-2); text-align: right; line-height: 1.3; white-space: nowrap; }
.topclock b { color: var(--ink); font-weight: 500; }
.topclock span { color: var(--ink-3); font-size: var(--fs-xs); }
.status-online { display: inline-flex; align-items: center; gap: 7px; font-family: var(--mono); font-size: 11px; letter-spacing: 1px; color: var(--ok-ink); background: var(--ok-soft); border: 1px solid var(--ok); border-radius: 20px; padding: 6px 11px; white-space: nowrap; }
.avatar-wrap { position: relative; }
.avatar-btn { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-family: var(--mono); font-size: 12.5px; font-weight: 700; background: linear-gradient(135deg, color-mix(in oklab, var(--accent-fill) 82%, #000), var(--accent-fill)); color: var(--on-accent); border: 2px solid color-mix(in srgb, var(--ink) 12%, transparent); cursor: pointer; flex: none; }
.avatar-menu { position: absolute; right: 0; top: calc(100% + 8px); width: 220px; z-index: 45; padding: 8px; box-shadow: var(--shadow-lg); }
.am-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px; border-bottom: 1px solid var(--line-soft); margin-bottom: 6px; }
.rail-collapse { margin-left: auto; width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-3); display: grid; place-items: center; cursor: pointer; flex: none; transition: .15s; }
.rail-collapse:hover { color: var(--accent); border-color: var(--accent); }
.rail-collapsed .rail-collapse { margin: 0 auto; }
@media (max-width: 1100px) { .topclock { display: none; } }
@media (max-width: 940px) { .status-online { display: none; } }

/* ============================================================
   SKIN: SaaS — Light Purple · Soft-UI Lite · Glassmorphism
   · Linear-style sidebar.  Layered over base tokens via
   [data-skin="saas"] (later in source → wins over :root).
   ============================================================ */
[data-skin="saas"] {
  /* light purple SaaS palette */
  --bg:        oklch(0.974 0.011 292);
  --bg-sunk:   oklch(0.962 0.014 292);
  --surface:   oklch(0.995 0.004 292);
  --surface-2: oklch(0.972 0.012 292);
  --line:      oklch(0.865 0.020 292);
  --line-soft: oklch(0.910 0.015 292);

  --ink:       oklch(0.29 0.035 290);
  --ink-2:     oklch(0.45 0.030 290);
  --ink-3:     oklch(0.49 0.026 290);   /* >= 4.5:1 on the skin's surfaces */
  --ink-4:     oklch(0.525 0.022 292);

  --accent-soft:   oklch(0.95 0.035 292);
  --accent-softer: oklch(0.975 0.018 292);
  --accent-ring:   oklch(var(--accent-l) var(--accent-c) var(--accent-h) / 0.26);

  --ok-soft:     oklch(0.95 0.04 165);
  --warn-soft:   oklch(0.955 0.06 75);
  --danger-soft: oklch(0.95 0.045 18);
  --none-soft:   oklch(0.95 0.012 292);

  /* soft-UI lite — diffuse violet-tinted shadows, airy radii */
  --radius:    18px;
  --radius-sm: 12px;
  --radius-lg: 24px;
  --shadow-sm: 0 1px 2px oklch(0.45 0.10 292 / 0.07), 0 1px 1px oklch(0.45 0.10 292 / 0.04);
  --shadow:    0 2px 6px oklch(0.45 0.10 292 / 0.06), 0 14px 34px -16px oklch(0.45 0.12 292 / 0.22);
  --shadow-lg: 0 6px 18px oklch(0.45 0.10 292 / 0.10), 0 36px 70px -28px oklch(0.45 0.14 292 / 0.34);
}

/* page backdrop: subtle lavender wash */
[data-skin="saas"] body {
  background:
    radial-gradient(1100px 620px at 78% -8%, oklch(0.95 0.05 292 / 0.55), transparent 60%),
    radial-gradient(900px 560px at 8% 108%, oklch(0.95 0.045 258 / 0.45), transparent 60%),
    var(--bg);
}

/* ---- Linear-style sidebar: frosted, tight, restrained ---- */
[data-skin="saas"] .rail {
  background: oklch(0.985 0.008 292 / 0.72);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  border-right: 1px solid oklch(0.9 0.02 292 / 0.7);
}
[data-skin="saas"] .nav-item {
  border-radius: 9px; font-weight: 500; font-size: 13.5px; padding: 8px 10px;
  color: var(--ink-3);
}
[data-skin="saas"] .nav-item:hover { background: oklch(0.95 0.02 292 / 0.7); color: var(--ink); }
[data-skin="saas"] .nav-item .txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[data-skin="saas"] .nav-item.active {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent-strong); font-weight: 600;
}
[data-skin="saas"] .nav-item.active::before {
  content: ""; position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 3px; background: var(--accent);
}
[data-skin="saas"] .nav-label { font-size: var(--fs-xs); letter-spacing: .11em; color: var(--ink-4); }
[data-skin="saas"] .brand-mark {
  border-radius: 12px;
  background: linear-gradient(140deg, color-mix(in srgb, var(--accent) 88%, #fff), var(--accent-strong));
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--accent) 60%, transparent), inset 0 1px 0 #ffffff55;
}

/* ---- soft-UI cards: borderless, diffuse shadow, rounder ---- */
[data-skin="saas"] .card {
  border: 1px solid oklch(0.94 0.014 292 / 0.7);
  box-shadow: 0 1px 2px oklch(0.45 0.10 292 / 0.05), 0 10px 26px -16px oklch(0.45 0.12 292 / 0.28);
}
[data-skin="saas"] .btn {
  border-radius: 11px;
  box-shadow: 0 1px 2px oklch(0.45 0.08 292 / 0.06);
}
[data-skin="saas"] .btn-primary {
  background: linear-gradient(140deg, var(--accent-fill), color-mix(in oklab, var(--accent-fill) 88%, #000));
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--accent) 55%, transparent), inset 0 1px 0 #ffffff45;
}
[data-skin="saas"] .chip { border-radius: 99px; }
[data-skin="saas"] .pill { border-radius: 99px; }

/* ---- glassmorphism: topbar + overlays ---- */
[data-skin="saas"] .topbar {
  background: oklch(0.99 0.006 292 / 0.62);
  backdrop-filter: blur(16px) saturate(1.5);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  border-bottom: 1px solid oklch(0.91 0.02 292 / 0.6);
}
[data-skin="saas"] .scrim {
  background: oklch(0.5 0.08 292 / 0.28);
  backdrop-filter: blur(6px) saturate(1.2);
  -webkit-backdrop-filter: blur(6px) saturate(1.2);
}
[data-skin="saas"] .drawer,
[data-skin="saas"] .modal,
[data-skin="saas"] .avatar-menu,
[data-skin="saas"] .seg {
  background: oklch(0.995 0.004 292 / 0.78);
  backdrop-filter: blur(22px) saturate(1.5);
  -webkit-backdrop-filter: blur(22px) saturate(1.5);
  border: 1px solid oklch(0.92 0.018 292 / 0.7);
}
[data-skin="saas"] .input, [data-skin="saas"] .select, [data-skin="saas"] .search input {
  border-radius: 11px; background: oklch(0.98 0.008 292 / 0.8);
}
[data-skin="saas"] .seg button.on { background: oklch(0.995 0.004 292 / 0.9); }
[data-skin="saas"] table.tbl thead th { background: oklch(0.965 0.014 292 / 0.7); }
[data-skin="saas"] .tbl tbody tr:hover { background: var(--accent-softer); }
.audit-row:hover { background: var(--accent-softer); }
/* audit trail on a phone: the time / who column moves under the text — beside
   it, it squeezed the text to a word per line. Inline styles → !important. */
@media (max-width: 640px) {
  .audit-row { flex-wrap: wrap; row-gap: 4px !important; }
  .audit-row .audit-meta { flex: 1 1 100% !important; text-align: left !important; padding-left: 45px; display: flex; flex-wrap: wrap; column-gap: 10px; }
  .audit-row .audit-meta > div { margin-top: 0 !important; }
}

/* keep printable FR sheets pure white regardless of skin */
[data-skin="saas"] .temp-sheet, [data-skin="saas"] .label-sheet, [data-skin="saas"] .repair-sheet { color: #111; }

/* ============================================================
   SKIN: Blue Neutral — calm navy / slate / blue-grey with a warm
   beige accent neutral (palette #1F3B62 #6B7F99 #A7B1BD #D9D6CE
   #F7F9FC). The page sits on the blue-grey, cards are an off-white
   rather than paper white, so the light theme is easier on the
   eyes. Light theme only — dark mode keeps the dark tokens.
   ============================================================ */
[data-skin="blue"]:not([data-theme="dark"]) {
  --bg:        oklch(0.935 0.011 252);   /* #E4EAF1 */
  --bg-sunk:   oklch(0.915 0.013 252);   /* #DDE4EC */
  --surface:   oklch(0.978 0.005 255);   /* #F5F8FB */
  --surface-2: oklch(0.958 0.008 254);
  --line:      oklch(0.855 0.016 252);
  --line-soft: oklch(0.905 0.011 252);

  --ink:       oklch(0.30 0.055 257);    /* navy text */
  --ink-2:     oklch(0.42 0.042 256);
  --ink-3:     oklch(0.47 0.032 255);    /* >= 4.5:1 on every surface of this skin, bg-sunk included */
  --ink-4:     oklch(0.50 0.028 254);

  --accent-soft:   oklch(0.925 0.028 257);
  --accent-softer: oklch(0.952 0.016 257);
  --none-soft:     oklch(0.925 0.010 90);   /* the palette's beige carries "no data" */

  --shadow-sm: 0 1px 2px oklch(0.35 0.05 257 / 0.08), 0 1px 1px oklch(0.35 0.05 257 / 0.05);
  --shadow:    0 1px 3px oklch(0.35 0.05 257 / 0.09), 0 8px 24px -12px oklch(0.35 0.06 257 / 0.24);
  --shadow-lg: 0 4px 12px oklch(0.35 0.05 257 / 0.10), 0 24px 60px -20px oklch(0.35 0.06 257 / 0.32);
}
/* ambient wash: slate from the top, a breath of the beige from below (not the navy accent) */
[data-skin="blue"]:not([data-theme="dark"]) .amb::before {
  background:
    radial-gradient(900px 600px at 12% -5%, oklch(0.59 0.046 255 / 0.16), transparent 60%),
    radial-gradient(820px 700px at 100% 0%, oklch(0.756 0.021 253 / 0.22), transparent 55%),
    radial-gradient(720px 720px at 50% 118%, oklch(0.876 0.011 90 / 0.55), transparent 60%);
}
[data-skin="blue"] .temp-sheet, [data-skin="blue"] .label-sheet, [data-skin="blue"] .repair-sheet { color: #111; }

/* ============================================================
   SKIN: Hospital Green — white-green to match the Amnatcharoen
   Hospital / MOPH emblem (palette #0F2A1D #375534 #6B9071 #AEC3B0
   #E3EED4). The forest green owns structure (buttons, active nav,
   marks), so the "ok" status leans a little toward teal (hue 165)
   and is never read as decoration. Light theme only.
   ============================================================ */
[data-skin="green"]:not([data-theme="dark"]) {
  --bg:        oklch(0.948 0.016 135);   /* #E9F0E6 */
  --bg-sunk:   oklch(0.928 0.022 138);   /* #E0EBDD */
  --surface:   oklch(0.985 0.007 130);   /* #F8FBF6 */
  --surface-2: oklch(0.966 0.011 132);
  --line:      oklch(0.860 0.026 145);
  --line-soft: oklch(0.910 0.018 140);

  --ink:       oklch(0.27 0.040 158);    /* #0F2A1D family */
  --ink-2:     oklch(0.40 0.040 155);
  --ink-3:     oklch(0.46 0.034 152);    /* >= 4.5:1 on every surface of this skin */
  --ink-4:     oklch(0.49 0.030 150);

  --accent-soft:   oklch(0.925 0.035 142);
  --accent-softer: oklch(0.955 0.020 140);
  --none-soft:     oklch(0.930 0.012 110);
  --ok-h: 165;

  --shadow-sm: 0 1px 2px oklch(0.30 0.05 155 / 0.08), 0 1px 1px oklch(0.30 0.05 155 / 0.05);
  --shadow:    0 1px 3px oklch(0.30 0.05 155 / 0.09), 0 8px 24px -12px oklch(0.30 0.06 155 / 0.24);
  --shadow-lg: 0 4px 12px oklch(0.30 0.05 155 / 0.10), 0 24px 60px -20px oklch(0.30 0.06 155 / 0.32);
}
/* ambient wash: sage from the top, the palette's pale green from below */
[data-skin="green"]:not([data-theme="dark"]) .amb::before {
  background:
    radial-gradient(900px 600px at 12% -5%, oklch(0.617 0.062 149 / 0.16), transparent 60%),
    radial-gradient(820px 700px at 100% 0%, oklch(0.796 0.035 148 / 0.24), transparent 55%),
    radial-gradient(720px 720px at 50% 118%, oklch(0.934 0.036 126 / 0.65), transparent 60%);
}
[data-skin="green"] .temp-sheet, [data-skin="green"] .label-sheet, [data-skin="green"] .repair-sheet { color: #111; }

/* ============================================================
   SKIN: Clinical Neutral (default) — the IBM Carbon model, which
   suits the app's IBM Plex type: true neutral greys with no hue,
   flat layers, small radii. Light and dark are two separate neutral
   ramps (graphite, not tinted brown or green), so the modes read as
   different rooms. Green is a signal only — the brand mark, the
   selected-menu bar, primary buttons, focus — and "ok" sits on a
   bluer green (hue 160) so it is never mistaken for the brand.
   No ambient glow, grid or grain: the content is the surface.
   ============================================================ */
[data-skin="clinical"] {
  --radius: 6px; --radius-sm: 4px; --radius-lg: 8px;
  --ok-h: 160;
}
[data-skin="clinical"]:not([data-theme="dark"]) {
  --bg:        #f4f4f4;
  --bg-sunk:   #ececec;
  --surface:   #ffffff;
  --surface-2: #f4f4f4;
  --line:      #e0e0e0;
  --line-soft: #ebebeb;

  --ink:   #161616;
  --ink-2: #393939;
  --ink-3: #5c5c5c;   /* 6.0:1 on #f4f4f4 */
  --ink-4: #6a6a6a;   /* 5.0:1 on #f4f4f4, 4.6:1 on #e8e8e8 */

  --accent-soft:   oklch(0.95 0.025 152);
  --accent-softer: oklch(0.975 0.012 152);
  --none-soft:     #ececec;

  --shadow-sm: none;
  --shadow:    0 2px 6px rgb(0 0 0 / .08);
  --shadow-lg: 0 8px 24px rgb(0 0 0 / .12);
}
[data-skin="clinical"][data-theme="dark"] {
  --bg:        #161616;
  --bg-sunk:   #111111;
  --surface:   #262626;
  --surface-2: #2f2f2f;
  --line:      #393939;
  --line-soft: #313131;

  --ink:   #f4f4f4;
  --ink-2: #c6c6c6;
  --ink-3: #a8a8a8;   /* 6.3:1 on #262626 */
  --ink-4: #9c9c9c;   /* 5.5:1 on #262626, 4.9:1 on #2f2f2f */

  /* selection and soft fills stay grey here: a green wash is what made dark mode read as the light theme */
  --accent-soft:   #333333;
  --accent-softer: #2b2b2b;
  --none-soft:     #333333;

  --shadow-sm: none;
  --shadow:    none;   /* depth in the dark comes from the lighter layer, not a shadow */
  --shadow-lg: 0 8px 24px rgb(0 0 0 / .5);
}
/* shell: solid layers, the page one step darker than rail, header and cards */
[data-skin="clinical"] .amb, [data-skin="clinical"] .amb-grain { display: none; }
[data-skin="clinical"] .rail { background: var(--surface); backdrop-filter: none; }
[data-skin="clinical"] .topbar { background: var(--surface); backdrop-filter: none; }
[data-skin="clinical"] .main { background: var(--bg); }
/* selected menu item: a neutral fill and a thin green bar, not a green slab */
[data-skin="clinical"] .nav-item.active {
  background: #e8e8e8; color: var(--ink);
  box-shadow: inset 3px 0 0 var(--accent); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
[data-skin="clinical"][data-theme="dark"] .nav-item.active { background: var(--surface-2); }
[data-skin="clinical"] .brand-mark, [data-skin="clinical"] .avatar-btn { border-radius: 4px; }
/* figures in the UI's own sans (Plex), not an editorial serif */
[data-skin="clinical"] .figure, [data-skin="clinical"] .auth-headline { font-family: var(--sans); font-weight: 400; letter-spacing: -.02em; }
/* sign-in: the same flat neutral ground — no accent glow, grid or sweeping scan line */
[data-skin="clinical"] .auth-show { background: var(--bg); }
[data-skin="clinical"] .auth-show::before, [data-skin="clinical"] .auth-scan { display: none; }
[data-skin="clinical"] .auth-card { border-radius: var(--radius-lg); box-shadow: 0 8px 24px rgb(0 0 0 / .08); }
/* charts of plain counts are data, not good news: neutral grey bars, so green keeps meaning "ok" */
[data-skin="clinical"] .vbar { background: #8d8d8d; border-radius: 3px 3px 1px 1px; }   /* 3.3:1 on white */
[data-skin="clinical"][data-theme="dark"] .vbar { background: #808080; }              /* 3.6:1 on #262626 */
[data-skin="clinical"] .temp-sheet, [data-skin="clinical"] .label-sheet, [data-skin="clinical"] .repair-sheet { color: #111; }

/* ---------- numeric calibration results table ---------- */
.cal-res-tbl { font-size: 12.5px; }
.cal-res-tbl thead th { background: var(--surface-2); font-size: var(--fs-xs); padding: 8px 8px; }
.cal-res-tbl tbody tr:hover { background: transparent; }
.cal-res-tbl tbody td { padding: 8px 8px; }
.cal-res-tbl .pill { font-size: 11px; }

/* ---------- annual calibration master plan ---------- */
.cp-loadrow { display: grid; grid-template-columns: repeat(12, 1fr); gap: 8px; align-items: end; }
.cp-loadcell { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 6px 2px; border-radius: 9px; }
.cp-loadcell.now { background: var(--accent-softer); }
.cp-loadbar-track { width: 100%; height: 64px; display: flex; align-items: flex-end; justify-content: center; }
.cp-loadbar { width: 60%; max-width: 26px; min-height: 4px; border-radius: 6px 6px 3px 3px; background: linear-gradient(180deg, var(--accent), var(--accent-strong)); }
.cp-loadnum { font-size: 13px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.cp-loadmon { font-size: var(--fs-xs); color: var(--ink-3); }
.cp-loadcell.now .cp-loadmon { color: var(--accent-strong); font-weight: 600; }
[data-theme="dark"] .cp-loadcell.now .cp-loadmon { color: var(--ink); }
/* phones: 12 months in one row can't shrink below their labels — two rows of six */
@media (max-width: 640px) {
  .cp-loadrow { grid-template-columns: repeat(6, minmax(0, 1fr)); row-gap: 10px; }
}

.cp-dept-head { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 14px 18px; border: none; background: none; cursor: pointer; font-family: inherit; color: var(--ink); border-bottom: 1px solid var(--line-soft); }
.cp-dept-head:hover { background: var(--surface-2); }

table.cp-grid { table-layout: fixed; }
table.cp-grid thead th { background: var(--surface-2); padding: 8px 4px; text-align: center; font-size: var(--fs-xs); }
table.cp-grid thead th.cp-mon-col { width: 56px; }
.cp-name-col { width: 250px; text-align: left !important; position: sticky; left: 0; background: var(--surface); z-index: 1; }
table.cp-grid thead th.cp-name-col { background: var(--surface-2); }
table.cp-grid tbody td { padding: 7px 4px; text-align: center; border-bottom: 1px solid var(--line-soft); }
.cp-cell.now, table.cp-grid thead th.cp-mon-col.now { background: var(--accent-softer); }
table.cp-grid tbody tr:hover { background: var(--accent-softer); }
table.cp-grid tbody tr:hover .cp-name-col { background: var(--accent-softer); }
.cp-dot { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 99px; color: #fff; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; box-shadow: var(--shadow-sm); }
.cp-dot.done { width: 11px; height: 11px; background: transparent; border: 2px solid var(--ink-4); box-shadow: none; }

/* calibration dispatch modal — stack columns on narrow screens */
@media (max-width: 640px) {
  .cj-create-grid { grid-template-columns: 1fr !important; }
}

/* ---------- department landing cards ---------- */
/* a <button> styled as a card does NOT inherit the theme text colour
   (the UA forces a dark button colour) → force it so titles read in dark
   mode. Covers dept landing cards AND instrument grid cards. */
button.card { color: var(--ink); font-family: inherit; }
@media (hover: hover) {
  .dept-card { transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease; }
  .dept-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: color-mix(in oklch, var(--line), var(--ink) 22%); }
}

/* ---------- inventory filter cards (rounded, horizontal) ---------- */
.filter-card {
  display: flex; flex-direction: column; gap: 1px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 6px 13px 7px; cursor: pointer; transition: border-color .14s, box-shadow .14s;
}
.filter-card:hover { border-color: color-mix(in oklch, var(--line), var(--ink) 30%); box-shadow: var(--shadow-sm); }
.filter-card .fc-label {
  font-size: var(--fs-xs); color: var(--ink-3); font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; display: flex; align-items: center; gap: 4px;
}
.filter-card .fc-select {
  appearance: none; -webkit-appearance: none;
  width: auto; min-width: 110px; max-width: 230px;
  border: none; background: transparent; color: var(--ink);
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  padding: 1px 18px 0 0; outline: none; cursor: pointer;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="%23999" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9l6 6 6-6"/></svg>');
  background-repeat: no-repeat; background-position: right 0 center;
}
.filter-card .fc-select option { color: #111; }

/* ---------- playful loading scene (Claude mascot) ---------- */
.loader-scene { display: grid; place-items: center; }
.loader-claude { display: block; transform-origin: center 72%; animation: loader-bob 0.9s ease-in-out infinite; filter: drop-shadow(0 7px 9px rgba(0,0,0,.18)); }
.lc-body { fill: #cc785c; }
.lc-eye { fill: #1f1714; transform-box: fill-box; transform-origin: center; animation: loader-blink 2.8s ease-in-out infinite; }
@keyframes loader-bob { 0%, 100% { transform: translateY(0) scaleY(1); } 45% { transform: translateY(-9px) scaleY(1.03); } 60% { transform: translateY(-9px) scaleY(1.03); } }
@keyframes loader-blink { 0%, 90%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.08); } }
.loader-text { margin-top: 14px; font-size: 14px; font-weight: 500; letter-spacing: .02em; color: var(--muted, #8a8580); animation: loader-fade 1.6s ease-in-out infinite; }
.loader-dots::after { content: ''; animation: loader-dots 1.4s steps(1, end) infinite; }
@keyframes loader-fade { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@keyframes loader-dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* ---------- reports hub ---------- */
.reports-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.report-card { display: flex; flex-direction: column; gap: 5px; }
.report-ic { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 8px; }
.report-sub { font-family: var(--mono); font-size: var(--fs-xs); letter-spacing: .5px; text-transform: uppercase; color: var(--ink-3); }
.report-title { font-size: 16px; font-weight: 600; color: var(--ink); }
.report-desc { font-size: 12.5px; color: var(--ink-3); line-height: 1.5; flex: 1; margin: 2px 0 12px; }
.report-btn { align-self: flex-start; }

/* ---------- dashboard / KPI responsive grids ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.dash-two { display: grid; grid-template-columns: 1.25fr 1fr; gap: 22px; align-items: start; }
.dash-three { display: grid; grid-template-columns: 0.85fr 1fr 1fr; gap: 22px; align-items: start; }
@media (max-width: 980px) { .dash-three { grid-template-columns: 1fr 1fr; } }
@media (max-width: 720px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .dash-two, .dash-three { grid-template-columns: 1fr; }
  .content { padding: 18px 14px 56px; }
}

/* ---------- mobile: dashboard cards + alerts rows fit narrow screens ---------- */
@media (max-width: 720px) {
  .dash-two > *, .dash-three > *, .kpi-grid > * { min-width: 0; }   /* let cards shrink instead of overflowing */
  .dept-health-row { grid-template-columns: minmax(0, 1fr) auto !important; }
  .dh-bar { display: none !important; }              /* % conveys readiness; drop the bar on mobile */
  .alert-row { gap: 12px; }
  /* whole row is tappable → the จัดการ button leaves the layout, but stays the keyboard /
     screen-reader way in (the row itself takes no focus); its focus ring goes round the row */
  .alert-row .btn { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
  .alert-row:focus-within { outline: 2px solid var(--accent); outline-offset: -2px; }
  /* number tiles (reagents, document index): two-up, an odd last tile takes the whole row
     (!important: the grid's columns are an inline style) */
  .stat-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .stat-tiles > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}

/* ---------- mobile: section-card header stacks (title full width, actions below) ---------- */
@media (max-width: 640px) {
  .sec-head { flex-wrap: wrap; }
  .sec-head-right { flex-basis: 100%; margin-top: 10px; }
  .sec-head-right > div { justify-content: flex-start !important; }
  .sec-head-right .btn { flex: 1; justify-content: center; }
}

/* ---------- mobile: user-management table becomes a stacked card list ----------
   (overrides the generic .tbl horizontal-scroll for this specific small table so
   the edit/reset/suspend actions are reachable without side-scrolling) */
@media (max-width: 640px) {
  .tbl-cards { display: block; overflow: visible; white-space: normal; }
  .tbl-cards thead { display: none; }
  .tbl-cards tbody { display: block; }
  .tbl-cards tr { display: block; border: 1px solid var(--line); border-radius: 12px;
    padding: 6px 12px; margin: 0 0 10px; background: var(--surface); }
  .tbl-cards td { display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 8px 0 !important; text-align: left !important; overflow-wrap: anywhere; border: none; }
  .tbl-cards td:not(:last-child) { border-bottom: 1px dashed var(--line-soft); }
  .tbl-cards td::before { content: attr(data-label); flex: none; font-size: 11.5px; font-weight: 600;
    color: var(--ink-3); }
  .tbl-cards td:last-child > div { justify-content: flex-end !important; }
}

/* ---------- mobile: room map stays usable ---------- */
/* desktop shows the spatial drag-drop canvas; phones AND tablets show a
   readable list instead (a cramped positioned-token layout never reads well on
   touch/narrow screens; arranging is a mouse/desktop task anyway) */
.rm-canvas-wrap { overflow-x: auto; }
.rm-mobile-list { display: none; }
@media (max-width: 1024px) {
  .rm-canvas-wrap { display: none !important; }
  .rm-mobile-list { display: block !important; }
}

/* ---------- 3D floor map (floormap3d.jsx) — desktop only; the list beside the
   canvas is the keyboard / screen-reader way through the same rooms and instruments ---------- */
.fm3-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-height: 34px; }
.fm3 { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 14px; align-items: start; }
.fm3-stage { position: relative; height: clamp(440px, 66vh, 760px); border-radius: var(--radius); overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); }
.fm3-stage > canvas { display: block; opacity: 0; transition: opacity .25s ease; }
.fm3-stage.ready > canvas { opacity: 1; }
.fm3-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.fm3-loading { position: absolute; inset: 0; display: grid; place-items: center; font-size: 13px; color: var(--ink-3); }
/* room label stays one compact line so the floor's status colour shows; the
   overdue / due-soon pills open only while that room is hovered or focused */
.fm3-room-label { display: flex; flex-direction: column; align-items: center; gap: 4px; max-width: 220px; padding: 3px 9px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-sm);
  color: var(--ink); font-size: 12px; line-height: 1.3; text-align: center; }
.fm3-room-label .line { display: flex; align-items: baseline; gap: 6px; max-width: 100%; white-space: nowrap; }
.fm3-room-label b { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.fm3-room-label .n { flex: none; font-size: var(--fs-xs); color: var(--ink-3); }
.fm3-room-label .pills { display: none; gap: 4px; flex-wrap: wrap; justify-content: center; }
.fm3-room-label.on { border-color: var(--ink-4); box-shadow: var(--shadow); }
.fm3-room-label.on .pills { display: flex; }
.fm3-room-label .pill, .fm3-tip .pill { font-size: var(--fs-xs); padding: 1px 7px 1px 6px; }
.fm3-wall-label, .fm3-tray-label { padding: 1px 7px; border-radius: 6px; white-space: nowrap; font-size: var(--fs-xs); font-weight: 600;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); }
.fm3-tray-label { color: var(--ink); }
.fm3-anchor { position: relative; width: 0; height: 0; }
.fm3-tip { position: absolute; bottom: 6px; left: 0; transform: translateX(calc(-50% + var(--tip-dx, 0px))); display: flex; align-items: center; gap: 10px;
  width: max-content; min-width: 150px; max-width: 300px; padding: 8px 10px 8px 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); color: var(--ink); }
/* no room above the instrument (near the stage's top edge): hang below its point instead */
.fm3-tip.below { bottom: auto; top: 10px; }
/* the photo sits on white whatever the theme: product shots come on white backgrounds */
.fm3-tip-photo { flex: none; width: 76px; height: 76px; border-radius: 8px; background: #fff; border: 1px solid var(--line-soft);
  display: grid; place-items: center; overflow: hidden; }
.fm3-tip-photo img { width: 100%; height: 100%; object-fit: contain; }
.fm3-tip-text { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.fm3-tip .code { font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.fm3-tip .t { font-size: 12px; color: var(--ink-2); line-height: 1.35; }
.fm3-list { max-height: clamp(440px, 66vh, 760px); overflow-y: auto; padding: 6px 0; }
.fm3-list-head { margin: 0; padding: 10px 14px 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.fm3-list-head:focus { outline: none; }
.fm3-list-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }
.fm3-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 8px 14px; border: none; background: none;
  text-align: left; color: var(--ink); font: inherit; cursor: pointer; }
.fm3-item:hover, .fm3-item.on { background: var(--accent-softer); }
.fm3-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.fm3-item > svg { flex: none; color: var(--ink-4); }
.fm3-item .pill { flex: none; }
.fm3-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fm3-item-title { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm3-item-sub { font-size: var(--fs-xs); color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm3-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.fm3-empty { padding: 14px; font-size: 13px; color: var(--ink-3); }
.fm3-notice { font-size: 12.5px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 7px 12px; }
@media (max-width: 1024px) { .fm3-toggle { display: none !important; } }

/* ---------- 2D lab overview on phones: a room box is ~100 px wide, too small for a
   Thai room name, so it keeps the department code + count and the full names are
   listed under the map (!important: the box's own layout is inline) ---------- */
.fm-zone-mini, .fm-mobile-list { display: none; }
.fm-zone-mini { flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 0 5px; line-height: 1.15; text-align: center; }
.fm-zone-mini b { font-size: 12px; font-weight: 700; letter-spacing: .02em; }
.fm-zone-mini .figure { font-size: 16px; }
.fm-mobile-list { padding: 6px 0; overflow: hidden; }
@media (max-width: 640px) {
  .fm-zone { padding: 4px !important; justify-content: center; align-items: center; }
  .fm-zone-full { display: none !important; }
  .fm-zone-mini { display: flex !important; }
  .fm-mobile-list { display: block !important; }
}

/* ---------- reduced motion ----------
   Things still change visibly (cards and drawers fade in, busy icons keep
   turning) but nothing travels, bobs or sweeps. Inline JSX animations are the
   'spin' busy indicator only — kept on purpose. */
@media (prefers-reduced-motion: reduce) {
  .enter { animation-name: fade; }
  .drawer { animation-name: fade; }
  .auth-scan { animation: none; opacity: 0; }
  .loader-claude, .lc-eye { animation: none; }
  .dept-card:hover { transform: none; }
  .ring-arc { transition: none !important; }   /* the transition is inline (Ring) */
  .fm3-stage > canvas { transition: none; }
}
