  :root {
    --ink: #111111; --ink-2: #4a4a4a; --ink-3: #6b6b6b;
    --surface: #ffffff; --page: #f7f6f3; --line: #e6e3dc; --line-2: #d4d0c6;
    --gold: #d8b758; --gold-ink: #9c7b23; --gold-wash: #f6efd9;
    --good-text: #006300; --warn-text: #8a5a00; --bad: #d03b3b; --bad-text: #a32626;
    --serif: "Cormorant Garamond", "Minion Pro", Georgia, serif;
    --sans: "Inter", "Proxima Nova", Helvetica, Arial, sans-serif;
    --r: 6px;
  }
  * { box-sizing: border-box; }
  html, body { margin: 0; }
  body { font: 14px/1.5 var(--sans); color: var(--ink); background: var(--page); font-variant-numeric: tabular-nums; }
  a { color: inherit; }
  :focus-visible { outline: 2px solid var(--gold-ink); outline-offset: 2px; border-radius: 3px; }
  button { font: inherit; }


  .shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
  .side { background: #0d0d0d; color: #fff; padding: 24px 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
  .brand { font-family: var(--sans); font-weight: 600; font-size: 17px; letter-spacing: .01em; line-height: 1.2; margin: 0 0 4px; color: #fff; text-decoration: none; }
  .brand-sub { font-size: 10px; letter-spacing: .28em; text-transform: uppercase; color: var(--gold); margin-bottom: 16px; }
  .nav-h { font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: #8d8d8d; margin: 20px 8px 8px; }
  .nav a { display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: var(--r); text-decoration: none; color: #d9d9d9; min-height: 40px; }
  .nav a:hover { background: #1e1e1e; color: #fff; }
  .nav a[aria-current="page"] { background: #1e1e1e; color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
  .nav svg { width: 18px; height: 18px; flex: none; }
  .nav .count { margin-left: auto; font-size: 11px; font-weight: 600; background: #a32626; color: #fff; border-radius: 99px; padding: 0 7px; }
  .switcher { margin: 8px 0 0; }
  .switcher label { font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: #8d8d8d; display: block; margin: 0 8px 4px; }
  .switcher select { width: 100%; background: #1e1e1e; color: #fff; border: 1px solid #3a3a3a; }
  .side .who { margin-top: auto; padding-top: 24px; font-size: 11px; color: #8d8d8d; }
  .side :focus-visible { outline-color: var(--gold); }
  .menu-btn { display: none; }

  .main { padding: 24px 32px 48px; min-width: 0; }
  .crumbs { font-size: 12px; color: var(--ink-3); margin-bottom: 2px; }
  .crumbs a { text-decoration: none; } .crumbs a:hover { text-decoration: underline; }
  h1 { font-family: var(--sans); font-weight: 600; font-size: 26px; line-height: 1.25; letter-spacing: -.01em; margin: 0; }
  .head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
  .head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
  select, input, textarea { font: inherit; border: 1px solid var(--line-2); background: var(--surface); border-radius: var(--r); padding: 7px 10px; min-height: 36px; color: var(--ink); }
  input.num { text-align: right; font-variant-numeric: tabular-nums; }

  .btn { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: var(--r); border: 1px solid var(--line-2); background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; font-weight: 500; }
  .btn:hover { border-color: var(--ink-3); }
  .btn.primary { background: #0d0d0d; color: #fff; border-color: #0d0d0d; }
  .btn.primary:hover { background: #2a2a2a; }
  .btn.gold { background: var(--gold); border-color: var(--gold); color: #111; }
  .btn:disabled { opacity: .45; cursor: not-allowed; }
  .btn svg { width: 16px; height: 16px; }

  .grid { display: grid; gap: 16px; }
  .tiles { grid-template-columns: repeat(5, minmax(0, 1fr)); margin-bottom: 16px; }
  .two { grid-template-columns: 3fr 2fr; margin-bottom: 16px; }
  .halves { grid-template-columns: 1fr 1fr; margin-bottom: 16px; }
  .card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px; min-width: 0; }
  .card h2 { font-family: var(--sans); font-weight: 600; font-size: 17px; line-height: 1.35; margin: 0 0 2px; }
  .card .sub { font-size: 12px; color: var(--ink-3); margin: 0 0 12px; }
  .tile .k { font-size: 12px; color: var(--ink-3); }
  .tile .v { font-size: 26px; font-weight: 600; line-height: 1.2; margin: 4px 0 2px; }
  .tile .d { font-size: 12px; color: var(--ink-2); }
  .tile .chip { white-space: normal; border-radius: 10px; max-width: 100%; }
  .tile.hero { border-top: 3px solid var(--gold); }
  .neg { color: var(--bad-text); }

  .chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; padding: 1px 8px 1px 6px; border-radius: 99px; white-space: nowrap; background: #efede8; color: var(--ink-2); }
  .chip svg { width: 13px; height: 13px; }
  .chip.good { background: #e7f6e7; color: var(--good-text); }
  .chip.warn { background: #fff4dc; color: var(--warn-text); }
  .chip.bad { background: #fbe7e7; color: var(--bad-text); }
  .tag { font-size: 11px; border: 1px solid var(--line-2); border-radius: 99px; padding: 0 7px; color: var(--ink-2); white-space: nowrap; }
  .pending-note { display: inline-flex; gap: 6px; align-items: center; background: var(--gold-wash); border: 1px solid #ecdcae; border-radius: 99px; padding: 3px 12px; font-size: 12px; color: var(--ink-2); }

  .tbl-wrap { overflow-x: auto; }
  table { width: 100%; border-collapse: collapse; }
  th, td { text-align: right; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
  th:first-child, td:first-child, th.l, td.l { text-align: left; }
  th { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); vertical-align: bottom; }
  td.num, th.num { white-space: nowrap; }
  tfoot td { font-weight: 600; border-top: 2px solid var(--ink); border-bottom: 0; }
  tbody.totals td { font-weight: 500; background: #fcfbf8; }
  tbody.totals tr:first-child td { border-top: 1px solid var(--ink-3); }
  tr.sub td { font-weight: 600; border-top: 1px solid var(--ink-3); background: #fcfbf8; }
  tbody.totals tr.sub td { font-weight: 600; border-top: 1px solid var(--ink-3); }
  tr.key td, tbody.totals tr.key td { font-size: 15px; font-weight: 700; }
  tr.group td { background: #faf8f2; font-weight: 600; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); }
  .figlink { all: unset; cursor: pointer; border-bottom: 1px dotted var(--ink-3); }
  .figlink:hover { border-bottom-color: var(--ink); }
  .figlink:focus-visible { outline: 2px solid var(--gold-ink); outline-offset: 2px; }
  td.flag { background: #fff8e6; }
  .flag-ic { color: var(--warn-text); font-size: 11px; margin-left: 6px; white-space: nowrap; }

  .actlist { list-style: none; margin: 0; padding: 0; }
  .actlist li { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .actlist li:last-child { border-bottom: 0; }
  .actlist .ic { width: 28px; height: 28px; border-radius: 99px; display: grid; place-items: center; }
  .actlist .ic svg { width: 16px; height: 16px; }
  .ic.bad { background: #fbe7e7; color: var(--bad-text); } .ic.warn { background: #fff4dc; color: var(--warn-text); } .ic.info { background: #efede8; color: var(--ink-2); }
  .actlist .t { font-weight: 500; }
  .actlist .s { font-size: 12px; color: var(--ink-3); }

  .addr { overflow-wrap: anywhere; }
  .muted { color: var(--ink-3); }
  .small { font-size: 12px; }
  .empty { text-align: center; padding: 32px; color: var(--ink-3); }

  /* Side panel (drill-down) */
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.28); z-index: 40; }
  .panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100vw); background: #fff; z-index: 41; box-shadow: -8px 0 32px rgba(0,0,0,.15); display: flex; flex-direction: column; }
  .panel header { padding: 18px 20px 12px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
  .panel header h2 { font-family: var(--sans); font-weight: 600; font-size: 20px; margin: 0; }
  .panel .body { padding: 12px 20px 24px; overflow-y: auto; }
  .xbtn { all: unset; cursor: pointer; width: 36px; height: 36px; display: grid; place-items: center; border-radius: var(--r); }
  .xbtn:hover { background: #efede8; } .xbtn:focus-visible { outline: 2px solid var(--gold-ink); }
  details.loan { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; }
  details.loan summary { list-style: none; cursor: pointer; padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; }
  details.loan summary::-webkit-details-marker { display: none; }
  details.loan[open] summary { border-bottom: 1px solid var(--line); }
  details.loan table { font-size: 13px; }

  /* Review tray */
  .tray { display: grid; grid-template-columns: 280px minmax(0,.85fr) minmax(0,1.4fr); gap: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px; min-height: 640px; overflow: hidden; }
  .tray .q { border-right: 1px solid var(--line); overflow-y: auto; max-height: 760px; }
  .tray .q .qh { padding: 10px 12px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; position: sticky; top: 0; background: #fff; z-index: 1; }
  .qi { display: grid; grid-template-columns: 24px 1fr; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
  .qi:hover { background: #faf8f2; }
  .qi.sel { background: #faf6ea; box-shadow: inset 3px 0 0 var(--gold); }
  .qi .t { font-weight: 500; font-size: 13px; }
  .qi .s { font-size: 12px; color: var(--ink-3); }
  .doc { background: #ecebe7; padding: 16px; border-right: 1px solid var(--line); overflow-y: auto; max-height: 760px; }
  .paper { background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.12); padding: 28px; font-size: 12px; min-height: 560px; font-family: Georgia, serif; }
  .paper h3 { margin: 0 0 4px; font-size: 16px; }
  .paper table { font-size: 12px; } .paper td, .paper th { padding: 4px 6px; }
  .prop { padding: 16px; overflow-y: auto; max-height: 760px; }
  /* Wide preview: list | preview on top, proposed lines across the bottom */
  .tray.wide { grid-template-columns: 280px minmax(0,1fr); grid-template-rows: 560px auto; }
  .tray.wide .doc { display: block; border-right: 0; max-height: none; }
  .tray.wide .q { max-height: none; }
  .tray.wide .prop { grid-column: 1 / -1; border-top: 1px solid var(--line); max-height: none; }
  .tray.wide .prop .formgrid { grid-template-columns: 200px 200px !important; }
  .lowconf { background: #fff4dc !important; border-color: #e7b84a !important; }
  .kbd { font: 11px/1 ui-monospace, monospace; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; padding: 2px 5px; background: #fff; }
  .dup { border: 1px solid #ecdcae; background: var(--gold-wash); border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }

  /* Lines form */
  .lines td { padding: 6px; vertical-align: middle; }
  .lines select, .lines input { width: 100%; }
  .totalbar { display: flex; justify-content: flex-end; gap: 24px; align-items: center; padding: 12px 6px; flex-wrap: wrap; }
  .totalbar .diff { font-weight: 600; }

  .field { display: flex; flex-direction: column; gap: 4px; }
  .field label { font-size: 12px; color: var(--ink-3); }
  .field input, .field select { width: 100%; min-width: 0; }
  .prop table.lines { table-layout: fixed; }
  .prop table.lines th:nth-child(1) { width: 44%; } .prop table.lines th:nth-child(3) { width: 24%; }
  .tray > * { min-width: 0; }
  .formgrid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px 16px; margin-bottom: 16px; }

  .tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
  .tabs a { padding: 10px 12px; text-decoration: none; color: var(--ink-2); border-bottom: 2px solid transparent; white-space: nowrap; }
  .tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--gold); font-weight: 600; }

  .kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13px; }
  .kv dt { color: var(--ink-3); }
  .kv dd { margin: 0; }

  /* property timeline */
  .tl { padding: 0; overflow-x: auto; }
  .tl-inner { min-width: 980px; padding: 8px 16px 12px; }
  .tl-row { display: grid; grid-template-columns: 250px 1fr 130px; gap: 12px; align-items: center; min-height: 52px; border-bottom: 1px solid var(--line); }
  .tl-name { position: sticky; left: 0; background: #fff; z-index: 3; padding: 6px 0; font-size: 13px; line-height: 1.3; }
  .tl-name a { color: var(--ink); text-decoration: none; font-weight: 600; }
  .tl-name a:hover { text-decoration: underline; }
  .tl-track { position: relative; height: 30px; }
  .tl-fig { text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }
  .tl-axis { min-height: 30px; border-bottom: 1px solid var(--ink-2); }
  .tl-axis .tl-track span { position: absolute; top: 6px; text-align: center; font-size: 11px; }
  .tl-axis .tl-track a { color: var(--ink-2); text-decoration: none; }
  .tl-axis .tl-track a:hover { color: var(--ink); text-decoration: underline; }
  .tl-grid i { position: absolute; top: -12px; bottom: -12px; border-left: 1px dashed #e4e1d9; }
  .tl-today { position: absolute; top: -12px; bottom: -12px; border-left: 2px solid #d03b3b; z-index: 2; }
  .tl-band { position: absolute; top: -12px; bottom: -12px; background: rgba(216,183,88,.14); }
  .tl-seg { position: absolute; top: 5px; height: 20px; border-radius: 4px; overflow: hidden; font-size: 11px; line-height: 20px; padding: 0 6px; white-space: nowrap; z-index: 1; }
  .tl-seg.home { background: var(--gold); color: #0d0d0d; font-weight: 600; }
  .tl-seg.rent { background: #3d3d3d; color: #fff; }
  .tl-pre { position: absolute; top: 14px; height: 2px; background: #8d8d8d; }
  .tl-mark { position: absolute; top: 9px; width: 10px; height: 10px; margin-left: -5px; transform: rotate(45deg); border: 2px solid #3d3d3d; background: #fff; z-index: 2; }
  .tl-mark.sold { border-color: #d03b3b; }
  .tl-end { position: absolute; top: 5px; margin-left: 4px; font-size: 11px; font-weight: 600; color: #a32626; line-height: 20px; }
  .tl-ent { padding: 14px 0 4px; font-weight: 600; font-size: 13px; border-bottom: 1px solid var(--line); position: sticky; left: 0; }
  .tl-mr { background: #fbf8ef; }
  .tl-mr .tl-name { background: #fbf8ef; }
  .tl-total { border-bottom: 0; }
  @media (max-width: 760px) {
    .tl-inner { min-width: 760px; padding: 6px 10px 10px; }
    .tl-row { grid-template-columns: 120px 1fr 92px; gap: 8px; }
    .tl-name { font-size: 11px; box-shadow: 6px 0 6px -6px rgba(0,0,0,.25); }
    .tl-name .small { display: none; }
    .tl-fig { font-size: 11px; }
  }
  .tl-legend { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 10px; color: var(--ink-2); }
  .tl-legend i { display: inline-block; width: 14px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
  .tl-legend i.home { background: var(--gold); } .tl-legend i.rent { background: #3d3d3d; }
  .tl-legend i.pre { height: 2px; background: #8d8d8d; vertical-align: 3px; }
  .tl-legend i.mk { width: 9px; height: 9px; border: 2px solid #3d3d3d; transform: rotate(45deg); border-radius: 0; }
  .tl-legend i.today { width: 2px; height: 12px; background: #d03b3b; }
  .linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--gold-text, #9c7b23); text-decoration: underline; cursor: pointer; min-height: auto; }
  .toast .linkbtn { color: #fff; font-weight: 600; }
  .toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #0d0d0d; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 60; display: flex; gap: 8px; align-items: center; }
  .toast svg { color: var(--gold); width: 16px; height: 16px; }

  .bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 8px; }
  .bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
  .bars .b i { display: block; width: 100%; background: var(--gold); border-radius: 3px 3px 0 0; min-height: 2px; }
  .bars .b i.pend { background: repeating-linear-gradient(45deg, #ecdcae, #ecdcae 4px, #fff 4px, #fff 8px); border: 1px solid #ecdcae; }
  .bars .b span { font-size: 11px; color: var(--ink-3); }

  .ready { height: 8px; border-radius: 99px; background: #efede8; overflow: hidden; min-width: 100px; }
  .ready i { display: block; height: 100%; background: var(--gold); }

  /* Phones */
  @media (max-width: 1100px) {
    .tiles { grid-template-columns: repeat(3, minmax(0,1fr)); }
    .two, .halves { grid-template-columns: 1fr; }
    .tray { grid-template-columns: 260px 1fr; }
    .tray .doc { display: none; }
  }
  @media (max-width: 760px) {
    .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; align-content: start; }
    .tray.wide { grid-template-columns: 1fr; grid-template-rows: auto; }
    .tray.wide .doc { display: none; }
    .side { position: sticky; top: 0; z-index: 20; height: auto; padding: 10px 16px; flex-direction: row; flex-wrap: wrap; align-items: center; }
    .side { transition: transform .2s ease; }
    .side.hide:not(.open) { transform: translateY(-100%); }
    .brand { font-size: 16px; margin: 0; } .brand-sub { display: none; }
    .menu-btn { display: inline-flex; align-items: center; margin-left: auto; background: transparent; color: #fff; border: 1px solid #3a3a3a; border-radius: 6px; min-height: 44px; padding: 0 14px; cursor: pointer; }
    .side nav, .side .switcher, .side .who { display: none; width: 100%; }
    .side.open nav, .side.open .switcher { display: block; }
    .nav a { min-height: 44px; }
    .main { padding: 16px; }
    .tiles { grid-template-columns: 1fr 1fr; }
    .tile .v { font-size: 20px; }
    h1 { font-size: 22px; }
    .formgrid { grid-template-columns: 1fr; }
    .tray { grid-template-columns: 1fr; }
    .tray .q { max-height: 240px; border-right: 0; border-bottom: 1px solid var(--line); }
    .btn { min-height: 44px; }
    .actlist li { grid-template-columns: 28px 1fr; }
    .actlist li > div:last-child:not(:nth-child(2)) { grid-column: 2; }
    /* Wide tables become cards */
    table.cards thead { display: none; }
    table.cards tr { display: block; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; padding: 6px 10px; }
    table.cards td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 4px 0; text-align: right; }
    table.cards td::before { content: attr(data-l); color: var(--ink-3); font-size: 12px; text-align: left; flex: none; }
  }

  /* Live app additions */
  .loading { padding: 40px; text-align: center; color: var(--ink-3); }
  .err { color: var(--bad-text); font-size: 12px; margin-top: 4px; }
  .formerr { background: #fbe7e7; color: var(--bad-text); border-radius: 8px; padding: 8px 12px; margin: 8px 0; font-size: 13px; }
  .note { background: var(--gold-wash); border: 1px solid #ecdcae; border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
  .preview { width: 100%; height: 100%; min-height: 620px; border: 0; background: #fff; }
  .doc img.preview { object-fit: contain; height: auto; min-height: 0; }
  .tray.wide .preview { min-height: 540px; }
  .drop { text-align: center; padding: 40px 20px; border: 2px dashed var(--line-2); border-radius: 10px; background: #fff; }
  .drop.over { border-color: var(--gold); background: var(--gold-wash); }
  .txblock { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
  .txblock.low { border-color: #e7b84a; }
  .txblock .hdr { display: grid; grid-template-columns: 130px 1fr 130px; gap: 8px; margin-bottom: 6px; }
  .rowbtns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
  .chk { display: flex; gap: 8px; align-items: center; min-height: 36px; }
  .chk input { min-height: auto; }
  .hidden { display: none !important; }
  .side .who a, .side .who button { color: #c9c9c9; background: none; border: 0; padding: 0; font: inherit; text-decoration: underline; cursor: pointer; }
  .tl-name .addr { overflow-wrap: anywhere; }
  .pill-proposed { background: var(--gold-wash); color: var(--warn-text); }
  dialog { border: 1px solid var(--line); border-radius: 10px; padding: 20px; max-width: 460px; width: calc(100vw - 32px); }
  dialog::backdrop { background: rgba(0,0,0,.3); }
  @media (max-width: 760px) { .txblock .hdr { grid-template-columns: 1fr; } }
  .tl-ent-l { position: sticky; left: 0; display: inline-block; background: #fff; padding-right: 8px; }
