/* ==========================================================================
   styles.css — Lab Intelligence Suite design system
   --------------------------------------------------------------------------
   Palette:  Primary Green #0B6E4F · Gold #C9A227 · White · Light Gray #F5F7F8
             Dark Text #1E293B
   Type:     Fraunces (display, restrained) / Inter (UI) / IBM Plex Mono (data,
             record IDs, QR labels — the "specimen label" signature)
   ========================================================================== */

:root {
  --green: #0B6E4F;
  --green-dark: #08543C;
  --green-tint: #E7F2ED;
  --gold: #C9A227;
  --gold-tint: #FBF3DC;
  --white: #FFFFFF;
  --gray-bg: #F5F7F8;
  --border: #E2E8F0;
  --text: #1E293B;
  --text-muted: #64748B;
  --danger: #B3413A;
  --danger-tint: #FBEBEA;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;

  --sidebar-w: 248px;
  --transition: 180ms cubic-bezier(.4,0,.2,1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--gray-bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; color: var(--text); }
p { margin: 0; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--text-muted); font-size: 13px; }
.is-hidden { display: none !important; }
.is-locked-field { background: var(--gray-bg); color: var(--text-muted); cursor: not-allowed; }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ------------------------------------------------------------------------ *
 * Sidebar
 * ------------------------------------------------------------------------ */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--green-dark);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform var(--transition);
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar__mark { color: var(--gold); font-size: 20px; line-height: 1; }
.sidebar__brand-text { display: flex; flex-direction: column; min-width: 0; }
.sidebar__brand-name {
  font-family: var(--font-display);
  color: var(--white);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar__brand-sub { color: rgba(255,255,255,0.55); font-size: 11px; letter-spacing: .04em; }

.sidebar__nav { flex: 1; padding: 14px 10px; overflow-y: auto; }
.sidebar__link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.75);
  font-size: 14px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.sidebar__icon { font-size: 15px; width: 18px; text-align: center; }
.sidebar__link:hover { background: rgba(255,255,255,0.06); color: var(--white); }
.sidebar__link.is-active {
  background: rgba(201,162,39,0.14);
  color: var(--white);
  border-left-color: var(--gold);
}
.sidebar__group-toggle {
  width: 100%; background: none; border: none; cursor: pointer; text-align: left;
  font-family: inherit;
}
.sidebar__caret { margin-left: auto; font-size: 11px; transition: transform var(--transition); }
.sidebar__group-toggle.is-open .sidebar__caret { transform: rotate(180deg); }
.sidebar__group {
  max-height: 0; overflow: hidden;
  transition: max-height var(--transition);
}
.sidebar__group.is-open { max-height: 900px; }
.sidebar__sublink { padding-left: 30px; font-size: 13.5px; }
.sidebar__subsublink { padding-left: 46px; font-size: 13px; }
.sidebar__footer {
  padding: 14px 20px;
  color: rgba(255,255,255,0.4);
  font-size: 11px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sidebar__support-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.16);
  color: rgba(255,255,255,0.65);
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
}
.sidebar__support-btn:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}
.support-modal__email {
  font-family: var(--font-mono, monospace);
  font-size: 14px;
  font-weight: 600;
  background: var(--surface-2, #f4f6f8);
  border: 1px solid var(--border, #e2e6ea);
  border-radius: 8px;
  padding: 10px 14px;
  margin-top: 8px;
  word-break: break-all;
}
.sidebar-scrim {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.4);
  z-index: 35;
}

/* ------------------------------------------------------------------------ *
 * App shell / header
 * ------------------------------------------------------------------------ */
.app-shell { margin-left: var(--sidebar-w); min-height: 100%; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 14px 28px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
}
.menu-toggle {
  display: none;
  background: none; border: none; font-size: 20px; color: var(--text);
}
.topbar__title { font-size: 19px; white-space: nowrap; }
.topbar__search {
  position: relative;
  flex: 1;
  max-width: 460px;
  display: flex; align-items: center;
}
.topbar__search-icon { position: absolute; left: 12px; color: var(--text-muted); font-size: 14px; pointer-events: none; }
.topbar__search .input { padding-left: 32px; }
.topbar__right { display: flex; align-items: center; gap: 16px; margin-left: auto; }
.topbar__date { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.icon-btn {
  background: var(--gray-bg); border: none; border-radius: 999px;
  width: 36px; height: 36px; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}
.topbar__notif { position: relative; }
.icon-btn--alert { position: relative; }
.icon-btn--alert::after {
  content: ''; position: absolute; top: 2px; right: 2px;
  width: 9px; height: 9px; border-radius: 999px;
  background: var(--danger); border: 2px solid var(--white);
}
.notif-popover {
  display: none; position: absolute; top: calc(100% + 8px); right: 0; width: 340px;
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); max-height: 440px; overflow-y: auto; z-index: 40;
}
.notif-popover.is-open { display: block; }
.notif-popover__section { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.notif-popover__section:last-child { border-bottom: none; }
.notif-popover__section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center;
}
.notif-popover__item {
  padding: 7px 0; font-size: 13px; cursor: pointer; border-bottom: 1px dashed var(--border);
  display: flex; justify-content: space-between; gap: 8px;
}
.notif-popover__item:last-child { border-bottom: none; }
.notif-popover__item:hover { color: var(--green); }
.notif-popover__item span:last-child { color: var(--text-muted); white-space: nowrap; }
.notif-popover__empty { padding: 18px 14px; text-align: center; color: var(--text-muted); font-size: 13px; }
.notif-popover__viewall { font-size: 12px; color: var(--green); cursor: pointer; font-weight: 600; }

.topbar__user { position: relative; display: flex; align-items: center; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 8px; }
.user-chip--trigger {
  background: none; border: none; padding: 4px; border-radius: var(--radius-sm);
  cursor: pointer; font: inherit; color: inherit; text-align: left;
}
.user-chip--trigger:hover { background: var(--gray-bg); }
.user-chip--trigger:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.user-chip__avatar {
  width: 34px; height: 34px; border-radius: 999px;
  background: var(--green); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; flex-shrink: 0;
}
.user-chip__meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-chip__name { font-size: 13px; font-weight: 600; }
.user-chip__role { font-size: 11px; color: var(--text-muted); }

/* --- User popover (avatar chip → Change Password + Theme) — mirrors .notif-popover --- */
.user-popover {
  display: none; position: absolute; top: calc(100% + 8px); right: 0; width: 300px;
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); max-height: 480px; overflow-y: auto; z-index: 40;
}
.user-popover.is-open { display: block; }
.user-popover__section { padding: 14px; border-bottom: 1px solid var(--border); }
.user-popover__section:last-child { border-bottom: none; }
.user-popover__section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); margin-bottom: 10px;
}
.user-popover__note { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.user-popover .password-field { margin-bottom: 10px; }
.user-popover .field { margin-bottom: 10px; }
.user-popover .field:last-of-type { margin-bottom: 0; }
.user-popover__theme-row { display: flex; gap: 10px; flex-wrap: wrap; }
.theme-swatch {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: none; border: none; padding: 2px; cursor: pointer; font: inherit; color: var(--text-muted);
  font-size: 11px; width: 60px;
}
.theme-swatch__dot {
  width: 34px; height: 34px; border-radius: 999px; border: 2px solid var(--border);
  box-shadow: inset 0 0 0 2px var(--white);
}
.theme-swatch--light .theme-swatch__dot { background: #f4f6f5; }
.theme-swatch--forest .theme-swatch__dot { background: #1f5c3f; }
.theme-swatch--ocean .theme-swatch__dot { background: #145a86; }
.theme-swatch--dark .theme-swatch__dot { background: #1c2430; }
.theme-swatch:hover .theme-swatch__dot { border-color: var(--green); }
.theme-swatch.is-active .theme-swatch__dot { border-color: var(--green); box-shadow: inset 0 0 0 2px var(--white), 0 0 0 2px var(--green); }
.theme-swatch.is-active { color: var(--text); font-weight: 600; }
.btn-link {
  background: none; border: none; padding: 0; cursor: pointer; font: inherit;
  color: var(--green); text-decoration: underline; display: block;
}
.btn-link:hover { color: var(--green-dark, var(--green)); }

.page-content { padding: 26px 28px 60px; max-width: 1240px; width: 100%; margin: 0 auto; }

/* ------------------------------------------------------------------------ *
 * Typography helpers
 * ------------------------------------------------------------------------ */
.page-title { font-size: 26px; margin-bottom: 4px; }
.page-subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 20px; display: block; }

/* ------------------------------------------------------------------------ *
 * Cards & grids
 * ------------------------------------------------------------------------ */
.card {
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 20px;
}
.card__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card__header h3 { font-size: 15px; font-weight: 600; }
.view-all-link { font-size: 12.5px; font-weight: 600; color: var(--green); text-decoration: none; }
.view-all-link:hover { text-decoration: underline; }
.perf-stat-list { display: flex; flex-direction: column; gap: 12px; }
.perf-stat-row { display: flex; align-items: center; justify-content: space-between; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.perf-stat-row:last-child { border-bottom: none; padding-bottom: 0; }
.perf-stat-row__label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.perf-stat-row__value { font-size: 17px; font-weight: 700; font-family: var(--font-mono); }
.perf-stat-row__value--green { color: var(--green); }
.perf-stat-row__value--gold { color: #8a6d13; }
.perf-stat-row__value--danger { color: var(--danger); }
.form-card { padding: 22px; }
.protocol-stage-card { border-top: 3px solid var(--green); margin-bottom: 0; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}
.card-grid--compact { grid-template-columns: repeat(6, 1fr); }
.card-grid .card { margin-bottom: 0; padding: 16px 18px; }

.two-col { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; align-items: start; }

.summary-card { display: flex; align-items: center; gap: 12px; }
.summary-card--clickable { cursor: pointer; }
.summary-card--clickable:hover { opacity: 0.8; }
.summary-card__icon {
  width: 42px; height: 42px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
  background: var(--green-tint); color: var(--green);
}
.summary-card__icon--gold { background: var(--gold-tint); color: var(--gold); }
.summary-card__icon--danger { background: var(--danger-tint); color: var(--danger); }
.summary-card__icon--neutral { background: var(--gray-bg); color: var(--text-muted); }
.summary-card__value { font-family: var(--font-display); font-size: 22px; font-weight: 600; line-height: 1; }
.summary-card__label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.stat-mini__value { font-family: var(--font-display); font-size: 24px; font-weight: 600; color: var(--green); }
.stat-mini__label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 14px 16px;
}
.stat-card--clickable { cursor: pointer; transition: box-shadow .12s, transform .12s; }
.stat-card--clickable:hover { box-shadow: var(--shadow-md, 0 4px 14px rgba(0,0,0,.08)); transform: translateY(-1px); border-color: var(--green); }
.stat-card__value { font-family: var(--font-display); font-size: 24px; font-weight: 600; line-height: 1; color: var(--text); }
.stat-card__label { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* ------------------------------------------------------------------------ *
 * Buttons
 * ------------------------------------------------------------------------ */
.btn {
  border: none; border-radius: var(--radius-sm);
  padding: 10px 16px; font-size: 13px; font-weight: 600;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
  display: inline-flex; align-items: center; gap: 6px;
}
.btn--primary { background: var(--green); color: var(--white); }
.btn--primary:hover { background: var(--green-dark); box-shadow: var(--shadow-sm); }
.btn--secondary { background: var(--gray-bg); color: var(--text); border: 1px solid var(--border); }
.btn--secondary:hover { background: #EEF1F3; }
.btn--danger { background: var(--danger-tint); color: var(--danger); }
.btn--danger:hover { background: #f6d9d7; }
.btn--tiny { padding: 6px 10px; font-size: 12px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ------------------------------------------------------------------------ *
 * Spinners & loading states
 * ------------------------------------------------------------------------ */
@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
  display: inline-block; width: 14px; height: 14px; flex: 0 0 auto;
  border: 2px solid rgba(255, 255, 255, 0.4); border-top-color: currentColor;
  border-radius: 50%; animation: spin 700ms linear infinite;
}
/* On light/neutral backgrounds (secondary buttons, page loaders) the
   translucent-white track reads as invisible — use a tinted-gray track
   there instead so the ring is visible against white/gray, not just white. */
.btn--secondary .spinner, .btn--danger .spinner, .spinner--tinted {
  border-color: rgba(30, 41, 59, 0.18); border-top-color: currentColor;
}
.btn.is-loading { cursor: progress; }

/* A centered "Loading…" block for a page or panel that's still waiting on
 * its first data (see UI.loadingBlock) — same shape as .empty-state so it
 * drops into the same layout slots without any extra CSS at the call site. */
.loading-block {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 48px 20px; color: var(--text-muted); text-align: center;
}
.loading-block .spinner { width: 22px; height: 22px; border-width: 3px; }
.loading-block__label { font-size: 13.5px; font-weight: 600; }

/* Full-screen overlay shown while the app's first cloud sync is still in
 * flight, right after sign-in and before the sidebar/page-content behind
 * it has real data to show. */
.boot-loader {
  position: fixed; inset: 0; z-index: 500;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; background: var(--gray-bg);
  transition: opacity 220ms ease, visibility 220ms ease;
}
.boot-loader.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-loader .spinner { width: 28px; height: 28px; border-width: 3px; color: var(--green); }
.boot-loader__brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-size: 20px; color: var(--text); }
.boot-loader__label { font-size: 13px; font-weight: 600; color: var(--text-muted); min-height: 18px; }

/* ------------------------------------------------------------------------ *
 * Forms
 * ------------------------------------------------------------------------ */
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 16px; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.input {
  font-size: 14px; color: var(--text);
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input:focus {
  outline: none; border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-tint);
}
textarea.input { resize: vertical; }

.password-field { position: relative; display: flex; }
.password-field .input { padding-right: 38px; }
.password-toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0;
  border: none; background: transparent; border-radius: var(--radius-sm);
  color: var(--text-muted); cursor: pointer;
  transition: color var(--transition), background var(--transition);
}
.password-toggle svg { width: 18px; height: 18px; }
.password-toggle:hover { color: var(--text); background: var(--gray-bg); }
.password-toggle:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.inline-form { display: block; }

/* Unified flow-step indicator — same pattern on every workflow module */
.flow-steps { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.flow-step {
  font-size: 11px; font-weight: 700; letter-spacing: .03em; color: var(--green);
  background: var(--green-tint); padding: 6px 12px; border-radius: 999px;
}
.flow-arrow { color: var(--border); font-size: 13px; }

.autofill-panel {
  margin-top: 16px; padding: 14px 16px;
  background: var(--green-tint); border-radius: var(--radius-sm);
}
.autofill-panel__title { font-size: 12px; font-weight: 700; color: var(--green); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 10px; }
.autofill-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.info-chip { display: flex; flex-direction: column; font-size: 12px; }
.info-chip span { color: var(--text-muted); }
.info-chip strong { font-family: var(--font-mono); font-size: 13px; }

.autofill-panel + .is-hidden, .autofill-panel ~ div { margin-top: 16px; }

/* Scan / search picker */
.scan-picker { position: relative; margin-top: 4px; }
.scan-picker__input-row { display: flex; align-items: center; gap: 8px; position: relative; }
.scan-picker__icon { position: absolute; left: 10px; color: var(--text-muted); }
.scan-picker__input-row .input { padding-left: 30px; flex: 1; }
.scan-picker__scan-btn { flex-shrink: 0; white-space: nowrap; }

.scanner-body { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.scanner-video { width: 100%; max-width: 380px; border-radius: var(--radius-md); background: #000; aspect-ratio: 1 / 1; object-fit: cover; }
.scanner-status { font-size: 13px; color: var(--text-muted); text-align: center; }
.scan-picker__results, #global-search-results {
  display: none;
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); max-height: 280px; overflow-y: auto; z-index: 30;
}
.scan-picker__results.is-open, #global-search-results.is-open { display: block; }
.scan-picker__item {
  padding: 10px 14px; font-size: 13px; border-bottom: 1px solid var(--border);
}
.scan-picker__item:last-child { border-bottom: none; }
.scan-picker__item:hover { background: var(--gray-bg); }
.scan-picker__empty { padding: 12px 14px; font-size: 13px; color: var(--text-muted); }
#global-search-results { min-width: 320px; }

/* ------------------------------------------------------------------------ *
 * Tables
 * ------------------------------------------------------------------------ */
.table-panel__search { margin-bottom: 14px; max-width: 320px; }
.table-scroll { overflow-x: auto; }
.table-panel__pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 12px; flex-wrap: wrap;
}
.table-panel__pager-info { font-size: 12px; color: var(--color-text-muted, #6b7280); }
.table-panel__pager-controls { display: flex; gap: 8px; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); padding: 10px 12px; border-bottom: 2px solid var(--border); white-space: nowrap;
}
.table th.is-sortable { cursor: pointer; user-select: none; }
.table th.is-sortable:hover { color: var(--green); }
.table th.is-sorted { color: var(--green); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr.is-clickable { cursor: pointer; }
.table tr.is-clickable:hover td { background: var(--green-tint); }
.table-empty { text-align: center; color: var(--text-muted); padding: 30px !important; }
.qr-thumb { width: 40px; height: 40px; display: flex; }
.qr-thumb canvas, .qr-thumb img { width: 40px !important; height: 40px !important; }
.row-actions { display: flex; gap: 6px; }

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge--green { background: var(--green-tint); color: var(--green); }
.badge--gold { background: var(--gold-tint); color: #8a6d13; }
.badge--danger { background: var(--danger-tint); color: var(--danger); }
.badge--neutral { background: var(--gray-bg); color: var(--text-muted); }

/* ------------------------------------------------------------------------ *
 * Empty state
 * ------------------------------------------------------------------------ */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state p { margin-bottom: 16px; }

.checkbox-group { margin-bottom: 14px; }
.checkbox-group__label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; }
.checkbox-group__items { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.checkbox-item { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text); cursor: pointer; }
.checkbox-item input { accent-color: var(--green); width: 15px; height: 15px; }

/* ------------------------------------------------------------------------ *
 * Task list / activity (Dashboard)
 * ------------------------------------------------------------------------ */
.task-list { display: flex; flex-direction: column; gap: 4px; }
.task-row { display: flex; align-items: center; gap: 10px; padding: 9px 4px; font-size: 14px; cursor: pointer; }
.task-row input { accent-color: var(--green); width: 16px; height: 16px; }
.task-row__label.is-done { text-decoration: line-through; color: var(--text-muted); }

.activity-list { display: flex; flex-direction: column; gap: 2px; }
.activity-row {
  display: grid; grid-template-columns: 90px 1fr auto; gap: 10px;
  font-size: 13px; padding: 8px 4px; border-bottom: 1px solid var(--border);
}
.activity-row:last-child { border-bottom: none; }
.activity-row__id { font-family: var(--font-mono); color: var(--green); font-size: 12px; }
.activity-row__date { color: var(--text-muted); font-size: 12px; white-space: nowrap; }

/* ------------------------------------------------------------------------ *
 * Modal
 * ------------------------------------------------------------------------ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal {
  background: var(--white); border-radius: var(--radius-lg);
  width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal--wide { max-width: 760px; }
.modal__header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal__header h3 { font-size: 16px; }
.modal__close { background: none; border: none; font-size: 15px; color: var(--text-muted); }
.modal__body { padding: 22px; }
body.no-scroll { overflow: hidden; }

.result-panel { display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.bottle-result-list { display: flex; flex-wrap: wrap; gap: 6px; }
.bottle-chip { font-family: var(--font-mono); font-size: 11.5px; background: var(--gray-bg); border-radius: 6px; padding: 4px 6px 4px 8px; display: inline-flex; align-items: center; gap: 6px; }
.bottle-chip__print { background: none; border: none; font-size: 12px; padding: 2px 4px; border-radius: 4px; color: var(--green); }
.bottle-chip__print:hover { background: var(--green-tint); }
.bottle-chip--more { color: var(--text-muted); }
.table-actions { display: flex; gap: 6px; }
.clone-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.clone-row { display: flex; align-items: center; gap: 10px; }
.clone-row__label { font-weight: 600; font-size: 13px; min-width: 64px; color: var(--text); }
.clone-row input { max-width: 100px; }

/* ------------------------------------------------------------------------ *
 * Specimen label — signature component (QR + printed label look)
 * ------------------------------------------------------------------------ */
.specimen-label {
  display: flex; gap: 14px; align-items: center;
  border: 1px dashed #c9c9c9; border-radius: var(--radius-sm);
  padding: 12px 14px; background: repeating-linear-gradient(135deg, #fff, #fff 10px, #fcfcfa 10px, #fcfcfa 20px);
}
.specimen-label__id { font-family: var(--font-mono); font-weight: 700; font-size: 15px; color: var(--green); }
.specimen-label__title { font-size: 12.5px; color: var(--text); margin-top: 2px; }
.specimen-label__field { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.specimen-label__field span { display: inline-block; min-width: 44px; color: #94A3B8; }
.specimen-label__qr-col { flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.specimen-label__qr canvas, .specimen-label__qr img { width: 58px !important; height: 58px !important; }
.specimen-label__pwdw { font-size: 9.5px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.qr-fallback { font-family: var(--font-mono); font-size: 10px; display:flex; align-items:center; justify-content:center; border:1px solid var(--border); }
.print-preview { align-self: flex-start; }
.print-tip {
  font-size: 12px; color: var(--text-muted); background: var(--gray-bg);
  border-radius: var(--radius-sm); padding: 9px 12px; line-height: 1.5;
}

.profile-photo, .profile-photo__placeholder {
  width: 88px; height: 88px; border-radius: var(--radius-md); flex-shrink: 0;
  background: var(--gray-bg); display: flex; align-items: center; justify-content: center; overflow: hidden;
  font-size: 30px;
}
.profile-photo img { width: 100%; height: 100%; object-fit: cover; }
.profile-header { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.profile-header__main { flex: 1; min-width: 240px; }
.profile-header__id { font-family: var(--font-mono); color: var(--green); font-weight: 600; font-size: 13px; }
.profile-qr { flex-shrink: 0; }
.profile-info { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 20px; margin-top: 14px; }
.profile-info__row { display: flex; justify-content: space-between; font-size: 13px; border-bottom: 1px dotted var(--border); padding-bottom: 4px; gap: 10px; }
.profile-info__label { color: var(--text-muted); }
.profile-actions { display: flex; gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.back-link { display: inline-block; margin-bottom: 14px; font-size: 13px; color: var(--green); font-weight: 600; }

/* ------------------------------------------------------------------------ *
 * Traceability
 * ------------------------------------------------------------------------ */
.trace-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.trace-alert {
  margin-top: 14px; padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--danger-tint); color: var(--danger); font-size: 13px; font-weight: 600;
}
.trace-timeline { display: flex; flex-direction: column; }
.trace-node { display: flex; gap: 16px; }
.trace-node__rail { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; }
.trace-node__marker {
  width: 34px; height: 34px; border-radius: 999px; flex-shrink: 0;
  background: var(--green-tint); display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.trace-node__line { width: 2px; background: var(--border); flex: 1; margin: 4px 0; min-height: 24px; }
.trace-node__body { flex: 1; padding-bottom: 22px; min-width: 0; }
.trace-node__header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; font-size: 14px; }

/* ------------------------------------------------------------------------ *
 * Reports
 * ------------------------------------------------------------------------ */
.report-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.report-tab {
  background: var(--gray-bg); border: 1px solid var(--border); border-radius: 999px;
  padding: 7px 14px; font-size: 12.5px; font-weight: 600; color: var(--text-muted);
}
.report-tab.is-active { background: var(--green); border-color: var(--green); color: var(--white); }
.export-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.export-bar__actions { display: flex; gap: 8px; }

/* ------------------------------------------------------------------------ *
 * Settings
 * ------------------------------------------------------------------------ */
.logo-preview { width: 100%; max-width: 160px; min-height: 44px; display: flex; align-items: center; font-size: 12px; color: var(--text-muted); }
.logo-preview img { max-width: 100%; max-height: 60px; }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--green-tint); color: var(--green);
  padding: 5px 6px 5px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
}
.chip__remove { background: none; border: none; color: var(--green); font-size: 11px; width: 18px; height: 18px; border-radius: 999px; }
.chip__remove:hover { background: rgba(11,110,79,0.15); }
.inline-add { display: flex; gap: 8px; }
.inline-add .input { flex: 1; }

/* ------------------------------------------------------------------------ *
 * Charts
 * ------------------------------------------------------------------------ */
.chart-canvas { width: 100%; height: 200px; display: block; }

/* ------------------------------------------------------------------------ *
 * Toasts
 * ------------------------------------------------------------------------ */
.toast-host { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--text); color: var(--white);
  padding: 11px 18px; border-radius: var(--radius-sm);
  font-size: 13.5px; box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(8px);
  transition: opacity var(--transition), transform var(--transition);
}
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast--danger { background: var(--danger); }
.toast--success { background: var(--green-dark); }

/* ------------------------------------------------------------------------ *
 * Auth gate
 * ------------------------------------------------------------------------ */
.auth-gate { display: none; }
body.auth-locked .auth-gate {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px; background: var(--gray-bg);
}
body.auth-locked .sidebar,
body.auth-locked .sidebar-scrim,
body.auth-locked .app-shell,
body.auth-locked .toast-host { display: none; }

/* ------------------------------------------------------------------------ *
 * Super Admin shell — a separate top-level container from the normal
 * sidebar/app-shell, since the platform dashboard isn't a tenant page.
 * Hidden by default; body.super-admin-mode (set by startSuperAdminApp())
 * swaps which shell is visible. Reuses .topbar/.page-content/.card/.table
 * styling from the main app rather than introducing a parallel design.
 * ------------------------------------------------------------------------ */
#super-admin-app { display: none; }
body.super-admin-mode .sidebar,
body.super-admin-mode .sidebar-scrim,
body.super-admin-mode .app-shell { display: none; }
body.super-admin-mode #super-admin-app { display: block; min-height: 100%; }
.super-admin-topbar__brand { display: flex; align-items: center; gap: 8px; font-weight: 600; white-space: nowrap; }
.super-admin-topbar__badge { background: var(--gold-tint); color: #8a6d13; font-size: 11px; font-weight: 700; letter-spacing: .03em; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; }
.module-toggle { display: inline-flex; align-items: center; gap: 8px; padding: 6px 0; }
.module-toggle__name { font-size: 13px; font-weight: 500; width: 100px; }
.lab-profile__section { margin-bottom: 18px; }
.lab-profile__section h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: 8px; }
.lab-profile__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; }
.lab-profile__row { display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; }
.lab-profile__row span:first-child { font-size: 11px; color: var(--text-muted); }

.auth-card {
  background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 32px; width: 100%; max-width: 400px;
}
.auth-card__logo {
  display: block; width: auto; height: auto;
  max-width: 100%; max-height: 88px;
  object-fit: contain;
  margin: 0 auto 18px; /* centered above the brand row */
}
.auth-card__brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-size: 17px; font-weight: 600; color: var(--green-dark);
  margin-bottom: 22px;
}
.auth-card__brand .sidebar__mark { color: var(--gold); font-size: 20px; }
.auth-tabs { display: flex; gap: 6px; background: var(--gray-bg); padding: 4px; border-radius: var(--radius-sm); margin-bottom: 18px; }
.auth-tab { flex: 1; border: none; background: none; padding: 9px 0; border-radius: 6px; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.auth-tab.is-active { background: var(--white); color: var(--green); box-shadow: var(--shadow-sm); }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-submit { width: 100%; justify-content: center; padding: 11px; margin-top: 4px; }
.auth-forgot-link { background: none; border: none; padding: 0; margin: -6px 0 2px; color: var(--accent, #2f7d5f); font-size: 12px; text-align: right; cursor: pointer; text-decoration: underline; align-self: flex-end; }
.auth-back-link { background: none; border: none; padding: 0; margin-top: 16px; color: var(--text-muted); font-size: 12px; text-align: center; cursor: pointer; text-decoration: underline; width: 100%; }
.auth-hint { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.auth-privacy-notice { font-size: 11px; color: var(--text-muted); line-height: 1.5; text-align: center; margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--border, #e5e5e5); }
.auth-privacy-link { color: var(--green); text-decoration: underline; cursor: pointer; }
.legal-policy-body { font-size: 13px; line-height: 1.6; color: var(--text); max-height: 60vh; overflow-y: auto; }
.legal-policy-body h4 { margin: 16px 0 6px; font-size: 14px; }
.legal-policy-body h4:first-child { margin-top: 0; }
.auth-error {
  background: var(--danger-tint); color: var(--danger); font-size: 13px; font-weight: 600;
  padding: 9px 12px; border-radius: var(--radius-sm); margin-bottom: 14px;
}
.auth-footnote { font-size: 11px; color: var(--text-muted); margin-top: 18px; line-height: 1.5; text-align: center; }

/* ------------------------------------------------------------------------ *
 * Read-only / permission notices
 * ------------------------------------------------------------------------ */
.readonly-notice {
  display: flex; align-items: center; gap: 10px;
  background: var(--gold-tint); color: #8a6d13; font-size: 13px; font-weight: 600;
  padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px;
}

/* ------------------------------------------------------------------------ *
 * Users & Access (Settings)
 * ------------------------------------------------------------------------ */
.user-row { display: grid; grid-template-columns: 1fr 1fr auto auto auto auto auto; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.user-row:last-child { border-bottom: none; }
.user-row__name { font-weight: 600; }
.user-row__username { color: var(--text-muted); font-family: var(--font-mono); font-size: 12px; }
.user-row__password { color: var(--text-muted); font-family: var(--font-mono); font-size: 12px; min-width: 76px; }
@media (max-width: 720px) { .user-row { grid-template-columns: 1fr 1fr; } }

/* ------------------------------------------------------------------------ *
 * Additional themes — Forest Green & Ocean Blue reskin the whole app by
 * overriding the same tokens every component already uses; Slate Dark
 * reuses the existing dark-mode rules below, just exposed under a clearer
 * name in Settings.
 * ------------------------------------------------------------------------ */
body.theme-forest {
  --green: #1B4332; --green-dark: #122E22; --green-tint: #E3ECE7;
  --gold: #B08D57; --gold-tint: #F3EBDD;
}
body.theme-ocean {
  --green: #0B5E8E; --green-dark: #084A70; --green-tint: #E3F0F8;
  --gold: #2A9D8F; --gold-tint: #E1F3F1;
}

/* ------------------------------------------------------------------------ *
 * Dark theme (optional, toggled via Settings)
 * ------------------------------------------------------------------------ */
body.theme-dark {
  background: #0F1720; color: #E2E8F0;
}
body.theme-dark .topbar,
body.theme-dark .card,
body.theme-dark .modal { background: #16202B; border-color: #223041; color: #E2E8F0; }
body.theme-dark h1, body.theme-dark h2, body.theme-dark h3 { color: #F1F5F9; }
body.theme-dark .input { background: #101922; border-color: #2A3A4C; color: #E2E8F0; }
body.theme-dark .table th { color: #94A3B8; border-color: #223041; }
body.theme-dark .table td { border-color: #223041; }
body.theme-dark .gray-bg, body.theme-dark .step, body.theme-dark .bottle-chip { background: #1C2836; }

/* ------------------------------------------------------------------------ *
 * Responsive
 * ------------------------------------------------------------------------ */
@media (max-width: 1080px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .card-grid--compact { grid-template-columns: repeat(3, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-scrim { display: block; }
  .app-shell { margin-left: 0; }
  .menu-toggle { display: block; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; gap: 10px; }
  .topbar__title { display: none; }
  .topbar__search { order: 3; max-width: none; flex-basis: 100%; }
  .topbar__date { display: none; }
  .page-content { padding: 18px 16px 50px; }
}

@media (max-width: 600px) {
  .card-grid, .card-grid--compact { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .profile-info { grid-template-columns: 1fr; }
  .user-chip__meta { display: none; }
  /* Anchored-to-the-bell popover overflows off a narrow screen at width:340px
     — pin it to the viewport instead so it's always fully visible and its
     own scroll (not the page's) handles content taller than the screen. */
  .notif-popover {
    position: fixed; top: 64px; left: 10px; right: 10px; width: auto;
    max-height: calc(100vh - 84px); z-index: 90;
  }
  .user-popover {
    position: fixed; top: 64px; left: 10px; right: 10px; width: auto;
    max-height: calc(100vh - 84px); z-index: 90;
  }
}

/* ------------------------------------------------------------------------ *
 * Shipping Documents (Invoices & Packing Lists)
 * ------------------------------------------------------------------------ */
.ship-doc {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 28px 30px; font-family: var(--font-body); color: var(--text);
}
.ship-doc__header { display: flex; justify-content: space-between; gap: 18px; flex-wrap: wrap; border-bottom: 2px solid var(--green); padding-bottom: 16px; margin-bottom: 18px; }
.ship-doc__brand { display: flex; gap: 12px; align-items: flex-start; }
.ship-doc__logo { width: 56px; height: 56px; object-fit: contain; }
.ship-doc__lab-name { font-family: var(--font-display); font-weight: 600; font-size: 18px; color: var(--green-dark); }
.ship-doc__lab-meta { font-size: 11.5px; color: var(--text-muted); line-height: 1.5; white-space: pre-line; }
.ship-doc__title-block { text-align: right; }
.ship-doc__doctype { font-family: var(--font-display); font-weight: 600; font-size: 22px; color: var(--text); letter-spacing: .03em; }
.ship-doc__docmeta { margin-top: 6px; font-size: 12px; color: var(--text-muted); }
.ship-doc__docmeta div { display: flex; justify-content: flex-end; gap: 6px; }
.ship-doc__docmeta span { font-weight: 600; color: var(--text); }
.ship-doc__parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.ship-doc__label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: 6px; }
.ship-doc__customer-name { font-weight: 700; font-size: 14px; }
.ship-doc__parties div div { font-size: 12.5px; line-height: 1.6; }
.ship-doc__table { width: 100%; border-collapse: collapse; margin-bottom: 18px; font-size: 12.5px; }
.ship-doc__table th { text-align: left; background: var(--green-tint); color: var(--green-dark); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.ship-doc__table td { padding: 7px 10px; border-bottom: 1px solid var(--border); }
.ship-doc__table th.num, .ship-doc__table td.num { text-align: right; }
.ship-doc__footer { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 26px; }
.ship-doc__remarks { flex: 1; min-width: 200px; font-size: 12.5px; color: var(--text-muted); }
.ship-doc__remarks p { margin: 4px 0 0; white-space: pre-line; }
.ship-doc__totals { min-width: 220px; font-size: 13px; }
.ship-doc__totals > div { display: flex; justify-content: space-between; padding: 4px 0; }
.ship-doc__grand { border-top: 2px solid var(--text); margin-top: 6px; padding-top: 8px !important; font-size: 15px; font-weight: 700; color: var(--green-dark); }
.ship-doc__signoff { display: flex; gap: 40px; margin-top: 30px; }
.ship-doc__terms { margin-bottom: 22px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-muted); }
.ship-doc__terms p { margin: 4px 0 0; white-space: pre-line; line-height: 1.5; }
.ship-doc__sign-box { flex: 1; border-top: 1px solid var(--text-muted); padding-top: 6px; font-size: 11px; color: var(--text-muted); text-align: center; }
.ship-doc__sign-img { display: block; max-height: 46px; max-width: 160px; margin: 0 auto 4px; object-fit: contain; }

.doc-type-toggle { display: flex; align-items: center; gap: 10px 18px; flex-wrap: wrap; background: var(--gray-bg); border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 16px; }
.doc-type-toggle label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; cursor: pointer; }
.doc-number-preview { font-family: var(--font-mono); font-weight: 700; color: var(--green); font-size: 15px; }
.source-picker-tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.source-picker-tabs button.is-active { background: var(--green); color: var(--white); border-color: var(--green); }

@media print {
  body * { visibility: hidden; }
  .ship-doc, .ship-doc * { visibility: visible; }
  .ship-doc { position: absolute; top: 0; left: 0; width: 100%; border: none; padding: 0; }
}
