/* ============================================================
   LedgerBeaver Web App — v2
   Theme-aware. Uses brand.css tokens. Light + Dark.
   ============================================================ */

/* ---------- Demo banner ---------- */
.demo-banner {
  background: var(--amber);
  color: var(--on-amber);
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  text-align: center;
  display: flex; justify-content: center; align-items: center; gap: 8px;
  position: relative; z-index: 80;
}
.demo-banner span { color: var(--on-amber); }
.demo-banner a { text-decoration: underline; }
.demo-banner button {
  background: transparent; border: 1px solid currentColor;
  color: currentColor; padding: 2px 8px; border-radius: 4px;
  font-family: inherit; font-size: 11px; cursor: pointer; margin-left: 8px;
}

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.side {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.side-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.side-brand .mark {
  width: 36px; height: 36px; border-radius: 9px;
  background: var(--amber);
  display: grid; place-items: center;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--amber-deep), 0 4px 14px -4px var(--amber-glow);
  flex-shrink: 0;
}
.side-brand .mark img {
  width: 100%; height: 100%; object-fit: contain;
}
.side-brand .name {
  font-family: var(--font-display); font-weight: 700; color: var(--text-hi);
  font-size: 16px; letter-spacing: -0.01em;
}
.side-brand .name span { color: var(--amber); }

.side-grp { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--text-lo); padding: 16px 8px 6px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; color: var(--text-mid);
  font-size: 13.5px; font-weight: 500; cursor: pointer;
  transition: background .15s ease, color .15s ease;
  border: 1px solid transparent;
}
.nav-item:hover { background: var(--bg-3); color: var(--text-hi); }
.nav-item.on {
  background: var(--bg-3); color: var(--text-hi);
  border-color: var(--line-2);
}
.nav-item .badge {
  margin-left: auto; font-family: var(--font-mono); font-size: 10px;
  background: var(--amber); color: var(--on-amber);
  padding: 1px 6px; border-radius: 999px; font-weight: 700;
}
.nav-item.has-sub { align-items: center; }
.nav-item .nav-label { display: flex; flex-direction: column; line-height: 1.15; flex: 1; min-width: 0; }
.nav-item .nav-sub {
  font-family: var(--font-mono); font-size: 9.5px;
  letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--text-lo); margin-top: 2px;
}

.side-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
}
.user-card:hover { background: var(--bg-3); }
.user-card .ava {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--amber); display: grid; place-items: center;
  color: var(--on-amber); font-weight: 700; font-size: 13px;
  border: 1.5px solid var(--amber-deep);
}
.user-card .who { font-size: 13px; color: var(--text-hi); font-weight: 600; }
.user-card .role { font-size: 11px; color: var(--text-lo); font-family: var(--font-mono); }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in oklab, var(--bg-0) 86%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 10px 28px;
  display: flex; align-items: center; gap: 12px;
}

/* ---- Global search ---- */
.search {
  position: relative;
  flex: 1; max-width: 520px;
}
.search-input {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text-mid);
  font-size: 13px;
  cursor: text;
}
.search-input input {
  flex: 1; border: none; background: transparent; outline: none;
  color: var(--text-hi); font-size: 13px;
}
.search-input input::placeholder { color: var(--text-lo); }
.search-input kbd {
  font-family: var(--font-mono); font-size: 10.5px; padding: 2px 6px;
  background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 4px; color: var(--text-mid);
}
.search-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-pop);
  padding: 6px;
  z-index: 100;
}
.search-grp { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--text-lo); padding: 8px 10px 4px; }
.search-result {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
}
.search-result:hover { background: var(--bg-3); }
.search-result .pri { color: var(--text-hi); font-size: 13px; font-weight: 500; }
.search-result .sec { color: var(--text-lo); font-size: 11.5px; font-family: var(--font-mono); margin-left: auto; }

/* ---- Quick actions ---- */
.qa-bar { display: flex; gap: 6px; margin-left: 6px; }
.qa-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 10px; border-radius: 8px;
  background: transparent; border: 1px solid var(--line);
  color: var(--text); font-size: 12.5px; font-weight: 500;
}
.qa-btn:hover { background: var(--bg-3); color: var(--text-hi); border-color: var(--line-2); }
.qa-btn svg { color: var(--amber); }
@media (max-width: 1280px) { .qa-btn span:not(.qa-icon) { display: none; } .qa-btn { padding: 8px; } }

/* ---- Top icons ---- */
.top-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.top-icon {
  width: 34px; height: 34px; border-radius: 8px;
  background: transparent; border: 1px solid transparent;
  color: var(--text-mid);
  display: grid; place-items: center;
  position: relative;
}
.top-icon:hover { background: var(--bg-3); color: var(--text-hi); }
.top-icon .dot {
  position: absolute; top: 7px; right: 7px;
  width: 7px; height: 7px; border-radius: 999px; background: var(--amber);
  border: 2px solid var(--bg-0);
}
.top-icon .count {
  position: absolute; top: 2px; right: 2px;
  background: var(--amber); color: var(--on-amber);
  font-size: 10px; font-weight: 700;
  padding: 1px 5px; border-radius: 999px;
  border: 2px solid var(--bg-0);
  min-width: 17px; line-height: 1; text-align: center;
}

/* ---- Notifications dropdown ---- */
.noti-pop {
  position: absolute; top: calc(100% + 8px); right: 20px;
  width: 380px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-pop);
  z-index: 100;
  overflow: hidden;
}
.noti-head { padding: 14px 16px 10px; display: flex; justify-content: space-between; align-items: center; }
.noti-head h4 { margin: 0; font-family: var(--font-display); font-size: 16px; color: var(--text-hi); }
.noti-head a { color: var(--amber); font-size: 12px; font-weight: 600; cursor: pointer; }
.noti-body { max-height: 420px; overflow-y: auto; }
.noti-item {
  display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line);
  cursor: pointer; transition: background .12s;
}
.noti-item:hover { background: var(--bg-3); }
.noti-item .ico {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--amber-soft); color: var(--amber);
  display: grid; place-items: center; flex-shrink: 0;
}
.noti-item .ico.err { background: rgba(239,68,68,0.10); color: var(--err); }
.noti-item .ico.warn { background: rgba(251,191,36,0.10); color: var(--warn); }
.noti-item .ico.info { background: rgba(96,165,250,0.10); color: var(--info); }
.noti-item .t { color: var(--text-hi); font-size: 13px; font-weight: 600; line-height: 1.35; }
.noti-item .d { color: var(--text-mid); font-size: 12px; margin-top: 2px; line-height: 1.4; }
.noti-item time { color: var(--text-lo); font-family: var(--font-mono); font-size: 11px; flex-shrink: 0; }
.noti-foot { padding: 8px 16px; border-top: 1px solid var(--line); text-align: center; }
.noti-foot a { color: var(--text-mid); font-size: 13px; font-weight: 500; }
.noti-foot a:hover { color: var(--amber); }

/* ---- Theme/lang at top — slot ---- */
.topbar #lb-controls { margin-left: 4px; }

/* ---------- Main / screen ---------- */
.main { background: var(--bg-1); }
.screen { padding: 28px 32px 80px; max-width: 1400px; }

/* ---------- Section header ---------- */
.section-head {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 24px;
  margin-bottom: 22px;
}
.section-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 28px;
  letter-spacing: -0.02em;
  margin: 6px 0 4px;
  color: var(--text-hi);
}
.section-sub { color: var(--text-mid); font-size: 14px; max-width: 580px; }
.section-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- KPI ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.kpi {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  position: relative; overflow: hidden;
}
.kpi-l { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-lo); }
.kpi-v {
  font-family: var(--font-display); font-weight: 600;
  font-size: 26px; margin: 6px 0 4px; letter-spacing: -0.02em;
  color: var(--text-hi);
}
.kpi-d { font-size: 11px; font-family: var(--font-mono); display: inline-flex; align-items: center; gap: 4px; }
.kpi-d.up { color: var(--ok); }
.kpi-d.dn { color: var(--err); }

/* Skeleton state */
.skel {
  background: linear-gradient(90deg, var(--bg-2) 0%, var(--bg-3) 50%, var(--bg-2) 100%);
  background-size: 200% 100%;
  animation: skel 1.4s ease-in-out infinite;
  border-radius: 6px;
}
@keyframes skel { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skel.line { height: 10px; margin: 4px 0; }
.skel.title { height: 22px; width: 60%; }

/* Empty / Error state */
.state {
  padding: 56px 24px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  background: var(--bg-2); border: 1px dashed var(--line-2); border-radius: 14px;
}
.state img { margin-bottom: 16px; }
.state h4 { color: var(--text-hi); margin: 0 0 6px; font-family: var(--font-display); font-size: 18px; }
.state p  { color: var(--text-mid); font-size: 13.5px; margin: 0 0 18px; max-width: 360px; line-height: 1.5; }

/* ---------- Card / panel ---------- */
.card-row { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin: 16px 0; }
.card-row.fourup { grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 1100px) { .card-row, .card-row.fourup { grid-template-columns: 1fr; } }
.panel { padding: 18px 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.panel-title { font-family: var(--font-display); font-weight: 600; font-size: 18px; margin: 4px 0 0; color: var(--text-hi); letter-spacing: -0.01em; }

/* ---------- Module cards ---------- */
.module-card { padding: 18px; cursor: pointer; position: relative; min-height: 148px; transition: transform .2s ease, border-color .2s ease; }
.module-card:hover { transform: translateY(-2px); border-color: var(--line-2); }
.mc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.mc-tag { font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; letter-spacing: 0.14em;
  padding: 3px 8px; border-radius: 4px; }
.mc-tag[data-accent="amber"]   { background: rgba(245,158,11,0.14); color: var(--ap); }
.mc-tag[data-accent="emerald"] { background: rgba(16,185,129,0.14); color: var(--ar); }
.mc-tag[data-accent="purple"]  { background: rgba(168,85,247,0.14); color: var(--gl); }
.mc-tag[data-accent="cyan"]    { background: rgba(6,182,212,0.14);  color: var(--reports); }
.mc-icon { color: var(--text-mid); }
.mc-title { font-family: var(--font-display); font-weight: 600; font-size: 18px; color: var(--text-hi); }
.mc-n { font-size: 13px; color: var(--text); margin-top: 4px; font-family: var(--font-mono); }
.mc-sub { font-size: 12px; color: var(--text-lo); margin-top: 2px; }
.mc-arrow { position: absolute; right: 16px; bottom: 14px; color: var(--text-lo); opacity: 0.5; transition: opacity .2s; }
.module-card:hover .mc-arrow { opacity: 1; color: var(--amber); }

/* ---------- Tables ---------- */
.lb-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.lb-table thead th {
  text-align: left; font-family: var(--font-mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-lo);
  padding: 8px 10px; border-bottom: 1px solid var(--line);
}
.lb-table tbody td { padding: 12px 10px; border-bottom: 1px solid var(--line); color: var(--text); vertical-align: top; }
.lb-table tbody tr { transition: background .12s; cursor: pointer; }
.lb-table tbody tr:hover { background: var(--bg-2); }
.lb-table tbody tr.sel { background: var(--bg-3); }
.lb-table tbody tr.sel td:first-child { border-left: 2px solid var(--amber); padding-left: 8px; }
.lb-table td.num { text-align: right; }
.lb-table td.mono, .lb-table th.mono { font-family: var(--font-mono); }
.lb-table .muted-sm { font-size: 11px; color: var(--text-lo); margin-top: 2px; }
.lb-table .muted { color: var(--text-lo); }
.lb-table input[type="checkbox"] { accent-color: var(--amber); cursor: pointer; }

/* Status pills */
.s-pill {
  font-family: var(--font-mono); font-weight: 700; letter-spacing: 0.06em;
  padding: 3px 8px; border-radius: 999px; font-size: 10.5px;
}
.s-pill[data-s="received"]  { background: rgba(96,165,250,0.12);  color: #4F88E8; }
.s-pill[data-s="matched"]   { background: rgba(245,158,11,0.14);  color: var(--ap); }
.s-pill[data-s="review"]    { background: rgba(239,68,68,0.12);   color: var(--err); }
.s-pill[data-s="approved"]  { background: rgba(16,185,129,0.14);  color: var(--ok); }
.s-pill[data-s="posted"]    { background: rgba(168,85,247,0.14);  color: var(--gl); }
.s-pill[data-s="paid"]      { background: rgba(16,185,129,0.14);  color: var(--ok); }
.s-pill[data-s="sent"]      { background: rgba(96,165,250,0.12);  color: #4F88E8; }
.s-pill[data-s="partial"]   { background: rgba(251,191,36,0.14);  color: var(--warn); }
.s-pill[data-s="overdue"]   { background: rgba(239,68,68,0.12);   color: var(--err); }
.s-pill[data-s="duplicate"] { background: rgba(239,68,68,0.12);   color: var(--err); }
.s-pill[data-s="pending"]   { background: rgba(251,191,36,0.14);  color: var(--warn); }

/* ---------- Approvals: batch + reason ---------- */
.batch-bar {
  display: flex; align-items: center; gap: 12px;
  background: var(--amber-soft);
  border: 1px solid var(--amber);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 12px;
}
.batch-bar .count { font-family: var(--font-display); font-weight: 600; font-size: 14px; color: var(--text-hi); }
.batch-bar .spacer { flex: 1; }

.approve-row {
  display: grid; grid-template-columns: 28px 64px 1fr auto auto;
  gap: 12px; align-items: center;
  padding: 12px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px;
  margin-bottom: 8px;
}
.approve-row.checked { border-color: var(--amber); background: var(--amber-soft); }
.ap-kind {
  font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: 0.14em;
  padding: 4px 8px; border-radius: 4px; text-align: center;
}
.ap-kind[data-kind="invoice"] { background: rgba(245,158,11,0.14); color: var(--ap); }
.ap-kind[data-kind="payment"] { background: rgba(16,185,129,0.14); color: var(--ar); }
.ap-kind[data-kind="reclass"] { background: rgba(168,85,247,0.14); color: var(--gl); }
.ap-kind[data-kind="ar"]      { background: rgba(16,185,129,0.14); color: var(--ar); }
.ap-kind[data-kind="vendor"]  { background: rgba(139,92,246,0.14); color: var(--vendor); }
.ap-title { color: var(--text-hi); font-weight: 600; font-size: 14px; }
.ap-ctx { font-size: 12px; color: var(--text-mid); margin-top: 3px; display: flex; align-items: center; gap: 6px; }
.ap-amt { font-family: var(--font-mono); font-weight: 600; color: var(--amber); font-size: 15px; }
.ap-act { display: flex; gap: 6px; }

/* Reason input on approve */
.reason-box {
  margin-top: 10px;
  display: flex; gap: 8px; align-items: center;
  background: var(--bg-1); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px;
}
.reason-box input {
  flex: 1; border: none; background: transparent; outline: none;
  color: var(--text-hi); font-size: 13px;
}
.reason-box input::placeholder { color: var(--text-lo); }

/* Audit history (clickable approved item) */
.audit-pop {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; margin-top: 8px;
}
.audit-pop h5 { margin: 0 0 8px; font-family: var(--font-display); font-size: 13px; color: var(--text-hi); letter-spacing: 0.02em; }
.audit-row { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; font-size: 12px; color: var(--text-mid); border-bottom: 1px dashed var(--line); }
.audit-row:last-child { border-bottom: none; }
.audit-row .who { color: var(--text-hi); font-weight: 600; }
.audit-row time { font-family: var(--font-mono); color: var(--text-lo); margin-left: auto; flex-shrink: 0; }

/* ---------- Inspector ---------- */
.ap-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .ap-grid { grid-template-columns: 1fr; } }
.inspector .insp-rows { display: flex; flex-direction: column; gap: 10px; padding-bottom: 16px; border-bottom: 1px dashed var(--line); }
.inspector .insp-rows > div { display: flex; justify-content: space-between; font-size: 13px; }
.inspector .insp-rows > div > span:first-child { color: var(--text-mid); }
.inspector .insp-rows > div > span:last-child  { color: var(--text-hi); font-family: var(--font-mono); }
.match-block { margin: 16px 0; }
.match-h { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-mid); margin-bottom: 8px; }
.match-rows { background: var(--bg-1); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.mrow { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13px; }
.mrow .ok { color: var(--ok); }
.mrow .amber { color: var(--amber); font-family: var(--font-mono); }

.agent-quote {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px;
  background: var(--amber-soft);
  border: 1px solid var(--amber);
  border-left: 2px solid var(--amber);
  border-radius: 8px;
  font-size: 13px; color: var(--text);
  margin-bottom: 16px;
}
.agent-quote svg { color: var(--amber); flex-shrink: 0; margin-top: 2px; }

.insp-actions { display: flex; gap: 8px; }
.insp-actions .btn { flex: 1; }
.insp-actions .btn-primary { flex: 1.6; }

/* ---------- GL grid ---------- */
.gl-grid { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .gl-grid { grid-template-columns: 1fr; } }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; flex-wrap: wrap; }
.tab {
  padding: 10px 16px; background: transparent; border: none; color: var(--text-mid);
  font-size: 13.5px; font-weight: 500; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text-hi); }
.tab.on { color: var(--text-hi); border-bottom-color: var(--amber); }

/* ---------- Setup center ---------- */
.setup-hero {
  background: linear-gradient(180deg, var(--amber-soft) 0%, var(--bg-2) 100%);
  border: 1px solid var(--amber);
  border-radius: 18px;
  padding: 28px; margin-bottom: 24px;
  display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center;
}
@media (max-width: 880px) { .setup-hero { grid-template-columns: 1fr; } }
.setup-h { font-family: var(--font-display); font-weight: 600; font-size: 26px;
  color: var(--text-hi); letter-spacing: -0.02em; margin: 0 0 6px; }
.setup-progress {
  margin-top: 14px;
  height: 8px; border-radius: 999px; background: var(--bg-3);
  overflow: hidden; border: 1px solid var(--line);
}
.setup-progress span { display: block; height: 100%; background: var(--amber); transition: width .4s ease; }
.setup-progress-label { font-family: var(--font-mono); font-size: 11px; color: var(--text-mid); margin-top: 8px; }
.setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 800px) { .setup-grid { grid-template-columns: 1fr; } }
.setup-step {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 14px; align-items: center;
  padding: 16px 18px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
}
.setup-step.done { border-color: var(--ok); }
.setup-step-ico {
  width: 44px; height: 44px; border-radius: 10px;
  background: var(--bg-3); border: 1px solid var(--line);
  display: grid; place-items: center;
  color: var(--amber);
}
.setup-step.done .setup-step-ico { background: rgba(16,185,129,0.12); color: var(--ok); border-color: var(--ok); }
.setup-step h5 { margin: 0; font-size: 14px; color: var(--text-hi); font-weight: 600; }
.setup-step p { margin: 3px 0 0; font-size: 12.5px; color: var(--text-mid); line-height: 1.4; }

/* ---------- Workflow drilldown ---------- */
.wf-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 999px; font-size: 12px; font-family: var(--font-mono);
  color: var(--text-mid);
}
.wf-toggle .pill {
  padding: 3px 10px; border-radius: 999px;
  cursor: pointer;
}
.wf-toggle .pill.on { background: var(--amber); color: var(--on-amber); font-weight: 700; }
.wf-pipeline {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px;
  margin: 24px 0;
}
@media (max-width: 1000px) { .wf-pipeline { grid-template-columns: 1fr 1fr; } }
.wf-stage {
  position: relative;
  padding: 18px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  min-height: 130px;
}
.wf-stage.active { border-color: var(--amber); background: var(--amber-soft); }
.wf-stage h5 { margin: 0 0 4px; color: var(--text-hi); font-size: 13.5px; font-weight: 600; }
.wf-stage .stage-num { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; color: var(--text-lo); }
.wf-stage .stage-by { display: inline-flex; gap: 4px; align-items: center; margin-top: 8px; font-size: 11px; color: var(--text-mid); font-family: var(--font-mono); }
.wf-stage .stage-status { margin-top: 6px; font-size: 11.5px; color: var(--ok); font-weight: 600; }
.wf-stage.active .stage-status { color: var(--amber); }
.wf-arrow {
  position: absolute; top: 50%; right: -12px;
  transform: translateY(-50%);
  color: var(--text-lo); z-index: 1;
}

/* Live stream */
.wf-stream {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px;
  max-height: 240px; overflow-y: auto;
}
.stream-row {
  display: grid; grid-template-columns: 60px 80px 1fr auto;
  gap: 10px; align-items: baseline;
  padding: 6px 0;
  font-size: 12px; font-family: var(--font-mono);
  color: var(--text-mid);
  border-bottom: 1px dashed var(--line);
}
.stream-row:last-child { border-bottom: none; }
.stream-row .t { color: var(--text-lo); }
.stream-row .ev { color: var(--amber); }
.stream-row .body { color: var(--text); }
.stream-row .amt { color: var(--text-hi); }

/* ---------- Agent chip ---------- */
.agent-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 7px; border-radius: 999px;
  background: var(--amber-soft);
  border: 1px solid var(--amber);
  color: var(--amber);
  font-family: var(--font-mono);
  font-size: 10.5px; font-weight: 600;
}
.agent-chip-dot {
  width: 5px; height: 5px; border-radius: 999px; background: var(--amber);
  animation: pulse-amber 2s ease-out infinite;
}

/* ---------- Code stubs (inline) ---------- */
.snippet { background: var(--bg-1); border: 1px solid var(--line); border-radius: 10px; }
.snippet-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); color: var(--text-mid); font-size: 11px; }
.snippet pre { margin: 0; padding: 14px;
  font-family: var(--font-mono); font-size: 12px; line-height: 1.55;
  color: var(--text); white-space: pre-wrap; word-break: break-word; }

/* ---------- OAuth modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px); z-index: 200;
  display: grid; place-items: center; padding: 20px;
}
.modal {
  width: min(540px, 100%);
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow-pop);
  padding: 28px;
}
.modal h3 { margin: 0 0 4px; font-family: var(--font-display); font-size: 22px; color: var(--text-hi); letter-spacing: -0.01em; }
.modal p { color: var(--text-mid); font-size: 13.5px; line-height: 1.5; margin: 0 0 18px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* Onboarding toast */
.toast {
  position: fixed; bottom: 22px; right: 22px;
  background: var(--bg-2); border: 1px solid var(--amber); border-radius: 14px;
  padding: 14px 16px 14px 12px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow-pop); z-index: 90;
  max-width: 380px;
}
.toast .t-msg { font-size: 13px; color: var(--text); line-height: 1.45; }
.toast strong { color: var(--text-hi); }

/* ---------- Feed timeline ---------- */
.feed-list { display: flex; flex-direction: column; }
.feed-row { display: grid; grid-template-columns: 80px 24px 1fr; gap: 12px; padding: 14px 0; }
.feed-time { font-family: var(--font-mono); font-size: 12px; color: var(--text-lo); padding-top: 4px; }
.feed-line { position: relative; background: var(--line); width: 2px; justify-self: center; }
.feed-line::before { content: ''; position: absolute; top: 6px; left: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--bg-2); border: 2px solid var(--amber); }
.feed-row[data-urg="urgent"] .feed-line::before { border-color: var(--err); }
.feed-row[data-urg="info"]   .feed-line::before { border-color: var(--info); }
.feed-meta { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; }
.feed-title { font-size: 14px; color: var(--text-hi); font-weight: 600; }
.feed-desc { font-size: 13px; color: var(--text-mid); margin-top: 2px; }
.rail-cat {
  font-family: var(--font-mono); font-weight: 700; letter-spacing: 0.12em;
  padding: 2px 6px; border-radius: 4px; font-size: 9.5px;
}
.rail-cat[data-cat="AP"]   { background: rgba(245,158,11,0.14); color: var(--ap); }
.rail-cat[data-cat="AR"]   { background: rgba(16,185,129,0.14); color: var(--ar); }
.rail-cat[data-cat="GL"]   { background: rgba(168,85,247,0.14); color: var(--gl); }
.rail-cat[data-cat="Sec"]  { background: rgba(239,68,68,0.14);  color: var(--err); }

/* ---------- Reports table ---------- */
.lb-table.report td { border-bottom: none; padding: 6px 8px; }
.lb-table.report tr.grp td { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--text-lo); padding-top: 18px; padding-bottom: 6px; }
.lb-table.report tr.subtot td { border-top: 1px solid var(--line); font-weight: 600; color: var(--text-hi); padding-top: 10px; padding-bottom: 12px; }
.lb-table.report tr.total td { border-top: 2px solid var(--amber); padding-top: 12px; padding-bottom: 14px;
  font-family: var(--font-display); font-weight: 700; font-size: 18px; color: var(--text-hi); }
.lb-table.report tr.total td:last-child { color: var(--amber); }

/* ---------- Settings: agent list ---------- */
.agent-list { display: flex; flex-direction: column; gap: 8px; }
.agent-card { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 12px;
  background: var(--bg-1); border: 1px solid var(--line); border-radius: 10px; }
.agent-card[data-primary="true"] { border-color: var(--amber); background: var(--amber-soft); }
.agent-card-l { display: flex; align-items: center; gap: 12px; }
.ag-ava {
  width: 38px; height: 38px; border-radius: 50%; background: var(--bg-3); display: grid;
  place-items: center; color: var(--amber); border: 1px solid var(--line-2);
}
.ag-name { color: var(--text-hi); font-weight: 600; font-size: 14px; }
.ag-meta { font-size: 11.5px; color: var(--text-lo); margin-top: 2px; }
.agent-card-r { display: flex; gap: 10px; align-items: center; }

.mcp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 800px) { .mcp-grid { grid-template-columns: 1fr; } }
.mcp-tool { display: grid; grid-template-columns: 80px 1fr auto; gap: 10px; align-items: center;
  padding: 10px 12px; background: var(--bg-1); border: 1px solid var(--line); border-radius: 8px; }
.mcp-ns {
  font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: 0.14em;
  padding: 4px 6px; border-radius: 4px; text-align: center;
}
.mcp-ns[data-ns="ap"]       { background: rgba(245,158,11,0.14); color: var(--ap); }
.mcp-ns[data-ns="ar"]       { background: rgba(16,185,129,0.14); color: var(--ar); }
.mcp-ns[data-ns="gl"]       { background: rgba(168,85,247,0.14); color: var(--gl); }
.mcp-ns[data-ns="rpt"]      { background: rgba(6,182,212,0.14);  color: var(--reports); }
.mcp-ns[data-ns="cls"]      { background: rgba(139,92,246,0.14); color: var(--vendor); }
.mcp-name { color: var(--text-hi); font-size: 13px; }
.mcp-desc { font-size: 11.5px; color: var(--text-lo); margin-top: 2px; }

.policy-list { display: flex; flex-direction: column; gap: 8px; }
.policy-row {
  display: grid; grid-template-columns: 1fr auto 1fr auto;
  gap: 14px; align-items: center;
  padding: 12px; background: var(--bg-1); border: 1px solid var(--line); border-radius: 8px;
}
.policy-l, .policy-r { font-size: 13px; color: var(--text); }
.policy-row .mono { color: var(--amber); margin-right: 6px; font-size: 11px; }

/* Forecast */
.forecast-rows { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; border-top: 1px dashed var(--line); }
.frow { display: flex; justify-content: space-between; font-size: 13px; padding: 6px 0; color: var(--text-mid); font-family: var(--font-mono); }

/* Settings grid */
.settings-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .settings-grid { grid-template-columns: 1fr; } }

/* Aging bar */
.aging-bar { display: flex; border-radius: 8px; overflow: hidden; height: 40px; }
.aging-bar > div { position: relative; }

/* Beaver mascot helper for state cards */
.state .beaver-img { width: 100px; height: 100px; }

/* =================== CASH FLOW FORECAST =================== */
.cf-view-toggle { display: flex; gap: 4px; background: var(--bg-3); border-radius: 8px; padding: 3px; }
.cf-view-toggle button { padding: 5px 10px; border-radius: 6px; border: none; background: transparent; color: var(--text-mid); font-size: 12px; font-family: var(--font-mono); cursor: pointer; transition: all .15s; }
.cf-view-toggle button.on { background: var(--bg-2); color: var(--text-hi); font-weight: 600; }

/* Daily trend chart */
.cf-trend-chart { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding: 16px 0 0; }
.cf-trend-datum { display: flex; flex-direction: column; align-items: center; flex: 1; gap: 4px; cursor: pointer; }
.cf-bar { width: 100%; max-width: 36px; min-height: 8px; background: var(--amber); border-radius: 4px 4px 0 0; transition: opacity .2s; }
.cf-bar[data-projected=true] { background: var(--bg-3); border: 1px dashed var(--line); }
.cf-trend-label { font-size: 10px; font-family: var(--font-mono); color: var(--text-lo); height: 16px; }
.cf-legend-row { display: flex; gap: 20px; margin-top: 8px; }
.cf-leg { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-mid); font-family: var(--font-mono); }
.cf-leg-dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }

/* Waterfall */
.cf-waterfall { display: flex; flex-direction: column; gap: 10px; padding: 4px 0; }
.cf-wf-row { display: flex; align-items: center; gap: 10px; }
.cf-wf-label { font-size: 12.5px; color: var(--text-mid); min-width: 130px; }
.cf-wf-bar-wrap { flex: 1; height: 22px; background: var(--bg-3); border-radius: 4px; overflow: hidden; }
.cf-wf-bar { height: 100%; border-radius: 4px; }
.cf-wf-val { font-size: 12px; font-family: var(--font-mono); color: var(--text-hi); min-width: 70px; text-align: right; }

/* Monthly bars */
.cf-monthly-chart { display: flex; flex-direction: column; gap: 12px; }
.cf-month-row { display: flex; align-items: center; gap: 12px; }
.cf-month-label { font-family: var(--font-mono); font-size: 12px; color: var(--text-mid); min-width: 32px; }
.cf-month-bars { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.cf-m-bar-group { display: flex; align-items: center; gap: 8px; }
.cf-m-bar { height: 14px; border-radius: 3px; }
.cf-m-val { font-size: 11px; font-family: var(--font-mono); color: var(--text-lo); min-width: 70px; }

/* =================== PEOPLE WIKI =================== */
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-top: 16px; }
.people-card {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; cursor: pointer; transition: border-color .2s, box-shadow .2s;
}
.people-card:hover { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber-glow); }
.people-card-top { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.people-ava {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  font-size: 15px; font-weight: 700; font-family: var(--font-display);
  background: var(--amber-soft); color: var(--amber); flex-shrink: 0; letter-spacing: -0.01em;
}
.people-ava[data-c=amber]   { background: var(--amber-soft); color: var(--amber); }
.people-ava[data-c=emerald]  { background: rgba(52,211,153,.12); color: var(--ar); }
.people-ava[data-c=cyan]     { background: rgba(6,182,212,.12); color: var(--gl); }
.people-ava[data-c=purple]   { background: rgba(139,92,246,.12); color: var(--gl); }
.people-ava.xl { width: 56px; height: 56px; font-size: 18px; }
.people-card-info { min-width: 0; }
.people-name { font-size: 14px; font-weight: 600; color: var(--text-hi); }
.people-role { font-size: 12px; color: var(--text-mid); margin-top: 1px; }
.people-company { font-size: 12px; color: var(--text-lo); }
.people-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.people-tag { font-size: 11px; padding: 2px 7px; border-radius: 4px; border: 1px solid; font-family: var(--font-mono); }
.people-footer { margin-top: 10px; display: flex; justify-content: flex-end; }
.people-last { font-size: 11px; color: var(--text-lo); }
