/* ════════════════════════════════════════════════════════════════════
   Funds tab + topbar fund-switcher
   ════════════════════════════════════════════════════════════════════ */

/* ── Topbar select ────────────────────────────────────────────────── */
.fund-select {
  background: var(--input);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-size: 13px;
  min-width: 180px;
  /* On phones the 180px floor + topbar siblings can overrun the
     viewport. Drop the floor on small screens so the select shrinks
     to whatever space the wrapped action row gives it. */
  max-width: 100%;
}
.fund-select:focus { outline: none; border-color: var(--ring); }
@media (max-width: 720px) {
  .fund-select { min-width: 0; width: 100%; }
}

/* ── Spartan-only affordances ─────────────────────────────────────── */
:root[data-role="lp"] .spartan-only { display: none !important; }

/* ── Summary row across the top ───────────────────────────────────── */
.fund-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.fund-summary-tile {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-card);
  padding: 14px 16px;
}
.fund-summary-tile.fund-summary-active {
  /* Subtle ring + tinted background on the "Currently active" tile so
     it pops without competing with the per-fund cards below. */
  border-color: var(--ring);
  background: linear-gradient(180deg, var(--surface-card-2), var(--surface-card));
}
.fund-summary-label {
  font-size: 10px; color: var(--muted-foreground);
  text-transform: uppercase; letter-spacing: .12em; font-weight: 500;
}
.fund-summary-value {
  margin-top: 6px;
  font-size: 22px; font-weight: 600; color: var(--foreground);
  font-family: var(--font-mono);
  letter-spacing: -.01em;
}
.fund-summary-sub {
  margin-top: 4px;
  font-size: 11.5px; color: var(--muted-foreground);
}

/* ── Funds list ───────────────────────────────────────────────────── */
.funds-list {
  display: flex; flex-direction: column; gap: 12px;
}
.fund-grid {
  display: grid;
  /* Only the active fund is rendered (the bento mirrors the topbar fund
     switcher), so this is always a single full-width card. */
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: stretch;
}

.fund-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-card);
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
  /* --fund-accent / --fund-accent-soft / --fund-accent-edge come from JS
     so each fund gets its own deterministic hue. */
}
.fund-card:hover {
  transform: translateY(-1px);
  border-color: var(--fund-accent-edge, var(--border-strong));
}
.fund-card.is-active {
  border-color: var(--fund-accent-edge, var(--ring));
  /* Toned down — the per-fund hue should hint at active state, not flood
     the card. Gradient fades to plain card surface so the lower half is
     the same color as inactive cards. */
  background: linear-gradient(180deg, var(--fund-accent-soft, var(--surface-card-2)) 0%, var(--surface-card) 60%);
  box-shadow: 0 0 0 1px var(--fund-accent-edge, var(--ring));
}
/* Unsaved-edit state — same amber border + glow that .deal-card.dirty
   uses, so the visual signal is consistent across tabs. */
.fund-card.dirty,
.user-card.dirty {
  border-color: var(--status-dev);
  box-shadow: 0 0 0 1px var(--status-dev), 0 0 24px rgba(248, 168, 0, 0.22);
}

/* Vertical color stripe on the left edge — same pattern as deal-cards
   but driven by the per-fund hue. */
.fund-card-stripe {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 3px;
  background: var(--fund-accent, var(--border));
  opacity: .6;
}
.fund-card.is-active .fund-card-stripe { opacity: 1; }

.fund-card-inner {
  padding: 16px 18px 18px 22px;
  display: flex; flex-direction: column; gap: 14px;
}

.fund-card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.fund-card-name {
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.fund-card-name-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.fund-card-title {
  font-size: 16px; font-weight: 600; color: var(--foreground);
  letter-spacing: -.005em;
}
.fund-card-slug-pill {
  display: inline-block;
  font-family: var(--font-mono); font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--fund-accent-soft, var(--surface-tinted));
  border: 1px solid var(--fund-accent-edge, var(--border));
  color: var(--fund-accent, var(--muted-foreground));
  letter-spacing: .04em;
  text-transform: lowercase;
}
.fund-card-actions {
  display: flex; gap: 8px; flex-shrink: 0;
}

/* Live "Active" pill on the active card — pulse-dot mirrors the sidebar
   System Online indicator so it reads as "this is the live source of
   truth right now". */
.fund-live-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10px; font-weight: 600;
  padding: 3px 9px 3px 8px;
  border-radius: 999px;
  background: var(--fund-accent-soft);
  border: 1px solid var(--fund-accent-edge);
  color: var(--fund-accent);
  text-transform: uppercase; letter-spacing: .12em;
}
.fund-live-dot {
  position: relative;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--fund-accent);
  box-shadow: 0 0 6px var(--fund-accent);
}
.fund-live-dot::after {
  content: '';
  position: absolute; inset: 0; border-radius: inherit;
  background: var(--fund-accent);
  animation: fund-pulse 2.4s cubic-bezier(.32, 0, .2, 1) infinite;
  z-index: -1;
}
@keyframes fund-pulse {
  0%   { transform: scale(1);   opacity: .55; }
  80%  { transform: scale(3.2); opacity: 0; }
  100% { transform: scale(3.2); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .fund-live-dot::after { animation: none; opacity: 0; }
}

/* Stat tiles inside the card body. Active-fund tiles get the per-fund
   accent text-color so the live numbers read warmer than the static
   threshold/deal-count tiles. */
.fund-stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}
.fund-stat {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-tinted);
  padding: 10px 12px;
}
.fund-stat-label {
  font-size: 9.5px; color: var(--muted-foreground);
  text-transform: uppercase; letter-spacing: .14em; font-weight: 500;
}
.fund-stat-value {
  margin-top: 4px;
  font-size: 18px; font-weight: 600;
  font-family: var(--font-mono);
  color: var(--foreground);
  letter-spacing: -.01em;
}
.fund-stat-suffix {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted-foreground);
  margin-left: 2px;
}
.fund-stat-accent .fund-stat-value { color: var(--fund-accent); }

.fund-card-body {
  display: grid;
  grid-template-columns: 1fr 140px;
  gap: 10px 14px;
  align-items: end;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.fund-card-body.is-readonly { opacity: .85; }
.fund-field {
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.fund-field label {
  font-size: 10px; color: var(--muted-foreground);
  text-transform: uppercase; letter-spacing: .1em; font-weight: 500;
}
.fund-field input {
  background: var(--input); color: var(--foreground);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 10px; font-family: var(--font-mono); font-size: 13px;
}
.fund-field input:focus { outline: none; border-color: var(--fund-accent-edge, var(--ring)); }
.fund-field input:disabled,
.fund-field input[readonly] {
  cursor: not-allowed;
  background: transparent;
  border-color: var(--border);
  color: var(--muted-foreground);
}

/* ── Add-fund + add-allowlist forms ───────────────────────────────── */
.fund-form {
  display: flex; flex-direction: column; gap: 10px; max-width: 480px;
}
.fund-form .settings-row label .muted { font-weight: normal; }

/* ── User-management list ─────────────────────────────────────────── */
.users-list {
  display: flex; flex-direction: column; gap: 10px;
}
.user-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-card);
  padding: 14px 16px;
}
.user-card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px;
}
.user-card-meta { min-width: 0; }
.user-card-email {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--foreground);
  word-break: break-all;
}
.user-card-sub { margin-top: 2px; }

.user-card-body {
  margin-top: 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.user-card-section-label {
  font-size: 10px; color: var(--muted-foreground);
  text-transform: uppercase; letter-spacing: .1em; font-weight: 500;
}
/* Inline-button variant for the "Data obfuscation" header row — lets
   the Demo mode preset sit on the right edge of the section label
   without a separate row. */
.user-card-obf-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
}
.user-card-obf-head .user-obf-demo {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 6px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}

.fund-access-row {
  display: flex; flex-wrap: wrap; gap: 10px 16px;
}
.fund-access-check {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-tinted);
  cursor: pointer;
  user-select: none;
}
.fund-access-check input { margin: 0; cursor: pointer; }
.fund-access-check:has(input:checked) {
  border-color: var(--ring);
  background: var(--hover-tint);
}

/* (Capability tiles in the User Management tab reuse .settings-perm
   styling from css/pages/settings.css — see the .settings-perm-toggle
   variant there.) */

/* ── Tab switcher (APIs ↔ Capital Calls) ─────────────────────────────
   Sits inside .fund-card-inner between the editable fields (.fund-card-body)
   and the panel-scoped content (CEX/DeFi blocks for "apis", capital-calls
   grid for "capital"). The dashed top border that .fund-cex-block usually
   draws is suppressed when it's the first child of a panel — the tab strip
   itself acts as the section divider. */
.fund-tabs {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}
.fund-tab {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: .1em;
  cursor: pointer;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.fund-tab:hover {
  color: var(--foreground);
  background: var(--hover-tint);
}
.fund-tab.is-active {
  color: var(--foreground);
  background: var(--fund-accent-soft, var(--surface-tinted));
  border-color: var(--fund-accent-edge, var(--border));
}
.fund-tab-panel { display: none; }
.fund-tab-panel.is-active { display: block; }
/* Suppress the first block's own divider — the tab strip already separates
   it from the form fields above. */
.fund-tab-panel > .fund-cex-block:first-child,
.fund-tab-panel > .fund-cc-block:first-child {
  margin-top: 8px;
  padding-top: 0;
  border-top: 0;
}

/* ── Capital calls grid (per fund) ────────────────────────────────────
   Lives inside the "capital" tab panel. The table pivots
   capital_call_entries rows into a sparse grid: investors are rows,
   distinct effective_dates are columns, each cell is one entry's amount.
   Empty cells = no entry row.

   Data semantics:
     • Positive amount = subscription, negative = redemption.
     • Editing a cell upserts; clearing it (blank or zero) deletes the row.
     • Column set = (distinct dates from entries) ∪ (locally-added unsaved
       columns the operator just clicked "+ Month" on).

   Share class: v1 shows USD only. The data layer is keyed on
   (investor, effective_date, share_class) so a future BTC toggle plugs in
   without DB or API changes — see lib/capital-calls/persistence.ts. */
.fund-cc-block {
  display: flex; flex-direction: column; gap: 10px;
}
.fund-cc-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; flex-wrap: wrap;
}
.fund-cc-title {
  font-size: 11px; color: var(--muted-foreground);
  text-transform: uppercase; letter-spacing: .1em; font-weight: 500;
}
/* USD/BTC share-class switch — a compact segmented control in the Capital
   Calls + Fee Slabs heads. The active segment is filled; the inactive one
   is a quiet ghost button. Shared by both blocks (same markup). */
.fund-cc-share-switch {
  display: inline-flex;
  align-items: stretch;
  align-self: center;   /* center in the fs-head's baseline-aligned row */
  gap: 0;
  padding: 2px;
  border-radius: 999px;
  background: var(--surface-tinted);
  border: 1px solid var(--border);
}
.fund-cc-share-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 3px 11px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: background-color .12s ease, color .12s ease;
}
.fund-cc-share-ico { display: block; flex: none; }
.fund-cc-share-btn:hover { color: var(--foreground); }
.fund-cc-share-btn.is-active {
  background: var(--background);
  color: var(--foreground);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .15);
}
/* BTC segment, when active, picks up the Bitcoin amber. */
.fund-cc-share-btn[data-cc-share="btc"].is-active { color: #f7931a; }

/* Scroll container — horizontal scroll only, for funds with many month
   columns. No vertical cap: the table grows to fit every investor row so
   the cap-calls grid never needs an inner vertical scrollbar. The sticky
   header / investor column still rely on overflow:auto here. */
.fund-cc-scroll {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-tinted);
  overflow: auto;
}
.fund-cc-grid {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-family: var(--font-mono);
  font-size: 12px;
}
.fund-cc-grid th,
.fund-cc-grid td {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 0;            /* inputs/buttons fill the cell themselves */
  /* Cell bg is solid `--input` (white in light, near-black in dark) so
     the data cells fully occlude content behind sticky columns when the
     grid is scrolled horizontally. The cross-hatch + hover layers are
     applied to the inner inputs, not the td, so they don't bleed under
     the sticky investor column. */
  background: var(--input);
  vertical-align: middle;
  white-space: nowrap;
}
.fund-cc-grid tr:last-child td,
.fund-cc-grid tr:last-child th { border-bottom: 0; }
.fund-cc-grid th:last-child,
.fund-cc-grid td:last-child { border-right: 0; }

/* Sticky header row — persists while scrolling vertically. z-index
   layering, top to bottom:
     • corner cell (sticky in BOTH axes)        z=4
     • regular header cells (sticky top)        z=3
     • body investor cells (sticky left)        z=2
     • body data cells                          z=0 (default)
   Solid bg required on every sticky element — `--surface-card-2` is
   `rgba(3,3,3,.40)` in dark theme (40% alpha), which let body rows
   bleed through as they scrolled under the header. color-mix() against
   the solid `--input` token gives a subtle theme-aware grey that is
   fully opaque in both light and dark mode. */
.fund-cc-grid thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: color-mix(in srgb, var(--foreground) 4%, var(--input));
  font-weight: 500;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 10px;
  padding: 8px 10px 6px 10px;
  text-align: right;
  vertical-align: top;
}
.fund-cc-grid thead th.fund-cc-corner {
  text-align: left;
  position: sticky; left: 0; z-index: 4;
}
.fund-cc-grid tbody th.fund-cc-investor {
  position: sticky; left: 0; z-index: 2;
  background: var(--input);   /* solid — see z-index comment above */
  text-align: left;
  padding: 0;
  min-width: 180px;
  max-width: 260px;
}
.fund-cc-grid tbody th.fund-cc-investor::after {
  /* Visual divider between the name column and the data cells. */
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 1px;
  background: var(--border);
}

/* Header cell for a date column — date label + delete button. */
.fund-cc-month-th {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 6px;
  min-width: 120px;
}
.fund-cc-month-label { font-family: var(--font-mono); }

/* Per-column subtotal — sum of all entries in this date / share-class.
   Renders below the date label as a quiet subheader. Same right-aligned
   monospace as the cell amounts so the total reads as a column footer
   pinned to the top. Empty when total is zero so newly-added columns
   don't show a misleading "0". */
.fund-cc-month-total {
  font-size: 11px;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  text-align: right;
  padding-top: 4px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  min-height: 14px;     /* reserve space so empty totals don't shrink the th */
}
.fund-cc-month-del {
  width: 16px; height: 16px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--muted-foreground);
  cursor: pointer;
  font-size: 12px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity .12s ease, color .12s ease, border-color .12s ease;
}
.fund-cc-grid thead th:hover .fund-cc-month-del { opacity: 1; }
.fund-cc-month-del:hover {
  color: var(--neg);
  border-color: rgba(220, 90, 90, 0.4);
}

/* Investor name input + delete button. */
.fund-cc-investor-row {
  display: flex; align-items: center;
  gap: 4px;
  padding: 0 6px 0 10px;
  height: 36px;
}
.fund-cc-investor-name {
  flex: 1 1 auto; min-width: 0;
  background: transparent;
  border: 1px solid transparent;
  color: var(--foreground);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 4px;
}
.fund-cc-investor-name:hover { border-color: var(--border); }
.fund-cc-investor-name:focus {
  outline: none;
  border-color: var(--ring);
  background: var(--input);
}
.fund-cc-investor-del {
  flex: none;
  width: 20px; height: 20px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--muted-foreground);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity .12s ease, color .12s ease, border-color .12s ease;
}
.fund-cc-grid tbody tr:hover .fund-cc-investor-del,
.fund-cc-grid tbody tr:focus-within .fund-cc-investor-del { opacity: 1; }
.fund-cc-investor-del:hover {
  color: var(--loss);
  border-color: rgba(220, 90, 90, 0.4);
}

/* Amount cell — flat input fills the cell. Right-aligned numeric. The td
   is a FIXED 36px in both USD and BTC modes (BTC fits a shorter input + a
   USD-equivalent sub-label into the same 36px), so switching class never
   changes row height and the numbers stay aligned. */
.fund-cc-grid td {
  min-width: 120px;
  height: 36px;
  padding: 0;
}
.fund-cc-cell-input {
  display: block;
  width: 100%;
  height: 36px;
  /* Default: clean "white" (in dark theme: solid input bg). Empty cells
     overlay a subtle diagonal cross-hatch via :placeholder-shown so the
     operator can tell at a glance which (investor, month) pairs are
     blank vs. zero-suppressed. Hover greys the cell; focus clears the
     hatch and shows the focus ring. */
  background-color: var(--input);
  border: 1px solid transparent;
  color: var(--foreground);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 0 10px;
  text-align: right;
  transition: background-color .12s ease, border-color .12s ease;
}
/* Empty-cell cross-hatch — only fires when the input has nothing typed.
   Uses --border at low opacity so the texture reads as "no data yet"
   without competing with the filled cells next to it. */
.fund-cc-cell-input:placeholder-shown {
  background-image: repeating-linear-gradient(
    -45deg,
    transparent 0,
    transparent 6px,
    var(--border) 6px,
    var(--border) 7px
  );
}
.fund-cc-cell-input:hover {
  /* Mix 7% of the text color into the input bg — gives a stronger,
     theme-aware grey than `--surface-tinted` (which is alpha 4% and
     barely registers on top of the solid `--input` cell). */
  background-color: color-mix(in srgb, var(--foreground) 7%, var(--input));
}
.fund-cc-cell-input:focus {
  outline: none;
  background-color: var(--input);
  background-image: none;     /* drop hatch while actively editing */
  border-color: var(--ring);
}
/* Additions (subscriptions) read green, withdrawals (redemptions) red —
   applied live on every keystroke by liveFormatCell and on save. Uses the
   REAL theme tokens (--profit/--loss); --pos/--neg are undefined phantoms. */
.fund-cc-cell-input.is-negative { color: var(--loss); }
.fund-cc-cell-input.is-positive { color: var(--profit); }

/* BTC mode keeps the SAME 36px cell height as USD: the qty input shrinks to
   24px and the USD-equivalent sub-label takes the remaining 12px, so rows
   stay aligned and BTC cells are never taller than USD cells. */
.fund-cc-block[data-cc-share-class="btc"] .fund-cc-cell-input {
  height: 24px;
  /* Amber unit accent so BTC mode reads distinctly from USD at a glance. */
  box-shadow: inset 2px 0 0 color-mix(in srgb, #f7931a 55%, transparent);
}
/* Indicative USD-equivalent under the ₿ quantity, valued at the entry
   month's opening BTC price. Fixed 12px so 24 (input) + 12 (sub) = 36px. */
.fund-cc-cell-sub {
  height: 12px;
  line-height: 12px;
  margin: 0;
  padding: 0 10px;
  font-family: var(--font-mono);
  font-size: 9px;
  text-align: right;
  color: var(--muted-foreground);
  background: var(--input);   /* match the input above — no seam */
  white-space: nowrap;
  overflow: hidden;
  pointer-events: none;
}
/* ── Cell chrome: edit pencil, "n legs" badge, cash marker ─────────────
   A cell is every leg of (investor, month, class). The wrapper positions
   the affordances OVER the input so the 36px row height never changes:
     - pencil (left, hover-reveal)  opens the legs + settlements editor
     - "n legs" badge (left)         2+ legs: the input is read-only and
                                     the editor owns the cell
     - flag dot (top-right)          cash still owed (red) or settled after
                                     the effective month (muted) */
.fund-cc-cell-wrap { position: relative; height: 36px; }
.fund-cc-cell-edit {
  position: absolute;
  left: 4px; top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--foreground) 6%, var(--input));
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--muted-foreground);
  cursor: pointer;
  opacity: 0;
  transition: opacity .12s ease, color .12s ease, border-color .12s ease;
}
.fund-cc-grid td.fund-cc-cell:hover .fund-cc-cell-edit,
.fund-cc-cell-wrap:focus-within .fund-cc-cell-edit { opacity: 1; }
.fund-cc-cell-edit:hover {
  color: var(--foreground);
  border-color: var(--border);
}
/* BTC mode: the input is the top 24px of the wrap - centre the pencil on it. */
.fund-cc-block[data-cc-share-class="btc"] .fund-cc-cell-edit { top: 12px; }
.fund-cc-cell-badge {
  position: absolute;
  left: 26px; top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 9px;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted-foreground);
  background: var(--input);
  pointer-events: none;
  white-space: nowrap;
}
.fund-cc-block[data-cc-share-class="btc"] .fund-cc-cell-badge { top: 12px; }
/* Multi-leg cell: read-only sum, pointer cursor, room on the left for the
   pencil + badge so the right-aligned number never sits under them. The
   column widens for every row (a th/td min-width applies column-wide). */
.fund-cc-grid td.fund-cc-cell.is-multi { min-width: 200px; }
.fund-cc-cell.is-multi .fund-cc-cell-input {
  cursor: pointer;
  padding-left: 76px;
  background-image: none;
}
.fund-cc-cell-flag {
  position: absolute;
  top: 3px; right: 3px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--loss);
  box-shadow: 0 0 0 1px var(--input);
  pointer-events: none;
}
.fund-cc-cell.is-late .fund-cc-cell-flag { background: var(--muted-foreground); }
/* Unpaid tint: the cell still owes cash (a declared redemption whose money
   has not left, or has only partly left). Subtle so the sign colour on the
   number stays the primary read. */
.fund-cc-cell.is-unpaid .fund-cc-cell-input {
  background-color: color-mix(in srgb, var(--loss) 9%, var(--input));
}
.fund-cc-cell.is-unpaid .fund-cc-cell-input:hover {
  background-color: color-mix(in srgb, var(--loss) 16%, var(--input));
}
.fund-cc-cell.is-unpaid .fund-cc-cell-sub {
  background: color-mix(in srgb, var(--loss) 9%, var(--input));
}

/* Brief saved/error halo on a cell after autosave finishes. The classes
   are added/removed by the funds.js cell-save handler. */
.fund-cc-cell-input.is-saved {
  background: color-mix(in srgb, var(--profit) 10%, transparent);
  transition: background .6s ease;
}
.fund-cc-cell-input.is-error {
  background: color-mix(in srgb, var(--loss) 14%, transparent);
  border-color: var(--loss);
}

/* Footer row — "+ Investor" button spans the whole row. */
.fund-cc-grid tfoot td {
  background: var(--surface-tinted);
  padding: 6px 8px;
}
.fund-cc-add-investor {
  width: 100%;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  transition: color .12s ease, border-color .12s ease, background .12s ease;
}
.fund-cc-add-investor:hover {
  color: var(--foreground);
  border-color: var(--ring);
  background: var(--hover-tint);
}

/* "+ Month" header cell on the far right — appended as the last <th> in
   the header row + a matching empty <td> in each body row so the column
   widths line up. min-width is generous (160px) so when the operator
   clicks "+ Month" and the button is swapped for an `<input type="month">`,
   the browser's native calendar trigger fits inside the cell instead of
   getting clipped by the scroll container's right edge. */
.fund-cc-grid th.fund-cc-add-month-th { padding: 0; min-width: 160px; }
.fund-cc-grid th.fund-cc-add-month-th input[type="month"] {
  /* The picker control needs ~150-180px to render its "MM-YYYY" text +
     spinner + calendar icon without truncation. Grow the input to fill
     the full cell so the icon at the right edge is always reachable. */
  width: 100%;
  min-width: 150px;
  height: 100%;
  min-height: 32px;
  font-family: var(--font-mono);
  font-size: 12px;
}
.fund-cc-add-month {
  width: 100%; height: 100%;
  min-height: 32px;
  background: transparent;
  border: none;
  border-left: 1px dashed var(--border);
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  padding: 8px 10px;
  transition: color .12s ease, background .12s ease;
}
.fund-cc-add-month:hover {
  color: var(--foreground);
  background: var(--hover-tint);
}
.fund-cc-grid td.fund-cc-add-month-cell { background: var(--surface-tinted); border-right: 0; }

/* Empty state — no investors yet. */
.fund-cc-empty {
  padding: 18px;
  text-align: center;
  color: var(--muted-foreground);
  font-size: 12px;
}

/* Read-only mode (LP role): hide every editor affordance. The block
   itself is hidden by .spartan-only + auth.css — this is defense in
   depth in case the panel ever shows up for an LP. */
.fund-cc-block.is-readonly .fund-cc-cell-input,
.fund-cc-block.is-readonly .fund-cc-investor-name {
  pointer-events: none;
}
.fund-cc-block.is-readonly .fund-cc-add-investor,
.fund-cc-block.is-readonly .fund-cc-add-month,
.fund-cc-block.is-readonly .fund-cc-investor-del,
.fund-cc-block.is-readonly .fund-cc-month-del,
.fund-cc-block.is-readonly .fund-cc-cell-edit,
.fund-cc-block.is-readonly .fund-cc-slab-select {
  display: none;
}

/* Per-investor share-class picker — sits to the right of the investor
   name. The <select> itself is the chip: trigger shows the selected
   option's text (slab code, or '—' for unassigned). Unassigned reads
   as a muted dashed outline; assigned slabs pick up the fund accent
   so the roster scans at a glance.
   Option styling is explicit because the popup is rendered by the
   browser's chrome and won't inherit the trigger's color/background —
   without this, the dropdown was white-on-white in light theme. */
.fund-cc-slab-select {
  flex: none;
  /* `appearance: none` strips the native dropdown caret; we don't have
     room for it next to a single-letter code, and the click target is
     the whole chip anyway. */
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  min-width: 36px; height: 22px;
  padding: 0 8px;
  border: 1px dashed var(--border);
  border-radius: 999px;
  background: var(--surface-tinted);
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .04em;
  text-transform: uppercase;
  text-align: center;
  text-align-last: center;
  cursor: pointer;
  transition: color .12s ease, border-color .12s ease, background .12s ease;
}
.fund-cc-slab-select.is-assigned {
  color: var(--foreground);
  border-style: solid;
  border-color: var(--fund-accent-edge, var(--ring));
  background: var(--fund-accent-soft, var(--hover-tint));
}
.fund-cc-slab-select:hover {
  color: var(--foreground);
  border-color: var(--ring);
}
.fund-cc-slab-select:focus {
  outline: none;
  border-color: var(--ring);
}
/* The popup options live outside the trigger's stacking context, so
   they need their own theme tokens. var(--input) is solid in both
   themes (#0b0b0b dark / #ffffff light); var(--foreground) flips
   correctly so option text reads on whichever surface the OS picks. */
.fund-cc-slab-select option {
  background: var(--input);
  color: var(--foreground);
  text-transform: uppercase;
  font-family: var(--font-mono);
}

/* ── Fee slabs block (per fund) ──────────────────────────────────────
   Lives behind the "Fee Slabs" tab. Tabular layout: code + three rate
   columns + delete. Rates render as percent values for operator
   readability (5% annual hurdle), stored as fractions (0.05) — the
   conversion happens in the JS layer. */
.fund-fs-block {
  display: flex; flex-direction: column; gap: 10px;
}
.fund-fs-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.fund-fs-title {
  font-size: 11px; color: var(--muted-foreground);
  text-transform: uppercase; letter-spacing: .1em; font-weight: 500;
}
.fund-fs-hint {
  flex: 1 1 auto; min-width: 0;
  text-align: right;
}
.fund-fs-scroll {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-tinted);
  overflow: auto;
}
.fund-fs-grid {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-family: var(--font-mono);
  font-size: 12px;
}
.fund-fs-grid th,
.fund-fs-grid td {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 0;
  background: var(--input);
  vertical-align: middle;
  white-space: nowrap;
}
.fund-fs-grid tr:last-child td { border-bottom: 0; }
.fund-fs-grid th:last-child,
.fund-fs-grid td:last-child { border-right: 0; }
.fund-fs-grid thead th {
  background: color-mix(in srgb, var(--foreground) 4%, var(--input));
  font-weight: 500;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 10px;
  padding: 8px 10px;
  text-align: right;
}
.fund-fs-grid thead th.fund-fs-th-code     { text-align: left; min-width: 90px; }
.fund-fs-grid thead th.fund-fs-th-rate     { min-width: 130px; }
.fund-fs-grid thead th.fund-fs-th-actions  { width: 36px; padding: 0; border-right: 0; }

.fund-fs-code-input,
.fund-fs-rate-input {
  width: 100%;
  height: 36px;
  background: var(--input);
  border: 1px solid transparent;
  color: var(--foreground);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 0 10px;
  transition: background .12s ease, border-color .12s ease;
}
.fund-fs-code-input { text-align: left; text-transform: uppercase; }
.fund-fs-rate-input { text-align: right; padding-right: 26px; }
.fund-fs-code-input:hover,
.fund-fs-rate-input:hover {
  background: color-mix(in srgb, var(--foreground) 7%, var(--input));
}
.fund-fs-code-input:focus,
.fund-fs-rate-input:focus {
  outline: none;
  background: var(--input);
  border-color: var(--ring);
}
.fund-fs-code-input.is-saved,
.fund-fs-rate-input.is-saved {
  background: color-mix(in srgb, var(--profit) 10%, transparent);
  transition: background .6s ease;
}
.fund-fs-code-input.is-error,
.fund-fs-rate-input.is-error {
  background: color-mix(in srgb, var(--loss) 14%, transparent);
  border-color: var(--loss);
}

/* % suffix sits in-cell so the input keeps native text-cursor behavior. */
.fund-fs-rate-cell {
  position: relative;
  display: block;
}
.fund-fs-rate-suffix {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--muted-foreground);
  font-size: 11px;
}

.fund-fs-actions-cell {
  text-align: center;
  width: 36px;
  padding: 0;
}
.fund-fs-row-del {
  width: 24px; height: 24px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--muted-foreground);
  cursor: pointer;
  font-size: 14px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity .12s ease, color .12s ease, border-color .12s ease;
}
.fund-fs-grid tr:hover .fund-fs-row-del,
.fund-fs-grid tr:focus-within .fund-fs-row-del { opacity: 1; }
.fund-fs-row-del:hover {
  color: var(--neg);
  border-color: rgba(220, 90, 90, 0.4);
}

.fund-fs-empty {
  padding: 18px;
  text-align: center;
  color: var(--muted-foreground);
  font-size: 12px;
}

.fund-fs-add-row {
  display: flex;
}
.fund-fs-add {
  width: 100%;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  transition: color .12s ease, border-color .12s ease, background .12s ease;
}
.fund-fs-add:hover {
  color: var(--foreground);
  border-color: var(--ring);
  background: var(--hover-tint);
}

/* ── CEX credentials (per fund) ──────────────────────────────────── */
/* Sits inside .fund-card under the deals/MtM-threshold body. Lists
   API keys per CEX (binance/bybit/okx/bitget) with a masked last4
   tag, sync status, and a per-key kebab menu. Adding a key opens
   the .cex-add-modal shared at the bottom of the page. */
.fund-cex-block {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  display: flex; flex-direction: column; gap: 10px;
}
.fund-cex-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
}
.fund-cex-title {
  font-size: 11px; color: var(--muted-foreground);
  text-transform: uppercase; letter-spacing: .1em; font-weight: 500;
}
.fund-cex-pills {
  /* Auto-fit grid — packs as many pills per row as fit at ≥ 220px each,
     dropping to 2 / 1 columns as the fund card narrows or the user
     zooms. Each pill stacks its action buttons below the inception
     input (see `.fund-cex-pill` two-row layout below) so the column
     budget only has to hold the badge + label horizontal axis. */
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 6px;
  align-items: stretch;
}
.fund-cex-add-row {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.fund-cex-add-row .muted { font-size: 11px; }

/* Per-credential pill ("Binance · Main · ***AB12 · ✓ 2m ago"). Two-row
   grid: row 1 holds [badge | meta] so the logo sits next to the label
   stack (label / synced status / inception input); row 2 places the
   action buttons under the meta column. This vertical packing lets the
   container grid fit 3+ pills per row in a typical fund-card width. */
.fund-cex-pill {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  row-gap: 8px;
  column-gap: 10px;
  padding: 10px;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-tinted);
  font-size: 12px;
  cursor: default;
}
.fund-cex-pill .tdd-cex-logo-wrap {
  width: 22px; height: 22px; flex: none;
}

/* Chain text-badge — used by the DeFi-wallet block when we don't have
   a chain logo asset. Replaces the <img> child with a text mark
   ("ETH", "ARB", "BASE") inside the same rounded-square chrome the
   CEX logo wrappers use, so the wallet pills line up with the API-key
   pills visually. */
.fund-chain-badge {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-tinted);
  border: 1px solid var(--border);
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.fund-chain-badge-text {
  font-size: 9px;
  line-height: 1;
  padding: 0 1px;
  white-space: nowrap;
}
/* Native-token icon overlays the .fund-chain-badge-text fallback. The
   slot fills the entire wrap so the CG logo reads at the chain-badge
   size; when the icon resolver returns a hit, the painted <img> hides
   the text underneath. The base .ticker-icon rule sets width:1em which
   would render as a tiny dot at the badge's 9px font-size — overrides
   below pin it to 100% of the wrap instead. */
.fund-chain-badge .fund-chain-badge-icon {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  background: transparent;
  border-radius: inherit;
  overflow: hidden;
}
.fund-chain-badge .fund-chain-badge-icon img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
/* Icon resolved to a missing entry — hide the empty slot completely so
   the text fallback owns the badge again. (Default
   .ticker-icon--missing rule collapses to width/height 0 but keeps the
   slot in flow; we want it gone so the text isn't pushed off-center.) */
.fund-chain-badge .fund-chain-badge-icon.ticker-icon--missing {
  display: none !important;
}
/* Once the chain icon resolves to a real image (or obfuscation paint),
   hide the underlying text mark — crypto logos have transparent corners
   so leaving the text would let the ticker letters bleed through. The
   text stays visible while the slot is loading or has resolved missing. */
.fund-chain-badge:has(.fund-chain-badge-icon[data-icon-painted]:not(.ticker-icon--missing)) .fund-chain-badge-text {
  display: none;
}
.fund-cex-add-btn .fund-chain-badge { width: 22px; height: 22px; }
.fund-cex-pill .fund-chain-badge { width: 22px; height: 22px; }
.app-modal-title .fund-chain-badge { width: 22px; height: 22px; }
/* Keep the text mark legible at the smaller sizes — the auto-sized
   .fund-chain-badge-text scales naturally because we set it in pixels,
   but at the pill width it crowds the border. Bump the radius slightly so
   the mark feels seated. */
.fund-cex-pill .fund-chain-badge-text { font-size: 9px; }
.fund-cex-add-btn .fund-chain-badge-text { font-size: 9px; }

/* "+ Add Wallet" button — same chrome as CEX add buttons; the globe
   icon inside .fund-chain-badge stands in for a chain logo because
   auto-detect spans every chain Covalent serves. */
.fund-wallet-add-primary {
  border-color: var(--ring);
  color: var(--foreground);
}
.fund-wallet-add-primary:hover {
  background: var(--hover-tint);
}
.fund-wallet-add-primary .fund-chain-badge {
  background: var(--surface);
  color: var(--foreground);
}


.fund-cex-pill-meta {
  display: flex; flex-direction: column; gap: 3px; min-width: 0;
}
.fund-cex-pill-label {
  font-weight: 500; color: var(--foreground);
  font-family: var(--font-mono); font-size: 12px;
  white-space: nowrap;
  /* Long names ("Bybit · Subaccount 1 · ***Jwd3") truncate with an
     ellipsis instead of pushing the actions column off the right. The
     full string is exposed via title= on the element for hover. */
  overflow: hidden;
  text-overflow: ellipsis;
}
.fund-cex-pill-sub {
  font-size: 10px; color: var(--muted-foreground);
  font-family: var(--font-mono);
  min-width: 0;
}
.fund-cex-pill-actions {
  /* Row 2 of the pill grid — sits under the meta column so the badge
     column stays empty in row 2 and actions align with the inception
     input above. */
  grid-column: 2;
  display: inline-flex; gap: 2px;
  opacity: .65; transition: opacity .12s ease;
  flex: none;
}
.fund-cex-pill:hover .fund-cex-pill-actions,
.fund-cex-pill:focus-within .fund-cex-pill-actions { opacity: 1; }

/* Square icon button — used by per-credential pill actions and the
   modal close button. Mirrors the lucide-icon style: 1px transparent
   border, fades in border + tint on hover. */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted-foreground);
  padding: 0;
  border-radius: 6px;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.icon-btn:hover {
  background: var(--hover-tint);
  border-color: var(--border);
  color: var(--foreground);
}
.icon-btn:focus-visible {
  outline: none;
  border-color: var(--ring);
  background: var(--hover-tint);
}
.icon-btn.danger:hover { color: var(--neg); border-color: rgba(220, 90, 90, 0.4); }
.icon-btn .lucide { width: 14px; height: 14px; }

.fund-cex-pill-sub {
  display: inline-flex; align-items: center; gap: 4px;
}
.fund-cex-pill-status-ico { display: inline-block; vertical-align: -1px; }
.fund-cex-pill-status-ico.is-ok      { color: var(--pos); }
.fund-cex-pill-status-ico.is-error   { color: var(--neg); }
.fund-cex-pill-status-ico.is-pending { color: var(--muted-foreground); }
.fund-cex-pill.is-disabled { opacity: .5; }

/* Connectivity-test feedback states. The pill border + sub-line tinted
   by the result so the operator sees the outcome where they clicked,
   not in the page-level status dot (test isn't a save → autosave's
   "Saved · …" copy was misleading). Success auto-reverts after 2.5s;
   error sticks until the user re-runs or dismisses. */
.fund-cex-pill.test-pending {
  border-color: var(--muted-foreground);
  background: color-mix(in srgb, var(--muted-foreground) 6%, var(--surface-tinted));
}
.fund-cex-pill.test-ok {
  border-color: var(--pos);
  background: color-mix(in srgb, var(--pos) 8%, var(--surface-tinted));
}
.fund-cex-pill.test-ok .fund-cex-pill-status { color: var(--pos); }
.fund-cex-pill.test-error {
  border-color: var(--neg);
  background: color-mix(in srgb, var(--neg) 8%, var(--surface-tinted));
}
.fund-cex-pill.test-error .fund-cex-pill-status { color: var(--neg); }

/* Spinner for the test button while the request is in flight. The JS
   swaps the test button's icon SVG for a `loader2` lucide that carries
   the .lucide-spin class — rotating a quarter-arc reads as "loading"
   the way a rotating lightning bolt didn't. The .is-busy class on the
   button itself suppresses pointer events so a double-click can't
   re-fire the request. transform-origin centers on the 24×24 viewBox
   so the arc spins in place rather than orbiting. */
.icon-btn.is-busy {
  pointer-events: none;
  cursor: wait;
}
.lucide-spin {
  animation: cred-test-spin .9s linear infinite;
  transform-origin: 50% 50%;
}
@keyframes cred-test-spin {
  to { transform: rotate(360deg); }
}

/* Inline inception-date input — small, lives next to the synced-status
   line. Styled to look like part of the pill rather than a form. */
.fund-cex-pill-inception {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; color: var(--muted-foreground);
  font-family: var(--font-mono);
  margin-top: 1px;
}
.fund-cex-pill-inception-label { opacity: .8; }
.fund-cex-pill-inception-input {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 1px 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--foreground);
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
  color-scheme: dark;
}
:root[data-theme="light"] .fund-cex-pill-inception-input { color-scheme: light; }
.fund-cex-pill-inception-input:hover,
.fund-cex-pill-inception-input:focus {
  border-color: var(--border);
  background: var(--hover-tint);
  outline: none;
}
.fund-cex-pill-inception-input:focus { border-color: var(--ring); }

/* Add-key venue chooser — a row of CEX badges that opens the modal. */
.fund-cex-add-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: transparent;
  font-size: 11px;
  color: var(--muted-foreground);
  cursor: pointer;
}
.fund-cex-add-btn .tdd-cex-logo-wrap { width: 16px; height: 16px; }
.fund-cex-add-btn:hover {
  border-color: var(--ring);
  color: var(--foreground);
  background: var(--hover-tint);
}
/* Bank wordmark in the "+ <provider>" add button. The SVG ships with a
   near-black fill; tdd-cex-logo--invert flips it white in dark mode so it
   contrasts on either theme. Sized off the button text height. */
.fund-bank-wordmark {
  display: block;
  height: 11px;
  width: auto;
}

/* ── Add-credential modal — form-specific bits ────────────────────────
   The modal shell (backdrop, card, head/title/sub/actions/status) lives
   in components/modal.css under .app-modal-*. Below are only the form-
   field styles, scoped to .cex-modal-form so they don't leak into other
   dialogs that might want their own field treatment. */
.cex-modal-form { display: flex; flex-direction: column; gap: 12px; }
.cex-modal-field { display: flex; flex-direction: column; gap: 4px; }
.cex-modal-field label {
  font-size: 10px; color: var(--muted-foreground);
  text-transform: uppercase; letter-spacing: .1em; font-weight: 500;
}
.cex-modal-field input,
.cex-modal-field textarea {
  background: var(--input); color: var(--foreground);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 10px; font-family: var(--font-mono); font-size: 13px;
}
.cex-modal-field input:focus,
.cex-modal-field textarea:focus { outline: none; border-color: var(--ring); }
/* `.is-secret` masks the value visually without using type="password",
   which is what triggered Chrome/1Password/LastPass to offer to save the
   field as a login credential. -webkit-text-security works in Chromium
   and Safari (Firefox falls back to plaintext, acceptable for an
   internal tool). The font-family override gives the disc glyphs a
   tighter, more password-like rhythm than the inherited mono. */
.cex-modal-field input.is-secret {
  -webkit-text-security: disc;
  font-family: var(--font-sans);
  letter-spacing: .1em;
}

/* ── Capital-calls cell editor (legs + cash settlements) ──────────────
   Programmatic modal (components/modal.js openModal) whose body is the
   .fund-cc-editor block below: one card per leg (effective date, amount,
   notes) with its cash history (settlement rows, "remainder pending"
   checkbox, remainder date) and a read-only paid/pending line. Wider than
   the default dialog so a settlement row (date / amount / note / x) fits
   on one line. */
.app-modal.fund-cc-editor-modal { width: min(680px, 94vw); }
.fund-cc-editor {
  display: flex; flex-direction: column; gap: 12px;
  margin-bottom: 8px;
}
.fund-cc-editor-empty { padding: 6px 0; }
.fund-cc-leg {
  display: flex; flex-direction: column; gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-tinted);
}
.fund-cc-leg.is-removed { opacity: .6; }
.fund-cc-leg-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.fund-cc-leg-title {
  font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted-foreground); font-weight: 500;
}
.fund-cc-leg-btn { font-size: 11px; padding: 4px 8px; }
.fund-cc-add-leg { align-self: flex-start; }
.fund-cc-leg-row {
  display: grid; grid-template-columns: 160px 1fr 1fr; gap: 8px;
}
.fund-cc-ed-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fund-cc-ed-field > span {
  font-size: 10px; color: var(--muted-foreground);
  text-transform: uppercase; letter-spacing: .1em; font-weight: 500;
}
.fund-cc-ed-field input,
.fund-cc-settlement input {
  min-width: 0; width: 100%;
  background: var(--input); color: var(--foreground);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px 8px; font-family: var(--font-mono); font-size: 12px;
}
.fund-cc-ed-field input:focus,
.fund-cc-settlement input:focus { outline: none; border-color: var(--ring); }
.fund-cc-ed-field input:disabled { opacity: .5; }
.fund-cc-ed-amount { text-align: right; }
.fund-cc-ed-amount.is-negative { color: var(--loss); }
.fund-cc-ed-amount.is-positive { color: var(--profit); }
.fund-cc-leg-cash {
  display: flex; flex-direction: column; gap: 6px;
  border-top: 1px dashed var(--border);
  padding-top: 8px;
}
.fund-cc-leg-cash-title {
  font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted-foreground); font-weight: 500;
}
.fund-cc-leg-cash-title .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }
.fund-cc-settlements { display: flex; flex-direction: column; gap: 4px; }
.fund-cc-settlement {
  display: grid; grid-template-columns: 160px 1fr 1fr 24px; gap: 6px;
  align-items: center;
}
.fund-cc-settlement input[data-ed-sfield="amount"] { text-align: right; }
.fund-cc-settlement-del {
  width: 22px; height: 22px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--muted-foreground);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; line-height: 1;
}
.fund-cc-settlement-del:hover {
  color: var(--loss);
  border-color: rgba(220, 90, 90, 0.4);
}
.fund-cc-leg-remainder {
  display: grid; grid-template-columns: 1fr 200px; gap: 8px; align-items: end;
}
.fund-cc-ed-check {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--foreground);
  padding-bottom: 6px;
}
.fund-cc-ed-check input { accent-color: var(--loss); }
.fund-cc-leg-summary {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--muted-foreground);
  padding: 4px 0 0;
}
.fund-cc-editor-status { min-height: 16px; margin-right: 0; }
@media (max-width: 720px) {
  .fund-cc-leg-row,
  .fund-cc-settlement,
  .fund-cc-leg-remainder { grid-template-columns: 1fr; }
}

/* ── Mobile (≤ 720px) — CEX block + add-key modal ────────────────────
   Pill width / alignment is already row-based at desktop sizes; mobile
   only needs the label to wrap (no ellipsis) so long subaccount names
   stay readable in the constrained meta column. The add-key button row
   collapses to two-up so the touch targets stay comfortable. */
@media (max-width: 720px) {
  .fund-cex-pill-label {
    white-space: normal;
    word-break: break-word;
    overflow: visible;
    text-overflow: clip;
  }
  .fund-cex-pill-actions {
    opacity: 1; /* hover-to-reveal doesn't work with touch — show always */
  }
  .fund-cex-add-row {
    gap: 4px;
  }
  .fund-cex-add-btn {
    flex: 1 1 calc(50% - 4px);
    justify-content: center;
  }
  /* Mobile sheet rules for the modal shell live in components/modal.css
     under .app-modal — no need to duplicate them here. */
}

/* ── Mobile (≤ 720px) ────────────────────────────────────────────────
   The fund cards' 360px-min auto-fill grid forces a horizontal
   overflow on any phone narrower than ~360 + page padding (i.e.
   every phone). Drop to a single column and let cards fill their
   container's width. The card body's "label / 140px input" split
   also collapses to single-column so input controls stay reachable
   without horizontal scrolling. */
@media (max-width: 720px) {
  /* Fund cards — one per row, no minimum width that overruns the
     viewport. */
  .fund-grid { grid-template-columns: 1fr; gap: 12px; }
  .fund-card-inner { padding: 14px 14px 14px 18px; gap: 12px; }

  /* Stat tiles — two per row at typical phone widths (180-180px is
     comfortable at 100px each + 8px gap on a ≥ 360px panel) but
     drop to one when really narrow. */
  .fund-stat-row { grid-template-columns: 1fr 1fr; gap: 8px; }
  .fund-stat { padding: 8px 10px; }
  .fund-stat-value { font-size: 16px; }

  /* Card body inputs — stack labels above inputs in a single column
     so the "MTM Threshold (Days)" caption stops being cropped to its
     pinned 140px column. */
  .fund-card-body {
    grid-template-columns: 1fr;
    gap: 10px;
    padding-top: 10px;
  }

  /* Top summary row — explicit single column on tiny screens. The
     auto-fit minmax(180px, 1fr) already handles 360px+ widths but a
     320px viewport can fall through. */
  .fund-summary { grid-template-columns: 1fr; gap: 10px; }
  .fund-summary-tile { padding: 12px 14px; }
  .fund-summary-value { font-size: 18px; }

  /* Fund-card head: actions (View / Delete) need to wrap below the
     name on the narrowest screens rather than being squeezed beside
     a long fund title. */
  .fund-card-head { gap: 8px; }

  /* Card title shrink — at 360px viewport, a 16px title with no
     wrap could push the action buttons off-screen. */
  .fund-card-title { font-size: 15px; }
}

/* Even narrower: drop stats to a single column when two columns
   wouldn't have a readable inner padding any more. */
@media (max-width: 380px) {
  .fund-stat-row { grid-template-columns: 1fr; }
}
