/* Buy Big Buildings (BBB) Deal Intake — one calm surface: warm off-white page, white cards with thin
   borders, one indigo accent. Light only (an internal tool used in daylight). */
:root {
  --bg: #f8f6f2; --surface: #ffffff; --raised: #fbfaf7; --line: #e6e1d8; --line-strong: #d4cec2;
  --ink: #1d2433; --ink-2: #3c4456; --muted: #6b7385; --faint: #9aa1ae;
  --accent: #3b3fd8; --accent-ink: #ffffff; --accent-soft: #eceefe;
  --ok: #e3f4e8; --ok-ink: #1f6b3a; --bad: #fde8e6; --bad-ink: #a12a1f; --warn: #fff4d6; --warn-ink: #8a5a00;
  --edit: #fff6d9;
  --side: 232px; --rail: 60px;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 17px; font-weight: 600; margin: 0 0 10px; }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 8px; }
.muted { color: var(--muted); font-weight: normal; }
.faint { color: var(--faint); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------------------------------------------------------------- shell */
.topbar { position: fixed; inset: 0 0 auto 0; height: 52px; display: flex; align-items: center; gap: 12px;
  padding: 0 16px; background: var(--bg); border-bottom: 1px solid var(--line); z-index: 30; }
.topbar .menu-toggle { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px;
  background: transparent; color: var(--ink-2); border: 0; cursor: pointer; padding: 0; margin: 0; }
.topbar .menu-toggle:hover { background: #efebe4; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; color: var(--ink); font-size: 15px; }
.brand:hover { text-decoration: none; }
.brand .mark { min-width: 26px; height: 26px; padding: 0 6px; border-radius: 7px; letter-spacing: .02em; background: var(--accent); color: #fff; display: grid;
  place-items: center; font-size: 13px; font-weight: 700; }
.crumbs { color: var(--muted); display: flex; gap: 8px; align-items: center; min-width: 0; }
.crumbs a { color: var(--muted); }
.crumbs strong { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }

.side { position: fixed; top: 52px; bottom: 0; left: 0; width: var(--side); background: var(--bg);
  border-right: 1px solid var(--line); padding: 12px 10px; display: flex; flex-direction: column; gap: 2px;
  transition: width .18s ease; overflow: hidden; z-index: 20; }
.side .group { font-size: 11.5px; color: var(--faint); padding: 14px 10px 4px; white-space: nowrap; }
.side a.item, .side span.item { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 8px;
  color: var(--ink-2); white-space: nowrap; font-size: 13.5px; }
.side a.item:hover { background: #efebe4; text-decoration: none; }
.side a.item.active { background: #ece7de; color: var(--ink); font-weight: 600; }
.side .item svg { flex: none; width: 18px; height: 18px; }
.side span.item.soon { color: var(--faint); cursor: default; }
.side .pill { margin-left: auto; font-size: 10.5px; padding: 1px 7px; border-radius: 10px; background: #eeebe5; color: var(--muted); }
.side .bottom { margin-top: auto; }
body.rail .side { width: var(--rail); }
body.rail .side .label, body.rail .side .group, body.rail .side .pill { display: none; }
body.rail .side a.item, body.rail .side span.item { justify-content: center; padding: 9px 0; }

.main { margin: 52px 0 0 var(--side); padding: 28px 36px 80px; transition: margin .18s ease; min-height: calc(100vh - 52px); }
body.rail .main { margin-left: var(--rail); }
.page { max-width: 1240px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .grow { flex: 1; min-width: 240px; }
.page-head p { margin: 2px 0 0; color: var(--muted); }

/* ---------------------------------------------------------------- controls */
button, .button { font: inherit; font-size: 13.5px; background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent);
  border-radius: 8px; padding: 7px 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  margin: 0; white-space: nowrap; }
button:hover, .button:hover { filter: brightness(1.06); text-decoration: none; }
button.secondary, .button.secondary { background: var(--surface); color: var(--accent); border-color: #cfd1f6; }
button.ghost, .button.ghost { background: transparent; color: var(--ink-2); border-color: var(--line-strong); }
button.danger { background: var(--surface); color: var(--bad-ink); border-color: #f0c4be; }
button:disabled, .button[aria-disabled="true"] { background: #e7e4de; border-color: #e7e4de; color: #a19d95; cursor: not-allowed; filter: none; }
input, select, textarea { font: inherit; border: 1px solid var(--line-strong); border-radius: 8px; padding: 7px 10px; background: var(--surface); color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid #c9cbfa; border-color: var(--accent); }
textarea { width: 100%; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; background: var(--surface); }
.segmented button { background: transparent; color: var(--ink-2); border: 0; border-radius: 0; padding: 6px 12px; }
.segmented button.on { background: #ece7de; color: var(--ink); font-weight: 600; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }
.search { min-width: 240px; }

/* ---------------------------------------------------------------- cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.section { margin-bottom: 28px; }
.section > .section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.section > .section-head h2 { margin: 0; }
.section > .section-head .grow { flex: 1; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.grid-charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px; }

.deal-card { cursor: pointer; display: flex; flex-direction: column; gap: 14px; transition: border-color .12s, box-shadow .12s; }
.deal-card:hover { border-color: var(--line-strong); box-shadow: 0 2px 10px rgba(29, 36, 51, .06); }
.deal-card .title { font-size: 16px; font-weight: 600; }
.deal-card .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat .k { font-size: 11.5px; color: var(--muted); }
.stat .v { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.deal-card .activity { font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--raised); }

/* progress steps: T12 · Rent roll · Signed off · Model built */
.steps { display: flex; gap: 6px; flex-wrap: wrap; }
.step { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); background: #f1eee8;
  border-radius: 20px; padding: 3px 9px 3px 6px; }
.step .dot { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid #c9c3b8; display: grid; place-items: center; font-size: 9px; }
.step.done { color: var(--ok-ink); background: var(--ok); }
.step.done .dot { border-color: var(--ok-ink); background: var(--ok-ink); color: #fff; }

/* tables (list views, logs) */
table.list { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.list th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line);
  background: var(--raised); white-space: nowrap; cursor: default; }
table.list th[data-sort] { cursor: pointer; }
table.list td { padding: 10px 12px; border-bottom: 1px solid #f0ece5; vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr.click { cursor: pointer; }
table.list tbody tr.click:hover td { background: #faf8f4; }

/* badges */
.badges { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px; background: #f1eee8; font-size: 12px; color: var(--ink-2); }
.badge.ok { background: var(--ok); color: var(--ok-ink); }
.badge.bad { background: var(--bad); color: var(--bad-ink); }
.badge.warn { background: var(--warn); color: var(--warn-ink); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.problems { color: var(--bad-ink); margin: 8px 0 0; padding-left: 18px; }

/* document cards */
.doc-card { cursor: pointer; display: flex; flex-direction: column; gap: 10px; }
.doc-card:hover { border-color: var(--line-strong); }
.doc-card.open { border-color: var(--accent); box-shadow: 0 0 0 2px #dfe0fc; }
.doc-card.failed { background: #fffaf9; border-color: #f2d3ce; }
.doc-card .doc-top { display: flex; gap: 10px; align-items: flex-start; }
.doc-card .kind { font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 3px 7px; border-radius: 6px; background: #eef0f4; color: var(--ink-2); }
.doc-card .kind.t12 { background: #e9ecfd; color: #3036b3; }
.doc-card .kind.rr { background: #e4f3ec; color: #1f6b3a; }
.doc-card .fname { font-weight: 600; word-break: break-word; }
.doc-card .meta { font-size: 12.5px; color: var(--muted); }
.doc-card .error { font-size: 12.5px; color: var(--bad-ink); }
.doc-card .actions { display: flex; gap: 8px; margin-top: auto; }
.dropzone { border: 1.5px dashed var(--line-strong); border-radius: var(--radius); padding: 16px; text-align: center; color: var(--muted); background: var(--raised); }
.section.dragover .dropzone { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* ready-to-build + exports */
.build { display: grid; grid-template-columns: minmax(320px, 1.3fr) minmax(280px, 1fr); gap: 14px; }
.readiness .doc { margin: 8px 0; padding: 8px 10px; border-left: 3px solid var(--line-strong); background: var(--raised); border-radius: 0 8px 8px 0; }
.readiness .doc.ok { border-left-color: var(--ok-ink); }
.readiness .signoff { margin-left: 10px; font-size: 13px; }
.exports { display: flex; flex-direction: column; gap: 8px; }
.exports .row { display: flex; gap: 8px; flex-wrap: wrap; }
.exports h3 { margin-top: 6px; }

/* charts */
.chart-card { min-height: 300px; display: flex; flex-direction: column; }
.chart-card .chart-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.chart-card .chart-head h3 { margin: 0; }
.chart-card .chart-box { position: relative; flex: 1; min-height: 230px; }
.chart-card .chart-empty { flex: 1; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 20px; font-size: 13px; }
.chart-card.wide { grid-column: span 2; }
@media (max-width: 900px) { .chart-card.wide { grid-column: auto; } .build { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- preview panel */
.panel-shade { position: fixed; inset: 52px 0 0 0; background: rgba(29, 36, 51, .18); z-index: 24; }
.preview { position: fixed; top: 52px; right: 0; bottom: 0; width: min(72vw, 1500px); min-width: min(760px, 100vw);
  background: var(--bg); border-left: 1px solid var(--line-strong); box-shadow: -12px 0 30px rgba(29, 36, 51, .10);
  z-index: 25; display: flex; flex-direction: column; transition: width .18s ease; }
.preview.full { width: calc(100vw - var(--rail)); }
.preview[hidden] { display: none; }
.preview .p-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.preview .p-head .grow { flex: 1; min-width: 0; }
.preview .p-head .fname { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview .icon-btn { width: 34px; height: 34px; padding: 0; justify-content: center; background: transparent; color: var(--ink-2); border-color: transparent; font-size: 18px; }
.preview .icon-btn:hover { background: #efebe4; }
.preview .p-body { flex: 1; overflow: auto; padding: 16px; }
.preview .p-body .card { margin-bottom: 14px; }
.notice { padding: 10px 12px; border-radius: 8px; background: var(--warn); color: var(--warn-ink); margin-bottom: 14px; display: flex; gap: 10px; align-items: center; }

/* ---------------------------------------------------------------- the editing grids (Jspreadsheet CE) */
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid { border-collapse: collapse; width: 100%; }
.grid th, .grid td { border-bottom: 1px solid var(--line); padding: 5px 7px; text-align: left; vertical-align: top; }
.grid th { background: var(--raised); font-weight: 600; white-space: nowrap; font-size: 12.5px; }
.grid.dense td select { max-width: 220px; padding: 3px 5px; font-size: 12.5px; }
.origin { font-size: 12px; padding: 1px 6px; border-radius: 10px; background: #eef0f4; white-space: nowrap; }
.sheet { max-width: 100%; }
.jexcel { font-size: 12px; }
.jexcel > tbody > tr > td { white-space: nowrap; padding: 2px 5px; }
.jexcel > tbody > tr > td.readonly { color: var(--ink); background-color: #fbfbfc; }
.jexcel > tbody > tr > td.src-header { background-color: #e9edf4; font-weight: 600; }
.jexcel > tbody > tr > td.src-total { background-color: #f3f5f9; font-weight: 600; border-top: 1px solid #b9c0cc; }
.jexcel > tbody > tr > td.edited { background-color: var(--edit); }
.jexcel > tbody > tr > td.needs { background-color: var(--bad); }
.jexcel > tbody > tr > td.excluded { color: var(--muted); text-decoration: line-through; }
.jexcel > tbody > tr > td.src-colhead { background-color: #dfe4ec; font-weight: 700; border-bottom: 1px solid #9aa3b2; }
.jexcel > tbody > tr > td.src-total.off { color: var(--bad-ink); }

/* ---------------------------------------------------------------- logs */
.lvl { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 10px; text-transform: uppercase; letter-spacing: .03em; }
.lvl.info { background: #eef0f4; color: var(--ink-2); }
.lvl.warning { background: var(--warn); color: var(--warn-ink); }
.lvl.error { background: var(--bad); color: var(--bad-ink); }
tr.log-detail td { background: #faf8f4; }
tr.log-detail pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 12px; max-height: 360px; overflow: auto; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }

/* ---------------------------------------------------------------- settings */
.settings { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13.5px; }
.kv .k { color: var(--muted); }
.kv .v { word-break: break-word; }

/* ---------------------------------------------------------------- status toast, copy box */
.status { position: fixed; bottom: 18px; right: 18px; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; z-index: 60; max-width: 560px; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.status.error { background: var(--bad-ink); }
.copybox, .modal { position: fixed; inset: 0; background: rgba(20, 26, 40, .45); z-index: 70; display: flex; align-items: center; justify-content: center; }
.copybox .card, .modal .card { width: min(900px, 92vw); }
.modal .card { width: min(460px, 92vw); }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

/* ---------------------------------------------------------------- the bell */
.bell-wrap { position: relative; }
#bell { position: relative; }
#bell svg { width: 20px; height: 20px; }
.bell-dot { position: absolute; top: 6px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad-ink); }
.bell-menu { position: absolute; right: 0; top: 42px; width: min(380px, calc(100vw - 32px)); max-height: 70vh; overflow: auto;
  padding: 12px; z-index: 40; box-shadow: 0 10px 30px rgba(29, 36, 51, .12); }
.bell-menu h3 { margin: 0 0 8px; font-size: 14px; }
.bell-item { display: block; padding: 8px 10px; border-radius: 8px; color: var(--ink); font-size: 13px; line-height: 1.4; }
.bell-item:hover { background: #f4f1eb; text-decoration: none; }
.bell-item .muted { display: block; font-size: 12px; }
.bell-item.new { background: var(--accent-soft); }
.bell-item.warn { background: var(--warn); color: var(--warn-ink); }

/* ---------------------------------------------------------------- the Vault */
.small { font-size: 12.5px; }
.v-deal { margin-bottom: 12px; padding: 0; }
.v-deal > summary { display: flex; align-items: center; gap: 12px; padding: 14px 18px; cursor: pointer; list-style: none; }
.v-deal > summary::-webkit-details-marker, .v-folder > summary::-webkit-details-marker { display: none; }
.v-deal > summary::before, .v-folder > summary::before { content: "▸"; color: var(--faint); transition: transform .12s; }
.v-deal[open] > summary::before, .v-folder[open] > summary::before { transform: rotate(90deg); }
.v-deal > summary .v-name { font-weight: 650; font-size: 15px; }
.v-deal > summary a { margin-left: auto; }
.v-deal[open] > summary { border-bottom: 1px solid var(--line); }
.v-folder { margin: 0 18px; border-bottom: 1px solid var(--line); }
.v-folder:last-child { border-bottom: 0; margin-bottom: 6px; }
.v-folder > summary { display: flex; align-items: center; gap: 8px; padding: 10px 0; cursor: pointer; list-style: none; font-weight: 600; font-size: 13.5px; }
.v-folder > summary svg { width: 17px; height: 17px; color: var(--muted); }
.v-folder > summary button { margin-left: auto; }
.v-folder.trash > summary { color: var(--bad-ink); }
.v-file { display: flex; align-items: center; gap: 12px; padding: 9px 0 9px 26px; border-top: 1px dashed var(--line); flex-wrap: wrap; }
.v-file .fname { font-weight: 550; font-size: 13.5px; word-break: break-word; }
.v-file .error { color: var(--bad-ink); }
.v-empty { padding: 0 0 10px 26px; margin: 0; }

/* the deal's sections */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 4px 0 20px; overflow-x: auto; }
.tabs button { background: transparent; color: var(--ink-2); border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  padding: 9px 14px; white-space: nowrap; font-weight: 500; }
.tabs button:hover { color: var(--ink); background: transparent; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 650; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 22px; }
.kpi { padding: 14px 16px; }
.kpi .k { font-size: 12px; color: var(--muted); }
.kpi .v { font-size: 21px; font-weight: 650; margin: 2px 0; font-variant-numeric: tabular-nums; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions button { margin-left: 4px; }
button.small { padding: 4px 9px; font-size: 12.5px; }
table.list tr.chosen td { background: var(--accent-soft); }
td.neg { color: var(--bad-ink); }
.chart-head select { margin-left: auto; padding: 4px 8px; font-size: 12.5px; }
.ledger-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); max-height: 70vh; }
table.ledger { border-collapse: separate; border-spacing: 0; font-size: 12.5px; font-variant-numeric: tabular-nums; }
table.ledger th, table.ledger td { padding: 6px 10px; border-bottom: 1px solid #f0ece5; white-space: nowrap; }
table.ledger thead th { position: sticky; top: 0; background: var(--raised); color: var(--muted); font-weight: 600; z-index: 2; }
table.ledger .sticky { position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 220px; max-width: 320px;
  overflow: hidden; text-overflow: ellipsis; border-right: 1px solid var(--line); }
table.ledger thead th.sticky { z-index: 3; background: var(--raised); }
table.ledger tr.group td { background: var(--raised); font-weight: 650; color: var(--ink-2); }
table.ledger tr.total td { font-weight: 650; border-top: 1px solid var(--line-strong); }
.soon-card { margin-bottom: 24px; background: var(--raised); }
.soon-card h2 { margin: 8px 0 6px; }
.soon-card p { max-width: 760px; margin: 6px 0; }
.soon-card .pill { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
