/* Accounting (purchasing audit trail) — mirrors Cash Flow's shell + header so
   the two sibling internal apps feel like one product. The audit-trail-specific
   styles (timeline list, Ramp inbox, tie-out widget) follow below. */

/* ── Shell ────────────────────────────────────────────────────────── */
.app-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6) var(--space-16);
}

/* Shared chrome (header / auth gate / toolbar / panel / pills / timeline)
   lives in /design-system/hive-chrome.css — only app-specific overrides here. */
.toolbar input[type="search"] { min-width: 240px; }

/* ── PO list (audit-trail default view) ───────────────────────────── */
.po-list { background: var(--n-0); border: 1px solid var(--n-200); border-radius: var(--radius-lg); overflow: hidden; }
.po-list__row {
  display: grid;
  grid-template-columns: 130px 1fr 88px 112px 116px 116px 122px;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--n-100);
  align-items: center;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-standard);
}
.po-list__row:last-child { border-bottom: 0; }
.po-list__row:hover { background: var(--bg-subtle); }
.po-list__row.is-open { background: var(--bg-subtle); }
.po-list__header {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--n-500);
  background: var(--bg-subtle); cursor: default;
}
.po-list__header:hover { background: var(--bg-subtle); }
.po-list__po { font-family: var(--font-mono); font-size: 13px; color: var(--n-700); font-weight: 600; }
.po-list__vendor { font-size: 14px; color: var(--fg-1); }
.po-list__amt { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--fg-1); text-align: right; }
.po-list__totals { font-weight: 700; background: var(--bg-subtle); border-top: 2px solid var(--n-300); cursor: default; }
.po-list__totals:hover { background: var(--bg-subtle); }
.po-list__totals .po-list__amt { color: var(--fg-0); font-weight: 700; font-size: 13px; }
.po-list__status {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--n-600);
  text-align: right;
}

/* ── Side panel (timeline drawer) ─────────────────────────────────── */
.panel {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(640px, 96vw);
  background: var(--n-0); border-left: 1px solid var(--n-200); box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform var(--dur-base) var(--ease-standard);
  z-index: 50; display: flex; flex-direction: column; overflow-y: auto;
}
.panel__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); padding: var(--space-5) var(--space-5) var(--space-3); border-bottom: 1px solid var(--n-200); position: sticky; top: 0; background: var(--n-0); z-index: 1; }
.panel h2 { font-size: 13px; font-family: var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--n-500); margin: 0 0 var(--space-3); }

.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px var(--space-3); font-size: 13px; }

/* ── Timeline ─────────────────────────────────────────────────────── */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline__row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--n-100);
}
.timeline__row:last-child { border-bottom: 0; }
.timeline__when {
  font-family: var(--font-mono); font-size: 11px; color: var(--n-500);
  letter-spacing: 0.02em;
}
.timeline__what { font-size: 13px; color: var(--fg-1); }
.timeline__what strong { font-weight: 600; }
.timeline__ids {
  font-family: var(--font-mono); font-size: 10px; color: var(--n-500);
  margin-top: 4px; display: flex; flex-wrap: wrap; gap: var(--space-2);
}
.timeline__ids code { background: var(--n-100); padding: 1px 5px; border-radius: var(--radius-sm); }
.timeline__je {
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-subtle);
  border-left: 2px solid var(--n-300);
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.timeline__je-line {
  display: flex; gap: var(--space-3);
  font-variant-numeric: tabular-nums;
}
.timeline__je-account { color: var(--n-600); min-width: 90px; }
.timeline__je-name    { color: var(--n-700); flex: 1; }
.timeline__je-dr, .timeline__je-cr { font-family: var(--font-mono); }
.timeline__je-dr { color: #065f46; }
.timeline__je-cr { color: #991b1b; }

/* Event-type pill: distinguishes Ramp / Inflow / QBO / manual sources at a glance. */
.event-pill {
  display: inline-block;
  font-family: var(--font-mono); font-size: 10px; font-weight: 600; letter-spacing: 0.04em;
  padding: 2px 7px; border-radius: var(--radius-pill);
  margin-right: var(--space-2);
  border: 1px solid transparent;
}
.event-pill.src-ramp    { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.event-pill.src-inflow  { background: #eff6ff; color: #1e3a8a; border-color: #bfdbfe; }
.event-pill.src-qbo     { background: #fef3c7; color: #92400e; border-color: #fcd9a3; }
.event-pill.src-manual  { background: var(--n-100); color: var(--n-700); border-color: var(--n-200); }
.event-pill.src-n8n     { background: var(--n-100); color: var(--n-600); border-color: var(--n-200); }
.event-pill.je-posted   { background: var(--success-soft); color: #065f46; border-color: #a7f3d0; }
.event-pill.je-pending  { background: var(--warning-soft); color: #92400e; border-color: #fcd9a3; }

/* ── Ramp Inbox view ──────────────────────────────────────────────── */
.inbox { max-width: 920px; }
.inbox .lead { color: var(--n-600); font-size: 14px; margin: 0 0 var(--space-5); }
.inbox table { width: 100%; border-collapse: collapse; font-size: 13px; }
.inbox th { text-align: left; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--n-500); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--n-200); }
.inbox td { padding: var(--space-3); border-bottom: 1px solid var(--n-100); color: var(--fg-1); vertical-align: middle; }
.inbox td.num { text-align: right; font-variant-numeric: tabular-nums; }
.inbox select {
  font: inherit; font-size: 12px; padding: 4px 6px;
  border: 1px solid var(--n-300); border-radius: var(--radius-sm); background: var(--n-0);
  min-width: 200px;
}

/* ── Tie-out view ─────────────────────────────────────────────────── */
.tieout { max-width: 720px; }
.tieout .lead { color: var(--n-600); font-size: 14px; margin: 0 0 var(--space-5); }
.tieout__card {
  background: var(--n-0); border: 1px solid var(--n-200); border-radius: var(--radius-lg);
  padding: var(--space-5); margin-bottom: var(--space-5);
}
.tieout__row { display: flex; justify-content: space-between; padding: var(--space-2) 0; border-bottom: 1px solid var(--n-100); }
.tieout__row:last-child { border-bottom: 0; }
.tieout__row span:first-child { color: var(--n-600); }
.tieout__row span:last-child  { font-variant-numeric: tabular-nums; font-weight: 600; }
.tieout__variance { font-size: 18px; }
.tieout__variance.ok    { color: #065f46; }
.tieout__variance.bad   { color: #991b1b; }
.tieout input[type="number"] {
  font: inherit; font-size: 14px; padding: 4px 8px;
  border: 1px solid var(--n-300); border-radius: var(--radius-sm); background: var(--n-0);
  text-align: right; width: 140px; font-variant-numeric: tabular-nums;
}
.tieout details {
  margin-top: var(--space-4);
  background: var(--bg-subtle); border: 1px solid var(--n-200);
  border-radius: var(--radius-md); padding: var(--space-3);
}
.tieout details summary { font-size: 13px; color: var(--n-700); cursor: pointer; font-weight: 600; }
.tieout details pre {
  margin: var(--space-3) 0 0;
  font-family: var(--font-mono); font-size: 12px;
  background: var(--n-0); border: 1px solid var(--n-200); border-radius: var(--radius-sm);
  padding: var(--space-3); overflow-x: auto;
}

/* ── SO Ledger balance cards (click to filter the table) ──────────── */
.so-card { flex: 1; border: 1px solid var(--n-200); border-radius: 8px; padding: var(--space-3) var(--space-4); cursor: pointer; transition: border-color var(--dur-fast) var(--ease-standard), background var(--dur-fast) var(--ease-standard); }
.so-card:hover { background: var(--bg-subtle); }
.so-card.is-active { border-color: var(--n-900); background: var(--bg-subtle); box-shadow: inset 0 0 0 1px var(--n-900); }

/* ── Revenue ledger (rev-rec audit trail) ─────────────────────────── */
.rev-key { margin-bottom: var(--space-4); background: var(--bg-subtle); border: 1px solid var(--n-200); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); }
.rev-key summary { font-size: 12px; color: var(--n-600); cursor: pointer; font-weight: 600; }
.rev-key table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: var(--space-2); }
.rev-key td { padding: var(--space-2) var(--space-3) var(--space-2) 0; border-bottom: 1px solid var(--n-100); vertical-align: top; }
.rev-key tr:last-child td { border-bottom: 0; }
.rev-key td:first-child { white-space: nowrap; }
.rev-key code { font-family: var(--font-mono); font-size: 11px; background: var(--n-100); padding: 1px 4px; border-radius: var(--radius-sm); }
.rev table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rev th { text-align: left; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--n-500); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--n-200); }
.rev td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--n-100); color: var(--fg-1); vertical-align: middle; }
.rev th.num, .rev td.num { text-align: right; font-variant-numeric: tabular-nums; }
.rev tbody tr { cursor: pointer; }
.rev tbody tr:hover, .rev tbody tr.is-open { background: var(--bg-subtle); }
.rev tr.rev__totals { font-weight: 700; background: var(--bg-subtle); cursor: default; }
.rev tr.rev__totals td { border-top: 2px solid var(--n-300); }

.btn { background: var(--n-900); color: var(--n-0); border: 0; border-radius: var(--radius-md); padding: 6px 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.btn--ghost { background: transparent; color: var(--n-700); border: 1px solid var(--n-300); }
.btn--ghost:hover { background: var(--n-100); }
