/* Folio: estimates and invoices */
:root {
  --bg: #E9ECEA;
  --sheet: #FFFFFF;
  --desk: #F4F6F5;
  --ink: #16202A;
  --ink-2: #3A4652;
  --muted: #6B7682;
  --line: #D9DEE0;
  --line-2: #ECEFF0;
  --spruce: #1F4E46;
  --spruce-2: #2A6A5E;
  --brass: #9C7434;
  --red: #A8432F;  --red-tint: #F7E6E1;
  --blue: #2C5A85; --blue-tint: #E3EBF3;
  --violet: #5B4892; --violet-tint: #ECE8F5;
  --green: #2D6F47; --green-tint: #E1EFE6;
  --amber: #8A6420; --amber-tint: #F5ECDC;
  --grey-tint: #EDF0F1;
  --font: "Instrument Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--spruce-2); }
h1 { font-size: 28px; line-height: 1.15; font-weight: 600; letter-spacing: -0.022em; margin: 0; }
h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 12px; }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 8px; }
p { margin: 0 0 10px; }
.sub { color: var(--muted); font-size: 13px; }
.lead { color: var(--ink-2); max-width: 62ch; margin: 6px 0 24px; }
.num, .tbl td.n, .p-num, .p-totals { font-variant-numeric: tabular-nums; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ok { color: var(--green); font-weight: 500; }
.err { color: var(--red); }
.empty, .tbl tr.none td { color: var(--muted); padding: 28px 0; }
.grow { flex: 1; }
:focus-visible { outline: 2px solid var(--spruce-2); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Controls ---------- */
input, select, textarea, button { font: inherit; color: inherit; }
.btn {
  font-size: 14px; font-weight: 550; line-height: 1.2; padding: 8px 14px;
  border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { border-color: #BFC7CB; background: #F8FAF9; }
.btn.primary { background: var(--spruce); border-color: var(--spruce); color: #fff; }
.btn.primary:hover { background: var(--spruce-2); border-color: var(--spruce-2); }
.btn.subtle { border-style: dashed; color: var(--ink-2); background: transparent; }
.btn.danger { color: var(--red); }
.btn.wide { width: 100%; }
.btn.icon { padding: 8px 11px; letter-spacing: 1px; font-size: 11px; }
.btn:disabled { opacity: .55; cursor: progress; }
.link { background: none; border: 0; padding: 0; color: var(--spruce-2); font-weight: 550; cursor: pointer; font-size: 13.5px; }
.link:hover { text-decoration: underline; }
.link.small { font-size: 12.5px; font-weight: 500; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

label { display: block; font-size: 13px; font-weight: 550; color: var(--ink-2); }
.field, .filters input, .filters select, .modal input:not([type=checkbox]), .modal select, .modal textarea,
.co-form input:not([type=color]):not([type=file]), .co-form textarea, .auth input, .acf input, .switch select {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; background: #fff; width: 100%; font-size: 14.5px; font-weight: 400; color: var(--ink);
}
label > input, label > select, label > textarea { margin-top: 5px; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--spruce-2); box-shadow: 0 0 0 3px rgba(42, 106, 94, .14); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check.small { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.check input { accent-color: var(--spruce); width: 16px; height: 16px; margin: 0; }
label .sub { font-weight: 400; }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: 12.5px; }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 100vh; }
.side { padding: 26px 16px 20px 22px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 24px; }
.brand { font-weight: 700; font-size: 21px; letter-spacing: -0.03em; display: flex; align-items: center; gap: 10px; }
.mark { width: 22px; height: 22px; border-radius: 6px; background: linear-gradient(135deg, var(--spruce) 0 58%, var(--brass) 58%); }
.switch { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.switch select { margin-top: 6px; font-size: 14px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { padding: 8px 12px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
.nav a:hover { background: rgba(22, 32, 42, .05); color: var(--ink); }
.nav a.on { background: var(--sheet); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(22, 32, 42, .06); }
.side-foot { margin-top: auto; font-size: 12.5px; color: var(--muted); }
.side-foot p { margin: 6px 0 0; }
.demo-tag { display: inline-block; font-weight: 600; color: var(--amber); background: var(--amber-tint); border-radius: 999px; padding: 2px 9px; font-size: 12px; }

.main { padding: 16px 20px 20px 0; display: flex; flex-direction: column; min-width: 0; }
.top { display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding: 2px 4px 14px; }
.bell { position: relative; width: 38px; height: 38px; border-radius: 10px; border: 1px solid transparent; background: transparent; cursor: pointer; display: grid; place-items: center; color: var(--ink-2); }
.bell:hover { background: rgba(22, 32, 42, .06); }
.badge { position: absolute; top: 3px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--bg); }

.sheet { background: var(--sheet); border-radius: 18px; border: 1px solid var(--line); padding: 34px 40px 44px; flex: 1; min-width: 0; }
.sheet.desk { background: var(--desk); }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 26px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-block; font-size: 13px; color: var(--muted); text-decoration: none; margin-bottom: 6px; }
.back::before { content: "‹ "; }
.back:hover { color: var(--ink); }

/* ---------- Overview ---------- */
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 34px; overflow: hidden; }
.metric { padding: 18px 20px 16px; border-left: 1px solid var(--line); }
.metric:first-child { border-left: 0; }
.metric .l { font-size: 13px; color: var(--muted); font-weight: 500; }
.metric .v { font-size: 27px; font-weight: 600; letter-spacing: -0.025em; font-variant-numeric: tabular-nums; margin: 6px 0 2px; }
.metric.warn .v { color: var(--red); }
.two { display: grid; grid-template-columns: 1.2fr 1fr; gap: 40px; }
.rows, .feed, .pays { list-style: none; margin: 0; padding: 0; }
.rows li a { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line-2); color: inherit; text-decoration: none; }
.rows li:first-child a { border-top: 0; }
.rows li a:hover b { color: var(--spruce-2); }
.who { display: flex; flex-direction: column; min-width: 0; }
.feed li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0 9px 16px; position: relative; border-top: 1px solid var(--line-2); font-size: 14px; }
.feed li:first-child { border-top: 0; }
.feed li::before { content: ""; position: absolute; left: 0; top: 16px; width: 7px; height: 7px; border-radius: 50%; background: #B9C1C6; }
.feed li.k-viewed::before { background: var(--violet); }
.feed li.k-accepted::before, .feed li.k-paid::before { background: var(--green); }
.feed li.k-sent::before, .feed li.k-reminder::before { background: var(--blue); }
.feed a { color: inherit; text-decoration: none; }
.feed a:hover { color: var(--spruce-2); }
.feed .sub { white-space: nowrap; }
.feed.small li { font-size: 13px; padding: 7px 0 7px 15px; }
.feed.small li::before { top: 13px; }

/* ---------- Lists ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; align-items: center; }
.filters input[type=search] { flex: 1 1 240px; width: auto; }
.filters select { width: auto; flex: 0 0 auto; padding-right: 28px; }
.filters .range { display: inline-flex; gap: 6px; align-items: center; }
.filters .range input { width: auto; }
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { font-size: 12.5px; font-weight: 600; color: var(--muted); text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tbody tr[data-id] { cursor: pointer; }
.tbl tbody tr[data-id]:hover td { background: #F6F8F7; }
.tbl .n { text-align: right; }
.tbl tfoot td { font-weight: 600; border-bottom: 0; color: var(--ink-2); padding-top: 14px; }
.tbl tr.none td { text-align: left; }
.docno { font-weight: 600; white-space: nowrap; }
.dots { border: 0; background: transparent; border-radius: 6px; padding: 5px 8px; cursor: pointer; color: var(--muted); font-size: 10px; letter-spacing: 1px; }
.dots:hover { background: var(--grey-tint); color: var(--ink); }

.pill { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--grey-tint); color: var(--ink-2); white-space: nowrap; }
.pill.sent { background: var(--blue-tint); color: var(--blue); }
.pill.viewed { background: var(--violet-tint); color: var(--violet); }
.pill.paid, .pill.accepted { background: var(--green-tint); color: var(--green); }
.pill.partial { background: var(--amber-tint); color: var(--amber); }
.pill.overdue, .pill.declined { background: var(--red-tint); color: var(--red); }
.pill.converted { background: #E6ECEB; color: var(--spruce); }
.pill.expired { background: var(--grey-tint); color: var(--muted); }

/* ---------- Menus, modals, toasts ---------- */
.menu { position: fixed; z-index: 60; min-width: 210px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 18px 40px -12px rgba(22, 32, 42, .28); }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 12px; border-radius: 7px; cursor: pointer; font-size: 14px; }
.menu button:hover, .menu button:focus-visible { background: var(--grey-tint); outline: none; }
.menu button.danger { color: var(--red); }
.menu hr { border: 0; border-top: 1px solid var(--line-2); margin: 6px 4px; }
.bell-panel { width: 340px; max-height: 70vh; overflow: auto; padding: 0; }
.bp-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 10px; border-bottom: 1px solid var(--line-2); position: sticky; top: 0; background: #fff; }
.bp-item { display: flex; flex-direction: column; gap: 2px; padding: 11px 16px; text-decoration: none; color: var(--ink-2); border-bottom: 1px solid var(--line-2); font-size: 14px; }
.bp-item:hover { background: #F6F8F7; }
.bp-item.unread { color: var(--ink); font-weight: 550; box-shadow: inset 3px 0 0 var(--violet); }
.bp-empty { color: var(--muted); font-size: 13.5px; padding: 16px; margin: 0; }

.modal-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(22, 32, 42, .38); display: grid; place-items: center; padding: 20px; overflow: auto; }
.modal { background: #fff; border-radius: 16px; width: min(560px, 100%); padding: 26px 28px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 30px 80px -20px rgba(22, 32, 42, .4); }
.modal h2 { font-size: 20px; margin: 0; }
.modal .sub { margin: -4px 0 0; }
.modal.wide { width: min(920px, 100%); background: var(--desk); padding: 20px 24px 28px; }
.send-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.m-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.note { background: var(--amber-tint); color: var(--amber); border-radius: 10px; padding: 10px 14px; font-size: 13.5px; margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 16px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 16px; }
.pv-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.pv-body .paper { margin: 0 auto; }

.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast { pointer-events: auto; background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 14px; display: flex; gap: 14px; align-items: center; box-shadow: 0 12px 30px -10px rgba(22, 32, 42, .5); transition: opacity .3s, transform .3s; max-width: min(560px, 92vw); }
.toast.error { background: var(--red); }
.toast.out { opacity: 0; transform: translateY(8px); }
.toast button { background: rgba(255, 255, 255, .14); border: 0; color: #fff; border-radius: 7px; padding: 5px 10px; cursor: pointer; font-weight: 600; font-size: 13px; white-space: nowrap; }

/* ---------- Editor ---------- */
.ed-top { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.ed-top .back { flex-basis: 100%; margin: 0; }
.ed-title { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 220px; }
.ed-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ed-grid { display: grid; grid-template-columns: minmax(0, 816px) minmax(260px, 300px); gap: 28px; align-items: start; }
.rail { position: sticky; top: 18px; display: flex; flex-direction: column; gap: 14px; }
.rail-box { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.rail-box .sub { margin-bottom: 10px; }
.rail-box p:last-child { margin-bottom: 0; }
.rail-box .ok { font-size: 14px; }
.row-sb { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.row-sb h3 { margin: 0; }
.summary .big { font-size: 30px; font-weight: 600; letter-spacing: -0.03em; margin-top: 12px; line-height: 1.1; }
.summary .btn { margin-top: 8px; }
.pays li { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-top: 1px solid var(--line-2); }
.pays li:first-child { border-top: 0; }
.pays li > div { display: flex; flex-direction: column; }
.x { border: 0; background: transparent; color: #9AA3AB; cursor: pointer; font-size: 18px; line-height: 1; width: 26px; height: 26px; border-radius: 6px; }
.x:hover { background: var(--red-tint); color: var(--red); }

/* ---------- The document ---------- */
.paper {
  --brand: #1F4E46;
  background: #fff; color: #1A232C; width: 100%; max-width: 816px; position: relative;
  padding: 58px 56px 44px; border: 1px solid #DDE2E4; border-radius: 3px;
  box-shadow: 0 1px 2px rgba(22, 32, 42, .05), 0 28px 50px -34px rgba(22, 32, 42, .4);
  font-size: 14px; line-height: 1.5;
}
.p-band { position: absolute; left: 0; right: 0; top: 0; height: 7px; background: var(--brand); }
.p-head { display: flex; justify-content: space-between; gap: 32px; align-items: flex-start; }
.p-from { min-width: 0; max-width: 360px; }
.p-logo { max-width: 210px; max-height: 88px; object-fit: contain; display: block; margin-bottom: 14px; }
.p-co { font-size: 19px; font-weight: 700; letter-spacing: -0.015em; color: #16202A; margin-bottom: 6px; }
.p-lines { font-size: 12.5px; color: #59646F; line-height: 1.6; }
.p-title { text-align: right; flex-shrink: 0; }
.p-type { font-size: 46px; font-weight: 600; letter-spacing: -0.045em; line-height: .95; color: var(--brand); }
.p-meta { display: grid; grid-template-columns: auto auto; gap: 3px 18px; margin: 18px 0 0; font-size: 13px; justify-content: end; align-items: center; }
.p-meta dt { color: #6B7682; text-align: right; }
.p-meta dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.p-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 36px; margin: 38px 0 30px; padding-top: 22px; border-top: 1px solid #E6E9EB; font-size: 13.5px; color: #3A4652; }
.p-h { font-size: 12px; font-weight: 600; color: #6B7682; margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.p-strong { font-weight: 600; font-size: 15px; color: #16202A; }
.p-items { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.p-items th { text-align: left; font-size: 12px; font-weight: 600; color: #6B7682; padding: 0 8px 9px; border-bottom: 2px solid var(--brand); }
.p-items th:first-child, .p-items td:first-child { padding-left: 0; }
.p-items th:last-child, .p-items td:last-child { padding-right: 0; }
.p-items td { padding: 12px 8px; border-bottom: 1px solid #ECEFF0; vertical-align: top; }
.p-items .p-num { text-align: right; white-space: nowrap; }
.p-kind { font-size: 11.5px; color: var(--brand); font-weight: 600; margin-bottom: 1px; }
.p-empty { color: #8A939C; }
.p-bottom { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 44px; margin-top: 26px; }
.p-notes { font-size: 12.5px; color: #3A4652; }
.p-notes p { margin: 0 0 16px; }
.p-totals .tr { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 5px 0; font-size: 13.5px; color: #3A4652; }
.p-totals .total { border-top: 1px solid #E6E9EB; margin-top: 6px; padding-top: 11px; font-weight: 600; color: #16202A; font-size: 15px; }
.p-totals .due { background: var(--brand); color: #fff; padding: 13px 14px; border-radius: 6px; margin-top: 12px; font-weight: 600; font-size: 16.5px; }
.p-stamp { margin-top: 12px; border: 1.5px solid var(--brand); color: var(--brand); border-radius: 6px; padding: 8px 12px; font-size: 12.5px; font-weight: 600; text-align: center; }
.p-foot { margin-top: 46px; padding-top: 14px; border-top: 1px solid #E6E9EB; font-size: 11.5px; color: #8A939C; display: flex; justify-content: space-between; gap: 16px; }

/* Editable document */
.ghost {
  font: inherit; color: inherit; background: transparent; border: 1px solid transparent; border-radius: 6px;
  padding: 3px 6px; margin: 0 -7px; width: calc(100% + 14px); resize: none; display: block;
  transition: background .12s, border-color .12s;
}
.ghost:hover { border-color: #E2E6E8; background: #FAFBFB; }
.ghost:focus { outline: none; border-color: var(--spruce-2); background: #fff; box-shadow: 0 0 0 3px rgba(42, 106, 94, .12); }
.ghost::placeholder { color: #A5ADB4; }
.ghost.r { text-align: right; }
.stack > .ghost { margin-bottom: 1px; }
.edit .p-meta dd .ghost { width: 152px; margin: 0 -7px 0 0; }
.edit .p-meta label { font-weight: 400; color: inherit; font-size: inherit; }
.edit .co-pick { font-size: 19px; font-weight: 700; color: #16202A; cursor: pointer; margin-bottom: 4px; width: auto; max-width: 100%; }
.edit .tiny { display: inline-block; margin-top: 8px; font-size: 12px; color: var(--muted); }
.edit .p-h .mini { font-size: 12px; border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; background: #fff; color: var(--ink-2); max-width: 160px; }
.edit-items td { padding: 8px 8px; }
.edit-items .ghost { margin: 0; width: 100%; }
.edit-items td:first-child .ghost { margin-left: -7px; width: calc(100% + 7px); }
.edit-items td:first-child .kind { font-size: 11.5px; color: var(--brand); font-weight: 600; width: auto; padding: 1px 6px; margin: 0 0 2px -7px; cursor: pointer; }
.edit-items .qty { width: 64px; margin-left: auto; }
.edit-items .rate { width: 104px; margin-left: auto; }
/* Description box: visible, drag the bottom-right handle to make it taller */
.edit-items textarea.desc {
  display: block; width: 100%; min-height: 54px; margin: 2px 0 0;
  font: inherit; font-size: 13.5px; line-height: 1.55; color: #1A232C;
  padding: 8px 10px; border: 1px solid #E1E5E8; border-radius: 7px; background: #FCFCFC;
  resize: vertical; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere;
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.edit-items textarea.desc:hover { border-color: #CDD4D8; background: #fff; }
.edit-items textarea.desc:focus { outline: none; border-color: var(--spruce-2); background: #fff; box-shadow: 0 0 0 3px rgba(42, 106, 94, .12); }
.edit-items textarea.desc::placeholder { color: #A5ADB4; }
.edit-items td:first-child { width: 100%; }
.edit-items td.p-num { padding-top: 30px; }
.edit-items .amt { padding-top: 34px !important; }
.edit-items td:last-child { width: 30px; }
.edit-items tr.none td { color: #8A939C; padding: 16px 0; }
.add-line { margin-top: 12px; }
.inl { display: inline-flex; align-items: center; gap: 4px; }
.ghost.xs { width: 64px; margin: 0; padding: 2px 5px; display: inline-block; }
select.ghost.xs { width: auto; }
.p-totals .ghost.xs { font-size: 13px; }

.export-host { position: fixed; left: -10000px; top: 0; width: 816px; }
.export-host .paper { box-shadow: none; border: 0; border-radius: 0; max-width: none; width: 816px; min-height: 1056px; }

/* ---------- Customers & companies ---------- */
.co-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; max-width: 860px; }
.co-row { display: flex; align-items: center; gap: 16px; padding: 14px 18px; border-top: 1px solid var(--line-2); text-decoration: none; color: inherit; }
.co-row:first-child { border-top: 0; }
.co-row:hover { background: #F6F8F7; }
.co-row .who { flex: 1; }
.co-logo { width: 46px; height: 46px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 18px; overflow: hidden; flex-shrink: 0; }
.co-logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.co-form { max-width: 820px; }
.co-form section { padding: 24px 0; border-top: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 14px; }
.co-form section:first-child { border-top: 0; padding-top: 0; }
.co-form h2 { margin: 0; }
.logo-field { display: flex; gap: 20px; align-items: center; }
.logo-box { width: 200px; height: 96px; border: 1px dashed #C6CED2; border-radius: 12px; display: grid; place-items: center; background: #FAFBFB; padding: 10px; }
.logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.color-row { display: flex; align-items: center; gap: 12px; margin-top: 5px; }
.color-row input[type=color] { width: 46px; height: 38px; border: 1px solid var(--line); border-radius: 8px; padding: 3px; background: #fff; cursor: pointer; flex-shrink: 0; }
.set { padding: 22px 0; border-top: 1px solid var(--line-2); max-width: 680px; }
.set:first-of-type { border-top: 0; padding-top: 0; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 34px 34px 26px; width: min(400px, 100%); display: flex; flex-direction: column; gap: 16px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card h1 { font-size: 24px; }
.auth-card p { margin: 0; }
.fatal { max-width: 560px; margin: 80px auto; padding: 20px; }

/* ---------- Customer page ---------- */
body.public { min-height: 100vh; }
.preview-banner { background: var(--amber-tint); color: var(--amber); text-align: center; font-size: 13.5px; font-weight: 500; padding: 9px 16px; }
.pub-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; max-width: 864px; margin: 0 auto; padding: 22px 24px 18px; }
.pub-co { font-weight: 600; font-size: 15px; color: var(--ink-2); }
.pub-wrap { max-width: 864px; margin: 0 auto; padding: 0 24px 64px; }
.pub-wrap .paper { margin: 0 auto; }
.pub-loading, .pub-msg { text-align: center; color: var(--muted); padding: 60px 20px; }
.pub-msg h1 { color: var(--ink); margin-bottom: 10px; }
.accept { max-width: 816px; margin: 20px auto 0; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 22px 26px; }
.accept h2 { margin-bottom: 4px; }
.acf { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.acf input { flex: 1 1 220px; width: auto; }

/* ---------- Responsive ---------- */
@media (max-width: 1240px) {
  .ed-grid { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); max-width: 816px; }
}
@media (max-width: 1000px) {
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric:nth-child(3) { border-left: 0; }
  .metric:nth-child(n+3) { border-top: 1px solid var(--line); }
  .two { grid-template-columns: 1fr; gap: 28px; }
  .grid4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: 16px 16px 4px; gap: 12px; }
  .brand { font-size: 19px; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; margin: 0 -4px; padding-bottom: 4px; }
  .nav a { white-space: nowrap; padding: 7px 11px; }
  .side-foot { display: none; }
  .main { padding: 0 10px 10px; }
  .top { position: absolute; top: 12px; right: 12px; padding: 0; }
  .sheet { padding: 22px 18px 32px; border-radius: 14px; }
  .paper { padding: 40px 22px 30px; }
  .paper .p-head { flex-direction: column; gap: 22px; }
  .paper .p-title { text-align: left; }
  .paper .p-meta { justify-content: start; }
  .paper .p-meta dt { text-align: left; }
  .paper .p-type { font-size: 38px; }
  .paper .p-parties, .paper .p-bottom { grid-template-columns: 1fr; gap: 22px; }
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
  .logo-field { flex-direction: column; align-items: flex-start; }
  #tbl th:nth-child(3), #tbl td:nth-child(3), #tbl th:nth-child(4), #tbl td:nth-child(4), #tbl tfoot { display: none; }
  .toasts { left: 12px; right: 12px; bottom: 12px; align-items: stretch; }
  .modal { padding: 22px 20px; }
}

/* Line item column widths: give the description the room */
.edit-items { table-layout: fixed; }
.edit-items th:nth-child(2) { width: 96px; }
.edit-items th:nth-child(3) { width: 70px; }
.edit-items th:nth-child(4) { width: 104px; }
.edit-items th:nth-child(5) { width: 28px; }
.edit-items .rate, .edit-items .qty { width: 100%; }
.p-items:not(.edit-items) th:nth-child(1) { width: 58%; }
@media (max-width: 820px) {
  .edit-items th:nth-child(2) { width: 84px; }
  .edit-items th:nth-child(3) { width: 52px; }
  .edit-items th:nth-child(4) { width: 92px; }
}
.edit-items input[type=number] { -moz-appearance: textfield; appearance: textfield; padding-left: 4px; padding-right: 4px; }
.edit-items input[type=number]::-webkit-outer-spin-button,
.edit-items input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- Upgrade banner ---------- */
.banner { background: var(--amber-tint); color: var(--amber); border-radius: 12px; padding: 11px 16px; font-size: 14px; margin-bottom: 12px; }

/* ---------- Price book ---------- */
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 60ch; }
.li-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tiny-link { font-size: 11.5px; font-weight: 500; color: var(--muted); opacity: 0; transition: opacity .12s; }
.edit-items tr:hover .tiny-link, .tiny-link:focus-visible { opacity: 1; }
@media (hover: none) { .tiny-link { opacity: 1; } }
.edit-items .unit { width: 100%; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.line-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.p-unit { font-size: 11px; color: #6B7682; }
.suggest { position: fixed; z-index: 70; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 18px 40px -12px rgba(22, 32, 42, .3); max-height: 320px; overflow: auto; }
.sg-head { font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 4px 10px 6px; }
.suggest button { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 12px; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13.5px; }
.suggest button.on, .suggest button:hover { background: var(--grey-tint); }
.suggest .num { white-space: nowrap; }
.suggest .sub { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42ch; }
.pick-modal { width: min(640px, 100%); }
.pick-list { max-height: 50vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.pick { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-top: 1px solid var(--line-2); cursor: pointer; font-weight: 400; color: var(--ink); font-size: 14px; }
.pick:first-child { border-top: 0; }
.pick:hover { background: #F6F8F7; }
.pick input { accent-color: var(--spruce); width: 17px; height: 17px; flex-shrink: 0; }
.pick .who { flex: 1; }

/* ---------- Payment schedule ---------- */
.p-sched { margin-top: 30px; }
.p-sched .sched th:first-child { width: 50%; }
.edit-sched { border-top: 1px solid #E6E9EB; padding-top: 22px; }
.edit-sched-t { table-layout: fixed; }
.edit-sched-t th:nth-child(2) { width: 170px; }
.edit-sched-t th:nth-child(3) { width: 80px; }
.edit-sched-t th:nth-child(4) { width: 110px; }
.edit-sched-t th:nth-child(5) { width: 28px; }
.edit-sched-t td { padding: 6px 8px; vertical-align: middle; }
.edit-sched-t .ghost { margin: 0; width: 100%; }
.edit-sched-t input[type=number] { appearance: textfield; -moz-appearance: textfield; }
.sched-tools { display: inline-flex; gap: 14px; }
.sched-empty { font-size: 13px; color: #6B7682; margin: 0; }
.sched-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 12px; }
.sched-warn { color: var(--red); font-size: 13px; font-weight: 500; }
.presets { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sched-tbl input, .sched-tbl select { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; width: 100%; font-size: 14px; }
.sched-tbl .pct-in { width: 90px; text-align: right; }
.sched-tbl td { padding: 6px 8px; }
.sched-tbl tr.none td { padding: 14px 8px; }
.ms { list-style: none; margin: 0; padding: 0; }
.ms li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line-2); }
.ms li:first-child { border-top: 0; }
.ms li > div { display: flex; flex-direction: column; min-width: 0; font-size: 14px; }
.ms .btn { padding: 6px 10px; font-size: 13px; }
.ms-inv { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap; }

/* ---------- Photos ---------- */
.ed-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; max-width: 816px; }
.ph-box { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.ph-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.ph-head h3 { margin: 0 0 2px; font-size: 16px; }
.ph-head .sub { margin: 0; }
#phStatus:empty { display: none; }
.ph-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.ph-grid figure { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.ph-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 9px; display: block; background: var(--grey-tint); }
.ph-grid .cap { margin: 0; width: 100%; font-size: 13px; }
.ph-act { display: flex; gap: 14px; }
.link.danger { color: var(--red); }
.btn.cam { display: none; }
@media (hover: none) and (pointer: coarse) { .btn.cam { display: inline-flex; } }
.p-photos { margin-top: 30px; }
.p-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.p-grid figure { margin: 0; break-inside: avoid; }
.p-grid img { width: 100%; height: auto; display: block; border-radius: 4px; }
.p-grid figcaption { font-size: 12px; color: #59646F; margin-top: 5px; }
@media (max-width: 820px) {
  .edit-sched-t th:nth-child(2) { width: 110px; }
  .edit-sched-t th:nth-child(4) { width: 90px; }
  .ph-grid { grid-template-columns: 1fr 1fr; }
}
.co-form .check input[type=checkbox] { width: 16px; height: 16px; padding: 0; margin: 0; flex: none; }

/* ---------- Photos sheet (web view) ---------- */
.paper + .paper { margin-top: 24px; }
.ph-title { margin-bottom: 22px; }
.p-type.sm { font-size: 30px; letter-spacing: -0.035em; margin-bottom: 4px; }
.p-grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px 14px; }
.p-grid3 figure { margin: 0; }
.p-grid3 img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; border-radius: 4px; background: #EDF0F1; }
.p-grid3 figcaption { font-size: 12px; color: #59646F; margin-top: 6px; line-height: 1.4; }
@media (max-width: 820px) { .p-grid3 { grid-template-columns: 1fr 1fr; } }

/* ---------- Printed pages (PDF, JPEG, preview) ---------- */
.pg {
  --brand: #1F4E46;
  width: 816px; height: 1056px; position: relative; overflow: hidden; background: #fff; color: #1A232C;
  padding: 52px 56px 0; font-size: 14px; line-height: 1.5; box-sizing: border-box;
}
.pg .p-band { position: absolute; left: 0; right: 0; top: 0; height: 7px; background: var(--brand); }
.pg-body { position: relative; }
.blk { display: flow-root; }
.pg .p-parties { margin-bottom: 26px; }
.pg .p-bottom { margin-top: 24px; }
.pg-sec-title { padding-top: 30px; }
.pg-notes p { margin: 0 0 12px; }
.pg-cont-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 2px 0 12px; margin-bottom: 18px; border-bottom: 1px solid #E6E9EB; font-size: 12.5px; color: #6B7682; }
.pg-co { font-weight: 700; font-size: 15px; color: #16202A; letter-spacing: -0.01em; }
.pg-cont-note { position: absolute; right: 56px; bottom: 82px; font-size: 12px; font-weight: 600; color: var(--brand); }
.pg-cont-note::after { content: " \2192"; }
.pg-foot { position: absolute; left: 56px; right: 56px; bottom: 28px; display: flex; justify-content: space-between; gap: 16px; padding-top: 12px; border-top: 1px solid #E6E9EB; font-size: 11px; color: #8A939C; }
.pg-ph-head { margin-bottom: 20px; }
.pg-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; padding-bottom: 18px; }
.pg-grid figure { margin: 0; }
.pg-grid img { width: 100%; height: 169px; display: block; border-radius: 4px; background: #EDF0F1; }
.pg-grid figcaption { font-size: 11.5px; color: #59646F; margin-top: 6px; line-height: 1.35; height: 31px; overflow: hidden; }
.pv-pages { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.pv-page { --s: 1; width: calc(816px * var(--s)); height: calc(1056px * var(--s)); overflow: hidden; box-shadow: 0 1px 2px rgba(22,32,42,.08), 0 20px 40px -24px rgba(22,32,42,.45); border-radius: 2px; background: #fff; flex-shrink: 0; }
.pv-page > .pg { transform: scale(var(--s)); transform-origin: top left; }

/* Percent or fixed-amount milestones */
.valcell { display: inline-flex; align-items: center; gap: 4px; justify-content: flex-end; width: 100%; }
.edit-sched-t .valcell .pct { width: 84px; flex: none; }
.edit-sched-t .valcell select.xs { width: auto; flex: none; }
.edit-sched-t th:nth-child(3) { width: 140px; }
.sched-tbl .pct-in { width: 110px; }
.sched-tbl .mode-in { width: 64px; padding: 7px 6px; }
.sched-tbl th:nth-child(3) { width: 200px; }
.p-items tr.sched-note td { font-size: 11.5px; color: #6B7682; border-bottom: 0; padding-top: 8px; }

/* ---------- Options on estimates ---------- */
.p-kind { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.p-opt { font-size: 10.5px; font-weight: 600; border-radius: 999px; padding: 1px 8px; letter-spacing: .01em; }
.p-opt.in { background: #E1EFE6; color: #2D6F47; }
.p-opt.out { background: #EDF0F1; color: #6B7682; }
.p-items tr.p-off td { color: #8A939C; }
.p-items tr.p-off td.p-num:last-child { text-decoration: line-through; text-decoration-color: #B9C1C6; }
.p-optnote { font-size: 11px; color: #6B7682; margin-top: 8px; text-align: right; }
.opt-pick { font-size: 11.5px; color: var(--muted); width: auto; padding: 1px 4px; margin: 0; cursor: pointer; }
.opt-pick.on { color: var(--violet); font-weight: 600; }
.li-opt { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.li-opt .grp { width: 220px; margin: 0; font-size: 12.5px; border-color: #E1E5E8; }
.li-opt .check.small { margin: 0; }
.edit-items td.amt.off { color: #A5ADB4; text-decoration: line-through; }
.opt-hint { align-self: center; font-size: 12px; }
#optWarn:empty { display: none; }

/* Customer page: choosing options */
.opts { border-bottom: 1px solid var(--line-2); padding-bottom: 20px; margin-bottom: 20px; }
.opts h2 { margin-bottom: 2px; }
.opt-group { border: 1px solid var(--line); border-radius: 12px; padding: 6px 14px 8px; margin: 14px 0 0; }
.opt-group legend { font-size: 13px; font-weight: 600; color: var(--ink-2); padding: 0 6px; }
.opt-row { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-top: 1px solid var(--line-2); cursor: pointer; font-weight: 400; color: var(--ink); font-size: 14.5px; }
.opt-row:first-of-type { border-top: 0; }
.opt-row input { accent-color: var(--spruce); width: 18px; height: 18px; flex-shrink: 0; margin: 0; }
.opt-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.opt-row .num { white-space: nowrap; font-weight: 600; }
.opt-total { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; padding: 12px 16px; background: var(--spruce); color: #fff; border-radius: 10px; font-size: 16px; }

/* ---------- Change orders ---------- */
.p-type.co { font-size: 38px; }
.p-contract { margin-top: 14px; border: 1px solid #E1E5E8; border-radius: 6px; padding: 8px 12px; }
.p-contract .tr { font-size: 12.5px; padding: 3px 0; }
.p-contract .tr.total { font-size: 13.5px; margin-top: 4px; padding-top: 7px; }
.co-ref { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; padding: 4px 0; }
.kv.total { border-top: 1px solid var(--line-2); margin-top: 4px; padding-top: 8px; }

/* ---------- Jobs ---------- */
.note-box { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; background: var(--blue-tint); color: var(--blue); border-radius: 12px; padding: 12px 16px; margin-bottom: 18px; font-size: 14px; }
.job-name { font: inherit; font-size: 28px; font-weight: 600; letter-spacing: -0.022em; border: 1px solid transparent; border-radius: 8px; padding: 0 6px; margin: 0 -7px; background: transparent; width: min(560px, 100%); color: var(--ink); }
.job-name:hover { border-color: var(--line); }
.job-name:focus { outline: none; border-color: var(--spruce-2); background: #fff; }
.status-sel { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; font-size: 14px; font-weight: 550; }
.job-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr); gap: 36px; }
.job-sec { margin-bottom: 30px; }
.job-sec .row-sb h2 { margin: 0; }
.job-sec .ph-grid figcaption { margin-top: 2px; }
.job-notes { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
#jSaved:empty { display: none; }
.pill.job-estimating { background: var(--blue-tint); color: var(--blue); }
.pill.job-active { background: var(--green-tint); color: var(--green); }
.pill.job-on_hold { background: var(--amber-tint); color: var(--amber); }
.pill.job-completed { background: var(--grey-tint); color: var(--muted); }
.metric.warn-soft .v { color: var(--amber); }
.pick-list button.pick { width: 100%; background: none; border: 0; text-align: left; }
@media (max-width: 1000px) { .job-grid { grid-template-columns: 1fr; } }
.edit-items td:first-child .opt-pick { width: auto; margin: 0; padding: 1px 4px; }
.edit-items td:first-child .li-opt .grp { width: 230px; margin: 0; display: inline-block; }
.tiny-link { white-space: nowrap; }
.li-opt { margin-top: 8px; }

/* ---------- List / Pipeline switch ---------- */
.seg { display: inline-flex; background: var(--grey-tint); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 7px; font-weight: 550; font-size: 13.5px; color: var(--ink-2); cursor: pointer; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(22, 32, 42, .12); }

/* ---------- Pipeline board ---------- */
.board-note { background: var(--amber-tint); color: var(--amber); border-radius: 10px; padding: 10px 14px; font-size: 13.5px; font-weight: 500; }
.board { display: grid; grid-template-columns: repeat(6, minmax(172px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity; }
.col { background: var(--desk); border: 1px solid var(--line-2); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; min-height: 220px; scroll-snap-align: start; transition: background .12s, border-color .12s; }
.col.drop-ok { background: var(--spruce-tint, #E3EEEB); border-color: var(--spruce-2); border-style: dashed; }
.col-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 2px 4px 10px; }
.col-head b { font-size: 13.5px; }
.col-head .count { display: inline-block; min-width: 20px; text-align: center; margin-left: 6px; font-size: 11.5px; font-weight: 700; color: var(--muted); background: #fff; border-radius: 999px; padding: 1px 6px; }
.col-body { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.col-empty { font-size: 12.5px; color: #9AA3AB; text-align: center; margin: 18px 6px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px 11px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; box-shadow: 0 1px 2px rgba(22, 32, 42, .04); transition: box-shadow .12s, transform .12s; }
.card:hover { box-shadow: 0 6px 16px -8px rgba(22, 32, 42, .3); }
.card.dragging { opacity: .45; }
.card.is-follow { border-left: 3px solid #C99A45; }
.card-top { display: flex; justify-content: space-between; align-items: center; }
.card-top .docno { font-size: 12px; color: var(--muted); }
.card-top .dots { padding: 2px 6px; }
.card-name { font-size: 14px; line-height: 1.3; }
.card-job { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.card-foot .num { font-weight: 600; font-size: 14px; }
.tag { font-size: 11px; color: var(--muted); }
.tag.follow { color: var(--amber); font-weight: 600; }
.tag.seen { color: var(--violet); font-weight: 600; }
.tag.ok { color: var(--green); font-weight: 600; }
.board-help { margin-top: 10px; }

/* ---------- Bottom menu (phones) ---------- */
.tabbar { display: none; }
@media (max-width: 820px) {
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
  .app { grid-template-rows: auto 1fr; }
  .side { padding-top: calc(14px + env(safe-area-inset-top, 0px)); flex-direction: row; align-items: center; flex-wrap: wrap; gap: 10px 14px; padding-bottom: 8px; }
  .side .nav, .side .side-foot { display: none; }
  .switch { flex: 1 1 100%; order: 3; }
  .top { top: calc(10px + env(safe-area-inset-top, 0px)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: rgba(255, 255, 255, .96); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 2px; border: 0; background: none; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 550; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .tabbar svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  .tabbar #moreTab svg { fill: currentColor; stroke: none; }
  .tabbar .on { color: var(--spruce); }
  .toasts { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
  .board { grid-template-columns: repeat(6, 78vw); }
  .head h1 { font-size: 24px; }
  .ed-actions { width: 100%; }
  .ed-actions .btn { flex: 1 1 auto; }
  .modal-wrap { align-items: end; padding: 0; }
  .modal { border-radius: 18px 18px 0 0; width: 100%; max-height: 92vh; overflow: auto; padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px)); }
  .filters select { flex: 1 1 40%; }
  input, select, textarea { font-size: 16px; } /* stops iPhone from zooming in when you tap a field */
  .ghost, .edit-items textarea.desc { font-size: 15px; }
}
/* Installed app: a touch more breathing room at the top for the status bar */
@media (display-mode: standalone) { .side { padding-top: calc(18px + env(safe-area-inset-top, 0px)); } }
/* Keep hidden helper labels inside their table so phones never scroll sideways */
.tbl-wrap, .p-items, .edit-sched-t { position: relative; }
.vh { left: 0; top: 0; }
body { overflow-x: clip; }

/* ---------- Phones: line items as stacked cards ---------- */
.p-mob { display: none; }
@media (max-width: 820px) {
  .sheet.desk { padding: 16px 10px 28px; }
  .paper.edit { padding: 30px 14px 24px; }

  .paper.edit .edit-items, .paper.edit .edit-items tbody { display: block; width: 100%; }
  .paper.edit .edit-items thead { display: none; }
  .paper.edit .edit-items tr.none { display: block; }
  .paper.edit .edit-items tr[data-i] {
    display: grid; grid-template-columns: minmax(0, 1fr) 72px minmax(0, 1fr) 32px;
    grid-template-areas: "desc desc desc desc" "rate qty amt x";
    column-gap: 10px; row-gap: 10px; padding: 16px 0; border-bottom: 1px solid #E6E9EB;
  }
  .paper.edit .edit-items tr[data-i] > td { display: block; padding: 0 !important; border: 0; width: auto !important; min-width: 0; }
  .paper.edit .edit-items tr[data-i] > td:nth-child(1) { grid-area: desc; }
  .paper.edit .edit-items tr[data-i] > td:nth-child(2) { grid-area: rate; text-align: left; }
  .paper.edit .edit-items tr[data-i] > td:nth-child(3) { grid-area: qty; text-align: left; }
  .paper.edit .edit-items tr[data-i] > td:nth-child(4) { grid-area: amt; text-align: right; font-size: 15.5px; font-weight: 600; }
  .paper.edit .edit-items tr[data-i] > td:nth-child(5) { grid-area: x; align-self: start; padding-top: 20px !important; }
  .paper.edit .edit-items tr[data-i] > td:nth-child(2)::before,
  .paper.edit .edit-items tr[data-i] > td:nth-child(3)::before,
  .paper.edit .edit-items tr[data-i] > td:nth-child(4)::before { display: block; font-size: 11.5px; font-weight: 600; color: #6B7682; margin-bottom: 4px; }
  .paper.edit .edit-items tr[data-i] > td:nth-child(2)::before { content: "Rate"; }
  .paper.edit .edit-items tr[data-i] > td:nth-child(3)::before { content: "Qty"; }
  .paper.edit .edit-items tr[data-i] > td:nth-child(4)::before { content: "Amount"; font-weight: 600; }
  .paper.edit .edit-items tr[data-i] > td:nth-child(4) { padding-top: 0 !important; line-height: 1.2; }
  .paper.edit .edit-items tr[data-i] > td:nth-child(4)::after { content: ""; display: block; height: 10px; }

  /* Comfortable, finger-sized fields */
  .paper.edit .edit-items textarea.desc { min-height: 96px; font-size: 16px; line-height: 1.5; padding: 10px 12px; }
  .paper.edit .edit-items .rate, .paper.edit .edit-items .qty {
    width: 100%; margin: 0; text-align: left; font-size: 16px; padding: 8px 10px;
    border: 1px solid #E1E5E8; border-radius: 8px; background: #FCFCFC;
  }
  .paper.edit .edit-items .unit { width: 100%; margin: 6px 0 0; text-align: left; font-size: 13px; padding: 4px 2px; }
  .paper.edit .edit-items .x { width: 32px; height: 32px; font-size: 20px; }
  .paper.edit .li-top { gap: 6px; flex-wrap: wrap; }
  .paper.edit .li-top .kind, .paper.edit .li-top .opt-pick { font-size: 13px; }
  .paper.edit .li-opt .grp { width: 100%; }
  .paper.edit .line-btns .btn { flex: 1 1 auto; }

  /* Payment schedule rows, stacked the same way */
  .paper.edit .edit-sched-t, .paper.edit .edit-sched-t tbody { display: block; width: 100%; }
  .paper.edit .edit-sched-t thead { display: none; }
  .paper.edit .edit-sched-t tr[data-si] {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 32px;
    grid-template-areas: "name name x" "basis val val" "amt amt amt";
    gap: 8px 10px; padding: 12px 0; border-bottom: 1px solid #E6E9EB;
  }
  .paper.edit .edit-sched-t tr[data-si] > td { display: block; padding: 0; border: 0; width: auto !important; }
  .paper.edit .edit-sched-t tr[data-si] > td:nth-child(1) { grid-area: name; }
  .paper.edit .edit-sched-t tr[data-si] > td:nth-child(2) { grid-area: basis; }
  .paper.edit .edit-sched-t tr[data-si] > td:nth-child(3) { grid-area: val; }
  .paper.edit .edit-sched-t tr[data-si] > td:nth-child(4) { grid-area: amt; text-align: right; font-weight: 600; }
  .paper.edit .edit-sched-t tr[data-si] > td:nth-child(4)::before { content: "Amount  "; font-weight: 500; color: #6B7682; font-size: 12px; }
  .paper.edit .edit-sched-t tr[data-si] > td:nth-child(5) { grid-area: x; }
  .paper.edit .edit-sched-t .ghost { border-color: #E1E5E8; background: #FCFCFC; padding: 7px 9px; }
  .paper.edit .edit-sched-t .valcell { justify-content: flex-start; }
  .paper.edit .edit-sched-t .valcell .pct { width: 100%; flex: 1; }

  /* Customer page on a phone: give the description the full width */
  .paper:not(.edit) .p-items:not(.sched) th:nth-child(2), .paper:not(.edit) .p-items:not(.sched) td:nth-child(2),
  .paper:not(.edit) .p-items:not(.sched) th:nth-child(3), .paper:not(.edit) .p-items:not(.sched) td:nth-child(3) { display: none; }
  .paper:not(.edit) .p-items:not(.sched) .p-mob { display: block; font-size: 12.5px; color: #6B7682; margin-top: 3px; }
}
@media (max-width: 820px) { .paper.edit .edit-items td.amt.off { text-decoration: none; color: #A5ADB4; } }

/* ---------- Import from Skynova ---------- */
.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center; border: 1.5px dashed #C3CBCF; border-radius: 14px; padding: 30px 20px; background: var(--desk); cursor: pointer; color: var(--ink); font-weight: 400; margin-bottom: 14px; transition: border-color .12s, background .12s; }
.drop:hover, .drop.over { border-color: var(--spruce-2); background: #EEF4F2; }
.drop b { font-size: 15px; color: var(--spruce); }
.imp-tbl td { vertical-align: top; }
.imp-tbl tr.off td { opacity: .55; }
.imp-tbl input[type=checkbox] { accent-color: var(--spruce); width: 17px; height: 17px; margin-top: 3px; }
.imp-foot { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; max-width: 760px; }
.imp-foot .btn-row { justify-content: flex-start; }
.modal.wide-form { width: min(760px, 100%); }
.modal h3 { margin: 6px 0 -4px; font-size: 15px; }
.rv-line { border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.rv-top { display: flex; align-items: center; gap: 8px; }
.rv-top select { width: auto !important; font-size: 13px; padding: 5px 8px; }
.rv-line textarea { min-height: 60px; }
.rv-nums { display: flex; gap: 10px; flex-wrap: wrap; }
.rv-nums label { flex: 1 1 120px; }

/* Logo boxes: fixed size, the logo is scaled to fit inside without stretching or cropping */
.logo-box { position: relative; width: 200px; height: 96px; flex: 0 0 200px; overflow: hidden; padding: 0; }
.logo-box img { position: absolute; inset: 10px; width: calc(100% - 20px); height: calc(100% - 20px); max-width: none; max-height: none; object-fit: contain; }
.logo-box .sub { position: absolute; inset: 0; display: grid; place-items: center; }
.co-logo { position: relative; }
.co-logo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 3px; box-sizing: border-box; }
/* Bigger logo boxes (twice the previous size) */
.logo-box { width: 400px; height: 192px; flex: 0 0 400px; max-width: 100%; }
.logo-box img { inset: 14px; width: calc(100% - 28px); height: calc(100% - 28px); }
.co-logo { width: 92px; height: 92px; border-radius: 14px; font-size: 32px; }
.co-logo img { padding: 6px; }
@media (max-width: 820px) { .logo-box { width: 100%; flex-basis: auto; height: 160px; } }
/* Logo on estimates, change orders and invoices (web, PDF and JPEG): box 50% wider, 25% taller */
.p-logo { width: 320px; height: 220px; max-width: 100%; max-height: none; background-repeat: no-repeat; background-size: contain; background-position: left center; }
.p-from { max-width: 400px; }
@media (max-width: 820px) { .paper .p-logo { width: min(320px, 100%); height: auto; aspect-ratio: 32 / 22; } }

/* ---------- Contract ---------- */
.contract-paper { margin-bottom: 24px; }
.contract-paper, .kpg { font-size: 13.5px; line-height: 1.55; color: #1A232C; }
.k-blk h2 { font-size: 26px; letter-spacing: -0.02em; color: var(--brand); margin: 0 0 4px; }
.k-sub { color: #6B7682; font-size: 13px; margin: 0 0 18px; }
.k-blk h3 { font-size: 14.5px; margin: 18px 0 6px; color: #16202A; }
.k-blk h3.k-sec { font-size: 15.5px; margin-top: 26px; padding-top: 14px; border-top: 1px solid #E6E9EB; color: var(--brand); }
.k-blk p { margin: 0 0 8px; }
.k-blk ul, .k-blk ol { margin: 0 0 8px; padding-left: 20px; }
.k-blk li { margin: 0 0 4px; }
.k-big { font-weight: 700; font-size: 13.5px; letter-spacing: .01em; }
.k-tbl { width: 100%; border-collapse: collapse; margin: 6px 0 10px; font-size: 13px; }
.k-tbl th { text-align: left; font-size: 11.5px; color: #6B7682; font-weight: 600; padding: 0 6px 6px 0; border-bottom: 2px solid var(--brand); }
.k-tbl td { padding: 7px 6px 7px 0; border-bottom: 1px solid #ECEFF0; }
.k-tbl .n { text-align: right; font-variant-numeric: tabular-nums; }
.k-box { border: 1.5px solid #16202A; padding: 12px 14px 4px; border-radius: 4px; }
.k-signs { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin: 14px 0 8px; }
.k-lab { font-size: 11.5px; font-weight: 600; color: #6B7682; margin-bottom: 4px; }
.k-sig { display: block; height: 64px; max-width: 100%; object-fit: contain; object-position: left bottom; }
.k-sig-blank { height: 64px; display: flex; align-items: flex-end; color: #A5ADB4; font-size: 12px; font-style: italic; }
.k-line { border-top: 1px solid #16202A; padding-top: 4px; font-weight: 600; font-size: 13px; }
.k-meta { font-size: 11.5px; color: #6B7682; }
.kpg .pg-body { font-size: 12.5px; line-height: 1.5; }
.kpg .k-blk h3 { margin-top: 12px; }

/* Signing form on the customer page */
.kform { display: flex; flex-direction: column; gap: 14px; margin-top: 10px; }
.kform > label:not(.check) { font-size: 13px; }
.kform input[name=n] { margin-top: 5px; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%; font-size: 16px; }
.k-agree { align-items: flex-start; font-size: 14px; line-height: 1.45; color: var(--ink); }
.k-agree input { margin-top: 3px; }
.k-padbox { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.k-padhead { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; font-size: 12.5px; color: var(--muted); background: var(--desk); border-bottom: 1px solid var(--line-2); }
.k-pad { display: block; width: 100%; height: 170px; touch-action: none; cursor: crosshair; background: linear-gradient(transparent 128px, #C8D0D4 128px, #C8D0D4 129px, transparent 129px); }
.k-arb { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; display: flex; flex-direction: column; gap: 10px; }
.k-arb summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.k-arb[open] { gap: 10px; }
.k-arb[open] > * + * { margin-top: 10px; }
.k-go { align-self: flex-start; padding: 12px 22px; font-size: 15px; }
.k-note { margin: -4px 0 0; }

/* Contract panel in the app */
.k-status { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.k-status .warn { color: var(--amber); font-weight: 600; font-size: 14px; }
.k-miss { margin: 0 0 10px; padding-left: 18px; font-size: 13px; color: var(--red); }
.k-miss li { margin-bottom: 2px; }
.sig-field { display: flex; flex-direction: column; gap: 8px; }
.sig-saved { height: 80px; border: 1px dashed #C6CED2; border-radius: 10px; display: grid; place-items: center; background: #FAFBFB; padding: 6px; }
.sig-saved img { max-height: 100%; max-width: 100%; }
@media (max-width: 820px) { .k-signs { grid-template-columns: 1fr; gap: 18px; } }
.k-blk { display: flow-root; }
.co-form select { border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; background: #fff; width: 100%; font-size: 14.5px; margin-top: 5px; }
.k-state select { display: block; width: 100%; margin-top: 5px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: #fff; font-size: 13.5px; }
