/* Component kit + shell, implementing the approved reference's grammar (05 §1–§4).
   Colours come from tokens.css only — a literal hex here fails eng/check-ui-tokens.sh. */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
html { font-size: var(--text-base); }
body {
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--app-bg);
  font-size: 0.875rem;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); text-decoration: underline; }
input, select, textarea, button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-track { background: transparent; }

.icon {
  font-family: var(--font-icon);
  font-weight: 400;
  font-style: normal;
  font-size: 18px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  direction: ltr;
  -webkit-font-feature-settings: "liga";
  font-feature-settings: "liga";
  user-select: none;
  vertical-align: middle;
  flex: none;
}
.icon-sm { font-size: 16px; }
.icon-lg { font-size: 20px; }
.icon-xl { font-size: 26px; }

/* screen-reader-only text: colour is never the sole carrier of meaning (§7 U12) */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes riseIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* ====================================================================== */
/* Shell (05 §2)                                                          */
/* ====================================================================== */

.shell { display: flex; height: 100vh; overflow: hidden; background: var(--app-bg); }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--rail);
  display: flex;
  flex-direction: column;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--rail-rule);
}
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; flex: none;
  border-radius: var(--radius);
  background: var(--primary); color: var(--paper);
  font-size: 18px; font-weight: 700;
}
.brand-text { min-width: 0; }
.brand-name {
  color: var(--paper); font-weight: 700; font-size: 0.9rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-tagline {
  color: var(--rail-muted-2); font-size: 0.65rem; letter-spacing: 0.06em;
  text-transform: uppercase; margin-top: 2px;
}
.rail-nav { flex: 1; overflow-y: auto; padding: 10px 10px 20px; }
.nav-group { margin-top: 14px; }
.nav-group:first-child { margin-top: 4px; }
.nav-group-title {
  display: flex; align-items: center; gap: 7px;
  padding: 0 8px 6px;
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--rail-muted);
}
.dept-dot { width: 7px; height: 7px; flex: none; border-radius: var(--radius-pill); background: var(--rail-muted); }
.dept-dot[data-dept="dashboard"] { background: var(--dept-dashboard); }
.dept-dot[data-dept="registration"] { background: var(--dept-registration); }
.dept-dot[data-dept="appointments"] { background: var(--dept-appointments); }
.dept-dot[data-dept="billing"] { background: var(--dept-billing); }
.dept-dot[data-dept="diagnostics"] { background: var(--dept-diagnostics); }
.dept-dot[data-dept="lis"] { background: var(--dept-lis); }
.dept-dot[data-dept="admin"] { background: var(--dept-admin); }
.dept-dot[data-dept="notifications"] { background: var(--dept-notifications); }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  min-height: 34px;
  padding: 5px 9px;
  border: none; border-radius: var(--radius);
  background: transparent; color: var(--rail-ink);
  font-size: 0.8125rem; font-weight: 500;
  text-align: left; text-decoration: none;
  margin-bottom: 1px;
}
.nav-item:hover { background: var(--rail-hover); color: var(--rail-hover-ink); text-decoration: none; }
.nav-item.active { background: var(--rail-active); color: var(--paper); font-weight: 700; }
.nav-item .icon { font-size: 19px; color: inherit; }
.nav-item span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rail-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--rail-rule);
  color: var(--rail-muted);
  font-size: 0.6875rem;
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow-x: auto; }

.topbar {
  min-height: 50px;
  min-width: var(--content-min);
  background: var(--paper);
  border-bottom: 1px solid var(--border-1);
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
}
.topbar-title { width: 236px; margin-right: auto; }
.crumb {
  font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted-2);
}
.page-title { font-size: 1.03rem; font-weight: 700; line-height: 1.25; }

.global-search { position: relative; width: 280px; }
.global-search .icon {
  position: absolute; left: 10px; top: 9px; font-size: 19px; color: var(--muted-2); pointer-events: none;
}
.global-search input {
  width: 100%; height: 37px;
  padding: 0 12px 0 36px;
  font-size: 0.8125rem;
  background: var(--app-bg);
  border: 1px solid var(--border-1); border-radius: var(--radius);
  color: var(--ink);
}
.topbar-btn {
  position: relative;
  width: 37px; height: 37px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-1); border-radius: var(--radius);
  background: var(--paper); color: var(--ink-2); cursor: pointer;
}
.topbar-btn:hover { background: var(--app-bg); text-decoration: none; }
.topbar-btn .badge-dot {
  position: absolute; top: 6px; right: 7px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--danger);
}
.user-chip {
  display: flex; align-items: center; gap: 9px;
  border-left: 1px solid var(--border-1);
  padding-left: 10px;
}
.avatar {
  width: 34px; height: 34px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--primary-tint); color: var(--primary);
  font-weight: 700; font-size: 0.8125rem;
}
.user-name { font-size: 0.8125rem; font-weight: 600; line-height: 1.2; }
.user-role { font-size: 0.6875rem; color: var(--muted-2); }

.content {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px 34px;
  min-width: var(--content-min);
  animation: riseIn 0.25s ease;
}

.status-footer {
  min-height: 26px;
  min-width: var(--content-min);
  background: var(--paper);
  border-top: 1px solid var(--border-1);
  display: flex; align-items: center; gap: 16px;
  padding: 0 14px;
  font-size: 0.71875rem; color: var(--muted-1);
  white-space: nowrap;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); display: inline-block; }
.status-dot.live { animation: pulse 1.6s infinite; }
.fkey-map { margin-left: auto; }
.tabular { font-variant-numeric: tabular-nums; }

/* ====================================================================== */
/* Cards, sections, layout helpers                                        */
/* ====================================================================== */

.card {
  background: var(--paper);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-card);
}
.card-clip { overflow: hidden; }
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 10px;
  font-size: 0.875rem; font-weight: 700;
}
.card-head .spacer { margin-left: auto; }
.card-hint { font-size: 0.8125rem; color: var(--muted-1); font-weight: 400; }
.card-body { padding: 14px 16px; }
.section-sub { font-size: 0.71875rem; color: var(--muted-2); font-weight: 400; }

.grid { display: grid; gap: 14px; align-items: start; }
.grid-main-side { grid-template-columns: minmax(0, 1fr) 330px; }
.grid-side-main { grid-template-columns: 272px minmax(0, 1fr); }
.grid-pos { grid-template-columns: minmax(0, 1fr) 356px; }
.grid-3 { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) 318px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-end { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.spacer { margin-left: auto; }
.sticky-top { position: sticky; top: 0; }
.narrow { max-width: 900px; }
.narrower { max-width: 760px; }
.mt { margin-top: 14px; }

/* ====================================================================== */
/* Buttons — 44px targets on primary actions (§7 U3)                      */
/* ====================================================================== */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--target-min);
  padding: 0 16px;
  border: 1px solid var(--border-input); border-radius: var(--radius);
  background: var(--paper); color: var(--ink-2);
  font: inherit; font-size: 0.8125rem; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--app-bg); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--paper); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: var(--paper); }
.btn-success { background: var(--success); border-color: var(--success); color: var(--paper); }
.btn-success:hover { filter: brightness(0.92); color: var(--paper); }
.btn-danger { background: var(--paper); border-color: var(--danger-border); color: var(--danger); font-weight: 700; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-outline { background: var(--paper); border-color: var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary-tint); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--muted-1); }
.btn-quiet:hover { background: var(--app-bg); color: var(--ink); }
.btn-block { width: 100%; }
.btn-cta { min-height: 46px; font-size: 0.84375rem; font-weight: 700; }

/* in-row action: compact by design, still 30px tall and clearly labelled */
.btn-tint {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  min-height: 30px; padding: 0 14px;
  border: none; border-radius: var(--radius-pill);
  background: var(--primary-tint); color: var(--primary);
  font: inherit; font-size: 0.78125rem; font-weight: 700;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn-tint:hover { background: var(--primary-tint-hover); color: var(--primary); text-decoration: none; }
.btn-tint:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-tint.danger { background: var(--danger-bg); color: var(--danger); }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; flex: none;
  border: 1px solid var(--border-1); border-radius: var(--radius-pill);
  background: var(--paper); color: var(--ink-2);
  cursor: pointer; text-decoration: none;
}
.btn-icon:hover { background: var(--app-bg); text-decoration: none; }
.btn-icon.primary { color: var(--primary); }
.btn-icon.info { color: var(--info); }
.btn-icon.danger { color: var(--danger); border-color: var(--danger-border); }
.btn-icon.danger:hover { background: var(--danger-bg); }
.btn-row { display: flex; align-items: center; gap: 8px; }
.btn-row.end { justify-content: flex-end; }

/* toggle chip (filter tabs, investigation picker) */
.chip-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 30px; padding: 0 12px;
  border: 1px solid var(--border-1); border-radius: var(--radius-pill);
  background: var(--paper); color: var(--muted-1);
  font: inherit; font-size: 0.75rem; font-weight: 700;
  cursor: pointer; text-decoration: none;
}
.chip-toggle:hover { background: var(--app-bg); text-decoration: none; }
.chip-toggle.on { border-color: var(--primary); background: var(--primary-tint); color: var(--primary); }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ====================================================================== */
/* Forms                                                                  */
/* ====================================================================== */

.field { display: block; }
.field-label {
  display: block;
  font-size: 0.78125rem; font-weight: 600; color: var(--ink-2);
  margin-bottom: 6px;
}
.field-label .req { color: var(--danger); }
.micro-label {
  display: block;
  font-size: 0.71875rem; font-weight: 700; color: var(--muted-2);
  text-transform: uppercase; letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.input, .select, .textarea {
  width: 100%;
  height: var(--control-h);
  padding: 0 12px;
  font-size: 0.84375rem; color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--border-input); border-radius: var(--radius);
  outline: none;
}
.select { padding: 0 10px; }
.textarea { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.4; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary); box-shadow: var(--focus-ring);
}
.input:disabled, .select:disabled { background: var(--surface-1); color: var(--muted-1); }
.input-sm { height: var(--control-h-sm); font-size: 0.8125rem; border-radius: var(--radius-pill); }
.input-invalid { border-color: var(--danger); }
.input-num { text-align: right; font-variant-numeric: tabular-nums; }
.field-grid { display: grid; gap: 14px 16px; }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-5 { grid-template-columns: repeat(5, 1fr); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.help-text { font-size: 0.71875rem; color: var(--muted-2); margin-top: 4px; }

/* type-ahead results (05 §3) — never a free-text foreign key (§7 U5) */
.typeahead-results {
  position: absolute; z-index: 40;
  margin: 2px 0 0; padding: 4px; list-style: none;
  min-width: 260px; max-height: 260px; overflow-y: auto;
  background: var(--paper);
  border: 1px solid var(--border-1); border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}
.typeahead-results li {
  padding: 7px 10px; font-size: 0.8125rem; border-radius: var(--radius-pill); cursor: pointer;
}
.typeahead-results li.focused, .typeahead-results li:hover { background: var(--primary-tint); color: var(--primary); }
.typeahead-host { position: relative; }

/* ====================================================================== */
/* Tables                                                                 */
/* ====================================================================== */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  padding: 6px 12px;               /* reference density — rows read tighter at register volume */
  text-align: left;
  font-size: 0.6875rem; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--ink-2);
  background: var(--th-bg);
  border-bottom: 1px solid var(--th-rule);
  white-space: nowrap;
}
table.data td {
  padding: 6px 12px;
  font-size: 0.8125rem;
  border-bottom: 1px solid var(--td-rule);
  vertical-align: middle;
}
table.data tbody tr:nth-child(even) { background: var(--zebra); }
table.data tbody tr:hover { background: var(--row-hover); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .mid { text-align: center; }
table.data .id-cell { font-weight: 600; color: var(--primary); font-variant-numeric: tabular-nums; }
table.data tfoot td, table.data tr.total-row td {
  background: var(--total-row-bg);
  font-weight: 800; font-size: 0.84375rem;
  border-bottom: none;
}
.empty-state {
  padding: 34px 16px; text-align: center; color: var(--muted-3);
  font-size: 0.8125rem;
}
.empty-state .icon { font-size: 34px; display: block; margin: 0 auto 8px; }
.dash { color: var(--muted-3); }

/* ====================================================================== */
/* Status pills — colour AND word, always (§7 U12)                        */
/* ====================================================================== */

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 0.71875rem; font-weight: 700;
  background: var(--surface-1); color: var(--muted-1);
  white-space: nowrap;
}
.pill.good { background: var(--success-bg); color: var(--success); }
.pill.warn { background: var(--warning-bg); color: var(--warning); }
.pill.bad { background: var(--danger-bg); color: var(--danger); }
.pill.info { background: var(--info-bg); color: var(--info); }

.flag {
  display: inline-block; min-width: 20px;
  padding: 1px 6px; border-radius: 5px;
  font-size: 0.6875rem; font-weight: 800; text-align: center;
}
.flag.high { background: var(--danger-bg); color: var(--danger); }
.flag.low { background: var(--info-bg); color: var(--info); }
.flag.none { color: var(--disabled); background: transparent; }

.money-due { color: var(--danger); font-weight: 700; }
.money-paid { color: var(--success); font-weight: 700; }
.text-muted { color: var(--muted-2); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }

/* ====================================================================== */
/* KPI tiles                                                              */
/* ====================================================================== */

.tile-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(152px, 1fr)); gap: 12px; }
.tile {
  background: var(--paper);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-card);
  padding: 12px 12px 10px;
}
.tile-head { display: flex; align-items: flex-start; gap: 8px; }
.tile-label {
  font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--muted-2);
}
.tile .icon { margin-left: auto; font-size: 19px; color: var(--muted-3); }
.tile-value {
  font-size: 1.125rem; font-weight: 800; margin-top: 8px;
  font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
}
.tile-sub { font-size: 0.71875rem; color: var(--muted-2); margin-top: 3px; }

/* role home: 3–6 big actions, not a menu tree (§7 U1) */
.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(232px, 1fr)); gap: 12px; }
.action-card {
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px; text-align: left;
  background: var(--paper);
  border: 1px solid var(--border-1); border-radius: var(--radius-card);
  color: var(--ink); text-decoration: none;
  min-height: 96px;
}
.action-card:hover {
  border-color: var(--primary); box-shadow: var(--shadow-card);
  color: var(--ink); text-decoration: none;
}
.action-icon {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius); background: var(--primary-tint); color: var(--primary);
}
.action-title { font-size: 0.875rem; font-weight: 700; }
.action-desc { font-size: 0.71875rem; color: var(--muted-2); }

/* ====================================================================== */
/* Charts (dashboard)                                                     */
/* ====================================================================== */

.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding: 10px 16px 6px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; height: 100%; justify-content: flex-end; }
.bar-val { font-size: 0.59375rem; color: var(--muted-2); }
.bar {
  width: 100%; border-radius: 5px 5px 2px 2px;
  background: var(--bar-idle); min-height: 2px;
}
.bar.today { background: var(--primary); }
.bar-label { font-size: 0.625rem; color: var(--muted-3); }

.dist-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 16px; border-top: 1px solid var(--border-3);
}
.dist-dot { width: 8px; height: 8px; flex: none; border-radius: var(--radius-pill); }
.dist-label { font-size: 0.8125rem; min-width: 104px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dist-track { flex: 1; height: 7px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.dist-fill { height: 100%; border-radius: 4px; }
.dist-value { font-size: 0.78125rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.snap-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; border-top: 1px solid var(--border-3);
  color: var(--ink); text-decoration: none;
}
.snap-row:hover { background: var(--row-hover); text-decoration: none; color: var(--ink); }
.snap-icon {
  width: 30px; height: 30px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-pill); background: var(--primary-tint); color: var(--primary);
}
.snap-label { flex: 1; font-size: 0.8125rem; }
.snap-value { font-size: 0.8125rem; font-weight: 800; color: var(--primary); }

/* ====================================================================== */
/* POS template (05 §4.2)                                                 */
/* ====================================================================== */

.cat-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--td-rule);
}
.cat-toolbar .icon { color: var(--muted-2); }
.cat-search {
  flex: 1; border: none; outline: none; font-size: 0.84375rem;
  background: transparent; color: var(--ink); height: 30px;
}
.cat-list { max-height: 430px; overflow-y: auto; }
.cat-row {
  display: flex; align-items: center; gap: 12px;
  padding: 7px 12px; border-bottom: 1px solid var(--border-3);
}
.cat-row:hover { background: var(--row-hover); }
.cat-code {
  width: 84px; flex: none;
  font-size: 0.71875rem; font-weight: 700; color: var(--muted-3);
  font-variant-numeric: tabular-nums;
}
.cat-name { flex: 1; font-size: 0.8125rem; min-width: 0; }
.cat-price { width: 76px; text-align: right; font-size: 0.8125rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.cat-add {
  width: 32px; height: 32px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: var(--radius-pill);
  background: var(--primary); color: var(--paper); cursor: pointer;
}
.cat-add:hover { background: var(--primary-dark); }

.cart-line {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; border-bottom: 1px solid var(--border-3);
}
.cart-name { flex: 1; font-size: 0.8125rem; }
.cart-price { font-size: 0.8125rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.cart-del {
  width: 28px; height: 28px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: var(--radius-pill);
  background: transparent; color: var(--danger); cursor: pointer;
}
.cart-del:hover { background: var(--danger-bg); }

.totals { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.total-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 0.8125rem; }
.total-line .val { font-weight: 600; font-variant-numeric: tabular-nums; }
.total-net {
  border-top: 1px dashed var(--border-1);
  padding-top: 8px;
  font-size: 0.90625rem; font-weight: 800;
}
.total-net .val { color: var(--primary); font-weight: 800; }
.total-due { color: var(--danger); font-weight: 700; }
.tender-row { display: flex; gap: 10px; }
.tender-row > * { flex: 1; }
.net-box {
  background: var(--primary-tint);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 8px 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.net-box .lbl { font-size: 0.75rem; font-weight: 800; color: var(--primary); text-transform: uppercase; letter-spacing: 0.04em; }
.net-box .val { font-size: 1.1875rem; font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; }
.pos-note { font-size: 0.71875rem; color: var(--muted-2); text-align: center; padding: 0 16px 12px; }

/* ====================================================================== */
/* Pipeline board (05 §4.3)                                               */
/* ====================================================================== */

.board { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; align-items: start; }
.board-col { background: var(--surface-2); border-radius: var(--radius-card); padding: 8px; min-height: 220px; }
.board-head { display: flex; align-items: center; gap: 6px; padding: 2px 2px 8px; }
.board-title { font-size: 0.71875rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; }
.board-count {
  margin-left: auto; background: var(--paper); border-radius: var(--radius);
  padding: 1px 7px; font-size: 0.6875rem; font-weight: 800; color: var(--muted-1);
}
.board-card {
  background: var(--paper);
  border: 1px solid var(--border-1);
  border-left: 3px solid var(--muted-3);
  border-radius: var(--radius);
  padding: 10px; margin-bottom: 8px;
}
.board-card .top { display: flex; align-items: baseline; gap: 6px; }
.board-id { font-size: 0.75rem; font-weight: 800; color: var(--primary); }
.board-time { margin-left: auto; font-size: 0.65625rem; color: var(--muted-3); }
.board-patient { font-size: 0.78125rem; font-weight: 700; margin-top: 3px; }
.board-tests { font-size: 0.6875rem; color: var(--muted-1); margin-top: 2px; line-height: 1.35; }
.board-hold { font-size: 0.65625rem; font-weight: 800; color: var(--danger); margin-top: 5px; display: flex; align-items: center; gap: 3px; }
.board-advance {
  width: 100%; min-height: 30px; margin-top: 8px;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  background: var(--app-bg);
  border: 1px solid var(--border-1); border-radius: var(--radius-pill);
  font: inherit; font-size: 0.71875rem; font-weight: 700; color: var(--ink-2);
  cursor: pointer; text-decoration: none;
}
.board-advance:hover { background: var(--primary-tint); color: var(--primary); border-color: var(--primary); text-decoration: none; }
.stage-pending_collection { border-left-color: var(--stage-pending); }
.stage-collected { border-left-color: var(--stage-collected); }
.stage-received { border-left-color: var(--stage-received); }
.stage-resulted { border-left-color: var(--stage-resulted); }
.stage-verified { border-left-color: var(--stage-verified); }
.stage-report_ready { border-left-color: var(--stage-verified); }
.stage-delivered { border-left-color: var(--stage-delivered); }
.stage-rejected { border-left-color: var(--stage-rejected); }
.ink-pending_collection { color: var(--stage-pending); }
.ink-collected { color: var(--stage-collected); }
.ink-received { color: var(--stage-received); }
.ink-resulted { color: var(--stage-resulted); }
.ink-verified { color: var(--stage-verified); }
.ink-report_ready { color: var(--stage-verified); }
.ink-delivered { color: var(--stage-delivered); }
.ink-rejected { color: var(--stage-rejected); }

/* worklist / queue panel */
.worklist-row {
  display: block; width: 100%; text-align: left;
  padding: 10px 14px; border: none; border-top: 1px solid var(--border-3);
  background: transparent; color: var(--ink); cursor: pointer; text-decoration: none;
}
.worklist-row:hover { background: var(--row-hover); text-decoration: none; color: var(--ink); }
.worklist-row.selected { background: var(--primary-tint); }
.worklist-id { font-size: 0.8125rem; font-weight: 700; color: var(--primary); }
.worklist-sub { font-size: 0.71875rem; color: var(--muted-2); margin-top: 2px; }

/* ====================================================================== */
/* Patient banner — one component, every patient-context screen (§7 U9)   */
/* ====================================================================== */

.patient-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--paper);
  border: 1px solid var(--border-1); border-radius: var(--radius-card);
}
.patient-banner .avatar { width: 44px; height: 44px; font-size: 0.9375rem; }
.patient-name { font-size: 1rem; font-weight: 800; }
.patient-meta { font-size: 0.78125rem; color: var(--muted-1); margin-top: 2px; }

/* ====================================================================== */
/* Approvals inbox                                                        */
/* ====================================================================== */

.approval-card {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 16px 18px; margin-bottom: 10px;
  background: var(--paper);
  border: 1px solid var(--border-1); border-radius: var(--radius-card);
}
.approval-icon {
  width: 40px; height: 40px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius); background: var(--warning-bg); color: var(--warning);
}
.approval-title { font-size: 0.875rem; font-weight: 700; }
.approval-sub { font-size: 0.78125rem; color: var(--muted-1); margin-top: 3px; }
.empty-card {
  border: 1px dashed var(--border-input); border-radius: var(--radius-card);
  padding: 36px; text-align: center; color: var(--muted-3);
  background: var(--paper);
}
.empty-card .icon { font-size: 36px; display: block; margin: 0 auto 10px; }

/* ====================================================================== */
/* Alerts, toasts, modal                                                  */
/* ====================================================================== */

.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px; border-radius: var(--radius);
  font-size: 0.8125rem; font-weight: 500;
  margin-bottom: 14px;
}
.alert.bad { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.alert.warn { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.alert.good { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.alert.info { background: var(--info-bg); color: var(--info); border: 1px solid var(--info-border); }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--paper);
  border-radius: var(--radius);
  padding: 11px 18px;
  display: flex; align-items: center; gap: 9px;
  font-size: 0.84375rem; font-weight: 600;
  box-shadow: var(--shadow-toast);
  animation: toastIn 0.22s ease;
  z-index: 90;
}
.toast .icon { color: var(--toast-ink); }

.modal-overlay {
  position: fixed; inset: 0;
  background: var(--overlay);
  z-index: 80;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
  padding: 20px;
}
.modal-shell { display: flex; flex-direction: column; gap: 10px; max-height: 94vh; }
.modal-tools { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }

/* ====================================================================== */
/* Print sheet (05 §6) — same layout on screen, on paper and in the PDF   */
/* ====================================================================== */

.sheet {
  width: 640px; max-width: 100%;
  background: var(--paper);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-modal);
  overflow-y: auto;
  padding: 28px 32px;
  font-size: 0.78125rem;
  color: var(--ink);
}
.sheet-head {
  display: flex; align-items: flex-start; gap: 12px;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 12px;
}
.sheet-mark {
  width: 42px; height: 42px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius); background: var(--primary); color: var(--paper);
  font-size: 1.25rem; font-weight: 800;
}
.sheet-hospital { font-size: 1.0625rem; font-weight: 800; }
.sheet-contact { font-size: 0.65625rem; color: var(--muted-1); margin-top: 2px; }
.sheet-doc { margin-left: auto; text-align: right; }
.sheet-doc-title {
  font-size: 0.8125rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--primary);
}
.sheet-doc-no { font-size: 0.6875rem; color: var(--muted-1); margin-top: 3px; }
.sheet-info { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; margin: 14px 0; }
.sheet-info div { font-size: 0.71875rem; }
.sheet-info .k { color: var(--muted-1); }
table.sheet-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
table.sheet-table th {
  text-align: left; font-size: 0.65625rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted-1); border-bottom: 1px solid var(--ink); padding: 5px 0;
}
table.sheet-table td { padding: 5px 0; font-size: 0.75rem; border-bottom: 1px solid var(--border-2); }
table.sheet-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.sheet-totals { margin-left: auto; width: 260px; margin-top: 10px; }
.sheet-total-line { display: flex; justify-content: space-between; font-size: 0.75rem; padding: 3px 0; }
.sheet-total-line.strong { font-weight: 800; border-top: 1px solid var(--ink); padding-top: 5px; }
.sheet-words { margin-top: 12px; font-size: 0.71875rem; }
.sheet-signs { display: flex; gap: 40px; margin-top: 34px; }
.sheet-sign { width: 170px; border-top: 1px solid var(--ink); padding-top: 5px; font-size: 0.6875rem; }
.sheet-foot {
  border-top: 1px solid var(--border-2); margin-top: 18px; padding-top: 8px;
  display: flex; justify-content: space-between;
  font-size: 0.59375rem; color: var(--muted-3);
}
.sheet-bn { font-family: var(--font-bn); }
.barcode {
  height: 34px; margin-top: 8px;
  background: repeating-linear-gradient(90deg,
    var(--barcode-ink) 0 2px, transparent 2px 5px,
    var(--barcode-ink) 5px 6px, transparent 6px 9px);
}
.barcode-text {
  font-size: 0.625rem; letter-spacing: 0.28em; text-align: center;
  color: var(--muted-3); margin-top: 3px;
}
.label-sheet { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.label-tile { border: 1px dashed var(--border-1); border-radius: var(--radius); padding: 8px 10px; }
.label-tile .who { font-size: 0.71875rem; font-weight: 700; }
.label-tile .what { font-size: 0.65625rem; color: var(--muted-1); }

/* ID card preview (registration) */
.idcard-panel { background: var(--rail); border-radius: var(--radius-card); padding: 16px; }
.idcard-cap {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--rail-muted-2); margin-bottom: 10px;
}
.idcard { background: var(--paper); border-radius: var(--radius); padding: 12px; }
.idcard-hosp { display: flex; align-items: center; gap: 8px; }
.idcard-mark {
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-pill); background: var(--primary); color: var(--paper);
  font-size: 0.75rem; font-weight: 800;
}
.idcard-name { font-size: 0.875rem; font-weight: 700; margin-top: 10px; }
.idcard-reg { font-size: 0.71875rem; color: var(--muted-1); margin-top: 2px; }

.dropzone {
  flex: 1; height: 110px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border: 1.5px dashed var(--border-input); border-radius: var(--radius);
  color: var(--muted-2); font-size: 0.71875rem;
  background: transparent; cursor: pointer;
}
.dropzone:hover { border-color: var(--primary); color: var(--primary); }

/* ====================================================================== */
/* Login                                                                  */
/* ====================================================================== */

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--rail);
}
.login-card {
  width: 400px; background: var(--paper);
  border-radius: var(--radius-card);
  padding: 30px 32px 32px;
  box-shadow: var(--shadow-modal);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-card h1 { margin: 0; font-size: 1.0625rem; font-weight: 700; }
.login-card .field { margin-bottom: 16px; }

/* ====================================================================== */
/* Print media — the sheet is the page (§7 U10)                           */
/* ====================================================================== */

@media print {
  .sidebar, .topbar, .status-footer, .modal-tools, .no-print, .toast { display: none !important; }
  .shell, .main, .content { display: block; height: auto; overflow: visible; min-width: 0; padding: 0; }
  .modal-overlay { position: static; background: none; padding: 0; display: block; }
  .modal-shell { max-height: none; }
  .sheet { width: auto; box-shadow: none; padding: 0; }
  body { background: var(--paper); }
}

/* ====================================================================== */
/* Thermal receipt (§5 M4 [M]) — 80 mm roll. The same document, re-flowed  */
/* for a counter POS printer instead of A4 (§7 U10, 05 §6).               */
/* ====================================================================== */

.sheet.thermal {
  width: 80mm;
  padding: 4mm 3mm;
  font-size: 0.6875rem;
  box-shadow: none;
}
.sheet.thermal .sheet-head { display: block; text-align: center; border-bottom-width: 1px; }
.sheet.thermal .sheet-mark { display: none; }
.sheet.thermal .sheet-doc { margin: 4px 0 0; text-align: center; }
.sheet.thermal .sheet-hospital { font-size: 0.8125rem; }
.sheet.thermal .sheet-info { grid-template-columns: 1fr; gap: 1px; margin: 6px 0; }
.sheet.thermal .sheet-totals { width: 100%; }
.sheet.thermal .sheet-signs { display: none; }
.sheet.thermal table.sheet-table th,
.sheet.thermal table.sheet-table td { font-size: 0.625rem; padding: 2px 0; }

@media print {
  /* The roll has no page furniture and no margins to spare. */
  .sheet.thermal { width: auto; padding: 0; }
  body:has(.sheet.thermal) { margin: 0; }
}
