:root {
  --font-display: 'Fraunces', Georgia, serif;
  --font-ui: 'Inter', -apple-system, 'Helvetica Neue', sans-serif;
  --bg: #F7F3EC; --surface: #FFFFFF; --ink: #2B2621; --muted: #8A8177;
  --accent: #B5603E; --success: #4F7A5B; --warning: #C08A3E; --danger: #A8483A;
  --hair: rgba(43,38,33,0.12); --hair-soft: rgba(43,38,33,0.07);
  --pill-draft: #EDEAE4; --pill-progress: #F1E1D8; --pill-awaiting: #F3E7D3; --pill-approved: #E1EBE3; --pill-disputed: #F0DDD9;
  --r-sm: 6px; --r-md: 12px; --r-lg: 16px; --r-pill: 999px;
  --sh-sm: 0 1px 2px rgba(43,38,33,0.06); --sh-md: 0 4px 12px rgba(43,38,33,0.08); --sh-lg: 0 12px 32px rgba(43,38,33,0.12);
  --tabbar: 64px;
}
[data-role="builder"] { --accent: #9C5033; }
[data-role="homeowner"] { --accent: #C97854; }

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-ui); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3, .display, .brand, .kpi, .signature { font-variation-settings: 'WONK' 0, 'SOFT' 30; }
h1, h2, h3, .display { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 28px; line-height: 1.15; }
h2 { font-size: 21px; line-height: 1.2; }
h3 { font-size: 17px; line-height: 1.3; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; cursor: pointer; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 11.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; }
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.right { text-align: right; }
.hide { display: none !important; }

/* Shell */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--hair-soft); }
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 12px; }
.brand { font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.brand span { color: var(--accent); }
.rolechip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border: 1px solid var(--hair); border-radius: var(--r-pill); background: var(--surface); }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; }
.rolechip .tiny { color: var(--ink); }
.main { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 20px 20px calc(var(--tabbar) + 24px); }
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--hair-soft); padding-bottom: env(safe-area-inset-bottom); }
.tabbar-inner { display: flex; justify-content: space-around; max-width: 640px; margin: 0 auto; }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 4px 8px; color: var(--muted); font-size: 11px; font-weight: 500; background: none; border: 0; }
.tab.active { color: var(--accent); }
.tab svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

@media (min-width: 1024px) {
  .app { flex-direction: row; }
  .topbar { position: static; width: 240px; flex-shrink: 0; border-bottom: 0; border-right: 1px solid var(--hair-soft); background: transparent; backdrop-filter: none; }
  .topbar-inner { flex-direction: column; align-items: stretch; padding: 28px 20px; gap: 20px; position: sticky; top: 0; }
  .main { padding: 36px 40px 60px; }
  .tabbar { position: static; border: 0; background: transparent; box-shadow: none; }
  .tabbar-inner { flex-direction: column; align-items: stretch; gap: 2px; }
  .tab { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 10px 12px; border-radius: var(--r-md); font-size: 14px; }
  .tab.active { background: var(--surface); box-shadow: var(--sh-sm); }
  .tab svg { width: 20px; height: 20px; }
  .two-col { display: grid; grid-template-columns: 1fr 340px; gap: 28px; align-items: start; }
}

/* Cards & controls */
.card { background: var(--surface); border: 1px solid var(--hair-soft); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--sh-sm); }
.card.tight { padding: 14px 16px; }
.card.click { cursor: pointer; transition: box-shadow .15s, transform .15s; }
.card.click:hover { box-shadow: var(--sh-md); transform: translateY(-1px); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: 8px; border: 1px solid transparent; font-weight: 500; font-size: 14.5px; background: var(--accent); color: #fff; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--hair); }
.btn.subtle { background: transparent; color: var(--accent); border-color: transparent; padding-left: 8px; padding-right: 8px; }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--hair); }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.planned { background: var(--pill-draft); color: var(--muted); }
.pill.in_progress { background: var(--pill-progress); color: var(--accent); }
.pill.submitted, .pill.proposed, .pill.requested { background: var(--pill-awaiting); color: var(--warning); }
.pill.approved { background: var(--pill-approved); color: var(--success); }
.pill.changes_requested { background: var(--pill-awaiting); color: var(--warning); }
.pill.disputed, .pill.declined { background: var(--pill-disputed); color: var(--danger); }
.pill.withdrawn { background: var(--pill-draft); color: var(--muted); }
input, textarea, select { font: inherit; color: var(--ink); width: 100%; padding: 11px 12px; border: 1px solid var(--hair); border-radius: 8px; background: var(--surface); }
textarea { min-height: 84px; resize: vertical; }
label.field { display: block; }
label.field > span { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.divider { height: 1px; background: var(--hair-soft); margin: 16px 0; }
.list > * + * { border-top: 1px solid var(--hair-soft); }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.list-item:first-child { padding-top: 0; }
.list-item:last-child { padding-bottom: 0; }
.eyebrow { font-size: 12px; color: var(--muted); font-weight: 500; }
.hero { padding: 8px 0 20px; }
.hero h1 { margin-top: 4px; }
.kpi { font-family: var(--font-display); font-size: 30px; font-weight: 500; letter-spacing: -0.02em; line-height: 1; }
.kpi.sm { font-size: 22px; }
.bar { height: 6px; border-radius: 3px; background: var(--pill-draft); overflow: hidden; display: flex; }
.bar > i { display: block; height: 100%; }
.bar .paid { background: var(--success); }
.bar .due { background: var(--accent); }
.bar .pending { background: repeating-linear-gradient(135deg, var(--warning) 0 4px, transparent 4px 8px); opacity: .7; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.ring { width: 132px; height: 132px; position: relative; flex-shrink: 0; }
.ring svg { transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; stroke-linecap: butt; }
.ring .track { stroke: var(--pill-draft); }
.ring .center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photos img, .photo-lg img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--r-md); display: block; background: var(--pill-draft); }
.photos .more { display: flex; align-items: center; justify-content: center; aspect-ratio: 1; border-radius: var(--r-md); background: var(--pill-draft); color: var(--muted); font-weight: 600; }
.photo-lg { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.photo-lg figure { margin: 0; }
.photo-lg img { aspect-ratio: 4/3; }
.photo-lg figcaption { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ''; position: absolute; left: 9px; top: 8px; bottom: 8px; width: 2px; background: var(--hair-soft); }
.tl-item { position: relative; margin-bottom: 12px; }
.tl-item::before { content: ''; position: absolute; left: -24px; top: 18px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--muted); }
.tl-item.approved::before { background: var(--success); border-color: var(--success); }
.tl-item.in_progress::before { background: var(--surface); border-color: var(--accent); }
.tl-item.submitted::before { background: var(--warning); border-color: var(--warning); }
.tl-item.disputed::before { background: var(--danger); border-color: var(--danger); }
.msg { max-width: 82%; padding: 10px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--hair-soft); }
.msg.me { margin-left: auto; background: var(--accent); color: #fff; border-color: transparent; }
.msg .meta { font-size: 11px; opacity: .7; margin-top: 4px; }
.sticky-cta { position: fixed; left: 0; right: 0; bottom: var(--tabbar); padding: 12px 20px; background: linear-gradient(to top, var(--bg) 70%, transparent); z-index: 15; }
.sticky-cta .btn { max-width: 600px; margin: 0 auto; display: flex; box-shadow: var(--sh-md); }
@media (min-width: 1024px) { .sticky-cta { position: static; padding: 0; background: none; margin-top: 16px; } }
.notice { padding: 12px 14px; border-radius: var(--r-md); background: var(--pill-awaiting); color: #6b4a1a; font-size: 13.5px; }
.notice.good { background: var(--pill-approved); color: #2f4f38; }
.notice.bad { background: var(--pill-disputed); color: #6e2c22; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13.5px; margin-bottom: 12px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 24px 0 10px; }
.section-title h2 { font-size: 18px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 6px 0; border-bottom: 1px solid var(--hair-soft); }
.tbl td { padding: 10px 0; border-bottom: 1px solid var(--hair-soft); vertical-align: top; }
.tbl td.r, .tbl th.r { text-align: right; }
.signature { font-family: var(--font-display); font-style: italic; font-size: 20px; color: var(--ink); }
.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar) + 16px); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--r-pill); font-size: 13.5px; box-shadow: var(--sh-lg); z-index: 50; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
.sheet-bg { position: fixed; inset: 0; background: rgba(43,38,33,0.35); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--surface); width: 100%; max-width: 560px; border-radius: 20px 20px 0 0; padding: 20px 20px 28px; max-height: 88vh; overflow: auto; }
@media (min-width: 640px) { .sheet-bg { align-items: center; } .sheet { border-radius: 20px; } }
.contract { font-size: 14.5px; line-height: 1.6; }
.contract h3 { margin-top: 20px; }
.contract ol { padding-left: 20px; }
.contract li { margin: 4px 0; }
.landing { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; text-align: center; }
.landing .brand { font-size: 34px; }
.landing p.lede { max-width: 440px; margin-top: 12px; color: var(--muted); font-size: 16px; }
.roles { display: grid; gap: 12px; width: 100%; max-width: 440px; margin-top: 32px; }
.role-card { text-align: left; padding: 18px 20px; display: flex; align-items: center; gap: 16px; border: 1px solid var(--hair-soft); }
.role-card .avatar { width: 40px; height: 40px; font-size: 14px; }

@media print {
  .topbar, .tabbar, .sticky-cta, .no-print { display: none !important; }
  body { background: #fff; }
  .main { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
  .page-break { break-before: page; }
}
