:root {
  --olive: #767650; --olive-2: #969674; --olive-dk: #55553a; --wash: #f2f2e8;
  --ink: #23241c; --muted: #7d7e70; --line: #e3e1d5; --bg: #f6f5f0; --card: #fff;
  --green: #15803d; --green-w: #e8f5ec; --red: #c0392b; --red-w: #fdeeee;
  --amber: #a16207; --amber-w: #fdf5e0; --blue: #1d4ed8; --blue-w: #eaf1ff;
}
* { box-sizing: border-box; }
[x-cloak]:not(body) { display: none !important; }
body { margin: 0; font: 14px/1.45 Inter, system-ui, sans-serif; color: var(--ink); background: var(--bg); }
h1 { font-size: 22px; margin: 0 0 2px; }
h2 { font-size: 18px; margin: 0; }
h3 { font-size: 14px; margin: 0; }
p { margin: 0; }
.muted, small { color: var(--muted); font-size: 12px; }
.r { text-align: right; }

/* layout */
.app { display: flex; min-height: 100vh; }
.side { width: 232px; flex: none; background: #fbfaf6; border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { padding: 0 8px 10px; }
.brand img { width: 108px; display: block; }
.navgroup { font-size: 11px; color: var(--muted); padding: 16px 10px 6px; letter-spacing: .04em; text-transform: uppercase; }
.navitem { display: block; padding: 8px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-weight: 500; }
.navitem:hover { background: var(--wash); }
.navitem.on { background: var(--olive); color: #fff; }
.sidefoot { margin-top: auto; padding: 16px 10px 0; }
.proto { font-size: 11px; background: var(--amber-w); color: var(--amber); padding: 6px 8px; border-radius: 6px; margin-bottom: 6px; }
.link { background: none; border: 0; color: var(--olive-dk); font: inherit; font-size: 12px; text-decoration: underline; cursor: pointer; padding: 0; }
.main { flex: 1; min-width: 0; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 28px; border-bottom: 1px solid var(--line); background: #fbfaf6; position: sticky; top: 0; z-index: 5; }
.company { font-weight: 600; color: var(--olive-dk); }
.who { display: flex; align-items: center; gap: 8px; }
.content { padding: 26px 28px 60px; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.head p { color: var(--muted); max-width: 720px; }

/* controls */
.btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 9px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--olive-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.p { background: var(--olive-dk); border-color: var(--olive-dk); color: #fff; }
.btn.p:hover { background: var(--ink); }
.btn.s { padding: 5px 9px; font-size: 12px; font-weight: 500; }
.btn.ok { color: var(--green); border-color: #b9dcc5; }
.btn.bad { color: var(--red); border-color: #efc9c5; }
.input { font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
.input:focus { outline: 2px solid var(--olive-2); outline-offset: -1px; }
.input:disabled { background: #f3f2ec; color: var(--muted); }
.input.sm { padding: 5px 8px; font-size: 12px; width: auto; }
.input.narrow { width: 92px; }
.input.auto { width: auto; }
.input.search { max-width: 380px; margin-bottom: 14px; }
textarea.input { resize: vertical; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
label .input, label .readonly { margin-top: 4px; font-weight: 400; }
label small { display: block; font-weight: 400; margin-top: 3px; }
.readonly { padding: 8px 10px; border: 1px dashed var(--line); border-radius: 8px; background: var(--wash); color: var(--ink); font-size: 14px; min-height: 37px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; color: var(--ink); font-size: 13px; }
.check input { margin-top: 3px; }
.check em { font-style: normal; font-size: 11px; background: var(--green-w); color: var(--green); padding: 1px 6px; border-radius: 10px; }
.hint { color: var(--muted); margin-bottom: 14px; }

/* cards and tables */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.card.flush { padding: 0; overflow-x: auto; }
.card h3 { margin-bottom: 10px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 2px; }
.stat span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat b { font-size: 22px; }
.stat b.warn { color: var(--red); }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 14px; }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t th.r { text-align: right; }
.t td { padding: 11px 14px; border-bottom: 1px solid #efede4; vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t.boxed { border: 1px solid var(--line); border-radius: 10px; border-collapse: separate; border-spacing: 0; margin: 6px 0 14px; }
.empty { text-align: center; color: var(--muted); padding: 28px 14px !important; }
.acts { text-align: right; white-space: nowrap; }
.acts .btn { margin-left: 4px; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 20px; white-space: nowrap; }
.b-grey { background: #eeede6; color: #5e5f52; } .b-blue { background: var(--blue-w); color: var(--blue); }
.b-green { background: var(--green-w); color: var(--green); } .b-red { background: var(--red-w); color: var(--red); }
.b-amber { background: var(--amber-w); color: var(--amber); }
.bar { height: 6px; width: 90px; background: #eceade; border-radius: 4px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 6px; }
.bar i { display: block; height: 100%; background: var(--olive); }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; }
.tabs button { font: inherit; font-weight: 600; border: 1px solid var(--line); background: #fff; padding: 7px 14px; border-radius: 8px; cursor: pointer; }
.tabs button.on { background: var(--olive); color: #fff; border-color: var(--olive); }
.termrow { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.termrow .input { width: 190px; } .termrow .input.sm { width: 100px; } .termrow .input.grow { flex: 1; width: auto; }

/* modals */
.modal-bg { position: fixed; inset: 0; background: rgba(30, 31, 22, .5); display: flex; align-items: flex-start; justify-content: center; padding: 34px 16px; overflow-y: auto; z-index: 20; }
.modal { background: #fbfaf6; border-radius: 14px; width: 100%; max-width: 720px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal.wide { max-width: 1020px; }
.mhead, .mfoot { display: flex; justify-content: space-between; align-items: center; padding: 16px 22px; }
.mhead { border-bottom: 1px solid var(--line); }
.mfoot { border-top: 1px solid var(--line); justify-content: flex-end; gap: 8px; }
.mbody { padding: 20px 22px; }
.x { background: none; border: 0; font: inherit; color: var(--muted); cursor: pointer; text-decoration: underline; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
.span2 { grid-column: span 2; }
.sec { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 14px 0 10px; flex-wrap: wrap; }
.sec .check { margin: 0; }
.line { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 12px 12px 0; margin-bottom: 10px; }
.lrow1 { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.lrow1 select { max-width: 440px; }
.lrow2 { display: grid; grid-template-columns: minmax(0, 1fr) 80px 100px 110px 80px 120px; gap: 0 10px; }
.avail { font-size: 12px; color: var(--green); font-weight: 600; flex: 1; }
.avail.short, .paysum.short { color: var(--red); }
.totals { display: flex; gap: 22px; align-items: baseline; flex-wrap: wrap; }
.totals .grand b { font-size: 17px; }
.tranche { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.tranche select.input { width: 170px; }
.days { display: flex; gap: 8px; align-items: center; }
.paysum { font-size: 12px; color: var(--muted); flex: 1; }
.termpick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 12px; }
.termpick .check { margin: 0; }
.prodform { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 22px; }
.prodform h3 { margin: 6px 0 8px; }
.prodform .termpick { grid-template-columns: 1fr; }
.qrbox { text-align: center; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.qrbox > div { width: 180px; height: 180px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.qrbox svg, .qr svg { width: 100%; height: 100%; display: block; }
.upload { background: var(--wash); border: 1px dashed var(--olive-2); border-radius: 10px; padding: 14px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font: inherit; font-size: 12px; background: var(--wash); border: 1px solid var(--line); border-radius: 20px; padding: 4px 11px; cursor: pointer; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 50; font-weight: 500; }
.toast.bad { background: var(--red); }
.toast { pointer-events: none; }
.storagefull { background: var(--red-w); color: var(--red); border: 1px solid #efc9c5; border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-weight: 600; }

/* printable documents */
.docwrap { width: 100%; max-width: 820px; }
.docbar { display: flex; justify-content: flex-end; gap: 8px; margin-bottom: 10px; }
.paper { background: #fff; padding: 44px 48px; border-radius: 4px; min-height: 1000px; color: #1c1c1c; }
.paper.label { min-height: 0; display: flex; gap: 24px; align-items: center; max-width: 460px; margin: 0 auto; padding: 24px; }
.paper.label .qr { width: 150px; height: 150px; flex: none; }
.paper.label b { font-size: 22px; }
.dhead { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid var(--olive); padding-bottom: 16px; }
.dhead img { width: 104px; }
.dco { text-align: right; display: flex; flex-direction: column; font-size: 12px; color: #555; }
.dco b { font-size: 14px; color: #1c1c1c; }
.dtitle { text-align: center; letter-spacing: .12em; color: var(--olive-dk); margin: 22px 0; font-size: 18px; }
.dmeta { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 20px; font-size: 13px; }
.dmeta > div { display: flex; flex-direction: column; gap: 2px; }
.dmeta .rgt { text-align: right; }
.dmeta small { text-transform: uppercase; letter-spacing: .04em; font-size: 10px; }
table.dt { width: 100%; border-collapse: collapse; font-size: 13px; }
.dt th { background: var(--olive-dk); color: #fff; text-align: left; padding: 8px 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.dt th.r { text-align: right; }
.dt td { padding: 9px 10px; border-bottom: 1px solid #e6e4da; vertical-align: top; }
.dt.slim td { padding: 6px 10px; }
.dtot { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; margin: 14px 0 6px; font-size: 13px; }
.dtot b { display: inline-block; min-width: 150px; text-align: right; }
.dtot .grand { font-size: 15px; border-top: 2px solid var(--olive); padding-top: 6px; }
.dsec { margin-top: 22px; font-size: 13px; }
.dsec h4 { margin: 0 0 6px; color: var(--olive-dk); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.dsec ol { margin: 0; padding-left: 18px; }
.dsec li { margin-bottom: 3px; }
.dnote { margin-top: 22px; font-size: 12px; color: #666; }
.sign { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 90px; font-size: 12px; }
.sign div { border-top: 1px solid #999; padding-top: 6px; }

/* finance and CRM */
.gap { margin-bottom: 14px; }
.licbtns { display: flex; gap: 14px; flex-wrap: wrap; }
.link:disabled { opacity: .5; cursor: not-allowed; }
.licread { display: flex; flex-direction: column; gap: 5px; }
.bar.wide { width: 100%; margin: 0; }
.licwarn { background: var(--amber-w); color: var(--amber); border-radius: 8px; padding: 8px 10px; font-weight: 600; font-size: 12px; }
.licerr { background: var(--red-w); color: var(--red); border-radius: 8px; padding: 8px 10px; font-weight: 600; }
.licres { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.licrow { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; font-size: 13px; }
.licrow .lab { width: 120px; flex: none; color: var(--muted); font-size: 12px; }
.licrow .val { flex: 1; min-width: 140px; font-weight: 600; word-break: break-word; }
.two > .card { min-width: 0; overflow-x: auto; }
.two > .card.full { grid-column: 1 / -1; }
.t.pl td { padding: 9px 6px; }
.t.pl tr.sum td { font-weight: 700; border-top: 2px solid var(--olive); border-bottom: 2px solid var(--line); }
.t.pl tr.sub td { color: var(--muted); padding: 5px 6px 5px 22px; border-bottom: 0; font-size: 13px; }
.hint.top { margin: 12px 0 0; font-size: 12px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters .input.search { margin-bottom: 0; flex: 1 1 240px; }
.inline { display: flex; align-items: center; gap: 6px; margin: 0; }
.inline .input { margin-top: 0; }
.headbtns { display: flex; gap: 8px; flex-wrap: wrap; }
.thumb { width: 64px; height: 40px; object-fit: cover; border: 1px solid var(--line); border-radius: 6px; cursor: zoom-in; display: block; background: #fff; }
.preview { max-width: 100%; max-height: 180px; border: 1px solid var(--line); border-radius: 8px; align-self: flex-start; }
.fullimg { max-width: 100%; display: block; margin: 0 auto; border: 1px solid var(--line); border-radius: 8px; }
.pdf { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 8px; }
.duerow td { background: var(--amber-w); }
.chip.static { cursor: default; }
.modal.narrowm { max-width: 460px; }
.modal-bg.top { z-index: 40; }
.stat b.small { font-size: 16px; }
.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.col { background: #efede4; border-radius: 12px; padding: 10px; min-height: 120px; }
.colhead { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; padding: 2px 4px 10px; font-size: 12px; color: var(--muted); }
.colhead b { color: var(--ink); font-size: 13px; }
.lead { display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left; font: inherit; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--olive-2); border-radius: 10px; padding: 10px; margin-bottom: 8px; cursor: pointer; color: var(--ink); }
.lead:hover { border-color: var(--olive); }
.lead.late { border-left-color: var(--red); }
.lead.late small:first-of-type { color: var(--red); font-weight: 600; }
.lead .val { font-weight: 600; color: var(--olive-dk); }
.colempty { font-size: 12px; color: var(--muted); text-align: center; padding: 18px 0; }
.actadd { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.actadd .input:not(.auto) { flex: 1 1 220px; width: auto; }
.event { display: flex; gap: 10px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid #efede4; flex-wrap: wrap; }
.event .when { width: 92px; flex: none; color: var(--muted); font-size: 12px; }
.event > span:nth-of-type(3), .event > span:last-of-type { flex: 1; min-width: 160px; }
.event b { margin-left: auto; white-space: nowrap; }
.paper.short { min-height: 0; }
@media (max-width: 900px) { .board { grid-template-columns: 1fr; } }
.scrollx { overflow-x: auto; max-width: 100%; }
fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
.menu { display: none; }
.navshade { display: none; }
.tranche { flex-wrap: wrap; }
.tabs { flex-wrap: wrap; }
.top { flex-wrap: wrap; }
.who .input { max-width: 100%; }
.dt th, .dtot .grand, .dhead, .navitem.on, .badge, .bar i { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

@media (max-width: 900px) {
  .menu { display: inline-block; }
  .side { position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0, 0, 0, .25); }
  .side.open { transform: none; }
  .navshade { display: block; position: fixed; inset: 0; background: rgba(30, 31, 22, .45); z-index: 25; }
  .top { padding: 10px 14px; }
  .company { flex: 1; min-width: 0; font-size: 13px; }
  .who { width: 100%; }
  .who .input { flex: 1; min-width: 0; width: auto; }
  .content { padding: 18px 14px 60px; }
  .head { flex-direction: column; }
  .two { grid-template-columns: 1fr; }
  .two .card { overflow-x: auto; }
  .toast { bottom: auto; top: 10px; max-width: 92vw; text-align: center; }
  .grid3, .lrow2, .termpick, .prodform { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .lrow1 { flex-wrap: wrap; }
  .termrow { flex-wrap: wrap; }
  .termrow .input, .termrow .input.sm, .termrow .input.grow { width: 100%; flex: none; }
  .modal-bg { padding: 10px 8px; }
  .mbody { padding: 16px 14px; }
  .paper { padding: 22px 16px; min-height: 0; overflow-x: auto; }
  .dmeta { flex-direction: column; }
  .dmeta .rgt { text-align: left; }
  .acts { white-space: normal; }
  .acts .btn { margin: 2px 0 2px 4px; }
  .qrbox { order: -1; }
}
@media print {
  .side, .top, .noprint, .toast, .navshade, .modal-bg:not(.printable) { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; }
  .card { border: 0; }
  .card.flush, .scrollx { overflow: visible; }
  .head .btn, .input.search, .acts, .tabs { display: none !important; }
  .t th, .t td { padding: 6px 6px; font-size: 11px; white-space: normal; }
  body.has-doc .app { display: none !important; }
  .modal-bg.printable { position: static; background: none; padding: 0; display: block; }
  .docwrap { max-width: none; }
  .paper { padding: 0; min-height: 0; }
}

/* loading notice, print header, phone tap targets */
.boot { display: none; }
body[x-cloak] > *:not(.boot) { display: none !important; }
body[x-cloak] > .boot { display: flex !important; min-height: 100vh; align-items: center; justify-content: center; color: var(--muted); font-weight: 600; }
.printhead { display: none; }
.period { font-weight: 600; margin: -4px 0 14px; }
.t td:first-child b { white-space: nowrap; }
@media (max-width: 900px) {
  .btn.s { min-height: 38px; padding: 8px 12px; }
  .link, .x { padding: 9px 6px; display: inline-block; }
}
@media print {
  .printhead { display: flex; justify-content: space-between; gap: 12px; border-bottom: 2px solid var(--olive); padding-bottom: 8px; margin-bottom: 12px; font-size: 12px; }
  .filters, .headbtns, .content .btn, .content .link, .storagefull { display: none !important; }
}

@media (max-width: 900px) {
  .input { min-height: 40px; }
  .input.sm { min-height: 40px; }
  .navitem { padding: 11px 10px; }
  .tabs button { min-height: 40px; }
  .link, .x { min-height: 38px; }
}
@media print { .t td.r, .t td b { white-space: nowrap; } }

/* client and vendor record */
.namelink { font: inherit; font-weight: 700; color: var(--ink); background: none; border: 0; padding: 0; cursor: pointer; text-align: left; text-decoration: underline; text-decoration-color: var(--olive-2); text-underline-offset: 3px; }
.namelink:hover { color: var(--olive-dk); }
.details { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 18px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; }
.details div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.details small { text-transform: uppercase; letter-spacing: .04em; font-size: 10px; }
.details b { font-weight: 600; word-break: break-word; }
@media (max-width: 900px) { .details { grid-template-columns: 1fr 1fr; } .namelink { min-height: 38px; } }
