/* Invoicing (private). Same colours and type as yanproduction.live / the overlay tool. */
:root {
  --bg: #060607; --surface: #0E0E0F; --raise: #141416; --ink: #F2F2F3; --muted: #A4A4A8; --dim: #6E6E73;
  --line: #222224; --line2: #2E2E31; --sel: #1A1A1C; --red: #C83736; --focus: #7FA8FF; --ok: #3DBE7A; --warn: #E3A33B; --info: #6FA0FF;
  --f-display: "Archivo", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
  --f-body: "IBM Plex Sans", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.5 var(--f-body); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.wrap { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 clamp(16px, 3vw, 40px); }

/* bar + nav */
.bar { position: sticky; top: 0; z-index: 20; background: rgba(6, 6, 7, .92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.bar-in { display: flex; align-items: center; gap: 14px; min-height: 58px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand svg { height: 21px; width: auto; display: block; color: #fff; }
.brand span { font: 500 12px/1 var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); padding-left: 12px; border-left: 1px solid var(--line2); }
:lang(zh) .brand span { font: 500 13px/1 var(--f-body); letter-spacing: .04em; text-transform: none; }
.bar-sp { flex: 1; }
.who { font-size: 13px; color: var(--muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang { display: flex; border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.lang button { border: 0; background: none; padding: 5px 10px; border-radius: 6px; font: 500 12px/1 var(--f-mono); color: var(--muted); cursor: pointer; }
.lang button[aria-pressed="true"] { background: var(--sel); color: var(--ink); }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-top: 1px solid var(--line); }
.nav::-webkit-scrollbar { display: none; }
.nav a { flex: none; padding: 12px 14px 11px; text-decoration: none; color: var(--muted); font-size: 14px; border-bottom: 2px solid transparent; white-space: nowrap; }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--red); font-weight: 600; }

/* type */
.h1 { font: 800 clamp(1.7rem, 1.3rem + 1.6vw, 2.4rem)/1.1 var(--f-display); letter-spacing: -0.01em; margin: 0; }
.h2 { font: 500 12px/1.2 var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; }
:lang(zh) .h2 { font-family: var(--f-body); letter-spacing: .06em; font-size: 13px; text-transform: none; }
.muted { color: var(--muted); } .dim { color: var(--dim); }
.note { color: var(--muted); font-size: 13.5px; margin: 6px 0 0; }
.page { padding: clamp(22px, 4vw, 40px) 0 80px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .grow { flex: 1; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line2); background: transparent; color: var(--ink); font-weight: 500; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--sel); }
.btn.solid { background: #F2F2F3; color: #0B0B0C; border-color: #F2F2F3; font-weight: 600; }
.btn.solid:hover { background: #fff; }
.btn.red { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }
.btn.small { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn.icon { min-width: 34px; padding: 0 10px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.danger { color: #FF8A88; border-color: #4a2424; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* cards & panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: clamp(16px, 2.4vw, 24px); }
.panel + .panel { margin-top: 18px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; container-type: inline-size; min-width: 0; }
.kpi .k { font-size: 12.5px; color: var(--muted); }
.kpi .v { font: 800 24px/1.2 var(--f-display); font-size: clamp(16px, 12.5cqi, 24px); margin-top: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .s { font-size: 12.5px; color: var(--dim); margin-top: 2px; }
.kpi.good .v { color: var(--ok); } .kpi.bad .v { color: #FF7B79; }
.alerts { display: grid; gap: 8px; margin-bottom: 18px; }
.alert { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 10px; background: #1b1508; border: 1px solid #3d2f0e; color: #F1C77A; font-size: 14px; }
.alert.red { background: #1d0b0b; border-color: #4a1d1d; color: #FF9F9D; }
.alert .grow { flex: 1; min-width: 200px; }

/* tables */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font: 500 11.5px/1.3 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 11px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--raise); }
:lang(zh) .tbl th { font-family: var(--f-body); letter-spacing: .04em; font-size: 12.5px; }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover td { background: #121214; }
.tbl .n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl .nw { white-space: nowrap; }
.tbl .b { font-weight: 600; }
.tbl tfoot td { font-weight: 700; background: var(--raise); border-top: 1px solid var(--line2); }
.empty { color: var(--dim); font-size: 14px; padding: 26px; text-align: center; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid var(--line2); color: var(--muted); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.draft { color: var(--muted); } .pill.sent { color: var(--info); } .pill.partial { color: var(--warn); } .pill.paid { color: var(--ok); }
.pill.overdue { color: #FF7B79; border-color: #4a1d1d; } .pill.void { color: var(--dim); text-decoration: line-through; } .pill.unpaid { color: var(--warn); }
.pill.ok { color: var(--ok); } .pill.miss { color: #FF7B79; } .pill.active { color: var(--info); } .pill.done { color: var(--ok); } .pill.plan { color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.seg button { min-height: 34px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--line); background: #0E0E0F; color: var(--ink); cursor: pointer; font-size: 13.5px; }
.seg button[aria-pressed="true"] { background: var(--sel); border-color: var(--line2); box-shadow: inset 0 0 0 1px var(--line2); font-weight: 600; }

/* forms */
.inp { width: 100%; min-height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line2); background: #0A0A0B; color: var(--ink); }
textarea.inp { padding: 10px 12px; min-height: 84px; resize: vertical; line-height: 1.45; }
select.inp { padding-right: 30px; }
.inp:focus { border-color: #4A4A4E; outline: none; box-shadow: 0 0 0 3px rgba(127, 168, 255, .18); }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form .full { grid-column: 1 / -1; }
.fld .lbl { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.chk { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.chk input { width: 18px; height: 18px; accent-color: var(--red); }
@media (max-width: 640px) { .form { grid-template-columns: minmax(0, 1fr); } }
.file-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.file-row .fname { font-size: 13px; color: var(--muted); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* modal */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 24px; background: rgba(0, 0, 0, .66); overflow-y: auto; }
.modal-box { width: 100%; max-width: 680px; background: var(--surface); border: 1px solid var(--line2); border-radius: 16px; padding: 22px 22px 18px; box-shadow: 0 30px 80px rgba(0, 0, 0, .6); }
.modal-box.wide { max-width: 1000px; }
.modal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.modal-head h2 { font: 700 20px/1.2 var(--f-display); margin: 0; flex: 1; }
.modal-foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.modal-foot .left { margin-right: auto; }
@media (max-width: 640px) { .modal { padding: 0; } .modal-box { border-radius: 0; min-height: 100%; border: 0; } }

/* invoice editor */
.ed { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
@media (max-width: 1080px) { .ed { grid-template-columns: minmax(0, 1fr); } }
.lines { width: 100%; border-collapse: collapse; }
.lines th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 0 6px 8px; }
.lines td { padding: 4px 4px; vertical-align: top; }
.lines .inp { min-height: 38px; padding: 0 9px; font-size: 14px; }
.lines textarea.inp { min-height: 38px; height: 38px; padding: 8px 9px; font-size: 13px; }
.lines .q { width: 74px; } .lines .p { width: 120px; } .lines .u2 { width: 110px; } .lines .amt { width: 120px; text-align: right; padding-top: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lines .x { width: 40px; }
@media (max-width: 760px) {
  .lines thead { display: none; }
  .lines tr { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .lines td { padding: 0; } .lines td.dsc { grid-column: 1 / -1; } .lines .q, .lines .p, .lines .u2 { width: auto; } .lines .amt { text-align: left; padding-top: 8px; } .lines .x { width: auto; }
}
.sumbox { position: sticky; top: 120px; }
.sum { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.sum td { padding: 6px 0; } .sum td:last-child { text-align: right; }
.sum .grand td { font: 800 20px/1.2 var(--f-display); border-top: 1px solid var(--line2); padding-top: 12px; }
.preview { background: #2a2a2d; border-radius: 12px; padding: 16px; overflow: auto; }
.preview .ydoc { border-radius: 4px; }

/* login */
.login { max-width: 420px; margin: 12vh auto; padding: 0 20px; }
.login .panel { padding: 28px; }
.login h1 { font: 800 28px/1.15 var(--f-display); margin: 0 0 6px; }
.login .form { grid-template-columns: 1fr; margin-top: 20px; }
.err { color: #FF8A88; font-size: 14px; margin: 10px 0 0; }
.okmsg { color: var(--ok); font-size: 14px; margin: 10px 0 0; }
.linkbtn { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 0; font-size: 13.5px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 80; background: #F2F2F3; color: #0B0B0C; padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }
.toast.bad { background: var(--red); color: #fff; }
.bar-mini { height: 6px; border-radius: 3px; background: var(--line2); overflow: hidden; min-width: 60px; }
.bar-mini i { display: block; height: 100%; background: var(--ok); }
.bar-mini i.neg { background: var(--red); }
.alert { margin-bottom: 10px; }
.alert + .kpis { margin-top: 8px; }
.brand span, .lang button { white-space: nowrap; }
@media (max-width: 640px) {
  .who { display: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpis > .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .kpi { padding: 12px 14px; }
  .kpi .v { font-size: clamp(15px, 12cqi, 20px); }
  .page-head .h1 { font-size: 26px; }
  .page-head.sp > .grow { flex-basis: 100%; }
}
/* quote editor: sections and vendor costs per line */
.qsec { margin-top: 18px; }
.lines tr.costrow td { padding: 0 4px 10px; border-bottom: 1px solid var(--line); }
.costs { display: grid; gap: 6px; padding: 8px 10px; border-left: 2px solid #3a2a12; background: #0c0b09; border-radius: 0 8px 8px 0; }
.crow { display: grid; grid-template-columns: minmax(140px, 1.4fr) 110px minmax(100px, 1fr) auto auto; gap: 6px; align-items: center; }
.crow .inp { min-height: 34px; font-size: 13.5px; padding: 0 8px; }
.crow .chk { font-size: 13px; white-space: nowrap; }
.costs .ghostc { justify-self: start; color: #F1C77A; border-color: #3d2f0e; min-height: 30px; }
@media (max-width: 760px) { .lines tr.costrow { display: block; } .crow { grid-template-columns: 1fr 1fr; } }
.lines td.dsc { width: 42%; min-width: 220px; }
@media (max-width: 760px) { .lines td.dsc { width: auto; min-width: 0; } .crow .btn.icon { width: 40px; } }
/* project page: breadcrumb, sub-navigation, next step */
.crumb { display: inline-block; margin-bottom: 10px; color: var(--muted); text-decoration: none; font-size: 14px; }
.crumb:hover { color: var(--ink); }
.subnav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); margin: 0 0 20px; }
.subnav::-webkit-scrollbar { display: none; }
.subnav a { flex: none; padding: 10px 14px 9px; text-decoration: none; color: var(--muted); font-size: 14.5px; border-bottom: 2px solid transparent; white-space: nowrap; }
.subnav a:hover { color: var(--ink); }
.subnav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--red); font-weight: 600; }
.subnav .cnt { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--sel); color: var(--muted); font-size: 12px; text-align: center; }
.page-head.sub { margin: 0 0 16px; }
.edtitle { font: 700 22px/1.2 var(--f-display); margin: 0; }
.next { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 16px 20px; margin-bottom: 18px; border-radius: 14px; border: 1px solid #3d2f0e; background: linear-gradient(90deg, #1b1508, #0e0e0f); }
.next .k { font-size: 12.5px; color: #F1C77A; }
.next .v { font: 700 19px/1.3 var(--f-display); margin-top: 2px; }
.next.done { border-color: #1d4430; background: linear-gradient(90deg, #0b1a12, #0e0e0f); }
.next.done .k { color: #8fe0b0; }
.next.bad { border-color: #4a1d1d; background: linear-gradient(90deg, #1f0c0c, #0e0e0f); }
.next.bad .k { color: #FF9F9D; }
.tbl tr.fresh td { background: #0b1a12; }
.muted a { color: inherit; }
/* portal */
.pcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr)); gap: 14px; }
.pcard { text-align: left; display: grid; gap: 8px; padding: 18px 20px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; font: inherit; }
.pcard:hover { border-color: #4A4A4E; }
.pc-h { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; font-size: 17px; }
.pc-h b { min-width: 0; }
.pc-h .pill { flex-shrink: 0; }
.pc-n { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.pc-n span { display: grid; gap: 2px; }
.pc-n b { color: var(--ink); font-size: 14px; font-variant-numeric: tabular-nums; }
.pc-n b.due { color: #FF9F9D; }
.vproj { margin-bottom: 16px; }
@media (max-width: 640px) { .pc-n { grid-template-columns: repeat(2, 1fr); } .pcards { grid-template-columns: 1fr; } }

.sec { font: 700 20px/1.3 var(--f-display); margin: 30px 0 14px; padding-top: 18px; border-top: 1px solid var(--line); }
.page-head + .sec { margin-top: 0; padding-top: 0; border-top: 0; }
.pref { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 30px; }
.pref .grow { flex: 1; min-width: 220px; }

/* quote editor */
.edmain { display: grid; gap: 16px; }
.edmain > .panel { margin: 0; }
.ph { font: 600 13px/1.3 var(--f-body, inherit); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 14px; }
.ph-row { display: flex; align-items: baseline; gap: 12px; margin-bottom: 4px; } .ph-row .ph { margin: 0; }
.form.f3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 760px) { .form.f3 { grid-template-columns: 1fr 1fr; } }
.qsec { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.qsec:first-child { border-top: 0; padding-top: 6px; margin-top: 6px; }
.lines .cst { width: 130px; text-align: right; }
.costbtn { all: unset; box-sizing: border-box; cursor: pointer; display: inline-grid; justify-items: end; gap: 1px; min-height: 38px; padding: 6px 10px; border-radius: 9px; border: 1px dashed #3d2f0e; color: #F1C77A; font-size: 12.5px; line-height: 1.25; text-align: right; max-width: 130px; }
.costbtn:hover { background: #17120a; }
.costbtn.has { border-style: solid; border-color: #3d2f0e; background: #120f08; color: var(--ink); }
.costbtn.has b { font-weight: 700; font-variant-numeric: tabular-nums; }
.costbtn span { color: #c9a86a; font-size: 11.5px; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.costbtn[aria-expanded="true"] { outline: 1px solid #F1C77A; }
.sumbox { display: grid; gap: 14px; }
.sumbox .panel { margin: 0; }
.intl { margin-top: 14px; padding: 12px 14px; border-radius: 10px; background: #0c0b09; border: 1px solid #2a2110; }
.intl .k { font-size: 11.5px; letter-spacing: .04em; color: #c9a86a; margin-bottom: 4px; }
.intl .sum td { padding: 4px 0; }
.acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.acts .btn.solid { flex: 1 1 100%; justify-content: center; }
@media (max-width: 760px) { .lines .cst { width: auto; text-align: left; } .costbtn { justify-items: start; text-align: left; } }

/* quote lines: let the description take the slack, keep numbers compact */
.qsec .lines td.dsc { width: auto; min-width: 200px; }
.qsec .lines .p { width: 96px; } .qsec .lines .q { width: 62px; } .qsec .lines .u2 { width: 86px; } .qsec .lines .amt { width: 112px; } .qsec .lines .x { width: 36px; }
.qsec .lines .u2 .inp { padding: 0 4px; }
@media (max-width: 760px) { .qsec .lines td.dsc { min-width: 0; } .qsec .lines .p, .qsec .lines .q, .qsec .lines .u2, .qsec .lines .amt, .qsec .lines .x { width: auto; } }
.lines:has(tbody:empty) thead { display: none; }

/* vendor portal */
.next .grow { flex: 1; min-width: 220px; }
.pc-n b.okc { color: #3DBE7A; }
.invbox { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 12px; padding: 14px 18px; border-radius: 12px; border: 1px solid #3d2f0e; background: linear-gradient(90deg, #1b1508, #0e0e0f); }
.invbox.ok { border-color: #1d4430; background: linear-gradient(90deg, #0b1a12, #0e0e0f); }
.invbox .k { font-size: 12.5px; color: #F1C77A; } .invbox.ok .k { color: #8fe0b0; }
.invbox .v { font-weight: 700; margin: 2px 0; }

/* portal project cards: one full-width row each, aligned with the KPI row above */
.pcards { grid-template-columns: 1fr; gap: 12px; }
.pcard { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "h n" "d n"; column-gap: 28px; row-gap: 4px; align-items: center; padding: 18px 22px; }
.pcard .pc-h { grid-area: h; justify-content: flex-start; }
.pcard > .dim { grid-area: d; }
.pcard .pc-n { grid-area: n; margin: 0; grid-template-columns: repeat(4, minmax(110px, auto)); gap: 22px; text-align: right; }
.pcard .pc-n span { justify-items: end; }
@media (max-width: 760px) {
  .pcard { grid-template-columns: 1fr; grid-template-areas: "h" "d" "n"; }
  .pcard .pc-n { grid-template-columns: repeat(2, minmax(0, 1fr)); text-align: left; margin-top: 8px; }
  .pcard .pc-n span { justify-items: start; }
}

/* portal tables become cards on phones */
@media (max-width: 640px) {
  .tbl.stack thead { display: none; }
  .tbl.stack, .tbl.stack tbody, .tbl.stack tfoot { display: block; }
  .tbl.stack tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .tbl.stack td { padding: 0; border: 0; text-align: left !important; white-space: normal; }
  .tbl.stack td[data-l]::before { content: attr(data-l); display: block; font-size: 11.5px; font-weight: 400; color: var(--muted); margin-bottom: 2px; }
  .tbl.stack td:first-child { grid-column: 1 / -1; }
  .tbl.stack td:last-child:not([data-l]) { grid-column: 1 / -1; }
  .tbl.stack tfoot td[colspan] { grid-column: 1 / -1; }
  .tbl.stack tfoot tr { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 14px; background: var(--raise); }
  .tbl.stack tfoot td { background: transparent; border: 0; }
  .tbl.stack tfoot td:empty { display: none; }
  .tbl.stack tfoot tr:not(:has(td.n ~ td.n)) td::before { display: none; }
  .tbl.stack tr.fresh { background: #0b1a12; }
  .tbl.stack td[data-l]:empty { display: none; }
  .tbl.stack tr.fresh td { background: transparent; }
  .tbl-wrap:has(.tbl.stack) { overflow: visible; }
}
.catgrid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 6px 8px; align-items: center; }
.catgrid > .dim { font-size: 12px; }
.tbl td.neg { color: #FF7B79; }

.alert > .grow { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lines textarea.inp { resize: none; overflow: hidden; }
.filepick { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 6px 4px 4px; border: 1px dashed var(--line2); border-radius: 10px; }
.filepick .fname { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
/* drag to reorder (quote lines + sections, invoice lines, rate card) */
.drag { flex: none; display: inline-grid; place-items: center; width: 26px; min-height: 34px; padding: 0; border: 0; background: none; color: var(--dim); font: 700 14px/1 system-ui, sans-serif; letter-spacing: -3px; cursor: grab; touch-action: none; border-radius: 6px; }
.drag:hover { color: var(--ink); background: var(--sel); }
.is-dragging, .is-dragging * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }
.dragging { opacity: .35; }
.drop-b > td { box-shadow: inset 0 2px 0 var(--red); }
.drop-a > td { box-shadow: inset 0 -2px 0 var(--red); }
.qsec.drop-b { box-shadow: 0 -3px 0 var(--red); }
.qsec.drop-a { box-shadow: 0 3px 0 var(--red); }
.qsec.drop-in { outline: 2px dashed var(--red); outline-offset: 4px; border-radius: 8px; }
.lines th.h, .lines td.h { width: 28px; padding-left: 0; padding-right: 0; }
.lines td.h { padding-top: 6px; }
.tbl td.h { width: 34px; padding-right: 0; }
.tbl tr.grp td { background: var(--raise); padding-top: 9px; padding-bottom: 9px; }
.tbl tr.grp td b { font-weight: 600; }
@media (max-width: 760px) {
  .lines tr[data-dk] { position: relative; }
  .lines td.h { position: absolute; top: 10px; right: 0; padding: 0; width: auto; }
  .lines tr[data-dk] td.dsc { padding-right: 34px; }
}
@media (max-width: 640px) {
  .tbl.stack tr[data-dk] { position: relative; }
  .tbl.stack td.h { position: absolute; top: 10px; right: 10px; width: auto; }
  .tbl.stack tr[data-dk] > td:nth-child(2) { padding-right: 34px; }
  .tbl.stack tr.drop-b { box-shadow: inset 0 2px 0 var(--red); }
  .tbl.stack tr.drop-a { box-shadow: inset 0 -2px 0 var(--red); }
}
@media (max-width: 640px) { .tbl.stack tr[data-dk] > td:nth-child(2) { grid-column: 1 / -1; } }
@media (max-width: 640px) {
  .page-head > h1.grow { min-width: 6em; }
  .tbl.stack tr.grp { background: var(--raise); padding-top: 12px; padding-bottom: 12px; }
  .tbl.stack tr.grp td { background: transparent; }
  .tbl.stack tr.grp td.h { top: 6px; }
}
/* editor header: number + copy link on the left, status on the right */
.edhead { align-items: center; gap: 10px; }
.edhead #cpl { display: inline-flex; align-items: center; gap: 10px; }
.edhead #cpl:empty { display: none; }
.edhead .seen { font-size: 12.5px; white-space: nowrap; }
/* save / preview / pdf on one row */
.tools3 { display: flex; gap: 8px; margin-bottom: 16px; }
.tools3 .btn { flex: 1 1 0; min-width: 0; padding: 0 8px; }
.tools3 .btn[hidden] { display: none; }
/* status actions: full-width buttons, the secondary ones share a row in equal widths */
.acts { display: grid; gap: 8px; margin-top: 12px; }
.acts > .btn { width: 100%; }
.acts .pair { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; }
.acts .pair .btn { width: 100%; padding: 0 8px; }
.acts:empty { display: none; }
#lnk:empty { display: none; }
/* vendor cost button: same outline with or without a cost, one centred line */
.lines .cst, .qsec .lines .cst { width: 150px; }
.costbtn, .costbtn.has { display: flex; align-items: center; justify-content: center; width: 100%; max-width: none; height: 38px; min-height: 38px; padding: 0 10px; border: 1px solid #4a3812; border-radius: 9px; background: #120f08; color: #F1C77A; font-size: 12.5px; font-weight: 600; text-align: center; }
.costbtn:hover { background: #1b150a; border-color: #6b5219; }
.costbtn span, .costbtn.has span { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: inherit; font-size: inherit; }
@media (max-width: 760px) { .costbtn, .costbtn.has { justify-content: center; text-align: center; } }
/* vendor cost window */
.modal-box.small { max-width: 540px; }
.cmhead { margin: -4px 0 14px; }
.cmhead .b { font-weight: 600; margin-bottom: 3px; }
.cmhead .muted { font-size: 13px; }
.cmlist { display: grid; gap: 10px; margin-bottom: 12px; }
.cmrow { display: grid; grid-template-columns: minmax(0, 1fr) 120px 38px; gap: 8px; align-items: center; padding: 12px; border: 1px solid var(--line2); border-radius: 12px; background: var(--raise); }
.cmrow [data-c="notes"] { grid-column: 1 / 2; }
.cmrow .chk { grid-column: 2 / 4; }
.cmrow .btn.icon { width: 38px; min-width: 38px; height: 38px; padding: 0; }
@media (max-width: 640px) {
  .modal:has(.modal-box.small) { align-items: flex-end; padding: 0; }
  .modal-box.small { min-height: 0; border-radius: 16px 16px 0 0; border-top: 1px solid var(--line2); }
  .cmrow { grid-template-columns: minmax(0, 1fr) 104px 38px; }
}
/* accepted quote: read-only except vendor costs */
.lockbar { margin-bottom: 14px; padding: 12px 14px; border-radius: 12px; border: 1px solid #23324a; background: #0c1320; color: #b9cdf0; font-size: 13.5px; line-height: 1.5; }
.lockbar::before { content: "🔒 "; }
.ed.locked .drag, .ed.locked [data-s="del"], .ed.locked .lines td.x button, .ed.locked [data-s="add"], .ed.locked [data-s="rate"], .ed.locked #as { display: none; }
.ed.locked .edmain .inp:disabled { opacity: 1; color: var(--ink); -webkit-text-fill-color: var(--ink); background: transparent; border-color: var(--line); cursor: default; }
.ed.locked .edmain select.inp:disabled { appearance: none; -webkit-appearance: none; background-image: none; }
.ed.locked .lines textarea.inp:placeholder-shown { display: none; }
.ed.locked .edmain .chk input:disabled { opacity: .7; }
/* quote line columns: a bit tighter so the description keeps its room */
.qsec .lines .p { width: 86px; } .qsec .lines .q { width: 54px; } .qsec .lines .u2 { width: 76px; } .qsec .lines .amt { width: 104px; } .qsec .lines .cst { width: 140px; } .qsec .lines .x { width: 34px; }
.ed.locked .lines .h, .ed.locked .lines .x { display: none; }
.ed.locked .lines tr[data-dk] td.dsc { padding-right: 4px; }
.cmcols { display: grid; grid-template-columns: minmax(0, 1fr) 120px 38px; gap: 8px; padding: 0 13px 6px; font-size: 12px; color: var(--muted); }
@media (max-width: 640px) { .cmcols { grid-template-columns: minmax(0, 1fr) 104px 38px; } }
/* action buttons always sit flush with the right edge of the table */
.tbl td:last-child:has(> .btn, > button, > a.btn, > .acts-cell) { text-align: right; width: 1%; white-space: nowrap; }
.tbl td:last-child > .btn + .btn { margin-left: 6px; }
/* tables: first column starts at the left edge, last column ends at the right edge */
.tbl th:last-child:not([colspan]), .tbl td:last-child:not([colspan]) { text-align: right; }
.tbl td.fdate { width: 1%; text-align: right; color: var(--muted); padding-right: 18px; }
.tbl .icoslot { display: inline-block; width: 36px; text-align: left; margin-left: 6px; white-space: nowrap; }
@media (max-width: 640px) { .tbl.stack .icoslot { width: auto; } .tbl.stack td.fdate { width: auto; } }
.tbl th.n:has(+ th:last-child:empty) { padding-right: 18px; }
/* phones: the title gets its own line, the page buttons line up underneath from the left */
@media (max-width: 640px) {
  .page-head > h1.grow, .page-head > h2.grow { flex-basis: 100%; }
  .page-head > span.grow:empty { display: none; }
}
/* document number that opens the document */
.doclink { all: unset; cursor: pointer; font-weight: 600; color: var(--ink); text-decoration: underline; text-decoration-color: rgba(255, 255, 255, .28); text-underline-offset: 3px; }
.doclink:hover { color: #fff; text-decoration-color: var(--red); }
.doclink:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
/* pills and counters that sit inside a line of text: centre them on the text */
.pill { vertical-align: middle; line-height: 16px; position: relative; top: -1px; }
.subnav .cnt { vertical-align: middle; line-height: 18px; position: relative; top: -1px; }
/* line description with a compact "details" button; details show in small text underneath */
.dscrow { display: flex; gap: 6px; align-items: center; }
.dscrow .inp { flex: 1; min-width: 0; }
.detbtn { all: unset; box-sizing: border-box; flex: none; cursor: pointer; height: 38px; padding: 0 10px; border-radius: 9px; border: 1px dashed var(--line2); color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.detbtn:hover { color: var(--ink); border-color: var(--muted); }
.detbtn.has { border-style: solid; }
.detline { all: unset; display: block; cursor: pointer; margin: 5px 2px 0; font-size: 12.5px; line-height: 1.45; color: var(--muted); white-space: normal; overflow-wrap: anywhere; }
.detline:hover { color: var(--ink); }
.ed.locked .detbtn { display: none; }
.ed.locked .detline { pointer-events: none; }
.detbtn { width: 38px; padding: 0; text-align: center; font-size: 15px; font-weight: 400; }
.detbtn.has { color: var(--ink); border-color: var(--line2); background: var(--raise); }
/* section title with an action on the right (portal) */
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 26px 0 10px; }
.sec-head .h2 { margin: 0; }
