/* PARADYSE Development. Fonts and tokens first, then layout, components, and the phone block last.
   Colours and type come from the PARADYSE brand guidelines (2025):
   Bistre #382C24, Black Olive #3B3A2D, Reseda Green #828169, Payne's Gray #5B7483,
   Anti White #EBEDED, Eggshell #ECE6D5. Helixa for headings, Codec Pro Bold for
   subheadings and labels, Neue Haas for text. Tints and shades of those six are
   used where the pure colour would fail WCAG AA contrast. */

@font-face {
  font-family: "Helixa"; font-weight: 700; font-style: normal; font-display: swap;
  src: url("/assets/fonts/Helixa-Bold.ttf") format("truetype");
}
@font-face {
  font-family: "Codec Pro"; font-weight: 700; font-style: normal; font-display: swap;
  src: url("/assets/fonts/CodecPro-Bold.ttf") format("truetype");
}
@font-face {
  font-family: "Neue Haas Display"; font-weight: 400; font-style: normal; font-display: swap;
  src: url("/assets/fonts/NeueHaasDisplayRegular.ttf") format("truetype");
}
@font-face {
  font-family: "Neue Haas Display"; font-weight: 500; font-style: normal; font-display: swap;
  src: url("/assets/fonts/NeueHaasDisplayMedium.ttf") format("truetype");
}

/* Neue Haas Display has no tabular figures, so amounts would not line up in columns.
   Digits only (unicode-range) come from the system's Helvetica/Arial, which is the same
   design family and has fixed-width figures. Everything else stays Neue Haas. */
@font-face {
  font-family: "Paradyse Figures"; font-weight: 400; unicode-range: U+30-39;
  src: local("Helvetica Neue"), local("HelveticaNeue"), local("Helvetica"), local("Arial"), local("Roboto"), local("Liberation Sans");
}
@font-face {
  font-family: "Paradyse Figures"; font-weight: 500; unicode-range: U+30-39;
  src: local("Helvetica Neue Medium"), local("HelveticaNeue-Medium"), local("Roboto Medium"), local("Roboto-Medium"), local("Helvetica Neue"), local("Arial");
}

:root {
  /* page */
  --bg: #f5f3ee;            /* cream, the soft background on the team's landing pages */
  --surface: #ffffff;
  --surface-2: #efebdf;     /* Eggshell, 70% tint */
  --text: #1a1916;          /* Black Olive, deepened for body text */
  --muted: #666553;         /* Reseda Green, darkened for AA (as on paradysehomes.com) */
  --line: #d6d0c4;          /* divider */
  --line-strong: #8f8d78;   /* control borders, 3:1 on white */
  /* actions */
  --accent: #382c24;        /* Bistre */
  --accent-hover: #2a2019;
  --accent-text: #ffffff;
  --link: #46606f;          /* Payne's Gray, darkened for AA */
  --focus: #5b7483;         /* Payne's Gray */
  /* states */
  --ok: #5a8a5a;
  --ok-bg: #e8e8df;
  --info: #3e5564;
  --info-bg: #e6ecef;
  --danger: #b94040;
  --danger-bg: #f8e6e4;
  --danger-text: #ffffff;
  --warn: #7a5510;
  --warn-bg: #f6ebd0;
  /* top bar and sign-in artwork: always dark, white logo (guidelines, "Logo color") */
  --chrome: #3b3a2d;
  --chrome-text: #ffffff;
  --chrome-muted: #d4d0c0;
  --chrome-line: rgb(255 255 255 / .22);
  --chrome-warn: #edd49a;
  --chrome-danger: #ffb9ac;

  --radius: 0;
  --radius-control: 0;
  --ease: cubic-bezier(.25, .46, .45, .94);
  --font: "Paradyse Figures", "Neue Haas Display", "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  --font-head: "Helixa", "Neue Haas Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-label: "Codec Pro", "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  --nav-w: 216px;
  --topbar-h: 56px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141311;          /* olive-black */
    --surface: #1f1d1a;
    --surface-2: #2b2824;
    --text: #f5f3ee;        /* cream */
    --muted: #b0ae98;       /* Reseda Green, lightened */
    --line: #3a362f;
    --line-strong: #858270;
    --accent: #ece6d5;      /* Eggshell */
    --accent-hover: #ffffff;
    --accent-text: #382c24; /* Bistre */
    --link: #a9c0cd;
    --focus: #9db6c4;
    --ok: #7fae7f;
    --ok-bg: #2c3327;
    --info: #bccdd7;
    --info-bg: #26323a;
    --danger: #f0958c;
    --danger-bg: #3f231d;
    --danger-text: #2a120d;
    --warn: #e6c67e;
    --warn-bg: #3a3019;
    --chrome: #0d0c0a;
    --chrome-text: #f5f3ee;
    --chrome-muted: #b0ae98;
    --chrome-line: rgb(255 255 255 / .2);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 400 15px/1.5 var(--font); letter-spacing: .01em;
  font-variant-numeric: tabular-nums; font-synthesis: none;
  -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased;
}
h1 { font: 700 1.75rem/1.1 var(--font-head); letter-spacing: -.02em; margin: 0 0 .5rem; }
h2 { font: 700 .8rem/1.3 var(--font-label); letter-spacing: .08em; text-transform: uppercase; margin: 0; }
p { margin: .5rem 0; }
strong, b { font-weight: 500; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.error { color: var(--danger); }
.num { font-variant-numeric: tabular-nums; margin-left: auto; font-weight: 500; white-space: nowrap; }
.note {
  margin: 0; padding: .7rem .9rem; border-radius: var(--radius-control);
  background: var(--info-bg); color: var(--info); border-left: 3px solid var(--focus);
}
.eyebrow { font: 700 .72rem/1.3 var(--font-label); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 .5rem; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1rem; min-height: var(--topbar-h);
  padding: .5rem 1.25rem; padding-top: max(.5rem, env(safe-area-inset-top));
  padding-left: max(1.25rem, env(safe-area-inset-left)); padding-right: max(1.25rem, env(safe-area-inset-right));
  background: var(--chrome); color: var(--chrome-text); border-bottom: 1px solid var(--chrome-line);
}
.topbar :focus-visible { outline-color: var(--chrome-text); }
.brand { display: flex; align-items: center; gap: .75rem; flex: none; }
.brand-logo { display: block; height: 20px; width: auto; }
.brand-icon { display: none; height: 24px; width: auto; }
.brand-product, .section-title { font: 700 .72rem/1 var(--font-label); letter-spacing: .12em; text-transform: uppercase; }
.brand-product { color: var(--chrome-muted); padding-left: .75rem; border-left: 1px solid var(--chrome-line); line-height: 20px; }
.section-title { color: var(--chrome-text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-title::before { content: "/"; color: var(--chrome-muted); margin-right: 1rem; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .6rem; min-width: 0; }
.save-status { font-size: .85rem; color: var(--chrome-muted); display: inline-flex; align-items: center; gap: .45rem; flex-wrap: wrap; justify-content: flex-end; }
.save-status:not(:empty)::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.save-status.saving { color: var(--chrome-warn); }
.save-status.saving::before { background: var(--chrome-warn); }
.save-status.failing { color: var(--chrome-danger); font-weight: 500; }
.save-status.failing::before { background: var(--chrome-danger); }
.topbar .btn-link { color: inherit; }
.topbar .btn, .topbar select {
  background: transparent; color: var(--chrome-text); border-color: var(--chrome-line);
}
.topbar .btn:hover, .topbar select:hover { background: rgb(255 255 255 / .1); }
.topbar select option { color: #3b3a2d; background: #fff; }

.layout { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.nav { width: var(--nav-w); flex: none; padding: 1.25rem .75rem; display: flex; flex-direction: column; gap: .25rem; border-right: 1px solid var(--line); }
.nav-btn {
  display: flex; align-items: center; gap: .7rem; min-height: 44px; padding: 0 .75rem;
  background: none; border: 0; border-radius: var(--radius-control); color: var(--muted);
  font: inherit; font-weight: 500; text-align: left; cursor: pointer; position: relative;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.nav-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-btn.active { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.nav-btn.active::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0; background: var(--accent); }
.nav-icon { width: 20px; height: 20px; flex: none; background: currentColor; -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; }
.nav-icon[data-icon="home"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 10.5 12 3.5l8.5 7V20a.5.5 0 0 1-.5.5h-5v-6h-6v6H4a.5.5 0 0 1-.5-.5z'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="ledger"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 3.5h14v17H5z'/%3E%3Cpath d='M8.5 8h7M8.5 12h7M8.5 16h4'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="buyers"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='8' r='3.2'/%3E%3Cpath d='M3.5 19.5c.6-3.2 2.9-5 5.5-5s4.9 1.8 5.5 5'/%3E%3Cpath d='M15.5 5.2a3.2 3.2 0 0 1 0 5.6M17.5 14.8c1.6.7 2.7 2.3 3 4.7'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="contractor"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 20.5h16M6 20.5V11l6-4.5 6 4.5v9.5'/%3E%3Cpath d='M10 20.5v-5h4v5'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="costs"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 3.5h12v17l-3-2-3 2-3-2-3 2z'/%3E%3Cpath d='M9 8.5h6M9 12h6'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="decisions"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="ve"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 17l6-6 4 4 6-7'/%3E%3Cpath d='M15 8h5v5'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="sim"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.7' stroke-linecap='round'%3E%3Cpath d='M5 4v16M12 4v16M19 4v16'/%3E%3Ccircle cx='5' cy='14' r='2' fill='%23fff'/%3E%3Ccircle cx='12' cy='8' r='2' fill='%23fff'/%3E%3Ccircle cx='19' cy='16' r='2' fill='%23fff'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="more"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Ccircle cx='5' cy='12' r='1.8'/%3E%3Ccircle cx='12' cy='12' r='1.8'/%3E%3Ccircle cx='19' cy='12' r='1.8'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="settings"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.7' stroke-linecap='round'%3E%3Cpath d='M4 7h9m5 0h2M4 17h2m5 0h9'/%3E%3Ccircle cx='15.5' cy='7' r='2.5'/%3E%3Ccircle cx='8.5' cy='17' r='2.5'/%3E%3C/svg%3E"); }
.main { flex: 1; min-width: 0; padding: 1.75rem 2rem 3rem; overflow-x: hidden; }
.section { max-width: 860px; display: flex; flex-direction: column; gap: 1rem; }
.page-head { padding: .25rem 0 .5rem; }
.page-head h1 { margin: 0 0 .35rem; }
.page-head p { margin: 0; }

/* ---------- components ---------- */
.card { scroll-margin-top: 5.5rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; }
.card-head { display: flex; align-items: center; gap: .5rem; min-height: 34px; margin-bottom: .25rem; }
.card-head h2 { margin-right: auto; }
.card > .muted.small { margin-top: 0; max-width: 60ch; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
  min-height: 40px; padding: 0 1rem; border-radius: var(--radius-control); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); cursor: pointer;
  font: 700 .75rem/1.2 var(--font-label); letter-spacing: .05em; text-transform: uppercase;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--danger-text); }
.btn-danger:hover { background: var(--danger); filter: brightness(1.08); }
.btn-ghost-danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn-ghost-danger:hover { background: var(--danger-bg); }
.btn-small { min-height: 34px; padding: 0 .75rem; font-size: .7rem; }
/* Full-width buttons carry the long labels (and long Indonesian ones): sentence case, larger. */
.btn-block { width: 100%; padding: .5rem 1rem; font-size: .9rem; letter-spacing: .01em; text-transform: none; }
.btn-link { background: none; border: 0; padding: 0; color: var(--link); font: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.icon-btn { background: none; border: 0; border-radius: var(--radius-control); font-size: 1.6rem; line-height: 1; width: 44px; height: 44px; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.rows { list-style: none; margin: .5rem 0 0; padding: 0; }
.row { display: flex; align-items: center; gap: .75rem; padding: .55rem 0; border-top: 1px solid var(--line); }
.row-main { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .4rem; overflow-wrap: anywhere; }
.row-actions { display: flex; gap: .25rem; align-items: center; flex: none; }
.row-actions select { width: auto; min-height: 36px; padding-top: 0; padding-bottom: 0; font-size: 15px; }
.pill { font: 700 .62rem/1 var(--font-label); letter-spacing: .08em; text-transform: uppercase; padding: .32rem .55rem; border-radius: 0; background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); white-space: nowrap; }
.pill-sold { background: var(--ok-bg); box-shadow: none; }
.pill-retained { background: var(--info-bg); color: var(--info); box-shadow: none; }
.pill-reserved, .pill-partial { background: var(--warn-bg); color: var(--warn); box-shadow: none; }
.pill-escrow { background: transparent; color: var(--muted); }
.pill-overdue { background: var(--danger); color: var(--danger-text); box-shadow: none; }
.due-line .num { font-weight: 700; color: var(--warn); }
.row-sub { flex-basis: 100%; }
.import-group { margin-top: 1rem; }
.import-group h3 { font: 700 .72rem/1.3 var(--font-label); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 .25rem; }
.import-group p { margin: .2rem 0; }
.warn-text { color: var(--warn); }
.import-errors { margin: .5rem 0 0; padding-left: 1.1rem; font-size: .875rem; }
/* ---------- ledger ---------- */
.cash-list { margin-top: .5rem; }
.cash-entity, .cash-total { justify-content: space-between; }
.cash-total { border-top: 2px solid var(--line-strong); font-weight: 500; }
.cash-amounts { display: flex; flex-direction: column; align-items: flex-end; gap: .1rem; }
.cash-amounts .num { margin-left: 0; }
.cash-subs { list-style: none; margin: 0 0 .4rem; padding: 0 0 0 1rem; }
.cash-sub { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .1rem .75rem; font-size: .875rem; color: var(--muted); padding: .15rem 0; }
.cash-sub .num { font-weight: 400; }
.cash-escrow { margin-top: 1rem; }
.cash-escrow h3, .import-group h3 { font: 700 .72rem/1.3 var(--font-label); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 .25rem; }
.cash-escrow .row { justify-content: space-between; font-size: .9rem; }
.negative { color: var(--danger); }
.ledger-filters { display: flex; flex-wrap: wrap; gap: .5rem; margin: .75rem 0; }
.ledger-filters select, .ledger-filters input { min-height: 40px; }
.ledger-filters input[type=search] { flex: 1; min-width: 12rem; }
.ledger-totals { margin: .15rem 0; font-variant-numeric: tabular-nums; font-weight: 500; overflow-wrap: anywhere; }
.ledger-list .ledger-row { padding: 0; }
.row-button { all: unset; box-sizing: border-box; display: flex; gap: .75rem; align-items: center; width: 100%; padding: .6rem .25rem; cursor: pointer; }
.row-button:hover { background: var(--surface-2); }
.row-button:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.ledger-row > .row-main { padding: .6rem 0; }
.ledger-date { margin-left: 0; font-weight: 400; color: var(--muted); font-size: .85rem; }
.ledger-amount { display: flex; flex-direction: column; align-items: flex-end; text-align: right; flex: none; }
.ledger-amount .num { margin-left: 0; }
.amount-in { color: var(--text); }
.check-grid { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
.sheet-delete { margin-right: auto; }
details.field > summary { cursor: pointer; padding: .3rem 0; }
/* ---------- buyers ---------- */
.rate-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .5rem; padding-top: .6rem; border-top: 1px solid var(--line); }
.rate-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.buyer-card .card-head > div { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.leg { margin-top: .9rem; }
.leg-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .6rem; }
.bar { height: 8px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); margin: .4rem 0; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.leg-figures { display: flex; flex-wrap: wrap; gap: .2rem 1rem; margin: 0; }
.buyer-more { margin-top: .75rem; }
.buyer-more > summary { cursor: pointer; font: 700 .72rem/1.3 var(--font-label); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: .4rem 0; min-height: 32px; }
.inst-row { align-items: flex-start; }
.dec-text { margin: .3rem 0 0; }
.dec-more > summary { cursor: pointer; font-size: .8rem; color: var(--muted); padding: .2rem 0; }
.dec-actions { flex-direction: column; align-items: stretch; }
.ve-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 1rem; }
.ve-figs { display: flex; gap: 2rem; flex-wrap: wrap; }
.ve-figs > div { display: flex; flex-direction: column; gap: .15rem; }
.ve-figs .eyebrow { margin: 0; }
.ve-big { font: 700 1.6rem/1.1 var(--font-head); margin-left: 0; }
.ve-tabs { display: flex; gap: 0; }
.ve-tabs .tab { border-radius: 0; }
.ve-tabs .tab-on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.ve-preview { font-weight: 600; margin: .25rem 0; }
.sim-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 1rem; align-items: start; }
.sim-results { position: sticky; top: 5rem; }
.sim-net { display: flex; flex-direction: column; gap: .15rem; margin-bottom: .5rem; }
.sim-row { justify-content: space-between; gap: .75rem; }
.sim-price { display: flex; align-items: center; gap: .35rem; margin-left: auto; }
.sim-price input { width: 9.5rem; text-align: right; }
.sim-fx input { max-width: 10rem; }
.sim-line { display: flex; gap: .35rem; }
.sim-save { display: flex; gap: .5rem; margin: .5rem 0; }
.sim-save input { flex: 1; }
.up { color: var(--text); } .down { color: var(--danger); }
.cost-group { font: 700 .72rem/1.3 var(--font-label); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 1.1rem 0 .2rem; }
.cost-done { cursor: pointer; font: 700 .8rem/1.3 var(--font-label); letter-spacing: .08em; text-transform: uppercase; padding: .3rem 0; }
.ledger-amount .btn { margin-top: .35rem; }
/* ---------- overview ---------- */
.curve-wrap { margin: .5rem 0; }
.curve { width: 100%; height: auto; display: block; }
.curve-axis { stroke: var(--line-strong); stroke-width: 1; }
.curve-bar { fill: var(--accent); }
.curve-warn { fill: var(--warn); }
.curve-neg { fill: var(--danger); }
.curve-label { font: 500 10px var(--font-label); fill: var(--muted); text-anchor: middle; }
.curve-row { display: grid; grid-template-columns: 3.4rem repeat(3, minmax(0, 1fr)); gap: .4rem; font-size: .875rem; align-items: baseline; white-space: nowrap; }
@media (max-width: 640px) { .curve-row { font-size: .74rem; gap: .75rem; grid-template-columns: 2.9rem repeat(3, minmax(0, 1fr)); } }
.curve-row > :not(:first-child) { text-align: right; }
.curve-head .eyebrow { margin: 0; font-size: .65rem; }
.curve-row .num { margin-left: 0; }
.table-wrap { overflow-x: auto; margin: .5rem 0; }
table.pl { width: 100%; border-collapse: collapse; font-size: .875rem; font-variant-numeric: tabular-nums; }
table.pl th, table.pl td { padding: .45rem .5rem; border-top: 1px solid var(--line); text-align: right; white-space: nowrap; }
table.pl th[scope=row], table.pl thead th:first-child { text-align: left; }
table.pl thead th { font: 700 .68rem/1.3 var(--font-label); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border-top: 0; }
table.pl tfoot th, table.pl tfoot td { border-top: 2px solid var(--line-strong); font-weight: 500; }
.pl-kind { display: block; font-size: .72rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.facts { display: grid; grid-template-columns: minmax(7rem, 16rem) 1fr; margin: .5rem 0 0; }
.facts dt, .facts dd { margin: 0; padding: .5rem 0; border-top: 1px solid var(--line); }
.facts dt { color: var(--muted); padding-right: 1rem; }
.facts dd { font-weight: 500; overflow-wrap: anywhere; }

.checklist { list-style: none; padding: 0; margin: .75rem 0 .5rem; }
.check-item { display: flex; align-items: center; gap: .7rem; padding: .6rem 0; border-top: 1px solid var(--line); }
.check-item:last-child { border-bottom: 1px solid var(--line); }
.check-item .muted { margin-left: auto; font-size: .875rem; text-align: right; }
.check-item.done { font-weight: 500; }
.check-link { display: flex; align-items: center; gap: .7rem; flex: 1; min-height: 44px; color: inherit; text-decoration: none; }
.check-link:hover .check-label { text-decoration: underline; text-underline-offset: 3px; }
.check-link .muted { margin-left: auto; font-size: .875rem; text-align: right; }
.check-link::after { content: "›"; color: var(--muted); font-size: 1.2rem; line-height: 1; }
.check-item:has(.check-link) { padding: 0; }
.loading-line { color: var(--muted); }
.loading-block { min-height: 12rem; display: flex; align-items: center; }
.check-mark { width: 18px; height: 18px; flex: none; border-radius: 50%; border: 1.5px solid var(--line-strong); }
.check-item.done .check-mark {
  border-color: var(--ok);
  background: var(--ok) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 9.3 2.6 2.6L13 6.5'/%3E%3C/svg%3E") center / 15px no-repeat;
}

.form { display: flex; flex-direction: column; gap: .8rem; }
.field { display: flex; flex-direction: column; gap: .3rem; border: 0; padding: 0; margin: 0; min-width: 0; }
.field-label { font: 700 .68rem/1.3 var(--font-label); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 0; }
.field-hint { font-size: .8rem; color: var(--muted); }
.field-error { font-size: .8rem; color: var(--danger); min-height: 0; }
.field-error:empty { display: none; }
.field-row { display: grid; grid-template-columns: 120px 1fr; gap: .75rem; }
.field-row.even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
/* Elements hidden by script stay hidden even when a layout class sets display. */
[hidden] { display: none !important; }
input, select, textarea {
  font: inherit; font-size: 16px; letter-spacing: 0; color: var(--text); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-control); padding: .55rem .7rem; min-height: 44px; width: 100%;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; border-color: var(--focus); }
input[type="checkbox"] { width: 20px; min-height: 20px; height: 20px; padding: 0; accent-color: var(--accent); flex: none; }
textarea { min-height: 0; resize: vertical; }
select:disabled { opacity: 1; color: var(--muted); background: var(--surface-2); border-color: var(--line); }
[aria-invalid] { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.check { display: flex; align-items: center; gap: .5rem; min-height: 44px; }
fieldset.field .check { display: inline-flex; margin-right: 1rem; }
.amount { display: flex; flex-direction: column; gap: .2rem; }
.amount-hint { font-size: .8rem; color: var(--muted); min-height: 1em; }
select.lang { width: auto; min-height: 34px; padding: 0 .4rem; font: 700 .72rem/1 var(--font-label); letter-spacing: .08em; }

.banner { display: flex; align-items: center; gap: 1rem; padding: .7rem 1.25rem; }
.banner-error { background: var(--danger-bg); color: var(--danger); font-weight: 500; border-bottom: 1px solid var(--line); }
.banner .btn { margin-left: auto; flex: none; }

/* Shown by index.html until the app has started. */
.center-card { max-width: 420px; margin: 30vh auto 0; padding: 1.5rem; text-align: center; }

/* ---------- sign-in ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(280px, 42%) 1fr; }
.auth-art {
  position: relative; display: flex; flex-direction: column; padding: 2.5rem; color: #fff;
  background:
    linear-gradient(180deg, rgb(59 58 45 / .72) 0%, rgb(59 58 45 / .28) 45%, rgb(56 44 36 / .6) 100%),
    #3b3a2d url("/assets/img/signin.jpg") 62% center / cover no-repeat;
}
.auth-logo { display: block; height: 26px; width: auto; align-self: flex-start; }
.auth-art .eyebrow { color: #fff; margin: .9rem 0 0; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 2rem; }
.auth-box { width: 100%; max-width: 400px; padding: 2rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.auth-box h1 { margin-bottom: 1rem; }
.auth-box .form, .auth-box .field { margin-top: .9rem; }
.auth-box .form .field { margin-top: 0; }
.auth-box .btn-block { min-height: 48px; margin-top: 1.1rem; }
.auth-box .form .btn-block { margin-top: .2rem; }
.auth-box .btn-link { align-self: flex-start; min-height: 44px; }
.auth-box .note strong { display: block; }
.auth-box .note .small { display: block; margin-top: .15rem; }

/* ---------- sheets and toasts ---------- */
.sheet { border: 0; padding: 0; border-radius: var(--radius); width: min(520px, calc(100vw - 32px)); max-height: 85vh; background: var(--surface); color: var(--text); box-shadow: 0 16px 48px rgb(27 26 20 / .28); }
.sheet::backdrop { background: rgb(27 26 20 / .55); }
.sheet[open] { display: flex; flex-direction: column; }
.sheet-head { display: flex; align-items: center; padding: .4rem .4rem .4rem 1.25rem; border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin-right: auto; overflow-wrap: anywhere; }
.sheet-body { padding: 1.25rem; overflow-y: auto; }
.sheet-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .75rem 1.25rem; border-top: 1px solid var(--line); padding-bottom: max(.75rem, env(safe-area-inset-bottom)); }

.toasts { position: fixed; right: 1.25rem; bottom: 1.25rem; display: flex; flex-direction: column; gap: .5rem; z-index: 100; }
.toast { display: flex; gap: 1rem; align-items: center; padding: .7rem 1rem; border-radius: var(--radius-control); background: var(--text); color: var(--bg); font-weight: 500; box-shadow: 0 6px 20px rgb(27 26 20 / .22); max-width: 360px; }
.toast .btn-link { color: inherit; }
.toast-error { background: var(--danger); color: var(--danger-text); }
.toast-warn { background: var(--warn-bg); color: var(--warn); box-shadow: inset 0 0 0 1px var(--warn), 0 6px 20px rgb(27 26 20 / .22); }
.toast > span { flex: 1; }
.toast .toast-close { color: inherit; width: 36px; height: 36px; font-size: 1.4rem; margin: -.4rem -.6rem -.4rem 0; flex: none; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- phones ---------- */
@media (max-width: 640px) {
  .sim-grid { grid-template-columns: 1fr; }
  .sim-results { position: static; }
  .sim-price input { width: 8rem; }
  table.pl .col-detail { display: none; }
  .curve-row { grid-template-columns: 4.2rem 1fr 1fr 1fr; font-size: .8rem; }
  .topbar { gap: .6rem; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .brand-logo, .brand-product { display: none; }
  .brand-icon { display: block; }
  .section-title { font-size: .8rem; }
  .section-title::before { content: none; }
  .section-title { flex: 1; }
  .topbar-right { flex: none; }
  /* Saving and retry messages float just under the bar so it never changes height. */
  .save-status:not(:empty) {
    position: absolute; top: 100%; right: 12px; margin-top: 8px; max-width: calc(100vw - 24px);
    padding: .4rem .8rem; border-radius: 0; background: var(--chrome); border: 1px solid var(--chrome-line);
    box-shadow: 0 4px 14px rgb(27 26 20 / .25); justify-content: flex-start;
  }
  .save-status .btn-link { min-height: 32px; }
  .save-status:not(.saving):not(.failing) { display: none; }
  .topbar .btn, select.lang { min-height: 44px; }
  .layout { display: block; min-height: 0; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; width: auto;
    flex-direction: row; justify-content: space-around; gap: 0; padding: 0 4px env(safe-area-inset-bottom);
    border-right: 0; border-top: 1px solid var(--line); background: var(--surface);
  }
  .nav-btn {
    flex: 1; flex-direction: column; justify-content: center; gap: 4px; min-height: 60px; padding: 0; border-radius: 0;
    font: 700 .62rem/1 var(--font-label); letter-spacing: .08em; text-transform: uppercase; text-align: center;
  }
  .nav-btn:hover, .nav-btn.active { background: none; box-shadow: none; }
  .nav-btn.active::before { left: 25%; right: 25%; top: -1px; bottom: auto; width: auto; height: 3px; border-radius: 0; }
  .nav-icon { width: 22px; height: 22px; }
  .main { padding: 16px 16px 24px; }
  h1 { font-size: 1.5rem; }
  .card { padding: 1rem; }
  .btn, .btn-small { min-height: 44px; }
  .row { flex-wrap: wrap; }
  .row-actions { width: 100%; justify-content: flex-end; }
  .row-actions select { min-height: 44px; font-size: 16px; flex: 1; }
  .facts { grid-template-columns: minmax(0, 45%) 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .banner { padding: .7rem 16px; }
  .auth { display: block; background: var(--bg); }
  .auth-art { min-height: 0; height: 30vh; min-height: 168px; justify-content: flex-end; padding: 20px 16px 60px; padding-top: max(20px, env(safe-area-inset-top)); }
  .auth-logo { height: 22px; }
  .auth-panel { display: block; padding: 16px 16px max(24px, env(safe-area-inset-bottom)); }
  .auth-box { max-width: none; padding: 1.25rem; margin-top: -40px; position: relative; }
  .sheet { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: 0; }
  .sheet-foot .btn { flex: 1; }
  .toasts { left: 16px; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); }
  .toast { max-width: none; }
}

/* ---------- less text: info toggles, icon buttons, tappable titles ---------- */
details.info { margin: -.2rem 0 .3rem; }
details.info > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; color: var(--muted); font-size: 1rem; }
details.info > summary::-webkit-details-marker { display: none; }
details.info[open] > summary { color: var(--text); }
details.info > p { margin: 0 0 .5rem; color: var(--muted); max-width: 60ch; }
.btn-icon { min-width: 40px; padding: 0 .6rem; font-size: 1.05rem; }
.link-title { all: unset; cursor: pointer; font-weight: 600; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.link-title:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.dec-text { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 640px) {
  .ledger-main .row-sub { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
}

.nav-more { display: none; }
.more-list { display: flex; flex-direction: column; gap: .25rem; }
.more-list .nav-btn { flex-direction: row; justify-content: flex-start; min-height: 48px; position: relative; }
/* In the More menu the current screen is marked on the left of its own row, not floating above. */
.more-list .nav-btn.active::before { left: 0; right: auto; top: 10px; bottom: 10px; width: 3px; height: auto; }
@media (max-width: 640px) {
  .nav .nav-extra { display: none; }
  .nav .nav-more { display: flex; }
}

/* The popup hangs from the card header (not the icon), so it never runs off the screen. */
.card-head { position: relative; }
.card-head details.info { position: static; margin: 0 auto 0 .25rem; }
.card-head details.info > p { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0; max-width: 420px; box-sizing: border-box; padding: .7rem .8rem; background: var(--surface); border: 1px solid var(--line-strong); box-shadow: 0 8px 24px rgb(0 0 0 / .12); color: var(--text); overflow-wrap: anywhere; }
.card-head { gap: .5rem; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Progress: S-curve lines */
.curve-grid { stroke: var(--line); stroke-width: 1; }
.curve-plan { fill: none; stroke: var(--muted); stroke-width: 2; stroke-dasharray: 5 4; }
.curve-actual { fill: none; stroke: var(--accent); stroke-width: 3; }
.curve-dot { fill: var(--surface, #fff); stroke: var(--accent); stroke-width: 2; }
.curve-end { stroke: var(--danger); stroke-width: 1.5; stroke-dasharray: 3 3; }
.curve-key { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .75rem; margin: 0; }
.key { display: inline-block; width: 1.25rem; height: 0; border-top: 3px solid var(--accent); margin-right: -.4rem; vertical-align: middle; }
.key-plan { border-top: 2px dashed var(--muted); }
.key-dot { width: .6rem; height: .6rem; border: 2px solid var(--accent); border-radius: 50%; }
.key-end { border-top: 2px dashed var(--danger); }
details.report summary { cursor: pointer; }
details.report > div { margin: .35rem 0; }
.nav-icon[data-icon="progress"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 20h16M4 20V4'/%3E%3Cpath d='M6 17c4 0 5-2 7-6s4-5 7-5'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="sourcing"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 10l2-5h14l2 5M4 10v9h16v-9M3 10h18M9 19v-5h6v5'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="requests"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 5h16v11H9l-5 4z'/%3E%3Cpath d='M12 8.5v3M12 13.8v.2'/%3E%3C/svg%3E"); }
.checks { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
.thread .row-main p { white-space: pre-wrap; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }
@media (min-width: 641px) { .sim-sticky { position: sticky; top: 0; z-index: 5; } }
.sim-villa { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.sim-levers { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.sim-levers input[type=number] { width: 7.5rem; }
.sim-levers input[type=month] { width: 9.5rem; }
.sim-chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.pl .pl-sub th, .pl .pl-sub td { border-top: 1px solid var(--line-strong); }
.pl .pl-revenue th { font-weight: 600; }

/* Simulator: one block per unsold villa */
.sim-villa { list-style: none; padding: 1rem 0; border-top: 1px solid var(--line); display: grid; gap: .75rem; }
.sim-villa:first-child { border-top: 0; }
.sim-villa-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; }
.sim-villa-head h3 { margin: 0; font-size: 1.15rem; }
.sim-profit { display: flex; flex-direction: column; align-items: flex-end; }
.sim-profit .eyebrow { margin: 0; }
.sim-profit strong { font-size: 1.15rem; }
.sim-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.sim-stat { display: flex; flex-direction: column; gap: .1rem; }
.sim-stat .eyebrow { margin: 0; }
.sim-fields { margin: 0; }
.sim-fields input { width: 100%; box-sizing: border-box; }
.sim-stat .num { margin-left: 0; }
.sim-fields .field { align-self: start; }
.cash-sub .cash-note { flex-basis: 100%; }
.sim-sold-fig { display: flex; flex-direction: column; align-items: flex-end; gap: .1rem; }

/* iPhone Safari gives date and month inputs a fixed minimum width; let them fit their column. */
.field-row > *, .field-row .field { min-width: 0; }
input[type="date"], input[type="month"] { -webkit-appearance: none; appearance: none; min-width: 0; width: 100%; max-width: 100%; box-sizing: border-box; display: block; min-height: 2.75rem; }
input[type="date"]::-webkit-date-and-time-value, input[type="month"]::-webkit-date-and-time-value { text-align: left; }

/* Multi-select drop-down (ledger filters) */
details.multi { position: relative; }
details.multi > summary { list-style: none; cursor: pointer; border: 1px solid var(--line-strong); padding: .55rem 2rem .55rem .75rem; min-height: 2.75rem; box-sizing: border-box; display: flex; align-items: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative; }
details.multi > summary::-webkit-details-marker { display: none; }
details.multi > summary::after { content: "▾"; position: absolute; right: .75rem; color: var(--muted); }
details.multi.multi-on > summary { border-color: var(--accent); }
.multi-panel { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; min-width: 100%; width: max-content; max-width: min(340px, 90vw); max-height: 60vh; overflow: auto; background: var(--surface); border: 1px solid var(--line-strong); box-shadow: 0 8px 24px rgb(0 0 0 / .18); padding: .25rem .75rem .5rem; }
.multi-option { min-height: 40px; }
@media (max-width: 640px) { .multi-panel { position: fixed; left: 16px; right: 16px; top: auto; bottom: 90px; max-width: none; width: auto; } }

/* BOQ work breakdown */
.wbs > summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: .7rem 0; border-top: 1px solid var(--line); }
.wbs > summary::-webkit-details-marker { display: none; }
.wbs > summary .wbs-label::before { content: "▸ "; color: var(--muted); }
.wbs[open] > summary .wbs-label::before { content: "▾ "; }
.wbs-figs { display: flex; flex-direction: column; align-items: flex-end; white-space: nowrap; }
.wbs-1 > summary { font-weight: 600; }
.wbs-2 { margin-left: .75rem; }
.wbs-3 { margin-left: .75rem; }
.wbs-3 > summary { font-size: .9rem; }
.wbs-toggle { margin-bottom: .75rem; flex-wrap: wrap; }
.pl .pl-share { font-size: .85em; white-space: nowrap; }
.seq-tag { display: flex; align-items: center; gap: .75rem; }
.seq-tag select { flex: 0 0 auto; max-width: 9.5rem; }
