/* ==========================================================================
   Formulary Manager — design system + internal application styles
   --------------------------------------------------------------------------
   Design language
     Subject      Compounding pharmacy. The artifacts are the master formula
                  sheet, the amber vial, and the stamp struck on a document.
     Devices      (1) THE STAMP. Status is never a rounded pill; it is a
                      thin-ruled rectangle, small caps, wide tracking.
                  (2) FORMULA-SHEET RULES. Tables are hairline horizontal
                      rules only. No zebra, no boxed cells. The CSN column is
                      set in mono and reads as a specification code.
     Restraint    Verdigris is the ONLY accent. It marks actions and the
                  active state and appears nowhere decoratively.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */
:root {
  /* Neutral scale — cool graphite, stainless / cleanroom */
  --n-0:   #FFFFFF;
  --n-25:  #FBFCFC;
  --n-50:  #F7F8F9;
  --n-100: #EDEFF2;
  --n-150: #E4E7EB;
  --n-200: #D8DEE4;
  --n-300: #C0C7CF;
  --n-400: #98A1AC;
  --n-500: #6F7883;
  --n-600: #525A65;
  --n-700: #3A414A;
  --n-800: #262C33;
  --n-900: #1A1F25;
  --n-950: #141A1F;

  /* Accent — verdigris / apothecary teal. The only accent in the system. */
  --vd-50:  #ECF4F3;
  --vd-100: #D3E7E4;
  --vd-200: #A8CFCA;
  --vd-400: #3A8E85;
  --vd-500: #1C6E66;
  --vd-600: #175A54;
  --vd-700: #114742;

  /* Status — each derived from the subject's own world */
  --amber-50:  #FBF3E4;   /* amber glass: pending, awaiting signature */
  --amber-200: #E6CF9D;
  --amber-600: #8A5A12;
  --amber-700: #6E4710;

  --seal-50:   #E8F2EC;   /* seal green: executed, signed, active */
  --seal-200:  #A9CDB8;
  --seal-600:  #1D6B42;
  --seal-700:  #165334;

  --verm-50:   #FBECEA;   /* vermilion: void, expired, destructive */
  --verm-200:  #E8B5AF;
  --verm-600:  #A8322A;
  --verm-700:  #862620;

  /* Semantic */
  --bg:            var(--n-50);
  --surface:       var(--n-0);
  --surface-sunk:  var(--n-25);
  --fg:            var(--n-900);
  --fg-muted:      var(--n-500);
  --fg-subtle:     var(--n-400);
  --rule:          var(--n-200);
  --rule-soft:     var(--n-150);
  --rule-strong:   var(--n-300);
  --accent:        var(--vd-500);
  --accent-hover:  var(--vd-600);
  --accent-weak:   var(--vd-50);
  --focus:         var(--vd-400);

  /* Type */
  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  /* Spacing — dense dashboard scale */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;

  /* Geometry — minimal radius; this is a document system, not a soft app */
  --r-1: 2px;
  --r-2: 3px;
  --r-3: 5px;

  --shadow-1: 0 1px 2px rgba(20, 26, 31, .06);
  --shadow-2: 0 2px 4px rgba(20, 26, 31, .06), 0 1px 2px rgba(20, 26, 31, .04);
  --shadow-pop: 0 12px 32px -8px rgba(20, 26, 31, .22), 0 2px 6px rgba(20, 26, 31, .08);

  --sidebar-w: 248px;
  --topbar-h: 56px;

  --dur: 140ms;
  --ease: cubic-bezier(.2, .6, .3, 1);
}

/* --------------------------------------------------------------------------
   2. Reset + base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv05" 1; /* single-storey l, clearer in dense data */
}

h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

img, svg { display: block; max-width: 100%; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
  margin: 0;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

/* Numbers everywhere must align in columns. */
.mono, .num, td.num, th.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "zero" 1;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-1);
}

::selection { background: var(--vd-100); color: var(--vd-700); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --------------------------------------------------------------------------
   3. Type scale
   -------------------------------------------------------------------------- */
.t-display { font-size: 26px; font-weight: 600; letter-spacing: -.016em; line-height: 1.2; }
.t-h1      { font-size: 21px; font-weight: 600; letter-spacing: -.012em; line-height: 1.25; }
.t-h2      { font-size: 17px; font-weight: 600; letter-spacing: -.008em; line-height: 1.3; }
.t-h3      { font-size: 15px; font-weight: 600; letter-spacing: -.004em; }
.t-body    { font-size: 15px; }
.t-sm      { font-size: 13px; }
.t-xs      { font-size: 12px; }

/* The eyebrow. Shares the stamp's register: small, caps, wide tracking. */
.t-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--fg-subtle);
}

.t-muted  { color: var(--fg-muted); }
.t-subtle { color: var(--fg-subtle); }

/* --------------------------------------------------------------------------
   4. THE STAMP — the system's signature device
   -------------------------------------------------------------------------- */
.stamp {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 6px;
  border: 1px solid currentColor;
  border-radius: var(--r-1);
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  line-height: 1.5;
  white-space: nowrap;
  vertical-align: middle;
  color: var(--n-600);
  background: transparent;
}

/* A stamp carries meaning by colour AND by its word, never colour alone. */
.stamp--neutral { color: var(--n-600); }
.stamp--draft   { color: var(--n-500); border-style: dashed; }
.stamp--pending { color: var(--amber-600); background: var(--amber-50); }
.stamp--signed  { color: var(--seal-600);  background: var(--seal-50); }
.stamp--active  { color: var(--seal-600);  background: var(--seal-50); }
.stamp--void    { color: var(--verm-600);  background: var(--verm-50); }
.stamp--accent  { color: var(--vd-500);    background: var(--vd-50); }

/* Struck across a document: used on the executed-PDF certificate and on a
   voided proposal card. Rotated, heavier, lower contrast — a real impression. */
.stamp--struck {
  padding: 6px 14px;
  border-width: 2px;
  font-size: 15px;
  letter-spacing: .14em;
  transform: rotate(-4deg);
  opacity: .82;
}

/* --------------------------------------------------------------------------
   5. Application shell (internal)
   -------------------------------------------------------------------------- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* -- Sidebar: ink field, hairline rules, verdigris only on the active item -- */
.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--n-950);
  color: var(--n-300);
  border-right: 1px solid var(--n-900);
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  height: var(--topbar-h);
  padding: 0 var(--s-5);
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  flex: none;
}

.sidebar__mark {
  width: 26px;
  height: 26px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--vd-400);
  border-radius: var(--r-1);
  color: var(--vd-200);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -.02em;
}

.sidebar__name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -.008em;
  color: var(--n-0);
  line-height: 1.15;
}

.sidebar__sub {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--n-500);
}

.sidebar__nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--s-4) var(--s-3);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar__section {
  padding: var(--s-5) var(--s-2) var(--s-2);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--n-600);
}
.sidebar__section:first-child { padding-top: var(--s-1); }

.navitem {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 7px var(--s-3);
  border-radius: var(--r-2);
  color: var(--n-300);
  font-size: 13.5px;
  font-weight: 450;
  text-align: left;
  background: none;
  border: 0;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.navitem:hover { background: rgba(255, 255, 255, .055); color: var(--n-0); text-decoration: none; }

.navitem.is-active {
  background: rgba(255, 255, 255, .07);
  color: var(--n-0);
  font-weight: 500;
}
/* The specimen rule: a 1px verdigris mark on the active section. */
.navitem.is-active::before {
  content: "";
  position: absolute;
  left: calc(var(--s-3) * -1 + 1px);
  top: 6px;
  bottom: 6px;
  width: 2px;
  border-radius: 1px;
  background: var(--vd-400);
}

.navitem__icon { width: 16px; height: 16px; flex: none; opacity: .8; }
.navitem.is-active .navitem__icon { opacity: 1; color: var(--vd-200); }
.navitem__count {
  margin-left: auto;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--n-500);
}

.sidebar__foot {
  flex: none;
  border-top: 1px solid rgba(255, 255, 255, .07);
  padding: var(--s-3);
}

.whoami {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  padding: var(--s-2);
  border: 0;
  border-radius: var(--r-2);
  background: none;
  color: inherit;
  cursor: pointer;
  text-align: left;
}
.whoami:hover { background: rgba(255, 255, 255, .055); }
.whoami__name { font-size: 13px; font-weight: 500; color: var(--n-100); }
.whoami__role { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--n-500); }

/* -- Main column -- */
.main { display: flex; flex-direction: column; min-width: 0; background: var(--bg); }

/* The mobile nav scrim is a child of .shell, which is a two-column grid.
   Left in flow it becomes a third grid item, taking column 2 and pushing
   .main onto a second row underneath the sidebar. It only exists on small
   screens, where it is position:fixed anyway, so keep it out of the grid. */
.navscrim { display: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--s-4);
  height: var(--topbar-h);
  padding: 0 var(--s-6);
  background: rgba(247, 248, 249, .88);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--rule);
}

.crumbs { display: flex; align-items: center; gap: var(--s-2); font-size: 13px; min-width: 0; }
.crumbs a { color: var(--fg-muted); }
.crumbs a:hover { color: var(--fg); }
.crumbs__sep { color: var(--n-300); }
.crumbs__here { font-weight: 500; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.topbar__spacer { flex: 1 1 auto; }

.page {
  flex: 1 1 auto;
  padding: var(--s-6) var(--s-6) var(--s-16);
  max-width: 1480px;
  width: 100%;
}
.page--narrow { max-width: 860px; }

.pagehead {
  display: flex;
  align-items: flex-start;
  gap: var(--s-4);
  padding-bottom: var(--s-5);
  margin-bottom: var(--s-5);
  border-bottom: 1px solid var(--rule);
}
.pagehead__text { min-width: 0; flex: 1 1 auto; }
.pagehead__title { font-size: 22px; font-weight: 600; letter-spacing: -.014em; line-height: 1.2; }
.pagehead__meta { margin-top: 3px; font-size: 13px; color: var(--fg-muted); }
.pagehead__actions { display: flex; align-items: center; gap: var(--s-2); flex: none; }

/* --------------------------------------------------------------------------
   6. Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 var(--s-3);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-2);
  background: var(--surface);
  color: var(--fg);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn:hover { background: var(--n-50); border-color: var(--n-400); text-decoration: none; }
.btn:active { background: var(--n-100); }
.btn[disabled], .btn.is-disabled {
  opacity: .5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-1);
}
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--primary:active { background: var(--vd-700); }

.btn--ink {
  background: var(--n-900);
  border-color: var(--n-900);
  color: #fff;
}
.btn--ink:hover { background: var(--n-800); border-color: var(--n-800); }

.btn--ghost { background: transparent; border-color: transparent; color: var(--fg-muted); }
.btn--ghost:hover { background: var(--n-100); border-color: transparent; color: var(--fg); }

.btn--danger { color: var(--verm-600); border-color: var(--verm-200); background: var(--surface); }
.btn--danger:hover { background: var(--verm-50); border-color: var(--verm-600); }

.btn--sm { min-height: 28px; padding: 0 var(--s-2); font-size: 12.5px; }
.btn--lg { min-height: 42px; padding: 0 var(--s-5); font-size: 15px; }
.btn--block { width: 100%; }

/* Icon-only buttons keep a 44px hit area via ::after, but stay visually 28px. */
.btn--icon {
  position: relative;
  min-height: 30px;
  width: 30px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--fg-muted);
}
.btn--icon:hover { background: var(--n-100); color: var(--fg); }
.btn--icon::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: 44px; height: 44px;
  transform: translate(-50%, -50%);
}
.btn--icon svg { width: 16px; height: 16px; }

.btn__spinner {
  width: 13px; height: 13px;
  border: 1.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btnrow { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.btnrow--end { justify-content: flex-end; }
.btnrow--split { justify-content: space-between; }

/* --------------------------------------------------------------------------
   7. Panels
   -------------------------------------------------------------------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-1);
}
.panel + .panel { margin-top: var(--s-5); }

.panel__head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--rule-soft);
}
.panel__title { font-size: 15px; font-weight: 600; letter-spacing: -.004em; }
.panel__sub { font-size: 12.5px; color: var(--fg-muted); margin-top: 1px; }
.panel__head .btnrow { margin-left: auto; }
.panel__body { padding: var(--s-5); }
.panel__body--flush { padding: 0; }
.panel__foot {
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--rule-soft);
  background: var(--surface-sunk);
  border-radius: 0 0 var(--r-3) var(--r-3);
}

.grid { display: grid; gap: var(--s-5); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--sidebar { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
@media (max-width: 1100px) {
  .grid--2, .grid--3, .grid--sidebar { grid-template-columns: minmax(0, 1fr); }
}

/* --------------------------------------------------------------------------
   8. The formula sheet — tables
   -------------------------------------------------------------------------- */
.sheet-wrap { width: 100%; overflow-x: auto; }

.sheet {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.sheet thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: var(--s-2) var(--s-3);
  background: var(--surface);
  border-bottom: 1px solid var(--rule-strong);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .085em;
  text-transform: uppercase;
  color: var(--fg-subtle);
  text-align: left;
  white-space: nowrap;
}
.sheet thead th.num { text-align: right; }

.sheet tbody td {
  padding: var(--s-3);
  border-bottom: 1px solid var(--rule-soft);
  vertical-align: middle;
}
.sheet tbody td.num { text-align: right; }
.sheet tbody tr:last-child td { border-bottom: 0; }

/* No zebra. A single hairline and a quiet hover is the whole treatment. */
.sheet tbody tr { transition: background var(--dur) var(--ease); }
.sheet tbody tr:hover { background: var(--n-25); }
.sheet tbody tr.is-selected { background: var(--vd-50); }

.sheet--clickable tbody tr { cursor: pointer; }

.sheet--tight tbody td { padding: 7px var(--s-3); }

/* The CSN reads as a specification code, not as body text. */
.csn {
  font-family: var(--mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
  color: var(--fg-muted);
  white-space: nowrap;
}

.drug { min-width: 0; }
.drug__name { font-weight: 500; letter-spacing: -.004em; }
.drug__spec {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}

.price { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 500; white-space: nowrap; }
.price--unset { color: var(--fg-subtle); font-weight: 400; font-style: normal; }
.unit { font-size: 11.5px; color: var(--fg-subtle); font-family: var(--sans); }

.rowtools { display: flex; align-items: center; gap: 2px; justify-content: flex-end; opacity: 0; transition: opacity var(--dur) var(--ease); }
tr:hover .rowtools, tr:focus-within .rowtools { opacity: 1; }
@media (hover: none) { .rowtools { opacity: 1; } }

/* --------------------------------------------------------------------------
   9. Toolbar + search
   -------------------------------------------------------------------------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-5);
  border-bottom: 1px solid var(--rule-soft);
  flex-wrap: wrap;
}
.toolbar__spacer { flex: 1 1 auto; }
.toolbar__count { font-family: var(--mono); font-size: 12px; color: var(--fg-subtle); font-variant-numeric: tabular-nums; }

.search {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 200px;
  flex: 0 1 320px;
}
.search svg {
  position: absolute;
  left: 9px;
  width: 15px; height: 15px;
  color: var(--fg-subtle);
  pointer-events: none;
}
.search input {
  width: 100%;
  min-height: 34px;
  padding: 0 var(--s-3) 0 30px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-2);
  background: var(--surface);
  font-size: 13.5px;
}
.search input::placeholder { color: var(--fg-subtle); }
.search input:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px var(--vd-50); }

/* --------------------------------------------------------------------------
   10. Forms
   -------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field + .field { margin-top: var(--s-4); }

.label { font-size: 12.5px; font-weight: 500; color: var(--n-700); }
.label__opt { font-weight: 400; color: var(--fg-subtle); }

.input, .select, .textarea {
  width: 100%;
  min-height: 36px;
  padding: 7px var(--s-3);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-2);
  background: var(--surface);
  font-size: 14px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--vd-50);
}
.input::placeholder, .textarea::placeholder { color: var(--fg-subtle); }
.input[readonly], .input[disabled], .select[disabled], .textarea[disabled] {
  background: var(--n-50);
  color: var(--fg-muted);
  cursor: not-allowed;
}
.textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.input--mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.select {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236F7883' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M4 6.5 8 10.5l4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 15px;
}

/* Money input: the currency mark sits inside the field, mono and quiet. */
.money { position: relative; }
.money__mark {
  position: absolute;
  left: var(--s-3);
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--mono);
  font-size: 14px;
  color: var(--fg-subtle);
  pointer-events: none;
}
.money .input { padding-left: 26px; font-family: var(--mono); font-variant-numeric: tabular-nums; }

.hint { font-size: 12px; color: var(--fg-muted); }
.err { font-size: 12px; color: var(--verm-600); display: flex; align-items: center; gap: 4px; }
.field.has-error .input,
.field.has-error .select,
.field.has-error .textarea { border-color: var(--verm-600); }
.field.has-error .input:focus { box-shadow: 0 0 0 3px var(--verm-50); }

.checkline { display: flex; align-items: flex-start; gap: var(--s-2); font-size: 13.5px; }
.checkline input[type="checkbox"], .checkline input[type="radio"] {
  width: 16px; height: 16px;
  margin-top: 2px;
  flex: none;
  accent-color: var(--accent);
  cursor: pointer;
}
.checkline label { cursor: pointer; }

.fieldrow { display: grid; gap: var(--s-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fieldrow--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fieldrow + .field, .field + .fieldrow, .fieldrow + .fieldrow { margin-top: var(--s-4); }
@media (max-width: 640px) { .fieldrow, .fieldrow--3 { grid-template-columns: minmax(0, 1fr); } }

/* --------------------------------------------------------------------------
   11. Definition list — client information, audit detail
   -------------------------------------------------------------------------- */
.dl { display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: 0; font-size: 13.5px; }
.dl dt {
  padding: 9px 0;
  color: var(--fg-muted);
  border-bottom: 1px solid var(--rule-soft);
  font-size: 12.5px;
}
.dl dd {
  padding: 9px 0;
  border-bottom: 1px solid var(--rule-soft);
  min-width: 0;
  word-break: break-word;
}
.dl dt:last-of-type, .dl dd:last-of-type { border-bottom: 0; }
@media (max-width: 560px) {
  .dl { grid-template-columns: minmax(0, 1fr); }
  .dl dt { border-bottom: 0; padding-bottom: 0; }
}

/* --------------------------------------------------------------------------
   12. Tabs
   -------------------------------------------------------------------------- */
.tabs {
  display: flex;
  gap: var(--s-1);
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--s-5);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  padding: var(--s-3) var(--s-3);
  border: 0;
  background: none;
  color: var(--fg-muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--dur) var(--ease);
}
.tab:hover { color: var(--fg); }
.tab.is-active { color: var(--fg); }
.tab.is-active::after {
  content: "";
  position: absolute;
  left: var(--s-2); right: var(--s-2);
  bottom: -1px;
  height: 2px;
  background: var(--accent);
}
.tab__count {
  margin-left: 5px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-subtle);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   13. Empty states — an invitation to act, never a shrug
   -------------------------------------------------------------------------- */
.empty {
  padding: var(--s-12) var(--s-6);
  text-align: center;
  max-width: 420px;
  margin: 0 auto;
}
.empty__rule {
  width: 32px;
  height: 1px;
  background: var(--rule-strong);
  margin: 0 auto var(--s-5);
}
.empty__title { font-size: 15px; font-weight: 600; margin-bottom: 5px; }
.empty__text { font-size: 13.5px; color: var(--fg-muted); margin-bottom: var(--s-5); }

/* --------------------------------------------------------------------------
   14. Modal
   -------------------------------------------------------------------------- */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: start center;
  padding: var(--s-10) var(--s-4) var(--s-6);
  overflow-y: auto;
  background: rgba(20, 26, 31, .42);
  backdrop-filter: blur(2px);
  animation: fade var(--dur) var(--ease);
}
@keyframes fade { from { opacity: 0; } }

.modal {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-pop);
  animation: rise 180ms var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.modal--wide { max-width: 760px; }
.modal--xwide { max-width: 1080px; }

.modal__head {
  display: flex;
  align-items: flex-start;
  gap: var(--s-4);
  padding: var(--s-5) var(--s-5) var(--s-4);
  border-bottom: 1px solid var(--rule-soft);
}
.modal__title { font-size: 16px; font-weight: 600; letter-spacing: -.008em; }
.modal__sub { font-size: 13px; color: var(--fg-muted); margin-top: 2px; }
.modal__body { padding: var(--s-5); }
.modal__body--scroll { max-height: min(60vh, 560px); overflow-y: auto; }
.modal__foot {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  justify-content: flex-end;
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--rule-soft);
  background: var(--surface-sunk);
  border-radius: 0 0 var(--r-3) var(--r-3);
}
.modal__foot .modal__foot-start { margin-right: auto; }

/* --------------------------------------------------------------------------
   15. Toast
   -------------------------------------------------------------------------- */
.toasts {
  position: fixed;
  z-index: 200;
  bottom: var(--s-5);
  right: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  max-width: 360px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-3);
  background: var(--n-900);
  color: var(--n-100);
  font-size: 13.5px;
  box-shadow: var(--shadow-pop);
  pointer-events: auto;
  animation: toastin 200ms var(--ease);
}
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } }
.toast__bar { width: 2px; align-self: stretch; border-radius: 1px; background: var(--vd-400); flex: none; }
.toast--err .toast__bar { background: var(--verm-200); }
.toast--ok .toast__bar { background: var(--seal-200); }

/* --------------------------------------------------------------------------
   16. Notice
   -------------------------------------------------------------------------- */
.notice {
  display: flex;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--rule);
  border-left-width: 2px;
  border-left-color: var(--n-400);
  border-radius: var(--r-2);
  background: var(--surface-sunk);
  font-size: 13.5px;
}
.notice--info   { border-left-color: var(--vd-500);    background: var(--vd-50); }
.notice--warn   { border-left-color: var(--amber-600);  background: var(--amber-50); }
.notice--danger { border-left-color: var(--verm-600);   background: var(--verm-50); }
.notice--ok     { border-left-color: var(--seal-600);   background: var(--seal-50); }
.notice__title { font-weight: 600; margin-bottom: 2px; }

/* --------------------------------------------------------------------------
   17. Loading
   -------------------------------------------------------------------------- */
.skel {
  background: linear-gradient(90deg, var(--n-100) 25%, var(--n-150) 37%, var(--n-100) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  border-radius: var(--r-1);
  height: 12px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.loading-rows { padding: var(--s-4) var(--s-5); display: flex; flex-direction: column; gap: var(--s-4); }

/* --------------------------------------------------------------------------
   18. Auth pages
   -------------------------------------------------------------------------- */
/* One centred column on a quiet field. The card carries the hairline and
   the page carries nothing else — no split panel, no marketing copy. */
.authpage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--s-10) var(--s-5);
  background: var(--bg);
}

.authwrap {
  width: 100%;
  max-width: 404px;
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
}

.authwrap__mark {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--fg-subtle);
}

.authcard {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-2);
  padding: var(--s-8) var(--s-6) var(--s-6);
}

.authfoot {
  text-align: center;
  font-size: 12.5px;
  color: var(--fg-subtle);
}

@media (max-width: 420px) {
  .authpage { padding: var(--s-6) var(--s-4); }
  .authcard { padding: var(--s-6) var(--s-5); }
}
.authcard__title { font-size: 22px; font-weight: 600; letter-spacing: -.014em; margin-bottom: 5px; }
.authcard__sub { font-size: 14px; color: var(--fg-muted); margin-bottom: var(--s-6); }

/* The verification code: six mono cells, spaced like a stamped serial. */
.codefield {
  display: flex;
  gap: var(--s-2);
  justify-content: center;
}
.codefield input {
  width: 44px;
  height: 54px;
  padding: 0;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-2);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 500;
  text-align: center;
  font-variant-numeric: tabular-nums;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.codefield input:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--vd-50);
}
.codefield input.is-filled { border-color: var(--n-400); }
@media (max-width: 420px) {
  .codefield { gap: 6px; }
  .codefield input { width: 38px; height: 48px; font-size: 19px; }
}

/* --------------------------------------------------------------------------
   19. Utilities
   -------------------------------------------------------------------------- */
.row { display: flex; align-items: center; gap: var(--s-2); }
.row--wrap { flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.col { display: flex; flex-direction: column; }
.gap-1 { gap: var(--s-1); } .gap-2 { gap: var(--s-2); } .gap-3 { gap: var(--s-3); }
.gap-4 { gap: var(--s-4); } .gap-5 { gap: var(--s-5); } .gap-6 { gap: var(--s-6); }
.grow { flex: 1 1 auto; min-width: 0; }
.mt-2 { margin-top: var(--s-2); } .mt-3 { margin-top: var(--s-3); }
.mt-4 { margin-top: var(--s-4); } .mt-5 { margin-top: var(--s-5); } .mt-6 { margin-top: var(--s-6); }
.mb-2 { margin-bottom: var(--s-2); } .mb-3 { margin-bottom: var(--s-3); }
.mb-4 { margin-bottom: var(--s-4); } .mb-5 { margin-bottom: var(--s-5); }
.right { text-align: right; } .center { text-align: center; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.hidden { display: none !important; }

/* --------------------------------------------------------------------------
   20. Mobile shell — the sidebar becomes a sheet
   -------------------------------------------------------------------------- */
.navtoggle { display: none; }

@media (max-width: 880px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 90;
    width: 272px;
    transform: translateX(-100%);
    transition: transform 200ms var(--ease);
  }
  .shell.nav-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-pop); }
  .shell.nav-open .navscrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(20, 26, 31, .42);
  }
  .navtoggle { display: inline-flex; }
  .page { padding: var(--s-5) var(--s-4) var(--s-12); }
  .topbar { padding: 0 var(--s-4); }
  .pagehead { flex-direction: column; gap: var(--s-3); }
  .pagehead__actions { width: 100%; }
}
