/* ============================================================
   TOKENS
   ============================================================ */
:root{
  --ink:#131A24;
  --ink-2:#3C4756;
  --muted:#6B7787;
  --faint:#9AA5B3;
  --line:#DDE2E9;
  --line-soft:#EBEEF2;
  --surface:#EDEFF3;
  --panel:#FFFFFF;
  --brand:#1B3A6B;
  --brand-soft:#EAF0FA;
  --accent:#C0912C;
  --ok:#0E7A57;
  --ok-soft:#E4F4EE;
  --warn:#9A6410;
  --warn-soft:#FBF1DF;
  --bad:#A32F2F;
  --bad-soft:#FBEAEA;
  --radius:10px;
  --radius-sm:7px;
  --sans:"Inter Tight","Inter","Segoe UI",system-ui,-apple-system,sans-serif;
  --serif:"Newsreader","Iowan Old Style","Georgia",serif;
  --shadow:0 1px 2px rgba(19,26,36,.06), 0 8px 24px -12px rgba(19,26,36,.18);
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  font-family:var(--sans);
  background:var(--surface);
  color:var(--ink);
  font-size:14px;
  line-height:1.5;
  -webkit-font-smoothing:antialiased;
  font-feature-settings:"tnum" 0;
}
button,input,select,textarea{font:inherit;color:inherit}
:focus-visible{outline:2px solid var(--brand);outline-offset:2px;border-radius:4px}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}

/* ============================================================
   APP CHROME
   ============================================================ */
.topbar{
  position:sticky;top:0;z-index:40;
  display:flex;align-items:center;gap:14px;
  padding:10px 18px;
  background:rgba(255,255,255,.88);
  backdrop-filter:blur(10px);
  border-bottom:1px solid var(--line);
}
.mark{display:flex;align-items:center;gap:10px;min-width:0}
.mark img{height:26px;width:auto;display:block}
.mark .glyph{
  width:26px;height:26px;border-radius:7px;background:var(--brand);
  color:#fff;display:grid;place-items:center;font-weight:700;font-size:12px;letter-spacing:.02em;
}
.mark b{font-size:14px;font-weight:600;letter-spacing:-.01em;white-space:nowrap}
.mark span{color:var(--faint);font-size:12px;white-space:nowrap}
.topbar .spacer{flex:1}

.nav{display:flex;gap:2px;background:var(--surface);padding:3px;border-radius:9px;border:1px solid var(--line-soft)}
.nav button{
  border:0;background:transparent;padding:6px 12px;border-radius:7px;
  font-size:13px;font-weight:500;color:var(--ink-2);cursor:pointer;white-space:nowrap;
}
.nav button:hover{color:var(--ink)}
.nav button[aria-selected="true"]{background:var(--panel);color:var(--ink);box-shadow:0 1px 2px rgba(19,26,36,.10);font-weight:600}

.btn{
  border:1px solid var(--line);background:var(--panel);color:var(--ink);
  padding:7px 13px;border-radius:8px;font-size:13px;font-weight:500;cursor:pointer;
  display:inline-flex;align-items:center;gap:7px;white-space:nowrap;
}
.btn:hover{border-color:#C6CDD7;background:#FAFBFC}
.btn:active{transform:translateY(.5px)}
.btn.primary{background:var(--brand);border-color:var(--brand);color:#fff}
.btn.primary:hover{background:#16305A}
.btn.ghost{border-color:transparent;background:transparent;color:var(--ink-2)}
.btn.ghost:hover{background:var(--surface);color:var(--ink)}
.btn.danger{color:var(--bad);border-color:#EED6D6}
.btn.danger:hover{background:var(--bad-soft)}
.btn.sm{padding:4px 9px;font-size:12px;border-radius:7px}
.btn[disabled]{opacity:.45;cursor:not-allowed}

.pill{
  display:inline-flex;align-items:center;gap:6px;
  padding:3px 9px;border-radius:999px;font-size:11.5px;font-weight:600;
  background:var(--surface);color:var(--muted);border:1px solid var(--line-soft);
}
.pill .dot{width:6px;height:6px;border-radius:50%;background:currentColor}
.pill.s-draft{background:var(--surface);color:var(--muted)}
.pill.s-sent{background:var(--brand-soft);color:var(--brand);border-color:#D3E0F4}
.pill.s-accepted{background:var(--ok-soft);color:var(--ok);border-color:#CDE9DE}
.pill.s-rejected{background:var(--bad-soft);color:var(--bad);border-color:#F0D8D8}
.pill.s-expired{background:var(--warn-soft);color:var(--warn);border-color:#F0E1C4}

/* layout */
.wrap{max-width:1760px;margin:0 auto;padding:18px}
.view{display:none}
.view.active{display:block}
.split{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,760px);gap:18px;align-items:start}
@media (max-width:1240px){.split{grid-template-columns:1fr}}

.card{
  background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);
  margin-bottom:14px;overflow:hidden;
}
.card > header{
  display:flex;align-items:center;gap:10px;
  padding:11px 15px;border-bottom:1px solid var(--line-soft);background:#FCFCFD;
}
.card > header h2{margin:0;font-size:13px;font-weight:600;letter-spacing:-.005em}
.card > header .hint{font-size:11.5px;color:var(--faint);font-weight:400}
.card > header .spacer{flex:1}
.card .body{padding:15px}
.card .body.tight{padding:10px 15px 14px}

.grid{display:grid;gap:11px}
.g2{grid-template-columns:1fr 1fr}
.g3{grid-template-columns:1fr 1fr 1fr}
.g4{grid-template-columns:1fr 1fr 1fr 1fr}
@media (max-width:760px){.g2,.g3,.g4{grid-template-columns:1fr}}

label.f{display:block}
label.f > span{
  display:block;font-size:11.5px;font-weight:600;color:var(--muted);
  margin-bottom:5px;letter-spacing:.005em;
}
input[type=text],input[type=date],input[type=number],input[type=email],input[type=tel],select,textarea{
  width:100%;padding:8px 10px;border:1px solid var(--line);border-radius:var(--radius-sm);
  background:#fff;font-size:13.5px;transition:border-color .12s;
}
input:hover,select:hover,textarea:hover{border-color:#C9D0DA}
input:focus,select:focus,textarea:focus{outline:none;border-color:var(--brand);box-shadow:0 0 0 3px rgba(27,58,107,.10)}
textarea{resize:vertical;min-height:74px;line-height:1.55}
input[type=number]{font-variant-numeric:tabular-nums}
.num{text-align:right;font-variant-numeric:tabular-nums}
.help{font-size:11.5px;color:var(--faint);margin-top:5px}

/* line items */
.items{width:100%;border-collapse:collapse}
.items th{
  font-size:11px;font-weight:600;color:var(--muted);text-align:left;
  padding:0 8px 7px;border-bottom:1px solid var(--line-soft);
}
.items th.r{text-align:right}
.items td{padding:7px 6px;vertical-align:top;border-bottom:1px solid var(--line-soft)}
.items tr:last-child td{border-bottom:0}
.items .drag{cursor:grab;color:var(--faint);padding:12px 2px 0 4px;user-select:none;font-size:14px;line-height:1}
.items input{padding:7px 8px;font-size:13px}
.items textarea{min-height:34px;font-size:12.5px;padding:6px 8px;line-height:1.45}
.items .rowsum{
  font-variant-numeric:tabular-nums;font-weight:600;font-size:13px;
  padding-top:14px;text-align:right;white-space:nowrap;
}
.items tr.dragging{opacity:.4}
.items tr.over td{box-shadow:inset 0 2px 0 var(--brand)}
.col-x{width:34px}

.chiprow{display:flex;flex-wrap:wrap;gap:6px;margin-top:9px}
.chip{
  border:1px dashed var(--line);background:#fff;color:var(--ink-2);
  padding:4px 10px;border-radius:999px;font-size:12px;cursor:pointer;font-weight:500;
}
.chip:hover{border-style:solid;border-color:var(--brand);color:var(--brand);background:var(--brand-soft)}

/* totals */
.totals{display:grid;gap:6px;font-variant-numeric:tabular-nums}
.totals .row{display:flex;justify-content:space-between;gap:16px;font-size:13px;color:var(--ink-2)}
.totals .row.big{
  margin-top:6px;padding-top:10px;border-top:1px solid var(--line);
  font-size:19px;font-weight:700;color:var(--ink);letter-spacing:-.02em;
}
.totals .row.neg{color:var(--ok)}

/* insight */
.insight{display:flex;gap:9px;padding:10px 12px;border-radius:var(--radius-sm);font-size:12.5px;line-height:1.5;margin-bottom:8px}
.insight:last-child{margin-bottom:0}
.insight b{font-weight:600}
.insight .ic{flex:none;width:16px;height:16px;border-radius:50%;display:grid;place-items:center;font-size:10px;font-weight:700;color:#fff;margin-top:1px}
.insight.i-warn{background:var(--warn-soft);color:#6B4708}.insight.i-warn .ic{background:var(--warn)}
.insight.i-ok{background:var(--ok-soft);color:#0B5B41}.insight.i-ok .ic{background:var(--ok)}
.insight.i-info{background:var(--brand-soft);color:#173257}.insight.i-info .ic{background:var(--brand)}
.insight.i-bad{background:var(--bad-soft);color:#7A2222}.insight.i-bad .ic{background:var(--bad)}

/* preview */
.previewpane{position:sticky;top:64px}
.pvbar{
  display:flex;align-items:center;gap:8px;padding:9px 12px;
  background:var(--panel);border:1px solid var(--line);border-bottom:0;
  border-radius:var(--radius) var(--radius) 0 0;
}
.pvbar .t{font-size:12px;font-weight:600;color:var(--muted)}
.pvbar .spacer{flex:1}
.stage{
  background:#DFE3E9;border:1px solid var(--line);border-radius:0 0 var(--radius) var(--radius);
  padding:16px;overflow:hidden;max-height:calc(100vh - 132px);overflow-y:auto;
}
.paperbox{position:relative}
#paper{
  width:210mm;background:#fff;transform-origin:top left;
  box-shadow:0 2px 6px rgba(19,26,36,.14),0 20px 50px -20px rgba(19,26,36,.35);
}

/* tables (lists) */
.list{width:100%;border-collapse:collapse;font-size:13px}
.list th{
  text-align:left;font-size:11px;font-weight:600;color:var(--muted);
  padding:8px 12px;background:#FCFCFD;border-bottom:1px solid var(--line-soft);position:sticky;top:0;
}
.list th.r,.list td.r{text-align:right}
.list td{padding:9px 12px;border-bottom:1px solid var(--line-soft);vertical-align:middle}
.list tbody tr:hover{background:#FAFBFC}
.list tbody tr:last-child td{border-bottom:0}
.list .strong{font-weight:600}
.list .sub{font-size:11.5px;color:var(--faint)}
.list .acts{display:flex;gap:5px;justify-content:flex-end;opacity:.35;transition:opacity .12s}
.list tr:hover .acts{opacity:1}

.empty{padding:40px 20px;text-align:center;color:var(--faint)}
.empty h3{margin:0 0 6px;font-size:14px;color:var(--ink-2);font-weight:600}
.empty p{margin:0 0 14px;font-size:13px;max-width:380px;margin-inline:auto}

.stats{display:grid;grid-template-columns:repeat(4,1fr);gap:12px;margin-bottom:14px}
@media (max-width:860px){.stats{grid-template-columns:1fr 1fr}}
.stat{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);padding:13px 15px}
.stat .k{font-size:11.5px;color:var(--muted);font-weight:600;margin-bottom:4px}
.stat .v{font-family:var(--serif);font-size:25px;font-weight:500;letter-spacing:-.02em;font-variant-numeric:tabular-nums;line-height:1.1}
.stat .n{font-size:11.5px;color:var(--faint);margin-top:3px}

/* modal */
.veil{position:fixed;inset:0;background:rgba(19,26,36,.42);display:none;place-items:center;z-index:80;padding:20px}
.veil.on{display:grid}
.modal{background:var(--panel);border-radius:12px;max-width:520px;width:100%;box-shadow:0 30px 70px -20px rgba(19,26,36,.5);max-height:88vh;overflow:auto}
.modal header{padding:16px 18px 0}
.modal h3{margin:0 0 5px;font-size:16px;font-weight:600;letter-spacing:-.01em}
.modal .sub{color:var(--muted);font-size:13px;margin:0}
.modal .body{padding:16px 18px}
.modal footer{display:flex;gap:8px;justify-content:flex-end;padding:0 18px 18px}
.checklist{list-style:none;margin:0;padding:0;font-size:13px}
.checklist li{padding:7px 0 7px 24px;position:relative;border-bottom:1px solid var(--line-soft);color:var(--ink-2)}
.checklist li:last-child{border-bottom:0}
.checklist li::before{content:"";position:absolute;left:4px;top:13px;width:7px;height:7px;border-radius:50%;background:var(--accent)}

.toast{
  position:fixed;left:50%;bottom:26px;transform:translateX(-50%) translateY(12px);
  background:var(--ink);color:#fff;padding:9px 16px;border-radius:999px;font-size:13px;font-weight:500;
  opacity:0;pointer-events:none;transition:opacity .18s,transform .18s;z-index:90;
}
.toast.on{opacity:1;transform:translateX(-50%) translateY(0)}

.swatchrow{display:flex;gap:8px;align-items:center}
input[type=color]{width:42px;height:34px;padding:2px;border:1px solid var(--line);border-radius:var(--radius-sm);background:#fff;cursor:pointer}
.logopreview{
  height:52px;border:1px dashed var(--line);border-radius:var(--radius-sm);
  display:grid;place-items:center;background:#FAFBFC;padding:6px;
}
.logopreview img{max-height:40px;max-width:180px}
.logopreview span{font-size:12px;color:var(--faint)}

/* ============================================================
   THE DOCUMENT (paper) — its own typographic world
   ============================================================ */
.doc{
  --dbrand:#1B3A6B;
  --dacc:#C0912C;
  padding:16mm 15mm 18mm;
  color:#1A1F26;
  font-family:var(--sans);
  font-size:9.6pt;
  line-height:1.55;
  font-variant-numeric:tabular-nums;
}
.doc .lede{font-variant-numeric:normal}
.doc h1,.doc h2,.doc h3{margin:0}
.doc a{color:inherit;text-decoration:none}

.doc .head{display:flex;align-items:flex-start;justify-content:space-between;gap:16mm}
.doc .brandblock{display:flex;align-items:center;gap:9px;min-width:0}
.doc .brandblock img{max-height:13mm;max-width:52mm;display:block}
.doc .brandblock .bg{
  width:11mm;height:11mm;border-radius:2.6mm;background:var(--dbrand);color:#fff;
  display:grid;place-items:center;font-weight:700;font-size:11pt;letter-spacing:.01em;
}
.doc .brandblock .bn{font-size:12pt;font-weight:600;letter-spacing:-.01em;line-height:1.2}
.doc .brandblock .bt{font-size:7.6pt;color:#78828F;line-height:1.3;margin-top:1px}
.doc .contact{text-align:right;font-size:8.2pt;color:#5A6472;line-height:1.65;white-space:nowrap}
.doc .contact .l{color:#98A1AC;display:inline-block;min-width:0}

.doc .title{margin-top:12mm;display:flex;align-items:flex-end;justify-content:space-between;gap:12mm}
.doc .title h1{
  font-family:var(--serif);font-weight:500;font-size:30pt;line-height:.95;
  letter-spacing:-.025em;color:#141A22;
}
.doc .title .proj{font-size:9.6pt;color:#5A6472;margin-top:2.5mm;max-width:95mm;line-height:1.45}
.doc .title .meta{text-align:right;font-size:8.4pt;color:#5A6472;line-height:1.7;white-space:nowrap}
.doc .title .meta b{display:block;font-family:var(--serif);font-size:13pt;font-weight:600;color:var(--dbrand);letter-spacing:.01em;line-height:1.2;margin-bottom:1.5mm}
.doc .rule{height:1.1mm;background:var(--dacc);width:26mm;margin:5mm 0 0}

.doc .parties{
  display:grid;grid-template-columns:1fr 1fr;gap:10mm;
  margin-top:8mm;padding:6mm 0;border-top:.35mm solid #E4E8EE;border-bottom:.35mm solid #E4E8EE;
}
.doc .party .lab{font-size:7.4pt;font-weight:700;color:#98A1AC;margin-bottom:2.2mm}
.doc .party .nm{font-size:11pt;font-weight:600;letter-spacing:-.01em;line-height:1.3}
.doc .party .ln{font-size:8.6pt;color:#5A6472;line-height:1.6}

.doc .lede{margin-top:7mm;font-size:10pt;line-height:1.72;color:#333B45;max-width:150mm}
.doc .lede p{margin:0 0 3.2mm}
.doc .lede p:last-child{margin-bottom:0}

.doc .sect{margin-top:9mm;break-inside:auto}
.doc .sect > h2{
  font-size:8pt;font-weight:700;color:var(--dbrand);
  padding-bottom:2mm;border-bottom:.35mm solid #E4E8EE;margin-bottom:4mm;
  display:flex;justify-content:space-between;align-items:baseline;
}
.doc .sect > h2 em{font-style:normal;font-weight:500;color:#98A1AC;font-size:7.6pt}

table.dt{width:100%;border-collapse:collapse}
table.dt thead th{
  font-size:7.4pt;font-weight:700;color:#98A1AC;text-align:left;
  padding:0 0 2.5mm;border-bottom:.35mm solid #E4E8EE;
}
table.dt thead th.r{text-align:right}
table.dt tbody td{padding:3.4mm 0;border-bottom:.3mm solid #EFF2F5;vertical-align:top;break-inside:avoid}
table.dt tbody tr:last-child td{border-bottom:0}
table.dt td.r{text-align:right;white-space:nowrap}
table.dt .iname{font-size:9.8pt;font-weight:600;letter-spacing:-.005em;line-height:1.35}
table.dt .idesc{font-size:8.4pt;color:#6B7583;line-height:1.55;margin-top:1.2mm;max-width:98mm}
table.dt .qty{color:#5A6472;white-space:nowrap;font-size:9pt}
table.dt .unitp{color:#5A6472;font-size:9pt}
table.dt .amt{font-weight:600;font-size:9.8pt}
table.dt .disc{display:block;font-size:7.6pt;color:#0E7A57;font-weight:600;margin-top:.8mm}

.doc .sumwrap{display:flex;justify-content:flex-end;margin-top:5mm;break-inside:avoid}
.doc .sum{width:88mm}
.doc .sum .r{display:flex;justify-content:space-between;padding:1.9mm 0;font-size:9.2pt;color:#4B5561}
.doc .sum .r.save{color:#0E7A57;font-weight:600}
.doc .sum .r.sub{border-top:.3mm solid #EFF2F5}
.doc .grand{
  display:flex;justify-content:space-between;align-items:baseline;
  margin-top:2.5mm;padding:4mm 5mm;background:var(--dbrand);color:#fff;border-radius:1.6mm;
}
.doc .grand .gl{font-size:8.4pt;font-weight:600;opacity:.82}
.doc .grand .gv{font-family:var(--serif);font-size:19pt;font-weight:600;letter-spacing:-.02em;line-height:1}
.doc .vatnote{text-align:right;font-size:7.8pt;color:#98A1AC;margin-top:2mm}

.doc .cols2{display:grid;grid-template-columns:1fr 1fr;gap:9mm}
.doc ul.tick{list-style:none;margin:0;padding:0;font-size:8.8pt;line-height:1.6}
.doc ul.tick li{position:relative;padding:0 0 2.4mm 5mm;color:#333B45;break-inside:avoid}
.doc ul.tick li::before{
  content:"";position:absolute;left:0;top:1.5mm;width:2.2mm;height:2.2mm;
  border-radius:.5mm;background:var(--dacc);
}
.doc ul.tick.no li::before{background:#DCE1E8}
.doc ul.tick.no li{color:#78828F}

.doc .phases{display:grid;gap:0}
.doc .phase{
  display:grid;grid-template-columns:7mm 1fr auto;gap:4mm;align-items:baseline;
  padding:3mm 0;border-bottom:.3mm solid #EFF2F5;break-inside:avoid;
}
.doc .phase:last-child{border-bottom:0}
.doc .phase .n{
  font-family:var(--serif);font-size:11pt;color:var(--dacc);font-weight:600;line-height:1;
}
.doc .phase .t{font-size:9.4pt;font-weight:600}
.doc .phase .d{font-size:8.2pt;color:#6B7583;margin-top:.8mm;line-height:1.5}
.doc .phase .w{font-size:8.4pt;color:#5A6472;white-space:nowrap;text-align:right}
.doc .phase .w b{display:block;font-weight:600;color:#333B45}

.doc .payrow{display:grid;grid-template-columns:1fr 1fr;gap:6mm;break-inside:avoid}
.doc .paybox{border:.35mm solid #E4E8EE;border-radius:1.6mm;padding:4mm 4.5mm}
.doc .paybox .pl{font-size:7.6pt;font-weight:700;color:#98A1AC;margin-bottom:1.5mm}
.doc .paybox .pv{font-family:var(--serif);font-size:14pt;font-weight:600;letter-spacing:-.02em;line-height:1.1}
.doc .paybox .pd{font-size:8.2pt;color:#6B7583;margin-top:1.2mm;line-height:1.5}

.doc .terms{font-size:8pt;color:#6B7583;line-height:1.7;columns:2;column-gap:9mm}
.doc .terms p{margin:0 0 2mm;break-inside:avoid}

.doc .sign{display:grid;grid-template-columns:1fr 1fr;gap:14mm;margin-top:12mm;break-inside:avoid}
.doc .sign .box{border-top:.35mm solid #C6CDD7;padding-top:2.5mm}
.doc .sign .who{font-size:9pt;font-weight:600}
.doc .sign .role{font-size:7.8pt;color:#98A1AC;margin-top:.6mm}

.doc .foot{
  margin-top:11mm;padding-top:4mm;border-top:.35mm solid #E4E8EE;
  display:flex;justify-content:space-between;gap:8mm;font-size:7.6pt;color:#98A1AC;line-height:1.55;
}
.doc .foot .fr{text-align:right;white-space:nowrap}

/* ============================================================
   PRINT
   ============================================================ */
@page{size:A4;margin:16mm 15mm 18mm}
@media print, .print-mode {
  html,body{background:#fff!important;margin:0!important;padding:0!important}
  .app{display:none!important}
  .veil,.toast{display:none!important}
  #printroot{display:block!important;position:static!important}
  #paper{
    width:auto!important;transform:none!important;box-shadow:none!important;margin:0!important;
  }
  /* page margins come from @page so every page gets them, not just the first */
  .doc{padding:0!important}
  .doc .sect > h2{break-after:avoid}
  .doc .title,.doc .head,.doc .parties{break-inside:avoid}
  *{-webkit-print-color-adjust:exact!important;print-color-adjust:exact!important}
}
#printroot{position:relative}
