/* ════════════════════════════════════════════════════════════════════
   Reconciliation tab — Position Report upload + auto-match report.
   ════════════════════════════════════════════════════════════════════ */

/* Top-of-tab switcher between Positions and Balance Sheet views. Reuses
   the .section-toggle / .seg-btn pattern but sits above the cards
   instead of inline within a filter strip — a small margin-bottom
   gives breathing room before the first card in the active view. */
.recon-view-switcher {
  margin-bottom: 14px;
}

/* Lock the upload card to a stable height so toggling between the
   Positions and Balance Sheet views doesn't shift the dropzone up or
   down a few px when intro-paragraph wrapping differs. The min-height
   accommodates both cards' natural sizes (title row + ~5-line intro +
   dropzone padding + meta row) with a small comfort margin so neither
   appears starved if a future description tweak adds a line.
   .recon-intro is also pinned so the dropzone always starts at the
   same Y inside the card regardless of view. */
.recon-view .recon-intro-card {
  min-height: 360px;
}
.recon-view .recon-intro {
  min-height: 90px;
  margin-bottom: 14px;
  max-width: 720px;
  line-height: 1.5;
}

.recon-intro {
  margin-bottom: 14px;
  max-width: 720px;
  line-height: 1.5;
}

/* ── Administrator byline ─────────────────────────────────────────────
   Theme-aware Formidium attribution sitting on the right edge of a
   header (recon card title, investors fund-summary section head, …).
   The logo file is swapped via a CSS variable so dark/light themes
   pick the contrast-correct asset automatically — same pattern as
   --watermark-svg in tokens.css. */
.admin-byline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 4px 10px 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-elevated);
  white-space: nowrap;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.admin-byline:hover {
  border-color: var(--border-strong);
  background: var(--surface-tinted);
}
.admin-byline-label {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-foreground);
}
.admin-byline-logo {
  display: inline-block;
  width: 88px;
  height: 18px;
  background-image: url('/formidium-logo-white.svg');
  background-repeat: no-repeat;
  background-position: left center;
  background-size: contain;
}
:root[data-theme="light"] .admin-byline-logo {
  background-image: url('/formidium-logo-black.svg');
}
@media (max-width: 640px) {
  .admin-byline {
    margin-left: 0;
  }
}

/* ── Upload card ──────────────────────────────────────────────────── */

.recon-upload {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.recon-dropzone {
  display: block;
  cursor: pointer;
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  padding: 32px 24px;
  background: var(--bg-elev);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.recon-dropzone:hover,
.recon-dropzone.is-dragging {
  background: var(--bg-hover);
  border-color: var(--accent);
}
.recon-dropzone.is-staged {
  border-style: solid;
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.recon-dropzone-body {
  display: flex;
  align-items: center;
  gap: 18px;
  justify-content: center;
}
.recon-dropzone-body svg {
  width: 40px;
  height: 40px;
  color: var(--text-soft);
  flex-shrink: 0;
}
.recon-dropzone.is-staged .recon-dropzone-body svg {
  color: var(--accent);
}
.recon-dropzone-title {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
  color: var(--text);
}
.recon-dropzone-sub em {
  font-style: normal;
  color: var(--text-soft);
}

.recon-upload-meta {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.recon-date-override {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-soft);
}
.recon-date-override input[type="date"] {
  margin-top: 2px;
}
#recon-upload-status.is-ok    { color: var(--good); }
#recon-upload-status.is-error { color: var(--danger); }

/* ── Archive list ─────────────────────────────────────────────────── */

.recon-uploads-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.recon-upload-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elev);
  transition: background 0.12s ease, border-color 0.12s ease;
}
.recon-upload-row:hover {
  background: var(--bg-hover);
  border-color: color-mix(in srgb, var(--accent) 60%, var(--border));
}
.recon-upload-row.is-selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--bg-elev));
}
.recon-upload-row-main {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 14px;
  cursor: pointer;
  min-width: 0;
}
.recon-upload-row-date {
  font-weight: 600;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--text);
}
.recon-upload-row-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.recon-upload-row-file {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 360px;
  color: var(--text-soft);
  font-size: 12px;
}
.recon-upload-row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* ── Report card summary tiles ────────────────────────────────────── */

.recon-report-summary,
.recon-bs-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.recon-summary-tile {
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
}
.recon-summary-tile.recon-summary-ok {
  border-color: color-mix(in srgb, var(--good) 60%, var(--border));
}
.recon-summary-tile.recon-summary-warn {
  border-color: color-mix(in srgb, var(--danger) 60%, var(--border));
  background: color-mix(in srgb, var(--danger) 5%, var(--bg-elev));
}
.recon-summary-label {
  font-size: 11px;
  color: var(--text-soft);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.recon-summary-value {
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
/* Full-width header that splits the summary grid into sections (top
   tiles → "By venue" → "By chain"). Spans every column so wrapping
   tiles below it line up cleanly. */
.recon-summary-section {
  grid-column: 1 / -1;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
  padding: 6px 2px 0;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.recon-summary-section:first-child {
  border-top: none;
  margin-top: 0;
}

/* ── Report filters ───────────────────────────────────────────────── */

.recon-report-filters {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.recon-report-filters .field-inline {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.recon-report-filters .field-inline label {
  font-size: 11px;
  color: var(--text-soft);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.recon-report-filters input[type="text"] {
  min-width: 240px;
}

/* ── Report table ─────────────────────────────────────────────────── */

.recon-report-table-wrap {
  /* overflow:auto (both axes) on a max-height container makes the table
     scroll internally — needed for the sticky thead to actually stick.
     overflow-x:auto alone forces overflow-y:auto per spec but with no
     max-height nothing ever overflows vertically, so page-scroll moved
     the whole table (and its sticky thead) up out of view. The
     calc() leaves room for the app shell + filters above. */
  overflow: auto;
  max-height: calc(100vh - 240px);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.recon-report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--surface-elevated);
}
.recon-report-table th,
.recon-report-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.recon-report-table th {
  /* Opaque background is required for position:sticky — without it the
     scrolled rows show through the floating header. --bg / --text-soft
     in earlier drafts referenced undefined tokens; using the actual
     palette tokens (--background, --muted-foreground) gives the header
     a solid theme-aware fill. */
  background: var(--background);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted-foreground);
  position: sticky;
  top: 0;
  /* Above divider rows (which have their own tinted backgrounds) and
     above the column-tint hover rules. */
  z-index: 3;
}
.recon-report-table td.num,
.recon-report-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.recon-report-table tr:last-child td {
  border-bottom: none;
}
.recon-report-table tr.recon-row:hover {
  background: var(--bg-hover);
}
.recon-report-table td.is-diff {
  color: var(--danger);
  font-weight: 500;
}
.recon-report-table td.is-positive {
  color: var(--profit);
  font-weight: 500;
}
.recon-report-table td.is-negative {
  color: var(--loss);
  font-weight: 500;
}

/* Discount-applied badge — used on:
   • OTC rows whose mark has been prorated by the deal's d_pro
     (variant: --otc, tan accent).
   • Perp hedge rows whose uPnL/mark has been adjusted by the linked
     OTC ticker's aggregate discount (variant: --hedge, blue accent).
   Single shape so the operator reads both as one concept. Theme-aware
   via --foreground for body text + the OTC-token / OTC-hedge palette
   tokens for the accent colour (which already flip per data-theme). */
.recon-discount-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  line-height: 1.4;
  white-space: nowrap;
  color: var(--foreground);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
}
.recon-discount-badge__pct {
  font-weight: 700;
  letter-spacing: 0.01em;
}
.recon-discount-badge__label {
  color: var(--muted-foreground);
  font-weight: 500;
}
.recon-discount-badge__sep,
.recon-discount-badge__delta {
  color: var(--muted-foreground);
}
.recon-discount-badge--otc {
  border-color: color-mix(in srgb, var(--otc-token) 45%, var(--border));
  background: color-mix(in srgb, var(--otc-token) 12%, var(--surface-2));
}
.recon-discount-badge--otc .recon-discount-badge__pct {
  color: var(--otc-token);
}
.recon-discount-badge--hedge {
  border-color: color-mix(in srgb, var(--otc-hedge) 45%, var(--border));
  background: color-mix(in srgb, var(--otc-hedge) 12%, var(--surface-2));
}
.recon-discount-badge--hedge .recon-discount-badge__pct {
  color: var(--otc-hedge);
}

/* ── Pricing basis (Fund | Formidium) ─────────────────────────────────
   The pill borrows the Live Overview switch's look (.liveov-mp-toggle and
   the helmet / Formidium marks) but not its .liveov-pricing-btn hook: that
   one is bound by a document-wide click and would flip the overview too. */
.recon-pricing-toggle .recon-pricing-btn {
  padding: 3px 8px 3px 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.recon-pricing-btn.is-active .liveov-pricing-ico { opacity: 1; }
/* The admin basis wears the CoinMarketCap blue, as on the overview. */
.recon-pricing-btn.is-active[data-recon-pricing="formidium"] {
  color: #2B6AFF;
  box-shadow: 0 1px 2px rgba(0,0,0,.06), inset 0 0 0 1px color-mix(in srgb, #2B6AFF 35%, transparent);
}
/* Source mark beside the Spartan mark on the Formidium basis (the
   .ov-px-src brand backgrounds live in live-overview.css). */
.recon-report-table .ov-mark-cell { justify-content: flex-end; }
.recon-report-table .recon-admin-src { cursor: inherit; }
.recon-report-table td[title] { cursor: help; }
/* Formidium MP off its own rule: the admin mark itself is the finding. */
.recon-report-table td.recon-mark-dev {
  color: var(--loss);
  font-weight: 600;
}
.recon-admin-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  line-height: 1.4;
  white-space: nowrap;
  color: var(--foreground);
  border: 1px solid color-mix(in srgb, var(--loss) 45%, var(--border));
  background: color-mix(in srgb, var(--loss) 10%, var(--surface-2));
}
.recon-admin-badge__label { color: var(--muted-foreground); font-weight: 500; }
.recon-admin-badge__usd { color: var(--loss); font-weight: 700; }

/* ── Column side-tints — Formidium vs Spartan ─────────────────────────
   Subtle background tints that flag which side of the reconciliation a
   column belongs to. Formidium columns get a blue tint (the fund-admin
   brand colour); Spartan columns get a theme-aware tint built from
   var(--foreground) so it inverts naturally with the theme — a touch
   darker than the bg in light mode (foreground = #111) and a touch
   lighter in dark mode (foreground = #f8f8f8). Opacities deliberately
   low so the row's status colour and text remain readable; we don't
   change text colour anywhere.
   Header cells get a slightly stronger version so the column origin is
   obvious without scanning data. */
.recon-report-table th.col-formidium {
  background: color-mix(in srgb, #3b82f6 10%, var(--background));
}
.recon-report-table th.col-spartan {
  background: color-mix(in srgb, var(--foreground) 6%, var(--background));
}
.recon-report-table td.col-formidium {
  background: color-mix(in srgb, #3b82f6 5%, transparent);
}
.recon-report-table td.col-spartan {
  background: color-mix(in srgb, var(--foreground) 3%, transparent);
}
/* Row hover should keep showing tracking even when the cell carries a
   column tint. var(--hover-tint) is the theme-aware overlay (rgba white
   in dark mode / rgba black in light mode), so layering it via
   linear-gradient over the column tint keeps both signals visible
   without hard-coding a per-theme background. */
.recon-report-table tr.recon-row:hover td.col-formidium {
  background:
    linear-gradient(var(--hover-tint), var(--hover-tint)),
    color-mix(in srgb, #3b82f6 5%, transparent);
}
.recon-report-table tr.recon-row:hover td.col-spartan {
  background:
    linear-gradient(var(--hover-tint), var(--hover-tint)),
    color-mix(in srgb, var(--foreground) 3%, transparent);
}

/* Status pills — colour-keyed by recon outcome. */
.recon-status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-soft);
}
.recon-status-pill.recon-status-ok {
  border-color: color-mix(in srgb, var(--good) 60%, var(--border));
  background: color-mix(in srgb, var(--good) 18%, transparent);
  color: var(--good);
}
.recon-status-pill.recon-status-mismatch {
  border-color: color-mix(in srgb, #f59e0b 60%, var(--border));
  background: color-mix(in srgb, #f59e0b 18%, transparent);
  color: #f59e0b;
}
.recon-status-pill.recon-status-missing {
  border-color: color-mix(in srgb, var(--danger) 60%, var(--border));
  background: color-mix(in srgb, var(--danger) 18%, transparent);
  color: var(--danger);
}
.recon-status-pill.recon-status-extra {
  border-color: color-mix(in srgb, #8b5cf6 60%, var(--border));
  background: color-mix(in srgb, #8b5cf6 18%, transparent);
  color: #a78bfa;
}
.recon-status-pill.recon-status-unmapped {
  border-color: color-mix(in srgb, #64748b 60%, var(--border));
  background: color-mix(in srgb, #64748b 18%, transparent);
  color: var(--text-soft);
}

/* Multi-check status badge — three letter dots (Q M N) for Quantity,
   Mark, and Notional. Each dot carries its own status colour so the
   operator can see at a glance which leg of the qty × mark = notional
   chain didn't reconcile. The outer pill keeps the existing border /
   row-tinting hooks (.recon-status-${aggregate}) so per-row CSS still
   matches; we just neutralise its background so the dots' colours
   carry the signal. */
.recon-status-pill.recon-status-multi {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 5px;
  background: var(--surface-elevated);
  color: var(--muted-foreground);
  border-color: var(--border);
}
.recon-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  font-size: 9px;
  font-weight: 700;
  font-family: var(--font-mono, monospace);
  letter-spacing: 0;
  line-height: 1;
  cursor: help;
  /* Border on every variant keeps the circle visible even when the
     theme's tokens render the fill at low contrast. Per-variant rules
     below override border-color where needed. */
  border: 1px solid transparent;
  box-sizing: border-box;
}
/* Traffic-light palette. Tokens used here are the ones actually defined
   in tokens.css — earlier drafts referenced --good / --danger / --bg
   which don't exist in this app and silently rendered transparent. */
.recon-check-ok {
  background: var(--profit);
  color: #0d0d0d;
  border-color: color-mix(in srgb, var(--profit) 70%, #000);
}
.recon-check-mismatch {
  background: #f59e0b;
  color: #0d0d0d;
  border-color: color-mix(in srgb, #f59e0b 70%, #000);
}
.recon-check-missing {
  background: var(--loss);
  color: #ffffff;
  border-color: color-mix(in srgb, var(--loss) 70%, #000);
}
.recon-check-extra {
  background: #8b5cf6;
  color: #ffffff;
  border-color: color-mix(in srgb, #8b5cf6 70%, #000);
}
.recon-check-unmapped,
.recon-check-na {
  background: transparent;
  border: 1px dashed color-mix(in srgb, var(--muted-foreground) 60%, transparent);
  color: var(--muted-foreground);
}

/* Neutral outcomes from the v2 matcher: a dust row (verdict DUST) and a
   member of a netted group. A grey pill, N/A dots and a short tag, so the
   row reads as neither a break, an OK nor an unmapped account. Three
   classes so it beats .recon-status-multi above. Real tokens only. */
.recon-status-pill.recon-status-multi.recon-status-dust,
.recon-status-pill.recon-status-multi.recon-status-group {
  border-color: var(--border-strong);
  background: color-mix(in srgb, var(--muted-foreground) 10%, transparent);
  color: var(--muted-foreground);
}
.recon-status-tag {
  margin-left: 2px;
  font-size: 9px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

/* Status cell of a row with a match explanation: the pill, then the (?)
   match hint (components/hint.js), on one line. */
.recon-status-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
/* Match-hint body. hint.css owns the surface and the .tip-* blocks; these
   are the table-specific bits: lot labels wrap (they can be long), the
   figures sit right with their source beneath, reasons read as a list. */
.hint-tip .tip-rows.recon-mh-lots {
  grid-template-columns: minmax(0, 1fr) auto;
}
.hint-tip .recon-mh-lots .tip-row .k {
  white-space: normal;
  overflow-wrap: anywhere;
  color: var(--foreground);
}
.hint-tip .recon-mh-lots .tip-row > span:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.hint-tip .recon-mh-prov {
  display: block;
  font-size: 10px;
  color: var(--muted-foreground);
}
.hint-tip .recon-mh-reason {
  position: relative;
  padding-left: 10px;
}
.hint-tip .recon-mh-reason::before {
  content: "\00B7";
  position: absolute;
  left: 2px;
  color: var(--muted-foreground);
}
.hint-tip .recon-mh-warn {
  margin-top: 6px;
  color: var(--loss);
}
.hint-tip .recon-mh-more {
  margin-top: 4px;
  color: var(--muted-foreground);
}
/* The row's own Spartan figure under its lots, ruled off from them, and
   the sentence on why it differs from the lots' total. */
.hint-tip .tip-rows.recon-mh-total {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}
.hint-tip .recon-mh-note {
  margin-top: 4px;
  color: var(--muted-foreground);
}

.recon-kind {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  background: var(--bg);
  color: var(--text-soft);
  border: 1px solid var(--border);
}

.recon-acct-type {
  display: inline-block;
  padding: 1px 6px;
  margin-left: 6px;
  font-size: 11px;
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-soft);
  border: 1px solid var(--border);
  font-family: var(--font-mono, monospace);
}

.recon-symbol {
  font-family: var(--font-mono, monospace);
  font-weight: 500;
  color: var(--text);
}

/* ── Section-divider rows (Sub Total / Grand Total) ───────────────── */
/* Each divider renders as three stacked rows (Formidium / DB / Δ) that
   share a single outer border so they read as one grouped block. */

.recon-row-divider td {
  background: color-mix(in srgb, var(--accent) 5%, var(--bg));
  padding: 4px 10px;
  font-size: 12px;
  border-top: 0;
  border-bottom: 0;
}
.recon-row-divider-gt td {
  border-top: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  padding-top: 6px;
}
.recon-row-divider-delta td {
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  padding-bottom: 6px;
}
.recon-row-divider-db td,
.recon-row-divider-delta td {
  background: color-mix(in srgb, var(--accent) 3%, var(--bg));
}
.recon-row-divider:hover td {
  background: color-mix(in srgb, var(--accent) 8%, var(--bg)) !important;
}

/* Side-tint the GT (Formidium) and DB (Spartan) sub-rows of each
   divider so the three-row block reads as Formidium-then-DB-then-Δ
   without needing to read the row labels. Composes the side tint over
   the existing accent stripe so both signals are visible. */
.recon-report-table .recon-row-divider.recon-row-divider-gt td {
  background: color-mix(in srgb, #3b82f6 6%, color-mix(in srgb, var(--accent) 5%, var(--background)));
}
.recon-report-table .recon-row-divider.recon-row-divider-db td {
  background: color-mix(in srgb, var(--foreground) 4%, color-mix(in srgb, var(--accent) 3%, var(--background)));
}
.recon-report-table .recon-row-total.recon-row-divider-gt td {
  background: color-mix(in srgb, #3b82f6 8%, color-mix(in srgb, var(--accent) 9%, var(--background)));
}
.recon-report-table .recon-row-total.recon-row-divider-db td {
  background: color-mix(in srgb, var(--foreground) 5%, color-mix(in srgb, var(--accent) 7%, var(--background)));
}
.recon-divider-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-soft);
}
.recon-divider-sublabel {
  font-size: 11px;
  letter-spacing: 0.04em;
  font-weight: 500;
  color: var(--text-soft);
  padding-left: 12px;
}
.recon-row-total td {
  background: color-mix(in srgb, var(--accent) 9%, var(--bg));
  font-weight: 600;
}
.recon-row-total.recon-row-divider-gt td {
  border-top: 2px solid var(--accent);
}
.recon-row-total.recon-row-divider-delta td {
  border-bottom: 2px solid var(--accent);
}
.recon-row-total.recon-row-divider-db td,
.recon-row-total.recon-row-divider-delta td {
  background: color-mix(in srgb, var(--accent) 7%, var(--bg));
}
.recon-row-total .recon-divider-label {
  color: var(--text);
  font-weight: 700;
}
.recon-row-divider .num .muted {
  margin-right: 4px;
}
.recon-row-divider .is-negative {
  color: var(--danger);
}

/* Running $-impact footer injected ahead of each Sub Total / Grand Total.
   Sits visually attached to the divider block below it — a lighter tint than
   the divider so it reads as a lead-in, with the net (signed) + abs (gross)
   sums aligned under the Spartan $ / $-impact columns. */
.recon-row-impact td {
  background: color-mix(in srgb, var(--accent) 2%, var(--bg));
  padding: 3px 10px;
  border-top: 1px dashed color-mix(in srgb, var(--accent) 22%, var(--border));
  border-bottom: 0;
}
.recon-row-impact-grand td {
  background: color-mix(in srgb, var(--accent) 4%, var(--bg));
  border-top: 1px dashed color-mix(in srgb, var(--accent) 35%, var(--border));
}
.recon-row-impact:hover td {
  background: color-mix(in srgb, var(--accent) 6%, var(--bg)) !important;
}
.recon-impact-label {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-soft);
}
.recon-row-impact-grand .recon-impact-label {
  color: var(--text);
  font-weight: 700;
}
.recon-row-impact .num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.recon-row-impact .num .muted {
  margin-right: 3px;
}
.recon-impact-net.is-positive { color: var(--profit); font-weight: 600; }
.recon-impact-net.is-negative { color: var(--loss); font-weight: 600; }
.recon-impact-abs { color: var(--text-soft); }

@media (min-width: 720px) {
  .recon-upload {
    grid-template-columns: 2fr 1fr;
    align-items: stretch;
  }
  .recon-upload-meta {
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
  }
}

/* ──────────────────────────────────────────────────────────────────
   Projections sub-view — user-editable monthly synthetic balance
   sheets. One card per snapshot date; locked Positions row +
   editable Other-assets and per-line Liabilities rows.
   ────────────────────────────────────────────────────────────────── */

.proj-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.proj-toolbar #proj-baseline-status {
  flex: 1;
}

.proj-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 14px;
}
.proj-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.proj-card.is-dirty {
  border-color: color-mix(in srgb, var(--chart-3) 55%, var(--border));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--chart-3) 40%, transparent);
}

/* Card header — date + badges on the left, three rollup totals on the
   right. Wraps gracefully on narrow viewports. */
.proj-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  flex-wrap: wrap;
}
.proj-card-headline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.proj-card-date {
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.proj-card-totals {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.proj-total {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.proj-total > span:last-child {
  font-size: 15px;
  font-weight: 500;
  color: var(--foreground);
}
.proj-total-capital > span:last-child {
  font-size: 18px;
  font-weight: 700;
  color: var(--foreground);
}
.proj-total em {
  font-style: normal;
  color: var(--otc-cyan);
}

/* Source badges — chip-style, color-coded so the operator can scan
   a list of cards and instantly see which are admin-confirmed vs
   synthesized vs operator-modelled. The three colors map to the
   theme tokens whose semantics already match this taxonomy:
     • --profit   (green)  — admin-confirmed historical sheet
     • --otc-cyan (cyan)   — design-system "projected/simulated"
                              (literally what this badge means)
     • --chart-3  (amber)  — speculative / operator what-if
   All three are theme-aware (different hex per light/dark) so the
   chip retains contrast in both modes. */
.proj-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted-foreground);
}
.proj-badge-historical {
  color: var(--profit);
  border-color: color-mix(in srgb, var(--profit) 50%, var(--border));
  background: color-mix(in srgb, var(--profit) 12%, var(--surface-2));
}
.proj-badge-projected {
  color: var(--otc-cyan);
  border-color: color-mix(in srgb, var(--otc-cyan) 50%, var(--border));
  background: color-mix(in srgb, var(--otc-cyan) 12%, var(--surface-2));
}
.proj-badge-speculative {
  color: var(--chart-3);
  border-color: color-mix(in srgb, var(--chart-3) 50%, var(--border));
  background: color-mix(in srgb, var(--chart-3) 12%, var(--surface-2));
}
.proj-modified-dot,
.proj-dirty-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.proj-modified-dot { background: var(--otc-cyan); }
.proj-dirty-dot {
  background: var(--chart-3);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--chart-3) 25%, transparent);
}

/* Sections — Assets / Liabilities — each gets its own table. */
.proj-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.proj-section-title {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  display: flex;
  align-items: center;
  gap: 8px;
}
.proj-add-liab {
  margin-left: auto;
  font-size: 12px;
  padding: 2px 8px;
}

.proj-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  /* Fixed layout so the Assets and Liabilities tables on the same
     card share identical column geometry. Without this each table
     would size from its own content and the Default / Override /
     Value columns would drift apart. */
  table-layout: fixed;
}
/* Column widths — applied to every .proj-table so the two tables on
   a card line up vertically. Order: Line item (flex) · Default · Override ·
   Units (ccy picker + amount) · Value (USD) · Actions. The Units column is
   the widest — it holds a compact currency input, the amount field and the
   effective-from date (60 + 96..150 + 128 + gaps), so it must stay >= ~366px
   or the amount field collapses to nothing. */
.proj-table th:nth-child(1),
.proj-table td:nth-child(1) { width: auto; }
.proj-table th:nth-child(2),
.proj-table td:nth-child(2) { width: 120px; }
.proj-table th:nth-child(3),
.proj-table td:nth-child(3) { width: 76px; }
.proj-table th:nth-child(4),
.proj-table td:nth-child(4) { width: 370px; }
.proj-table th:nth-child(5),
.proj-table td:nth-child(5) { width: 130px; }
.proj-table th:nth-child(6),
.proj-table td:nth-child(6) { width: 84px; }
.proj-table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  font-weight: 500;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.proj-table th.num { text-align: right; }
.proj-table th.proj-col-override,
.proj-table th.proj-col-actions { text-align: center; }
.proj-table th.proj-col-units { text-align: right; }
.proj-table td {
  padding: 8px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}
.proj-table td.num { text-align: right; }
.proj-table td.proj-col-override,
.proj-table td.proj-col-actions { text-align: center; }
.proj-row:last-child td { border-bottom: none; }
.proj-row-locked td {
  background: color-mix(in srgb, var(--surface-2) 60%, transparent);
}
.proj-row-locked .proj-line-label {
  font-weight: 500;
}
.proj-row.is-overridden td {
  background: color-mix(in srgb, var(--otc-cyan) 6%, transparent);
}
.proj-row.is-overridden .proj-line-label {
  font-weight: 600;
}
/* Zeroed lines (operator clicked the X to exclude from totals) get
   strikethrough on the label, the amount input, and the Value (USD) cell.
   The row stays visible — strikethrough is the cue that the line exists but
   contributes 0 to the rollup. The held-flat Default column is left intact
   so the baseline the line WOULD carry stays readable. Reset (↺) restores
   the default. */
.proj-row.is-zeroed .proj-line-label,
.proj-row.is-zeroed .proj-value-input,
.proj-row.is-zeroed .proj-value-usd {
  text-decoration: line-through;
  color: var(--muted-foreground);
}
.proj-line-label { color: var(--foreground); }
.proj-line-sub {
  display: inline-block;
  margin-left: 6px;
}

/* Units cell — the per-line denomination picker (compact currency input)
   sitting flush-left of the amount input. Both share the cell so changing
   the token and the units reads as one control. */
.proj-units-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}
.proj-value-input {
  flex: 1 1 auto;
  min-width: 96px;
  max-width: 150px;
  padding: 5px 8px;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--foreground);
  font: inherit;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.proj-value-input:disabled {
  background: transparent;
  border-color: transparent;
  color: var(--muted-foreground);
}
.proj-value-input:focus,
.proj-ccy-input:focus {
  outline: none;
  border-color: var(--otc-cyan);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--otc-cyan) 25%, transparent);
}
/* Compact denomination input (USD / a token ticker). Free-text + a shared
   <datalist> of common currencies. Disabled (and visually recessed) until
   the row's override is toggled on. */
.proj-ccy-input {
  flex: 0 0 60px;
  width: 60px;
  padding: 5px 6px;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--foreground);
  font: inherit;
  text-transform: uppercase;
  text-align: center;
  letter-spacing: 0.02em;
}
.proj-ccy-input:disabled {
  background: transparent;
  border-color: transparent;
  color: var(--muted-foreground);
}
/* Effective-from date of an override (see reconciliation-projections.js
   fieldFrom). Same recessed-when-disabled treatment as the ccy input. */
.proj-from-input {
  flex: 0 0 128px;
  width: 128px;
  padding: 4px 6px;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--foreground);
  font: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.proj-from-input:disabled {
  background: transparent;
  border-color: transparent;
  color: var(--muted-foreground);
}
.proj-from-input:focus {
  outline: none;
  border-color: var(--otc-cyan);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--otc-cyan) 25%, transparent);
}
/* A saved override whose window starts after the sheet's as-of date. */
.proj-sched-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px dashed var(--border);
  color: var(--muted-foreground);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
}
/* Computed Value (USD) cell + its live token-price hint. */
.proj-value-usd { font-weight: 500; }
.proj-px-hint {
  color: var(--muted-foreground);
  font-size: 11px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.proj-override-toggle {
  display: inline-flex;
  cursor: pointer;
}
.proj-override-toggle input { cursor: pointer; }

/* "Liable for last month's fees" toggle on the Accrued Management Fee
   row. Sits under the line label as its own control block, so the
   carry-forward decision reads as a distinct affordance rather than a
   generic override. */
.proj-mgmt-liable {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--foreground);
  user-select: none;
}
.proj-mgmt-liable input { cursor: pointer; margin: 0; }
/* When the line is reset to $0 the row carries .is-zeroed (strikethrough
   on the label / value); keep the toggle's own text upright + legible so
   the control stays readable. */
.proj-row-mgmt-fee.is-zeroed .proj-mgmt-liable,
.proj-row-mgmt-fee.is-zeroed .proj-mgmt-hint {
  text-decoration: none;
  color: var(--muted-foreground);
}
.proj-mgmt-hint {
  display: block;
  margin-left: 0;
  margin-top: 3px;
}

/* Shared icon-button skeleton for the X (zero) and ↺ (reset) buttons
   that share each editable row's actions cell. Kept compact so two
   buttons fit comfortably side by side. */
.proj-reset,
.proj-zero {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  vertical-align: middle;
}
.proj-reset:not(:disabled):hover {
  background: var(--surface-2);
  color: var(--foreground);
  border-color: var(--border);
}
/* X-zero hover hints destructive-ish "this excludes the line" — use
   the loss token for the icon so the operator reads "subtract" not
   "delete forever". */
.proj-zero:not(:disabled):hover {
  background: color-mix(in srgb, var(--loss) 12%, var(--surface-2));
  color: var(--loss);
  border-color: color-mix(in srgb, var(--loss) 40%, var(--border));
}
.proj-reset:disabled,
.proj-zero:disabled { opacity: 0.3; cursor: not-allowed; }
.proj-reset svg,
.proj-zero svg { width: 14px; height: 14px; }
/* Sit the two buttons flush; the 86px column accommodates both. */
.proj-col-actions .proj-zero + .proj-reset,
.proj-col-actions .proj-reset + .proj-zero { margin-left: 2px; }

.proj-notes {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.proj-notes textarea {
  width: 100%;
  padding: 8px 10px;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--foreground);
  font: inherit;
  resize: vertical;
}
.proj-notes textarea:focus {
  outline: none;
  border-color: var(--otc-cyan);
}

.proj-card-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
}

/* ── Speculative-month dialog ─────────────────────────────────────── */
.proj-dialog-backdrop {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--background) 70%, transparent);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.proj-dialog-backdrop[hidden] { display: none; }
.proj-dialog {
  width: 100%;
  max-width: 440px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 18px 40px color-mix(in srgb, var(--background) 60%, transparent);
}
.proj-dialog-title {
  font-size: 16px;
  font-weight: 600;
}
.proj-dialog-help {
  margin: -4px 0 0;
}
.proj-dialog .field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.proj-dialog .field input,
.proj-dialog .field textarea {
  padding: 8px 10px;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--foreground);
  font: inherit;
}
.proj-dialog .field input:focus,
.proj-dialog .field textarea:focus {
  outline: none;
  border-color: var(--otc-cyan);
}
.proj-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

/* ── SP_BTC package (Balance sheet view) ──────────────────────────── */
/* The BTC feeder package's dry run and apply. Real tokens only (see the
   traffic-light note above): --profit / --loss / amber for tone. */

#recon-bs-upload-status.is-ok,
#recon-btcpkg-status.is-ok    { color: var(--profit); }
#recon-bs-upload-status.is-error,
#recon-btcpkg-status.is-error { color: var(--loss); }

.recon-btcpkg-banner {
  margin-bottom: 14px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--profit) 55%, var(--border));
  background: color-mix(in srgb, var(--profit) 8%, transparent);
  font-size: 13px;
  line-height: 1.5;
}
.recon-btcpkg-banner.is-warn {
  border-color: color-mix(in srgb, #f59e0b 60%, var(--border));
  background: color-mix(in srgb, #f59e0b 10%, transparent);
}
.recon-btcpkg-banner.is-error {
  border-color: color-mix(in srgb, var(--loss) 60%, var(--border));
  background: color-mix(in srgb, var(--loss) 8%, transparent);
}
.recon-btcpkg-banner ul {
  margin: 4px 0 0;
  padding-left: 18px;
}
.recon-btcpkg-banner .recon-btcpkg-banner-title {
  font-weight: 600;
}

.recon-btcpkg-section {
  margin-top: 14px;
}
.recon-btcpkg-section-title {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  margin-bottom: 6px;
}
.recon-btcpkg-checks {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
}
.recon-btcpkg-checks li.is-flag { color: #f59e0b; }
.recon-btcpkg-checks li.is-error { color: var(--loss); }

.recon-btcpkg-kv {
  display: grid;
  grid-template-columns: minmax(160px, max-content) 1fr;
  gap: 4px 16px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.recon-btcpkg-kv dt { color: var(--muted-foreground); }
.recon-btcpkg-kv dd { margin: 0; }
.recon-btcpkg-kv .recon-btcpkg-strong { font-weight: 600; }

.recon-btcpkg-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}
.recon-btcpkg-actions label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.recon-btcpkg-text {
  margin-top: 14px;
}
.recon-btcpkg-text pre {
  margin: 8px 0 0;
  padding: 10px 12px;
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-elevated);
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  line-height: 1.45;
  white-space: pre;
}

.recon-report-table tr.recon-btcpkg-class td {
  font-weight: 600;
  border-top: 1px solid var(--border);
}
#recon-btcpkg-table td.num {
  white-space: nowrap;
}

@media (max-width: 640px) {
  .recon-btcpkg-kv { grid-template-columns: 1fr; }
  .recon-btcpkg-kv dd { margin-bottom: 6px; }
}
