:root {
  --ink: #0f1116; --ink2: #2a2e38; --bg: #f6f5f1; --card: #fff; --mut: #6b6f78; --line: #e7e4dc;
  --b: #3a5bf5; --b2: #2846d6; --bl: #eaeefe; --red: #d0342c; --redl: #fdecea; --amber: #b7700b; --amberl: #fdf3e1;
  --green: #18874a; --greenl: #e6f5ec; --purple: #7a4bd8; --purplel: #f1ebfc;
  --r: 16px; --sh: 0 1px 2px rgba(0,0,0,.04), 0 6px 18px rgba(15,17,22,.06);
  --font: "Inter Tight", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --disp: "Bricolage Grotesque", "Inter Tight", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.25; font-family: var(--disp); letter-spacing: -.01em; }
h2 { font-size: 1.35rem; } h3 { font-size: 1.04rem; }
small, .small { font-size: .82em; }
.muted { color: var(--mut); } .red { color: var(--red) !important; } .green { color: var(--green) !important; } .blue { color: var(--b); }
.loading { font-size: 3rem; text-align: center; padding: 30vh 0; }
.num { font-variant-numeric: tabular-nums; }

/* layout */
#side { display: none; }
#body { padding-bottom: 92px; min-width: 0; }
#top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--ink); color: #fff; }
#top:empty { display: none; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { width: 30px; height: 30px; border-radius: 8px; flex: none; }
.brand b { font-family: var(--disp); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#top-new { display: none; }
@media (min-width: 900px) { #top-new { display: inline-flex; } }
.demo-pill { background: #ffd23f; color: #3a2a00; font-size: .7rem; font-weight: 800; padding: 3px 8px; border-radius: 999px; letter-spacing: .04em; flex: none; cursor: pointer; border: 0; }
#main { padding: 14px; max-width: 1180px; margin: 0 auto; overflow-x: clip; }
#bottom { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex; align-items: flex-end; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
#bottom:empty { display: none; }
#bottom a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 9px; font-size: .7rem; color: var(--mut); min-width: 0; }
#bottom a .ic { font-size: 1.3rem; line-height: 1; }
#bottom a.on { color: var(--b); font-weight: 700; }
#bottom a.fab { flex: none; width: 66px; }
#bottom a.fab .ic { width: 54px; height: 54px; border-radius: 50%; background: var(--b); color: #fff; display: grid; place-items: center; font-size: 1.9rem; margin-top: -26px; box-shadow: 0 6px 18px rgba(58,91,245,.4); }
body.client #top, body.client #bottom, body.client #side { display: none !important; }
body.client #body { padding-bottom: 20px; }

@media (min-width: 900px) {
  #app { display: flex; min-height: 100vh; }
  #side { display: flex; flex-direction: column; gap: 2px; width: 230px; flex: none; background: var(--ink); color: #cfd2da; padding: 16px 12px; position: sticky; top: 0; height: 100vh; }
  #side .brand { color: #fff; padding: 4px 8px 16px; }
  #side a { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; }
  #side a:hover { background: rgba(255,255,255,.07); }
  #side a.on { background: var(--b); color: #fff; font-weight: 600; }
  #side .side-new { margin: 6px 0 12px; background: #fff; color: var(--ink); justify-content: center; font-weight: 700; }
  #side .side-new:hover { background: #eef0f5; }
  #side .side-foot { margin-top: auto; font-size: .78rem; color: #8b8f99; padding: 8px 12px; }
  #body { flex: 1; padding-bottom: 30px; }
  #bottom { display: none !important; }
  #top .brand { visibility: hidden; }
  #main { padding: 22px 26px; }
}

/* building blocks */
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--sh); padding: 16px; margin-bottom: 14px; min-width: 0; }
.card.soft { background: #faf9f6; box-shadow: none; border: 1px solid var(--line); }
.card > h3:first-child { margin-top: 0; }
.row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row.wrap { flex-wrap: wrap; }
.row.gap { gap: 12px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 18px; }
@media (min-width: 900px) { .cols { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); } }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin: 2px 0 14px; }
.pagehead h2 { margin: 0; font-size: 1.55rem; }
.back { display: inline-flex; gap: 6px; color: var(--mut); font-size: .9rem; margin-bottom: 8px; cursor: pointer; }
hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 14px; cursor: pointer; font-weight: 600; white-space: nowrap; text-align: center; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--b); border-color: var(--b); color: #fff; }
.btn.primary:hover { background: var(--b2); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.green { background: var(--green); border-color: var(--green); color: #fff !important; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--mut); }
.btn.big { padding: 14px 18px; font-size: 1.05rem; width: 100%; border-radius: 14px; }
.btn.sm { padding: 6px 10px; font-size: .85rem; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 12px; font-size: .88rem; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip .c { opacity: .6; margin-left: 3px; }
.scrollx { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; scrollbar-width: none; }
.scrollx::-webkit-scrollbar { display: none; }

label.f { display: block; margin-bottom: 11px; min-width: 0; }
label.f > span { display: block; font-size: .8rem; color: var(--mut); margin-bottom: 4px; font-weight: 600; }
input, select, textarea { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 11px; padding: 10px 12px; outline: none; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--b); box-shadow: 0 0 0 3px var(--bl); }
textarea { min-height: 70px; resize: vertical; }
input[type=checkbox] { width: auto; }
.check { display: flex; align-items: center; gap: 8px; padding: 6px 0; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--b); }
.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 11px; background: #fff; overflow: hidden; }
.stepper button { border: 0; background: #f3f2ee; width: 40px; height: 42px; font-size: 1.2rem; cursor: pointer; flex: none; }
.stepper input { border: 0; text-align: center; border-radius: 0; padding: 10px 2px; box-shadow: none !important; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { background: var(--card); border-radius: var(--r); box-shadow: var(--sh); padding: 14px; min-width: 0; }
.kpi .l { font-size: .78rem; color: var(--mut); font-weight: 600; }
.kpi .v { font-family: var(--disp); font-size: 1.45rem; font-weight: 700; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .s { font-size: .76rem; color: var(--mut); margin-top: 2px; }
.kpi.hero { background: var(--ink); color: #fff; }
.kpi.hero .l, .kpi.hero .s { color: #aab0bd; }

.hello { margin: 4px 0 14px; }
.hello h2 { font-size: 1.6rem; margin: 0; }

/* lists */
.li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); min-width: 0; cursor: pointer; }
.li:last-child { border-bottom: 0; }
.li > .grow { min-width: 0; }
.li .t { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .d { font-size: .84rem; color: var(--mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .amt { font-weight: 700; text-align: right; flex: none; }
.av { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; font-weight: 700; font-size: .95rem; background: var(--bl); color: var(--b); }
.empty { text-align: center; color: var(--mut); padding: 26px 10px; }
.empty .e { font-size: 2.2rem; }

.todo { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 14px; background: #faf9f6; border: 1px solid var(--line); margin-bottom: 8px; min-width: 0; }
.todo .ti { font-size: 1.3rem; flex: none; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: #fff; }
.todo .grow b { display: block; line-height: 1.3; overflow-wrap: anywhere; }
.todo .grow span { font-size: .82rem; color: var(--mut); display: block; margin-top: 2px; overflow-wrap: anywhere; }
.todo .btn { flex: none; }
.todo.hot { background: var(--amberl); border-color: #f4dfb5; }

/* stage badges */
.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; white-space: nowrap; letter-spacing: .01em; }
.st-lead { background: var(--purplel); color: var(--purple); }
.st-draft { background: #f0efea; color: #555; }
.st-sent { background: var(--amberl); color: var(--amber); }
.st-won { background: var(--bl); color: var(--b); }
.st-scheduled { background: var(--bl); color: var(--b2); }
.st-progress { background: #e3f4fb; color: #0b7aa3; }
.st-done { background: var(--greenl); color: var(--green); }
.st-paid { background: var(--green); color: #fff; }
.st-lost { background: var(--redl); color: var(--red); }

.pipe { display: flex; gap: 4px; margin: 10px 0 4px; }
.pipe i { flex: 1; height: 6px; border-radius: 3px; background: #e7e4dc; }
.pipe i.on { background: var(--b); }
.pipe-l { display: flex; justify-content: space-between; font-size: .7rem; color: var(--mut); }

/* estimate builder */
.area { display: flex; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 14px; margin-bottom: 8px; background: #fff; cursor: pointer; min-width: 0; }
.area .ai { width: 42px; height: 42px; border-radius: 12px; background: #f3f2ee; display: grid; place-items: center; font-size: 1.3rem; flex: none; }
.area .grow b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.area .grow span { display: block; font-size: .8rem; color: var(--mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.area .amt { font-weight: 700; flex: none; }
.addarea { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.addarea button { border: 1px dashed #cfcabd; background: #fff; border-radius: 14px; padding: 12px 6px; cursor: pointer; font-size: .82rem; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.addarea button .i { font-size: 1.4rem; }
.addarea button:hover { border-color: var(--b); color: var(--b); }
.tiers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tier { border: 2px solid var(--line); border-radius: 14px; padding: 10px 8px; text-align: center; cursor: pointer; background: #fff; min-width: 0; position: relative; }
.tier .n { font-size: .78rem; font-weight: 700; color: var(--mut); text-transform: uppercase; letter-spacing: .05em; }
.tier .p { font-family: var(--disp); font-weight: 700; font-size: 1.12rem; margin: 3px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tier .w { font-size: .72rem; color: var(--mut); }
.tier.on { border-color: var(--b); background: var(--bl); }
.tier .pop { position: absolute; top: -9px; left: 50%; transform: translateX(-50%); background: var(--b); color: #fff; font-size: .62rem; font-weight: 800; padding: 2px 7px; border-radius: 999px; white-space: nowrap; }
.calc { font-size: .84rem; color: var(--mut); background: #faf9f6; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.calc b { color: var(--ink); }
.livep { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line); margin: 10px -18px -18px; padding: 12px 18px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.livep .v { font-family: var(--disp); font-size: 1.3rem; font-weight: 700; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.sw { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px 4px 4px; font-size: .8rem; background: #fff; }
.sw i { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(0,0,0,.12); }

.photos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.photo { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: #eee; cursor: pointer; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo span { position: absolute; left: 6px; bottom: 6px; background: rgba(0,0,0,.65); color: #fff; font-size: .66rem; font-weight: 700; padding: 2px 7px; border-radius: 999px; text-transform: uppercase; }
.photo.add { display: grid; place-items: center; border: 1px dashed #cfcabd; background: #fff; font-size: .8rem; color: var(--mut); text-align: center; }

.log { font-size: .84rem; }
.log div { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.log div:last-child { border: 0; }
.log time { color: var(--mut); flex: none; width: 62px; }

/* schedule */
.day { margin-bottom: 14px; }
.day h4 { font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--mut); margin: 0 0 6px; font-family: var(--font); }
.day.today h4 { color: var(--b); }
.jobbar { display: flex; gap: 10px; align-items: center; background: #fff; border-left: 4px solid var(--b); border-radius: 12px; padding: 10px 12px; box-shadow: var(--sh); margin-bottom: 6px; cursor: pointer; min-width: 0; }
.jobbar .grow b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jobbar .grow span { font-size: .8rem; color: var(--mut); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.free { font-size: .84rem; color: var(--mut); padding: 4px 2px 0; }

/* bars (reports) */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; height: 100%; justify-content: flex-end; }
.bars .b i { width: 100%; max-width: 46px; background: var(--b); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.bars .b small { color: var(--mut); font-size: .7rem; }
.bars .b em { font-style: normal; font-size: .68rem; font-weight: 700; white-space: nowrap; }
.hbar { margin-bottom: 9px; }
.hbar .row { font-size: .86rem; }
.hbar .tr { height: 8px; background: #efede7; border-radius: 4px; overflow: hidden; margin-top: 4px; }
.hbar .tr i { display: block; height: 100%; background: var(--b); border-radius: 4px; }

/* client-facing proposal / invoice */
.doc { max-width: 760px; margin: 0 auto; background: #fff; border-radius: 20px; box-shadow: var(--sh); overflow: hidden; }
.doc-head { background: var(--ink); color: #fff; padding: 22px 22px 18px; position: relative; }
.doc-head .drip { position: absolute; left: 0; right: 0; bottom: -1px; height: 18px; }
.doc-head .bz { display: flex; gap: 12px; align-items: center; }
.doc-head .bz img { width: 46px; height: 46px; border-radius: 12px; }
.doc-head h1 { font-size: 1.25rem; margin: 0; }
.doc-head .meta { color: #aab0bd; font-size: .85rem; }
.doc-body { padding: 22px; }
.doc-body h3 { margin-top: 18px; }
.doc .kv { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; font-size: .9rem; }
.doc .kv b { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--mut); }
.scope { width: 100%; border-collapse: collapse; font-size: .9rem; }
.scope td { padding: 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.scope td:last-child { text-align: right; white-space: nowrap; padding-left: 10px; font-weight: 600; }
.scope td small { color: var(--mut); display: block; }
.scope tfoot td { border: 0; padding: 5px 0; }
.scope tfoot tr.tot td { font-size: 1.15rem; font-weight: 800; padding-top: 10px; border-top: 2px solid var(--ink); }
.opt { border: 2px solid var(--line); border-radius: 16px; padding: 14px; cursor: pointer; margin-bottom: 10px; display: flex; gap: 12px; align-items: flex-start; }
.opt.on { border-color: var(--b); background: var(--bl); }
.opt .rd { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #c9c5ba; flex: none; margin-top: 2px; }
.opt.on .rd { border: 7px solid var(--b); }
.opt .grow b { font-size: 1.02rem; }
.opt .grow ul { margin: 6px 0 0; padding-left: 18px; font-size: .84rem; color: var(--ink2); }
.opt .pr { font-family: var(--disp); font-weight: 800; font-size: 1.2rem; white-space: nowrap; }
.sig { border: 2px dashed #cfcabd; border-radius: 14px; background: #fcfbf8; touch-action: none; width: 100%; height: 150px; display: block; cursor: crosshair; }
.sigimg { max-width: 260px; height: 80px; object-fit: contain; display: block; }
.signed { background: var(--greenl); color: var(--green); border-radius: 14px; padding: 14px; font-weight: 600; }
.stamp { position: fixed; top: 46%; left: 50%; transform: translate(-50%, -50%) rotate(-24deg); font-size: 7rem; font-weight: 900; color: rgba(208,52,44,.08); pointer-events: none; z-index: 1; letter-spacing: .1em; font-family: var(--disp); }
.demobar { background: #ffd23f; color: #3a2a00; font-size: .82rem; text-align: center; padding: 8px 12px; font-weight: 600; }
.demobar a { text-decoration: underline; cursor: pointer; }
.terms { font-size: .78rem; color: var(--mut); line-height: 1.5; }
.paid-stamp { display: inline-block; border: 3px solid var(--green); color: var(--green); font-weight: 900; padding: 4px 14px; border-radius: 8px; transform: rotate(-6deg); font-size: 1.3rem; letter-spacing: .1em; }

/* sheet */
#sheet-wrap { position: fixed; inset: 0; z-index: 20; }
#sheet-bg { position: absolute; inset: 0; background: rgba(15,17,22,.45); opacity: 0; transition: opacity .18s; }
#sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow: auto; background: #fff; border-radius: 22px 22px 0 0; padding: 18px; padding-bottom: max(18px, env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform .2s ease; }
#sheet-wrap.open #sheet-bg { opacity: 1; }
#sheet-wrap.open #sheet { transform: none; }
#sheet h3 { padding-right: 36px; font-size: 1.15rem; }
.sheet-x { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: #f0efea; cursor: pointer; z-index: 2; }
@media (min-width: 700px) {
  #sheet { left: 50%; right: auto; width: 560px; bottom: auto; top: 50%; transform: translate(-50%, -46%); opacity: 0; border-radius: 20px; max-height: 88vh; transition: transform .2s, opacity .2s; }
  #sheet.small { width: 420px; }
  #sheet-wrap.open #sheet { transform: translate(-50%, -50%); opacity: 1; }
}
.lock-sheet { text-align: center; }
.lock-sheet .lock-ic { font-size: 2.4rem; }
.lock-list { text-align: left; }
.lock-list ul { margin: 6px 0 0; padding-left: 4px; list-style: none; line-height: 1.8; font-size: .92rem; }
.lock-sheet .btn { margin-top: 10px; width: 100%; }

#toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px; opacity: 0; pointer-events: none; transition: .2s; z-index: 30; max-width: 90vw; text-align: center; font-size: .92rem; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--red); }
#toast.ok { background: var(--green); }

@media (max-width: 420px) {
  .tier .p { font-size: .98rem; }
  .kpi .v { font-size: 1.25rem; }
  .doc-body, .doc-head { padding-left: 16px; padding-right: 16px; }
}

@media print {
  #top, #bottom, #side, .noprint, .demobar, #toast, #sheet-wrap { display: none !important; }
  body, html { background: #fff; }
  #main { padding: 0; max-width: none; }
  #body { padding: 0; }
  .doc { box-shadow: none; border-radius: 0; max-width: none; }
  .doc-head { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .stamp { position: fixed; color: rgba(208,52,44,.12); }
}
@media (max-width: 460px) {
  .grid3 .stepper button { width: 30px; }
  .grid3 .stepper input { padding: 10px 0; }
}
