:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #e5e7eb;
  --border-soft: #eef0f3;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --head: #6b7a90;
  --primary: #2563eb;
  --primary-h: #1d4ed8;
  --purple: #6d28d9;
  --dark: #111827;
  --danger: #dc2626;
  --green: #059669;
  --amber: #b45309;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'tnum' 1;
}
[hidden] { display: none !important; }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 14px; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 12px; font-weight: 400; }
.error { color: var(--danger); font-size: 13px; margin: 0; }
.mt { margin-top: 22px; }
.mt-s { margin-top: 10px; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex: none; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 20px 18px 18px; border-bottom: 1px solid var(--border-soft); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px; background: var(--dark); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; letter-spacing: .02em;
}
.brand-name { font-weight: 600; font-size: 14px; }
.brand-sub { font-size: 12px; color: var(--muted); }
.nav { padding: 10px 10px; flex: 1; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--head); padding: 16px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: var(--text-2); text-decoration: none; font-weight: 500; margin-bottom: 2px;
}
.nav-item .ico { width: 18px; height: 18px; flex: none; display: grid; place-items: center; color: var(--muted); }
.nav-item .ico svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:hover { background: #f3f4f6; }
.nav-item.active { background: #eff4ff; color: var(--primary); }
.nav-item.active .ico { color: var(--primary); }
.sidebar-foot { padding: 14px 18px; border-top: 1px solid var(--border-soft); }
.sync { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.sync::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #9ca3af; }
.sync.ok::before { background: var(--green); }
.sync.busy::before { background: #f59e0b; }
.sync.err::before { background: var(--danger); }
.user-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; font-size: 12px; color: var(--text-2); }
.user-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-btn { font: inherit; font-size: 12px; color: var(--primary); background: none; border: 0; padding: 0; cursor: pointer; flex: none; }
.gate-card label { margin-bottom: 0; }

.main { flex: 1; min-width: 0; padding: 28px 32px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Buttons */
.btn {
  font: inherit; font-weight: 500; border-radius: 8px; padding: 8px 14px; cursor: pointer;
  border: 1px solid transparent; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); }
.btn-dark { background: var(--dark); color: #fff; }
.btn-dark:hover { background: #000; }
.btn-purple { background: var(--purple); color: #fff; }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { background: #f9fafb; border-color: #d1d5db; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-remove {
  font: inherit; font-size: 13px; color: var(--danger); background: #fff; border: 1px solid var(--border);
  border-radius: 7px; padding: 5px 12px; cursor: pointer;
}
.btn-remove:hover { border-color: #fca5a5; background: #fef2f2; }
.icon-btn { font: inherit; font-size: 18px; line-height: 1; width: 32px; height: 34px; border: 0; background: transparent; cursor: pointer; color: var(--text-2); }
.icon-btn:hover { color: var(--primary); }
.period { display: flex; align-items: center; border: 1px solid var(--border); background: #fff; border-radius: 8px; }
.period-label { min-width: 150px; text-align: center; font-weight: 600; font-size: 13px; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.kpi-label { font-size: 12px; font-weight: 500; color: var(--muted); }
.kpi-value { font-size: 24px; font-weight: 600; margin-top: 6px; letter-spacing: -0.01em; }
.kpi-foot { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi-accent { border-color: #c7d7fe; background: #f5f8ff; }
.kpi-accent .kpi-value { color: var(--primary); }

/* Stage bar */
.stages { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px 12px; margin-bottom: 16px; }
.sp-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.sp-head .muted { font-size: 12.5px; font-weight: 500; }
.sp-track { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: #eef0f3; gap: 2px; }
.sp-track span { display: block; height: 100%; min-width: 4px; }
.sp-legend { display: grid; grid-template-columns: minmax(0, 1.5fr) repeat(5, minmax(0, 1fr)); gap: 4px; margin-top: 12px; }
.sp-item { font: inherit; text-align: left; display: grid; grid-template-columns: auto 1fr; column-gap: 7px; row-gap: 2px; align-items: center; padding: 7px 9px; border-radius: 8px; border: 1px solid transparent; background: transparent; cursor: pointer; min-width: 0; }
.sp-item:hover { background: #f5f6f8; }
.sp-item.is-active { background: #eff4ff; border-color: #c7d7fe; }
.sp-item.is-empty { opacity: .45; }
.sp-name { font-size: 12px; color: var(--muted); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-val { grid-column: 2; font-size: 14.5px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sp-n { font-size: 11.5px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; }
.card.pad { padding: 20px 22px; }
.card-title { font-weight: 600; padding: 16px 20px 0; }
.row-between { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* Forms */
input, select, textarea {
  font: inherit; color: var(--text); background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 11px; outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
textarea { resize: vertical; line-height: 1.55; font-size: 13.5px; }
label { display: block; font-size: 12.5px; font-weight: 500; color: var(--text-2); margin-bottom: 14px; }
label input, label select, label textarea { margin-top: 6px; }
.add-row {
  display: grid; grid-template-columns: 1.6fr 1.6fr .8fr .8fr .7fr .9fr auto auto; gap: 8px;
  padding: 16px 18px; border-bottom: 1px solid var(--border-soft); align-items: center;
}
.fee-preview { font-size: 12.5px; color: var(--muted); white-space: nowrap; padding: 0 4px; }
.filters { display: flex; gap: 10px; align-items: center; padding: 12px 18px; flex-wrap: wrap; }
.filters #search { max-width: 260px; }
.spacer { flex: 1; }
.chips { display: flex; gap: 6px; }
.chip { font: inherit; font-size: 12.5px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); background: #fff; color: var(--text-2); cursor: pointer; }
.chip.active { background: var(--dark); border-color: var(--dark); color: #fff; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; padding: 3px; margin-bottom: 18px; background: #f9fafb; }
.seg button { font: inherit; font-size: 13px; font-weight: 500; border: 0; background: transparent; padding: 7px 14px; border-radius: 7px; cursor: pointer; color: var(--text-2); }
.seg button.active { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* Tables */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; }
.grid th {
  text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--head); padding: 12px 16px; border-bottom: 1px solid var(--border); background: #fbfbfc; white-space: nowrap;
}
.grid td { padding: 13px 16px; border-bottom: 1px solid var(--border-soft); color: var(--text-2); vertical-align: middle; }
.grid td.strong { color: var(--text); font-weight: 500; }
.buyer { font-size: 12px; font-weight: 400; color: var(--muted); margin-top: 2px; }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.grid td.num { color: var(--text); }
.grid tfoot td { font-weight: 700; color: var(--text); background: #fbfbfc; border-bottom: 0; border-top: 1px solid var(--border); }
.grid tbody tr:hover td { background: #fafbff; }
.grid tr.disc td { background: #f6fbf8; }
.c-tick { width: 52px; text-align: center !important; }
.grid td.c-tick input { width: 16px; height: 16px; accent-color: var(--green); cursor: pointer; }
.cell { cursor: text; border-radius: 6px; padding: 3px 6px; margin: -3px -6px; display: inline-block; min-width: 30px; }
.cell:hover { background: #eef2ff; }
.cell-input { padding: 4px 6px; font-size: 13.5px; width: 100%; min-width: 70px; }
td.num .cell-input { text-align: right; }
.stage-select { width: auto; padding: 4px 26px 4px 10px; font-size: 12.5px; font-weight: 500; border-radius: 999px; cursor: pointer; }
.stage-yet-to-receive-contract { color: #475569; background: #f1f5f9; border-color: #cbd5e1; }
.stage-evaluation { color: var(--amber); background: #fffbeb; border-color: #fde68a; }
.stage-on-track { color: var(--primary); background: #eff6ff; border-color: #bfdbfe; }
.stage-on-hold { color: #6d28d9; background: #f5f3ff; border-color: #ddd6fe; }
.stage-reject { color: var(--danger); background: #fef2f2; border-color: #fecaca; }
.stage-live { color: var(--green); background: #ecfdf5; border-color: #a7f3d0; }
.empty { padding: 36px; text-align: center; color: var(--muted); }
.hint { font-size: 12.5px; color: var(--muted); margin: 0; padding: 12px 18px 16px; }
.card.pad .hint { padding: 0; }

/* Onboarding */
.two-col { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 16px; align-items: start; }

/* Transfer */
.tr-top { display: grid; grid-template-columns: 2fr 1.4fr 1fr; gap: 14px; }
.tr-inputs td { padding: 8px 10px; }
.tr-inputs th { padding: 10px; }
.tr-inputs input { padding: 7px 10px; }
.tr-inputs td.num input { text-align: right; }
.card #trOut { margin-top: 10px; }

.tr-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.tr-main > .card:last-child { margin-bottom: 0; }
.tr-recent { position: sticky; top: 20px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
.recent-head { padding: 18px 18px 12px; border-bottom: 1px solid var(--border-soft); }
.recent-head h2 { margin-bottom: 10px; }
.recent-list { overflow-y: auto; padding: 6px; }
.recent-item { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.recent-item:hover { background: #f9fafb; }
.recent-item.active { background: #eff4ff; border-color: #c7d7fe; }
.recent-body { flex: 1; min-width: 0; }
.recent-title { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-net { font-size: 13px; color: var(--primary); font-weight: 600; margin-top: 2px; }
.recent-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.recent-del { font: inherit; font-size: 16px; line-height: 1; color: var(--muted); background: none; border: 0; cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.recent-del:hover { color: var(--danger); background: #fef2f2; }
.recent-empty { padding: 22px 12px; text-align: center; color: var(--muted); font-size: 13px; }
.editing { font-size: 12.5px; color: var(--primary); background: #eff4ff; border: 1px solid #c7d7fe; border-radius: 8px; padding: 8px 12px; margin-bottom: 16px; }

/* Transfer details (asset ledger) */
.month-select { width: auto; min-width: 170px; font-weight: 500; }
.filters.bare { padding: 0 0 14px; }
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.asset-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px;
  cursor: pointer; text-align: left; font: inherit; color: inherit; display: flex; flex-direction: column; gap: 10px;
  transition: border-color .12s, box-shadow .12s;
}
.asset-card:hover { border-color: #c7d7fe; box-shadow: 0 4px 14px rgba(17, 24, 39, .06); }
.asset-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.ac-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.ac-house { font-size: 12px; color: var(--muted); }
.ac-name { font-weight: 600; font-size: 15px; margin-top: 2px; }
.ac-project { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.status { font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; border: 1px solid; }
.status-done { color: var(--green); background: #ecfdf5; border-color: #a7f3d0; }
.status-prog { color: var(--primary); background: #eff6ff; border-color: #bfdbfe; }
.status-none { color: var(--amber); background: #fffbeb; border-color: #fde68a; }
.progress { height: 6px; background: #eef0f3; border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.progress.done span { background: var(--green); }
.progress.big { height: 8px; margin: 4px 0 14px; }
.ac-nums { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ac-nums div { font-size: 11.5px; color: var(--muted); }
.ac-nums b { display: block; font-size: 14px; color: var(--text); font-weight: 600; margin-top: 1px; }
.ac-funded { color: var(--green); font-weight: 600; }
.am-span { font-size: 13px; color: var(--text-2); margin: -6px 0 12px; }
.ac-foot { font-size: 11.5px; color: var(--muted); display: flex; justify-content: space-between; }
.issues { padding: 0; }
.issues summary { list-style: none; cursor: pointer; padding: 13px 18px; display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 13.5px; color: var(--amber); }
.issues summary::-webkit-details-marker { display: none; }
.issues ul { margin: 0; padding: 0 18px 14px 36px; font-size: 13px; color: var(--text-2); line-height: 1.55; }
.issues li { margin-bottom: 6px; }
.badge { font-size: 12px; background: #fffbeb; border: 1px solid #fde68a; color: var(--amber); padding: 1px 9px; border-radius: 999px; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(17, 24, 39, .35); display: grid; place-items: center; padding: 16px; z-index: 40; }
.modal-card { background: #fff; border-radius: 14px; width: 100%; max-width: 860px; max-height: calc(100vh - 32px); overflow-y: auto; padding: 22px 24px; box-shadow: 0 24px 60px rgba(0,0,0,.2); }
.modal-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 16px; }
.modal-head h2 { font-size: 19px; margin: 2px 0; }
.modal-head .icon-btn { font-size: 24px; }
.am-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.am-stats div { background: #f9fafb; border: 1px solid var(--border-soft); border-radius: 9px; padding: 10px 12px; font-size: 11.5px; color: var(--muted); }
.am-stats b { display: block; font-size: 15px; color: var(--text); font-weight: 600; margin-top: 2px; }
.am-note { font-size: 13px; background: #fffbeb; border: 1px solid #fde68a; color: #92400e; border-radius: 8px; padding: 9px 12px; margin: 0 0 12px; }
.ref { font-family: ui-monospace, 'Geist Mono', monospace; font-size: 12px; color: var(--text-2); }
.tick { color: var(--green); font-size: 12px; font-weight: 600; }
#amTable td, #amTable th { padding: 10px 12px; }
.muted.small { font-size: 12px; }

/* Gate */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.gate-card { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 32px; width: 100%; max-width: 360px; display: grid; gap: 12px; }
.gate-card h1 { margin-top: 6px; }

/* Toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--dark); color: #fff;
  padding: 10px 16px; border-radius: 9px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.18); z-index: 50;
  display: flex; gap: 12px; align-items: center;
}
.toast button { font: inherit; font-size: 13px; color: #93c5fd; background: none; border: 0; cursor: pointer; font-weight: 600; padding: 0; }

@media (max-width: 1200px) {
  .sp-legend { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .add-row { grid-template-columns: 1fr 1fr 1fr 1fr; }
}
.nav-sub { padding-left: 22px; font-size: 13.5px; }
.tr-recent.flash { box-shadow: 0 0 0 3px rgba(37, 99, 235, .25); transition: box-shadow .3s; }
@media (max-width: 1100px) {
  .tr-layout { grid-template-columns: 1fr; }
  .tr-recent { position: static; max-height: 420px; order: -1; }
}
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--border); }
  .nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; }
  .nav-label, .sidebar-foot { display: none; }
  .main { padding: 18px 16px 40px; }
  .kpis, .kpis-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sp-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col, .tr-top { grid-template-columns: 1fr; }
  .am-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .add-row { grid-template-columns: 1fr 1fr; }
}

/* Sync now button */
.sync-btn { display: inline-flex; align-items: center; gap: 7px; }
.sync-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sync-btn.is-syncing svg { animation: bfo-spin 1s linear infinite; }
.sync-btn:disabled { opacity: .7; cursor: progress; }
@keyframes bfo-spin { to { transform: rotate(360deg); } }

/* Monthly summary */
.sm-trend { position: relative; }
.sm-trend-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.sm-trend-head h2 { margin: 0; }
.sm-chart { display: flex; align-items: flex-end; gap: 2px; height: 190px; margin-top: 18px; border-bottom: 1px solid var(--border); }
.sm-bar { flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; cursor: pointer; background: none; border: 0; padding: 0 3px; font: inherit; }
.sm-bar .v { font-size: 11px; font-weight: 600; color: var(--text); margin-bottom: 4px; white-space: nowrap; visibility: hidden; }
.sm-bar .b { width: 100%; max-width: 46px; border-radius: 4px 4px 0 0; background: var(--primary); opacity: .28; transition: opacity .15s; min-height: 2px; }
.sm-bar:hover .b { opacity: .5; }
.sm-bar.on .b { opacity: 1; }
.sm-bar.on .v, .sm-bar.peak .v { visibility: visible; }
.sm-axis { display: flex; gap: 2px; margin-top: 6px; }
.sm-axis span { flex: 1 1 0; min-width: 0; text-align: center; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.sm-axis span.on { color: var(--text); font-weight: 600; }
.sm-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 20px rgba(17,24,39,.12); padding: 9px 12px; font-size: 12px; color: var(--text-2); white-space: nowrap; z-index: 5; }
.sm-tip b { color: var(--text); display: block; margin-bottom: 3px; }
.sm-cols { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.sm-table td { font-size: 13px; }
.sm-table .when { white-space: nowrap; color: var(--muted); font-size: 12.5px; }
.sm-tag { display: inline-block; font-size: 11px; font-weight: 500; padding: 1px 7px; border-radius: 999px; margin-left: 6px; vertical-align: 1px; }
.sm-tag.sec { color: #6d28d9; background: #f5f3ff; }
.sm-tag.live { color: var(--amber); background: #fffbeb; }
.sm-houses { padding: 8px 20px 16px; }
.sm-house { padding: 10px 0; border-bottom: 1px solid var(--border-soft); }
.sm-house:last-child { border-bottom: 0; }
.sm-house .top { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.sm-house .top .n { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sm-house .top .g { color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sm-house .track { height: 6px; background: var(--border-soft); border-radius: 3px; margin: 6px 0 4px; overflow: hidden; }
.sm-house .fill { height: 100%; background: var(--primary); border-radius: 3px; }
.sm-house .sub { font-size: 12px; color: var(--muted); }
.up { color: var(--green); }
.down { color: var(--danger); }
.sm-note { margin-top: -4px; }
@media (max-width: 1100px) { .sm-cols { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .sm-bar .v { display: none; } .sm-axis span { font-size: 9.5px; } }
#view-summary.is-empty .kpis, #view-summary.is-empty .sm-trend, #view-summary.is-empty .sm-cols, #view-summary.is-empty .sm-note { display: none; }
.sm-table th, .sm-table td { padding-left: 12px; padding-right: 12px; }
.sm-table th { white-space: normal; line-height: 1.3; }
.sm-table td.num { white-space: nowrap; }
.sm-cols { grid-template-columns: minmax(0, 2.6fr) minmax(240px, 1fr); }

/* Pending collections */
#view-collections.is-empty .kpis, #view-collections.is-empty .filters, #view-collections.is-empty #pcCard { display: none; }
.pc-table td { font-size: 13px; }
.pc-table td.num.strong { font-weight: 600; color: var(--text); }
.pc-bar { width: 90px; height: 6px; background: var(--border-soft); border-radius: 3px; overflow: hidden; }
.pc-bar span { display: block; height: 100%; background: var(--green); border-radius: 3px; }
.pc-note { font-size: 12.5px; color: var(--muted); max-width: 200px; }
.pc-note a { color: var(--primary); text-decoration: none; font-weight: 500; }
.pc-note a:hover { text-decoration: underline; }
.sm-tag.pc-live { color: var(--green); background: #ecfdf5; margin-left: 0; }
.sm-tag.pc-notlive { color: #475569; background: #f1f5f9; margin-left: 0; }
.sm-tag.pc-sec { color: #6d28d9; background: #f5f3ff; margin-left: 0; }
.pc-table .sm-tag { white-space: nowrap; }
.pc-table td.when { white-space: nowrap; }

/* Weekly update */
.wu-note { width: 100%; min-height: 460px; resize: vertical; font-family: 'Geist', system-ui, sans-serif; font-size: 14px; line-height: 1.6; color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 16px 18px; background: #fcfcfd; }
.wu-note:focus { outline: none; border-color: var(--primary); background: #fff; }

/* Collections movement */
.pc-move { margin-top: -4px; }
.pc-slow { color: var(--amber); }
@media (max-width: 900px) { .kpis-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Overview (calm, light figures, generous spacing) */
#view-home .page-head { margin-bottom: 26px; }
.hm-hero { padding: 28px 30px 26px; margin-bottom: 20px; }
.hm-hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.hm-eyebrow { font-size: 13px; color: var(--muted); font-weight: 500; }
.hm-amount { font-size: 40px; font-weight: 300; letter-spacing: -0.03em; color: var(--text); margin: 6px 0 6px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hm-sub { font-size: 13px; color: var(--muted); }
.hm-pill { font-size: 12px; font-weight: 500; padding: 4px 11px; border-radius: 999px; white-space: nowrap; margin-top: 2px; }
.hm-pill.ok { color: #0e7a50; background: #e8f8f0; }
.hm-pill.warn { color: #9a5b00; background: #fff4e0; }
.hm-pill.neutral { color: var(--muted); background: var(--border-soft); }
.hm-progress { margin: 26px 0 24px; }
.hm-track { position: relative; height: 6px; background: var(--border-soft); border-radius: 999px; }
.hm-fill { height: 100%; width: 0; background: var(--primary); border-radius: 999px; transition: width .6s cubic-bezier(.25, 1, .5, 1); }
.hm-mark { position: absolute; top: -5px; width: 2px; height: 16px; background: var(--text-2); border-radius: 1px; display: none; }
.hm-mark span { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--muted); white-space: nowrap; }
.hm-scale { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: 12px; color: var(--muted); }
.hm-target { display: inline-flex; align-items: center; gap: 10px; }
.hm-target .link-btn { margin: 0; font-size: 12px; }
.hm-target-form { display: inline-flex; gap: 6px; align-items: center; }
.hm-target-form input { width: 70px; padding: 5px 8px; font-size: 12.5px; text-align: right; }
.btn-sm { padding: 5px 12px; font-size: 12.5px; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; font-size: 12.5px; font-weight: 500; color: var(--primary); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.hm-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--border-soft); padding-top: 20px; }
.hm-stat { padding: 0 20px; border-left: 1px solid var(--border-soft); }
.hm-stat:first-child { padding-left: 0; border-left: 0; }
.hm-stat-label { font-size: 12px; color: var(--muted); }
.hm-stat-value { font-size: 18px; font-weight: 400; color: var(--text); margin-top: 6px; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.hm-stat-foot { font-size: 12px; color: var(--muted); margin-top: 3px; }
.hm-good { color: var(--green); }
.hm-warn { color: var(--amber); }
.hm-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.hm-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; text-decoration: none; color: inherit; display: block; }
.hm-link { transition: border-color .2s, transform .2s, box-shadow .2s; }
.hm-link:hover { border-color: var(--primary); }
.hm-card-label { font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; }
.hm-arrow { opacity: 0; transition: opacity .2s, transform .2s; transform: translateX(-4px); }
.hm-link:hover .hm-arrow { opacity: 1; transform: none; color: var(--primary); }
.hm-card-value { font-size: 22px; font-weight: 400; color: var(--text); margin-top: 10px; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; }
.hm-card-foot { font-size: 12px; color: var(--muted); margin-top: 4px; }
.hm-attn { padding: 22px 26px 10px; }
.hm-attn-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.hm-attn-head h2 { margin: 0; font-size: 15px; font-weight: 500; }
.hm-count { font-size: 12px; color: var(--muted); background: var(--border-soft); padding: 1px 8px; border-radius: 999px; }
.hm-row { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px 0; border-top: 1px solid var(--border-soft); text-decoration: none; color: inherit; }
.hm-row:first-child { border-top: 0; }
.hm-row .dotk { width: 8px; height: 8px; border-radius: 50%; }
.hm-row .dotk.collection { background: var(--primary); }
.hm-row .dotk.transfer { background: var(--amber); }
.hm-row .dotk.deal { background: var(--muted); }
.hm-row .t { font-size: 13.5px; color: var(--text); }
.hm-row .w { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.hm-row .k { font-size: 12px; color: var(--muted); white-space: nowrap; }
.hm-row:hover .t { color: var(--primary); }
.hm-none { padding: 16px 0 18px; color: var(--muted); font-size: 13px; }
@media (max-width: 1100px) { .hm-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 18px; } .hm-stat:nth-child(3) { padding-left: 0; border-left: 0; } .hm-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .hm-amount { font-size: 32px; } .hm-hero { padding: 22px 20px; } .hm-cards { grid-template-columns: 1fr; } .hm-row { grid-template-columns: 10px minmax(0, 1fr); } .hm-row .k { display: none; } }

/* Production house logo strip */
.hm-logos { overflow: hidden; margin: 4px 0 24px; -webkit-mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent); mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent); }
.hm-logos-track { display: flex; width: max-content; list-style: none; margin: 0; padding: 0; will-change: transform; }
.hm-logo { flex: 0 0 auto; padding: 8px 7px 12px; }
.hm-logo img { display: block; width: 180px; height: auto; aspect-ratio: 1024 / 614; border-radius: 10px; box-shadow: 0 1px 2px rgba(6, 27, 49, .06), 0 6px 16px -6px rgba(6, 27, 49, .18); transition: transform .3s cubic-bezier(.25, 1, .5, 1), box-shadow .3s; user-select: none; }
.hm-logos .hm-logo:hover img { transform: translateY(-3px); box-shadow: 0 2px 4px rgba(6, 27, 49, .08), 0 14px 28px -8px rgba(6, 27, 49, .28); }
html[data-mode="dark"] .hm-logo img { box-shadow: 0 0 0 1px rgba(115, 137, 255, .14), 0 10px 24px -8px rgba(0, 0, 0, .6); }
@media (max-width: 600px) { .hm-logo img { width: 140px; } }
.mode-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 600px) { .mode-options { grid-template-columns: 1fr; } }
a.btn, a.btn:hover { text-decoration: none; }

/* BetterInvest logo (from the brand guide: forest green #02341b, leaf green #5bd640) */
.bi-logo, .bi-mark { display: block; height: 30px; width: auto; flex: 0 0 auto; }
.bi-ink { fill: #02341b; }
.bi-arrow { fill: #5bd640; }
a.brand { text-decoration: none; color: inherit; gap: 12px; padding: 20px 18px 18px; }
.brand-div { width: 1px; height: 28px; background: var(--border); flex: 0 0 auto; }
.brand .brand-sub { font-size: 12px; line-height: 1.3; color: var(--muted); font-weight: 500; }
.gate-logo { display: flex; justify-content: center; margin: 2px 0 10px; }
.gate-logo .bi-logo { height: 48px; }

/* ---------- Settings: account ---------- */
.acct-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 12px; flex-wrap: wrap; }
.acct-email { font-size: 14px; color: var(--text); font-weight: 500; margin-top: 2px; word-break: break-all; }
.acct-out { color: var(--danger); }
html[data-mode="dark"] .acct-out { color: var(--danger); }
.settings-card + .settings-card { margin-top: 16px; }

/* ---------- Mobile top bar and menu drawer ---------- */
.mbar, .nav-close { display: none; }
.mbar-btn { width: 40px; height: 40px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 10px; color: var(--text); cursor: pointer; flex: none; }
.mbar-btn:hover { background: var(--border-soft); }
.mbar-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.nav-scrim { position: fixed; inset: 0; background: rgba(6, 27, 49, .4); z-index: 59; animation: bfo-fade .2s ease; }
@keyframes bfo-fade { from { opacity: 0; } }

@media (max-width: 1100px) and (min-width: 861px) {
  .sidebar { width: 220px; }
  .main { padding: 24px 24px 56px; }
}

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .mbar {
    display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 40;
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: var(--surface);
    border-bottom: 1px solid var(--border);
  }
  .mbar-logo { display: flex; align-items: center; }
  .mbar-logo .bi-logo { height: 26px; }
  .mbar-title { margin-left: auto; font-size: 13px; font-weight: 500; color: var(--muted); padding-right: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* the sidebar becomes a drawer that slides in from the left */
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); height: 100%; z-index: 60;
    transform: translateX(-102%); transition: transform .28s cubic-bezier(.25, 1, .5, 1);
    border-right: 1px solid var(--border); border-bottom: 0; box-shadow: none;
    padding-top: env(safe-area-inset-top); overflow-y: auto;
  }
  body.nav-open .sidebar { transform: none; box-shadow: 0 24px 60px rgba(0, 0, 0, .25); }
  body.nav-open { overflow: hidden; }
  .nav { display: block; padding: 8px 10px; }
  .nav-label, .sidebar-foot { display: block; }
  .nav-item { padding: 11px 10px; }
  .brand { position: relative; padding-right: 56px; }
  .nav-close { display: grid; position: absolute; top: calc(14px + env(safe-area-inset-top)); right: 10px; }

  .main { padding: 18px 16px calc(40px + env(safe-area-inset-bottom)); }
  h1, html[data-look="stripe"] h1 { font-size: 24px; }
  .page-head, html[data-look="stripe"] .page-head { margin-bottom: 18px; padding-top: 0; align-items: stretch; }
  .page-head > div:first-child { width: 100%; }
  .head-actions { width: 100%; }
  .head-actions .month-select { flex: 1 1 100%; min-width: 0; }
  .head-actions .btn { flex: 1 1 auto; justify-content: center; text-align: center; }
  .head-actions .sync-btn { justify-content: center; }

  .kpis, .kpis-3, .kpis-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; min-width: 0; }
  .kpi-value { font-size: 19px; overflow-wrap: anywhere; }
  .kpi-foot { font-size: 11.5px; }

  .filters, .filters.bare { gap: 10px; }
  .filters input, #pcSearch, #lgSearch, .filters #search { max-width: none; width: 100%; flex: 1 1 100%; }
  .chips { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; padding-bottom: 2px; max-width: 100%; }
  .chip { flex: none; }

  .asset-grid { grid-template-columns: 1fr; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .grid th, .grid td { padding: 10px 12px; }
  .card.pad { padding: 16px; }
  .card-title { padding: 14px 16px 0; }
  .stages { padding: 12px 14px 10px; }

  .modal { padding: 0; align-items: end; }
  .modal-card { max-width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
  .toast { left: 16px; right: 16px; transform: none; bottom: calc(16px + env(safe-area-inset-bottom)); justify-content: space-between; }

  /* overview */
  .hm-hero { padding: 20px 18px; }
  .hm-hero-top { flex-direction: column; gap: 10px; }
  .hm-amount { font-size: 34px; }
  .hm-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 16px; }
  .hm-stat { padding: 0 0 0 14px; }
  .hm-stat:nth-child(odd) { padding-left: 0; border-left: 0; }
  .hm-scale { flex-wrap: wrap; gap: 6px; }
  .hm-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .hm-card { padding: 14px; }
  .hm-card-value { font-size: 19px; }
  .hm-attn { padding: 18px 16px 6px; }
  .hm-logo img { width: 150px; }

  /* summary chart: keep bars readable */
  .sm-chart { height: 150px; }
  .wu-note { min-height: 360px; font-size: 13.5px; padding: 12px 14px; }
}

@media (max-width: 380px) {
  .kpis, .kpis-3, .kpis-4, .hm-cards { grid-template-columns: 1fr; }
}

/* Phones: tables keep a readable width and scroll sideways, with the first column pinned */
@media (max-width: 860px) {
  .table-wrap > table.grid { min-width: 640px; }
  .table-wrap > table.pc-table, .table-wrap > table#pipeTable { min-width: 780px; }
  .table-wrap .grid td:first-child, .table-wrap .grid th:first-child { position: sticky; left: 0; z-index: 1; min-width: 160px; max-width: 200px; }
  .table-wrap .grid td:first-child { background: var(--surface); box-shadow: 1px 0 0 var(--border-soft); }
  .table-wrap .grid tfoot td:first-child { background: inherit; }
  #pipeTable td:first-child, #pipeTable th:first-child { min-width: 52px; max-width: 52px; }
}

/* the drawer's close button and the top bar exist only on phones */
.sidebar .nav-close, .app > .mbar { display: none; }
@media (max-width: 860px) {
  .sidebar .nav-close { display: grid; }
  .app > .mbar { display: flex; }
  /* the pipeline's first column is the small tick box: no need to pin it */
  #pipeTable td:first-child, #pipeTable th:first-child { position: static; box-shadow: none; }
}

/* Stage labels in the pipelines: tinted pill in the stage's own colour */
.stage-select { color: var(--sc, #64748b); background-color: color-mix(in srgb, var(--sc, #64748b) 7%, transparent); border-color: color-mix(in srgb, var(--sc, #64748b) 33%, transparent); }

/* ---------- Settings: collapsible Themes group ---------- */
.settings-group { padding: 0; overflow: hidden; }
.sg-sum { display: flex; align-items: center; gap: 14px; padding: 18px 22px; cursor: pointer; list-style: none; user-select: none; }
.sg-sum::-webkit-details-marker { display: none; }
.sg-sum:hover { background: var(--border-soft); }
.sg-ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--border-soft); color: var(--text-2); flex: none; }
.sg-ico svg, .sg-chev svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sg-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sg-title { font-size: 15px; font-weight: 500; color: var(--text); }
.sg-sub { font-size: 12.5px; color: var(--muted); }
.sg-chev { margin-left: auto; color: var(--muted); display: grid; transition: transform .2s ease; }
.settings-group[open] .sg-chev { transform: rotate(90deg); }
.settings-group[open] .sg-sum { border-bottom: 1px solid var(--border-soft); }
.sg-body { padding: 20px 22px 22px; }
html[data-mode="dark"] .sg-sum:hover { background: rgba(255, 255, 255, .03); }

/* ---------- Monthly summary: two columns only on wide screens ---------- */
.sm-cols { grid-template-columns: 1fr; }
@media (min-width: 1101px) { .sm-cols { grid-template-columns: minmax(0, 2.6fr) minmax(240px, 1fr); } }

/* ---------- Net transfer amount: let the layout shrink to the screen ---------- */
.tr-main { min-width: 0; }
@media (max-width: 1100px) { .tr-layout { grid-template-columns: minmax(0, 1fr); } }

@media (max-width: 860px) {
  /* comfortable tap sizes */
  .btn, .btn-sm { min-height: 38px; }
  .btn-sm { padding: 8px 14px; font-size: 13px; }
  .link-btn { padding: 8px 6px; margin: -8px -6px; }
  .chip { min-height: 34px; }
  .tr-inputs input { min-height: 38px; }
  /* summary chart: label every other month on narrow screens (the selected month always shows) */
  .sm-axis span:nth-child(even):not(.on) { visibility: hidden; }
  .sm-bar { padding: 0 1px; }
}
@media (max-width: 860px) {
  .recent-del { width: 34px; height: 34px; display: grid; place-items: center; font-size: 16px; margin: -6px -8px -6px 0; }
}
