/* Engage Command Centre — design tokens (per Design.md §4) */
:root {
  --bg: #EFEDE5;
  --surface: #FFFFFF;
  --surface-2: #E8E6DD;
  --surface-3: #DEDCD3;
  --border: oklch(0.92 0.004 90);
  --border-strong: oklch(0.86 0.005 90);

  --text: oklch(0.20 0.01 80);
  --text-2: oklch(0.45 0.01 80);
  --text-3: oklch(0.62 0.008 80);
  --text-inv: #FAFAF7;

  /* Evergreen accent — default per Design.md */
  --accent: oklch(0.42 0.09 165);
  --accent-2: oklch(0.55 0.13 165);
  --accent-tint: oklch(0.96 0.025 165);
  --accent-ink: oklch(0.30 0.07 165);

  --warn: oklch(0.72 0.14 70);
  --warn-tint: oklch(0.96 0.04 75);
  --danger: oklch(0.58 0.18 25);
  --danger-tint: oklch(0.96 0.03 25);
  --ok: oklch(0.62 0.13 155);
  --ok-tint: oklch(0.96 0.04 155);
  --info: oklch(0.58 0.12 245);
  --info-tint: oklch(0.96 0.03 245);
  --pending: oklch(0.55 0.10 290);
  --pending-tint: oklch(0.96 0.03 290);

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --shadow-sm: 0 1px 0 oklch(0.85 0.005 80 / 0.4);
  --shadow: 0 1px 2px rgba(20,20,15,0.04), 0 4px 16px rgba(20,20,15,0.04);
  --shadow-lg: 0 8px 24px rgba(20,20,15,0.08), 0 2px 4px rgba(20,20,15,0.04);

  --font: "Geist", -apple-system, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "Geist Mono", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
}
button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: inherit; }

.num, .mono { font-family: var(--mono); font-feature-settings: "tnum"; letter-spacing: -0.01em; }
.tnum { font-variant-numeric: tabular-nums; }

/* Shell layout */
.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  height: 100vh;
  background: var(--bg);
}
.app.collapsed { grid-template-columns: 72px 1fr; }
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.content {
  flex: 1;
  overflow: auto;
  padding: 32px 40px 64px;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 24px; }
.card-pad-sm { padding: 16px; }

.section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0 0 12px;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:disabled:hover { background: var(--surface); border-color: var(--border-strong); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }

/* Decision buttons — used on the approvals page so approve/reject don't
   fade into the background. Tint variants are the resting state (subtle
   wash + matching text colour); the solid variants are used once the user
   has picked a decision or is about to confirm. */
.btn-ok-tint        { background: var(--ok-tint);     color: var(--ok);     border-color: transparent; }
.btn-ok-tint:hover  { background: oklch(0.92 0.06 155); border-color: var(--ok); }
.btn-ok             { background: var(--ok);          color: #fff;          border-color: var(--ok); }
.btn-ok:hover       { background: oklch(0.55 0.13 155); border-color: oklch(0.55 0.13 155); }

.btn-danger-tint        { background: var(--danger-tint); color: var(--danger); border-color: transparent; }
.btn-danger-tint:hover  { background: oklch(0.92 0.05 25);  border-color: var(--danger); }
.btn-danger             { background: var(--danger);  color: #fff;             border-color: var(--danger); }
.btn-danger:hover       { background: oklch(0.50 0.18 25); border-color: oklch(0.50 0.18 25); }

.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-icon { padding: 7px; width: 32px; justify-content: center; }

/* ----- Payout-flow (React Flow viewer on the charge-group detail page) ----- */
.payout-flow-canvas {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: oklch(0.97 0.003 80);
}
.payout-flow-canvas .react-flow__handle {
  width: 8px; height: 8px;
  background: var(--accent);
  border: 2px solid var(--surface);
}
.payout-flow-canvas .react-flow__edge-path {
  stroke-width: 1.5;
}

.pf-node {
  width: 220px;
  border-radius: var(--r-lg);
  font-family: var(--font);
  user-select: none;
  box-shadow: 0 1px 2px rgba(20,20,15,0.04), 0 4px 12px rgba(20,20,15,0.04);
}
.pf-node .pf-lbl   { font-size: 10.5px; color: var(--text-3); letter-spacing: 0.06em; text-transform: uppercase; font-weight: 500; }
.pf-node .pf-name  { font-size: 14px; font-weight: 600; margin-top: 4px; line-height: 1.25; }
.pf-node .pf-sub   { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }
.pf-node .pf-entity{ font-size: 11px; color: var(--text-3); margin-top: 1px;
                     overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pf-node--trunk {
  padding: 18px 20px;
  background: var(--accent); color: #fff;
  text-align: center;
  box-shadow: 0 6px 24px oklch(0.42 0.09 165 / 0.18);
}
.pf-node--trunk .pf-lbl { color: rgba(255,255,255,0.78); }
.pf-node--trunk .pf-name { font-size: 16px; }
.pf-node--trunk .pf-sub { color: rgba(255,255,255,0.82); font-family: var(--mono); font-feature-settings: "tnum"; }

.pf-node--leaf {
  padding: 12px 14px 18px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;     /* clip the magnitude bar to border-radius */
}
.pf-node--leaf .pf-head    { display: flex; align-items: center; gap: 10px; }
.pf-node--leaf .pf-swatch  { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.pf-node--leaf .pf-name    { font-size: 13.5px; margin: 0;
                             overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.pf-node--leaf .pf-stats   { display: flex; justify-content: space-between; align-items: baseline;
                             margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); }
.pf-node--leaf .pf-pct     { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.pf-node--leaf .pf-rand    { font-family: var(--mono); font-size: 13.5px; font-weight: 500; }
.pf-node--leaf .pf-flag    { font-size: 10px; margin-top: 4px; font-weight: 500;
                             text-transform: uppercase; letter-spacing: 0.04em; }
.pf-node--leaf .pf-flag--residual { color: var(--accent-ink); }
.pf-node--leaf .pf-flag--presplit { color: oklch(0.45 0.13 70); }
.pf-node--residual { border-color: var(--accent); }
.pf-node--presplit { background: var(--warn-tint); border-color: transparent; }

.pf-node--leaf .pf-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 5px;
  background: var(--surface-2);
}
.pf-node--leaf .pf-bar-fill {
  height: 100%;
  border-radius: 0 2px 2px 0;
  transition: width 0.25s ease-out;
}

/* Inputs */
.field {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 8px;
  transition: all 0.12s ease;
}
.field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px oklch(0.42 0.09 165 / 0.12);
}
.field input, .field select {
  border: 0; outline: 0; background: transparent;
  flex: 1; min-width: 0;
}

/* Pills */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-ok { background: var(--ok-tint); color: var(--ok); border-color: transparent; }
.pill-warn { background: var(--warn-tint); color: oklch(0.45 0.13 70); border-color: transparent; }
.pill-danger { background: var(--danger-tint); color: var(--danger); border-color: transparent; }
.pill-info { background: var(--info-tint); color: var(--info); border-color: transparent; }
.pill-pending { background: var(--pending-tint); color: var(--pending); border-color: transparent; }
.pill-accent { background: var(--accent-tint); color: var(--accent-ink); border-color: transparent; }

/* Headings */
h1.page {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}
h2.page {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}
.crumbs {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px;
  color: var(--text-3);
  margin-bottom: 4px;
}

/* Layout helpers */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; }
.gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-20 { gap: 20px; }
.gap-24 { gap: 24px; }
.between { justify-content: space-between; }
.right { justify-content: flex-end; }
.grow { flex: 1; }
.muted { color: var(--text-2); }
.muted-2 { color: var(--text-3); }

/* Key-value list (label / value pairs in detail + review views) */
.kv {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 10px 16px;
  font-size: 13.5px;
}
.kv dt { color: var(--text-3); font-weight: 500; }
.kv dd { margin: 0; }

/* Command palette (Cmd-K) */
.cmdk-back {
  position: fixed; inset: 0;
  background: oklch(0.20 0.01 80 / 0.36);
  backdrop-filter: blur(4px);
  z-index: 100;
  animation: fadeIn 0.14s ease both;
}
.cmdk {
  position: fixed; top: 88px; left: 50%; transform: translateX(-50%);
  width: 560px; max-width: calc(100vw - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: 0 12px 40px rgba(20,20,15,0.18), 0 2px 8px rgba(20,20,15,0.08);
  z-index: 101;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: cmdkIn 0.18s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes cmdkIn {
  from { opacity: 0; transform: translate(-50%, -4px); }
  to   { opacity: 1; transform: translate(-50%, 0);    }
}
.cmdk-search {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-3);
}
.cmdk-search input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font-family: inherit; font-size: 15px; color: var(--text);
}
.cmdk-body {
  flex: 1; overflow-y: auto;
  padding: 6px 0 10px;
  max-height: calc(100vh - 280px);
}
.cmdk-section-title {
  font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-3);
  padding: 12px 16px 6px;
}
.cmdk-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px;
  margin: 0 6px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
  transition: background 0.08s;
}
.cmdk-item[data-selected] { background: var(--accent-tint); }
.cmdk-item-name { font-weight: 500; color: var(--text); }
.cmdk-item[data-selected] .cmdk-item-name { color: var(--accent-ink); }
.cmdk-item-meta {
  font-size: 11.5px; color: var(--text-3); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cmdk-empty {
  padding: 32px 16px; text-align: center;
  font-size: 13px; color: var(--text-3);
}
.cmdk-foot {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 11px; color: var(--text-3);
  display: flex; align-items: center; gap: 16px;
}
.cmdk-foot > span { display: inline-flex; align-items: center; gap: 4px; }
.cmdk-kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-2);
  line-height: 1;
}

/* Scrollbar */
.content::-webkit-scrollbar { width: 10px; height: 10px; }
.content::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid var(--bg); }
.content::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.fade-in { animation: fadeIn 0.18s ease both; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Live status pulse — used on integration health indicators */
@keyframes pulse-ok {
  0%, 100% { box-shadow: 0 0 0 0 oklch(0.62 0.13 155 / 0.45); }
  50%      { box-shadow: 0 0 0 6px oklch(0.62 0.13 155 / 0); }
}
.pulse-ok { animation: pulse-ok 2s ease-in-out infinite; }

/* Avatar */
.avatar {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

/* Print styles — used by the wallet statement view ("Print / save PDF"
   button). Sales-report PDFs are generated server-side via Puppeteer; this
   block only needs to clean up the on-screen chrome for the statement. */
@media print {
  body { background: #fff; }
  .app aside, .main > header, .crumbs, .btn { display: none !important; }
  .print-hide { display: none !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; break-inside: avoid; }
}
