:root {
  --bg: #f4f4f2;
  --card: #ffffff;
  --ink: #141414;
  --muted: #6b6b68;
  --line: #e4e3df;
  --soft: #f1f0ec;
  --accent: #141414;
  --good: #17734a;
  --bad: #b3261e;
  --warn: #8a5a00;
  --radius: 10px;
  --side: 216px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: inherit; }
h1 { font-size: 22px; margin: 0; font-weight: 650; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 13px; margin: 0 0 12px; font-weight: 600; color: var(--muted); text-transform: none; }
small, .small { font-size: 12.5px; }
.muted { color: var(--muted); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.show-s { display: none; }

/* Sidebar */
.side { position: fixed; inset: 0 auto 0 0; width: var(--side); background: #111; color: #fff; display: flex; flex-direction: column; padding: 22px 12px 14px; }
.brand img { width: 118px; filter: invert(1); display: block; margin: 0 10px 26px; }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px; text-decoration: none; color: #b9b9b6; font-weight: 500; }
.side nav a:hover { color: #fff; background: #1f1f1f; }
.side nav a.on { color: #fff; background: #2a2a2a; }
.ico { width: 18px; height: 18px; flex: none; background: currentColor; -webkit-mask: var(--i) center/contain no-repeat; mask: var(--i) center/contain no-repeat; }
.ico-dashboard { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='7' height='9' rx='1'/%3E%3Crect x='14' y='3' width='7' height='5' rx='1'/%3E%3Crect x='14' y='12' width='7' height='9' rx='1'/%3E%3Crect x='3' y='16' width='7' height='5' rx='1'/%3E%3C/svg%3E"); }
.ico-quotes { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 3v5h5M9 13h6M9 17h4'/%3E%3C/svg%3E"); }
.ico-invoices { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 3h14v18l-3-2-2 2-2-2-2 2-2-2-3 2z'/%3E%3Cpath d='M9 8h6M9 12h6'/%3E%3C/svg%3E"); }
.ico-projects { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z'/%3E%3Cpath d='M8 14l2.500 2.500L16 11'/%3E%3C/svg%3E"); }
.ico-products { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 8l-9-5-9 5v8l9 5 9-5z'/%3E%3Cpath d='M3 8l9 5 9-5M12 13v8'/%3E%3C/svg%3E"); }
.ico-partners { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='8' r='3.5'/%3E%3Cpath d='M2.500 20a6.500 6.500 0 0 1 13 0M16 4.800a3.500 3.500 0 0 1 0 6.400M18 14.500a6.500 6.500 0 0 1 3.500 5.500'/%3E%3C/svg%3E"); }
.ico-settings { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6h10M18 6h2M4 12h4M12 12h8M4 18h12M20 18h0'/%3E%3Ccircle cx='16' cy='6' r='2'/%3E%3Ccircle cx='10' cy='12' r='2'/%3E%3Ccircle cx='18' cy='18' r='2'/%3E%3C/svg%3E"); }
.who { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px; color: #8f8f8c; font-size: 13px; border-top: 1px solid #262626; }
.who .link { color: #b9b9b6; }

main { margin-left: var(--side); padding: 26px 30px 60px; max-width: 1240px; }
main.bare { margin: 0 auto; padding: 8vh 16px; }
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.back { font-size: 13px; color: var(--muted); text-decoration: none; display: inline-block; margin-bottom: 4px; }
.back:hover { color: var(--ink); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }
.count { font-size: 13px; font-weight: 500; color: var(--muted); background: var(--soft); padding: 2px 8px; border-radius: 20px; }

/* Buttons and fields */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); font: inherit; font-weight: 550; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c9c8c3; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #333; }
.btn.wide { width: 100%; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--ink); }
.link.danger:hover { color: var(--bad); }
:focus-visible { outline: 2px solid #3b6fd4; outline-offset: 2px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 500; }
input, select, textarea { font: inherit; font-size: 15px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 38px; width: 100%; }
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid #3b6fd4; outline-offset: 0; border-color: transparent; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); align-self: end; min-height: 38px; }
label.check input { width: 18px; min-height: 18px; height: 18px; }
.out { min-height: 38px; display: flex; align-items: center; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.span2 { grid-column: span 2; }
.span4 { grid-column: 1 / -1; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card.narrow { max-width: 400px; margin: 0 auto; }
.card.quiet { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; background: transparent; border-style: dashed; }
.pad { padding: 18px; margin: 0; }
.flash, .error { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 500; }
.flash { background: #e6f2ec; color: var(--good); }
.error { background: #fbe9e7; color: var(--bad); }
.login h1 { margin: 20px 0 8px; }
.login form { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.login-logo { width: 150px; display: block; }

/* Dashboard */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 2px; text-decoration: none; }
a.stat:hover { border-color: #c9c8c3; }
.stat .k { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat .v { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.stat .s { font-size: 12.5px; color: var(--muted); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.cols.wide-left { grid-template-columns: minmax(0, 1fr) 320px; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li + li { border-top: 1px solid var(--line); }
.rows a, .payrow { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; text-decoration: none; }
.rows .main { display: flex; flex-direction: column; min-width: 0; }
.rows .main b { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows small { color: var(--muted); }
.amt { font-weight: 600; font-variant-numeric: tabular-nums; }

/* Lists */
.filters { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filters input[type=search] { flex: 1 1 240px; }
.filters select { width: auto; flex: 0 1 180px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg a { padding: 8px 14px; text-decoration: none; color: var(--muted); font-weight: 550; }
.seg a.on { background: var(--ink); color: #fff; }
table.list { width: 100%; border-collapse: collapse; }
.list th { text-align: left; font-size: 12.5px; font-weight: 550; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafaf8; white-space: nowrap; }
.list th.num { text-align: right; }
.list td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.list tr:last-child td { border-bottom: 0; }
.list tr[data-href] { cursor: pointer; }
.list tr[data-href]:hover td { background: #fafaf8; }
.list td a { text-decoration: none; font-weight: 550; }
.list tr.off td { opacity: 0.5; }
.list .sub { display: block; color: var(--muted); font-weight: 400; }
.list tr.section td { background: var(--soft); font-weight: 650; font-size: 12.5px; letter-spacing: 0.04em; }
.list.lines { margin: 16px -18px 0; width: calc(100% + 36px); border-top: 1px solid var(--line); }
.list.lines th, .list.lines td { padding-left: 18px; padding-right: 18px; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 20px; background: var(--soft); color: var(--muted); text-transform: capitalize; white-space: nowrap; letter-spacing: 0; }
.pill.paid, .pill.confirmed { background: #e3f1ea; color: var(--good); }
.pill.unpaid { background: #fbe9e7; color: var(--bad); }
.pill.partial, .pill.sent { background: #fbf0d9; color: var(--warn); }

/* Document view */
.meta { display: flex; gap: 12px 34px; flex-wrap: wrap; }
.meta > div { display: flex; flex-direction: column; font-weight: 550; }
.k { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.notes { margin-top: 18px; }
.notes pre { margin: 6px 0 0; font: inherit; white-space: pre-wrap; color: #3a3a38; }
.totals .row, .ed-totals .row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-variant-numeric: tabular-nums; }
.row.big { font-size: 18px; padding-bottom: 8px; }
.internal { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.payform { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; padding-top: 14px; border-top: 1px solid var(--line); }
.payform label:nth-child(3), .payform .btn { grid-column: 1 / -1; }

/* Line editor */
.ed-head, .ed-row { display: grid; grid-template-columns: minmax(0, 1fr) 88px 96px 96px 104px 128px 84px; gap: 8px; align-items: start; padding: 8px 14px; }
.ed-head { font-size: 12.5px; font-weight: 550; color: var(--muted); background: #fafaf8; border-bottom: 1px solid var(--line); padding-top: 10px; padding-bottom: 10px; }
.ed-row { border-bottom: 1px solid var(--line); }
.ed-row.section { grid-template-columns: minmax(0, 1fr) 84px; background: var(--soft); }
.ed-row.section .desc { font-weight: 650; background: transparent; }
.cell { margin: 0; position: relative; }
.cell .lbl { display: none; }
.cell input { text-align: right; font-variant-numeric: tabular-nums; padding-left: 6px; padding-right: 8px; }
.cell.unit_cost input { color: var(--muted); }
.cell.qty .auto { position: absolute; left: 5px; bottom: 11px; border: 0; background: none; font: inherit; font-size: 10.5px; line-height: 16px; color: var(--muted); cursor: pointer; padding: 0; text-decoration: line-through; }
.cell.qty .auto.on { color: var(--good); font-weight: 600; text-decoration: none; }
.suggest { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 9px 14px; border-bottom: 1px dashed var(--line); background: #fbfbf9; font-size: 13px; }
.suggest .slabel { color: var(--muted); }
.chip { display: inline-flex; border: 1px dashed #c9c8c3; border-radius: 20px; overflow: hidden; background: #fff; }
.chip button { border: 0; background: none; font: inherit; font-size: 13px; color: var(--muted); cursor: pointer; padding: 4px 10px; }
.chip .take:hover { color: var(--ink); background: var(--soft); }
.chip .skip { padding: 4px 9px 4px 4px; }
.chip .skip:hover { color: var(--bad); }
.picker .create { color: var(--muted); border-top: 1px solid var(--line); }
.disc { align-items: center; }
.discin { display: inline-flex; gap: 4px; margin-left: auto; }
.discin input { width: 84px; min-height: 32px; padding: 4px 8px; text-align: right; }
.discin select { width: 68px; min-height: 32px; padding: 4px 6px; }
#t-disc { min-width: 84px; color: var(--muted); }
.disc > span:first-child { margin-right: auto; }
.discin { margin-left: 0; }
dialog { border: 0; border-radius: 12px; padding: 20px; width: min(520px, calc(100vw - 24px)); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); color: var(--ink); }
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.dlg-title { font-size: 18px; color: var(--ink); margin-bottom: 14px; }
.grid4.two { grid-template-columns: 1fr 1fr; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.rulef { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.cell.ro { min-height: 38px; display: flex; align-items: center; justify-content: flex-end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell.ro .margin { color: var(--muted); font-size: 13px; }
.cell.ro .margin.bad { color: var(--bad); }
textarea.desc { resize: none; overflow: hidden; display: block; }
.tools { display: flex; gap: 2px; justify-content: flex-end; }
.tools button { width: 26px; height: 38px; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 6px; font-size: 14px; }
.tools button:hover { background: var(--soft); color: var(--ink); }
.tools .rm:hover { color: var(--bad); }
.picker { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid #c9c8c3; border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); overflow: hidden; min-width: 280px; }
.picker button { display: flex; flex-direction: column; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; font: inherit; cursor: pointer; color: var(--ink); }
.picker button.on, .picker button:hover { background: var(--soft); }
.picker .pp { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ed-actions { display: flex; gap: 8px; padding: 12px 14px; }
.ed-totals { margin-left: auto; width: 400px; max-width: 100%; padding: 6px 14px 14px; }
.savebar { display: none; }

/* Phone and tablet */
@media (max-width: 880px) {
  .side { inset: auto 0 0 0; width: auto; flex-direction: row; padding: 0; padding-bottom: env(safe-area-inset-bottom); z-index: 50; border-top: 1px solid #262626; }
  .brand, .who { display: none; }
  .side nav { flex-direction: row; justify-content: space-around; gap: 0; }
  .side nav a { flex-direction: column; gap: 3px; font-size: 10.5px; padding: 8px 4px 7px; flex: 1; border-radius: 0; background: none !important; }
  .ico { width: 21px; height: 21px; }
  main { margin: 0; padding: 16px 14px 96px; }
  h1 { font-size: 20px; }
  .stats, .cols, .cols.wide-left { grid-template-columns: 1fr 1fr; }
  .cols, .cols.wide-left { grid-template-columns: 1fr; }
  .grid4 { grid-template-columns: 1fr 1fr; }
  .stat .v { font-size: 19px; }
  .hide-s { display: none; }
  .show-s { display: inline; }
  .list th, .list td { padding: 10px 12px; }
  .ed-head { display: none; }
  .ed-row { grid-template-columns: 1fr 1fr 1fr; gap: 8px 10px; padding: 12px; }
  .ed-row .descwrap { grid-column: 1 / -1; }
  .ed-row.section { grid-template-columns: 1fr auto; }
  .cell .lbl { display: block; font-size: 11.5px; margin-bottom: 3px; }
  .cell.ro { flex-direction: column; align-items: flex-start; justify-content: flex-start; min-height: 0; }
  .ed-row .tools { grid-column: 3; }
  .ed-row.section .tools { grid-column: auto; }
  .ed-totals { width: 100%; }
  .savebar { display: block; margin-bottom: 8px; }
  .filters select { flex: 1 1 130px; }
}
@media (max-width: 420px) {
  .grid4 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
}

/* Accept or cancel, optional products, capacity, projects */
.warn { color: var(--warn); }
.decide { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 18px; margin-bottom: 16px; }
.decide > span { font-weight: 550; margin-right: auto; }
.decide form { margin: 0; }
.opt-toggle { margin-left: auto; align-self: center; min-height: 0; }
.ed-actions select { width: auto; min-width: 120px; }
.opt-head { display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--line); background: #fafaf8; }
.opt-head .push { margin: 0 0 0 auto; }
.opt-sum { margin-left: auto; align-self: center; }
.opt-sum b { color: var(--ink); font-variant-numeric: tabular-nums; }
.opt-title { margin: 22px 0 0; font-size: 14px; color: var(--ink); }
.tools .inc { color: var(--good); font-weight: 700; }
#opt-lines .ed-row { grid-template-columns: minmax(0, 1fr) 88px 96px 96px 104px 128px 110px; }
.capacity .k { display: block; margin-bottom: 8px; }
.capacity .row { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-variant-numeric: tabular-nums; }
.capacity p { margin: 6px 0 0; }
.caps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.cap { background: var(--soft); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; }
.cap .k { margin: 0; }
.cap b { font-size: 18px; font-variant-numeric: tabular-nums; }
.cap small { color: var(--muted); }
.cap.bad { background: #fbe9e7; }
.cap.bad b { color: var(--bad); }
.capnotes:empty { display: none; }
.capnotes .bad { font-weight: 600; }
.kitform { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.kitform input { width: 170px; min-height: 32px; padding: 4px 8px; }
h2.sec { font-size: 16px; color: var(--ink); margin: 26px 0 12px; }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 13px; }
.list td form { margin: 0; }
.list td select { min-height: 32px; padding: 4px 8px; width: auto; max-width: 190px; }
select.st.pending { color: var(--bad); }
select.st.ordered { color: var(--warn); }
select.st.received { color: var(--good); }
.endbtn { display: flex; align-items: flex-end; }
.cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 880px) {
  .caps { grid-template-columns: 1fr 1fr; }
  .side nav a { font-size: 10px; padding-left: 2px; padding-right: 2px; }
  #opt-lines .ed-row { grid-template-columns: 1fr 1fr 1fr; }
  .opt-toggle { margin-left: 0; width: 100%; }
  .cols, .cols.wide-left { grid-template-columns: minmax(0, 1fr); }
}
.purchase td:nth-child(2) { width: 230px; }
.purchase td:nth-child(3) { width: 150px; }
.purchase td:nth-child(4) { width: 48px; }

/* Product images and descriptions */
.dcell { display: flex; gap: 10px; align-items: flex-start; }
.dcell .pre { white-space: pre-line; }
.thumb { width: 36px; height: 36px; object-fit: contain; border-radius: 6px; background: #fff; border: 1px solid var(--line); flex: none; }
.pthumb { position: absolute; right: 8px; top: 6px; width: 32px; height: 32px; object-fit: contain; }
.picker button { position: relative; }
.imgrow { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.imgbox { width: 160px; height: 160px; border: 1px dashed #c9c8c3; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: #fff; overflow: hidden; }
.imgbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.imgside { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; max-width: 320px; }
.imgside p { margin: 0; }
.bulkrow { padding: 6px 0; font-size: 13px; }

/* Arabic text, maps, per-quote descriptions */
td, th, h1, .main b, .main small, .meta > div, .pre, .notes pre, .pn { unicode-bidi: plaintext; }
.maplinks { display: inline-flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.mapbox { margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.mapbox iframe { display: block; width: 100%; height: 300px; border: 0; }
textarea.details { resize: none; overflow: hidden; display: block; margin-top: 4px; font-size: 13.5px; color: #4a4a47; min-height: 32px; padding: 5px 10px; background: #fcfcfb; border-style: dashed; }
textarea.details:not(:placeholder-shown) { border-style: solid; background: #fff; }

/* ---------- Sales orders, payments, projects, dashboard ---------- */
.ico-payments { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2.500' y='5' width='19' height='14' rx='2'/%3E%3Cpath d='M2.500 10h19M6.500 15h4'/%3E%3C/svg%3E"); }
.seg a small { color: inherit; opacity: 0.7; margin-left: 2px; }
.seg { flex-wrap: wrap; }
.pill.confirmed { background: #e3ecfa; color: #1d4f91; }
.pill.ms-paid { background: #e3f1ea; color: var(--good); }
.pill.ms-partial { background: #fbf0d9; color: var(--warn); }
.pill.ms-due { background: #fbe9e7; color: var(--bad); }
.pill.ms-upcoming { background: var(--soft); color: var(--muted); }
.pill.st-planning { background: var(--soft); color: #4a4a47; }
.pill.st-materials { background: #fbf0d9; color: var(--warn); }
.pill.st-installation { background: #e3ecfa; color: #1d4f91; }
.pill.st-handed_over { background: #e3f1ea; color: var(--good); }
.pill.st-completed { background: #ecebe7; color: var(--muted); }
.order-bar { background: #f5f8fd; border-color: #d6e2f3; }
.sub-h1 { margin: 4px 0 0; }
.sub-h { font-size: 12.5px; color: var(--muted); margin: 14px 0 4px; font-weight: 550; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.row-actions { display: inline-flex; gap: 12px; align-items: center; }
.row-actions form { margin: 0; }
.bar, .progress, .minibar { display: block; height: 6px; background: var(--soft); border-radius: 4px; overflow: hidden; }
.bar > span, .progress > span, .minibar > span { display: block; height: 100%; background: #2a78d6; border-radius: 4px; }
.bar { margin-top: 8px; }
.stat .bar { margin-top: 6px; }
.progress { display: inline-block; vertical-align: middle; width: 90px; }
.progress.big { display: block; width: 100%; height: 8px; margin-bottom: 14px; }
.progress.thin { display: block; width: 100%; height: 4px; margin-top: 8px; }
.progress.thin > span { background: #9a9893; }
.progress.thin.ending > span { background: var(--bad); }
.minibar { display: inline-block; vertical-align: middle; width: 48px; }
.minibar.wide { width: 80px; }
.minibar > span { background: var(--good); }

/* Dropdown menus */
details.menu { position: relative; display: inline-block; }
details.menu > summary { list-style: none; cursor: pointer; }
details.menu > summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; min-width: 240px; background: #fff; border: 1px solid #c9c8c3; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); padding: 6px; }
details.menu.right .menu-pop { left: auto; right: 0; }
.menu-pop.wide { min-width: 300px; padding: 12px; text-align: left; }
.menu-pop form { margin: 0; }
.menu-item { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; width: 100%; border: 0; background: none; font: inherit; padding: 8px 10px; border-radius: 6px; cursor: pointer; text-align: left; color: var(--ink); }
.menu-item:hover { background: var(--soft); }
.menu-item small { color: var(--muted); font-variant-numeric: tabular-nums; }
.payform .span2 { grid-column: 1 / -1; }

/* Combo box (customer) */
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 13px; color: var(--muted); font-weight: 500; }
.combo { position: relative; }
.picker .create { color: var(--muted); border-top: 1px solid var(--line); }

/* Quote lines: name and description in one box */
.ed-head small { font-weight: 400; }
textarea.desc { line-height: 1.45; }
.ldesc { display: block; white-space: pre-line; color: var(--muted); font-size: 13px; margin-top: 2px; }

/* Payment schedule editor */
.sched-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.sched-head h2 { margin: 0; }
.sched-row { display: grid; grid-template-columns: 92px minmax(0, 1fr) 170px 130px 32px; gap: 8px; align-items: center; margin-bottom: 8px; }
.sched-row .pct { display: flex; align-items: center; gap: 4px; }
.sched-row .pct input { text-align: right; }
.sched-row .unit { color: var(--muted); }
.sched-row .amt { text-align: right; font-variant-numeric: tabular-nums; color: #4a4a47; }
.sched-row .rm { border: 0; background: none; color: var(--muted); cursor: pointer; height: 36px; border-radius: 6px; }
.sched-row .rm:hover { color: var(--bad); background: var(--soft); }
.np-margin b { color: var(--ink); }
.np-more { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.np-more summary { cursor: pointer; font-size: 13px; color: var(--muted); font-weight: 550; }
.np-more .grid4 { margin-top: 10px; }
dialog { max-height: calc(100vh - 40px); overflow: auto; }

/* Project page */
.stepper { list-style: none; display: flex; gap: 4px; padding: 0; margin: 0 0 16px; counter-reset: step; }
.stepper li { flex: 1; position: relative; padding: 9px 10px 9px 30px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; font-size: 13px; color: var(--muted); font-weight: 550; counter-increment: step; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stepper li::before { content: counter(step); position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; border-radius: 50%; background: var(--soft); color: var(--muted); font-size: 10.5px; display: grid; place-items: center; }
.stepper li.done { color: var(--good); }
.stepper li.done::before { content: '✓'; background: #e3f1ea; color: var(--good); }
.stepper li.now { border-color: #2a78d6; color: var(--ink); box-shadow: inset 0 0 0 1px #2a78d6; }
.stepper li.now::before { background: #2a78d6; color: #fff; }
.tasks { list-style: none; margin: 0 0 12px; padding: 0; }
.tasks li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.tasks li form { margin: 0; }
.tasks .tt { flex: 1; }
.tasks li.done .tt { color: var(--muted); text-decoration: line-through; text-decoration-color: #c9c8c3; }
.tick { width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid #c9c8c3; background: #fff; cursor: pointer; display: grid; place-items: center; color: #fff; font-size: 13px; padding: 0; }
.tick:hover { border-color: var(--good); }
.tasks li.done .tick { background: var(--good); border-color: var(--good); }
.rmx { text-decoration: none; color: #b4b2a9; }
.rmx:hover { color: var(--bad); }
.inline-add { display: flex; gap: 8px; }
.inline-add input { flex: 1; }
.covers { list-style: none; margin: 0 0 12px; padding: 0; }
.covers > li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.cov-main { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.cov-name { display: flex; flex-direction: column; min-width: 0; }
.cov-dates { font-variant-numeric: tabular-nums; font-size: 13.5px; }
.cov-left { text-align: right; white-space: nowrap; }
.cov-left b { font-size: 18px; font-variant-numeric: tabular-nums; }
.cov-edit { margin-top: 6px; }
.cov-edit summary, .add-cov summary { cursor: pointer; list-style: none; display: inline-block; }
.cov-edit summary::-webkit-details-marker, .add-cov summary::-webkit-details-marker { display: none; }
.cov-edit form, .add-cov form { margin-top: 10px; padding: 12px; background: #fafaf8; border: 1px solid var(--line); border-radius: 8px; }
.gap { gap: 12px; align-items: center; }
.upload { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-top: 12px; }
.upload label:first-child { min-width: 200px; }
.pad { padding: 14px; }
form.pad { margin: 0; border-top: 1px solid var(--line); }
.opt-head .push { margin-left: auto; }
.cust { margin: 0 0 10px; line-height: 1.6; }
.update-form { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; margin-bottom: 10px; }
.log { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow: auto; }
.log li { padding: 8px 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; }

/* Dashboard charts */
.legend { display: inline-flex; gap: 14px; font-size: 12.5px; color: #4a4a47; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.s1, .vb.s1 { background: #2a78d6; }
.sw.s2, .vb.s2 { background: #eb6834; }
.vchart { position: relative; height: 210px; padding: 0 0 22px 40px; }
.vgrid { position: absolute; inset: 0 0 22px 40px; }
.gl { position: absolute; left: 0; right: 0; border-top: 1px solid #ecebe7; }
.gl span { position: absolute; right: calc(100% + 8px); top: -8px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.vcols { position: relative; height: 100%; display: flex; }
.vcol { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; position: relative; }
.vbars { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.vb { width: min(22px, 32%); border-radius: 4px 4px 0 0; min-height: 0; }
.vb:hover { filter: brightness(0.9); }
.vx { position: absolute; bottom: -20px; font-size: 11.5px; color: var(--muted); }
.numbers { margin-top: 10px; }
.numbers summary { cursor: pointer; list-style: none; }
.list.compact th, .list.compact td { padding: 6px 8px; }
.hbars { list-style: none; margin: 0 0 10px; padding: 0; }
.hbars a { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 10px; align-items: center; padding: 6px 0; text-decoration: none; }
.hl { font-size: 13px; color: #4a4a47; }
.ht { display: flex; align-items: center; gap: 8px; }
.hb { height: 16px; min-width: 2px; background: #2a78d6; border-radius: 0 4px 4px 0; }
.ht b { font-variant-numeric: tabular-nums; font-size: 13px; }
.ending { list-style: none; margin: 0; padding: 0; }
.ending li + li { border-top: 1px solid var(--line); }
.ending a { display: grid; grid-template-columns: minmax(0, 1fr) 140px; gap: 12px; align-items: center; padding: 9px 0; text-decoration: none; }
.ending .main { display: flex; flex-direction: column; min-width: 0; }
.ending .main b { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ending .main small { color: var(--muted); }
.eb { display: flex; flex-direction: column; gap: 4px; }
.eb-track { height: 6px; background: var(--soft); border-radius: 4px; overflow: hidden; }
.eb-fill { display: block; height: 100%; border-radius: 4px; }
.eb-fill.ended, .eb-fill.soon { background: #e34948; }
.eb-fill.mid { background: #eda100; }
.eb-fill.far { background: #9a9893; }

@media (max-width: 880px) {
  .stepper { overflow-x: auto; }
  .stepper li { flex: 0 0 auto; }
  .sched-row { grid-template-columns: 84px minmax(0, 1fr) 32px; }
  .sched-row select { grid-column: 1 / 3; }
  .sched-row .amt { grid-column: 3 / 4; }
  .cov-main { grid-template-columns: minmax(0, 1fr) auto; }
  .cov-dates { grid-column: 1 / -1; order: 3; }
  .ending a { grid-template-columns: minmax(0, 1fr) 110px; }
  .side nav { overflow-x: auto; justify-content: flex-start; }
  .side nav a { flex: 0 0 auto; min-width: 58px; }
}
.pill[class*="st-"], .pill[class*="ms-"], .pill[class*="tk-"], .pill[class*="ph-"], .pill.confirmed { text-transform: none; }
.hb.zero { display: none; }
.settle { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }

/* ---------- Service, devices, photos, reports ---------- */
.ico-tickets { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14.7 6.3a4 4 0 0 0-5.400 5.400L3 18l3 3 6.300-6.300a4 4 0 0 0 5.400-5.400l-2.600 2.600-2.400-.6-.6-2.400z'/%3E%3C/svg%3E"); }
.ico-reports { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 20h16M7 16v-5M12 16V6M17 16v-8'/%3E%3C/svg%3E"); }
.tickets { list-style: none; margin: 0; padding: 0; }
.tickets > li { border-top: 1px solid var(--line); }
.tickets > li:first-child { border-top: 0; }
.tickets summary { display: flex; align-items: center; gap: 12px; padding: 10px 0; cursor: pointer; list-style: none; }
.tickets summary::-webkit-details-marker { display: none; }
.tickets summary .main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tickets li.closed summary b { color: var(--muted); font-weight: 500; }
.tk-pills { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tk-body { padding: 0 0 14px; }
.tk-bill { margin-top: 8px; }
.tk-actions { display: flex; align-items: center; gap: 14px; }
.pill.tk-open { background: #fdf0d5; color: #8a5a00; }
.pill.tk-scheduled { background: #e3eefc; color: #1e4f9a; }
.pill.tk-closed { background: #ececec; color: #555; }
.renew { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0 4px; }
.dev-wrap { overflow-x: auto; margin: 0 -4px; }
table.devices { min-width: 860px; }
table.devices td { padding: 3px 3px; }
table.devices input { width: 100%; min-width: 80px; padding: 6px 7px; font-size: 13px; }
.dev-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0 6px; }
.dev-actions .push { margin-left: auto; display: flex; gap: 8px; }
.photos { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.photos img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; display: block; background: #f1f1ef; }
.ph-cap { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.ph-cap form { margin-left: auto; }
.pill.ph-before { background: #ececec; color: #444; }
.pill.ph-during { background: #e3eefc; color: #1e4f9a; }
.pill.ph-after { background: #dcf3e4; color: #1f6b3a; }
.share .menu-pop { min-width: 280px; }
.share-link { display: block; margin: 8px 0 4px; font-size: 12px; }
.share-link input { width: 100%; font-size: 12px; }
a.btn.wa { margin: 10px 0 0; text-align: center; display: block; }
table.report tr.quiet td { color: var(--muted); }
table.report tfoot th { border-top: 2px solid var(--ink, #111); }
.rbar { display: block; width: 100%; max-width: 160px; margin-top: 4px; }
.rbar span { display: block; height: 4px; border-radius: 2px; margin-top: 2px; min-width: 0; }
.rbar .s1 { background: #2a78d6; }
.rbar .s2 { background: #eb6834; }
.legend-note .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; margin: 0 4px 0 10px; }
.legend-note .sw.s1 { background: #2a78d6; }
.legend-note .sw.s2 { background: #eb6834; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
form.inline { display: inline; }
@media (max-width: 880px) {
  .tickets summary { flex-wrap: wrap; }
  .dev-actions .push { margin-left: 0; }
}

/* ---------- Credit, statements, scope changes ---------- */
.pill.credit { background: #fdf0d5; color: #8a5a00; text-transform: none; }
.credit-box { border: 1px solid #f0d9a8; background: #fffaf0; border-radius: 10px; padding: 12px 14px; margin: 12px 0; }
.credit-box p { margin: 0 0 8px; }
.credit-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-top: 8px; }
.credit-form label { font-size: 12px; flex: 1 1 120px; }
.credit-form button { flex: 0 0 auto; }
.amend { border-color: #f0d9a8; background: #fffaf0; }
.amend h2 { color: #8a5a00; }
.amend label { display: block; font-size: 12px; margin-top: 8px; }
.amend input { width: 100%; }
.st-order { padding: 10px 16px; border-top: 1px solid var(--line); }
.st-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.st-head .push { margin-left: auto; }
.rows.compact li { padding: 4px 0; }
table.statement tr.tx-payment td:nth-child(4), table.statement tr.tx-credit-in td:nth-child(4) { color: #1f6b3a; }
table.statement tr.tx-refund td:nth-child(4), table.statement tr.tx-creditnote td:nth-child(3) { color: #8a5a00; }
table.statement tfoot th { border-top: 2px solid #111; }
.bar.cost span { background: #eb6834; }
.tile-note { margin: -6px 0 14px; }
.paid-list { margin-top: 6px; border-top: 1px solid var(--line); }
.btn.wide { display: block; text-align: center; margin-top: 10px; }
@media print {
  .side, .actions, .back, .flash { display: none !important; }
  main { margin: 0 !important; padding: 0 !important; }
  .card { break-inside: avoid; box-shadow: none; }
  body { background: #fff; }
}
.dmy { position: relative; display: flex; align-items: center; }
.dmy input[type="text"] { flex: 1; min-width: 0; padding-right: 34px; width: 100%; }
.dmy-cal { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: none; cursor: pointer; font-size: 15px; padding: 4px; line-height: 1; }
.dmy-native { position: absolute; right: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0; }

/* ---------- Home cards ---------- */
.dash { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; align-items: start; }
.dash > .w { grid-column: span var(--span, 12); position: relative; min-width: 0; }
.dash > .w > .card, .dash > .w > section { margin: 0; }
.dash > .w > .stats { margin: 0; }
.w-tools { display: none; }
.dash.editing > .w { outline: 2px dashed #c9d6ea; outline-offset: 4px; border-radius: 12px; }
.dash.editing .w-tools { display: flex; align-items: center; gap: 6px; padding: 6px 8px; margin-bottom: 6px; background: #eef3fb; border-radius: 8px; font-size: 13px; }
.w-tools b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-tools button:not(.link) { border: 1px solid var(--line); background: #fff; border-radius: 6px; width: 28px; height: 28px; cursor: pointer; }
.w-tools select { font-size: 12px; padding: 3px 4px; }
.w-grip { cursor: grab; font-size: 18px; line-height: 1; padding: 0 4px; user-select: none; }
.w.dragging { opacity: .45; }
.w.drop-before { box-shadow: -4px 0 0 #2a78d6, 0 -4px 0 #2a78d6; }
.w.drop-after { box-shadow: 4px 0 0 #2a78d6, 0 4px 0 #2a78d6; }
.w-resize { display: none; }
.dash.editing .w-resize { display: block; position: absolute; top: 40px; right: -10px; bottom: 0; width: 14px; cursor: ew-resize; }
.dash.editing .w-resize::after { content: ''; position: absolute; top: 50%; left: 5px; width: 4px; height: 40px; margin-top: -20px; border-radius: 2px; background: #2a78d6; opacity: .6; }
.dash-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 14px; margin-bottom: 14px; background: #eef3fb; border: 1px solid #c9d6ea; border-radius: 10px; font-size: 13px; }
.dash-bar > span:first-child { flex: 1 1 260px; }
.dash-tray { display: flex; flex-wrap: wrap; gap: 6px; }
.tbl-scroll { overflow-x: auto; }
.covtable td { vertical-align: top; }
.decide.expired { background: #f4f4f2; }
@media (max-width: 880px) {
  .dash > .w { grid-column: span 12; }
  .dash.editing .w-resize, .w-tools select { display: none; }
}
.eb-fill.ok { background: #3a9b5c; }
.cov-cell { display: flex; flex-direction: column; gap: 3px; max-width: 170px; }
.cov-cell .eb-track { height: 5px; }
a.hlink { color: inherit; text-decoration: none; }
a.hlink:hover { text-decoration: underline; }
a.hlink::after { content: ' ›'; color: var(--muted, #888); }
