/* =====================================================================
   Agent & Staff Governance — design system
   A restrained, document/ledger-inspired palette: warm paper surfaces,
   deep ink text, a single brass accent reserved for primary actions
   and focus states. One variable typeface used throughout; its width
   axis differentiates dense tabular contexts from display headings
   instead of introducing a second family.
   ===================================================================== */

@font-face {
  font-family: 'Instrument Sans Variable';
  src: url('/fonts/instrument-sans-latin-wght-normal.woff2') format('woff2-variations');
  font-weight: 380 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Instrument Sans Variable';
  src: url('/fonts/instrument-sans-latin-wght-italic.woff2') format('woff2-variations');
  font-weight: 380 800;
  font-style: italic;
  font-display: swap;
}

/* Inter (the Enterprise theme's typeface), served locally like Instrument Sans. */
@font-face {
  font-family: 'Inter Variable';
  src: url('/fonts/inter-latin-wght-normal.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Inter Variable';
  src: url('/fonts/inter-latin-wght-italic.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

/* Base tokens. The signed-in company's theme (System → Themes, src/lib/themes.js)
   overrides these per company through <style id="company-theme">; the palette
   picker's other choices override them per person. */
:root {
  /* Color */
  --ink-900: #12182a;
  --ink-700: #3c4557;
  --ink-500: #5a6679;
  --ink-300: #9aa1b2;
  --paper-0: #faf9f5;
  --paper-100: #f2efe6;
  --paper-200: #eae5d6;
  --line: #ded8c6;
  --line-strong: #c3bca4;
  --white: #ffffff;

  --brass-700: #6e4a18;
  --brass-600: #8b5e1f;
  --brass-500: #a5731f;
  --brass-100: #f3e6cc;
  --brass-050: #faf3e4;

  --green-600: #2e6b4e;
  --green-100: #e1efe6;
  --red-600: #a23b34;
  --red-100: #f6e4e1;
  --amber-600: #9c6b14;
  --amber-100: #f3e8ce;
  --blue-600: #33587a;
  --blue-100: #e5edf4;

  /* Theme-able surfaces (see "Themes" at the end of this file) */
  --inverse-bg: #12182a;       /* sidebar, toasts, active chips */
  --sidebar-fg: #c4c9d6;
  --sidebar-muted: #98a1b8;
  --sidebar-active: rgba(139, 94, 31, 0.35);
  --on-accent: #ffffff;
  --on-inverse: #ffffff;       /* strong text on the sidebar / dark chips */
  --inverse-line: rgba(255, 255, 255, 0.08);
  --inverse-hover: rgba(255, 255, 255, 0.06);

  /* Type scale (approx. 1.2 modular) */
  --fs-11: 0.6875rem;
  --fs-13: 0.8125rem;
  --fs-14: 0.875rem;
  --fs-16: 1rem;
  --fs-19: 1.1875rem;
  --fs-23: 1.4375rem;
  --fs-28: 1.75rem;
  --fs-34: 2.125rem;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;

  --shadow-sm: 0 1px 2px rgba(18, 24, 42, 0.06);
  --shadow-md: 0 6px 20px -6px rgba(18, 24, 42, 0.18);
  --shadow-lg: 0 16px 48px -12px rgba(18, 24, 42, 0.28);

  --sidebar-w: 248px;
  --sidebar-w-collapsed: 68px;
  --topbar-h: 60px;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; font-size: var(--font-size-base, 16px); }
body {
  margin: 0;
  font-family: var(--font-sans, 'Instrument Sans Variable', system-ui, sans-serif);
  font-variation-settings: 'wght' 420;
  color: var(--ink-900);
  background: var(--paper-0);
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
  font-size: var(--fs-16);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

h1, h2, h3, h4 { margin: 0; font-variation-settings: 'wght' 620; letter-spacing: -0.01em; color: var(--ink-900); }
h1 { font-size: var(--fs-34); font-variation-settings: 'wght' 640, 'wdth' 108; }
h2 { font-size: var(--fs-23); }
h3 { font-size: var(--fs-19); }
p { margin: 0 0 0.75em; color: var(--ink-700); }
a { color: var(--brass-700); text-decoration: none; }
a:hover { text-decoration: underline; }
.alert .text-sm, .alert small, .alert code, .alert .text-muted { color: inherit; }
.captcha-question { margin: 0; font-size: var(--fs-14); color: var(--ink-900); font-variation-settings: 'wght' 560; }
/* Links inside text (a table cell, a sentence, a hint) are underlined, so they are not told apart by colour alone (WCAG 1.4.1). */
p a:not(.btn), li a:not(.btn), td a:not(.btn):not(.badge), .landing-foot a, .alert a:not(.btn), .field-hint a, .text-sm a:not(.btn) { text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
small, .text-sm { font-size: var(--fs-13); color: var(--ink-500); }
.text-muted { color: var(--ink-500); }
::selection { background: var(--brass-100); }

:focus-visible {
  outline: 2px solid var(--brass-500);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ---------- Layout shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--inverse-bg);
  color: var(--sidebar-fg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width 0.2s var(--ease), flex-basis 0.2s var(--ease);
  overflow: hidden;
  z-index: 30;
}
.sidebar.is-collapsed { width: var(--sidebar-w-collapsed); flex-basis: var(--sidebar-w-collapsed); }
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--inverse-line, rgba(255,255,255,0.08));
  white-space: nowrap;
}
.sidebar-brand img { width: 30px; height: 30px; border-radius: 6px; object-fit: contain; background: #fff; flex: none; }
.sidebar-brand .brand-name { font-size: var(--fs-14); font-variation-settings: 'wght' 600; color: var(--on-inverse, #fff); overflow: hidden; text-overflow: ellipsis; }
.sidebar-brand .brand-sub { font-size: var(--fs-11); color: var(--sidebar-muted); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px 20px; }
.nav-group { margin-bottom: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: var(--radius-md);
  color: var(--sidebar-fg); font-size: var(--fs-14);
  cursor: pointer; white-space: nowrap; user-select: none;
}
.nav-item svg { width: 17px; height: 17px; flex: none; opacity: 0.9; }
.nav-item:hover { background: var(--inverse-hover, rgba(255,255,255,0.06)); color: var(--on-inverse, #fff); text-decoration: none; }
.nav-item.is-active { background: var(--sidebar-active); color: var(--on-inverse, #fff); box-shadow: inset 3px 0 0 var(--brass-500); }
.nav-children { margin-left: 29px; margin-top: 2px; margin-bottom: 6px; border-left: 1px solid var(--inverse-line, rgba(255,255,255,0.1)); padding-left: 12px; }
.nav-children .nav-item { padding: 7px 10px; font-size: var(--fs-13); color: var(--sidebar-muted); }
.nav-children .nav-subhead { cursor: default; font-size: var(--fs-11); text-transform: uppercase; letter-spacing: .05em; opacity: .8; padding-top: 9px; }
.nav-children .nav-subhead:hover { background: transparent; }
.nav-children .nav-item.is-active { color: var(--on-inverse, #fff); background: transparent; font-variation-settings: 'wght' 600; }
.nav-toggle { width: 16px; height: 16px; margin-left: auto; opacity: 0.6; transition: transform 0.15s var(--ease); }
.nav-group.is-open .nav-toggle { transform: rotate(90deg); }
.nav-group:not(.is-open) .nav-children { display: none; }
.sidebar.is-collapsed .brand-sub,
.sidebar.is-collapsed .brand-name,
.sidebar.is-collapsed .nav-label,
.sidebar.is-collapsed .nav-toggle,
.sidebar.is-collapsed .nav-children { display: none; }
.sidebar.is-collapsed .nav-item { justify-content: center; }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--inverse-line, rgba(255,255,255,0.08)); }
.collapse-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: none; color: #98a1b8; font-size: var(--fs-13);
  padding: 8px 10px; border-radius: var(--radius-md); cursor: pointer;
}
.collapse-btn:hover { background: var(--inverse-hover, rgba(255,255,255,0.06)); color: var(--on-inverse, #fff); }
.collapse-btn svg { width: 16px; height: 16px; transition: transform 0.2s var(--ease); }
.sidebar.is-collapsed .collapse-btn svg { transform: rotate(180deg); }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h); flex: 0 0 var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 22px; background: var(--paper-0);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar .page-title { font-size: var(--fs-16); font-variation-settings: 'wght' 600; }
.topbar-spacer { flex: 1; }
.mobile-menu-btn { display: none; background: none; border: none; cursor: pointer; padding: 6px; color: var(--ink-700); }
.mobile-menu-btn svg { width: 22px; height: 22px; }

.icon-btn {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md); border: 1px solid transparent; background: none; cursor: pointer; color: var(--ink-700);
  position: relative;
}
.icon-btn:hover { background: var(--paper-100); border-color: var(--line); }
.icon-btn svg { width: 18px; height: 18px; }
.notif-dot { position: absolute; top: 6px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--red-600); border: 1.5px solid var(--paper-0); }

.profile-menu { position: relative; }
.profile-trigger { display: flex; align-items: center; gap: 9px; background: none; border: none; cursor: pointer; padding: 4px 6px 4px 4px; border-radius: 999px; }
.profile-trigger:hover { background: var(--paper-100); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--brass-100); color: var(--brass-700);
  display: flex; align-items: center; justify-content: center; font-size: var(--fs-13); font-variation-settings: 'wght' 650;
  flex: none;
}
.profile-name { font-size: var(--fs-13); color: var(--ink-900); font-variation-settings: 'wght' 560; text-align: left; line-height: 1.25; }
.profile-role { display: block; font-size: 11px; color: var(--ink-500); font-variation-settings: 'wght' 420; }

.dropdown-panel {
  position: absolute; top: calc(100% + 8px); right: 0; min-width: 220px;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md); padding: 6px; z-index: 50;
  opacity: 0; transform: translateY(-4px) scale(0.98); pointer-events: none;
  transition: opacity 0.14s var(--ease), transform 0.14s var(--ease);
}
.dropdown-panel.is-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.dropdown-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); font-size: var(--fs-14); color: var(--ink-700); cursor: pointer; }
.dropdown-item:hover { background: var(--paper-100); text-decoration: none; }
.dropdown-item svg { width: 16px; height: 16px; }
.dropdown-divider { height: 1px; background: var(--line); margin: 5px 4px; }

.content { flex: 1; padding: 26px 28px 60px; max-width: 1320px; width: 100%; margin: 0 auto; }
.content.is-narrow { max-width: 760px; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: var(--fs-28); }
.page-head .lede { color: var(--ink-500); font-size: var(--fs-14); margin-top: 4px; }
.page-actions { display: flex; gap: 10px; flex: none; }
.breadcrumb { font-size: var(--fs-13); color: var(--ink-500); margin-bottom: 6px; }
.breadcrumb a { color: var(--ink-500); }
.breadcrumb .sep { margin: 0 6px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-size: var(--fs-14); font-variation-settings: 'wght' 560;
  padding: 9px 16px; border-radius: var(--radius-md); border: 1px solid transparent;
  cursor: pointer; transition: background 0.14s var(--ease), border-color 0.14s var(--ease), color 0.14s var(--ease), transform 0.05s;
  line-height: 1.1;
}
.btn svg { width: 15px; height: 15px; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--brass-600); border-color: var(--brass-600); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brass-700); border-color: var(--brass-700); text-decoration: none; }
.btn-secondary { background: var(--white); border-color: var(--line-strong); color: var(--ink-900); }
.btn-secondary:hover:not(:disabled) { background: var(--paper-100); text-decoration: none; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-700); }
.btn-ghost:hover:not(:disabled) { background: var(--paper-100); text-decoration: none; }
.btn-danger { background: var(--white); border-color: var(--red-600); color: var(--red-600); }
.btn-danger:hover:not(:disabled) { background: var(--red-100); text-decoration: none; }
.btn-danger-solid { background: var(--red-600); border-color: var(--red-600); color: #fff; }
.btn-danger-solid:hover:not(:disabled) { filter: brightness(0.9); text-decoration: none; }
.btn-sm { padding: 6px 11px; font-size: var(--fs-13); }
.btn-block { width: 100%; }
.btn-icon-only { padding: 8px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 18px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.field-row.cols-4 { grid-template-columns: repeat(4, 1fr); }
label, .field-label { display: block; font-size: var(--fs-13); font-variation-settings: 'wght' 580; color: var(--ink-900); margin-bottom: 6px; }
.field-label .optional { color: var(--ink-500); font-variation-settings: 'wght' 400; }
.field-hint { font-size: var(--fs-13); color: var(--ink-500); margin-top: 5px; }
.field-error { font-size: var(--fs-13); color: var(--red-600); margin-top: 5px; display: flex; align-items: center; gap: 5px; }
.field-error svg { width: 13px; height: 13px; flex: none; }
.required-mark { color: var(--red-600); margin-left: 2px; }

.input, select.input, textarea.input {
  width: 100%; font-family: inherit; font-size: var(--fs-14); color: var(--ink-900);
  padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-md);
  background: var(--white); transition: border-color 0.14s var(--ease), box-shadow 0.14s var(--ease);
}
.input::placeholder { color: var(--ink-300); }
.input:focus { outline: none; border-color: var(--brass-500); box-shadow: 0 0 0 3px var(--brass-100); }
.input[disabled], .input[readonly] { background: var(--paper-100); color: var(--ink-700); }
.field.has-error .input { border-color: var(--red-600); }
.field.has-error .input:focus { box-shadow: 0 0 0 3px var(--red-100); }
textarea.input { resize: vertical; min-height: 84px; }

.select-wrap { position: relative; }
.select-wrap::after {
  content: ''; position: absolute; right: 12px; top: 50%; width: 9px; height: 9px;
  border-right: 1.5px solid var(--ink-500); border-bottom: 1.5px solid var(--ink-500);
  transform: translateY(-70%) rotate(45deg); pointer-events: none;
}
.select-wrap select { appearance: none; padding-right: 32px; }

.input-group { display: flex; }
.input-group .input { border-radius: 0; }
.input-group .input:first-child { border-top-left-radius: var(--radius-md); border-bottom-left-radius: var(--radius-md); }
.input-group .input:last-child { border-top-right-radius: var(--radius-md); border-bottom-right-radius: var(--radius-md); }
.input-group-addon {
  display: flex; align-items: center; padding: 0 12px; background: var(--paper-100);
  border: 1px solid var(--line-strong); border-right: none; color: var(--ink-500); font-size: var(--fs-13);
  border-top-left-radius: var(--radius-md); border-bottom-left-radius: var(--radius-md);
}
.input-group .btn { border-top-left-radius: 0; border-bottom-left-radius: 0; }

.check-row { display: flex; align-items: flex-start; gap: 10px; padding: 2px 0; }
.checkbox, .radio {
  appearance: none; width: 17px; height: 17px; border: 1.5px solid var(--line-strong); background: var(--white);
  flex: none; margin-top: 1px; cursor: pointer; position: relative; transition: all 0.12s var(--ease);
}
.checkbox { border-radius: 4px; }
.radio { border-radius: 50%; }
.checkbox:checked, .radio:checked { background: var(--brass-600); border-color: var(--brass-600); }
.checkbox:checked::after {
  content: ''; position: absolute; left: 4px; top: 1px; width: 5px; height: 9px;
  border-right: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(40deg);
}
.radio:checked::after { content: ''; position: absolute; inset: 4px; border-radius: 50%; background: #fff; }
.check-row label { margin: 0; font-size: var(--fs-14); font-variation-settings: 'wght' 440; color: var(--ink-700); cursor: pointer; }

.option-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.option-pill { position: relative; }
.option-pill input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.option-pill span {
  display: inline-flex; align-items: center; padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--line-strong); font-size: var(--fs-14); color: var(--ink-700); cursor: pointer;
  transition: all 0.14s var(--ease);
}
.option-pill input:checked + span { background: var(--brass-600); border-color: var(--brass-600); color: var(--on-accent, #fff); }
.option-pill input:focus-visible + span { outline: 2px solid var(--brass-500); outline-offset: 2px; }

fieldset.form-section { border: none; margin: 0 0 30px; padding: 0; }
.form-section-head { margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.form-section-head h3 { display: flex; align-items: center; gap: 9px; }
.form-section-head .section-index {
  width: 22px; height: 22px; border-radius: 50%; background: var(--inverse-bg); color: var(--on-inverse, #fff);
  font-size: 11px; display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.form-section-head p { margin: 4px 0 0; font-size: var(--fs-13); color: var(--ink-500); }

/* ---------- Stepper (registration wizard) ---------- */
.stepper { display: flex; align-items: center; margin-bottom: 34px; }
.step { display: flex; align-items: center; flex: 1; }
.step:last-child { flex: none; }
.step-dot {
  width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--line-strong);
  display: flex; align-items: center; justify-content: center; font-size: var(--fs-13);
  color: var(--ink-500); flex: none; background: var(--paper-0); font-variation-settings: 'wght' 600;
  transition: all 0.2s var(--ease);
}
.step.is-done .step-dot { background: var(--brass-600); border-color: var(--brass-600); color: var(--on-accent, #fff); }
.step.is-current .step-dot { border-color: var(--brass-600); color: var(--brass-600); box-shadow: 0 0 0 4px var(--brass-100); }
.step-dot svg { width: 14px; height: 14px; }
.step-label { margin-left: 10px; font-size: var(--fs-13); color: var(--ink-500); white-space: nowrap; }
.step.is-current .step-label, .step.is-done .step-label { color: var(--ink-900); font-variation-settings: 'wght' 560; }
.step-line { flex: 1; height: 1px; background: var(--line-strong); margin: 0 14px; }
.step.is-done + .step .step-line, .step.is-done .step-line { background: var(--brass-600); }
@media (max-width: 720px) { .step-label { display: none; } }

.wizard-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--line); }

/* ---------- Tables ---------- */
.table-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.search-box { position: relative; flex: 1; min-width: 220px; max-width: 340px; }
.search-box svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--ink-500); }
.search-box .input { padding-left: 34px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--white); font-size: var(--fs-13); color: var(--ink-700); cursor: pointer;
}
.filter-chip.is-active { background: var(--inverse-bg); border-color: var(--inverse-bg); color: var(--on-inverse, #fff); }
.toolbar-spacer { flex: 1; }

.table-wrap { border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; background: var(--white); }
.table-scroll { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-14); min-width: 620px; }
table.data-table thead th {
  text-align: left; font-size: var(--fs-11); text-transform: none; letter-spacing: 0.01em;
  color: var(--ink-700); font-variation-settings: 'wght' 560; font-weight: 560; padding: 11px 16px;
  background: var(--paper-100); border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data-table th.sortable { cursor: pointer; user-select: none; }
table.data-table th.sortable:hover { color: var(--ink-900); }
table.data-table td { padding: 13px 16px; border-bottom: 1px solid var(--line); color: var(--ink-700); vertical-align: middle; }
table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table tbody tr { transition: background 0.1s var(--ease); }
table.data-table tbody tr:nth-child(even) { background: var(--table-zebra, transparent); }
table.data-table tbody tr:hover { background: var(--paper-100); }
table.data-table td.cell-primary { color: var(--ink-900); font-variation-settings: 'wght' 560; }
table.data-table td.cell-num { font-variation-settings: 'wght' 460, 'wdth' 88; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }

.pagination { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--paper-100); font-size: var(--fs-13); color: var(--ink-500); }
.pagination-controls { display: flex; gap: 4px; }
.page-btn { width: 30px; height: 30px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--white); color: var(--ink-700); cursor: pointer; font-size: var(--fs-13); }
.page-btn:hover:not(:disabled) { background: var(--paper-100); }
.page-btn.is-active { background: var(--inverse-bg); border-color: var(--inverse-bg); color: var(--on-inverse, #fff); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Badges / status ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: var(--fs-11); font-variation-settings: 'wght' 600; letter-spacing: 0.01em; white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-green { background: var(--green-100); color: var(--green-600); }
.badge-red { background: var(--red-100); color: var(--red-600); }
.badge-amber { background: var(--amber-100); color: var(--amber-600); }
.badge-blue { background: var(--blue-100); color: var(--blue-600); }
.badge-neutral { background: var(--paper-200); color: var(--ink-700); }
/* Presence badges: soft, desaturated backgrounds with dark readable text. */
.badge-online { background: var(--color-success-bg, var(--green-100)); color: var(--color-success, var(--green-600)); }
.badge-busy { background: var(--color-warning-bg, var(--amber-100)); color: var(--color-warning, var(--amber-600)); }
.badge-offline { background: var(--color-offline-bg, var(--paper-200)); color: var(--color-offline, var(--ink-700)); }
.badge-online::before, .badge-busy::before, .badge-offline::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; margin-right: 6px; vertical-align: middle; }

/* ---------- Panels / cards (used sparingly) ---------- */
.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px; }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.stat-cell { background: var(--white); padding: 18px 20px; }
.stat-cell .stat-label { font-size: var(--fs-13); color: var(--ink-500); }
.stat-cell .stat-value { font-size: var(--fs-28); font-variation-settings: 'wght' 640, 'wdth' 106; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-cell .stat-delta { font-size: var(--fs-13); margin-top: 4px; }

.definition-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px 24px; }
.definition-list dt { font-size: var(--fs-11); color: var(--ink-500); margin-bottom: 3px; }
.definition-list dd { margin: 0; font-size: var(--fs-14); color: var(--ink-900); font-variation-settings: 'wght' 520; }

/* ---------- Empty / loading / error states ---------- */
.empty-state { text-align: center; padding: 64px 24px; color: var(--ink-500); }
.empty-state svg { width: 40px; height: 40px; color: var(--line-strong); margin-bottom: 14px; }
.empty-state h3 { color: var(--ink-900); margin-bottom: 6px; }
.empty-state p { max-width: 380px; margin: 0 auto 18px; }

.skeleton { background: linear-gradient(100deg, var(--paper-100) 30%, var(--paper-200) 50%, var(--paper-100) 70%); background-size: 200% 100%; animation: shimmer 1.3s ease-in-out infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton-row { height: 44px; margin-bottom: 1px; }
.skeleton-line { height: 12px; border-radius: 3px; margin-bottom: 8px; }

.alert { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius-md); font-size: var(--fs-14); border: 1px solid; margin-bottom: 18px; }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert-info { background: var(--blue-100); border-color: color-mix(in srgb, var(--blue-600) 28%, transparent); color: var(--blue-600); }
.alert-error { background: var(--red-100); border-color: color-mix(in srgb, var(--red-600) 28%, transparent); color: var(--red-600); }
.alert-success { background: var(--green-100); border-color: color-mix(in srgb, var(--green-600) 28%, transparent); color: var(--green-600); }
.alert-warning { background: var(--amber-100); border-color: color-mix(in srgb, var(--amber-600) 28%, transparent); color: var(--amber-600); }
.alert strong { display: block; margin-bottom: 2px; color: inherit; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16, 20, 34, 0.5); backdrop-filter: blur(1.5px);
  display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 100;
  opacity: 0; pointer-events: none; transition: opacity 0.16s var(--ease);
}
.modal-backdrop.is-open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; max-height: 88vh; display: flex; flex-direction: column;
  transform: translateY(10px) scale(0.98); opacity: 0; transition: transform 0.18s var(--ease), opacity 0.18s var(--ease);
}
.modal-backdrop.is-open .modal { transform: translateY(0) scale(1); opacity: 1; }
.modal.modal-lg { max-width: 760px; }
.modal.modal-xl { max-width: 980px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--line); flex: none; }
.modal-head h2 { font-size: var(--fs-19); }
.modal-head p { margin: 3px 0 0; font-size: var(--fs-13); color: var(--ink-500); }
.modal-close { background: none; border: none; cursor: pointer; color: var(--ink-500); padding: 4px; border-radius: 50%; }
.modal-close:hover { background: var(--paper-100); color: var(--ink-900); }
.modal-close svg { width: 18px; height: 18px; }
.modal-body { padding: 22px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; flex: none; }
.modal-foot.justify-between { justify-content: space-between; }

/* ---------- Toasts ---------- */
.toast-region { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 200; width: min(360px, calc(100vw - 40px)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px; background: var(--inverse-bg); color: var(--on-inverse, #fff);
  padding: 13px 14px; border-radius: var(--radius-md); box-shadow: var(--shadow-md); font-size: var(--fs-14);
  animation: toast-in 0.22s var(--ease);
}
.toast svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.toast.toast-success svg { color: #7fcf9e; }
.toast.toast-error svg { color: #e39a93; }
.toast.toast-info svg { color: #9bc4e8; }
.toast-close { margin-left: auto; background: none; border: none; color: #98a1b8; cursor: pointer; padding: 2px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.toast.is-leaving { animation: toast-out 0.16s var(--ease) forwards; }
@keyframes toast-out { to { opacity: 0; transform: translateY(4px); } }

/* ---------- Diff view (approval comparison) ---------- */
.diff-row { display: grid; grid-template-columns: 200px 1fr 1fr; gap: 0; border-bottom: 1px solid var(--line); font-size: var(--fs-14); }
.diff-row:last-child { border-bottom: none; }
.diff-cell { padding: 11px 14px; }
.diff-label { color: var(--ink-500); font-size: var(--fs-13); display: flex; align-items: center; }
.diff-before { color: var(--ink-500); background: var(--red-100); text-decoration: line-through; text-decoration-color: rgba(162,59,52,0.4); }
.diff-after { color: var(--green-600); background: var(--green-100); font-variation-settings: 'wght' 560; }
.diff-head { display: grid; grid-template-columns: 200px 1fr 1fr; font-size: var(--fs-11); color: var(--ink-500); padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--paper-100); }

/* ---------- Auth / landing ---------- */
.auth-shell { min-height: 100vh; display: flex; }
.auth-visual {
  flex: 1.1; background: var(--inverse-bg); color: var(--on-inverse, #fff); display: flex; flex-direction: column;
  justify-content: space-between; padding: 48px; position: relative; overflow: hidden;
}
.auth-visual::before {
  content: ''; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 44px 44px; mask-image: radial-gradient(circle at 30% 30%, black, transparent 70%);
}
.auth-visual .mark { font-size: var(--fs-14); letter-spacing: 0.02em; color: #98a1b8; position: relative; }
.auth-visual .pitch { position: relative; max-width: 420px; }
.auth-visual .pitch h1 { color: var(--on-inverse, #fff); font-size: var(--fs-34); line-height: 1.15; }
.auth-visual .pitch p { color: #b7bdce; margin-top: 14px; font-size: var(--fs-14); }
.auth-visual .foot-note { position: relative; font-size: var(--fs-13); color: #7d859c; }
.auth-mobile-brand { display: none; align-items: center; gap: 12px; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.auth-mobile-brand img { width: 44px; height: 44px; border-radius: 8px; object-fit: contain; background: #fff; border: 1px solid var(--line); }
.auth-visual-company { position: relative; margin-top: 28px; padding-top: 20px; border-top: 1px solid rgba(255,255,255,0.12); }
.auth-visual-company-name { font-size: var(--fs-14); color: var(--on-inverse, #fff); font-variation-settings: 'wght' 600; }
.auth-visual-company-meta { display: flex; flex-wrap: wrap; gap: 3px 12px; margin-top: 6px; font-size: var(--fs-13); color: #98a1b8; }
.auth-form-side { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--paper-0); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { margin-bottom: 6px; }
.auth-card .sub { color: var(--ink-500); font-size: var(--fs-14); margin-bottom: 26px; }
.auth-switch { display: flex; gap: 4px; background: var(--paper-100); padding: 4px; border-radius: var(--radius-md); margin-bottom: 24px; }
.auth-switch a { flex: 1; text-align: center; padding: 8px; border-radius: 5px; font-size: var(--fs-13); color: var(--ink-500); font-variation-settings: 'wght' 560; }
.auth-switch a:hover { text-decoration: none; }
.auth-switch a.is-active { background: var(--white); color: var(--ink-900); box-shadow: var(--shadow-sm); }
.captcha-box { display: flex; align-items: center; gap: 10px; background: var(--paper-100); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 6px; margin-bottom: 14px; }
.captcha-box img { border-radius: 4px; display: block; }
.otp-inputs { display: flex; gap: 8px; }
.otp-inputs .input { text-align: center; font-size: var(--fs-19); padding: 10px 0; font-variant-numeric: tabular-nums; }

/* ---------- Landing page ---------- */
.landing { min-height: 100vh; background: var(--paper-0); }
.landing-nav { display: flex; align-items: center; justify-content: space-between; padding: 20px 40px; }
.landing-nav .brand { display: flex; align-items: center; gap: 10px; font-size: var(--fs-14); font-variation-settings: 'wght' 620; }
.landing-nav .brand svg { width: 22px; height: 22px; color: var(--brass-600); }
.landing-company-strip {
  display: flex; align-items: center; gap: 14px; max-width: 1100px; margin: 0 auto; padding: 0 40px 20px;
}
.landing-company-logo { width: 44px; height: 44px; border-radius: var(--radius-md); object-fit: contain; background: #fff; border: 1px solid var(--line); flex: none; }
.landing-company-logo-fallback {
  display: flex; align-items: center; justify-content: center; background: var(--brass-050); color: var(--brass-700);
  font-size: var(--fs-14); font-variation-settings: 'wght' 640;
}
.landing-company-name { font-size: var(--fs-15); color: var(--ink-900); font-variation-settings: 'wght' 600; }
.landing-company-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 3px; font-size: var(--fs-13); color: var(--ink-500); }
.landing-company-meta a { color: inherit; }
.landing-hero { max-width: 1100px; margin: 0 auto; padding: 64px 40px 40px; display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 60px; align-items: center; }
.landing-hero h1 { font-size: 2.6rem; line-height: 1.12; font-variation-settings: 'wght' 640, 'wdth' 106; }
.landing-hero .lede { font-size: var(--fs-16); color: var(--ink-500); margin: 18px 0 30px; max-width: 480px; }
.entry-cards { display: flex; flex-direction: column; gap: 14px; }
.entry-card {
  display: flex; align-items: center; gap: 16px; padding: 20px 22px; border: 1px solid var(--line);
  border-radius: var(--radius-lg); background: var(--white); transition: border-color 0.15s var(--ease), transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.entry-card:hover { border-color: var(--brass-500); box-shadow: var(--shadow-sm); text-decoration: none; }
.entry-card .entry-icon { width: 42px; height: 42px; border-radius: var(--radius-md); background: var(--brass-050); color: var(--brass-700); display: flex; align-items: center; justify-content: center; flex: none; }
.entry-card .entry-icon svg { width: 20px; height: 20px; }
.entry-card .entry-title { font-size: var(--fs-16); color: var(--ink-900); font-variation-settings: 'wght' 600; }
.entry-card .entry-desc { font-size: var(--fs-13); color: var(--ink-500); margin-top: 2px; }
.entry-card .entry-arrow { margin-left: auto; color: var(--ink-300); }
.landing-figure {
  aspect-ratio: 4/5; background: var(--inverse-bg); border-radius: var(--radius-lg); position: relative; overflow: hidden;
}
.landing-figure .ledger-lines { position: absolute; inset: 24px; display: flex; flex-direction: column; gap: 14px; }
.landing-figure .ledger-lines .lg-row { display: flex; align-items: center; gap: 10px; }
.landing-figure .lg-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brass-500); flex: none; }
.landing-figure .lg-bar { height: 9px; border-radius: 3px; background: rgba(255,255,255,0.1); }
.landing-foot { text-align: center; padding: 30px; color: var(--ink-500); font-size: var(--fs-13); }

/* ---------- Utility ---------- */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 18px; } .mt-4 { margin-top: 26px; }
.mb-2 { margin-bottom: 12px; } .mb-3 { margin-bottom: 18px; } .mb-4 { margin-bottom: 26px; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.hidden { display: none !important; }
.file-drop {
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius-md); padding: 22px;
  text-align: center; color: var(--ink-500); font-size: var(--fs-13); cursor: pointer; transition: all 0.14s var(--ease);
}
.file-drop:hover, .file-drop.is-dragover { border-color: var(--brass-500); background: var(--brass-050); }
.file-drop svg { width: 22px; height: 22px; margin-bottom: 8px; color: var(--ink-300); }
.file-preview { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--paper-100); }
.file-preview img { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; }
.file-preview .file-meta { flex: 1; min-width: 0; }
.file-preview .file-name { font-size: var(--fs-13); color: var(--ink-900); font-variation-settings: 'wght' 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-preview .file-size { font-size: 11px; color: var(--ink-500); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .sidebar { position: fixed; left: 0; top: 0; height: 100dvh; transform: translateX(-100%); transition: transform 0.2s var(--ease); width: 260px; flex-basis: 260px; }
  .sidebar.is-mobile-open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar.is-collapsed { width: 260px; flex-basis: 260px; }
  .sidebar.is-collapsed .brand-name, .sidebar.is-collapsed .brand-sub, .sidebar.is-collapsed .nav-label, .sidebar.is-collapsed .nav-toggle, .sidebar.is-collapsed .nav-children { display: block; }
  .sidebar.is-collapsed .nav-group:not(.is-open) .nav-children { display: none; }
  .mobile-menu-btn { display: inline-flex; }
  .sidebar-scrim { display: none; position: fixed; inset: 0; background: rgba(16,20,34,0.45); z-index: 29; }
  .sidebar-scrim.is-open { display: block; }
  .content { padding: 18px 16px 40px; }
  .field-row, .field-row.cols-3 { grid-template-columns: 1fr; }
  .landing-hero { grid-template-columns: 1fr; padding: 40px 20px; }
  .landing-figure { display: none; }
  .landing-hero h1 { font-size: 2rem; }
  .auth-visual { display: none; } .auth-mobile-brand { display: flex; }
  .definition-list { grid-template-columns: 1fr 1fr; }
  .diff-row, .diff-head { grid-template-columns: 120px 1fr 1fr; font-size: var(--fs-13); }
}
@media (max-width: 520px) {
  .page-head { flex-direction: column; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .definition-list { grid-template-columns: 1fr; }
  .toast-region { left: 12px; right: 12px; width: auto; }
}

/* Identity cards: larger applicant photo / company logo (dashboards, application page) */
.dash-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dash-card { margin-bottom: 0; }
.dash-identity { display: flex; align-items: center; gap: 18px; }
.dash-photo { width: 112px; height: 112px; border-radius: var(--radius-lg); object-fit: cover; border: 1px solid var(--line); flex-shrink: 0; background: var(--white); }
img.dash-logo { object-fit: contain; padding: 6px; box-sizing: border-box; }
.dash-photo-fallback { display: flex; align-items: center; justify-content: center; background: var(--brass-100); color: var(--brass-700); font-size: 32px; font-weight: 700; }
.dash-name { font-size: var(--fs-19); font-variation-settings: 'wght' 620; }
@media (max-width: 860px) { .dash-cards { grid-template-columns: 1fr; } .dash-photo { width: 88px; height: 88px; } }

/* Service desk timer */
.timer-face { font-variant-numeric: tabular-nums; font-size: 1.9rem; font-variation-settings: 'wght' 640; padding: 10px 16px; border-radius: var(--radius-md); background: var(--paper-100); border: 1px solid var(--line); min-width: 150px; text-align: center; }
.timer-face.timer-sm { font-size: var(--fs-14); padding: 4px 10px; min-width: 92px; }

.select-search { margin-bottom: 6px; }

/* Target progress */
.progress { height: 8px; border-radius: 999px; background: var(--paper-100); border: 1px solid var(--line); overflow: hidden; }
.progress-bar { height: 100%; background: var(--blue-600); border-radius: 999px; transition: width 0.3s var(--ease); }
.progress-bar.is-done { background: var(--green-600); }

/* =====================================================================
   Themes — chosen from the palette button in the top bar (stored in the
   "theme" cookie so the server renders <html data-theme> with no flash).
   Each theme only overrides tokens; components never name colours.
   ===================================================================== */
[data-theme="slate"] {
  --ink-900: #0f172a; --ink-700: #334155; --ink-500: #5a6679; --ink-300: #94a3b8;
  --paper-0: #f6f8fb; --paper-100: #eef2f7; --paper-200: #e2e8f0; --line: #e2e8f0; --line-strong: #cbd5e1;
  --brass-700: #3730a3; --brass-600: #4f46e5; --brass-500: #6366f1; --brass-100: #e0e7ff; --brass-050: #eef2ff;
  --inverse-bg: #111827; --sidebar-active: rgba(99, 102, 241, 0.32);
}
[data-theme="ocean"] {
  --ink-900: #0b2530; --ink-700: #2f4a55; --ink-500: #4f6671; --ink-300: #93a7af;
  --paper-0: #f4f9fa; --paper-100: #e8f2f4; --paper-200: #d9e9ec; --line: #d5e4e8; --line-strong: #b5ccd2;
  --brass-700: #0b5563; --brass-600: #0e7490; --brass-500: #0891b2; --brass-100: #cff4fc; --brass-050: #ecfeff;
  --inverse-bg: #0b2530; --sidebar-fg: #bcd3da; --sidebar-muted: #86a3ad; --sidebar-active: rgba(8, 145, 178, 0.35);
}
[data-theme="forest"] {
  --ink-900: #14231b; --ink-700: #37493f; --ink-500: #55655b; --ink-300: #9aa89f;
  --paper-0: #f6f8f4; --paper-100: #ecf1e8; --paper-200: #dfe7d9; --line: #dbe3d4; --line-strong: #bccab2;
  --brass-700: #1f5130; --brass-600: #2f6b3f; --brass-500: #3f8a52; --brass-100: #dcefdf; --brass-050: #eef7ef;
  --inverse-bg: #14231b; --sidebar-fg: #c3d1c7; --sidebar-muted: #8ea396; --sidebar-active: rgba(63, 138, 82, 0.38);
}
[data-theme="dark"] {
  color-scheme: dark;
  --ink-900: #e7eaf1; --ink-700: #c1c7d3; --ink-500: #949cae; --ink-300: #677087;
  --paper-0: #0e121a; --paper-100: #151a24; --paper-200: #1d2330; --line: #283042; --line-strong: #394257;
  --white: #141924;
  --brass-700: #e3b066; --brass-600: #b8812e; --brass-500: #d49a45; --brass-100: #3a2c15; --brass-050: #231b0f;
  --green-600: #6cc392; --green-100: #142a1e; --red-600: #ec8c83; --red-100: #301816;
  --amber-600: #e2b45c; --amber-100: #2e2410; --blue-600: #92bbe4; --blue-100: #132233;
  --inverse-bg: #080b11; --sidebar-active: rgba(212, 154, 69, 0.28);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4); --shadow-md: 0 6px 20px -6px rgba(0,0,0,0.6); --shadow-lg: 0 16px 48px -12px rgba(0,0,0,0.7);
}
[data-theme="dark"] .input, [data-theme="dark"] select.input { color: var(--ink-900); }
[data-theme="dark"] img.dash-photo { background: var(--paper-200); }

/* ---------- Polish shared by every theme ---------- */
.panel, .table-wrap, .stat-row { box-shadow: var(--shadow-sm); }
.data-table tbody tr { transition: background-color 0.12s var(--ease); }
.data-table tbody tr:hover { background: var(--paper-100); }
.btn { transition: background-color 0.14s var(--ease), border-color 0.14s var(--ease), box-shadow 0.14s var(--ease), transform 0.06s var(--ease); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-primary { color: var(--on-accent); }
.page-head h1 { letter-spacing: -0.02em; }

/* ---------- Theme picker ---------- */
.theme-swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; padding: 10px 12px 12px; }
.theme-swatch { display: flex; flex-direction: column; align-items: center; gap: 5px; background: none; border: none; cursor: pointer; font-size: var(--fs-11); color: var(--ink-700); padding: 0; }
.theme-swatch i { display: block; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); box-shadow: inset 0 0 0 3px var(--white); }
.theme-swatch.is-current i { border-color: var(--brass-600); }
.dropdown-label { padding: 10px 12px 0; font-size: var(--fs-11); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-500); }
.theme-float { position: fixed; right: 16px; bottom: 16px; z-index: 40; }
.theme-float .dropdown-panel { bottom: 46px; top: auto; right: 0; }

/* ---------- Staff work / idle timer (top bar) ---------- */
.work-timer { display: inline-flex; align-items: center; gap: 10px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--white); font-size: var(--fs-13); font-variant-numeric: tabular-nums; white-space: nowrap; }
.work-timer .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green-600); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green-600) 20%, transparent); }
.work-timer.is-idle .dot { background: var(--amber-600); box-shadow: 0 0 0 3px color-mix(in srgb, var(--amber-600) 22%, transparent); animation: pulse 1.4s infinite; }
.work-timer .sep { width: 1px; height: 14px; background: var(--line); }
@keyframes pulse { 50% { opacity: 0.35; } }
@media (max-width: 720px) { .work-timer .wt-label { display: none; } }
/* Idle is shown larger and highlighted so it is noticed (and worked down). */
.work-timer [data-wt="idle"] { font-size: var(--fs-14); padding: 1px 8px; border-radius: 999px; background: var(--amber-100); color: var(--amber-600); }
.work-timer.is-idle { border-color: color-mix(in srgb, var(--amber-600) 45%, transparent); background: color-mix(in srgb, var(--amber-100) 55%, var(--white)); }
.work-timer.is-idle [data-wt="idle"] { font-size: var(--fs-16); background: var(--amber-600); color: #fff; box-shadow: 0 0 0 3px color-mix(in srgb, var(--amber-600) 22%, transparent); animation: idle-glow 2s ease-in-out infinite; }
.work-timer.is-idle .wt-label.wt-idle { color: var(--amber-600); font-weight: 600; }
@keyframes idle-glow { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--amber-600) 10%, transparent); } }
/* Idle sign-out warning */
.idle-warn { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 3000; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  max-width: calc(100vw - 32px); padding: 12px 16px; border-radius: var(--radius-md, 10px); background: var(--white); border: 1px solid var(--amber-600); box-shadow: 0 10px 30px rgba(0,0,0,.18); font-size: var(--fs-14, 14px); }
.idle-warn strong { color: var(--amber-600); }

/* ---------- Image cropper (every image upload) ---------- */
.cropper-stage { position: relative; background: var(--paper-200); border-radius: var(--radius-md); overflow: hidden; user-select: none; touch-action: none; display: flex; justify-content: center; }
.cropper-stage canvas { display: block; max-width: 100%; max-height: 56vh; }
.cropper-box { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(10, 13, 20, 0.55); cursor: move; }
.cropper-box .h { position: absolute; width: 14px; height: 14px; background: #fff; border: 2px solid var(--brass-600); border-radius: 3px; }
.cropper-box .h.nw { left: -8px; top: -8px; cursor: nwse-resize; } .cropper-box .h.ne { right: -8px; top: -8px; cursor: nesw-resize; }
.cropper-box .h.sw { left: -8px; bottom: -8px; cursor: nesw-resize; } .cropper-box .h.se { right: -8px; bottom: -8px; cursor: nwse-resize; }
.cropper-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.modal.modal-wide { max-width: 860px; width: calc(100% - 32px); }

/* ---------- Grouped page picker (User Access) ---------- */
.page-group { border: 1px solid var(--line); border-radius: var(--radius-md); margin-bottom: 10px; overflow: hidden; }
.page-group-head { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--paper-100); font-variation-settings: 'wght' 600; font-size: var(--fs-14); cursor: pointer; }
.page-group-head .count { margin-left: auto; font-size: var(--fs-13); color: var(--ink-500); font-variation-settings: 'wght' 420; }
.page-group-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 14px; padding: 10px 12px; }
.page-group-body label { display: flex; align-items: center; gap: 8px; font-size: var(--fs-14); cursor: pointer; margin: 0; }

/* ---------- Blocking document-request modal ---------- */
.modal-backdrop.is-blocking { backdrop-filter: blur(3px); }
.req-list { display: flex; flex-direction: column; gap: 12px; }
.req-item { border: 1px solid var(--line); border-radius: var(--radius-md); padding: 14px; }
.req-item h3 { font-size: var(--fs-16); margin-bottom: 4px; }
.banner-strip { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: var(--radius-md); background: var(--amber-100); color: var(--amber-600); font-size: var(--fs-13); margin-bottom: 16px; }
.banner-strip svg { width: 16px; height: 16px; flex: none; }
.banner-strip a { color: inherit; text-decoration: underline; margin-left: auto; }

/* ---------- Helpers used by the newer pages ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.kpi .k { font-size: var(--fs-13); color: var(--ink-500); }
.kpi .v { font-size: var(--fs-23); font-variation-settings: 'wght' 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--paper-100); border: 1px solid var(--line); font-size: var(--fs-13); }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px 16px; }
.check-grid label { display: flex; align-items: center; gap: 8px; font-size: var(--fs-14); cursor: pointer; margin: 0; }
.pick-list { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-md); padding: 6px 10px; }
.pick-list label { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: var(--fs-14); cursor: pointer; margin: 0; border-bottom: 1px dashed var(--line); }
.pick-list label:last-child { border-bottom: none; }
.vitem { border: 1px solid var(--line); border-radius: var(--radius-md); padding: 14px 16px; margin-bottom: 12px; background: var(--white); }
.vitem-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.vitem-head h3 { font-size: var(--fs-16); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.photo-grid figure { margin: 0; border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; background: var(--white); }
.photo-grid img { width: 100%; height: 120px; object-fit: cover; display: block; }
.photo-grid figcaption { padding: 6px 8px; font-size: var(--fs-13); color: var(--ink-700); }
.timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 12px 12px; font-size: var(--fs-14); }
.timeline li::before { content: ''; position: absolute; left: -23px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--brass-600); border: 2px solid var(--white); }
.bar-track { height: 8px; border-radius: 999px; background: var(--paper-200); overflow: hidden; display: flex; min-width: 120px; }
.bar-track .work { background: var(--green-600); } .bar-track .idle { background: var(--amber-600); }
.letter-paper { background: #fff; color: #111; max-width: 800px; margin: 0 auto; padding: 48px 56px; border: 1px solid var(--line); box-shadow: var(--shadow-md); font-family: Georgia, 'Times New Roman', serif; font-size: 15px; line-height: 1.6; }
.letter-paper p, .letter-paper td, .letter-paper h1, .letter-paper h2, .letter-paper h3 { color: #111; }
.placeholder-list code { cursor: pointer; display: inline-block; margin: 2px; padding: 2px 6px; border-radius: 4px; background: var(--paper-100); border: 1px solid var(--line); font-size: 12px; }
@media print {
  .sidebar, .topbar, .page-head, .no-print, .toast-region, .theme-float { display: none !important; }
  .content { padding: 0 !important; } .letter-paper { border: none; box-shadow: none; padding: 0; max-width: none; }
  body { background: #fff; }
}

/* ---------- Company portal (white-label entry page) ---------- */
.portal { min-height: 100vh; background: var(--paper-0); display: flex; flex-direction: column; }
.portal-hero { background: var(--inverse-bg); color: var(--on-inverse, #fff); padding: 48px 24px 88px; }
.portal-hero .inner, .portal-body { max-width: 1040px; margin: 0 auto; width: 100%; }
.portal-hero .brand { display: flex; align-items: center; gap: 16px; }
.portal-hero .brand img, .portal-hero .brand .mono { width: 64px; height: 64px; border-radius: 12px; background: #fff; object-fit: contain; flex: none; }
.portal-hero .brand .mono { display: flex; align-items: center; justify-content: center; color: #12182a; font-weight: 700; font-size: 22px; }
.portal-hero h1 { color: var(--on-inverse, #fff); font-size: var(--fs-28); }
.portal-hero p { color: var(--sidebar-fg); margin: 4px 0 0; }
.portal-body { padding: 0 24px 48px; margin-top: -48px; }
.portal-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.portal-card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px; box-shadow: var(--shadow-md); display: flex; flex-direction: column; gap: 8px; }
.portal-card svg { width: 26px; height: 26px; color: var(--brass-600); }
.portal-card h3 { font-size: var(--fs-19); }
.portal-card .btn { margin-top: auto; align-self: flex-start; }
/* Company branding on the public pages: large logo, name, punch line, clickable contacts (migration 076) */
.punch-line { font-size: 13.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--brass-300, #e9c46a); margin: 6px 0 0; }
.portal-hero .brand-lg { align-items: flex-start; gap: 22px; }
.portal-hero .brand-lg img, .portal-hero .brand-lg .mono { width: 112px; height: 112px; border-radius: 16px; padding: 6px; font-size: 34px; }
.portal-hero .brand-lg h1 { font-size: var(--fs-34, 34px); line-height: 1.15; }
.portal-hero .hero-address { font-size: 16px; margin-top: 10px; display: flex; gap: 6px; align-items: flex-start; }
.portal-hero .hero-contacts { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 8px; font-size: 16px; }
.portal-hero .hero-contacts a, .portal-hero .hero-address { color: var(--on-inverse, #fff); }
.portal-hero .hero-contacts a { text-decoration: underline; text-underline-offset: 3px; display: inline-flex; gap: 6px; align-items: center; }
.portal-hero svg { width: 17px; height: 17px; flex: none; margin-top: 2px; }
.register-hero .portal-hero { padding-bottom: 36px; margin-bottom: 18px; }
@media (max-width: 640px) {
  .portal-hero .brand-lg { flex-direction: column; gap: 14px; }
  .portal-hero .brand-lg img, .portal-hero .brand-lg .mono { width: 84px; height: 84px; }
  .portal-hero .brand-lg h1 { font-size: 26px; }
  .portal-hero .hero-contacts, .portal-hero .hero-address { font-size: 15px; }
}
.auth-company { position: relative; display: flex; flex-direction: column; align-items: flex-start; }
.auth-company-logo { width: 140px; height: 140px; border-radius: 20px; background: #fff; object-fit: contain; padding: 8px; box-shadow: 0 6px 24px rgba(0,0,0,0.25); }
.auth-company-logo.mono { display: flex; align-items: center; justify-content: center; color: #12182a; font-weight: 700; font-size: 44px; }
.auth-company-name { color: var(--on-inverse, #fff); font-size: var(--fs-34, 34px); line-height: 1.15; margin: 22px 0 0; }
.auth-company-full { color: #b7bdce; font-size: 15px; margin-top: 4px; }
.auth-company .punch-line { font-size: 14px; margin-top: 10px; }
.auth-company-details { list-style: none; padding: 0; margin: 24px 0 0; display: flex; flex-direction: column; gap: 12px; font-size: 16.5px; color: #dfe3ee; }
.auth-company-details li { display: flex; gap: 10px; align-items: flex-start; }
.auth-company-details svg { width: 19px; height: 19px; flex: none; margin-top: 3px; color: var(--brass-300, #e9c46a); }
.auth-company-details a { color: #fff; text-decoration: underline; text-underline-offset: 3px; }
.auth-mobile-brand { align-items: flex-start; gap: 14px; }
.auth-mobile-brand img, .auth-mobile-mono { width: 72px; height: 72px; border-radius: 14px; flex: none; }
.auth-mobile-mono { display: flex; align-items: center; justify-content: center; background: var(--inverse-bg); color: #fff; font-weight: 700; font-size: 24px; }
.auth-mobile-name { display: block; font-size: 22px; line-height: 1.2; }
.auth-mobile-brand .punch-line { color: var(--brass-600, #8b5e1f); font-size: 12px; margin-top: 4px; }
.auth-mobile-address { font-size: 14.5px; color: var(--ink-700, #334); margin-top: 6px; }
.auth-mobile-contacts { font-size: 15px; margin-top: 4px; }
/* Company registration / sign-in links (/join, /application/status, Registration & Sign-in Links) */
.join-body { max-width: 640px; display: flex; flex-direction: column; gap: 16px; }
.join-card { box-shadow: var(--shadow-md); }
.join-done-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--green-100); color: var(--green-600); display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.company-contact .panel-head h2 { display: flex; align-items: center; gap: 8px; font-size: var(--fs-19); }
.reg-link { padding: 14px 0; border-top: 1px solid var(--line); }
.reg-link:first-of-type { border-top: 0; padding-top: 0; }
.reg-link textarea[data-snippet] { font-family: var(--font-mono, monospace); font-size: 12px; }

/* ---------- Document / photo viewer ---------- */
.modal.viewer-modal { max-width: none; width: calc(100vw - 32px); height: calc(100vh - 32px); max-height: none; display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.viewer-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.viewer-title { flex: 1; min-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.viewer-zoom { min-width: 48px; text-align: center; font-size: var(--fs-13); font-variant-numeric: tabular-nums; }
.viewer-stage { position: relative; flex: 1; overflow: hidden; background: repeating-conic-gradient(var(--paper-100) 0 25%, var(--paper-200) 0 50%) 0 0 / 24px 24px; display: flex; align-items: center; justify-content: center; }
.viewer-stage img { max-width: none; transform-origin: center center; cursor: grab; user-select: none; transition: transform 0.06s linear; }
.viewer-stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.viewer-msg { color: var(--ink-500); }
.input.has-error { border-color: var(--red-600); box-shadow: 0 0 0 3px color-mix(in srgb, var(--red-600) 18%, transparent); }
img.dash-photo, img[data-zoomable] { cursor: zoom-in; }

/* ---------- Organisation tree (Hierarchy) ---------- */
.org-tree { padding: 8px 4px 16px; min-width: max-content; }
.org-tree ul { position: relative; display: flex; justify-content: center; padding: 22px 0 0; margin: 0; list-style: none; }
.org-tree li { position: relative; display: flex; flex-direction: column; align-items: center; padding: 22px 8px 0; }
.org-tree > ul { padding-top: 0; }
.org-tree > ul > li { padding-top: 0; }
.org-tree li::before, .org-tree li::after { content: ''; position: absolute; top: 0; right: 50%; width: 50%; height: 22px; border-top: 2px solid var(--line-strong); }
.org-tree li::after { right: auto; left: 50%; border-left: 2px solid var(--line-strong); }
.org-tree li:only-child::before, .org-tree li:only-child::after { display: none; }
.org-tree li:only-child { padding-top: 22px; }
.org-tree > ul > li:only-child { padding-top: 0; }
.org-tree li:first-child::before, .org-tree li:last-child::after { border: 0 none; }
.org-tree li:last-child::before { border-right: 2px solid var(--line-strong); border-radius: 0 6px 0 0; }
.org-tree li:first-child::after { border-radius: 6px 0 0 0; }
.org-tree ul ul::before { content: ''; position: absolute; top: 0; left: 50%; height: 22px; border-left: 2px solid var(--line-strong); }
.org-tree li:only-child > .org-card::before { content: ''; position: absolute; top: -22px; left: 50%; height: 22px; border-left: 2px solid var(--line-strong); }
.org-tree > ul > li > .org-card::before { display: none; }
.org-tree li.is-collapsed > ul { display: none; }
.org-card { position: relative; min-width: 150px; max-width: 200px; padding: 10px 12px; border: 1px solid var(--line); border-top: 4px solid var(--ink-300); border-radius: var(--radius-md); background: var(--white); box-shadow: var(--shadow-sm); text-align: center; }
.org-card.is-company { border-top-color: var(--brass-600); background: var(--brass-050); min-width: 220px; }
.org-card.is-staff { border-top-color: var(--blue-600); }
.org-card.is-agent { border-top-color: var(--green-600); }
.org-card.is-sub { border-top-color: var(--amber-600); }
.org-kind { font-size: var(--fs-11); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-500); }
.org-name { display: block; font-variation-settings: 'wght' 620; color: var(--ink-900); margin: 2px 0; }
.org-code { font-size: var(--fs-13); color: var(--ink-500); font-variant-numeric: tabular-nums; }
.org-toggle, .org-move { margin-top: 6px; border: 1px solid var(--line); background: var(--paper-100); color: var(--ink-700); border-radius: 999px; padding: 2px 9px; font-size: var(--fs-11); cursor: pointer; }
.org-move { display: block; margin: 6px auto 0; background: transparent; }
.org-toggle:hover, .org-move:hover { border-color: var(--brass-500); color: var(--brass-700); }
.org-dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.org-dot.is-staff { background: var(--blue-600); } .org-dot.is-agent { background: var(--green-600); } .org-dot.is-sub { background: var(--amber-600); }

/* ---------- Top performers ---------- */
.top-panel .panel-head h2 { display: flex; align-items: center; gap: 8px; }
.top-panel .panel-head svg { width: 20px; height: 20px; color: var(--amber-600); }
.top-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.top-card { display: flex; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: linear-gradient(135deg, var(--brass-050), var(--white)); }
.top-photo { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; flex: none; border: 3px solid var(--brass-500); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 24px; }

/* ---------- Suggestion dropdown (branch search, etc.) ---------- */
.suggest { position: relative; }
.suggest-list { display: none; position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 60; max-height: 280px; overflow: auto; background: var(--white); border: 1px solid var(--line-strong); border-radius: var(--radius-md); box-shadow: var(--shadow-md); }
.suggest-list.is-open { display: block; }
.suggest-item { padding: 8px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; }
.suggest-item strong { font-size: var(--fs-14); font-variation-settings: 'wght' 560; }
.suggest-item span { font-size: var(--fs-13); color: var(--ink-500); }
.suggest-item.is-active, .suggest-item:hover { background: var(--brass-050); }
.suggest-empty { padding: 8px 12px; color: var(--ink-500); font-size: var(--fs-13); }

/* Report sharing: scope picker under each person in the share list */
#sharePeople .share-scope { padding: 0 0 6px 26px; border-bottom: 1px dashed var(--line); }
#sharePeople label { border-bottom: none; }

/* Cropper: page navigation for PDFs */
.cropper-pages { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }

/* Notification pop-up (views/partials/notifications.ejs) */
.notice-pop { position: fixed; top: 72px; right: 20px; width: min(380px, calc(100vw - 32px)); max-height: calc(100vh - 110px); display: flex; flex-direction: column;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: 0 12px 32px rgba(0, 0, 0, .16); z-index: 150; }
.notice-pop.hidden { display: none; }
.notice-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.notice-head strong { display: flex; align-items: center; gap: 8px; }
.notice-head svg { width: 16px; height: 16px; }
.notice-list { overflow: auto; }
.notice-item { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.notice-title { font-variation-settings: 'wght' 600; margin-bottom: 2px; }
.notice-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.notice-foot { padding: 6px 12px; text-align: right; }
@media (max-width: 600px) { .notice-pop { top: auto; bottom: 16px; right: 16px; } }


/* ---------- Company theme management (views/admin/themes.ejs) ---------- */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.theme-card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 10px; }
.theme-card.is-default { border-color: var(--brass-600); box-shadow: 0 0 0 1px var(--brass-600), var(--shadow-sm); }
.theme-swatch-row { display: flex; gap: 4px; }
.theme-swatch-row i { flex: 1; height: 26px; border-radius: 4px; border: 1px solid rgba(15, 23, 42, 0.08); }
.theme-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
@media (max-width: 900px) { .theme-editor { grid-template-columns: 1fr; } }
.color-field { display: flex; align-items: center; gap: 8px; }
.color-field input[type="color"] { width: 38px; height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--white); cursor: pointer; flex: none; }
.color-field .input { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; text-transform: uppercase; }
.token-group { border: 1px solid var(--line); border-radius: var(--radius-md); padding: 12px; margin-bottom: 12px; }
.token-group legend { font-size: var(--fs-13); color: var(--ink-500); padding: 0 6px; }
.token-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 14px; }
.token-grid .field { margin-bottom: 0; }
/* The live preview gets its own variables from the server (.theme-preview{…}). */
.theme-preview { font-family: var(--font-sans); color: var(--ink-900); background: var(--paper-0); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; position: sticky; top: 0; }
.theme-preview .pv-shell { display: grid; grid-template-columns: 120px 1fr; min-height: 360px; }
.theme-preview .pv-side { background: var(--inverse-bg); color: var(--sidebar-fg); padding: 12px 8px; font-size: 12px; display: flex; flex-direction: column; gap: 4px; }
.theme-preview .pv-side span { padding: 6px 8px; border-radius: var(--radius-sm); }
.theme-preview .pv-side span.is-active { background: var(--sidebar-active); color: var(--on-inverse, #fff); box-shadow: inset 3px 0 0 var(--brass-500); }
.theme-preview .pv-main { padding: 14px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.theme-preview table.data-table { min-width: 0; }
.theme-preview .pv-busy { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(255, 255, 255, 0.55); font-size: 13px; }
.theme-preview.is-loading .pv-busy { display: flex; }


/* ---------- Service requests waiting 5+ minutes (escalation) ---------- */
@keyframes attention-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.attention-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: var(--red-100); color: var(--red-600);
  font-size: var(--fs-13); font-variation-settings: 'wght' 600; font-weight: 600; text-decoration: none; animation: attention-blink 1.2s ease-in-out infinite; white-space: nowrap; }
.attention-pill:hover { text-decoration: none; animation-play-state: paused; }
.attention-pill.hidden { display: none; }
.attention-pill svg { width: 15px; height: 15px; }
table.data-table tbody tr.is-attention { background: var(--red-100); }
table.data-table tbody tr.is-attention td:first-child { box-shadow: inset 3px 0 0 var(--red-600); }
table.data-table tbody tr.is-attention .attention-note { animation: attention-blink 1.2s ease-in-out infinite; }
.attention-note { display: flex; align-items: center; gap: 4px; margin-top: 4px; font-size: var(--fs-11); color: var(--red-600); font-variation-settings: 'wght' 600; font-weight: 600; }
.attention-note svg { width: 13px; height: 13px; }

/* ---------- Request queue pop-up (staff) ---------- */
.queue-list { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow: auto; }
.queue-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-md, 10px); }
.queue-item.is-first { border-color: var(--brass-600); box-shadow: inset 3px 0 0 var(--brass-600); }
.queue-main { flex: 1; min-width: 0; }
.queue-title { font-weight: 600; }

.idle-hot { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--amber-100); color: var(--amber-600); font-weight: 600; }

/* ---------- Balance Shortage ---------- */
.bs-result { margin-top: 4px; }
.bs-steps { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: var(--fs-13); color: var(--ink-500, inherit); font-variant-numeric: tabular-nums; margin-bottom: 8px; }
.bs-verdict { display: inline-block; padding: 8px 14px; border-radius: var(--radius-md, 10px); font-size: var(--fs-16); font-weight: 600; font-variant-numeric: tabular-nums; }
.bs-verdict span { font-size: var(--fs-13); font-weight: 400; opacity: .85; }
.bs-verdict.is-zero { background: var(--green-100); color: var(--green-600); }
.bs-verdict.is-short { background: var(--blue-100); color: var(--blue-600); }
.bs-verdict.is-excess { background: var(--amber-100); color: var(--amber-600); }
.bs-card { border: 1px solid var(--line); border-radius: var(--radius-md, 10px); padding: 14px; margin-bottom: 12px; }
.bs-calc-table td:first-child { width: 45%; }
@media (max-width: 720px) { .bs-calc.cols-4 { grid-template-columns: 1fr 1fr; } }

/* ---------- People picker toolbar (app.js enhancePicker) ---------- */
.picker-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.picker-bar > .input[type=search] { flex: 1; min-width: 180px; }
.picker-all { display: inline-flex; align-items: center; gap: 6px; margin: 0; white-space: nowrap; font-size: var(--fs-13); }

/* ---------- Letter pad thumbnails ---------- */
.pad-thumb { position: relative; width: 210px; height: 297px; border: 1px solid var(--line); background: #fff; display: flex; align-items: center; justify-content: center; flex: none; }
.pad-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.pad-thumb .pad-area { position: absolute; outline: 1.5px dashed var(--red-600); background: color-mix(in srgb, var(--red-600) 6%, transparent); }

/* ---------- Application status timeline ---------- */
.status-timeline { list-style: none; margin: 8px 0 0; padding: 0 0 0 18px; border-left: 2px solid var(--line); }
.status-timeline li { position: relative; padding: 0 0 12px 10px; }
.status-timeline li::before { content: ''; position: absolute; left: -25px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--brass-600); }

/* ---------- Training acknowledgement ---------- */
.ack-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.ack-row .ack-text { margin-bottom: 6px; }
.check-list { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-md, 10px); padding: 10px; }

/* ---------- Declarations / consent text ---------- */
.consent-box { white-space: pre-wrap; font-size: var(--fs-13); line-height: 1.55; max-height: 260px; overflow: auto; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-md, 10px); background: var(--paper-100, #fafafa); }

/* ---------- Page work timer (staff top bar) ---------- */
.page-work { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-13); white-space: nowrap; }
.page-work button { border: 1px solid var(--line); background: var(--white); border-radius: 999px; padding: 5px 12px; cursor: pointer; font: inherit; color: var(--ink-900); }
.page-work button:hover { border-color: var(--brass-600); }
.page-work.is-running { padding: 3px 4px 3px 12px; border: 1px solid color-mix(in srgb, var(--green-600) 45%, transparent); border-radius: 999px; background: var(--green-100); color: var(--green-600); }
.page-work.is-over { border-color: color-mix(in srgb, var(--amber-600) 55%, transparent); background: var(--amber-100); color: var(--amber-600); }
.page-work .pw-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 1.4s infinite; }
.page-work .pw-label { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
/* A request came in while the service timer runs: answer (open it) or Wait before the countdown ends. */
.page-work.is-alert { border-color: color-mix(in srgb, var(--red-600) 55%, transparent); background: var(--red-100, #fde8e8); color: var(--red-600); }
.page-work .pw-alert { font-weight: 600; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.page-work .pw-state { font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--amber-100); color: var(--amber-600); }
.page-work button[data-pw="wait"] { border-color: var(--red-600); color: var(--red-600); font-weight: 600; }
@media (max-width: 720px) { .page-work .pw-label { display: none; } .page-work .pw-alert { max-width: 140px; } }

/* ---------- Letter editor (public/js/letter-editor.js) ---------- */
.letter-toolbar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 8px; }
.letter-toolbar-sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 4px; }

/* ---- Document editor, Google-Docs style (public/js/letter-editor.js) ---- */
/* Sticks under the app's top bar while the page scrolls (inside a window: at its top). */
.docs-toolbar { position: sticky; top: 64px; z-index: 5; background: var(--paper-100, #f1f3f4); border: 1px solid var(--line); border-radius: 20px; padding: 4px 8px; gap: 2px; }
.modal .docs-toolbar { top: 0; }
.docs-toolbar .btn { min-width: 30px; justify-content: center; padding: 4px 7px; }
.docs-toolbar .btn.is-on { background: color-mix(in srgb, var(--blue-600, #1a73e8) 16%, transparent); color: var(--blue-600, #1a73e8); }
.docs-toolbar .docs-select { height: 30px; padding: 0 6px; font-size: 13px; background: transparent; border-color: transparent; }
.docs-toolbar .docs-select:hover { border-color: var(--line); background: var(--white); }
.docs-editor h1 { font-size: 20pt; margin: .4em 0 .3em; } .docs-editor h2 { font-size: 16pt; margin: .4em 0 .3em; } .docs-editor h3 { font-size: 13pt; margin: .4em 0 .3em; }
.docs-editor blockquote { margin: .4em 0 .4em 12mm; padding-left: 4mm; border-left: .8mm solid #ccc; }
/* Field chips — only while editing: on a printed / shown document they are plain text. */
[contenteditable="true"] .mf { display: inline-block; font-size: 0; line-height: 1.2; padding: 0 5px; margin: 0 1px; border-radius: 10px; background: #e8f0fe; box-shadow: inset 0 0 0 1px #aecbfa; vertical-align: baseline; cursor: default; user-select: all; }
[contenteditable="true"] .mf::before { content: attr(data-label); font-size: 11.5px; font-family: system-ui, sans-serif; color: #174ea6; white-space: nowrap; }
[contenteditable="true"] .mf.mf-if { background: #fef7e0; box-shadow: inset 0 0 0 1px #f9d77e; }
[contenteditable="true"] .mf.mf-if::before { color: #8a5a00; font-weight: 600; }
[contenteditable="true"] .mf.mf-miss { background: #fce8e6; box-shadow: inset 0 0 0 1px #f28b82; }
[contenteditable="true"] .mf.mf-miss::before { color: #a50e0e; }
[contenteditable="true"] .mf:not([data-label]) { font-size: inherit; }
[contenteditable="true"] .mf:not([data-label])::before { content: none; }
/* Editor + database panel side by side. */
.docs-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 12px; align-items: start; }
@media (max-width: 1100px) { .docs-layout { grid-template-columns: 1fr; } }
.docs-panel { position: sticky; top: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); display: flex; flex-direction: column; max-height: 78vh; overflow: hidden; }
.docs-panel-head { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 12px 6px; }
.docs-panel-search { margin: 0 10px 8px; width: auto; height: 32px; }
.docs-panel-body { overflow: auto; padding: 0 6px 10px; }
.docs-group { border-top: 1px solid var(--line); }
.docs-group-head { display: block; width: 100%; text-align: left; background: none; border: none; padding: 7px 6px; font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; color: var(--ink-900); }
.docs-group-head:hover { background: var(--paper-100); }
.docs-col { display: flex; align-items: center; gap: 6px; padding: 4px 8px 4px 18px; font-size: 13px; border-radius: 6px; cursor: pointer; }
.docs-col:hover { background: #e8f0fe; color: #174ea6; }
.docs-group [data-table], .docs-group [data-if] { margin: 4px 0 6px 18px; }
.letter-table-menu { position: relative; }
.letter-table-menu > summary { list-style: none; cursor: pointer; }
.letter-table-menu > summary::-webkit-details-marker { display: none; }
.letter-table-pop { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; width: 300px; display: flex; flex-direction: column; gap: 8px; padding: 12px; background: var(--paper-0, #fff); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-md); }
.letter-table-pop hr { border: none; border-top: 1px solid var(--line); margin: 2px 0; }
.letter-paper table td, .letter-paper table th { min-width: 24px; }
.letter-paper [data-page-break] { border-top: 1px dashed #aaa; margin: 10px 0; }
/* Stock order: the declaration shown before agreeing (Order Stock) */
.letter-paper.order-decl { max-height: 46vh; overflow: auto; padding: 20px 24px; font-size: 14px; box-shadow: none; }
.letter-sheet-wrap { overflow-x: auto; }
@media print {
  [data-page-break] { border: none !important; margin: 0 !important; }
}
.field-picker { position: relative; display: inline-block; }
.field-picker > summary { list-style: none; cursor: pointer; }
.field-picker > summary::-webkit-details-marker { display: none; }
.field-picker-pop { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; width: min(460px, 90vw); display: flex; flex-direction: column; gap: 8px; padding: 12px; background: var(--paper-0, #fff); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-md); }
.field-picker-cols { max-height: 240px; overflow: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; }
table.data-table tbody tr.is-subtotal td { background: var(--paper-100); }
.letter-color { position: relative; display: inline-flex; align-items: center; gap: 2px; height: 30px; padding: 0 6px; border-radius: 6px; cursor: pointer; font-weight: 700; }
.letter-color:hover { background: var(--paper-100); }
.letter-color input[type=color] { width: 18px; height: 18px; padding: 0; border: none; background: none; cursor: pointer; }
.letter-zoom { display: inline-flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: var(--paper-0, #fff); }
/* ---------- Print designs ---------- */
.design-item { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: 8px; color: inherit; text-decoration: none; border: 1px solid transparent; margin-bottom: 4px; }
.design-item:hover { background: var(--paper-100); }
.design-item.is-active { border-color: var(--line); background: var(--paper-100); }
.design-section { border-bottom: 1px solid var(--line); padding: 10px 0; }
.design-section > summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }
/* Print designs: a tiny page showing where the stamp space and the two signature lines go. */
.sign-explain { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.sign-explain-page { width: 150px; flex: none; aspect-ratio: 210 / 297; border: 1px solid var(--line); border-radius: 4px; background: var(--white); padding: 8px; display: flex; flex-direction: column; gap: 5px; font-size: 9px; line-height: 1.2; color: var(--ink-500); }
.sign-explain-page .se-gap { height: 30%; border: 1px dashed var(--amber-600); background: var(--amber-100); display: flex; align-items: center; justify-content: center; text-align: center; border-radius: 3px; }
.sign-explain-page .se-text { height: 5px; background: var(--paper-100); border-radius: 2px; }
.sign-explain-page .se-text.short { width: 60%; }
.sign-explain-page .se-sign { margin-top: auto; display: flex; justify-content: space-between; gap: 6px; }
.sign-explain-page .se-sign > div { width: 48%; display: flex; flex-direction: column; }
.sign-explain-page .se-sign > div:last-child { text-align: right; }
.sign-explain-page .se-img { min-height: 11px; }
.sign-explain-page .se-sign i { display: block; border-top: 1px solid var(--ink-700); margin: 2px 0; }
.design-canvas { overflow: auto; max-height: 75vh; background: repeating-conic-gradient(var(--paper-100) 0 25%, transparent 0 50%) 0 0 / 16px 16px; padding: 24px; border-radius: 8px; border: 1px solid var(--line); }
.design-sheet { margin: 0 auto !important; max-width: none !important; box-sizing: border-box; overflow: hidden; background-repeat: no-repeat; box-shadow: 0 2px 12px rgba(0,0,0,.18) !important; line-height: 1.35; }
.kind-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.kind-card { display: flex; gap: 8px; align-items: flex-start; padding: 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.kind-card:has(input:checked) { border-color: var(--brand-600, #1f3a5f); background: var(--paper-100); }
.kind-card span { display: flex; flex-direction: column; } .kind-card small { color: var(--ink-500, #666); }

/* ---------- User Access: all pages grid ---------- */
.page-grid th.grid-col, .page-grid td.grid-col { text-align: center; min-width: 96px; }
.page-grid thead th { position: sticky; top: 0; z-index: 2; background: var(--paper-0, #fff); }
.page-grid tr.grid-group td { background: var(--paper-100); position: sticky; top: 0; }
.page-grid td.is-off { background: repeating-linear-gradient(45deg, transparent 0 6px, var(--paper-100) 6px 12px); opacity: .55; }

/* ---------- Letter pads ---------- */
.pad-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 12px; }
.pad-card { display: flex; gap: 14px; align-items: flex-start; }
/* ---------- Signatories ---------- */
.sig-thumb { position: relative; width: 190px; height: 110px; flex: 0 0 190px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 8px;
  background: repeating-conic-gradient(#f1f1f1 0 25%, #fff 0 50%) 0 0 / 14px 14px; }
.sig-thumb img { max-width: 170px; max-height: 90px; }
.sig-thumb img.seal { position: absolute; right: 4px; bottom: 4px; max-width: 54px; max-height: 54px; opacity: .85; }
.sig-preview { margin-top: 8px; padding: 10px; border: 1px dashed var(--line); border-radius: 8px; background: repeating-conic-gradient(#f1f1f1 0 25%, #fff 0 50%) 0 0 / 14px 14px; }
.sig-preview img { max-width: 100%; max-height: 110px; }

.settle-options { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--paper-100); }

/* Letter / print-design editor: table tools shown while the cursor is in a table
   (public/js/letter-editor.js), and the cells selected for merging. */
.docs-tablebar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; flex-basis: 100%; margin-top: 4px; padding: 4px 6px; border-radius: var(--radius-md); background: var(--brass-050); border: 1px solid var(--brass-100); }
.docs-tablebar[hidden] { display: none; }
.docs-tb-label { font-size: var(--fs-11); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--brass-700); padding: 0 6px 0 2px; }
.docs-tablebar .btn { white-space: nowrap; }
[contenteditable="true"] td.lt-sel, [contenteditable="true"] th.lt-sel { background-color: rgba(37, 99, 235, 0.16) !important; outline: 2px solid #2563eb; outline-offset: -2px; }

/* Data table window (letter-editor.js dataTableDialog) */
.dt-backdrop { z-index: 2500; }
.dt-modal { width: min(880px, calc(100vw - 32px)); max-width: none; }
.dt-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; }
@media (max-width: 720px) { .dt-grid { grid-template-columns: 1fr; } }
.dt-cols { margin-top: 6px; max-height: 46vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-md); padding: 6px 10px; }
.dt-group { border: 0; margin: 0 0 8px; padding: 0; }
.dt-group legend { font-size: var(--fs-11); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-500); padding: 4px 0; }
.dt-group .check-row { padding: 2px 0; }
.dt-order { margin: 6px 0 0; padding-left: 22px; max-height: 40vh; overflow: auto; }
.dt-order li { display: flex; align-items: center; gap: 4px; padding: 3px 0; border-bottom: 1px dashed var(--line); font-size: var(--fs-13); }
.dt-order li span { flex: 1; min-width: 0; }
.dt-order li.text-muted { border: 0; display: list-item; }

/* Top bar Dashboard button with the count of requests waiting (pendingSummary.js). */
.dash-link { display: inline-flex; align-items: center; gap: 6px; position: relative; }
.dash-link .dash-count { padding: 1px 7px; font-size: 11px; }
.dash-link .dash-count::before { display: none; }
@media (max-width: 720px) { .dash-link-text { display: none; } }

/* SYSADMIN: the working company in the top bar (src/lib/adminCompany.js). */
.admin-company { min-width: 200px; max-width: 280px; }
.admin-company .input { height: 32px; padding-top: 4px; padding-bottom: 4px; }
@media (max-width: 720px) { .admin-company { min-width: 0; max-width: 150px; } }

/* Busy state while the server answers (public/js/app.js → Busy cursor). */
html.is-busy, html.is-busy *, html.is-busy-soft, html.is-busy-soft * { cursor: progress !important; }
.busy-layer { position: fixed; inset: 0; z-index: 2147483000; background: transparent; cursor: progress; }
.busy-layer[hidden] { display: none; }
