@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap;
  src: url(/assets/fonts/inter-5.3.0-400.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap;
  src: url(/assets/fonts/inter-5.3.0-500.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 600 800; font-display: swap;
  src: url(/assets/fonts/inter-5.3.0-600.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono'; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url(/assets/fonts/jetbrains-mono-5.3.0-500.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

:root {
  --brand-navy: #002E4A;
  --brand-navy-hover: #003E63;
  --brand-obsidian: #0E2130;
  --brand-teal: #1A3A4A;
  --brand-gold: #E8A634;
  --ink-primary: #1A1A1A;
  --ink-muted: #56636F;
  --ink-quaternary: #646F7B;
  --ink-inverse: #FFFFFF;
  --ink-2: #4A5763;
  --ink-small: #36434F;
  --turn-ink: #6F4304;
  --turn-tint: #FBF1DF;
  --surface-page: #F3F5F6;
  --surface-card: #FFFFFF;
  --surface-subtle: rgba(11, 45, 72, 0.04);
  --surface-active: rgba(0, 46, 74, 0.07);
  --border-subtle: #DBE1E5;
  --border-hairline: rgba(11, 45, 72, 0.08);
  --border-control: #7A8794;
  --focus-ring: #6490A9;
  --success: #256547;
  --success-bg: rgba(37, 101, 71, 0.08);
  --warning: #8B570E;
  --warning-bg: rgba(139, 87, 14, 0.09);
  --danger: #B13C36;
  --danger-bg: rgba(177, 60, 54, 0.08);
  --info: #226C9B;
  --info-bg: rgba(34, 108, 155, 0.08);
  --shadow-card: 0 1px 3px rgba(11,45,72,0.08), 0 4px 12px rgba(11,45,72,0.05);
  --shadow-raised: 0 4px 16px rgba(11,45,72,0.12), 0 1px 3px rgba(11,45,72,0.08);
  --shadow-modal: 0 16px 48px rgba(11,45,72,0.22), 0 4px 12px rgba(11,45,72,0.10);
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-xl: 12px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 14px; scroll-padding-top: 64px; -webkit-font-smoothing: antialiased; }
body {
  margin: 0; font-family: var(--font-sans); color: var(--ink-primary);
  background: var(--surface-page); line-height: 1.5;
}
a { color: var(--brand-navy); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; border-radius: var(--radius-sm); }

.skip-link {
  position: fixed; top: 12px; left: 16px; z-index: 999;
  padding: 8px 14px; background: var(--brand-navy); color: #fff; border-radius: 999px;
  font-weight: 600; font-size: 12px; transform: translateY(-200%);
}
.skip-link:focus-visible { transform: translateY(0); }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }
.text-literal { font-feature-settings: "calt" 0; }
.muted { color: var(--ink-muted); }
.quat { color: var(--ink-quaternary); }
.eyebrow { font-size: 10px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-quaternary); }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-md); font-size: 13px; font-weight: 600;
  cursor: pointer; border: 1px solid transparent; background: var(--brand-navy); color: #fff;
  font-family: inherit; transition: background 0.1s;
}
.btn:hover { background: var(--brand-navy-hover); text-decoration: none; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn.xs { height: 24px; padding: 0 8px; font-size: 11px; border-radius: var(--radius-sm); }
.btn.secondary { background: #fff; color: var(--ink-primary); border-color: var(--border-subtle); }
.btn.secondary:hover { background: var(--surface-subtle); border-color: var(--border-control); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { background: #962E29; }
.btn.ghost-danger { background: transparent; color: var(--danger); border: 1px solid rgba(177, 60, 54, 0.25); }
.btn.ghost-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.success { background: var(--success); color: #fff; }
.btn.ghost { background: transparent; color: var(--brand-navy); border-color: transparent; padding: 0 8px; }
.btn.ghost:hover { background: var(--surface-subtle); }

/* ── Admin Shell Grid ──────────────────────────────────────────────── */
.admin-layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
/* The rail is a popover where the window is narrow; `inset`, `width` and the rest undo what a browser gives one. */
.admin-portal .admin-rail {
  position: sticky; inset: auto; top: 0; width: auto; height: 100vh; height: 100dvh; margin: 0;
  display: flex; flex-direction: column; padding: 16px 10px 12px; overflow: auto;
  border: 0; border-right: 1px solid var(--border-subtle); background: var(--surface-card); color: inherit;
}
/* Open while the window grows wide: it stays where the rail stands. */
.admin-portal .admin-rail:popover-open { position: fixed; inset: 0 auto 0 0; width: 248px; }
.rail-lockup { display: block; padding: 2px 10px 12px; }
.rail-lockup img { display: block; width: 135px; height: 22px; }
.rail-logo { font-weight: 700; font-size: 16px; letter-spacing: -0.03em; color: var(--brand-navy); display: flex; align-items: center; gap: 8px; }
.rail-logo:hover { text-decoration: none; }
.rust-pill {
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  background: rgba(232, 166, 52, 0.18); color: #7C4D06;
  padding: 2px 6px; border-radius: var(--radius-sm); letter-spacing: 0.04em;
}
.rail-group ul { list-style: none; margin: 0; padding: 0; }
.rail-group-label { margin: 0; padding: 12px 10px 4px; font: 500 12px/16px var(--font-sans); color: var(--ink-2); }
.rail-link {
  display: flex; align-items: center; gap: 8px; min-height: 31px; padding: 0 10px; border-radius: var(--radius-md);
  font: 500 13px/18px var(--font-sans); color: var(--ink-primary);
}
.rail-link:hover { background: var(--surface-subtle); text-decoration: none; }
.rail-link[aria-current] {
  background: var(--surface-active); color: var(--brand-navy); font-weight: 600;
  box-shadow: inset 2px 0 0 var(--brand-navy);
}
.rail-link small { margin-left: auto; font: 400 12px/16px var(--font-sans); color: var(--ink-2); }
.rail-count {
  margin-left: auto; font: 500 12px/16px var(--font-sans); font-variant-numeric: tabular-nums; color: var(--ink-small);
}
.rail-turn {
  margin-left: auto; min-width: 20px; padding: 1px 6px; border: 1px solid var(--brand-gold); border-radius: 10px; text-align: center;
  background: var(--turn-tint); color: var(--turn-ink); font: 600 12px/16px var(--font-sans); font-variant-numeric: tabular-nums;
}
/* Drawn by its border: a background is gone in forced colours. */
.rail-dot { width: 0; height: 0; border: 4px solid var(--brand-navy); border-radius: 50%; }
.rail-me { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--border-hairline); font: 500 13px/18px var(--font-sans); }
.rail-me small { display: block; margin-bottom: 8px; font: 400 12px/16px var(--font-sans); color: var(--ink-2); }
.rail-me .btn { width: 100%; }

/* The last column, also while the open menu is out of the grid. */
.admin-main-col { grid-column-start: -2; display: flex; flex-direction: column; min-width: 0; }
.admin-topbar {
  position: sticky; top: 0; z-index: 40; height: 56px;
  background: var(--surface-card); border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px; gap: 12px;
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.crumb { font-size: 13px; color: var(--ink-muted); white-space: nowrap; }
.crumb strong { color: var(--ink-primary); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.admin-portal .admin-topbar {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0 16px; align-items: center;
  height: auto; min-height: 56px; padding: 0 24px;
}
.admin-portal .crumb { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.rail-menu { display: none; }
.cmd-trigger {
  display: inline-flex; align-items: center; gap: 10px; height: 34px; padding: 0 12px;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-md);
  background: var(--surface-page); color: var(--ink-muted); font-family: inherit; font-size: 12.5px; cursor: pointer;
}
.cmd-trigger:hover { border-color: var(--border-control); color: var(--ink-primary); }
.kbd {
  font-family: var(--font-mono); font-size: 10.5px; padding: 1px 5px;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); background: #fff; color: var(--ink-quaternary);
}

.admin-content { max-width: 1460px; width: 100%; padding: 22px 24px 48px; margin: 0 auto; }
.admin-content--flush {
  max-width: none; padding: 0; margin: 0;
  flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0;
  height: calc(100dvh - 56px); overflow: hidden;
}

/* ── Embedded Muddle Portal Mail Workspace (Clinical Sovereign) ────── */
.mail-shell {
  display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0;
  background: var(--surface-page);
}
.mail-bar {
  flex: 0 0 auto; height: 38px; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface-card); border-bottom: 1px solid var(--border-subtle);
  font-size: 12px; color: var(--ink-muted);
}
.mail-bar-left, .mail-bar-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mail-bar-address { font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--ink-primary); truncate: ellipsis; }
.mail-status-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: var(--surface-subtle); color: var(--ink-2);
}
.mail-status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brand-gold); flex: none; }
.mail-status-pill[data-state="ready"] { background: var(--success-bg); color: var(--success); }
.mail-status-pill[data-state="ready"] .mail-status-dot { background: var(--success); }
.mail-status-pill[data-state="error"] { background: var(--danger-bg); color: var(--danger); }
.mail-status-pill[data-state="error"] .mail-status-dot { background: var(--danger); }
.mail-filter-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--info-bg); color: var(--brand-navy); max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mail-filter-pill a { color: var(--brand-navy); text-decoration: underline; font-weight: 600; }
.mail-stage { position: relative; flex: 1 1 auto; min-height: 0; background: var(--surface-page); }
.mail-frame {
  width: 100%; height: 100%; border: 0; display: block;
  opacity: 0; transition: opacity 180ms cubic-bezier(0.2, 0, 0, 1);
  background: var(--surface-page);
}
.mail-frame[data-ready="1"] { opacity: 1; }
.mail-skeleton {
  position: absolute; inset: 0; z-index: 2;
  display: grid; grid-template-columns: 220px 320px minmax(0, 1fr);
  background: var(--surface-page);
}
.mail-skel-col { padding: 16px; border-right: 1px solid var(--border-subtle); display: flex; flex-direction: column; gap: 10px; }
.mail-skel-col:last-child { border-right: 0; background: var(--surface-card); }
.mail-skel-bar {
  height: 12px; border-radius: var(--radius-sm);
  background: linear-gradient(90deg, rgba(11,45,72,0.06) 25%, rgba(11,45,72,0.11) 50%, rgba(11,45,72,0.06) 75%);
  background-size: 200% 100%; animation: mail-shimmer 1.4s ease-in-out infinite;
}
.mail-skel-bar.w40 { width: 40%; }
.mail-skel-bar.w60 { width: 60%; }
.mail-skel-bar.w80 { width: 80%; }
.mail-skel-bar.h28 { height: 28px; border-radius: var(--radius-md); }
@keyframes mail-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .mail-skel-bar { animation: none; } }
@media (max-width: 900px) {
  .mail-skeleton { grid-template-columns: minmax(0, 1fr); }
  .mail-skel-col:nth-child(2), .mail-skel-col:nth-child(3) { display: none; }
}
.mail-error {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 28px; background: var(--surface-card); text-align: center;
}
.mail-error h2 { margin: 0; font-size: 16px; font-weight: 700; color: var(--ink-primary); }
.mail-error p { margin: 0; max-width: 440px; font-size: 13px; color: var(--ink-muted); }

/* ── The line and the palette ──────────────────────────────────────── */
.bar-line { display: flex; align-items: center; gap: 4px 12px; min-width: 0; font: 400 13px/18px var(--font-sans); color: var(--ink-primary); }
.bar-line > .said { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-line > :is(a, button) {
  flex: none; padding: 4px 0; border: 0; background: none; color: var(--brand-navy); font: 600 13px/18px var(--font-sans);
  text-decoration: underline; cursor: pointer;
}
#palette {
  width: min(600px, 100vw - 32px); max-height: 70vh; margin: 10vh auto 0; padding: 0; overflow: hidden;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-xl); background: #fff; color: var(--ink-primary);
  box-shadow: var(--shadow-modal);
}
#palette[open] { display: flex; flex-direction: column; }
#palette::backdrop { background: rgba(14, 33, 48, 0.55); }
#palette input {
  flex: none; width: 100%; padding: 15px 18px; border: 0; border-bottom: 1px solid var(--border-subtle); font: 400 16px/24px var(--font-sans);
}
#palette input:focus-visible { outline-offset: -3px; }
#palette ul { margin: 0; padding: 8px; overflow-y: auto; list-style: none; }
#palette [role=option] {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 9px 12px; border: 0;
  border-radius: var(--radius-md); background: none; color: inherit; font: 500 13px/18px var(--font-sans); text-align: left; cursor: pointer;
}
#palette [role=option]:hover { background: var(--surface-subtle); text-decoration: none; }
#palette [aria-selected=true] { background: var(--surface-active); outline: 2px solid transparent; }
#palette small { flex: none; font: 400 12px/16px var(--font-sans); color: var(--ink-2); }
.palette-said { margin: 0; padding: 0 20px 14px; font: 400 13px/18px var(--font-sans); color: var(--ink-2); }
.palette-said:empty { padding: 0; }

@media (max-width: 900px) {
  .admin-layout { grid-template-columns: minmax(0, 1fr); }
  .rail-menu { display: inline-flex; min-height: 44px; }
  .admin-portal .admin-rail:not(:popover-open) { display: none; }
  .admin-portal .admin-rail:popover-open { width: min(300px, 86vw); box-shadow: var(--shadow-modal); }
  .admin-rail::backdrop { background: rgba(14, 33, 48, 0.34); }
  .admin-portal .rail-link { min-height: 44px; }
  .admin-portal .admin-topbar { padding: 0 12px; column-gap: 8px; }
  .admin-portal .bar-line { grid-column: 1 / -1; grid-row: 2; }
  .admin-portal .bar-line:not(:empty) { padding-bottom: 8px; }
  .bar-line > .said { white-space: normal; }
  .bar-line > :is(a, button) { min-height: 44px; }
  .admin-portal .cmd-trigger { min-width: 44px; height: 44px; justify-content: center; }
  .admin-portal .cmd-trigger :is(span, kbd) {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
}
/* A browser without popover keeps the rail above the page, as it was. */
@supports not selector(:popover-open) {
  @media (max-width: 900px) {
    .rail-menu { display: none; }
    .admin-portal .admin-rail { position: relative; height: auto; border-right: 0; border-bottom: 1px solid var(--border-subtle); }
  }
}

/* ── Page Header, Panels, Stats, Tabs ──────────────────────────────── */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -0.025em; color: var(--ink-primary); }
.page-sub { margin: 3px 0 0; font-size: 13px; color: var(--ink-muted); }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.panel {
  background: var(--surface-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); padding: 16px 18px; margin-bottom: 16px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head h2, .panel-head h3 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -0.015em; }

.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card {
  background: var(--surface-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); padding: 14px 16px; display: block; color: inherit;
}
a.stat-card:hover { text-decoration: none; box-shadow: var(--shadow-card); border-color: var(--border-control); }
.stat-label { font-size: 11.5px; font-weight: 600; color: var(--ink-muted); margin-bottom: 6px; }
.stat-value { font-size: 23px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: var(--ink-primary); line-height: 1.15; }
.stat-meta { font-size: 11.5px; color: var(--ink-muted); margin-top: 4px; }
.stat-card.danger .stat-value { color: var(--danger); }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.warning .stat-value { color: var(--warning); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }

/* ── Controls, Buttons, Inputs, Badges ─────────────────────────────── */
.input, .select, .textarea {
  height: 36px; padding: 0 11px; border: 1px solid var(--border-control); border-radius: var(--radius-md);
  background: #fff; color: var(--ink-primary); font-family: inherit; font-size: 13px; width: 100%;
}
.textarea { height: auto; padding: 8px 11px; min-height: 76px; resize: vertical; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-primary); margin-bottom: 4px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; align-items: end; }

.toolbar {
  background: var(--surface-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); padding: 12px 14px; margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.tabs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.tab {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px;
  border-radius: var(--radius-md); font-size: 12.5px; font-weight: 600; color: var(--ink-muted);
}
.tab:hover { background: var(--surface-subtle); color: var(--ink-primary); text-decoration: none; }
.tab.active { background: var(--brand-navy); color: #fff; }
.tab .cnt { font-family: var(--font-mono); font-size: 11px; opacity: 0.85; }

.badge {
  display: inline-flex; align-items: center; padding: 2px 7px; border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; white-space: nowrap;
}
.badge.neutral { background: var(--surface-subtle); color: var(--ink-muted); }
.badge.success { background: var(--success-bg); color: var(--success); }
.badge.warning { background: var(--warning-bg); color: var(--warning); }
.badge.vendor { background: #FEF9C3; color: #715600; border: 1px solid #E5C94B; }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.info { background: var(--info-bg); color: var(--info); }

.flag-btn {
  font-family: inherit;
  line-height: 1.25;
  border: 1px solid currentColor;
  border-color: color-mix(in srgb, currentColor 28%, transparent);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.12s, background-color 0.12s, border-color 0.12s;
}
.flag-btn:hover:not(:disabled) {
  box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 22%, transparent);
  transform: translateY(-0.5px);
}
.flag-btn:disabled { opacity: 0.7; cursor: wait; }
@keyframes flag-flash {
  0%   { background: #F59E0B; color: #0E2130; border-color: #B45309; box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.48); }
  100% { background: #FEF3C7; color: #7C2D12; border-color: #D97706; box-shadow: 0 0 0 1px rgba(217, 119, 6, 0.25); }
}
.flag-btn.flag-pending {
  animation: flag-flash 0.42s ease-in-out infinite alternate;
  font-weight: 700;
}
tr.row-flag-committed,
tbody tr[data-href].row-flag-committed {
  background: rgba(37, 101, 71, 0.08);
  opacity: 0.72;
}
tr.row-flag-pending,
tbody tr[data-href].row-flag-pending,
tbody tr[data-href].row-flag-pending:hover {
  background: rgba(245, 158, 11, 0.13);
  opacity: 1;
}
.flag-btn.flag-saving { opacity: 0.78; cursor: wait; }
.flag-btn.flag-committed { box-shadow: 0 0 0 2px rgba(37, 101, 71, 0.35); }

.notice {
  padding: 12px 14px; border-radius: var(--radius-md); font-size: 13px; margin-bottom: 14px;
  border: 1px solid var(--border-subtle); background: var(--surface-card);
}
.notice.info { background: var(--info-bg); border-color: rgba(34,108,155,0.22); color: var(--info); }
.notice.success { background: var(--success-bg); border-color: rgba(37,101,71,0.22); color: var(--success); }
.notice.warning { background: var(--warning-bg); border-color: rgba(139,87,14,0.22); color: var(--warning); }
.notice.danger { background: var(--danger-bg); border-color: rgba(177,60,54,0.22); color: var(--danger); }

/* ── Tables ────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-quaternary); padding: 9px 10px; border-bottom: 1px solid var(--border-subtle); white-space: nowrap;
}
td { padding: 10px 10px; border-bottom: 1px solid var(--border-hairline); vertical-align: middle; }
tbody tr:hover { background: var(--surface-subtle); }
tbody tr[data-href] { cursor: pointer; }
tbody tr[data-href]:hover { background: var(--surface-active); }
tfoot td {
  border-top: 2px solid var(--border-subtle); border-bottom: 0;
  font-weight: 700; background: var(--surface-subtle);
}
.window-link { color: inherit; font-weight: 500; display: inline-flex; align-items: center; gap: 4px; }
.window-link:hover { text-decoration: none; color: var(--brand-navy); }
.window-arrow { color: var(--ink-quaternary); font-size: 12px; opacity: 0.45; transition: opacity 0.1s, transform 0.1s; }
tbody tr[data-href]:hover .window-arrow, .window-link:hover .window-arrow { opacity: 1; color: var(--brand-navy); transform: translateX(2px); }
.td-num, .th-num { text-align: right; font-variant-numeric: tabular-nums; }
th[data-sortable="1"] {
  cursor: pointer;
  user-select: none;
  transition: color 0.1s, background-color 0.1s;
}
th[data-sortable="1"]:hover { color: var(--brand-navy); background: var(--surface-subtle); }
th[data-sortable="1"]::after { content: ' \21C5'; opacity: 0.3; font-size: 10px; margin-left: 3px; }
th[data-sortable="1"][aria-sort="ascending"],
th[data-sortable="1"][aria-sort="descending"] { color: var(--brand-navy); }
th[data-sortable="1"][aria-sort="ascending"]::after { content: ' \25B2'; opacity: 1; color: var(--brand-navy); }
th[data-sortable="1"][aria-sort="descending"]::after { content: ' \25BC'; opacity: 1; color: var(--brand-navy); }
.filter-pills { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.filter-pill {
  padding: 3px 9px; border-radius: var(--radius-sm); font-size: 11px; font-weight: 600;
  border: 1px solid var(--border-subtle); background: #fff; color: var(--ink-muted); cursor: pointer;
  font-family: inherit;
}
.filter-pill:hover { border-color: var(--border-control); color: var(--ink-primary); }
.filter-pill.active { background: var(--brand-navy); color: #fff; border-color: var(--brand-navy); }
.panel-highlight { box-shadow: 0 0 0 3px rgba(37, 101, 71, 0.35); border-color: var(--success); }

/* ── Public & Entry Surfaces ───────────────────────────────────────── */
.pub-body { background: #fff; }
.pub-header {
  max-width: 1160px; margin: 0 auto; padding: 18px 24px;
  display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border-hairline);
  flex-wrap: wrap; gap: 12px;
}
.pub-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 18px; font-size: 13.5px; font-weight: 500; }
.pub-hero { max-width: 1160px; margin: 0 auto; padding: 64px 24px 56px; display: grid; grid-template-columns: 1.25fr 1fr; gap: 48px; align-items: center; }
.pub-hero h1 { font-size: clamp(34px, 4.8vw, 56px); line-height: 1.05; letter-spacing: -0.045em; margin: 14px 0 18px; color: var(--brand-navy); }
.pub-card {
  background: var(--brand-navy); color: #fff; border-radius: var(--radius-xl); padding: 36px;
  border-top: 4px solid var(--brand-gold);
}
.pub-form { max-width: 640px; margin: 40px auto; padding: 0 16px; }
.pub-form h1 { margin: 0 0 6px; font-size: 26px; letter-spacing: -0.03em; }
.pub-form h2 { margin: 0 0 8px; font-size: 18px; }
.pub-form .input, .pub-form .select, .pub-form .textarea { font-size: 16px; min-height: 46px; }
.pub-form input[type="file"] { padding: 9px; }
.pub-form .btn { min-height: 44px; white-space: normal; }
.pub-form fieldset { border: 0; padding: 0; margin: 0 0 12px; min-width: 0; }
.pub-form legend { font-size: 13px; font-weight: 600; padding: 0; margin-bottom: 6px; }
.pub-form .check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; font-size: 13.5px; line-height: 1.45; }
.pub-form .check input { width: 20px; height: 20px; margin: 0; flex: none; }
.pub-form .check label { font-weight: 400; margin: 0; }
.pub-form .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.pub-form .field-note { margin: 4px 0 0; font-size: 12.5px; color: var(--ink-muted); }
.pub-form .field-problem { margin: 4px 0 0; font-size: 13px; color: var(--danger); }
.pub-form dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 14px 0; font-size: 13.5px; }
.pub-form dd { margin: 0; text-align: right; }
.pub-form .message { white-space: pre-line; overflow-wrap: anywhere; }
.pub-legal { max-width: 760px; margin: 48px auto; padding: 0 20px; font-size: 15px; line-height: 1.7; overflow-wrap: anywhere; }
.pub-legal h1 { margin: 8px 0; font-size: 30px; letter-spacing: -0.03em; }
.pub-legal h2 { margin: 36px 0 8px; font-size: 18px; }
.entry-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--surface-page); }
.entry-card { width: 100%; max-width: 440px; background: #fff; border: 1px solid var(--border-subtle); border-radius: var(--radius-xl); padding: 28px; }

.wallet-list { display: flex; flex-direction: column; gap: 8px; }
.wallet-option {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 9px 12px; border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); background: #fff; color: var(--ink-primary);
  font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  text-align: left; transition: border-color 0.1s, background 0.1s;
}
.wallet-option:hover:not(:disabled) { border-color: var(--brand-navy); background: var(--surface-subtle); }
.wallet-option:disabled { opacity: 0.6; cursor: not-allowed; }
.wallet-option-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.wallet-icon { width: 22px; height: 22px; border-radius: 5px; flex-shrink: 0; object-fit: contain; }

.bar-track { height: 8px; background: var(--surface-subtle); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--brand-navy); border-radius: 999px; }

/* ── Testing & COA Management Workbench ────────────────────────────── */
.coa-workbench { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr); gap: 18px; align-items: start; }
.coa-doc-pane { position: sticky; top: 72px; }
.coa-review-pane { min-width: 0; }
.dropzone {
  border: 2px dashed var(--border-control); border-radius: var(--radius-lg);
  padding: 22px 18px; text-align: center; cursor: pointer;
  background: var(--surface-page); transition: border-color 0.12s, background-color 0.12s;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--brand-navy); background: var(--surface-active);
}
.dropzone-label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-primary); }
.coa-test-card {
  border: 1px solid var(--border-subtle); border-radius: var(--radius-md);
  padding: 12px 14px; background: var(--surface-page);
}
.coa-test-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cov-pills { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.cov-pill {
  display: inline-flex; align-items: center; padding: 2px 6px; border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; letter-spacing: 0.03em;
  background: var(--surface-subtle); color: var(--ink-quaternary); border: 1px solid var(--border-hairline);
}
.cov-pill.pass {
  background: var(--success-bg); color: var(--success); border-color: rgba(37, 101, 71, 0.25);
}
.test-flags {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
  max-width: 268px;
}
.test-flags.wide { max-width: none; }
.test-flag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.3;
  white-space: nowrap;
  cursor: default;
}
.test-flag.none {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(177, 60, 54, 0.32);
}
.test-flag.vendor {
  background: #FEF9C3;
  color: #715600;
  border: 1px solid #E5C94B;
}
.test-flag.own {
  background: #E4F5EC;
  color: #1B5E3F;
  border: 1px solid rgba(37, 101, 71, 0.34);
}
.test-flag.gold {
  background: linear-gradient(135deg, #FBE48C 0%, #E8A634 56%, #CA8210 100%);
  color: #2A1800;
  border: 1px solid #B57208;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 1px 2px rgba(181, 114, 8, 0.2);
}
.test-flag.flag-btn {
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.12s, background-color 0.12s, border-color 0.12s;
}
.test-flag.flag-btn:hover:not(:disabled) {
  box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 24%, transparent);
  transform: translateY(-0.5px);
}
.test-flag.flag-btn:focus-visible {
  outline: 2px solid var(--brand-navy);
  outline-offset: 1px;
}
.test-flag.flag-btn.flag-pending {
  background: #F59E0B;
  color: #0E2130;
  border-color: #B45309;
  animation: flag-flash 0.42s ease-in-out infinite alternate;
}
.test-flag.flag-btn.flag-saving {
  opacity: 0.78;
  cursor: wait;
}
.test-flag.flag-btn.flag-committed {
  box-shadow: 0 0 0 2px rgba(37, 101, 71, 0.35);
}
.test-flag-legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--ink-muted);
}
.stepper { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.step {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: var(--radius-md); border: 1px solid var(--border-subtle); background: var(--surface-page);
}
.step.done { background: var(--success-bg); border-color: rgba(37, 101, 71, 0.25); }
.step.current { background: var(--info-bg); border-color: rgba(34, 108, 155, 0.35); }
.step.alert { background: var(--danger-bg); border-color: rgba(177, 60, 54, 0.35); }
.step-dot {
  width: 24px; height: 24px; border-radius: 999px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  background: #fff; border: 1px solid var(--border-subtle); color: var(--ink-muted);
}
.step.done .step-dot { background: var(--success); border-color: var(--success); color: #fff; }
.step.current .step-dot { background: var(--info); border-color: var(--info); color: #fff; }
.step.alert .step-dot { background: var(--danger); border-color: var(--danger); color: #fff; }
.step-title { font-size: 12px; font-weight: 700; color: var(--ink-primary); line-height: 1.2; }
.step-meta { font-size: 10.5px; color: var(--ink-muted); margin-top: 2px; }

/* Substance / Mass -> Stacked Batches -> Per-Batch COAs & Vial Cap/Band Color Badges */
.product-stack {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  margin-bottom: 14px;
  overflow: hidden;
}
.product-stack > summary.product-stack-head {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: linear-gradient(180deg, rgba(0, 46, 74, 0.035), rgba(0, 46, 74, 0.015));
  border-bottom: 1px solid var(--border-hairline);
}
.product-stack:not([open]) > summary.product-stack-head { border-bottom: 0; }
.product-stack > summary.product-stack-head::-webkit-details-marker { display: none; }
.product-stack-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.product-stack-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stack-caret {
  display: inline-block;
  font-size: 12px;
  color: var(--ink-muted);
  transition: transform 0.14s ease;
}
.product-stack:not([open]) .stack-caret { transform: rotate(-90deg); }
.stack-name { font-size: 15px; color: var(--brand-navy); text-decoration: none; }
.stack-name:hover { text-decoration: underline; }
.stack-mass { font-family: var(--font-mono); font-size: 13.5px; font-weight: 600; color: var(--ink-secondary); }
.fifo-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  background: rgba(0, 46, 74, 0.09);
  color: var(--brand-navy);
}
.cap-band-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-primary);
  background: #fff;
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}
.cap-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  flex-shrink: 0;
}
.band-dot {
  width: 10px;
  height: 6px;
  border-radius: 2px;
  display: inline-block;
  flex-shrink: 0;
}
.coa-chip-list { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 4px; }
.coa-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--border-subtle);
  background: var(--surface-page);
  color: var(--ink-secondary);
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.coa-chip:hover { border-color: var(--brand-navy); color: var(--brand-navy); }
.coa-chip.verified { background: var(--success-bg); border-color: rgba(37, 101, 71, 0.25); color: var(--success); }
.coa-chip.pending { background: var(--warning-bg); border-color: rgba(180, 118, 22, 0.30); color: var(--warning); }
.coa-chip.vendor { background: #FEF9C3; border-color: #E5C94B; color: #715600; }
.coa-chip.danger { background: var(--danger-bg); border-color: rgba(177, 60, 54, 0.30); color: var(--danger); }
.sibling-strip {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 14px;
}
.sibling-strip-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-secondary);
  margin-bottom: 8px;
}
.sibling-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.sibling-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 8px;
  font-size: 11.5px;
  text-decoration: none;
  color: var(--ink-primary);
  background: var(--surface-page);
  border: 1px solid var(--border-subtle);
}
.sibling-pill:hover { border-color: var(--brand-navy); }
.sibling-pill.active {
  background: var(--info-bg);
  border-color: var(--brand-navy);
  box-shadow: 0 0 0 1px rgba(0, 46, 74, 0.14);
}
.view-toggle { display: inline-flex; gap: 4px; align-items: center; }
.view-toggle .btn.active { border-color: var(--brand-navy); color: var(--brand-navy); font-weight: 700; }

/* ── Print Studio Slide-Over Drawer & Bulk Print Bar ─────────────────── */
.drawer-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(14, 33, 48, 0.42); backdrop-filter: blur(2px);
  display: flex; justify-content: flex-end;
  opacity: 0; transition: opacity 0.16s ease;
}
.drawer-backdrop.open { opacity: 1; }
.print-drawer {
  width: min(580px, 100vw); height: 100%; max-height: 100%; max-width: 100vw;
  background: var(--surface-card); box-shadow: var(--shadow-modal);
  display: flex; flex-direction: column; overflow: hidden;
  border-left: 1px solid var(--border-subtle);
  transition: width 0.2s ease;
}
.print-drawer.with-preview { width: min(1020px, 100vw); }
.print-drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-card); flex-shrink: 0;
}
.print-drawer-head h2 { margin: 0; font-size: 16px; font-weight: 700; color: var(--ink-primary); }
.print-drawer-sub { font-size: 12px; color: var(--ink-muted); margin-top: 2px; }
.print-drawer-workspace {
  display: flex; flex: 0 1 auto; min-height: 0; overflow: hidden;
}
.print-drawer.with-preview .print-drawer-workspace { flex: 1 1 auto; }
.print-drawer-body {
  flex: 1 1 auto; min-width: 0; min-height: 0; overflow-y: auto; padding: 16px 20px 20px;
}
.print-drawer > .print-drawer-body { flex: 0 1 auto; }
.print-preview-pane {
  width: 440px; flex-shrink: 0; border-left: 1px solid var(--border-subtle);
  background: #E9EEF2; display: flex; flex-direction: column;
}
.print-preview-pane-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; background: var(--surface-card); border-bottom: 1px solid var(--border-subtle);
  font-size: 12px; font-weight: 600; color: var(--ink-muted);
}
.print-preview-pane iframe {
  width: 100%; flex: 1; border: 0; background: #525659;
}
.print-drawer-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 20px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-hairline);
  background: var(--surface-page); flex-shrink: 0;
}
.station-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 9px 12px; border-radius: var(--radius-md);
  background: var(--surface-subtle); border: 1px solid var(--border-hairline);
  margin-bottom: 14px; font-size: 12px;
}
.station-bar.offline { background: var(--warning-bg); border-color: rgba(139, 87, 14, 0.25); color: var(--warning); }
.station-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--success); display: inline-block; flex-shrink: 0; }
.station-dot.offline { background: var(--warning); }
.print-stock-group {
  border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
  margin-bottom: 14px; overflow: hidden; background: var(--surface-card);
}
.print-stock-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; background: var(--surface-page); border-bottom: 1px solid var(--border-hairline);
}
.print-stock-title { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--brand-navy); display: flex; align-items: center; gap: 6px; }
.print-stock-tag { font-family: var(--font-mono); font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: var(--radius-sm); background: #fff; border: 1px solid var(--border-subtle); color: var(--ink-muted); text-transform: none; letter-spacing: 0; }
.print-entry-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-bottom: 1px solid var(--border-hairline); transition: background 0.1s;
}
.print-entry-row:last-child { border-bottom: 0; }
.print-entry-row:hover { background: var(--surface-subtle); }
.print-entry-row.blocked { opacity: 0.65; background: rgba(11, 45, 72, 0.02); }
.print-entry-main { flex: 1; min-width: 0; }
.print-entry-title { font-size: 13px; font-weight: 600; color: var(--ink-primary); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.print-entry-sub { font-size: 11.5px; color: var(--ink-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.print-entry-blocker { font-size: 11px; color: var(--warning); margin-top: 3px; font-weight: 500; }
.qty-stepper {
  display: inline-flex; align-items: center; border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); background: #fff; overflow: hidden; flex-shrink: 0;
}
.qty-stepper button {
  width: 26px; height: 28px; border: 0; background: transparent; cursor: pointer;
  font-weight: 700; font-size: 13px; color: var(--brand-navy);
}
.qty-stepper button:hover:not(:disabled) { background: var(--surface-subtle); }
.qty-stepper button:disabled { opacity: 0.35; cursor: not-allowed; }
.qty-stepper input {
  width: 44px; height: 28px; border: 0; border-left: 1px solid var(--border-hairline);
  border-right: 1px solid var(--border-hairline); text-align: center;
  font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--ink-primary);
}
.qty-stepper input:focus { outline: none; background: var(--surface-subtle); }
.print-only-btn {
  border: 0; background: transparent; color: var(--ink-muted); font-size: 11px;
  font-weight: 600; cursor: pointer; padding: 4px 6px; border-radius: var(--radius-sm);
}
.print-only-btn:hover { background: var(--surface-subtle); color: var(--brand-navy); }
.bulk-print-bar {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 120;
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--brand-obsidian); color: #fff; border-radius: 999px;
  box-shadow: var(--shadow-modal); font-size: 13px; font-weight: 600;
}
.bulk-print-bar .btn { height: 30px; font-size: 12px; }
.post-pack-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; border-radius: var(--radius-lg); margin-bottom: 16px;
  background: linear-gradient(90deg, rgba(0, 46, 74, 0.06), rgba(232, 166, 52, 0.10));
  border: 1px solid rgba(0, 46, 74, 0.18);
}
.sl-picker-list {
  border: 1px solid var(--border-subtle); border-radius: var(--radius-md);
  background: var(--surface-card); max-height: 360px; overflow-y: auto;
}
.sl-picker-row {
  width: 100%; text-align: left; border: 0; background: transparent;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-bottom: 1px solid var(--border-hairline);
  cursor: pointer; font-family: inherit; color: var(--ink-primary); transition: background 0.1s;
}
.sl-picker-row:last-child { border-bottom: 0; }
.sl-picker-row:hover { background: var(--surface-subtle); }
.sl-picker-name { font-size: 13px; font-weight: 650; color: var(--ink-primary); }
.sl-picker-meta { font-size: 11.5px; color: var(--ink-muted); margin-top: 2px; }
.sl-addr-pills {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px;
}
.sl-pill {
  border: 1px solid var(--border-subtle); background: var(--surface-subtle);
  color: var(--ink-secondary); border-radius: 999px; padding: 3px 10px;
  font-size: 11.5px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.sl-pill:hover { border-color: var(--brand-navy); color: var(--brand-navy); }
.sl-pill.active { background: var(--brand-navy); border-color: var(--brand-navy); color: #fff; }
.sl-sender-preview {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px; border-radius: var(--radius-md);
  background: var(--surface-page); border: 1px solid var(--border-hairline);
  font-size: 11.5px; color: var(--ink-muted); margin-top: 10px;
}

/* ── Order System Studio (Clinical Sovereign) ─────────────────────── */
.os-hero {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border-subtle);
}
.os-back-link {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600;
  color: var(--ink-muted); margin-bottom: 6px; transition: color 0.12s;
}
.os-back-link:hover { color: var(--brand-navy); text-decoration: none; }
.os-hero h1 {
  margin: 0; font-size: 24px; font-weight: 750; letter-spacing: -0.03em; color: var(--brand-obsidian);
  line-height: 1.15;
}
.os-hero-sub { margin: 4px 0 0; font-size: 13px; color: var(--ink-muted); }

.os-grid {
  display: grid; grid-template-columns: minmax(0, 1.72fr) minmax(340px, 410px);
  gap: 22px; align-items: start;
}
.os-stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

.os-card {
  background: var(--surface-card); border: 1px solid var(--border-subtle);
  border-radius: 14px; padding: 20px 22px; box-shadow: var(--shadow-card);
}
.os-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.os-card-title { display: flex; align-items: center; gap: 10px; }
.os-step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--brand-navy); color: #fff;
  font-family: var(--font-mono); font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
  flex-shrink: 0;
}
.os-card-title h2 {
  margin: 0; font-size: 15.5px; font-weight: 700; letter-spacing: -0.02em; color: var(--brand-obsidian);
}
.os-card-sub { font-size: 12px; color: var(--ink-muted); margin-top: 1px; }

/* Segmented Control */
.os-seg {
  display: inline-flex; align-items: center; gap: 3px; padding: 3px;
  background: var(--surface-page); border: 1px solid var(--border-subtle);
  border-radius: 10px; flex-wrap: wrap;
}
.os-seg-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 13px; border: 0; border-radius: 7px;
  background: transparent; color: var(--ink-muted);
  font-family: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  transition: background 0.14s, color 0.14s, box-shadow 0.14s;
  text-decoration: none;
}
.os-seg-btn:hover { color: var(--ink-primary); text-decoration: none; }
.os-seg-btn.active {
  background: #fff; color: var(--brand-navy);
  box-shadow: 0 1px 3px rgba(11,45,72,0.12), 0 1px 1px rgba(11,45,72,0.06);
}
.os-seg-count {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 700;
  padding: 1px 6px; border-radius: 999px; background: var(--surface-subtle); color: var(--ink-muted);
}
.os-seg-btn.active .os-seg-count { background: rgba(0, 46, 74, 0.09); color: var(--brand-navy); }

/* Client Picker & Account Health Card */
.os-client-grid {
  display: grid; grid-template-columns: minmax(220px, 1fr) minmax(260px, 1.35fr);
  gap: 12px; margin-top: 14px;
}
.os-search-wrap { position: relative; }
.os-search-icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--ink-quaternary); font-size: 13px; pointer-events: none;
}
.os-search-input { padding-left: 32px !important; }
.os-health-card {
  margin-top: 14px; padding: 13px 15px; border-radius: 10px;
  background: linear-gradient(135deg, rgba(0, 46, 74, 0.03), rgba(232, 166, 52, 0.04));
  border: 1px solid rgba(0, 46, 74, 0.12);
}
.os-health-card.warn {
  background: linear-gradient(135deg, rgba(139, 87, 14, 0.06), rgba(177, 60, 54, 0.04));
  border-color: rgba(139, 87, 14, 0.28);
}
.os-health-top {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.os-health-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.os-avatar {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--brand-navy); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; letter-spacing: 0.03em; flex-shrink: 0;
}
.os-health-name { font-size: 13.5px; font-weight: 700; color: var(--brand-obsidian); line-height: 1.25; }
.os-health-meta { font-size: 11.5px; color: var(--ink-muted); }
.os-health-metrics {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px;
  margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--border-hairline);
}
.os-metric-lbl { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-quaternary); }
.os-metric-val { font-family: var(--font-mono); font-size: 13px; font-weight: 700; color: var(--ink-primary); margin-top: 2px; }
.os-credit-track {
  height: 5px; border-radius: 999px; background: rgba(11, 45, 72, 0.10);
  overflow: hidden; margin-top: 9px;
}
.os-credit-fill {
  height: 100%; border-radius: 999px; background: var(--success); transition: width 0.25s ease;
}
.os-credit-fill.mid { background: var(--brand-gold); }
.os-credit-fill.high { background: var(--danger); }

/* Visual Product Catalog Picker */
.os-catalog-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap; margin-bottom: 12px;
}
.os-catalog-search { flex: 1; min-width: 210px; }
.os-prod-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 9px; max-height: 330px; overflow-y: auto; padding: 2px 3px 4px 2px;
  scrollbar-width: thin;
}
.os-prod-card {
  display: flex; flex-direction: column; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border-subtle); background: #fff;
  transition: border-color 0.12s, box-shadow 0.12s, transform 0.1s;
  cursor: pointer; position: relative;
}
.os-prod-card:hover {
  border-color: var(--brand-navy); box-shadow: 0 3px 10px rgba(0, 46, 74, 0.08);
  transform: translateY(-1px);
}
.os-prod-card.in-cart {
  border-color: var(--brand-navy);
  background: linear-gradient(180deg, rgba(0, 46, 74, 0.03), #fff);
  box-shadow: inset 0 0 0 1px rgba(0, 46, 74, 0.18);
}
.os-prod-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; }
.os-prod-name { font-size: 13px; font-weight: 700; color: var(--brand-obsidian); line-height: 1.25; }
.os-prod-mass {
  display: inline-block; font-family: var(--font-mono); font-size: 10.5px; font-weight: 700;
  padding: 1px 6px; border-radius: 5px; background: var(--surface-active); color: var(--brand-navy);
  white-space: nowrap; flex-shrink: 0;
}
.os-prod-brand { font-size: 11px; color: var(--ink-muted); margin-top: 2px; }
.os-prod-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding-top: 6px; border-top: 1px solid var(--border-hairline);
}
.os-prod-meta { display: flex; flex-direction: column; gap: 1px; }
.os-prod-price { font-family: var(--font-mono); font-size: 12.5px; font-weight: 700; color: var(--ink-primary); }
.os-prod-stock { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; color: var(--ink-muted); font-family: var(--font-mono); }
.os-stock-dot { width: 6px; height: 6px; border-radius: 999px; background: var(--success); }
.os-stock-dot.low { background: var(--brand-gold); }
.os-prod-btns { display: inline-flex; align-items: center; gap: 4px; }
.os-add-pill {
  height: 26px; padding: 0 9px; border-radius: 6px; border: 1px solid var(--border-subtle);
  background: var(--brand-navy); color: #fff; font-family: inherit;
  font-size: 11.5px; font-weight: 650; cursor: pointer; transition: background 0.12s;
}
.os-add-pill:hover { background: var(--brand-navy-hover); }
.os-add-pill.free {
  background: var(--success-bg); color: var(--success); border-color: rgba(37, 101, 71, 0.25);
}
.os-add-pill.free:hover { background: var(--success); color: #fff; }
.os-in-cart-tag {
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 999px; background: var(--brand-navy); color: #fff;
}

/* Order Cart List */
.os-cart-wrap {
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border-subtle);
}
.os-cart-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 10px; flex-wrap: wrap;
}
.os-cart-empty {
  padding: 24px 16px; border-radius: 10px; border: 1.5px dashed var(--border-subtle);
  background: var(--surface-page); text-align: center; color: var(--ink-muted); font-size: 13px;
}
.os-cart-row {
  display: grid; grid-template-columns: minmax(180px, 1.8fr) auto 112px auto 30px;
  gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border-subtle); background: #fff;
  transition: border-color 0.12s, background 0.12s;
}
.os-cart-row.waived {
  border-color: rgba(37, 101, 71, 0.30);
  background: linear-gradient(90deg, rgba(37, 101, 71, 0.04), #fff);
}
.os-cart-item-title { font-size: 13px; font-weight: 700; color: var(--brand-obsidian); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.os-cart-item-sub { font-size: 11px; color: var(--ink-muted); margin-top: 2px; font-family: var(--font-mono); }
.os-waive-pill {
  display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 10px;
  border-radius: 7px; border: 1px solid var(--border-subtle); background: #fff;
  color: var(--ink-muted); font-size: 11.5px; font-weight: 650; cursor: pointer;
  white-space: nowrap; transition: all 0.12s; user-select: none;
}
.os-waive-pill:hover { border-color: var(--success); color: var(--success); }
.os-waive-pill.active,
.os-waive-pill:has(input:checked) {
  background: var(--success-bg); border-color: rgba(37, 101, 71, 0.40); color: var(--success);
}
.os-waive-pill input { accent-color: var(--success); margin: 0; cursor: pointer; }
.os-rm-btn {
  width: 30px; height: 30px; border-radius: 7px; border: 1px solid transparent;
  background: transparent; color: var(--ink-quaternary); font-size: 16px; line-height: 1;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.12s;
}
.os-rm-btn:hover { background: var(--danger-bg); color: var(--danger); border-color: rgba(177, 60, 54, 0.20); }

/* Service Fee Cards (Prep & Delivery) */
.os-fee-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 12px 0; }
.os-fee-card {
  padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border-subtle);
  background: var(--surface-page); transition: border-color 0.15s, background 0.15s;
}
.os-fee-card.waived {
  border-color: rgba(37, 101, 71, 0.35); background: rgba(37, 101, 71, 0.05);
}
.os-fee-top {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px;
}
.os-fee-title { font-size: 12.5px; font-weight: 700; color: var(--brand-obsidian); }
.os-fee-input-wrap { position: relative; }
.os-fee-prefix {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; color: var(--ink-muted);
  pointer-events: none;
}
.os-fee-input { padding-left: 24px !important; }
.os-fee-card.waived .os-fee-input { text-decoration: line-through; opacity: 0.55; }

/* Sticky Receipt Quote Panel */
.os-quote {
  position: sticky; top: 72px; background: var(--surface-card);
  border: 1px solid var(--border-subtle); border-radius: 14px;
  box-shadow: var(--shadow-raised); overflow: hidden;
}
.os-quote-head {
  padding: 16px 20px; background: linear-gradient(135deg, var(--brand-obsidian), var(--brand-navy));
  color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.os-quote-head h2 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -0.015em; color: #fff; }
.os-quote-pill {
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  background: rgba(232, 166, 52, 0.22); color: #F7CA74; letter-spacing: 0.03em;
}
.os-quote-body { padding: 16px 20px 20px; }
.os-quote-lines {
  max-height: 240px; overflow-y: auto; padding-bottom: 12px;
  border-bottom: 1px dashed var(--border-subtle); font-size: 12.5px;
}
.os-quote-line {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 5px 0;
}
.os-quote-summary {
  padding: 14px 0; border-bottom: 1px solid var(--border-hairline);
  display: flex; flex-direction: column; gap: 6px; font-size: 13px;
}
.os-quote-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.os-quote-total-box {
  padding: 14px 0 6px; display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
}
.os-quote-total-lbl { font-size: 13.5px; font-weight: 700; color: var(--brand-obsidian); }
.os-quote-total-val {
  font-family: var(--font-mono); font-size: 24px; font-weight: 800; letter-spacing: -0.03em;
  color: var(--brand-navy);
}
.os-quote-cop { text-align: right; font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-muted); margin-bottom: 6px; }
.os-submit-cta {
  width: 100%; height: 44px; margin-top: 14px; border-radius: 10px; font-size: 14px; font-weight: 700;
  letter-spacing: -0.01em; background: var(--brand-navy); color: #fff;
  box-shadow: 0 2px 8px rgba(0, 46, 74, 0.22);
}
.os-submit-cta:hover:not(:disabled) {
  background: var(--brand-navy-hover); box-shadow: 0 4px 14px rgba(0, 46, 74, 0.30);
}
.os-submit-cta:disabled { opacity: 0.48; cursor: not-allowed; box-shadow: none; }

/* Order Lifecycle Progress Stepper (Order Detail) */
.os-lifecycle {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0;
  background: var(--surface-card); border: 1px solid var(--border-subtle);
  border-radius: 12px; padding: 14px 18px; margin-bottom: 16px; box-shadow: var(--shadow-card);
}
.os-stage-step { display: flex; align-items: center; gap: 10px; position: relative; padding-right: 12px; }
.os-stage-step:not(:last-child)::after {
  content: ""; flex: 1; height: 2px; background: var(--border-subtle); margin-left: 4px;
}
.os-stage-step.done:not(:last-child)::after { background: var(--success); }
.os-stage-dot {
  width: 24px; height: 24px; border-radius: 999px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  border: 2px solid var(--border-subtle); background: #fff; color: var(--ink-quaternary);
}
.os-stage-step.done .os-stage-dot { background: var(--success); border-color: var(--success); color: #fff; }
.os-stage-step.current .os-stage-dot {
  background: var(--brand-navy); border-color: var(--brand-navy); color: #fff;
  box-shadow: 0 0 0 4px rgba(0, 46, 74, 0.14);
}
.os-stage-lbl { font-size: 12px; font-weight: 700; color: var(--ink-muted); white-space: nowrap; }
.os-stage-step.done .os-stage-lbl,
.os-stage-step.current .os-stage-lbl { color: var(--brand-obsidian); }
.os-stage-sub { font-size: 10.5px; color: var(--ink-quaternary); font-family: var(--font-mono); }

/* ── Person Workspace & Payment Studio (Clinical Sovereign) ─────────── */
.person-workspace {
  display: grid; grid-template-columns: minmax(368px, 416px) minmax(0, 1fr);
  gap: 16px; align-items: start;
}
.person-rail, .person-ledger { min-width: 0; }
.ledger-table { font-size: 12.5px; }
.ledger-table th, .ledger-table td { padding: 8px 6px; }
.ledger-table th:first-child, .ledger-table td:first-child { padding-left: 4px; }
.ledger-table th:last-child, .ledger-table td:last-child { padding-right: 4px; }
.ledger-table th[data-sortable="1"]::after { margin-left: 2px; font-size: 9px; }
.inv-num-cell { display: block; font-size: 11.5px; font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; }
.inv-sub-meta { font-size: 10.5px; line-height: 1.3; margin-top: 2px; white-space: nowrap; }
.inv-status-cell { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.inv-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 10px; flex-wrap: wrap;
}
.inv-head-actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.inv-head-sep {
  width: 1px; height: 20px; background: var(--border-subtle); flex-shrink: 0;
}
.inv-send-all-btn {
  border-color: rgba(0, 46, 74, 0.30); color: var(--brand-navy); font-weight: 650;
}
.inv-send-all-btn:hover:not(:disabled) {
  background: var(--brand-navy); color: #fff; border-color: var(--brand-navy);
}
.inv-send-all-btn:disabled,
.inv-send-btn:disabled {
  opacity: 0.55; cursor: not-allowed;
}
.inv-send-all-btn.is-sent,
.inv-send-all-btn.is-sent:disabled {
  background: var(--success-bg); color: var(--success);
  border-color: rgba(37, 101, 71, 0.30); opacity: 1; cursor: default;
}
.inv-row-actions {
  display: inline-flex; align-items: center; justify-content: flex-end; gap: 6px;
}
.inv-send-btn {
  border-color: rgba(0, 46, 74, 0.24); color: var(--brand-navy); font-weight: 600;
}
.inv-send-btn:hover:not(:disabled) {
  background: var(--brand-navy); color: #fff; border-color: var(--brand-navy);
}
.inv-send-btn.is-sent,
.inv-send-btn.is-sent:disabled {
  background: var(--success-bg); color: var(--success);
  border-color: rgba(37, 101, 71, 0.30); opacity: 1; cursor: default;
}
.inv-send-btn.is-queued,
.inv-send-btn.is-queued:disabled {
  background: var(--info-bg); color: var(--info);
  border-color: rgba(34, 108, 155, 0.28); opacity: 1; cursor: default;
}
.inv-sent-meta.is-queued { color: var(--info); font-weight: 600; }
.inv-send-confirm {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px 14px; margin-bottom: 10px; border-radius: var(--radius-md);
  background: var(--info-bg); border: 1px solid rgba(34, 108, 155, 0.24);
}
.inv-send-confirm-top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.inv-send-confirm-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding-top: 8px; border-top: 1px solid rgba(34, 108, 155, 0.16);
}
.inv-send-confirm-copy { min-width: 0; flex: 1; }
.inv-send-confirm-title { font-size: 12.5px; font-weight: 700; color: var(--brand-obsidian); }
.inv-send-confirm-meta { font-size: 11.5px; color: var(--ink-muted); margin-top: 3px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.inv-send-confirm-actions { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; }
.inv-send-notice { padding: 9px 12px; font-size: 12.5px; margin-bottom: 10px; }
.inv-send-group {
  display: inline-flex; align-items: center; gap: 5px;
}
.inv-send-counter {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 6px; border-radius: 999px;
  font-family: var(--font-mono); font-size: 10.5px; line-height: 1;
  font-variant-numeric: tabular-nums; white-space: nowrap;
  border: 1px solid var(--border-subtle); cursor: help;
}
.inv-cnt-total { font-weight: 700; }
.inv-cnt-split { font-size: 9.5px; font-weight: 500; opacity: 0.80; }
.inv-send-counter.is-zero {
  background: var(--surface-subtle, #f4f6f8); color: var(--ink-muted);
}
.inv-send-counter.is-sent {
  background: rgba(0, 46, 74, 0.06); color: var(--brand-navy);
  border-color: rgba(0, 46, 74, 0.20);
}
.inv-send-counter.is-queued {
  background: var(--info-bg); color: var(--info);
  border-color: rgba(34, 108, 155, 0.30);
}
.inv-send-counter.is-warn {
  background: var(--warning-bg); color: var(--warning);
  border-color: rgba(180, 118, 22, 0.36);
}
.inv-send-counter.is-danger {
  background: var(--danger-bg); color: var(--danger);
  border-color: rgba(177, 60, 54, 0.36);
}
.inv-channel-seg {
  display: inline-flex; align-items: center; gap: 2px; padding: 2px;
  background: #fff; border: 1px solid rgba(0, 46, 74, 0.18); border-radius: 7px;
  flex-shrink: 0;
}
.inv-ch-btn {
  appearance: none; border: 0; background: transparent; color: var(--brand-obsidian);
  font-family: inherit; font-size: 11.5px; font-weight: 600;
  padding: 5px 9px; border-radius: 5px; cursor: pointer; white-space: nowrap;
  transition: background 120ms ease, color 120ms ease;
}
.inv-ch-btn:hover:not(:disabled):not(.is-active) {
  background: rgba(0, 46, 74, 0.06); color: var(--brand-navy);
}
.inv-ch-btn.is-active {
  background: var(--brand-navy); color: #fff;
}
.inv-ch-btn:disabled {
  opacity: 0.42; cursor: not-allowed;
}
.inv-skip-recent-label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600; color: var(--brand-obsidian); cursor: pointer;
}
.inv-notif-pref-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 6px 12px; margin: 8px 0 10px;
}
.inv-send-popover {
  position: fixed; z-index: 1200; width: 316px; max-width: calc(100vw - 16px);
  background: var(--surface-card, #fff); border: 1px solid rgba(0, 46, 74, 0.18);
  border-radius: 10px; padding: 10px;
  box-shadow: 0 14px 36px rgba(10, 22, 34, 0.16), 0 2px 6px rgba(10, 22, 34, 0.08);
  font-size: 12px; color: var(--brand-obsidian);
}
.inv-pop-head {
  padding-bottom: 8px; margin-bottom: 8px;
  border-bottom: 1px solid var(--border-hairline);
}
.inv-pop-title {
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 700; color: var(--brand-navy);
}
.inv-pop-stats {
  font-size: 11px; color: var(--ink-muted); margin-top: 3px; line-height: 1.4;
}
.inv-pop-alert {
  font-size: 11px; line-height: 1.4; padding: 6px 8px; border-radius: 6px; margin-bottom: 8px;
  font-weight: 600;
}
.inv-pop-alert.is-warn {
  background: var(--warning-bg); color: var(--warning);
  border: 1px solid rgba(180, 118, 22, 0.28);
}
.inv-pop-alert.is-danger {
  background: var(--danger-bg); color: var(--danger);
  border: 1px solid rgba(177, 60, 54, 0.28);
}
.inv-pop-opts {
  display: flex; flex-direction: column; gap: 5px;
}
.inv-pop-sep {
  height: 1px; background: var(--border-hairline); margin: 3px 0;
}
.inv-pop-opt {
  appearance: none; display: block; width: 100%; text-align: left; font-family: inherit;
  text-decoration: none; color: inherit; box-sizing: border-box;
  background: var(--surface-subtle, #f7f9fb); border: 1px solid var(--border-subtle);
  border-radius: 7px; padding: 8px 10px; cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.inv-pop-opt:hover:not(:disabled) {
  background: rgba(0, 46, 74, 0.06); border-color: rgba(0, 46, 74, 0.34); text-decoration: none;
}
.inv-pop-opt:disabled {
  opacity: 0.56; cursor: not-allowed; background: var(--surface-subtle, #f7f9fb);
}
.inv-pop-opt-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.inv-pop-opt-name {
  font-size: 12px; font-weight: 700; color: var(--brand-obsidian);
}
.inv-pop-opt-mode {
  font-size: 10px; font-weight: 700; letter-spacing: 0.02em;
  padding: 2px 6px; border-radius: 999px;
  background: rgba(0, 46, 74, 0.08); color: var(--brand-navy);
}
.inv-pop-opt-dest {
  font-size: 11px; color: var(--ink-muted); margin-top: 3px;
  overflow-wrap: anywhere; line-height: 1.35;
}
.order-more-btn {
  min-width: 30px; padding-left: 7px; padding-right: 7px; font-weight: 800; letter-spacing: 0.04em;
}
.order-action-popover {
  position: fixed; z-index: 1200; width: 276px; max-width: calc(100vw - 16px);
  background: var(--surface-card, #fff); border: 1px solid rgba(0, 46, 74, 0.18);
  border-radius: 10px; padding: 10px;
  box-shadow: 0 14px 36px rgba(10, 22, 34, 0.16), 0 2px 6px rgba(10, 22, 34, 0.08);
  font-size: 12px; color: var(--brand-obsidian);
}
.order-pop-sep {
  height: 1px; background: var(--border-hairline); margin: 4px 0;
}
.order-pop-opt {
  appearance: none; display: block; width: 100%; text-align: left; font-family: inherit;
  text-decoration: none; color: inherit;
  background: var(--surface-subtle, #f7f9fb); border: 1px solid var(--border-subtle);
  border-radius: 7px; padding: 7px 10px; cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.order-pop-opt:hover:not(:disabled) {
  background: rgba(0, 46, 74, 0.06); border-color: rgba(0, 46, 74, 0.34); text-decoration: none;
}
.order-pop-opt.is-danger .inv-pop-opt-name { color: var(--danger); }
.order-pop-opt.is-danger:hover:not(:disabled) {
  background: var(--danger-bg); border-color: rgba(177, 60, 54, 0.36);
}
.order-pop-opt:disabled {
  opacity: 0.56; cursor: not-allowed; background: var(--surface-subtle, #f7f9fb);
}
.inv-preview-tag {
  display: inline-flex; align-items: center; padding: 1px 5px; border-radius: 4px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap;
}
.inv-preview-tag.paid { background: var(--success-bg); color: var(--success); border: 1px solid rgba(37, 101, 71, 0.28); }
.inv-preview-tag.partial { background: var(--info-bg); color: var(--info); border: 1px solid rgba(34, 108, 155, 0.28); }
tbody tr.row-pay-full,
tbody tr[data-href].row-pay-full {
  background: rgba(37, 101, 71, 0.055);
  box-shadow: inset 3px 0 0 var(--success);
}
tbody tr.row-pay-partial,
tbody tr[data-href].row-pay-partial {
  background: rgba(34, 108, 155, 0.055);
  box-shadow: inset 3px 0 0 var(--info);
}

.ps-studio { box-shadow: var(--shadow-card); }
.ps-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--border-hairline);
}
.ps-head-left { min-width: 0; }
.ps-head h2 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -0.02em; color: var(--brand-obsidian); }
.ps-trm-meta {
  display: flex; align-items: center; gap: 6px; margin-top: 4px;
  font-size: 11.5px; color: var(--ink-muted); line-height: 1.35;
}
.ps-trm-meta > span:last-child { min-width: 0; }
.ps-dot { width: 7px; height: 7px; border-radius: 999px; flex-shrink: 0; display: inline-block; }
.ps-dot.ok { background: var(--success); }
.ps-dot.warn { background: var(--brand-gold); }
.ps-due-pill { font-size: 11.5px; padding: 4px 9px; flex-shrink: 0; }
.ps-compact-notice { padding: 9px 11px; font-size: 12px; margin-bottom: 12px; }
.ps-scope-chip {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 7px 10px; border-radius: var(--radius-md);
  background: var(--surface-page); border: 1px solid var(--border-hairline);
  font-size: 12px; margin-bottom: 12px;
}
.ps-control-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: end;
  margin-bottom: 10px;
}
.ps-currency-seg { height: 36px; padding: 2px; gap: 2px; flex-wrap: nowrap; }
.ps-currency-seg .os-seg-btn { height: 30px; padding: 0 11px; font-size: 12px; white-space: nowrap; }
.ps-currency-seg .os-seg-btn:disabled { opacity: 0.42; cursor: not-allowed; }
.ps-interlock-hint { font-size: 11.5px; margin: -4px 0 10px; }

.ps-amount-field { margin-bottom: 12px; }
.ps-amount-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 5px; }
.ps-amount-label-row label { margin-bottom: 0; }
.ps-amount-rule { font-size: 11px; }
.ps-money-box {
  display: flex; align-items: center; border: 1.5px solid var(--border-control);
  border-radius: 9px; background: #fff; overflow: hidden;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.ps-money-box:focus-within {
  border-color: var(--brand-navy);
  box-shadow: 0 0 0 3px rgba(100, 144, 169, 0.25);
}
.ps-money-box.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(177, 60, 54, 0.15);
}
.ps-money-prefix {
  padding: 0 12px; height: 46px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-page); border-right: 1px solid var(--border-subtle);
  font-size: 13px; font-weight: 700; color: var(--brand-navy); flex-shrink: 0; min-width: 44px;
}
.ps-money-input {
  flex: 1; min-width: 0; height: 46px; border: 0; padding: 0 13px;
  font-size: 20px; font-weight: 700; letter-spacing: -0.02em; color: var(--brand-obsidian);
  background: transparent; outline: none;
}
.ps-amount-error {
  margin-top: 5px; font-size: 12px; font-weight: 600; color: var(--danger);
}
.ps-amount-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  flex-wrap: wrap; margin-top: 6px;
}
.ps-equiv { font-size: 12px; font-weight: 600; color: var(--brand-navy); }
.ps-quick-chips { display: inline-flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.ps-chip {
  height: 24px; padding: 0 9px; border-radius: 999px;
  border: 1px solid var(--border-subtle); background: var(--surface-page);
  color: var(--ink-muted); font-family: inherit; font-size: 11px; font-weight: 600;
  cursor: pointer; transition: border-color 0.1s, color 0.1s, background 0.1s;
}
.ps-chip:hover { border-color: var(--brand-navy); color: var(--brand-navy); background: #fff; }

.ps-defaults-note { font-size: 11px; margin: -4px 0 8px; }
.ps-discount-nudge {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 9px 11px; border-radius: 9px; margin-bottom: 12px;
  border: 1px solid rgba(34, 108, 155, 0.28);
  background: linear-gradient(180deg, rgba(34, 108, 155, 0.08), rgba(34, 108, 155, 0.035));
}
.ps-discount-nudge-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.ps-discount-nudge-title { font-size: 11.5px; font-weight: 700; color: var(--brand-navy); }
.ps-discount-nudge-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex-shrink: 0; }
.ps-apply-disc-btn { border-color: rgba(34, 108, 155, 0.4); color: var(--brand-navy); font-weight: 700; }
.ps-apply-disc-btn:hover { background: var(--brand-navy); color: #fff; border-color: var(--brand-navy); }
.ps-discount-card {
  padding: 10px 12px; border-radius: 9px; margin-bottom: 12px;
  border: 1px solid rgba(34, 108, 155, 0.22);
  background: rgba(34, 108, 155, 0.045);
}
.ps-discount-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px;
}
.ps-discount-title { font-size: 12px; font-weight: 700; color: var(--brand-obsidian); }
.ps-discount-toggle {
  display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600;
  color: var(--ink-primary); cursor: pointer;
}
.ps-discount-toggle.dimmed { opacity: 0.5; }
.ps-discount-savings {
  margin-top: 6px; font-size: 11.5px; font-weight: 600; color: var(--info);
}
.ps-amount-tag { font-size: 10px; padding: 1px 6px; }
.ps-override-details { margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(34, 108, 155, 0.14); }
.ps-override-details > summary { cursor: pointer; font-size: 11.5px; font-weight: 600; }

.ps-policy-section {
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-hairline);
}
.ps-policy-summary-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
}
.ps-policy-pills { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.ps-policy-editor { margin-top: 8px; }
.ps-policy-editor-summary {
  cursor: pointer; font-size: 12px; font-weight: 650; color: var(--brand-navy);
}
.ps-policy-editor-body { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.ps-policy-box {
  padding: 9px 11px; border: 1px solid var(--border-hairline); border-radius: 8px;
  background: var(--surface-subtle);
}
.ps-policy-box-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 8px; flex-wrap: wrap; font-size: 12.5px;
}
.ps-policy-form-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) 88px; gap: 8px; align-items: end; margin-bottom: 8px;
}
.ps-policy-form-grid .field { margin-bottom: 0; }
.ps-policy-form-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
}
.ps-settled-box {
  padding: 10px 12px; border-radius: 9px; margin: 4px 0 2px;
  border: 1px solid rgba(37, 101, 71, 0.22); background: rgba(37, 101, 71, 0.05);
  display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; color: var(--ink-primary);
}
.ps-settled-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.person-meta-dl {
  display: grid; grid-template-columns: minmax(104px, 124px) minmax(0, 1fr);
  gap: 8px 10px; margin: 0; font-size: 13px;
}
.person-meta-dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.deal-rule-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.deal-rule-empty {
  padding: 11px 12px; border-radius: var(--radius-md); font-size: 12.5px;
  border: 1px dashed var(--border-subtle); background: var(--surface-page); color: var(--ink-muted);
}
.deal-rule-card {
  padding: 10px 12px; border-radius: 9px;
  border: 1px solid var(--border-subtle); background: var(--surface-page);
  display: flex; flex-direction: column; gap: 6px;
}
.deal-rule-top {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
}
.deal-rule-scope {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; flex: 1;
  font-size: 13px; font-weight: 650; color: var(--brand-obsidian); overflow-wrap: anywhere;
}
.deal-rule-pct {
  font-family: var(--font-mono); font-size: 12.5px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; flex-shrink: 0;
  background: rgba(0, 46, 74, 0.08); color: var(--brand-navy);
}
.deal-rule-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
}
.deal-rule-note {
  font-size: 12px; color: var(--ink-muted); min-width: 0; flex: 1; overflow-wrap: anywhere;
}
.deal-add-details {
  border: 1px solid var(--border-hairline); border-radius: 9px;
  background: var(--surface-subtle); padding: 9px 11px; margin-bottom: 4px;
}
.deal-add-details > summary {
  cursor: pointer; font-size: 12.5px; font-weight: 650; color: var(--brand-navy);
}
.deal-add-form { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.deal-add-form .field { margin-bottom: 0; }
.deal-pct-note-row { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px; align-items: end; }
.pay-inv-list { font-size: 11.5px; line-height: 1.35; overflow-wrap: anywhere; }

.ps-preview-card {
  padding: 12px 13px; border-radius: 10px; margin-bottom: 10px;
  border: 1px solid var(--border-subtle);
  background: linear-gradient(180deg, rgba(0, 46, 74, 0.028), rgba(0, 46, 74, 0.01));
}
.ps-preview-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px;
}
.ps-preview-status { font-size: 11px; }
.ps-preview-metrics {
  display: flex; flex-direction: column; gap: 4px; font-size: 12.5px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border-hairline); margin-bottom: 8px;
}
.ps-preview-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.ps-preview-arrow { color: var(--ink-quaternary); margin: 0 4px; }
.ps-wf-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.ps-wf-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 12px; padding: 4px 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border-hairline);
}
.ps-wf-left { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ps-wf-idx {
  width: 17px; height: 17px; border-radius: 999px; background: var(--surface-active);
  color: var(--brand-navy); font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ps-wf-num { font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ps-wf-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; font-family: var(--font-mono); font-size: 11.5px; }
.ps-preview-note {
  margin-top: 8px; padding: 7px 9px; border-radius: 7px; font-size: 11.5px; line-height: 1.4;
}
.ps-preview-note.warn { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(139, 87, 14, 0.22); }
.ps-preview-note.danger { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(177, 60, 54, 0.24); font-weight: 600; }
.ps-preview-note.muted { background: var(--surface-subtle); color: var(--ink-muted); }

.ps-submit-btn {
  width: 100%; height: 42px; font-size: 13.5px; font-weight: 700; border-radius: 9px;
}
.ps-submit-btn:disabled { opacity: 0.48; cursor: not-allowed; }

.ps-receipt {
  border: 1.5px solid rgba(37, 101, 71, 0.34);
  background: linear-gradient(180deg, rgba(37, 101, 71, 0.075), rgba(37, 101, 71, 0.025));
  border-radius: 10px; padding: 12px 14px; margin-bottom: 14px;
}
.ps-receipt-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px;
}
.ps-receipt-title { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--success); }
.ps-receipt-dismiss {
  border: 0; background: transparent; color: var(--ink-muted); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 2px 5px; border-radius: 4px;
}
.ps-receipt-dismiss:hover { background: rgba(0, 0, 0, 0.06); color: var(--ink-primary); }
.ps-receipt-grid {
  display: flex; flex-direction: column; gap: 4px; font-size: 12px; margin-bottom: 8px;
}
.ps-receipt-actions {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  padding-top: 8px; border-top: 1px solid rgba(37, 101, 71, 0.16); margin-top: 8px;
}

@media (max-width: 1380px) {
  .person-workspace { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .ps-control-row { grid-template-columns: 1fr; }
}

@media (max-width: 1120px) {
  .os-grid { grid-template-columns: 1fr; }
  .os-quote { position: static; }
}
@media (max-width: 720px) {
  .os-client-grid, .os-fee-grid, .os-health-metrics { grid-template-columns: 1fr; }
  .os-cart-row { grid-template-columns: 1fr auto; }
  .os-lifecycle { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .os-stage-step::after { display: none; }
}
@media (max-width: 960px) {
  .print-drawer.with-preview { width: 100vw; }
  .print-drawer-workspace { flex-direction: column; }
  .print-preview-pane { width: 100%; height: 42vh; border-left: 0; border-top: 1px solid var(--border-subtle); }
}

@media (max-width: 1100px) {
  .coa-workbench { grid-template-columns: 1fr; }
  .coa-doc-pane { position: static; }
  .stepper { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}
@media (max-width: 900px) {
  .grid-2, .grid-3, .pub-hero { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .flag-btn.flag-pending {
    background: #F59E0B !important;
    color: #0E2130 !important;
    border: 2px dashed #7C2D12 !important;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.45) !important;
  }
}

/* ── Commission Payout Studio (Phase 1) ── */
.cs-page-receipt { margin-bottom: 16px; }
.cs-payouts-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.cs-group-row td,
.cs-divider-row td {
  background: var(--surface-page);
  padding: 7px 14px !important;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-hairline);
}
.cs-divider-row td { border-top: 2px solid var(--border-subtle); }
.cs-row-settled td { opacity: 0.86; }
.cs-row-settled:hover td { opacity: 1; }
.cs-earner-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cs-earner-sub { margin-top: 3px; font-size: 11.5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cs-progress-wrap { min-width: 110px; max-width: 150px; }
.cs-progress-track {
  height: 5px; border-radius: 999px; background: var(--surface-subtle);
  overflow: hidden; border: 1px solid var(--border-hairline);
}
.cs-progress-fill { height: 100%; background: var(--brand-navy); border-radius: 999px; }
.cs-progress-fill.done { background: var(--ink-quaternary); }
.cs-progress-meta { font-size: 10.5px; margin-top: 3px; }

.cs-drawer-backdrop[hidden] { display: none !important; }
.cs-drawer { width: min(560px, 100vw); }
.cs-payto-card {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 9px; margin-bottom: 12px;
  background: var(--surface-page); border: 1px solid var(--border-subtle);
}
.cs-payto-meta { min-width: 0; flex: 1; }
.cs-payto-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.cs-payto-addr { font-size: 12px; color: var(--ink-primary); word-break: break-all; }
.cs-reserve-banner, .cs-unknown-cop-note { font-size: 12px; margin-bottom: 12px; padding: 9px 11px; }
.cs-mode-seg { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); height: 38px; padding: 2px; gap: 2px; }
.cs-mode-seg .os-seg-btn { height: 32px; font-size: 12px; padding: 0 8px; text-align: center; justify-content: center; }
.cs-mode-hint { font-size: 11.5px; margin-top: 5px; line-height: 1.35; }
.cs-meta-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.cs-rate-card {
  padding: 10px 12px; border-radius: 9px; margin-bottom: 12px;
  background: var(--surface-page); border: 1px solid var(--border-subtle);
}
.cs-rate-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  flex-wrap: wrap; margin-bottom: 8px;
}
.cs-rate-title { font-size: 12px; font-weight: 700; color: var(--brand-obsidian); }
.cs-rate-tools { display: flex; align-items: center; gap: 6px; }
.cs-rate-guard {
  margin-top: 8px; padding: 8px 10px; border-radius: 7px; font-size: 12px; line-height: 1.4;
}
.cs-rate-guard.warn {
  background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(139, 87, 14, 0.28);
}
.cs-rate-guard.danger {
  background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(177, 60, 54, 0.28); font-weight: 600;
}
.cs-rate-confirm-label {
  display: flex; align-items: center; gap: 7px; margin-top: 7px; font-weight: 650;
  color: var(--ink-primary); cursor: pointer;
}
@media (max-width: 520px) {
  .cs-meta-row { grid-template-columns: 1fr; }
  .cs-mode-seg { grid-template-columns: 1fr; height: auto; }
}

/* ── Commission Portfolio Workbench (Phase 3) ── */
.cp-econ-panel { margin-bottom: 14px; }
.cp-econ-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.cp-period-pills, .cp-qselect-pills { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.cp-pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px;
  border-radius: 999px; border: 1px solid var(--border-subtle); background: var(--surface-card);
  color: var(--ink-primary); font-size: 12px; font-weight: 500; cursor: pointer; text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
}
.cp-pill:hover { background: var(--surface-subtle); text-decoration: none; border-color: var(--border-control); }
.cp-pill.active { background: var(--brand-navy); border-color: var(--brand-navy); color: var(--ink-inverse); font-weight: 600; }

.cp-econ-tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.cp-tile {
  border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
  padding: 11px 13px; background: var(--surface-card); display: flex; flex-direction: column; gap: 3px;
}
.cp-tile-warn { border-color: rgba(177, 60, 54, 0.34); background: linear-gradient(180deg, rgba(177, 60, 54, 0.05), var(--surface-card)); }
.cp-tile-ok { border-color: rgba(37, 101, 71, 0.32); background: linear-gradient(180deg, rgba(37, 101, 71, 0.055), var(--surface-card)); }
.cp-tile-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-muted); }
.cp-tile-val { font-size: 19px; font-weight: 700; color: var(--ink-primary); line-height: 1.2; }
.cp-tile-sub { font-size: 11.5px; color: var(--ink-muted); display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.cp-comm-mix { font-size: 10.5px; margin-top: 2px; }
.cp-waiver-split { display: flex; flex-direction: column; gap: 1px; margin-top: 3px; padding-top: 4px; border-top: 1px solid var(--border-hairline); font-size: 11px; }
.cp-ws-absorbed { color: var(--danger); }
.cp-ws-deducted { color: var(--success); }
.cp-dot { width: 7px; height: 7px; border-radius: 999px; display: inline-block; flex-shrink: 0; }
.cp-dot.ok { background: var(--success); }
.cp-dot.warn { background: var(--warning); }

.cp-split-wrap { margin-top: 12px; }
.cp-split-bar {
  display: flex; height: 11px; border-radius: 999px; overflow: hidden;
  background: var(--surface-subtle); border: 1px solid var(--border-hairline);
}
.cp-seg { height: 100%; min-width: 2px; }
.cp-seg-cogs { background: #64748B; }
.cp-seg-waived { background: #D97706; }
.cp-seg-comm { background: #226C9B; }
.cp-seg-net { background: #256547; }
.cp-split-legend { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 6px; font-size: 11.5px; color: var(--ink-muted); }
.cp-split-legend span { display: inline-flex; align-items: center; gap: 5px; }
.cp-sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; }

.cp-callouts { display: flex; flex-direction: column; gap: 7px; margin-top: 10px; }
.cp-callout { padding: 8px 11px; border-radius: var(--radius-md); font-size: 12px; line-height: 1.45; }
.cp-callout-info { background: var(--info-bg); color: var(--brand-obsidian); border: 1px solid rgba(34, 108, 155, 0.22); }
.cp-callout-warn { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(139, 87, 14, 0.28); }
.cp-sku-link { font-weight: 600; color: var(--brand-navy); text-decoration: underline; text-underline-offset: 2px; }

.cp-cards-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 10px; }
.cp-manager-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 12px; }
.cp-mgr-card { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; }
.cp-mgr-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.cp-mgr-name { font-size: 15px; font-weight: 700; color: var(--brand-navy); }
.cp-mgr-split-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cp-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-subtle); font-size: 11.5px; color: var(--ink-primary);
}
.cp-chip-gross { background: rgba(34, 108, 155, 0.10); color: var(--info); }
.cp-chip-net { background: rgba(37, 101, 71, 0.11); color: var(--success); }
.cp-mgr-kv { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 12px; margin: 0; font-size: 12px; }
.cp-mgr-kv dt { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-quaternary); }
.cp-mgr-kv dd { margin: 1px 0 0; }
.cp-mgr-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 8px; border-top: 1px solid var(--border-hairline); margin-top: auto; }

.cp-wb-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.rb-row-alert { background: rgba(245, 158, 11, 0.08); }
.cp-setup-panel { margin-bottom: 14px; }
.cp-setup-summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; cursor: pointer; list-style: none; }
.cp-setup-summary::-webkit-details-marker { display: none; }
.cp-setup-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-hairline); }
.cp-setup-card { border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 12px 14px; background: var(--surface-subtle); }
.cp-setup-card h3 { margin: 0 0 4px; font-size: 13.5px; }
.cp-form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.cp-matrix-panel { padding: 0; overflow: visible; }
.cp-matrix-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--border-subtle);
}
.cp-search-wrap { flex: 1 1 220px; max-width: 320px; }
.cp-unassigned-drawer {
  padding: 14px 16px; background: rgba(0, 46, 74, 0.03); border-bottom: 1px solid var(--border-subtle);
}
.cp-unassigned-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.cp-unassigned-controls { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.cp-inline-field { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--ink-muted); }
.cp-unassigned-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px;
  max-height: 220px; overflow-y: auto; margin-top: 10px; padding: 8px;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--surface-card);
}
.cp-unassigned-item {
  display: flex; align-items: center; gap: 7px; padding: 5px 8px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 12.5px;
}
.cp-unassigned-item:hover { background: var(--surface-subtle); }
.cp-ui-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cp-bulk-bar {
  position: sticky; top: 56px; z-index: 25;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 9px 16px; background: #EAF2F8; border-bottom: 1.5px solid rgba(0, 46, 74, 0.22);
}
.cp-bulk-left, .cp-bulk-right, .cp-bulk-control { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.cp-rate-wrap { display: inline-flex; align-items: center; gap: 3px; }
.cp-rate-input { width: 76px; padding: 4px 7px; font-size: 12.5px; text-align: right; }
.cp-pct-suffix { font-size: 12px; color: var(--ink-muted); font-weight: 600; }

.cp-seg-toggle {
  display: inline-flex; border: 1px solid var(--border-subtle); border-radius: var(--radius-md);
  overflow: hidden; background: var(--surface-card);
}
.cp-seg-btn {
  border: 0; background: transparent; padding: 4px 9px; font-size: 11.5px; font-weight: 600;
  color: var(--ink-muted); cursor: pointer; transition: background 0.1s, color 0.1s;
}
.cp-seg-btn:hover:not(:disabled) { background: var(--surface-subtle); color: var(--ink-primary); }
.cp-seg-btn.active { background: var(--brand-navy); color: var(--ink-inverse); }
.cp-seg-btn[data-cp-basis-btn="NET"].active,
.cp-seg-btn[data-cp-bulk-basis="NET"].active { background: var(--success); color: var(--ink-inverse); }
.cp-seg-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.cp-row-dirty { background: rgba(232, 166, 52, 0.10) !important; }
.cp-row-dirty td:first-child { box-shadow: inset 3px 0 0 var(--brand-gold); }
.cp-cap-badge { font-size: 11.5px; font-weight: 600; }
.cp-cap-over { color: var(--danger) !important; font-weight: 700; }
.cp-diff-cell { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11.5px; }
.cp-diff-pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px;
  border-radius: var(--radius-sm); background: var(--warning-bg); color: var(--warning);
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
}
.cp-delta-pos { color: var(--success); font-family: var(--font-mono); font-weight: 700; font-size: 11.5px; }
.cp-delta-neg { color: var(--danger); font-family: var(--font-mono); font-weight: 700; font-size: 11.5px; }
.cp-undo-btn {
  border: 1px solid var(--border-subtle); background: var(--surface-card); color: var(--ink-muted);
  border-radius: var(--radius-sm); padding: 1px 6px; font-size: 11px; cursor: pointer;
}
.cp-undo-btn:hover { color: var(--ink-primary); border-color: var(--border-control); }

.cp-commit-footer {
  position: sticky; bottom: 12px; z-index: 30; margin-top: 14px;
  background: var(--surface-card); border: 1.5px solid var(--brand-navy);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-raised); padding: 12px 16px;
}
.cp-commit-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cp-commit-summary { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cp-commit-metrics { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 12.5px; }
.cp-commit-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cp-reason-input { width: 240px; font-size: 12.5px; padding: 5px 9px; }
.cp-commit-messages { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.cp-msg-err { color: var(--danger); font-weight: 600; }
.cp-msg-warn { color: var(--warning); }

@media (max-width: 1200px) {
  .cp-econ-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cp-setup-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .cp-econ-tiles { grid-template-columns: 1fr; }
  .cp-reason-input { width: 100%; }
}

/* ── Commission Directory & Inspector (Phase 4) ── */
.cd-filter-panel { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.cd-filter-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.cd-search-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cd-search-input { min-width: 260px; flex: 1; max-width: 440px; }
.cd-live-count { font-size: 12px; margin-left: auto; }
.cd-client-cell, .cd-slot-cell, .cd-ledger-source { display: flex; flex-direction: column; gap: 3px; }
.cd-subline { font-size: 11.5px; }
.cd-slot-meta { font-size: 11.5px; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.cd-parent-note { margin-top: 2px; }
.cd-payees-panel { margin-top: 16px; }
.cd-payee-list { display: flex; flex-direction: column; gap: 8px; }
.cd-payee-card {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 11px 14px; border-radius: var(--radius-md); border: 1px solid var(--border-subtle);
  background: var(--surface-card);
}
.cd-payee-card.archived { opacity: 0.72; background: var(--surface-subtle); }
.cd-payee-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cd-payee-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13.5px; }
.cd-payee-meta { font-size: 12px; }
.cd-payee-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.cd-payout-filters { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.cd-payout-filters .field { margin: 0; min-width: 180px; }
.cd-check-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 6px 2px; cursor: pointer; user-select: none; }
.cd-row-clickable { cursor: pointer; }
.cd-row-removed td { opacity: 0.72; }
.cd-pager {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-top: 1px solid var(--border-subtle);
}
.cd-settlement-link { text-decoration: none; }
.cd-reason-sub { font-size: 12px; color: var(--ink-secondary); }
.cd-net-details { margin-top: 4px; font-size: 11.5px; }
.cd-net-details summary { cursor: pointer; color: var(--brand-navy); font-weight: 600; }
.cd-net-box {
  margin-top: 4px; padding: 6px 8px; border-radius: 6px;
  background: var(--surface-subtle); border: 1px solid var(--border-hairline);
  display: flex; flex-direction: column; gap: 3px;
}
.cd-net-target { font-size: 11px; }
.cd-drawer { width: min(640px, 100vw); }
.cd-section-card {
  border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
  padding: 14px 16px; margin-bottom: 14px; background: var(--surface-card);
}
.cd-section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border-hairline);
}
.cd-section-head h3 { margin: 0; font-size: 14px; font-weight: 700; color: var(--ink-primary); }
.cd-meter {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-md); margin-bottom: 14px;
  background: var(--surface-subtle); border: 1px solid var(--border-hairline); font-size: 12.5px;
}
.cd-meter.over { background: var(--danger-bg); border-color: rgba(177, 60, 54, 0.35); color: var(--danger); }
.cd-seg { display: inline-flex; border: 1px solid var(--border-subtle); border-radius: 8px; overflow: hidden; }
.cd-seg-btn {
  border: 0; background: var(--surface-subtle); color: var(--ink-secondary);
  padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.cd-seg-btn.active { background: var(--brand-navy); color: #fff; }
.cd-seg-btn.credit.active { background: var(--success); color: #fff; }
.cd-seg-btn.clawback.active { background: var(--danger); color: #fff; }
.cd-inline-box {
  margin-top: 10px; padding: 12px; border-radius: 8px;
  border: 1px dashed var(--border-subtle); background: var(--surface-subtle);
}
.cd-facts-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px;
  margin: 0 0 14px;
}
.cd-fact dt { font-size: 11px; color: var(--ink-muted); margin-bottom: 2px; }
.cd-fact dd { margin: 0; font-size: 13px; color: var(--ink-primary); word-break: break-word; }
.cd-adj-preview {
  padding: 10px 12px; border-radius: 8px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border-hairline); margin: 10px 0;
}
.cd-adj-preview.credit { background: rgba(37, 101, 71, 0.08); color: var(--success); border-color: rgba(37, 101, 71, 0.25); }
.cd-adj-preview.clawback { background: var(--danger-bg); color: var(--danger); border-color: rgba(177, 60, 54, 0.28); }
.cd-end-box {
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border-hairline);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
/* ── End Commission Directory & Inspector (Phase 4) ── */

/* ── Commission Attention & Reports (Phase 5) ── */
.comm-attention-panel {
  border-left: 3.5px solid var(--warning);
}
.comm-attn-group + .comm-attn-group {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-hairline);
}
.comm-attn-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.comm-attn-item {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--surface-subtle, #F8FAFC);
}
.comm-attn-main {
  flex: 1 1 360px;
  min-width: 0;
}
.comm-attn-title {
  font-size: 13px;
  line-height: 1.4;
}
.comm-attn-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 5px;
  font-size: 12px;
}
.comm-attn-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.comm-product-link {
  font-weight: 600;
  text-decoration: underline;
}
.comm-undo-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.comm-undo-bar[hidden] {
  display: none;
}
.comm-ladder-table tr.comm-ladder-closing td {
  background: rgba(0, 46, 74, 0.06);
  border-top: 1.5px solid var(--brand-navy, #002E4A);
  font-size: 13.5px;
}
.comm-cogs-box {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--surface-subtle, #F8FAFC);
}
.comm-cost-table {
  font-size: 12px;
}
/* ── End Commission Attention & Reports (Phase 5) ── */

/* ── Edit Order Studio Slide-Over Drawer (Clinical Sovereign) ───────── */
.eo-drawer {
  width: min(1140px, 100vw);
  height: 100%;
  max-height: 100%;
  max-width: 100vw;
  background: var(--surface-card);
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid var(--border-subtle);
}
.eo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 20px;
  background: var(--surface-card);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.eo-head-main { min-width: 0; flex: 1; }
.eo-head-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.eo-head h2 {
  margin: 0;
  font-size: 16.5px;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--brand-obsidian);
}
.eo-head-sub {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.eo-head-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.eo-discard-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 20px;
  background: var(--warning-bg);
  border-bottom: 1px solid rgba(139, 87, 14, 0.25);
  color: var(--warning);
  font-size: 12.5px;
  font-weight: 600;
  flex-shrink: 0;
}
.eo-discard-bar[hidden] { display: none; }
.eo-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.eo-editor-pane {
  overflow-y: auto;
  padding: 18px 20px 32px;
  background: var(--surface-page);
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.eo-ledger-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface-card);
  border-left: 1px solid var(--border-subtle);
  overflow: hidden;
}
.eo-ledger-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.eo-ledger-foot {
  flex-shrink: 0;
  padding: 12px 18px max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-page);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.eo-section {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 15px 16px;
  box-shadow: 0 1px 2px rgba(11, 45, 72, 0.04);
}
.eo-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.eo-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--brand-obsidian);
  letter-spacing: -0.01em;
}
.eo-col-head {
  display: grid;
  grid-template-columns: minmax(170px, 1.55fr) 104px 104px 86px 76px 32px;
  gap: 10px;
  padding: 0 12px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-quaternary);
}
.eo-col-head .num-col { text-align: right; }
.eo-col-head .ctr-col { text-align: center; }
.eo-lines-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.eo-line-row {
  display: grid;
  grid-template-columns: minmax(170px, 1.55fr) 104px 104px 86px 76px 32px;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: #fff;
  transition: border-color 0.12s, background-color 0.12s, box-shadow 0.12s;
}
.eo-line-row.is-modified {
  border-color: rgba(34, 108, 155, 0.34);
  background: rgba(34, 108, 155, 0.032);
  box-shadow: inset 3px 0 0 var(--info);
}
.eo-line-row.is-added {
  border-color: rgba(37, 101, 71, 0.34);
  background: rgba(37, 101, 71, 0.038);
  box-shadow: inset 3px 0 0 var(--success);
}
.eo-line-row.is-waived {
  border-color: rgba(37, 101, 71, 0.32);
  background: linear-gradient(90deg, rgba(37, 101, 71, 0.05), #fff);
  box-shadow: inset 3px 0 0 var(--success);
}
.eo-line-row.is-error {
  border-color: rgba(177, 60, 54, 0.42);
  background: rgba(177, 60, 54, 0.035);
  box-shadow: inset 3px 0 0 var(--danger);
}
@keyframes eo-pulse {
  0% { box-shadow: 0 0 0 3px rgba(34, 108, 155, 0.36); }
  100% { box-shadow: 0 0 0 0 rgba(34, 108, 155, 0); }
}
.eo-line-row.is-pulse { animation: eo-pulse 0.65s ease-out; }
.eo-line-removed {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px dashed rgba(177, 60, 54, 0.32);
  background: rgba(177, 60, 54, 0.035);
  box-shadow: inset 3px 0 0 var(--danger);
}
.eo-line-removed-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  font-size: 12.5px;
  color: var(--ink-muted);
}
.eo-line-removed-name {
  text-decoration: line-through;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.eo-prod-info { min-width: 0; }
.eo-prod-title {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  font-size: 13px;
  font-weight: 700;
  color: var(--brand-obsidian);
  line-height: 1.25;
}
.eo-prod-sub {
  margin-top: 3px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.eo-stock-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.eo-stock-chip.is-short { color: var(--danger); font-weight: 700; }
.eo-stock-chip.is-warn { color: var(--warning); font-weight: 600; }
.eo-qty-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.eo-qty-cell .qty-stepper { width: 104px; justify-content: space-between; }
.eo-qty-cell .qty-stepper button { width: 28px; height: 30px; }
.eo-qty-cell .qty-stepper input {
  width: 46px;
  height: 30px;
  appearance: textfield;
  -moz-appearance: textfield;
}
.eo-qty-cell .qty-stepper input::-webkit-outer-spin-button,
.eo-qty-cell .qty-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.eo-qty-locked {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--surface-page);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-muted);
}
.eo-price-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.eo-price-box {
  position: relative;
  display: flex;
  align-items: center;
  border: 1px solid var(--border-control);
  border-radius: var(--radius-md);
  background: #fff;
  height: 32px;
  overflow: hidden;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.eo-price-box:focus-within {
  border-color: var(--brand-navy);
  box-shadow: 0 0 0 2px rgba(100, 144, 169, 0.24);
}
.eo-price-box.is-floor-warn {
  border-color: var(--warning);
  background: rgba(139, 87, 14, 0.03);
}
.eo-price-box.is-floor-block {
  border-color: var(--danger);
  background: rgba(177, 60, 54, 0.04);
}
.eo-price-box.is-disabled {
  opacity: 0.48;
  background: var(--surface-page);
}
.eo-price-prefix {
  padding: 0 6px 0 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-muted);
  user-select: none;
}
.eo-price-input {
  width: 100%;
  min-width: 0;
  height: 100%;
  border: 0;
  padding: 0 7px 0 0;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-primary);
  background: transparent;
  outline: none;
}
.eo-sub-hint {
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.25;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
.eo-sub-hint.is-info { color: var(--info); font-weight: 600; }
.eo-sub-hint.is-warn { color: var(--warning); font-weight: 600; }
.eo-sub-hint.is-danger { color: var(--danger); font-weight: 700; }
.eo-reset-mini {
  border: 0;
  background: transparent;
  color: var(--brand-navy);
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  padding: 0 2px;
  text-decoration: underline;
}
.eo-total-cell {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.eo-line-total {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--brand-obsidian);
  font-variant-numeric: tabular-nums;
}
.eo-line-total.is-waived { color: var(--ink-quaternary); }
.eo-delta-mini {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.eo-delta-mini.pos { color: var(--info); }
.eo-delta-mini.neg { color: var(--success); }
.eo-waive-cell .os-waive-pill {
  width: 100%;
  justify-content: center;
  height: 32px;
  padding: 0 6px;
  font-size: 11px;
}
.eo-rm-cell { display: flex; justify-content: center; }
.eo-rm-cell .os-rm-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.eo-rm-cell .os-rm-btn:disabled:hover { background: transparent; color: var(--ink-quaternary); border-color: transparent; }

/* Quick-Add Catalog */
.eo-catalog-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.eo-catalog-search { flex: 1; min-width: 190px; }
.eo-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px;
  max-height: 235px;
  overflow-y: auto;
  margin-top: 10px;
  padding: 2px 2px 4px;
  scrollbar-width: thin;
}
.eo-catalog-grid[hidden] { display: none; }
.eo-prod-card-disabled {
  opacity: 0.56;
  cursor: not-allowed !important;
}
.eo-prod-card-disabled:hover {
  transform: none !important;
  border-color: var(--border-subtle) !important;
  box-shadow: none !important;
}
.eo-price-strike {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-quaternary);
  text-decoration: line-through;
  margin-left: 4px;
  font-weight: 500;
}
.eo-deal-tag {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--success-bg);
  color: var(--success);
  margin-left: 4px;
}

/* Delivery & Notes Collapsible Section */
.eo-delivery-details {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(11, 45, 72, 0.04);
  overflow: hidden;
}
.eo-delivery-details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 16px;
  user-select: none;
}
.eo-delivery-details > summary::-webkit-details-marker { display: none; }
.eo-delivery-summary-copy { min-width: 0; flex: 1; }
.eo-delivery-summary-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--brand-obsidian);
}
.eo-delivery-summary-preview {
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.eo-delivery-caret {
  font-size: 12px;
  color: var(--ink-muted);
  transition: transform 0.14s ease;
  flex-shrink: 0;
}
.eo-delivery-details[open] .eo-delivery-caret { transform: rotate(90deg); }
.eo-delivery-body {
  padding: 0 16px 16px;
  border-top: 1px solid var(--border-hairline);
  padding-top: 14px;
}

/* Right-Hand Impact & Settlement Ledger */
.eo-ledger-head {
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--brand-obsidian), var(--brand-navy));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}
.eo-ledger-head h3 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: #fff;
}
.eo-ledger-pill {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.03em;
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.88);
}
.eo-ledger-pill.is-dirty { background: rgba(232, 166, 52, 0.25); color: #F7CA74; }
.eo-ledger-pill.is-blocked { background: rgba(177, 60, 54, 0.9); color: #fff; }
.eo-ledger-block {
  border: 1px solid var(--border-hairline);
  border-radius: 10px;
  padding: 11px 12px;
  background: var(--surface-card);
}
.eo-ledger-block.is-tinted {
  background: linear-gradient(180deg, rgba(0, 46, 74, 0.028), rgba(0, 46, 74, 0.01));
  border-color: var(--border-subtle);
}
.eo-ledger-block.is-credit {
  background: linear-gradient(180deg, rgba(37, 101, 71, 0.06), rgba(37, 101, 71, 0.02));
  border-color: rgba(37, 101, 71, 0.25);
}
.eo-ledger-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.eo-diff-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
}
.eo-diff-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.eo-diff-left {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  flex: 1;
}
.eo-diff-sym {
  font-family: var(--font-mono);
  font-weight: 800;
  width: 12px;
  text-align: center;
  flex-shrink: 0;
}
.eo-diff-sym.add { color: var(--success); }
.eo-diff-sym.mod { color: var(--info); }
.eo-diff-sym.rem { color: var(--danger); }
.eo-diff-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-primary);
}
.eo-diff-val {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.eo-wf-rows {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
}
.eo-wf-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.eo-total-hero {
  margin-top: 8px;
  padding-top: 9px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.eo-total-vals {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.eo-total-old {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-quaternary);
  text-decoration: line-through;
}
.eo-total-new {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--brand-navy);
}
.eo-effect-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.eo-effect-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink-primary);
}
.eo-effect-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  margin-top: 5px;
  flex-shrink: 0;
  background: var(--ink-quaternary);
}
.eo-effect-dot.info { background: var(--info); }
.eo-effect-dot.success { background: var(--success); }
.eo-effect-dot.warning { background: var(--brand-gold); }
.eo-effect-dot.danger { background: var(--danger); }
.eo-credit-toggle {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(34, 108, 155, 0.06);
  border: 1px solid rgba(34, 108, 155, 0.22);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-obsidian);
  cursor: pointer;
}
.eo-credit-toggle input { margin-top: 2px; flex-shrink: 0; accent-color: var(--brand-navy); }
.eo-reason-chips {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.eo-foot-secondary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.eo-lock-screen {
  padding: 28px 24px;
  max-width: 560px;
  margin: 24px auto;
}
.eo-receipt { margin-bottom: 16px; }
.eo-receipt-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 6px 0 4px;
}

@media (max-width: 960px) {
  .eo-drawer { width: 100vw; }
  .eo-workspace {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
  }
  .eo-editor-pane {
    overflow: visible;
    padding: 14px 14px 16px;
  }
  .eo-ledger-pane {
    border-left: 0;
    border-top: 1px solid var(--border-subtle);
    overflow: visible;
  }
  .eo-ledger-scroll { overflow: visible; }
  .eo-ledger-foot {
    position: sticky;
    bottom: 0;
    z-index: 10;
    box-shadow: 0 -4px 16px rgba(11, 45, 72, 0.10);
  }
  .eo-col-head { display: none; }
  .eo-line-row {
    grid-template-columns: 1fr auto;
    gap: 8px 10px;
  }
  .eo-prod-info { grid-column: 1 / 2; }
  .eo-total-cell { grid-column: 2 / 3; grid-row: 1 / 2; }
  .eo-qty-cell { grid-column: 1 / 2; align-items: flex-start; }
  .eo-price-cell { grid-column: 2 / 3; }
  .eo-waive-cell { grid-column: 1 / 2; }
  .eo-rm-cell { grid-column: 2 / 3; justify-content: flex-end; }
}
/* ── End Edit Order Studio ────────────────────────────────────────── */
