/* ─────────────────────────────────────────────────────────────────
   Tokens — Meridian house style (mirrors Family Office Books.html)
   ───────────────────────────────────────────────────────────────── */
:root {
  --bg: #F4F1EA;
  --surface: #FFFFFF;
  --surface-2: #FAF7F0;
  --hairline: #E8E2D6;
  --hairline-strong: #D9D2C2;
  --ink-100: #14110D;
  --ink-80: #3B3631;
  --ink-60: #6E6862;
  --ink-40: #9E978C;
  --ink-20: #C9C3B7;
  --ink-10: #E3DDD0;
  --accent: #C8501C;
  --accent-strong: #A23E14;
  --accent-soft: #FBEDE0;
  --pos: #1F7A4D;
  --pos-soft: #E2EFE7;
  --neg: #B6322B;
  --neg-soft: #F6E3DF;
  --warn: #B5872A;
  --warn-soft: #F4ECD5;
  --info: #2C5F8B;
  --info-soft: #E0EAF2;
  --sans: "Geist", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--ink-100);
  font-family: var(--sans); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-width: 1180px;
}
button { font: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
.num  { font-variant-numeric: tabular-nums; font-feature-settings: "tnum", "ss01"; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ─────────────────────────────────────────────────────────────────
   Shared chrome — sidebar, topbar, integrity footer
   (kept in sync with Family Office Books.html / Hub.html)
   ───────────────────────────────────────────────────────────────── */
.fo-shell { display: flex; flex-direction: column; min-height: 100vh; }
.fo-app   { display: flex; flex: 1; min-height: 0; }

.fo-sidebar {
  width: 224px; flex: 0 0 224px;
  background: var(--bg); border-right: 1px solid var(--hairline);
  display: flex; flex-direction: column;
  min-height: calc(100vh - 30px);
}
.fo-brand { padding: 20px 18px 16px; display: flex; align-items: center; gap: 10px; }
.fo-brand__mark { flex: 0 0 22px; height: 22px; display: block; }
.fo-brand__name { font-size: 14.5px; font-weight: 500; letter-spacing: -0.3px; line-height: 1; }
.fo-brand__sub  { font-size: 9.5px; color: var(--ink-40); margin-top: 3px; text-transform: uppercase; letter-spacing: 1px; font-weight: 500; }

.fo-nav { padding: 0 12px; flex: 1; overflow: auto; }
.fo-nav__group-label {
  font-size: 9.5px; color: var(--ink-40);
  text-transform: uppercase; letter-spacing: 1.2px;
  padding: 6px 10px 4px; font-weight: 500; margin-top: 12px;
}
.fo-nav__group-label:first-child { margin-top: 0; }
.fo-nav__item {
  display: flex; align-items: center; gap: 10px;
  padding: 6.5px 10px;
  font-size: 13px; color: var(--ink-80);
  background: transparent;
  border: 1px solid transparent; border-radius: 3px;
  margin-bottom: 1px; cursor: pointer; text-decoration: none;
}
.fo-nav__item:hover { background: var(--surface-2); }
.fo-nav__item.is-active {
  font-weight: 500; color: var(--ink-100);
  background: var(--surface); border-color: var(--hairline);
}
.fo-nav__icon  { width: 14px; height: 14px; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-60); flex: 0 0 14px; }
.fo-nav__item.is-active .fo-nav__icon { color: var(--ink-100); }
.fo-nav__label { flex: 1; }
.fo-nav__badge { font-family: var(--mono); font-size: 10px; color: var(--ink-40); font-variant-numeric: tabular-nums; }
.fo-nav__item.is-active .fo-nav__badge { color: var(--ink-60); }

.fo-side-foot { padding: 12px; border-top: 1px solid var(--hairline); }
.fo-user { padding: 8px 10px 2px; display: flex; align-items: center; gap: 8px; }
.fo-user__avatar { width: 22px; height: 22px; background: var(--ink-100); color: #FFF; border-radius: 50%; font-size: 10.5px; font-weight: 500; display: flex; align-items: center; justify-content: center; }
.fo-user__name { font-size: 12px; font-weight: 500; }
.fo-user__role { font-size: 10px; color: var(--ink-60); }

.fo-main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }

.fo-topbar {
  height: 56px;
  border-bottom: 1px solid var(--hairline);
  background: var(--bg);
  display: flex; align-items: stretch;
  padding: 0 18px 0 24px;
  flex-shrink: 0;
  position: relative; /* anchor for entity-picker */
}
.fo-topbar__spoke {
  display: flex; flex-direction: column; justify-content: center;
  padding-right: 18px; border-right: 1px solid var(--hairline); margin-right: 18px;
}
.fo-topbar__spoke-eyebrow { font-size: 9.5px; color: var(--ink-40); text-transform: uppercase; letter-spacing: 1.2px; font-weight: 500; line-height: 1; }
.fo-topbar__spoke-name    { font-size: 14px; font-weight: 500; margin-top: 4px; line-height: 1; }

/* Entity pill area within topbar */
.fo-topbar__entity {
  display: flex; align-items: center;
  padding-right: 18px; border-right: 1px solid var(--hairline); margin-right: 18px;
}

/* Tab strip */
.fo-tabstrip { display: flex; align-items: stretch; }
.fo-tab {
  padding: 0 16px; height: 100%;
  display: flex; align-items: center;
  font-size: 13px; color: var(--ink-60);
  border: none; border-bottom: 2px solid transparent;
  background: transparent;
  margin-bottom: -1px; cursor: pointer;
  font-family: inherit;
}
.fo-tab:hover { color: var(--ink-80); }
.fo-tab.is-active { font-weight: 500; color: var(--ink-100); border-bottom-color: var(--ink-100); }
.fo-tab__count { margin-left: 6px; font-family: var(--mono); font-size: 10px; color: var(--ink-40); }
.fo-tab.is-active .fo-tab__count { color: var(--ink-60); }

.fo-topbar__spacer  { flex: 1; }
.fo-topbar__controls { display: flex; align-items: center; gap: 10px; }

.fo-search {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface); border: 1px solid var(--hairline);
  padding: 5px 10px; border-radius: 3px;
  width: 220px;
}
.fo-search__icon  { color: var(--ink-60); display: inline-flex; }
.fo-search__input {
  border: none; outline: none; background: transparent;
  font: inherit; font-size: 12px; color: var(--ink-100);
  width: 100%;
}
.fo-search__hot {
  font-family: var(--mono); font-size: 9.5px; color: var(--ink-40);
  padding: 1px 5px; border: 1px solid var(--hairline); border-radius: 2px;
  flex-shrink: 0;
}

.fo-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--hairline);
  padding: 4px 10px; border-radius: 3px;
  font-size: 11.5px; color: var(--ink-80);
}
.fo-toggle__switch {
  width: 22px; height: 12px; border-radius: 6px;
  background: var(--ink-20); position: relative; transition: background .12s ease;
  flex-shrink: 0;
}
.fo-toggle__switch::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 8px; height: 8px; background: #FFF; border-radius: 50%;
  transition: left .12s ease;
}
.fo-toggle.is-on .fo-toggle__switch { background: var(--ink-100); }
.fo-toggle.is-on .fo-toggle__switch::after { left: 12px; }

.fo-readonly {
  font-family: var(--mono); font-size: 9.5px; color: var(--ink-60);
  text-transform: uppercase; letter-spacing: 1px;
  padding: 3px 8px; border: 1px solid var(--hairline); border-radius: 2px;
}

.fo-body { flex: 1; padding: 22px; min-width: 0; }

.fo-integrity {
  height: 30px;
  border-top: 1px solid var(--hairline);
  background: var(--surface-2);
  display: flex; align-items: center;
  padding: 0 18px 0 24px; gap: 22px;
  font-size: 10.5px; color: var(--ink-60);
  flex-shrink: 0;
}
.fo-integrity__item  { display: flex; align-items: center; gap: 6px; }
.fo-integrity__label { color: var(--ink-40); text-transform: uppercase; letter-spacing: 0.8px; font-weight: 500; font-size: 9.5px; }
.fo-integrity__value { color: var(--ink-80); }
.fo-integrity__spacer { flex: 1; }
.fo-integrity__env    { color: var(--ink-40); font-size: 10px; }

/* ─────────────────────────────────────────────────────────────────
   Shared component — Entity Pill + Picker
   This is the contextual entity selector that lives in the topbar of
   any per-entity view (Books, Chart of accounts, Property registers).
   Selection persists in localStorage so it carries between views.
   ───────────────────────────────────────────────────────────────── */
.entity-pill {
  display: inline-flex; align-items: center; gap: 9px;
  background: var(--surface); border: 1px solid var(--hairline-strong);
  padding: 4px 8px 4px 6px; border-radius: 3px;
  cursor: pointer; font-family: inherit;
  min-width: 220px; max-width: 320px;
  transition: border-color .12s ease, background .12s ease;
}
.entity-pill:hover {
  background: var(--surface-2);
  border-color: var(--ink-40);
}
.entity-pill.is-open {
  background: var(--surface-2);
  border-color: var(--ink-100);
}
.entity-pill.is-disabled {
  cursor: default; opacity: 0.55;
}
.entity-pill.is-disabled:hover { background: var(--surface); border-color: var(--hairline-strong); }
.entity-pill__avatar {
  width: 26px; height: 26px;
  background: var(--ink-100); color: #FFF;
  font-size: 10px; font-weight: 600;
  font-family: var(--mono); letter-spacing: 0.4px;
  border-radius: 3px; flex: 0 0 26px;
  display: flex; align-items: center; justify-content: center;
}
.entity-pill__main {
  display: flex; flex-direction: column;
  min-width: 0; flex: 1; align-items: flex-start;
}
.entity-pill__name { font-size: 12.5px; font-weight: 500; line-height: 1.2; color: var(--ink-100); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.entity-pill__meta { font-size: 10px; color: var(--ink-60); margin-top: 1px; display: inline-flex; align-items: center; gap: 6px; }
.entity-pill__meta-sep { color: var(--ink-20); }
.entity-pill__chev { color: var(--ink-40); flex-shrink: 0; display: inline-flex; }

/* The picker dropdown — anchored under the pill */
.entity-picker {
  position: absolute;
  top: 56px; /* sits just below topbar */
  left: 0;
  width: 460px;
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-top: none;
  box-shadow: 0 18px 40px rgba(20, 17, 13, 0.10), 0 2px 6px rgba(20, 17, 13, 0.06);
  z-index: 30;
  display: flex; flex-direction: column;
  max-height: 540px;
}
.entity-picker__head {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--hairline);
  display: flex; align-items: center; gap: 10px;
}
.entity-picker__search {
  flex: 1;
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface-2); border: 1px solid var(--hairline);
  padding: 6px 10px; border-radius: 3px;
}
.entity-picker__search input {
  border: none; outline: none; background: transparent;
  font: inherit; font-size: 12px; color: var(--ink-100); width: 100%;
}
.entity-picker__count {
  font-family: var(--mono); font-size: 10px; color: var(--ink-60);
  white-space: nowrap;
}
.entity-picker__list { flex: 1; overflow-y: auto; padding: 4px 0 10px; }
.entity-picker__group {
  padding: 12px 14px 4px;
  font-size: 9.5px; color: var(--ink-40);
  text-transform: uppercase; letter-spacing: 1.2px; font-weight: 500;
  display: flex; align-items: baseline; justify-content: space-between;
}
.entity-picker__group-count { font-family: var(--mono); font-size: 9.5px; color: var(--ink-20); letter-spacing: 0; }
.entity-picker__row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  border-left: 2px solid transparent;
}
.entity-picker__row:hover { background: var(--surface-2); }
.entity-picker__row.is-selected {
  background: var(--accent-soft);
  border-left-color: var(--accent);
}
.entity-picker__row-avatar {
  width: 24px; height: 24px;
  background: var(--ink-100); color: #FFF;
  font-size: 9.5px; font-weight: 600;
  font-family: var(--mono); letter-spacing: 0.4px;
  border-radius: 3px; flex: 0 0 24px;
  display: flex; align-items: center; justify-content: center;
}
.entity-picker__row-main { flex: 1; min-width: 0; }
.entity-picker__row-name { font-size: 12.5px; font-weight: 500; color: var(--ink-100); line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entity-picker__row-meta { font-size: 10px; color: var(--ink-60); margin-top: 2px; display: flex; align-items: center; gap: 6px; }
.entity-picker__row-chip {
  font-size: 9px; padding: 1px 5px;
  border: 1px solid var(--hairline-strong); border-radius: 2px;
  text-transform: uppercase; letter-spacing: 0.5px; font-weight: 500;
  color: var(--ink-60);
}
.entity-picker__row-counts {
  text-align: right; font-size: 10.5px; color: var(--ink-60);
  font-family: var(--mono); flex-shrink: 0;
}
.entity-picker__row-counts strong { color: var(--ink-100); font-weight: 600; }

.entity-picker__foot {
  padding: 10px 14px;
  border-top: 1px solid var(--hairline);
  background: var(--surface-2);
  font-size: 10.5px; color: var(--ink-60); line-height: 1.5;
  display: flex; align-items: center; justify-content: space-between;
}
.entity-picker__foot-hint { color: var(--ink-60); }
.entity-picker__foot-hint strong { color: var(--ink-80); font-weight: 500; }

.entity-picker__empty {
  padding: 28px 14px; text-align: center;
  font-size: 11.5px; color: var(--ink-60);
}

/* backdrop that catches outside-clicks while the picker is open */
.entity-picker-backdrop {
  position: fixed; inset: 0; z-index: 25;
  background: transparent;
}

/* ─────────────────────────────────────────────────────────────────
   View · By entity — single continuous CoA with sticky group rows
   ───────────────────────────────────────────────────────────────── */
.coa-stack { display: flex; flex-direction: column; gap: 14px; max-width: 1280px; }

/* Compact entity context strip (sits above the CoA table) */
.ctx-strip {
  background: var(--surface); border: 1px solid var(--hairline);
  padding: 14px 18px;
  display: flex; align-items: center; gap: 16px;
}
.ctx-strip__avatar {
  width: 38px; height: 38px;
  background: var(--ink-100); color: #FFF;
  font-size: 14px; font-weight: 600;
  font-family: var(--mono); letter-spacing: 0.5px;
  border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ctx-strip__main { flex: 1; min-width: 0; }
.ctx-strip__title { display: flex; align-items: baseline; gap: 12px; }
.ctx-strip__name  { font-size: 19px; font-weight: 500; letter-spacing: -0.4px; }
.ctx-strip__juris { font-size: 11.5px; color: var(--ink-60); font-family: var(--mono); }
.ctx-strip__chips { display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.ctx-strip__chip {
  font-size: 9.5px; color: var(--ink-80);
  background: var(--bg);
  border: 1px solid var(--hairline-strong);
  padding: 2px 7px; border-radius: 2px;
  text-transform: uppercase; letter-spacing: 0.6px; font-weight: 500;
}
.ctx-strip__chip--info  { background: var(--info-soft); color: var(--info);  border-color: var(--info); }
.ctx-strip__chip--accent{ background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.ctx-strip__counts { text-align: right; }
.ctx-strip__count-big { font-size: 22px; font-weight: 600; letter-spacing: -0.4px; line-height: 1; font-variant-numeric: tabular-nums; }
.ctx-strip__count-sub { font-size: 10.5px; color: var(--ink-60); margin-top: 4px; }
.ctx-strip__count-sub strong { color: var(--ink-100); font-weight: 500; }

/* Main CoA table — single continuous, sticky group rows */
.coa-panel {
  background: var(--surface); border: 1px solid var(--hairline);
  display: flex; flex-direction: column;
}
.coa-panel__head {
  padding: 14px 22px; border-bottom: 1px solid var(--hairline);
  display: flex; align-items: baseline; justify-content: space-between;
}
.coa-panel__title { font-size: 13px; font-weight: 500; }
.coa-panel__sub   { font-size: 10.5px; color: var(--ink-60); margin-top: 2px; }
.coa-panel__legend {
  font-size: 10.5px; color: var(--ink-60);
  display: inline-flex; align-items: center; gap: 14px;
}
.coa-panel__legend-item { display: inline-flex; align-items: center; gap: 5px; }
.coa-panel__legend-swatch { width: 8px; height: 8px; border-radius: 1px; background: var(--ink-100); }
.coa-panel__legend-swatch.t-asset    { background: var(--ink-100); }
.coa-panel__legend-swatch.t-liability{ background: var(--ink-80); }
.coa-panel__legend-swatch.t-equity   { background: var(--ink-60); }
.coa-panel__legend-swatch.t-income   { background: var(--accent); }
.coa-panel__legend-swatch.t-expense  { background: var(--warn); }

.coa-table {
  display: grid;
  /* type | code | account-block | chip area | balance | */
  grid-template-columns: 6px 64px 1fr auto 140px;
  align-items: stretch;
}

/* Column header row (only once, at top) */
.coa-col-head {
  display: contents;
}
.coa-col-head > div {
  background: var(--surface-2);
  padding: 9px 0;
  font-size: 9.5px; color: var(--ink-40);
  text-transform: uppercase; letter-spacing: 1px; font-weight: 500;
  border-bottom: 1px solid var(--hairline);
}
.coa-col-head__type   { padding-left: 6px !important; }
.coa-col-head__code   { padding-left: 4px !important; }
.coa-col-head__name   { padding-left: 6px !important; }
.coa-col-head__chip   { padding-right: 14px !important; text-align: right; }
.coa-col-head__amt    { padding-right: 22px !important; text-align: right; }

/* Group divider row */
.coa-group {
  display: contents;
}
.coa-group > div {
  padding: 16px 0 7px;
  background: var(--surface);
  position: sticky; top: 0; z-index: 1;
  border-bottom: 1px solid var(--hairline-strong);
  border-top: 1px solid var(--hairline);
}
.coa-group__type   { padding-left: 0 !important; }
.coa-group__label  {
  padding-left: 6px !important;
  font-size: 10px; font-weight: 500; color: var(--ink-100);
  letter-spacing: 1.2px; text-transform: uppercase;
}
.coa-group__name   { padding-left: 6px !important; font-size: 11px; color: var(--ink-60); }
.coa-group__count  { padding-right: 14px !important; text-align: right; font-family: var(--mono); font-size: 11px; color: var(--ink-40); }
.coa-group__total  { padding-right: 22px !important; text-align: right; font-size: 12.5px; color: var(--ink-60); font-variant-numeric: tabular-nums; }

/* Account row */
.coa-row {
  display: contents;
}
.coa-row > div {
  padding: 11px 0;
  border-top: 1px solid var(--hairline);
  display: flex; align-items: center;
}
.coa-row:hover > div { background: var(--surface-2); }
.coa-row__type { padding: 0 !important; position: relative; }
.coa-row__type::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 2px; background: var(--ink-60);
}
.coa-row[data-type="asset"]     .coa-row__type::before { background: var(--ink-100); }
.coa-row[data-type="liability"] .coa-row__type::before { background: var(--ink-80); }
.coa-row[data-type="equity"]    .coa-row__type::before { background: var(--ink-60); }
.coa-row[data-type="income"]    .coa-row__type::before { background: var(--accent); }
.coa-row[data-type="expense"]   .coa-row__type::before { background: var(--warn); }

.coa-row__code {
  padding-left: 4px !important;
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-60);
}
.coa-row > .coa-row__name {
  padding-left: 6px !important;
  display: flex; flex-direction: column; align-items: flex-start;
  justify-content: center;
}
.coa-row__name-text { font-size: 13.5px; color: var(--ink-100); }
.coa-row__name-sub  { font-size: 10.5px; color: var(--ink-60); margin-top: 1px; display: inline-flex; align-items: center; gap: 6px; }
.coa-row__name-mono { font-family: var(--mono); color: var(--ink-40); }
.coa-row__chip {
  padding-right: 14px !important;
  justify-content: flex-end;
}
.coa-row__chip-inner {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 9.5px; padding: 2px 7px;
  text-transform: uppercase; letter-spacing: 0.6px; font-weight: 500;
  border-radius: 2px;
  background: var(--bg); color: var(--ink-60);
  border: 1px solid var(--hairline-strong);
}
.coa-row__chip-inner.is-bank      { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent); }
.coa-row__chip-inner.is-cash      { background: var(--info-soft);   color: var(--info);   border-color: var(--info); }
.coa-row__chip-inner.is-control   { background: var(--warn-soft);   color: var(--warn);   border-color: var(--warn); }
.coa-row__chip-inner.is-system    { background: var(--surface-2);   color: var(--ink-60); border-color: var(--hairline); }
.coa-row__amount {
  padding-right: 22px !important;
  justify-content: flex-end;
  font-size: 14px; font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ink-100);
}
.coa-row__amount.is-zero { color: var(--ink-20); font-weight: 400; }
.coa-row__amount.is-neg  { color: var(--neg); }

/* Closed (inactive) rows render muted */
.coa-row.is-closed > div { opacity: 0.45; }
.coa-row.is-closed .coa-row__chip-inner { background: var(--surface-2); color: var(--ink-40); border-style: dashed; }

/* Footer beneath the CoA table */
.coa-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 22px;
  border-top: 1px solid var(--hairline);
  background: var(--surface-2);
  font-size: 10.5px; color: var(--ink-60);
}
.coa-foot__group { display: inline-flex; align-items: center; gap: 18px; }
.coa-foot__item  { display: inline-flex; align-items: center; gap: 6px; }
.coa-foot__label { color: var(--ink-40); text-transform: uppercase; letter-spacing: 0.8px; font-weight: 500; font-size: 9.5px; }
.coa-foot__link  { color: var(--ink-80); font-weight: 500; display: inline-flex; align-items: center; gap: 5px; }

/* ─────────────────────────────────────────────────────────────────
   View · By account — comparison across entities (chart drift)
   ───────────────────────────────────────────────────────────────── */
.cmp-stack { display: flex; flex-direction: column; gap: 14px; max-width: 1280px; }

.cmp-intro {
  background: var(--surface); border: 1px solid var(--hairline);
  padding: 14px 18px;
  display: flex; align-items: center; gap: 14px;
}
.cmp-intro__icon {
  width: 32px; height: 32px;
  border: 1px solid var(--hairline-strong);
  background: var(--surface-2);
  border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: var(--ink-80);
}
.cmp-intro__copy { flex: 1; font-size: 12px; color: var(--ink-80); line-height: 1.5; }
.cmp-intro__copy strong { color: var(--ink-100); font-weight: 500; }
.cmp-intro__copy small { color: var(--ink-60); }

.cmp-picker {
  background: var(--surface); border: 1px solid var(--hairline);
  padding: 14px 18px;
}
.cmp-picker__label {
  font-size: 9.5px; color: var(--ink-40);
  text-transform: uppercase; letter-spacing: 1.2px; font-weight: 500;
  margin-bottom: 10px;
}
.cmp-picker__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cmp-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: var(--bg); border: 1px solid var(--hairline-strong);
  font-size: 12px; color: var(--ink-80);
  border-radius: 3px; cursor: pointer; font-family: inherit;
  font-weight: 400;
}
.cmp-chip:hover { background: var(--surface-2); border-color: var(--ink-40); }
.cmp-chip.is-active {
  background: var(--ink-100); color: #FFF; border-color: var(--ink-100); font-weight: 500;
}
.cmp-chip__count {
  font-family: var(--mono); font-size: 10px;
  color: var(--ink-40); padding-left: 2px;
}
.cmp-chip.is-active .cmp-chip__count { color: rgba(255,255,255,0.55); }
.cmp-chip.has-drift::after {
  content: ''; width: 6px; height: 6px; background: var(--warn); border-radius: 50%; display: inline-block;
}

/* The comparison table */
.cmp-panel {
  background: var(--surface); border: 1px solid var(--hairline);
}
.cmp-panel__head {
  padding: 14px 22px; border-bottom: 1px solid var(--hairline);
  display: flex; align-items: baseline; justify-content: space-between;
}
.cmp-panel__title { font-size: 13px; font-weight: 500; }
.cmp-panel__sub   { font-size: 10.5px; color: var(--ink-60); margin-top: 2px; }
.cmp-panel__sub strong { color: var(--ink-100); font-weight: 500; }
.cmp-panel__verdict {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11px; padding: 3px 10px;
  border-radius: 2px;
}
.cmp-panel__verdict.is-consistent { background: var(--pos-soft); color: var(--pos); }
.cmp-panel__verdict.is-drift       { background: var(--warn-soft); color: var(--warn); }
.cmp-panel__verdict.is-missing     { background: var(--neg-soft); color: var(--neg); }

.cmp-table {
  display: grid;
  grid-template-columns: 240px 64px 1fr 140px 140px;
  align-items: stretch;
}
.cmp-table__col-head { display: contents; }
.cmp-table__col-head > div {
  background: var(--surface-2);
  padding: 9px 14px;
  font-size: 9.5px; color: var(--ink-40);
  text-transform: uppercase; letter-spacing: 1px; font-weight: 500;
  border-bottom: 1px solid var(--hairline);
}
.cmp-table__col-head > div.is-right { text-align: right; }

.cmp-row { display: contents; }
.cmp-row > div {
  padding: 11px 14px;
  border-top: 1px solid var(--hairline);
  display: flex; align-items: center;
}
.cmp-row:hover > div { background: var(--surface-2); }

.cmp-row__entity { gap: 10px; }
.cmp-row__entity-avatar {
  width: 22px; height: 22px;
  background: var(--ink-100); color: #FFF;
  font-size: 9.5px; font-weight: 600;
  font-family: var(--mono); letter-spacing: 0.4px;
  border-radius: 3px; flex: 0 0 22px;
  display: flex; align-items: center; justify-content: center;
}
.cmp-row__entity-block { display: flex; flex-direction: column; min-width: 0; }
.cmp-row__entity-name { font-size: 12.5px; color: var(--ink-100); font-weight: 500; line-height: 1.25; }
.cmp-row__entity-meta { font-size: 10px; color: var(--ink-60); margin-top: 1px; font-family: var(--mono); }
.cmp-row__code   { font-family: var(--mono); font-size: 12px; color: var(--ink-60); }
.cmp-row > .cmp-row__name   { font-size: 13px; color: var(--ink-100); display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; }
.cmp-row__name-sub { font-size: 10.5px; color: var(--ink-60); }
.cmp-row__chip   { justify-content: flex-start; }
.cmp-row__amount {
  justify-content: flex-end; text-align: right;
  font-size: 13px; font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.cmp-row__amount.is-zero { color: var(--ink-20); font-weight: 400; }

.cmp-row.is-missing > div { background: var(--surface-2); }
.cmp-row.is-missing .cmp-row__code,
.cmp-row.is-missing .cmp-row__name,
.cmp-row.is-missing .cmp-row__amount { color: var(--ink-40); font-style: italic; }
.cmp-row.is-missing .cmp-row__name-sub { color: var(--ink-40); }
.cmp-row.is-missing:hover > div { background: var(--surface-2); }

.cmp-row.has-drift .cmp-row__code { color: var(--warn); font-weight: 600; }
.cmp-flag {
  font-size: 9.5px; color: var(--warn);
  padding: 1px 6px;
  background: var(--warn-soft); border: 1px solid var(--warn);
  border-radius: 2px;
  text-transform: uppercase; letter-spacing: 0.6px; font-weight: 500;
  margin-left: 8px;
}

/* ─────────────────────────────────────────────────────────────────
   Helpers
   ───────────────────────────────────────────────────────────────── */
.kbd {
  font-family: var(--mono); font-size: 10px;
  padding: 1px 5px; border: 1px solid var(--hairline);
  border-radius: 2px; color: var(--ink-60); background: var(--surface);
}

/* ── Entity tree (sidebar) — unified shell ──────────────────────────────────── */
.fo-nav__caret { color: var(--ink-40); display: inline-flex; transition: transform .12s ease; }
.fo-nav__item.is-open .fo-nav__caret, .fo-nav__item.is-active .fo-nav__caret { transform: rotate(90deg); color: var(--ink-100); }
.fo-nav__sublist { padding: 4px 0 6px 18px; margin: 0 0 4px 16px; border-left: 1px solid var(--hairline); }
.fo-nav__subitem { display: flex; align-items: center; gap: 8px; padding: 4px 8px; font-size: 11.5px; color: var(--ink-60); border-left: 2px solid transparent; margin-left: -1px; border-radius: 0 3px 3px 0; cursor: pointer; }
.fo-nav__subitem:hover { background: var(--surface-2); color: var(--ink-100); }
.fo-nav__subitem.is-active { color: var(--ink-100); border-left-color: var(--accent); font-weight: 500; background: var(--accent-soft); }
.fo-nav__subitem-dot { width: 6px; height: 6px; background: var(--ink-20); border-radius: 50%; flex-shrink: 0; }
.fo-nav__subitem.is-active .fo-nav__subitem-dot { background: var(--accent); }
.fo-nav__subitem-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fo-nav__subitem-meta { font-family: var(--mono); font-size: 9.5px; color: var(--ink-40); }

/* ── Per-entity sub-nav (tabs inside the entity view) ───────────────────────── */
.fo-subnav { height: 44px; background: var(--surface-2); border-bottom: 1px solid var(--hairline); display: flex; align-items: stretch; padding: 0 18px 0 24px; flex-shrink: 0; overflow-x: auto; scrollbar-width: thin; }
.fo-subnav__strip { display: flex; align-items: stretch; gap: 0; flex: 1; min-width: 0; }
.fo-subnav__tab { padding: 0 13px; height: 100%; display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-60); border: none; border-bottom: 2px solid transparent; background: transparent; margin-bottom: -1px; cursor: pointer; font-family: inherit; white-space: nowrap; }
.fo-subnav__tab:hover { color: var(--ink-80); }
.fo-subnav__tab.is-active { font-weight: 500; color: var(--ink-100); border-bottom-color: var(--ink-100); }
.fo-subnav__tab-icon { width: 12px; height: 12px; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-40); flex-shrink: 0; }
.fo-subnav__tab.is-active .fo-subnav__tab-icon { color: var(--ink-100); }
.fo-subnav__tab-badge { font-family: var(--mono); font-size: 9.5px; color: var(--ink-40); padding: 1px 5px; border: 1px solid var(--hairline); border-radius: 2px; margin-left: 2px; }
.fo-subnav__tab.is-active .fo-subnav__tab-badge { color: var(--ink-100); border-color: var(--hairline-strong); }
.fo-subnav__sep { align-self: center; height: 18px; width: 1px; background: var(--hairline-strong); margin: 0 8px; flex-shrink: 0; }
.fo-subnav__group-label { align-self: center; font-size: 9px; color: var(--ink-40); text-transform: uppercase; letter-spacing: 1.2px; font-weight: 500; padding: 0 8px 0 4px; flex-shrink: 0; }

/* ── In-tab CoA view toggle + placeholder panels ────────────────────────────── */
.coa-viewbar { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.coa-viewtoggle { display: inline-flex; background: var(--surface-2); border: 1px solid var(--hairline); border-radius: 4px; padding: 2px; }
.coa-viewtoggle__btn { padding: 5px 12px; font-size: 12px; color: var(--ink-60); background: transparent; border: none; border-radius: 3px; cursor: pointer; font-family: inherit; }
.coa-viewtoggle__btn.is-active { background: var(--surface); color: var(--ink-100); font-weight: 500; box-shadow: 0 1px 2px rgba(20,17,13,.06); }
.coa-viewbar__spacer { flex: 1; }
.fo-placeholder { padding: 60px 24px; text-align: center; color: var(--ink-60); border: 1px dashed var(--hairline-strong); border-radius: 6px; background: var(--surface-2); }
.fo-placeholder__title { font-size: 15px; font-weight: 500; color: var(--ink-80); margin-bottom: 6px; }
.fo-placeholder__sub { font-size: 12px; color: var(--ink-40); }
.entity-meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1px; background: var(--hairline); border: 1px solid var(--hairline); border-radius: 4px; overflow: hidden; margin-bottom: 18px; }
.entity-meta-cell { background: var(--surface); padding: 14px 16px; }
.entity-meta-cell__label { font-size: 9.5px; color: var(--ink-40); text-transform: uppercase; letter-spacing: 1px; font-weight: 500; }
.entity-meta-cell__value { font-size: 15px; font-weight: 500; margin-top: 4px; }
.entity-meta-cell__sub { font-size: 11px; color: var(--ink-60); margin-top: 2px; }
