

:root {

  --sheet:                    #FCFCFD;
  --surface:                  #FCFCFD;
  --surface-bright:           #FFFFFF;
  --surface-dim:              #EEF0F4;
  --surface-container-lowest: #FFFFFF;
  --surface-container-low:    #F6F7F9;
  --surface-container:        #EFF1F5;
  --surface-container-high:   #E8EBF0;
  --surface-container-highest:#E1E5EC;
  --bg:                       #FCFCFD;


  --ink:                #0B1220;
  --ink-secondary:      #4A5568;

  --ink-tertiary:       #616B82;

  --on-surface:         #0B1220;
  --on-surface-variant: #4A5568;
  --inverse-surface:    #0B1220;
  --inverse-on-surface: #F6F7F9;


  --rule:        #E6E8EE;
  --rule-strong: #C9CEDA;
  --rule-heavy:  #0B1220;
  --border:      #E6E8EE;
  --outline:     #6E7891;
  --outline-variant: #C9CEDA;


  --primary:            #031534;
  --primary-soft:       #16223C;
  --primary-hover:      #0A1E42;
  --on-primary:         #FFFFFF;
  --primary-container:  #16223C;
  --on-primary-container: #9BA9C4;
  --primary-fixed:      #E7EBF3;
  --primary-fixed-dim:  #C6CFE0;

  --secondary:          #b02d21;
  --secondary-hover:    #8E2419;
  --on-secondary:       #FFFFFF;
  --secondary-soft:     #C0392B;
  --secondary-container:#F6DEDB;
  --on-secondary-container: #5C130C;

  --tertiary:           #1F5C7A;
  --on-tertiary:        #FFFFFF;
  --tertiary-container: #E3EDF3;
  --on-tertiary-container: #123A4E;
  --consultant-blue:    #1F5C7A;


  --data-primary:        #1F5C7A;
  --data-primary-soft:   #7FA8BE;
  --data-primary-wash:   #E3EDF3;
  --data-counter:        #8A6D1F;
  --data-counter-soft:   #C9B27E;
  --data-counter-wash:   #F4EFE2;
  --data-reference:      #9AA3B5;
  --data-negative:       #b02d21;
  --data-grid:           #EDEFF3;


  --success:    #1E6E4B;
  --success-bg: #E6F2EC;
  --warning:    #8A6D1F;
  --warning-bg: #F4EFE2;
  --error:      #b02d21;
  --error-bg:   #F9E9E7;
  --info:       #1F5C7A;
  --info-bg:    #E3EDF3;


  --internal-bg:     #FBF7EC;
  --internal-border: #C9B27E;
  --internal-text:   #6B5310;

  --row-hover:    #F6F7F9;
  --table-stripe: #FBFBFC;


  --font-body: ui-sans-serif, system-ui, -apple-system, 'Segoe UI Variable Text',
               'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-heading: var(--font-body);
  --font-mono: ui-monospace, 'Cascadia Mono', 'SF Mono', 'Segoe UI Mono',
               Consolas, 'Liberation Mono', monospace;


  --t-micro:  10px;
  --t-xs:     11px;
  --t-sm:     12px;
  --t-base:   13px;
  --t-md:     15px;
  --t-lg:     18px;
  --t-xl:     22px;
  --t-2xl:    28px;
  --t-fig:    32px;
  --t-fig-lg: 44px;

  --tracking-caps: 0.08em;
  --tracking-tight: -0.015em;


  --u: 4px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;


  --row-h: 40px;
  --cell-y: 10px;
  --cell-x: 12px;
  --section-y: 24px;
  --gutter: 24px;


  --sidebar-width: 232px;
  --topbar-height: 56px;

  --topbar-side: 240px;
  --drawer-width: 520px;


  --radius-sm: 2px;
  --radius: 3px;
  --radius-md: 4px;
  --radius-lg: 6px;
  --radius-xl: 8px;
  --radius-full: 9999px;


  --shadow-1: 0 1px 2px rgba(11, 18, 32, 0.05);
  --shadow-2: 0 4px 12px rgba(11, 18, 32, 0.07);
  --shadow-3: 0 12px 28px rgba(11, 18, 32, 0.12);
  --shadow-4: 0 24px 56px rgba(11, 18, 32, 0.18);


  --scrim: rgba(3, 21, 52, 0.52);
  --scrim-blur: 2px;


  --focus-ring: 0 0 0 3px rgba(31, 92, 122, 0.14);
  --focus-border: var(--consultant-blue);

  --error-ring: 0 0 0 3px rgba(176, 45, 33, 0.18);


  --flag-ring:     rgba(138, 109, 31, 0.28);
  --flag-ring-out: rgba(138, 109, 31, 0);


  --internal-tint:       rgba(245, 158, 11, 0.06);
  --internal-tint-hover: #FFF5DC;


  --shadow-up: 0 -8px 20px -12px rgba(11, 18, 32, 0.22);


  --selection-bg: #C8DAE4;


  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease: var(--ease-out);
  --dur-press: 120ms;
  --dur-fast: 160ms;
  --dur-panel: 220ms;
}


@media (max-width: 1279px) {
  :root {
    --row-h: 44px;
    --cell-y: 12px;
    --section-y: 20px;
    --gutter: 16px;
  }
}
@media (min-width: 1600px) {
  :root {
    --row-h: 38px;
    --cell-y: 9px;
    --section-y: 28px;
    --gutter: 32px;
  }
}


*, *::before, *::after { box-sizing: border-box; }


[hidden]:not([hidden='until-found']),
[hidden][class]:not([hidden='until-found']) { display: none; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--sheet);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--t-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}


::selection { background: var(--selection-bg); color: var(--ink); }
html { scrollbar-color: var(--rule-strong) transparent; scrollbar-width: thin; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--rule-strong);
  border-radius: var(--radius-full);
  border: 3px solid var(--sheet);
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-tertiary); }
input, textarea, [contenteditable] { caret-color: var(--consultant-blue); }

:focus-visible {
  outline: 2px solid var(--consultant-blue);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
:focus:not(:focus-visible) { outline: none; }

a {
  color: var(--consultant-blue);
  text-decoration: none;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
}
a:hover { text-decoration: underline; }

button { font-family: inherit; cursor: pointer; }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 650;
  color: var(--ink);
  margin: 0;
  line-height: 1.2;
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
}
h1 { font-size: var(--t-2xl); }
h2 { font-size: var(--t-lg); }
h3 { font-size: var(--t-md); }
h4 { font-size: var(--t-base); }

input, select, textarea {
  font-family: inherit;
  font-size: var(--t-base);
  color: var(--ink);
}


.tbl, table, .figure-value, .text-mono, .mono, .ref, .currency-num,
input[type="number"], .dt-table, .charge-summary-table {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
.mono, .ref, .currency-num, .text-mono { font-family: var(--font-mono); }


.figure {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.figure-value {
  font-size: var(--t-fig);
  font-weight: 620;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.figure-value--lg { font-size: var(--t-fig-lg); }
.figure-value--sm { font-size: var(--t-xl); }
.figure-value.is-negative { color: var(--data-negative); }
.figure-value.is-muted { color: var(--ink-tertiary); }
.figure-label {
  font-size: var(--t-micro);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--ink-tertiary);
}

.figure-basis {
  font-size: var(--t-xs);
  color: var(--ink-secondary);
  line-height: 1.45;
}
.figure-delta {
  font-size: var(--t-xs);
  font-variant-numeric: tabular-nums;
  color: var(--ink-secondary);
}
.figure-delta.is-up { color: var(--success); }
.figure-delta.is-down { color: var(--data-negative); }


.figure-rank {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--gutter);
  padding: var(--section-y) 0;
  border-bottom: 1px solid var(--rule);
}
.figure-rank > .figure + .figure {
  padding-left: var(--gutter);
  border-left: 1px solid var(--rule);
}


.sheet-section {
  padding: var(--section-y) 0;
  border-bottom: 1px solid var(--rule);
}
.sheet-section:last-child { border-bottom: 0; }
.sheet-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.sheet-title {
  font-size: var(--t-micro);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--ink-tertiary);
}
.sheet-note {
  font-size: var(--t-xs);
  color: var(--ink-secondary);
}


.rule-total { border-top: 2px solid var(--rule-heavy); }


.btn, .icon-btn, .dt-pagebtn, .rte-btn {
  transition: background-color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              transform var(--dur-press) var(--ease-out);
}
.btn:active, .icon-btn:active, .dt-pagebtn:active:not(:disabled) {
  transform: scale(0.97);
}

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


.app-shell { display: flex; min-height: 100vh; background: var(--sheet); }


.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sheet);
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 100;
}


.sidebar-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: var(--topbar-height);
  padding: 0 var(--space-5);
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
}

.sidebar-brand:focus-visible {
  outline: 2px solid var(--consultant-blue);
  outline-offset: -3px;
}
.sidebar-brand-name {
  font-size: var(--t-md);
  font-weight: 680;
  letter-spacing: -0.02em;
  color: var(--primary);
  line-height: 1.1;
}


.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding: var(--space-3) 0 var(--space-4);
}
.sidebar-nav-group { margin-top: var(--space-4); }
.sidebar-nav-group:first-child { margin-top: 0; }
.sidebar-nav-group-label {
  padding: 0 var(--space-5) var(--space-2);
  font-size: var(--t-micro);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--ink-tertiary);
}

.sidebar-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);

  min-height: 32px;
  padding: 6px var(--space-5);
  font-size: var(--t-base);
  font-weight: 500;
  color: var(--ink-secondary);
  border: 0;
  background: none;
  width: 100%;
  text-align: left;
  transition: color var(--dur-fast) var(--ease-out),
              background-color var(--dur-fast) var(--ease-out);
}
.sidebar-nav-item:hover { background: var(--surface-container-low); color: var(--ink); text-decoration: none; }

.sidebar-nav-item.active {
  color: var(--ink);
  font-weight: 620;
}
.sidebar-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--consultant-blue);
}
.sidebar-nav-item .icon { width: 16px; height: 16px; flex: none; opacity: 0.75; }
.sidebar-nav-item.active .icon { opacity: 1; color: var(--consultant-blue); }
.sidebar-nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }


.sidebar-nav-subitem { padding-left: calc(var(--space-5) + 12px); font-size: var(--t-sm); }

.sidebar-nav-soon {
  margin-left: auto;
  font-size: var(--t-micro);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-tertiary);
}
.sidebar-nav-collapsible > summary.sidebar-nav-group-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0 var(--space-5) var(--space-2);
  font-size: var(--t-micro);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--ink-tertiary);
}
.sidebar-nav-collapsible > summary.sidebar-nav-group-summary::-webkit-details-marker { display: none; }
.sidebar-nav-collapsible > summary.sidebar-nav-group-summary::after {
  content: '';
  margin-left: auto;
  width: 5px; height: 5px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform var(--dur-fast) var(--ease-out);
}
.sidebar-nav-collapsible[open] > summary.sidebar-nav-group-summary::after { transform: rotate(45deg); }


.sidebar-cta { padding: var(--space-3) var(--space-4) var(--space-1); }
.sidebar-cta .btn { width: 100%; justify-content: center; }
.sidebar-footer { padding: var(--space-3) var(--space-5) var(--space-4); border-top: 1px solid var(--rule); }


.sidebar-footer-brand { display: flex; align-items: center; justify-content: center; gap: var(--space-2); }
.sidebar-footer-logo { max-width: 132px; height: auto; }


.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }


.topbar {
  min-height: var(--topbar-height);
  flex: none;
  display: grid;

  grid-template-columns:
    minmax(min(var(--topbar-side), 26%), 1fr)
    minmax(0, 520px)
    minmax(min(var(--topbar-side), 26%), 1fr);
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--gutter);
  background: var(--sheet);
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  z-index: 90;
}


.search-wrap { position: relative; display: flex; align-items: center; flex: 0 1 420px; min-width: 180px; }
.search-wrap .icon-search { position: absolute; left: 10px; color: var(--ink-tertiary); pointer-events: none; }

.search-wrap input {
  width: 100%;
  height: 32px;
  padding: 0 10px 0 32px;
  font-size: var(--t-base);
  color: var(--ink);
  background: var(--surface-container-low);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
}
.search-wrap input::placeholder { color: var(--ink-tertiary); }
.search-wrap input:focus {
  outline: none;
  background: var(--surface-bright);
  border-color: var(--consultant-blue);
  box-shadow: var(--focus-ring);
}


.topbar-actions { display: flex; align-items: center; justify-self: end; gap: var(--space-2); }

.topbar-icon-btn {
  position: relative;
  width: 32px; height: 32px;
  min-width: 32px; min-height: 32px;
  display: grid; place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  color: var(--ink-secondary);
  text-decoration: none;
  transition: background 120ms ease-out, color 120ms ease-out;
}
.topbar-icon-btn:hover { background: var(--surface-container-low); color: var(--ink); }
.topbar-icon-btn:active { transform: scale(0.94); }
.topbar-icon-btn:focus-visible {
  outline: 2px solid var(--consultant-blue);
  outline-offset: 1px;
}

.topbar-user {
  display: flex; align-items: center; gap: var(--space-2);
  padding: 4px 6px 4px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
}
.topbar-user:hover { background: var(--surface-container-low); }

.topbar-user-meta { text-align: right; line-height: 1.25; min-width: 0; }

.topbar-user-name {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 168px;
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--ink);
}
.topbar-user-role {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 168px;
  font-size: var(--t-micro);
  color: var(--ink-tertiary);
}

@media (max-width: 1200px) {
  .topbar-user-meta { display: none; }
}

.avatar {
  display: grid; place-items: center;
  width: 28px; height: 28px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: var(--on-primary);
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: 0.02em;
  flex: none;
}
.avatar.size-sm { width: 22px; height: 22px; font-size: 9px; }
.avatar.size-lg { width: 40px; height: 40px; font-size: var(--t-sm); }
.avatar.size-xl { width: 56px; height: 56px; font-size: var(--t-md); }
.avatar-xs { width: 18px; height: 18px; font-size: 8px; display: inline-grid; place-items: center;
             border-radius: var(--radius-full); background: var(--primary); color: var(--on-primary); font-weight: 700; }


.content {
  flex: 1;
  padding: var(--section-y) var(--gutter) var(--space-16);
  width: 100%;
}


.page-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-6);
  flex-wrap: wrap;
  padding-bottom: var(--space-4);
  border-bottom: 2px solid var(--rule-heavy);
  margin-bottom: var(--section-y);
}
.page-title-row h1 { font-size: var(--t-2xl); }
.page-subtitle {
  margin: 4px 0 0;
  font-size: var(--t-sm);
  color: var(--ink-secondary);
  max-width: 78ch;
}
.page-title-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }


.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: var(--t-base);
  font-weight: 560;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn svg { flex: none; }


.btn-primary,
.btn-dark { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover:not(:disabled),
.btn-dark:hover:not(:disabled) { background: var(--primary-hover); }

.btn-secondary {
  background: var(--surface-bright);
  border-color: var(--rule-strong);
  color: var(--ink);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-container-low); border-color: var(--ink-tertiary); }

.btn-ghost { background: none; color: var(--ink-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-container-low); color: var(--ink); }

.btn-danger, .btn-error { background: var(--secondary); color: var(--on-primary); }
.btn-danger:hover:not(:disabled), .btn-error:hover:not(:disabled) { background: var(--secondary-hover); }

.btn-sm { height: 28px; padding: 0 10px; font-size: var(--t-sm); }
.btn-lg { height: 38px; padding: 0 16px; font-size: var(--t-md); }

.btn-link, .btn-link-danger {
  background: none; border: 0; padding: 0;
  font-family: inherit; font-size: var(--t-sm); font-weight: 560;
  color: var(--consultant-blue); cursor: pointer;
}
.btn-link:hover { text-decoration: underline; }
.btn-link-danger { color: var(--secondary); }
.btn-link-danger:hover { text-decoration: underline; }


.icon-btn {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px;
  min-width: 24px; min-height: 24px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  color: var(--ink-tertiary);
  transition: background 120ms ease-out, color 120ms ease-out;
}
.icon-btn:hover { background: var(--surface-container-low); color: var(--ink); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn:focus-visible { outline: 2px solid var(--consultant-blue); outline-offset: 1px; }


.card {
  background: var(--surface-bright);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.card:not(.flush) { padding: var(--space-5); }
.card.flush { padding: 0; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--rule);
}
.card-header h2, .card-header h3 { font-size: var(--t-md); }
.card-footer {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--rule);
}
.section-header {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--space-4); margin-bottom: var(--space-3);
}
.section-header h2, .section-header h3 { font-size: var(--t-md); }


.form-row { display: grid; gap: var(--space-4); }
.form-row.cols-1 { grid-template-columns: 1fr; }
.form-row.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-row.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) {
  .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr; }
}

.form-field { display: flex; flex-direction: column; min-width: 0; }
.form-field > label,
.form-field > .form-label {
  font-size: var(--t-micro);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--ink-tertiary);
  margin-bottom: 5px;
}

.form-field--inline {
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
  flex: none;
}
.form-field--inline > label,
.form-field--inline > .form-label { margin-bottom: 0; white-space: nowrap; }


:where(.drawer, .modal) .form-field:has(input[required], select[required], textarea[required]):not(:has(.field-required)) > label::after,
:where(.drawer, .modal) .form-field:has(input[required], select[required], textarea[required]):not(:has(.field-required)) > .form-label::after {
  content: "Required";
  margin-left: var(--space-2);
  font-size: var(--t-micro);
  font-weight: 560;
  letter-spacing: var(--tracking-caps);
  color: var(--ink-tertiary);
}


.form-hint {
  margin-top: 5px;
  font-size: var(--t-xs);
  line-height: 1.45;
  color: var(--ink-secondary);
}


:where(input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="search"], input[type="tel"], input[type="url"],
select, textarea) {
  width: 100%;
  min-height: 32px;
  padding: 6px 9px;
  background: var(--surface-bright);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  font-size: var(--t-base);
  color: var(--ink);
}
textarea { min-height: 76px; resize: vertical; line-height: 1.5; }
input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover:not(:disabled) {
  border-color: var(--ink-tertiary);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--consultant-blue);
  box-shadow: var(--focus-ring);
}
input:disabled, select:disabled, textarea:disabled,
input[readonly], textarea[readonly] {
  background: var(--surface-container-low);
  color: var(--ink-secondary);
  cursor: not-allowed;
}
input::placeholder, textarea::placeholder { color: var(--ink-tertiary); }


input[data-money] { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }


.checkbox-row {
  display: flex; align-items: flex-start; gap: var(--space-2);
  min-height: 24px;
  cursor: pointer;
}
.checkbox-row input[type="checkbox"] {
  width: 15px; height: 15px;
  flex: none;
  min-height: 0;
  margin-top: 3px;
  accent-color: var(--consultant-blue);
  cursor: pointer;
}
.checkbox-row input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--consultant-blue);
  outline-offset: 2px;
}
.checkbox-row label {
  font-size: var(--t-base); color: var(--ink);
  text-transform: none; letter-spacing: 0; font-weight: 400;
  line-height: 1.5;
  cursor: pointer;
}


.file-field {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.file-field-input {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.file-field-btn {
  text-transform: none;
  letter-spacing: 0;
  margin: 0;
  cursor: pointer;
}
.file-field-input:focus-visible + .file-field-btn {
  outline: 2px solid var(--consultant-blue);
  outline-offset: 2px;
}
.file-field-name {
  font-size: var(--t-sm);
  color: var(--ink-tertiary);
  min-width: 0;
  overflow-wrap: anywhere;
}
.file-field-name.is-set { color: var(--ink); }

.filter-bar {
  display: flex; align-items: flex-end; gap: var(--space-3); flex-wrap: wrap;
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--rule);
}


.tbl { width: 100%; border-collapse: collapse; }
.tbl thead th {
  padding: var(--space-2) var(--cell-x);
  text-align: left;
  font-size: var(--t-micro);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--ink-tertiary);
  background: var(--surface-bright);
  border-bottom: 1px solid var(--rule-strong);
  white-space: nowrap;
}
.tbl tbody td {
  padding: var(--cell-y) var(--cell-x);
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
  color: var(--ink);
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--row-hover); }
.tbl .text-right, .tbl th.text-right { text-align: right; }
.tbl .text-center, .tbl th.text-center { text-align: center; }

.table-wrap {
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--rule-strong) transparent;
  background:
    linear-gradient(to right, var(--sheet), transparent)
      left / 20px 100% no-repeat local,
    linear-gradient(to left, var(--sheet), transparent)
      right / 20px 100% no-repeat local,
    linear-gradient(to right, var(--rule-strong), transparent)
      left / 8px 100% no-repeat scroll,
    linear-gradient(to left, var(--rule-strong), transparent)
      right / 8px 100% no-repeat scroll;
}
.table-empty {
  padding: var(--space-12) var(--space-4);
  text-align: center;
  font-size: var(--t-base);
  color: var(--ink-tertiary);
}

.table-cell-title {
  background: none; border: 0; text-align: left;
  padding: 3px 0;
  min-height: 24px;
  font: inherit; color: inherit; cursor: pointer; width: 100%;
}
.table-cell-title:focus-visible {
  outline: 2px solid var(--consultant-blue);
  outline-offset: 1px;
  border-radius: 2px;
}
.table-cell-title:hover .text-bold { color: var(--consultant-blue); }


.cell-link {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 0;
}


.row-sub-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 0;
  min-height: 24px;
  font-size: var(--t-xs);
  color: var(--consultant-blue);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: var(--rule-strong);
  overflow-wrap: anywhere;
}
.row-sub-link:hover { text-decoration-color: currentColor; }
.row-sub-link:focus-visible {
  outline: 2px solid var(--consultant-blue);
  outline-offset: 1px;
  border-radius: 2px;
}

.row-sub-link-out { font-size: 0.9em; opacity: 0.75; }


.row-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: var(--space-3);
}
.row-sub .row-flag { margin-top: 0; }


.row-flag {
  display: inline-block;
  margin-top: 3px;
  padding: 0 5px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  font-size: var(--t-micro);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--ink-secondary);
}


.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--t-xs);
  font-weight: 560;
  color: var(--ink-secondary);
  white-space: nowrap;
}
.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: var(--radius-full);
  background: currentColor;
  flex: none;
}
.badge-neutral { color: var(--ink-tertiary); }
.badge-info { color: var(--consultant-blue); }
.badge-success { color: var(--success); }
.badge-warning { color: var(--warning); }
.badge-error { color: var(--error); }
.badge-dark { color: var(--primary); }

.badge-status-Draft { color: var(--ink-tertiary); }
.badge-status-Sent { color: var(--consultant-blue); }
.badge-status-Accepted { color: var(--success); }
.badge-status-Declined { color: var(--error); }
.badge-status-Cancelled { color: var(--ink-tertiary); }
.badge-status-Expired { color: var(--warning); }
.badge-status-Active { color: var(--success); }
.badge-status-Inactive { color: var(--ink-tertiary); }
.badge-status-Pending { color: var(--warning); }


.badge-status-Draft::before,
.badge-status-Inactive::before {
  width: 7px;
  height: 7px;
  background: transparent;
  border: 1.5px solid currentColor;
}


.badge-info.badge-chip, .rbac-sys {
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  color: var(--ink-secondary);
}
.badge-info.badge-chip::before, .rbac-sys::before { display: none; }


.toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 5000;
  display: flex;
  flex-direction: column;
  gap: 8px;

  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 380px;
  background: var(--surface-bright);
  border: 1px solid var(--rule-strong);
  border-left: 3px solid var(--info);
  padding: 10px 12px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-3);
  font-size: var(--t-base);
  color: var(--ink);
  display: flex;
  align-items: flex-start;
  gap: 10px;

  animation: toast-in 240ms var(--ease-out);
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--error); }
.toast.info { border-left-color: var(--info); }
.toast.warning { border-left-color: var(--warning); }
.toast-icon { flex: none; width: 16px; height: 16px; margin-top: 1px; }
.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--error); }
.toast.info .toast-icon { color: var(--info); }
.toast.warning .toast-icon { color: var(--warning); }
.toast-body { flex: 1; min-width: 0; }
.toast-kind {
  display: block;
  font-size: var(--t-micro);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--ink-tertiary);
  margin-bottom: 1px;
}
.toast-msg { display: block; line-height: 1.4; overflow-wrap: anywhere; }

.toast .toast-close {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  margin: -2px -2px 0 0;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--ink-tertiary);
  cursor: pointer;
  padding: 0;
}
.toast .toast-close:hover { background: var(--surface-container-low); color: var(--ink); }
.toast .toast-close:focus-visible {
  outline: 2px solid var(--consultant-blue);
  outline-offset: 1px;
}
.toast.is-leaving {
  animation: toast-out 160ms var(--ease-out) forwards;
}
@keyframes toast-in {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes toast-out {
  from { opacity: 1; }
  to { opacity: 0; }
}


.drawer-overlay {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  backdrop-filter: blur(var(--scrim-blur));
  z-index: 900;
  display: none;
}
.drawer-overlay.visible { display: block; }
.drawer {
  position: fixed;
  right: calc(-1 * var(--drawer-width));
  top: 0;
  width: var(--drawer-width);
  max-width: 100vw;
  height: 100vh;
  background: var(--surface-bright);
  z-index: 950;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-4);
  transition: right 250ms var(--ease);
  overflow-x: hidden;
}
.drawer.open { right: 0; }

.drawer:focus-visible,
.modal:focus-visible {
  outline: 2px solid var(--consultant-blue);
  outline-offset: -3px;
}

.drawer-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 68px;
}
.drawer-header > .icon-btn { flex: none; }

.drawer-title,
.modal-header h2,
.modal-header h3 {
  font-family: var(--font-heading);
  font-size: var(--t-lg);
  font-weight: 700;
  line-height: 1.5;
}
.drawer-title {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.drawer-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-5) var(--space-6);
}
.drawer-body .form-row.cols-2,
.drawer-body .form-row.cols-3 {
  grid-template-columns: 1fr 1fr;
}

.drawer-body .form-row.cols-3 > .form-field:nth-child(3):last-child {
  grid-column: 1 / -1;
}
.drawer-body .form-field { min-width: 0; }
.drawer-body input,
.drawer-body select,
.drawer-body textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.drawer-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--space-3);
}
.drawer-footer > .btn-link-danger { margin-right: auto; }


.modal-overlay {
  position: fixed; inset: 0;
  background: var(--scrim);
  backdrop-filter: blur(var(--scrim-blur));
  display: none;

  align-items: flex-start;
  justify-content: center;
  padding: 96px var(--space-4) var(--space-6);
  z-index: 1200;
}
.modal-overlay.visible { display: flex; }

@media (min-width: 1200px) {
  html:has(.drawer.open) .modal-overlay { padding-right: calc(var(--drawer-width) + var(--space-4)); }
}

@media (max-height: 720px) {
  .modal-overlay { padding-top: var(--space-6); }
}

html:has(.modal-overlay.visible),
html:has(.preview-viewer.visible),
html:has(.drawer.open) {
  overflow: hidden;
}
.modal {
  background: var(--surface-bright);
  border-radius: var(--radius-lg);
  width: min(640px, calc(100vw - 32px));

  max-height: calc(100vh - 96px - var(--space-6));
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-4);
}
@media (max-height: 720px) {
  .modal { max-height: calc(100vh - var(--space-6) * 2); }
}
.modal.large { width: min(900px, calc(100vw - 32px)); }
.modal-header { padding: var(--space-5) var(--space-6); border-bottom: 1px solid var(--rule); display:flex; justify-content: space-between; align-items: center; }
.modal-body { padding: var(--space-5) var(--space-6); overflow-y: auto; }
.modal-footer { padding: var(--space-4) var(--space-6); border-top: 1px solid var(--rule); display: flex; justify-content: flex-end; gap: var(--space-3); }


.tabs {
  display: flex;
  border-bottom: 1px solid var(--rule);
  gap: 0;
}

.tabs--inset { padding: 0 var(--space-6); }
.tab-btn {
  background: none;
  border: none;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--ink); }

.tab-btn.active { color: var(--ink); border-bottom-color: var(--secondary); }


.muted { color: var(--ink-secondary); }
.text-mono { font-family: var(--font-mono); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-warning { color: var(--warning); }
.text-info { color: var(--info); }
.text-bold { font-weight: 700; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-lg { font-size: 16px; }

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-6 { gap: 24px; }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }

.bare-list { margin: 0; padding-left: 18px; }
.w-full { width: 100%; }
.grow { flex: 1; }

.min-w-0 { min-width: 0; }
.hidden { display: none !important; }


.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); margin-bottom: var(--space-6); }
.metric-card {
  background: var(--surface-bright);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-5);
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
}
.metric-card .metric-icon-wrap {
  width: 40px; height: 40px;
  background: var(--surface-container-low);
  border-radius: var(--radius);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}
.metric-card .metric-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-secondary);
  margin-bottom: 4px;
}
.metric-card .metric-value {
  font-family: var(--font-heading);
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
  margin-bottom: 2px;
}
.metric-card .metric-trend { font-size: 11px; font-weight: 500; }
.metric-card .metric-trend.up { color: var(--success); }
.metric-card .metric-trend.down { color: var(--error); }
.metric-card .metric-trend.flat { color: var(--ink-secondary); }


.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--surface-bright);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-5);
}
.filter-bar .form-field { flex: 1; min-width: 140px; }
.filter-bar .filter-actions { display: flex; gap: var(--space-2); align-items: flex-end; }


.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--rule);
  background: var(--surface-bright);
  font-size: 12px;
  color: var(--ink-secondary);
}
.pagination .pages { display: flex; gap: 4px; }
.pagination .pages button {
  width: 30px; height: 30px;
  border: 1px solid var(--rule);
  background: var(--surface-bright);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  color: var(--ink);
}
.pagination .pages button.active { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.pagination .pages button:hover:not(.active) { background: var(--surface-container-low); }
.pagination .pages button:disabled { opacity: 0.4; cursor: not-allowed; }


.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
}
.section-header h2, .section-header h3 { margin: 0; }


.builder-bar {
  position: sticky;
  top: var(--topbar-height);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: var(--surface-bright);
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
  min-height: 60px;
}
.builder-bar h1 {
  font-size: 16px;
  margin: 0;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  letter-spacing: 0.01em;
}
.builder-bar h1 .builder-bar-sep { color: var(--outline); margin: 0 6px; font-weight: 400; }
.builder-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}
.builder-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: nowrap;
}


.completion-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 26px;
  padding: 3px 10px;
  background: none;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-full);
  font-size: var(--t-xs);
  font-weight: 600;
  color: var(--ink-secondary);
  white-space: nowrap;
  flex-shrink: 1;
  min-width: 0;
  cursor: pointer;
  transition: border-color 120ms ease-out, color 120ms ease-out;
}
.completion-chip:hover { border-color: var(--data-counter); color: var(--ink); }
.completion-chip:active { transform: scale(0.98); }
.completion-chip:focus-visible { outline: 2px solid var(--consultant-blue); outline-offset: 1px; }
.completion-chip-dot {
  flex: none;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--data-counter);
}
.completion-chip-text {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.completion-chip-more {
  color: var(--ink-tertiary);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.completion-chip[data-score="100"] { border-color: var(--rule); color: var(--ink-tertiary); }
.completion-chip[data-score="100"] .completion-chip-dot { background: var(--success); }
.completion-chip[data-score="100"]:hover { cursor: default; border-color: var(--rule); }


.is-flagged {
  animation: flag-field 1.6s var(--ease-out);
}
@keyframes flag-field {
  0%, 60% { box-shadow: 0 0 0 3px var(--flag-ring); }
  100% { box-shadow: 0 0 0 3px var(--flag-ring-out); }
}
@media (prefers-reduced-motion: reduce) {
  .is-flagged { animation: none; box-shadow: 0 0 0 2px var(--data-counter); }
}


@media (max-width: 700px) {
  .completion-chip-more { display: none; }
  .completion-chip { max-width: 46vw; }
}
@media (max-width: 540px) {
  .completion-chip { display: none; }
}

.builder-grid {
  display: grid;

  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 0;

  flex: 1;
}
.builder-pane-left {

  position: relative;
  padding: 24px;

  background: var(--bg);
  border-right: 1px solid var(--rule);
}

.builder-pane-left .form-field { min-width: 0; }
.builder-pane-left .form-field input,
.builder-pane-left .form-field select,
.builder-pane-left .form-field textarea {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
@media (max-width: 1400px) {
  .builder-pane-left .form-row.cols-3 {
    grid-template-columns: 1fr 1fr;
  }
}


.builder-ref-edit { width: 26px; height: 26px; opacity: 0.5; flex-shrink: 0; }
.builder-ref-edit:hover { opacity: 1; }
.tax-exempt-locked { background: var(--surface-container-low); color: var(--ink-secondary); cursor: not-allowed; }


.content.content-builder {
  padding: 0;
  max-width: none;
  margin: 0;
}
.builder-root {
  display: flex;
  flex-direction: column;

  min-height: calc(100vh - var(--topbar-height));
  box-sizing: border-box;
}

.hide-on-narrow { display: inline; }
@media (max-width: 1180px) {
  .hide-on-narrow { display: none; }
  .builder-bar-right .btn-sm { padding: 0 8px; }
}

.builder-footer-bar {
  min-height: 88px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px;
  background: var(--surface-bright);
  border-top: 1px solid var(--rule);
  box-shadow: var(--shadow-up);
  gap: 16px;
}
.builder-footer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.export-menu {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 6px;
  background: white;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-3);
  min-width: 180px;
  z-index: 100;
}
.btn-sm {
  height: 32px;
  padding: 0 10px;
  font-size: 12px;
}


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

.financials-chip-wrap {
  position: relative;
  flex: 0 0 auto;
}
.financials-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--internal-bg);
  border: 1px solid var(--internal-border);
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  color: var(--internal-text);
  cursor: pointer;
  transition: background 120ms var(--ease), box-shadow 120ms var(--ease);
}
.financials-chip:hover { background: var(--internal-tint-hover); box-shadow: var(--shadow-1); }
.financials-chip[aria-expanded="true"] { background: var(--internal-tint-hover); box-shadow: var(--shadow-2); }
.financials-chip-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--internal-border);
  flex-shrink: 0;
}
.financials-chip-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.financials-chip-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
}
.financials-popover {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 240px;
  background: var(--surface-bright);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--internal-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-3);
  padding: 12px 16px;
  z-index: 70;
  display: grid;
  gap: 12px;
}
.financials-popover[hidden] { display: none; }
.financials-popover .financials-row { line-height: 1.2; }
.financials-popover .label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--internal-text);
  margin-bottom: 2px;
}
.financials-popover .value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
}
.financials-popover .secondary {
  font-size: 11px;
  color: var(--internal-text);
  margin-top: 2px;
}


.line-items-table th { background: var(--surface-container-low); }
.line-items-table input.inline-input,
.line-items-table input.inline-num {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border: 1px solid var(--rule);
  padding: 5px 6px;
  border-radius: var(--radius);
  background: var(--surface-bright);
  font-family: var(--font-mono);
  font-size: 13px;
  -moz-appearance: textfield;
}
.line-items-table input.inline-num::-webkit-outer-spin-button,
.line-items-table input.inline-num::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
.line-items-table input.inline-input:hover,
.line-items-table input.inline-num:hover {
  border-color: var(--outline);
}
.line-items-table input.inline-input:focus,
.line-items-table input.inline-num:focus {
  border-color: var(--consultant-blue);
  background: var(--surface-bright);
  outline: none;
  box-shadow: var(--focus-ring);
}
.line-items-table input.inline-input { font-family: var(--font-body); }
.line-items-table .cost-cell { color: var(--internal-text); background: var(--internal-tint); }
.line-items-table .profit-cell { font-weight: 600; }
.line-items-table tr.product-type-row td { background: var(--surface-container-low); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-secondary); padding: 8px 12px; }


.line-items-table .billing-cell { vertical-align: top; }
.line-items-table select.inline-select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border: 1px solid var(--rule);
  padding: 5px 6px;
  border-radius: var(--radius);
  background: var(--surface-bright);
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--ink);
}
.line-items-table select.inline-select:hover { border-color: var(--outline); }
.line-items-table select.inline-select:focus {
  border-color: var(--consultant-blue);
  outline: none;
  box-shadow: var(--focus-ring);
}
.line-items-table .billing-recurring-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 4px;
}
.line-items-table .billing-recurring-fields[hidden] { display: none; }
.line-items-table .billing-taxable {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--ink-secondary);
  cursor: pointer;
  user-select: none;
}
.line-items-table .billing-taxable input { margin: 0; cursor: pointer; }
.line-items-table .billing-periods { margin-top: 4px; font-family: var(--font-mono); font-size: 11px; }


.charge-summary {
  margin-top: 18px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface-container-low);
  padding: 14px 16px;
}
.charge-summary-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-secondary);
  margin-bottom: 8px;
}
.charge-summary-table { width: 100%; border-collapse: collapse; }
.charge-summary-table td { padding: 5px 0; font-size: 13px; }
.charge-summary-table td:last-child { font-family: var(--font-mono); white-space: nowrap; }
.charge-summary-table tr.charge-summary-sub td {
  color: var(--ink-secondary);
  font-size: 12px;
}
.charge-summary-table tr.charge-summary-total td {
  border-top: 1px solid var(--rule);
  padding-top: 9px;
  font-weight: 700;
}
.charge-summary-note { margin: 10px 0 0; }


:root {
  --pp-design-width: 816px;
  --pp-design-height: 1056px;
  --pp-scale: 1;
}
.preview-stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-page-frame {
  position: relative;

  height: min(100%, calc(var(--pp-design-height) * 0.9));
  aspect-ratio: 8.5 / 11;
  max-width: 100%;
  background: white;
  border-radius: 2px;
  overflow: hidden;

  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.14), 0 1px 2px rgba(0,0,0,0.06); /* uilint:allow */
  font-family: 'Calibri', 'Segoe UI', sans-serif;
  color: #111; /* uilint:allow */
}
.preview-page-frame #preview-pane,
.preview-page-frame .preview-stack {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
.preview-stack { counter-reset: pp-page; }
.pp-page {
  counter-increment: pp-page;
  position: absolute;
  top: 0;
  left: 0;
  width: var(--pp-design-width);
  height: var(--pp-design-height);
  transform-origin: top left;
  transform: scale(var(--pp-scale, 1));
  display: none;
  padding: 36px 38px 38px;
  box-sizing: border-box;
  font-size: 11px;
  line-height: 1.45;
  background: white;
  border-radius: 2px;
  overflow: hidden;
}
.pp-page.active {
  display: block;
  animation: pp-page-fade 160ms var(--ease);
}
@keyframes pp-page-fade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}


.pp-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  border-bottom: 1.5px solid var(--pp-accent, #1F5C7A);
  padding-bottom: 10px;
  margin-bottom: 14px;
}
.pp-header-left img { height: 32px; display: block; }
.pp-header-right {
  font-size: 9px;
  color: #6B7280;
  text-align: right;
  max-width: 60%;
}
.pp-header-title { font-weight: 700; font-size: 15px; color: var(--pp-accent, #1F5C7A); line-height: 1.2; }
.pp-header-doctype { font-size: 10px; letter-spacing: 0.12em; color: #6B7280; margin-top: 2px; text-transform: uppercase; }


.pp-block-table { width: 100%; border-collapse: collapse; margin: 6px 0 8px; }
.pp-block-table th {
  background: var(--pp-accent, #1F5C7A); color: var(--on-primary); font-size: 10px; font-weight: 700;
  text-align: left; padding: 5px 8px; border: 1px solid var(--pp-accent, #1F5C7A);
}
.pp-block-table td { font-size: 10px; padding: 5px 8px; border: 1px solid #BFBFBF; vertical-align: top; }
.pp-block-table tbody tr:nth-child(even) td { background: #F2F2F2; }
.pp-approval-detail { white-space: pre-line; line-height: 1.6; }


.pp-title {
  font-family: 'Calibri', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--pp-accent, #1F5C7A);
  margin: 0 0 14px 0;
  line-height: 1.15;
}


.pp-section {
  font-family: 'Calibri', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--pp-accent, #1F5C7A);
  margin: 14px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--pp-accent, #1F5C7A);
}
.pp-prose { font-size: 11px; line-height: 1.5; margin-bottom: 8px; white-space: pre-line; }


.pp-prepared-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 4px;
}
.pp-prepared-table td {
  border: 1px solid #BFBFBF;
  padding: 6px 9px;
  vertical-align: top;
  font-size: 10px;
}
.pp-prepared-banner {
  background: var(--pp-accent, #1F5C7A);
  color: white;
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.04em;
  border-color: var(--pp-accent, #1F5C7A) !important;
}

.pp-prepared-banner.pp-info-banner {
  background: #E6E8EC;
  color: #111;
  border-color: #BFBFBF !important;
}
.pp-meta-label {
  background: #F2F2F2;
  font-weight: 700;
  width: 18%;
}
.pp-meta-value { width: 26%; }
.pp-client-cell { width: 56%; padding: 10px 12px !important; }
.pp-client-name { font-weight: 700; font-size: 12.5px; margin-bottom: 4px; color: #111; }
.pp-client-line { font-size: 10px; line-height: 1.45; color: #111; }


.pp-product-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 4px;
}
.pp-product-table th {
  background: var(--pp-accent, #1F5C7A);
  color: white;
  font-weight: 700;
  font-size: 10px;
  padding: 7px 8px;
  text-align: left;
  border: 1px solid var(--pp-accent, #1F5C7A);
}
.pp-product-table th.text-right { text-align: right; }
.pp-product-table th.text-center { text-align: center; }
.pp-product-table td {
  padding: 6px 8px;
  border: 1px solid #BFBFBF;
  font-size: 10px;
  vertical-align: middle;
}
.pp-product-table td.text-right { text-align: right; }
.pp-product-table td.text-center { text-align: center; }
.pp-product-table tbody tr:nth-child(even) td { background: #F2F2F2; }
.pp-product-table tr.pp-type-row td {
  background: #E6E8EC !important;
  color: var(--pp-accent, #1F5C7A);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 6px 8px;
}
.pp-product-table tr.pp-subtotal-row td {
  background: white !important;
  font-weight: 700;
  font-size: 10.5px;
}
.pp-product-table tr.pp-grandsubtotal-row td,
.pp-product-table tr.pp-tax-row td {
  background: #F8FAFC !important;
  font-weight: 600;
  font-size: 10.5px;
}
.pp-product-table tr.pp-grandsubtotal-row td { border-top: 1.5px solid #BFBFBF; }
.pp-product-table tr.pp-total-row td {
  background: #E6E8EC !important;
  font-weight: 800;
  font-size: 12px;
  color: var(--pp-accent, #1F5C7A);
  border-top: 2px solid var(--pp-accent, #1F5C7A);
}
.pp-item-desc { font-weight: 600; color: #111; }
.pp-item-meta { font-size: 9px; color: #6B7280; font-style: italic; margin-top: 1px; }
.pp-item-note { font-size: 9px; color: #374151; margin-top: 2px; }
.pp-spec-note { font-size: 10px; color: #374151; margin-top: 2px; }


.pp-terms-strip {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin: 10px 0 0;
  padding: 8px 10px;
  background: #F2F2F2;
  border-radius: 4px;
  font-size: 10.5px;
  color: #111;
}


.pp-project-total {
  text-align: right;
  margin-top: 10px;
  font-size: 12px;
}
.pp-project-total .pp-subtle { color: #6B7280; font-size: 10px; }
.pp-project-total .pp-amount { color: #1F5C7A; font-weight: 700; }


.pp-auth-heading {
  font-family: 'Calibri', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--pp-accent, #1F5C7A);
  text-align: center;
  margin: 6px 0 12px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--pp-accent, #1F5C7A);
}
.pp-approval-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.pp-approval-table td { border: 1px solid #BFBFBF; padding: 8px 10px; font-size: 11px; vertical-align: middle; }
.pp-approval-table .pp-approval-label { background: #F2F2F2; font-weight: 700; width: 25%; }
.pp-approval-table .pp-approval-total { font-weight: 700; color: #1F5C7A; font-size: 12px; }

.pp-auth-clause { font-size: 10.5px; margin: 14px 0 18px; }


.pp-tnc-block { margin-top: 8px; }
.pp-tnc-title { font-weight: 700; font-size: 11px; margin: 4px 0 2px; }


.pp-sig-row { display: grid; grid-template-columns: 1fr 1fr; gap: 36px; margin-top: 16px; }
.pp-sig-block { padding: 0 4px; }
.pp-sig-heading {
  font-weight: 700;
  font-size: 10px;
  color: var(--pp-accent, #1F5C7A);
  margin-bottom: 32px;
  letter-spacing: 0.02em;
}
.pp-sig-line {
  border-bottom: 1px solid #111;
  height: 16px;
  margin-bottom: 2px;
}
.pp-sig-label {
  font-size: 9px;
  color: #6B7280;
  margin-bottom: 16px;
}


.pp-spec-group {
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6B7280;
  margin: 12px 0 4px;
}
.pp-spec-name {
  font-weight: 700;
  font-size: 11.5px;
  color: var(--pp-accent, #1F5C7A);
  margin: 4px 0 1px;
}
.pp-spec-meta {
  font-size: 9px;
  font-style: italic;
  color: #6B7280;
  margin-bottom: 3px;
}
.pp-spec-body { margin-bottom: 12px; }


.settings-shell-head { margin-bottom: 4px; }
.settings-shell-head h1 {
  margin: 0;
  font-size: var(--t-2xl);
  letter-spacing: var(--tracking-tight);
}
.settings-tabs {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
  border-bottom: 1px solid var(--rule);
  margin: var(--space-4) 0 var(--space-6);
}
.settings-tab {
  padding: 8px 12px;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--ink-tertiary);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color 120ms ease-out;
}
.settings-tab:hover { color: var(--ink); }
.settings-tab.is-active { color: var(--ink); border-bottom-color: var(--secondary); }
.settings-tab:focus-visible {
  outline: 2px solid var(--consultant-blue);
  outline-offset: 2px;
  border-radius: 3px;
}


.settings-layout {
  display: grid;
  grid-template-columns: 172px minmax(0, 1fr);
  gap: var(--space-8);
  align-items: start;
}
.settings-rail {
  position: sticky;
  top: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: 1px;
  border-left: 1px solid var(--rule);
}
.settings-rail-link {
  display: flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 10px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  font-size: var(--t-sm);
  color: var(--ink-tertiary);
  text-decoration: none;
  transition: color 120ms ease-out;
}
.settings-rail-link:hover { color: var(--ink); }

.settings-rail-link.is-active {
  color: var(--ink);
  font-weight: 600;
  border-left-color: var(--consultant-blue);
}
.settings-main { min-width: 0; }

.settings-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--gutter);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--rule-strong);
}
.settings-page-head h2 {
  margin: 0 0 4px;
  font-size: var(--t-xl);
  letter-spacing: var(--tracking-tight);
}
.settings-page-head .page-subtitle { margin: 0; max-width: 68ch; }
.settings-save {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: none;
}

.settings-dirty {
  font-size: var(--t-xs);
  font-weight: 600;
  color: var(--data-counter);
  white-space: nowrap;
}
.settings-dirty::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--data-counter);
  vertical-align: 1px;
}


.brand-block {
  display: flex;
  align-items: flex-start;
  gap: var(--gutter);
  padding: var(--space-4);
  background: var(--surface-container-low);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  margin-bottom: var(--space-5);
}
.brand-logo {
  flex: none;
  height: 48px;
  max-width: 190px;
  object-fit: contain;

  background: #fff; /* uilint:allow */
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 5px;
}
.brand-block-body { flex: 1; min-width: 0; }
.brand-block-body .form-hint { margin-top: 3px; }
.brand-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-top: var(--space-3);
}


.input-suffix-wrap {
  position: relative;
  display: flex;
  align-items: center;
  --suffix-reserve: 42px;
}
.input-suffix-wrap--wide { --suffix-reserve: 72px; }
.input-suffix-wrap input { padding-right: var(--suffix-reserve); }
.input-suffix {
  position: absolute;
  right: 9px;
  font-size: var(--t-sm);
  color: var(--ink-tertiary);
  pointer-events: none;
}


.setting-toggle {
  align-items: flex-start;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding: var(--space-3);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  cursor: pointer;
}
.setting-toggle:hover { background: var(--surface-container-low); }
.setting-toggle input[type="checkbox"] { margin-top: 1px; }
.setting-toggle-label {
  display: block;
  font-size: var(--t-base);
  font-weight: 600;
  color: var(--ink);
}
.setting-toggle-note {
  display: block;
  margin-top: 2px;
  font-size: var(--t-xs);
  line-height: 1.5;
  color: var(--ink-secondary);
  max-width: 70ch;
}


.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--t-xs);
  font-weight: 600;
  color: var(--ink-secondary);
}
.status-dot::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.status-dot.status-ok { color: var(--success); }
.status-dot.status-off { color: var(--ink-tertiary); }

.accent-row {
  display: flex;
  align-items: flex-end;
  gap: var(--gutter);
  flex-wrap: wrap;
  margin-top: var(--space-4);
}
.accent-picker { flex: none; width: auto; }
.accent-picker input[type="color"] {
  width: 56px;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-bright);
  cursor: pointer;
}
.accent-picker input[type="color"]:disabled { cursor: default; opacity: 0.5; }
.accent-auto { display: flex; flex-direction: column; gap: 4px; }
.accent-auto-read { display: flex; align-items: center; gap: 7px; min-height: 24px; }
.accent-swatch {
  width: 18px; height: 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule-strong);
  display: inline-block;
}

.smtp-test {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--rule);
}
.smtp-test .form-field { flex: 0 1 280px; }
.smtp-test .form-hint { flex: 1 1 100%; margin-top: 0; }

@media (max-width: 1080px) {
  .settings-layout { grid-template-columns: 1fr; }

  .settings-rail {
    position: static;
    flex-direction: row;
    overflow-x: auto;
    border-left: 0;
    border-bottom: 1px solid var(--rule);
    padding-bottom: 2px;
    margin-bottom: var(--space-2);
  }
  .settings-rail-link {
    border-left: 0;
    border-bottom: 2px solid transparent;
    margin-left: 0;
    margin-bottom: -3px;
    white-space: nowrap;
    min-height: 30px;
  }
  .settings-rail-link.is-active { border-bottom-color: var(--consultant-blue); }
}
@media (max-width: 720px) {
  .settings-page-head { flex-direction: column; }
  .brand-block { flex-direction: column; }
}


.blocks-list { display: flex; flex-direction: column; gap: 12px; }
.block-card {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface-bright);
  transition: opacity 0.15s var(--ease);
}
.block-card.is-disabled { opacity: 0.55; }
.block-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.block-include {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 24px;
  font-size: var(--t-xs); color: var(--ink-secondary);
  white-space: nowrap; cursor: pointer;
}
.block-title-input {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface-container-low);
}
.block-title-input:focus { border-color: var(--consultant-blue); background: var(--surface-bright); outline: none; }
.block-card-actions { display: inline-flex; align-items: center; gap: 2px; }
.block-card-actions .icon-btn { width: 26px; height: 26px; font-size: 14px; }
.block-core-badge {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--consultant-blue); background: var(--info-bg);
  padding: 2px 6px; border-radius: 999px;
}
.block-body-input {
  width: 100%;
  font: inherit;
  font-size: 12.5px;
  line-height: 1.5;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  resize: vertical;
}
.block-tokens { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.block-token {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--consultant-blue);
  background: var(--info-bg);
  padding: 1px 6px;
  border-radius: 4px;
}

.block-picker-list { display: flex; flex-direction: column; gap: 8px; }
.block-picker-item {
  display: flex; flex-direction: column; gap: 2px; text-align: left;
  width: 100%; padding: 10px 12px; cursor: pointer;
  border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--surface-bright); font: inherit;
}
.block-picker-item:hover { border-color: var(--consultant-blue); background: var(--surface-container-low); }
.block-picker-title { font-weight: 600; font-size: 13px; color: var(--ink); }
.block-picker-sub { font-size: 11px; color: var(--ink-secondary); }


.token-menu {
  position: absolute;
  z-index: 9000;
  background: var(--surface-bright);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-3);
  max-height: 260px;
  overflow-y: auto;
  padding: 4px;
}
.token-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.token-menu-item.is-active, .token-menu-item:hover { background: var(--surface-container-low); }
.token-menu-key { font-family: var(--font-mono); font-size: 11px; color: var(--consultant-blue); }


.token-input {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 8px 10px;
  font: inherit;
  font-size: 12.5px;
  line-height: 1.5;
  min-height: 34px;
  max-height: 130px;
  overflow-y: auto;
  background: var(--surface-bright);
  white-space: pre-wrap;
  word-break: break-word;
  cursor: text;
}
.token-input:focus { outline: none; border-color: var(--consultant-blue); }
.token-input[data-placeholder]:empty::before {
  content: attr(data-placeholder);
  color: var(--ink-secondary);
  opacity: 0.55;
  pointer-events: none;
}
.ph-chip {
  background: var(--info-bg);
  color: var(--consultant-blue);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.92em;
  white-space: nowrap;
}
.ph-chip.ph-legend { cursor: pointer; display: inline-block; }
.ph-chip.ph-legend:hover { background: var(--consultant-blue); color: var(--on-primary); }


.actions-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  min-width: 210px;
  background: var(--surface-bright);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-3);
  padding: 6px;
  z-index: 60;
}
.actions-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
}
.actions-menu-item:hover { background: var(--surface-container-low); }
.actions-menu-item.danger { color: var(--error); }
.actions-menu-sep { height: 1px; background: var(--rule); margin: 6px 4px; }


.lib-card .block-card-head { flex-wrap: wrap; }
.lib-grid { width: 100%; border-collapse: collapse; margin-top: 8px; }
.lib-grid th, .lib-grid td { border: 1px solid var(--rule); padding: 2px; vertical-align: top; }
.lib-grid .lib-col { width: 100%; border: none; font-weight: 600; font-size: 12px; padding: 4px 6px; background: var(--surface-container-low); }

.lib-grid .lib-cell {
  width: 100%; border: none; border-radius: 0; font: inherit; font-size: 12px;
  padding: 4px 6px; background: transparent; min-height: 26px; max-height: 64px; overflow-y: auto;
}
.lib-grid .lib-col:focus, .lib-grid .lib-cell:focus { outline: 1px solid var(--consultant-blue); }
.lib-col-head { display: flex; align-items: center; gap: 2px; }
.lib-col-head .lib-del-col { flex-shrink: 0; width: 24px; height: 24px; opacity: 0.55; }
.lib-col-head .lib-del-col:hover { opacity: 1; }

.pp-empty { text-align: center; padding: 24px 12px; color: #6B7280; font-style: italic; }
.text-right { text-align: right; }
.text-center { text-align: center; }


.quick-action-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--surface-bright);
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  font-size: 13px;
  margin-bottom: var(--space-2);
}
.quick-action-card:hover { background: var(--surface-container-low); text-decoration: none; }
.quick-action-card.dark { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.quick-action-card.dark:hover { background: var(--primary-hover); }


.activity-list { display: flex; flex-direction: column; gap: var(--space-4); }
.activity-item {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--rule);
}
.activity-item:last-child { border-bottom: none; padding-bottom: 0; }

.activity-mark {
  flex: none;
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-full);
  background: var(--surface-container);
  color: var(--ink-secondary);
}

.activity-mark--security { background: var(--warning-bg); color: var(--warning); }
.activity-mark--signin   { background: var(--tertiary-container); color: var(--on-tertiary-container); }
.activity-item .activity-text { flex: 1; }
.activity-item .activity-text .who { font-weight: 600; }
.activity-item .activity-time { font-size: 11px; color: var(--ink-secondary); margin-top: 2px; }


.profile-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: var(--space-8);
  align-items: start;
}
@media (max-width: 1080px) {
  .profile-grid { grid-template-columns: 1fr; gap: 0; }
}

.profile-head { align-items: center; }
.profile-identity {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-width: 0;
}
.profile-identity h2 { margin: 0 0 2px; }
.profile-identity .page-subtitle { margin: 0; }


.profile-earnings .figure { margin-bottom: var(--space-4); }
.figure-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gutter);
  padding-top: var(--space-4);
  border-top: 1px solid var(--rule);
}
.profile-earnings-foot {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--rule);
}


.permission-list { display: flex; flex-direction: column; gap: 10px; }
.permission-list .row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: var(--surface-container-low); border-radius: var(--radius);
}
.toggle {
  position: relative;
  display: inline-block;
  width: 36px; height: 20px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--surface-container-high);
  border-radius: var(--radius-full);
  transition: 200ms var(--ease);
}
.toggle .slider::before {
  content: ""; position: absolute;
  height: 16px; width: 16px;
  left: 2px; top: 2px;
  background: white;
  border-radius: var(--radius-full);
  transition: 200ms var(--ease);
}
.toggle input:checked + .slider { background: var(--consultant-blue); }
.toggle input:checked + .slider::before { transform: translateX(16px); }


.slab-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 36px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.slab-row input { height: 34px; }


.spin {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--surface-container-highest);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }


.typeahead { position: relative; }
.typeahead-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface-bright);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-3);
  max-height: 280px;
  overflow-y: auto;
  z-index: 200;
}
.typeahead-item {
  padding: 10px 12px; cursor: pointer;
  border-bottom: 1px solid var(--rule);
  font-size: 13px;
}
.typeahead-item:last-child { border-bottom: none; }
.typeahead-item:hover, .typeahead-item.highlighted { background: var(--surface-container-low); }
.typeahead-item .meta { font-size: 11px; color: var(--ink-secondary); display: block; margin-top: 2px; }


button.table-cell-title {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
button.table-cell-title:hover .text-bold,
button.table-cell-title:focus-visible .text-bold {
  color: var(--primary);
  text-decoration: underline;
}
button.table-cell-title:focus-visible {
  outline: 2px solid var(--primary-fixed-dim);
  outline-offset: 2px;
  border-radius: 2px;
}
a.table-cell-title {
  color: inherit;
  text-decoration: none;
}
a.table-cell-title:hover .text-bold,
a.table-cell-title:focus-visible .text-bold {
  color: var(--primary);
  text-decoration: underline;
}


@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .profile-grid { grid-template-columns: 1fr; }
}


.sidebar-backdrop { display: none; }


@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 240px;
    height: 100vh;
    z-index: 200;
    transform: translateX(0);
    transition: transform 0.2s var(--ease);
  }
  html.nav-collapsed .sidebar { transform: translateX(-100%); }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: var(--scrim);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s var(--ease);
  }
  html:not(.nav-collapsed) .sidebar-backdrop { opacity: 1; pointer-events: auto; }
}


@media (max-width: 820px) {
  .builder-grid {

    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 1fr;
  }
  .builder-pane-left, .builder-pane-right { min-width: 0; }

  .builder-footer-bar { flex-direction: column; align-items: stretch; gap: 12px; padding: 12px 16px; }
}


.topbar-popover-wrap { position: relative; }

.builder-bar .danger-btn,
.btn.btn-danger {
  background: var(--error);
  color: white;
  border: 1px solid var(--error);
}

.btn.btn-danger:hover { background: var(--secondary-hover); border-color: var(--secondary-hover); }
.btn.btn-ghost.btn-danger {
  background: transparent;
  color: var(--error);
  border-color: transparent;
}
.btn.btn-ghost.btn-danger:hover {
  background: var(--error-bg);
  color: var(--error);
}


.badge-opp-stage-Lead,
.badge-opp-stage-Qualified,
.badge-opp-stage-Qualification { color: var(--ink-tertiary); }
.badge-opp-stage-Proposal,
.badge-opp-stage-Negotiation,
.badge-opp-stage-Verbal-Approval { color: var(--consultant-blue); }
.badge-opp-stage-Won { color: var(--success); }
.badge-opp-stage-Lost { color: var(--error); }
.badge-opp-stage-On-Hold { color: var(--warning); }

.badge-opp-stage-Lead::before,
.badge-opp-stage-Qualified::before,
.badge-opp-stage-Qualification::before,
.badge-opp-stage-On-Hold::before {
  width: 7px;
  height: 7px;
  background: transparent;
  border: 1.5px solid currentColor;
}


.builder-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-full);
  background: var(--surface-container-low);
  color: var(--primary-soft);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background 120ms var(--ease), color 120ms var(--ease), border-color 120ms var(--ease);
}
.builder-back-link:hover {
  background: var(--primary-soft);
  border-color: var(--primary-soft);
  color: var(--on-primary);
  text-decoration: none;
}
.builder-back-link svg { flex-shrink: 0; }
.builder-back-link-label { letter-spacing: 0.01em; }
@media (max-width: 700px) {
  .builder-back-link-label { display: none; }
  .builder-back-link { padding: 0 8px; }
}


.changelog-list { display: flex; flex-direction: column; gap: var(--space-4); margin: 0; padding: 0; list-style: none; }

.changelog-entry { border-left: 2px solid var(--rule-strong); padding: 4px 0 4px 12px; }
.changelog-entry-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.changelog-entry-version {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
  color: var(--primary);
  letter-spacing: 0.02em;
}
.changelog-entry-date { font-size: 11px; color: var(--ink-secondary); }
.changelog-entry-title { font-weight: 600; font-size: 13px; margin: 0 0 4px; }
.changelog-entry-items { margin: 0; padding-left: 16px; font-size: 12px; color: var(--ink-secondary); }
.changelog-entry-items li { margin-bottom: 2px; }
.changelog-version-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--surface-container);
  color: var(--ink-secondary);
  border-radius: var(--radius-full);
}


.rbac-role-list { display: flex; flex-direction: column; }
.rbac-role-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border: none;
  border-left: 3px solid transparent;
  border-bottom: 1px solid var(--rule);
  background: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: background 120ms ease-out;
}
.rbac-role-item:last-child { border-bottom: 0; }
.rbac-role-item:hover { background: var(--surface-container-low); }

.rbac-role-item.is-active {
  background: var(--surface-container-low);
  border-left-color: var(--consultant-blue);
}
.rbac-role-item:focus-visible {
  outline: 2px solid var(--consultant-blue);
  outline-offset: -2px;
}
.rbac-role-name {
  display: flex; align-items: center; gap: var(--space-2);
  font-weight: 600; font-size: var(--t-base); color: var(--ink);
}
.rbac-role-sub {
  font-size: var(--t-xs);
  color: var(--ink-tertiary);
  font-variant-numeric: tabular-nums;
}
.rbac-sys {
  font-size: var(--t-micro);
  padding: 1px 5px;
  letter-spacing: var(--tracking-caps);
}

.rbac-detail-head {
  border-bottom: 1px solid var(--rule-strong);
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-4);
}
.rbac-detail-meta {
  display: flex; align-items: center; gap: var(--space-3);
  margin-top: var(--space-3);
}

.rbac-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.rbac-toolbar-actions {
  display: flex; align-items: center; gap: var(--space-2);
  margin-left: auto;
}

.rbac-cat { margin-bottom: var(--space-5); }

.rbac-cat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 0 0 4px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--space-1);
}
.rbac-cat-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 26px;
  font-size: var(--t-micro);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--ink-tertiary);
  cursor: pointer;
}
.rbac-cat-toggle:hover { color: var(--ink); }
.rbac-cat-toggle input { cursor: pointer; }
.rbac-cat-count {
  font-size: var(--t-xs);
  color: var(--ink-tertiary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rbac-perm-rows { display: flex; flex-direction: column; }
.rbac-perm {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: 7px var(--space-2);
  border-radius: var(--radius);
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
}
.rbac-perm:last-child { border-bottom: 0; }
.rbac-perm:hover { background: var(--surface-container-low); }

.rbac-perm.is-on .rbac-perm-label { font-weight: 700; }
.rbac-perm input { margin-top: 2px; cursor: pointer; }
.rbac-perm input:disabled { cursor: not-allowed; }
.rbac-perm-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.rbac-perm-label {
  display: flex; align-items: center; gap: var(--space-2);
  font-size: var(--t-base); font-weight: 600; color: var(--ink);
}
.rbac-perm-desc {
  font-size: var(--t-sm);
  color: var(--ink-secondary);
  line-height: 1.45;
}
.rbac-perm-implies {
  font-size: var(--t-xs);
  color: var(--ink-tertiary);
}
.rbac-perm-implies::before { content: '↳ '; }


.rbac-assign-list { display: flex; flex-direction: column; gap: 2px; }
.rbac-assign-scroll { max-height: 260px; overflow-y: auto; border: 1px solid var(--rule-strong); border-radius: var(--radius); padding: 6px; }
.rbac-assign-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 7px 9px;
  border-radius: var(--radius);
  cursor: pointer;
}
.rbac-assign-row:hover { background: var(--surface-container-low); }

.rbac-assign-row input {
  flex: none;
  width: 15px;
  height: 15px;
  margin-top: 2px;
  cursor: pointer;
}

.rbac-assign-row:has(input:disabled) { cursor: default; }
.rbac-assign-row:has(input:disabled):hover { background: transparent; }
.rbac-assign-row:has(input:disabled) .rbac-assign-name { color: var(--ink-secondary); font-weight: 500; }
.rbac-assign-name { display: block; font-size: 13px; font-weight: 600; }
.rbac-assign-sub { display: block; font-size: 11px; color: var(--ink-secondary); line-height: 1.4; }
.rbac-assign-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.rbac-filter-input {
  flex: 1;
  min-width: 0;
  padding: 6px 9px;
}
.rbac-effective { margin: 0; }
.rbac-effective-empty {
  margin: 0;
  font-size: var(--t-sm);
  color: var(--ink-secondary);
}
.rbac-effective-count {
  margin: 0 0 var(--space-3);
  font-size: var(--t-xs);
  font-weight: 600;
  color: var(--ink-tertiary);
  font-variant-numeric: tabular-nums;
}

.rbac-effective-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4) var(--gutter);
}
.rbac-effective-cat {
  font-size: var(--t-micro);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--ink-tertiary);
  padding-bottom: 3px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 5px;
}
.rbac-effective-list { list-style: none; margin: 0; padding: 0; }
.rbac-effective-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 2px 0;
  font-size: var(--t-sm);
  line-height: 1.4;
}
.rbac-effective-label { color: var(--ink); }
.rbac-effective-via {
  flex: none;
  font-size: var(--t-micro);
  color: var(--ink-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 45%;
}


.field-error {
  display: block;
  margin-top: 5px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--error);
}
input.has-error,
select.has-error,
textarea.has-error {
  border-color: var(--error);
  background: var(--error-bg);
}

input.has-error:focus,
select.has-error:focus,
textarea.has-error:focus {
  outline: none;
  border-color: var(--error);
  box-shadow: var(--error-ring);
}


.dt { display: flex; flex-direction: column; }

.dt-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--rule);
}
.dt-search { position: relative; display: flex; align-items: center; min-width: 220px; flex: 0 1 300px; }
.dt-search svg { position: absolute; left: 10px; color: var(--ink-secondary); pointer-events: none; }

.dt-search-input {
  width: 100%;
  padding: 7px 10px 7px 32px;
}
.dt-search-input:focus {
  outline: none;
  border-color: var(--consultant-blue);
  box-shadow: var(--focus-ring);
}
.dt-filters { display: flex; gap: 8px; flex-wrap: wrap; }

.dt-filter {
  width: auto;
  padding: 7px 9px;
  max-width: 190px;
}
.dt-filter:focus {
  outline: none;
  border-color: var(--consultant-blue);
  box-shadow: var(--focus-ring);
}
.dt-toolbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.dt-extra { display: flex; align-items: center; gap: 8px; }


.dt-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--t-sm);
  color: var(--ink-tertiary);
  white-space: nowrap;
}
.dt-meta:empty { display: none; }


.dt-table { width: 100%; }
.dt-th { white-space: nowrap; }
.dt-th-inner { display: inline-flex; align-items: center; gap: 5px; }

.dt-th.text-right .dt-th-inner { flex-direction: row-reverse; }
.dt-sortable { cursor: pointer; user-select: none; }
.dt-sortable:hover { background: var(--surface-container); }
.dt-sortable:focus-visible {
  outline: 2px solid var(--consultant-blue);
  outline-offset: -2px;
}
.dt-sort-icon { opacity: 0.3; flex: none; }
.dt-sortable:hover .dt-sort-icon { opacity: 0.6; }
.dt-sort-icon.is-active { opacity: 1; color: var(--consultant-blue); }
.dt-th.is-sorted { color: var(--consultant-blue); }

.dt-row-clickable { cursor: pointer; }
.dt-row-clickable:hover { background: var(--surface-container-low); }


.dt-open {
  display: block;

  width: calc(100% + var(--cell-x) * 2);
  min-height: 24px;
  margin: calc(var(--cell-y) * -1) calc(var(--cell-x) * -1);
  padding: var(--cell-y) var(--cell-x);
  color: inherit;
  font: inherit;
  text-align: inherit;
  text-decoration: none;
}
button.dt-open {
  border: 0;
  background: none;
  cursor: pointer;
}

.dt-open:not(:only-child) {
  margin-bottom: 0;
  padding-bottom: 0;
}
a.dt-open:hover { text-decoration: underline; text-underline-offset: 2px; }

.dt-open:focus-visible {
  outline: 2px solid var(--consultant-blue);
  outline-offset: -2px;
  border-radius: var(--radius);
}


.dt-table-frame { position: relative; }
.dt-table-wrap { position: relative; overflow-x: auto; }
.dt-table-wrap.dt-fits { overflow: visible; }


.dt-table-wrap.dt-fits .dt-table thead th {
  position: sticky;
  top: var(--topbar-height);
  z-index: 3;
}
.dt-table-wrap.dt-fits .dt-table thead .qf-bulk-cell { z-index: 4; }

.dt-state {
  padding: 40px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--ink-secondary);
}
.dt-state.is-error { color: var(--error); }


.dt-pager {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 9px 16px;
  font-size: 12px;
  color: var(--ink-secondary);
}

.dt-pager:empty { display: none; }
.dt-pager-top { border-bottom: 1px solid var(--rule); }
.dt-pager-bottom { border-top: 1px solid var(--rule); }
.dt-pagesize { display: flex; align-items: center; gap: 6px; }
.dt-count { font-variant-numeric: tabular-nums; color: var(--ink-secondary); }
.dt-pagebtns { display: flex; align-items: center; gap: 3px; margin-left: auto; }
.dt-pagebtn {
  min-width: 28px;
  height: 28px;
  padding: 0 7px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface-bright);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: inherit;
  cursor: pointer;
}
.dt-pagebtn:hover:not(:disabled) { background: var(--surface-container); }
.dt-pagebtn:disabled { opacity: 0.4; cursor: default; }
.dt-pagebtn.is-current {
  background: var(--consultant-blue);
  border-color: var(--consultant-blue);
  color: var(--on-primary);
  font-weight: 600;
}
.dt-pagegap { padding: 0 3px; }

@media (max-width: 700px) {
  .dt-toolbar { flex-direction: column; align-items: stretch; }
  .dt-toolbar-right { margin-left: 0; }
  .dt-search { flex: 1 1 auto; }
}

.dt-foot-row td {
  font-weight: 700;
  border-top: 2px solid var(--rule);
  background: var(--surface-container-low);
}


.pp-rich p { margin: 0 0 6px; }
.pp-rich p:last-child { margin-bottom: 0; }
.pp-rich h1, .pp-rich h2 { margin: 8px 0 4px; font-weight: 700; }
.pp-rich h1 { font-size: 1.08em; }
.pp-rich h2 { font-size: 1.02em; }
.pp-rich ul, .pp-rich ol { margin: 4px 0 6px; padding-left: 20px; }
.pp-rich li { margin-bottom: 2px; }
.pp-rich a { color: #0070C0; text-decoration: underline; }
.pp-rich blockquote {
  margin: 4px 0 6px 12px;
  padding-left: 10px;
  border-left: 2px solid rgba(0,0,0,0.15);
  font-style: italic;
}


.rte {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface-bright);
  overflow: hidden;
}
.rte:focus-within {
  border-color: var(--consultant-blue);
  box-shadow: var(--focus-ring);
}
.rte-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  padding: 5px 6px;
  border-bottom: 1px solid var(--rule);
  background: var(--surface-container-low);
}
.rte-btn {
  min-width: 28px;
  height: 26px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  font-size: 12px;
  font-family: var(--font-body);
  color: var(--ink-secondary);
  cursor: pointer;
  line-height: 1;
}
.rte-btn:hover { background: var(--surface-container); color: var(--ink); }
.rte-btn.is-active {
  background: var(--primary-fixed);
  border-color: var(--consultant-blue);
  color: var(--consultant-blue);
}
.rte-sep {
  width: 1px;
  height: 16px;
  margin: 0 4px;
  background: var(--rule);
}
.rte-surface {
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
  overflow-y: auto;
  max-height: 420px;
}
.rte-surface:focus { outline: none; }
.rte-surface.is-empty::before {
  content: attr(data-placeholder);
  color: var(--ink-secondary);
  opacity: 0.7;
  pointer-events: none;
}
.rte-surface p { margin: 0 0 8px; }
.rte-surface p:last-child { margin-bottom: 0; }
.rte-surface h3, .rte-surface h4 { margin: 10px 0 5px; font-weight: 700; }
.rte-surface h3 { font-size: 15px; }
.rte-surface h4 { font-size: 13.5px; }
.rte-surface ul, .rte-surface ol { margin: 6px 0 8px; padding-left: 22px; }
.rte-surface li { margin-bottom: 3px; }
.rte-surface a { color: var(--consultant-blue); text-decoration: underline; }
.rte-surface blockquote {
  margin: 6px 0 8px 8px;
  padding-left: 10px;
  border-left: 2px solid var(--rule);
  font-style: italic;
  color: var(--ink-secondary);
}


.rte-host { display: flex; flex-direction: column; }
.rte-host .rte-toolbar {
  border: 1px solid var(--rule);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}

.rte-host .token-input--rich {
  border-radius: 0 0 var(--radius) var(--radius);
}
.token-input--rich {
  min-height: 140px;
  max-height: 420px;
  overflow-y: auto;
}
.token-input--rich p { margin: 0 0 8px; }
.token-input--rich p:last-child { margin-bottom: 0; }
.token-input--rich h3, .token-input--rich h4 { margin: 10px 0 5px; font-weight: 700; }
.token-input--rich h3 { font-size: 15px; }
.token-input--rich h4 { font-size: 13.5px; }
.token-input--rich ul, .token-input--rich ol { margin: 6px 0 8px; padding-left: 22px; }
.token-input--rich li { margin-bottom: 3px; }
.token-input--rich a { color: var(--consultant-blue); text-decoration: underline; }


a.sheet-note {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  color: var(--consultant-blue);
}
a.sheet-note:hover { text-decoration: underline; }


.earnings-headline { padding-top: var(--space-4); }


.is-current-row > td { background: var(--data-primary-wash); }


.is-quiet-row > td { color: var(--ink-secondary); }


.tbl-total-row > td {
  font-weight: 700;
  border-top: 2px solid var(--rule);
  background: var(--surface-container-low);
}
.row-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-secondary);
  vertical-align: 1px;
}
.is-muted-cell { color: var(--ink-secondary); }
.empty-note {
  margin: 0;
  padding: var(--space-6) 0;
  font-size: var(--t-base);
  color: var(--ink-secondary);
  max-width: 70ch;
}


.btn-link, .btn-link-danger {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
}


input[type="checkbox"], input[type="radio"] {
  width: 15px;
  height: 15px;
  accent-color: var(--consultant-blue);
  cursor: pointer;
}

.billing-taxable, .checkbox-row label, .rbac-assign-row, .rbac-perm {
  min-height: 24px;
}
.billing-taxable { padding: 2px 0; }


.builder-footer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gutter);
  flex-wrap: wrap;
  padding: var(--space-3) var(--gutter);
  background: var(--surface-bright);
  border-top: 1px solid var(--rule-strong);
  position: sticky;
  bottom: 0;
  z-index: 40;
}
.builder-figures {
  display: flex;
  align-items: stretch;
  gap: 0;
  flex-wrap: wrap;
  min-width: 0;
}
.bfig {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0 var(--space-5);
  border-left: 1px solid var(--rule);
  min-width: 0;
}
.bfig:first-child { padding-left: 0; border-left: 0; }
.bfig-label {
  font-size: var(--t-micro);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--ink-tertiary);
}
.bfig-value {
  font-size: var(--t-xl);
  font-weight: 620;
  line-height: 1.1;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.bfig-basis { font-size: var(--t-xs); color: var(--ink-secondary); }

.bfig--internal .bfig-value { color: var(--internal-text); }
.bfig--internal .bfig-label { color: var(--internal-text); opacity: 0.75; }

.builder-footer-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

@media (max-width: 900px) {
  .builder-figures { gap: var(--space-3); }
  .bfig { padding: 0; border-left: 0; }
  .bfig-value { font-size: var(--t-md); }
}


.line-items-table thead th {
  background: var(--surface-bright);
  border-bottom: 1px solid var(--rule-strong);
}
.line-items-table tbody td {
  padding: var(--space-2) var(--cell-x);
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
.line-items-table tr.product-type-row td {
  padding: var(--space-3) var(--cell-x) var(--space-1);
  background: none;
  border-bottom: 1px solid var(--rule-strong);
  font-size: var(--t-micro);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--ink-tertiary);
}
.line-items-table input.inline-input,
.line-items-table input.inline-num,
.line-items-table select.inline-select {
  border-color: transparent;
  background: transparent;
  transition: border-color var(--dur-fast) var(--ease-out),
              background-color var(--dur-fast) var(--ease-out);
}

.line-items-table input.inline-input:hover,
.line-items-table input.inline-num:hover,
.line-items-table select.inline-select:hover {
  border-color: var(--rule-strong);
  background: var(--surface-bright);
}
.line-items-table input.inline-input:focus,
.line-items-table input.inline-num:focus,
.line-items-table select.inline-select:focus {
  border-color: var(--consultant-blue);
  background: var(--surface-bright);
  box-shadow: var(--focus-ring);
}
.line-items-table .cost-cell {
  background: var(--internal-bg);
  box-shadow: inset 1px 0 0 var(--internal-border);
}
.line-items-table .profit-cell {
  background: var(--internal-bg);
  font-weight: 620;
  font-variant-numeric: tabular-nums;
}
.line-items-table .ext-price { font-size: var(--t-base); }


.charge-summary {
  margin-top: var(--space-5);
  padding: var(--space-4) 0 0;
  background: none;
  border: 0;
  border-top: 1px solid var(--rule-strong);
}
.charge-summary-title {
  font-size: var(--t-micro);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--ink-tertiary);
  margin-bottom: var(--space-2);
}
.charge-summary-table { width: 100%; max-width: 520px; margin-left: auto; }
.charge-summary-table td { padding: 4px 0; font-size: var(--t-base); }
.charge-summary-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.charge-summary-table tr.charge-summary-total td {
  border-top: 2px solid var(--rule-heavy);
  padding-top: var(--space-2);
  font-weight: 700;
  font-size: var(--t-md);
}
.charge-summary-note { max-width: 520px; margin-left: auto; text-align: right; }


.slab-head, .slab-row {
  display: grid;
  grid-template-columns: 1fr 1fr 110px 28px;
  gap: var(--space-2);
  align-items: end;
}
.slab-head {
  padding-bottom: 4px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--space-2);
}
.slab-head span {
  font-size: var(--t-micro);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--ink-tertiary);
}
.slab-row { padding: 3px 0; }

.slab-field { display: flex; flex-direction: column; min-width: 0; }
.slab-field > label { display: none; }
.slab-rate-wrap { position: relative; display: flex; align-items: center; }
.slab-rate-wrap input { padding-right: 22px; text-align: right; font-variant-numeric: tabular-nums; }
.slab-rate-suffix {
  position: absolute; right: 8px;
  font-size: var(--t-sm); color: var(--ink-tertiary); pointer-events: none;
}
.slab-remove { align-self: center; }

.slab-actions {
  display: flex; align-items: center; gap: var(--space-3);
  flex-wrap: wrap; margin-top: var(--space-3);
}
.slab-warning {
  font-size: var(--t-xs);
  color: var(--warning);
  display: inline-flex; align-items: center; gap: 5px;
}
.slab-warning::before { content: '⚠'; font-size: 12px; }

.slab-plain {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--rule);
}

.slab-plain:empty { display: none; }
.slab-plain-line { font-size: var(--t-sm); color: var(--ink); padding: 2px 0; }
.slab-plain-eg { color: var(--ink-secondary); }
.slab-plain-empty { font-size: var(--t-sm); color: var(--ink-tertiary); margin: 0; }

@media (max-width: 760px) {
  .slab-head { display: none; }
  .slab-row { grid-template-columns: 1fr 1fr; grid-template-areas: 'a b' 'c d'; }
  .slab-field > label {
    display: block;
    font-size: var(--t-micro);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
    color: var(--ink-tertiary);
    margin-bottom: 3px;
  }
}


.form-section + .form-section {
  padding-top: var(--space-5);
  margin-top: var(--space-5);
  border-top: 1px solid var(--rule);
}

.form-section-title {
  font-size: var(--t-md);
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
  line-height: 1.3;
  color: var(--ink);
}

.form-section-title + .form-row,
.form-section-title + .form-field,
.form-section-title + .checkbox-row,
.form-section-title + .rbac-assign-list,
.form-section-title + .figure { margin-top: var(--space-3); }
.form-section-note {
  margin: 4px 0 var(--space-4);
  font-size: var(--t-xs);
  line-height: 1.5;
  color: var(--ink-secondary);
  max-width: 62ch;
}
.form-section-note strong { color: var(--ink); font-weight: 600; }
.form-section > .form-row + .form-row { margin-top: var(--space-4); }
.form-section > .form-row + .form-field,
.form-section > .form-field + .form-row,
.form-section > .form-field + .form-field { margin-top: var(--space-4); }


.token-ref { padding-top: 0; }
.token-ref .block-tokens { margin-top: var(--space-3); }
.block-token {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  font-size: var(--t-xs);
  padding: 2px 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color 120ms ease-out;
}
.block-token:hover { border-color: var(--consultant-blue); }
.block-token:active { transform: scale(0.97); }
.block-token:focus-visible { outline: 2px solid var(--consultant-blue); outline-offset: 1px; }

.block-card {
  border-color: var(--rule-strong);
}
.block-card:focus-within { border-color: var(--consultant-blue); }
.blocks-list { gap: var(--space-3); }


input.is-locked, textarea.is-locked, select.is-locked {
  background: var(--surface-container-low);
  color: var(--ink-secondary);
  border-style: dashed;
  cursor: default;
}

.sheet-head-actions { display: flex; align-items: center; gap: var(--space-2); }

.builder-section-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--rule);
}

.builder-tax-field { max-width: 200px; margin-bottom: var(--space-4); }


.opp-quote-strip {
  background: var(--surface-container-low);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.opp-quote-strip.is-empty { border-style: dashed; background: none; }
.opp-strip-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.opp-strip-offer { justify-content: space-between; align-items: flex-start; }
.opp-strip-offer .form-hint { margin-top: 3px; max-width: 60ch; }


.figure-rank--compact {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  padding: var(--space-4) 0;
  margin-bottom: var(--space-4);
}
.figure-rank--compact .figure-value { line-height: 1.1; }


.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: var(--space-2);
  font-size: var(--t-xs);
  color: var(--ink-tertiary);
}

.crumbs a {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  color: var(--consultant-blue);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: color-mix(in srgb, var(--consultant-blue) 45%, transparent);
}
.crumbs a:hover {
  text-decoration-thickness: 2px;
  text-decoration-color: currentColor;
}


.figure-basis.is-overdue { color: var(--data-negative); font-weight: 600; }


.chart-host {
  position: relative;
  width: 100%;
  min-height: 260px;
}

.chart-svg { display: block; overflow: visible; }

.chart-tick,
.chart-value-label,
.chart-series-label {
  font-family: var(--font-body);
  font-variant-numeric: tabular-nums;
}
.chart-tick { font-size: 10px; }
.chart-value-label { font-size: 10px; font-weight: 600; }
.chart-series-label { font-size: 10px; font-weight: 600; letter-spacing: 0.02em; }
.chart-series-label--strong { font-weight: 700; }

.chart-empty {
  padding: var(--space-10) 0;
  text-align: center;
  font-size: var(--t-sm);
  color: var(--ink-tertiary);
}


.chart-band {
  fill: transparent;
  cursor: pointer;
}

.chart-band-wash {
  fill: var(--data-primary-wash);
  fill-opacity: 0;
  transition: fill-opacity var(--dur-fast, 120ms) var(--ease-out, ease-out);
}
.chart-band-wash.is-active { fill-opacity: 0.55; }
.chart-band:focus { outline: none; }
.chart-band:focus-visible {
  outline: 2px solid var(--consultant-blue);
  outline-offset: 1px;
}
.chart-col { transition: opacity var(--dur-fast, 120ms) var(--ease-out, ease-out); }


.chart-readout {
  position: absolute;
  top: 4px;
  z-index: 5;
  max-width: 240px;
  padding: var(--space-2) var(--space-3);
  background: var(--surface-bright);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  font-size: var(--t-xs);
  color: var(--ink);
  pointer-events: none;
}
.chart-readout[hidden] { display: none; }
.chart-readout-head {
  font-weight: 700;
  margin-bottom: 2px;
  padding-bottom: 3px;
  border-bottom: 1px solid var(--rule);
}
.chart-readout dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1px var(--space-3);
  margin: 0;
}
.chart-readout dt { color: var(--ink-secondary); }
.chart-readout dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.chart-readout .is-quiet {
  color: var(--ink-tertiary);
  font-size: var(--t-micro);
  font-weight: 400;
}


.chart-readout--line {
  position: static;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 var(--space-2);
  max-width: none;
  min-height: 21px;
  margin-bottom: var(--space-2);
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;
  font-size: var(--t-xs);
  color: var(--ink-secondary);
}
.chart-readout--line b {
  font-weight: 640;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.chart-readout--line .chart-readout-head {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
  color: var(--ink);
}
.chart-readout-sep { color: var(--rule-strong); }


.chart-key {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  margin-top: var(--space-2);
  font-size: var(--t-micro);
  color: var(--ink-secondary);
}
.chart-key-item { display: inline-flex; align-items: center; gap: 6px; }
.chart-key-swatch {
  width: 10px;
  height: 10px;
  flex: none;
  background: var(--key-color, var(--data-primary));
  border-radius: 1px;
}
.chart-key-swatch--hatched {
  background:
    repeating-linear-gradient(45deg,
      var(--key-color, var(--data-primary-soft)) 0 1.5px,
      transparent 1.5px 6px),
    color-mix(in srgb, var(--key-color, var(--data-primary-soft)) 18%, transparent);
  border: 1px dashed var(--key-color, var(--data-primary-soft));
}
.chart-key-swatch--rule {
  height: 0;
  border-radius: 0;
  background: none;
  border-top: 2px dashed var(--key-color, var(--data-reference));
}

.chart-key-note {
  margin-top: 3px;
  font-size: var(--t-micro);
  color: var(--ink-tertiary);
}

@media (max-width: 620px) {
  .chart-host { min-height: 300px; }
  .chart-readout { max-width: 190px; }
}

@media (prefers-reduced-motion: reduce) {
  .chart-band-wash,
  .chart-col { transition: none; }
}


.session-warning {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
  background: var(--scrim);
  padding: var(--space-4);
}
.session-warning-panel {
  background: var(--surface-bright);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-4);
  padding: var(--space-6);
  max-width: 460px;
  width: 100%;
}
.session-warning-panel h2 {
  margin: 0 0 var(--space-2);
  font-size: var(--t-lg);
  font-weight: 650;
  color: var(--ink);
}
.session-warning-body {
  margin: 0 0 var(--space-5);
  color: var(--ink-secondary);
  line-height: 1.5;
}

#session-warning-count {
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.session-warning-actions {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
}
@media (prefers-reduced-motion: no-preference) {
  .session-warning-panel {
    animation: session-warning-in 160ms var(--ease-out) both;
  }
}
@keyframes session-warning-in {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}


.session-list { display: flex; flex-direction: column; }
.session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--rule);
}
.session-row:last-child { border-bottom: none; }
.session-row-main { min-width: 0; }

.session-row--current .session-row-main { font-weight: 500; }


.changelog-group-label {
  font-size: var(--t-micro);
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-tertiary);
  margin: var(--space-3) 0 var(--space-1);
}
.changelog-entry-items + .changelog-group-label { margin-top: var(--space-4); }

/* A link that cannot act yet. An anchor has no disabled attribute, so the
   pointer and the keyboard have to be stopped explicitly; aria-disabled
   carries it to a screen reader. */
a.btn.is-disabled {
  opacity: 0.5;
  pointer-events: none;
  cursor: default;
}
