/* office.css — quotation office layer: shell, list, preview, editor, A4 page, print. */

/* ---------- sign-in ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login { width: min(420px, 100%); padding: 30px 28px; }
.login .logo { display: block; height: 40px; margin: 0 auto 8px; }
.login h1 { text-align: center; font-size: 20px; margin: 18px 0 4px; }
.login p.sub { text-align: center; margin: 0 0 22px; }
.user-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.user-pick button {
  height: 44px; border-radius: var(--radius-sm); border: 1px solid var(--field-line); background: var(--field);
  color: var(--text); font: 500 14px var(--font-body); cursor: pointer;
}
.user-pick button.on { border-color: var(--accent); background: var(--accent-soft); }
.login .err { color: var(--danger); font-size: 13px; min-height: 18px; }
.login-foot { display: flex; justify-content: center; gap: 8px; margin-top: 18px; }

/* ---------- shell: sidebar always on the left ---------- */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 6px;
  padding: 20px 14px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  backdrop-filter: var(--glass); -webkit-backdrop-filter: var(--glass);
}
.sidebar .logo { height: 26px; margin: 2px 8px 22px; align-self: flex-start; }
.nav-item {
  display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px;
  border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500; cursor: pointer;
  border: 1px solid transparent; background: none; font-family: var(--font-body); font-size: 14px; text-align: start;
}
.nav-item:hover { background: var(--btn); color: var(--text); text-decoration: none; }
.nav-item.on { background: var(--accent-soft); color: var(--text); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.nav-item.on svg { color: var(--accent); }
.nav-item svg { width: 18px; height: 18px; flex: none; }
.sidebar .bottom { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.who { padding: 4px 10px; }
.who b { display: block; font-size: 14px; }
.who span { font-size: 12px; color: var(--text-2); }
.sidebar .tools { display: flex; gap: 6px; padding: 0 6px; }

.main { padding: 28px 32px 40px; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin-inline-end: auto; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar .logo { margin: 0 8px 0 0; height: 22px; }
  .sidebar .bottom { margin: 0; margin-left: auto; flex-direction: row; align-items: center; border: 0; padding: 0; }
  .who { display: none; }
  .main { padding: 18px 16px 32px; }
}

/* ---------- list ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters .input { width: auto; }
.filters .search { flex: 1 1 240px; min-width: 200px; }
.summary-line { font-size: 13px; color: var(--text-2); margin: 0 4px 10px; }
.summary-line b { color: var(--text); }
.table-wrap { overflow-x: auto; }
.table-wrap > .table { min-width: 780px; }
.table td.client { font-weight: 500; max-width: 320px; }
.table td { overflow-wrap: break-word; }
.table td .sub { display: block; font-size: 12px; color: var(--text-2); font-weight: 400; }

/* ---------- status colours ---------- */
.st-draft { --c: var(--st-draft); }
.st-pending { --c: var(--st-pending); }
.st-sent { --c: var(--st-sent); }
.st-accepted { --c: var(--st-accepted); }
.st-rejected { --c: var(--st-rejected); }
.st-paid { --c: var(--st-paid); }
.st-cancelled { --c: var(--st-cancelled); }

/* ---------- preview ---------- */
.preview { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.page-frame { overflow: hidden; border-radius: 6px; direction: ltr; }
.page-frame .scaler { transform-origin: top left; width: max-content; }
.page-frame .scaler .a4 + .a4 { margin-top: 8mm; outline: 1px solid var(--line); }
.side { position: sticky; top: 20px; display: flex; flex-direction: column; gap: 14px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; text-align: end; }
.kv .total { font-weight: 700; font-size: 16px; }
.activity { list-style: none; margin: 0; padding: 0; font-size: 13px; display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow: auto; }
.activity li { display: flex; flex-direction: column; }
.activity time { color: var(--text-3); font-size: 12px; }
.note-box { white-space: pre-wrap; font-size: 14px; }
@media (max-width: 1100px) { .preview { grid-template-columns: minmax(0, 1fr); } .side { position: static; } }

/* ---------- editor ---------- */
.editor { display: flex; flex-direction: column; gap: 16px; padding-bottom: 90px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid .wide { grid-column: span 2; }
@media (max-width: 560px) { .grid .wide { grid-column: auto; } }
.section-title { font: 600 13px var(--font-body); color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 12px; }

/* items: one card per section, one row per item (v1.8) */
.line {
  display: grid; align-items: start; gap: 6px; padding: 7px 10px;
  grid-template-columns: 22px minmax(0, 1fr) 106px 52px 98px 92px 104px 100px;
}
#secList.both .line, .line-cols.both { grid-template-columns: 22px minmax(0, 1fr) 106px 52px 98px 92px 104px 92px 100px; }
/* our cost and profit: on screen only, never on the PDF */
.line .cost .input { border-style: dashed; color: var(--text-2); }
.line .lt .lp { display: block; font-size: 11px; font-weight: 500; line-height: 1.2; margin-top: 2px; color: var(--ok); }
.line .lt .lp:empty { display: none; }
.line .lt .lp.neg { color: var(--danger); }
.totals-bar .t.profit b { color: var(--ok); }
.totals-bar .t.profit.neg b { color: var(--danger); }
.kv .profit-v { color: var(--ok); font-weight: 600; }
.kv .profit-v.neg { color: var(--danger); }
.rate-keep { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: -4px 0 12px; }
.seg.sm button { height: 28px; padding: 0 10px; font-size: 12px; }
.irow-nums { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.irow-nums label { display: flex; flex-direction: column; gap: 2px; font-size: 11.5px; color: var(--text-2); }
.irow-nums .input { height: 34px; text-align: end; }
.ichip small { color: var(--text-2); font-size: 11px; }
.line .num-in.qty-u { display: flex; gap: 4px; }
.line .qty-u .input.n { flex: 1 1 50px; min-width: 0; }
.line .input.unit { flex: 0 0 56px; width: 56px; min-width: 0; padding: 0 6px; font-size: 12.5px; color: var(--text-2); }
.irow-top { display: flex; gap: 6px; }
.irow-top [data-iname] { flex: 1 1 auto; min-width: 0; }
.irow-top .input.unit { flex: 0 0 86px; width: 86px; }
.line-cols { padding: 0 10px 6px; font: 600 11.5px var(--font-body); color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.line-cols span { overflow: hidden; text-overflow: ellipsis; }
.line-cols .end { text-align: end; }
.sec-body > .line + .line { border-top: 1px solid var(--line); }
.line .input { height: 34px; font-size: 14px; }
.line .input.n { text-align: end; padding: 0 9px; }
.line .pick { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.line .pick > [data-item], .line .pick > [data-itemtxt] { flex: 1 1 170px; min-width: 140px; width: auto; font-weight: 500; }
.line .pick > [data-item][data-few] { flex: 0 1 112px; min-width: 96px; font-weight: 400; color: var(--text-2); }
.line .pick > select.opt[data-opt] { flex: 1 1 110px; min-width: 96px; width: auto; max-width: 190px; }
.line select.input { background-position: calc(100% - 16px) 14px, calc(100% - 11px) 14px; }
[dir="rtl"] .line select.input { background-position: 16px 14px, 21px 14px; }
.line .num-in { display: block; min-width: 0; }
.line .lt { padding-top: 8px; text-align: end; font-weight: 600; font-size: 14px; white-space: nowrap; }
.line .lt.usd { color: var(--usd); }
.line .acts { display: flex; justify-content: flex-end; gap: 2px; padding-top: 2px; }
.line .acts .btn.on, .line .pick .pen.on { color: var(--accent); background: var(--accent-soft); }
.line .pick .pen { flex: none; height: 34px; width: 34px; color: var(--text-3); }
.line .pick .pen:hover { color: var(--text); }
.note-line, .txt-line { grid-column: 2 / -1; display: flex; gap: 6px; align-items: flex-start; }
.note-line[hidden], .txt-line[hidden], .txt-line [hidden] { display: none; }
.note-line > svg, .txt-line > svg { width: 15px; height: 15px; flex: none; margin-top: 9px; color: var(--text-3); }
.txt-line > svg { color: var(--accent); }
.txt-line .input { flex: 1 1 auto; min-width: 0; font-weight: 500; }
[dir="rtl"] .note-line > svg { transform: scaleX(-1); }
.note-line textarea.input { height: auto; min-height: 34px; font-size: 13px; resize: none; padding-top: 7px; padding-bottom: 7px; }

.sec-card { padding: 0; margin-bottom: 10px; overflow: visible; }
.sec-head { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-bottom: 1px solid var(--line); }
.sec-card.folded .sec-head { border-bottom: 0; }
.sec-card.folded .sec-body { display: none; }
.sec-fold {
  flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 6px; padding: 5px 6px; border: 0; border-radius: 8px;
  background: none; color: var(--text); font: 700 15.5px var(--font-heading); text-align: start; cursor: pointer;
}
.sec-fold span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sec-fold:hover { background: var(--btn); }
.sec-fold svg { width: 18px; height: 18px; flex: none; color: var(--accent); transition: transform .18s var(--ease); }
.sec-card.folded .sec-fold svg { transform: rotate(-90deg); }
[dir="rtl"] .sec-card.folded .sec-fold svg { transform: rotate(90deg); }
.sec-count { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.sec-sum { font-weight: 700; font-size: 14px; white-space: nowrap; min-width: 90px; text-align: end; }
.sec-acts { display: flex; gap: 2px; }
.sec-acts .btn.armed { width: auto; padding: 0 8px; color: var(--danger); }
.sec-body { padding: 2px 0 4px; }
.sec-foot { display: flex; gap: 6px; flex-wrap: wrap; padding: 4px 10px 2px 38px; }
[dir="rtl"] .sec-foot { padding: 4px 38px 2px 10px; }
.sec-foot .btn { color: var(--accent); }
.sec-empty { padding: 18px 12px; text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius); margin-bottom: 10px; }
.fold-all svg { width: 16px; height: 16px; }
.add-sec {
  display: flex; align-items: center; gap: 8px; padding: 4px 12px; color: var(--accent);
  border: 1.5px dashed color-mix(in srgb, var(--accent) 45%, transparent); border-radius: var(--radius);
}
.add-sec > svg { width: 18px; height: 18px; flex: none; }
.add-sec .input { border: 0; background: transparent; box-shadow: none; height: 40px; padding: 0 4px; }

/* handles and dragging (quotation cards and lines, services, items in a service) */
.sec-card .grip, .line .grip, .svc-card .grip, .irow .grip {
  display: flex; align-items: center; justify-content: center; width: 22px; height: 34px; flex: none;
  border-radius: 6px; color: var(--text-3); cursor: grab; touch-action: none; user-select: none;
}
.grip svg { width: 16px; height: 16px; }
.grip:hover { background: var(--accent-soft); color: var(--accent); }
.sec-card.dragging, .line.dragging, .svc-card.dragging, .irow.dragging { background: var(--accent-soft); outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: -2px; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none !important; }
.moved { animation: moved 1s ease; }
@keyframes moved { from { background: var(--accent-soft); } to { background: transparent; } }

/* services page: one card per service, in the team's order */
.svc-list { display: flex; flex-direction: column; gap: 8px; }
.svc-card { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; cursor: pointer; }
.svc-card:hover, .svc-card:focus-visible { border-color: color-mix(in srgb, var(--accent) 45%, transparent); outline: none; }
.svc-list.no-drag .svc-card { padding-inline-start: 16px; }
.svc-main { flex: 1; min-width: 0; }
.svc-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.svc-top b { font-size: 15.5px; font-family: var(--font-heading); }
.ichips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.ichip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--btn); border: 1px solid var(--line); }
.ichip svg { width: 12px; height: 12px; color: var(--accent); }
.ichip.more { color: var(--text-2); }
.svc-props { display: flex; flex-wrap: wrap; gap: 3px 14px; margin-top: 7px; }
.svc-props b { font-weight: 600; }
.svc-open { color: var(--text-3); padding-top: 4px; }
.svc-open svg { width: 16px; height: 16px; }
.irow { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 6px; align-items: start; padding: 6px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--field); }
.irow-in { display: flex; flex-direction: column; gap: 4px; }
.irow .input { height: 36px; }
.irow textarea.input { height: auto; min-height: 34px; font-size: 13px; resize: none; padding-top: 7px; padding-bottom: 7px; }

.totals-bar {
  position: sticky; bottom: 12px; z-index: 20;
  display: flex; gap: 22px; align-items: center; flex-wrap: wrap;
  padding: 12px 18px;
  background: var(--toast);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.totals-bar .t { display: flex; flex-direction: column; }
.totals-bar .t span { font-size: 12px; color: var(--text-2); }
.totals-bar .t b { font-size: 16px; }
.totals-bar .t.grand b { font-size: 20px; color: var(--accent); }
.totals-bar .t.grand.usd b { color: var(--usd); }
.items-head { display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 14px; }
.cur-pick { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-inline-start: auto; }
.cur-pick .rate { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.cur-pick .rate .input { width: 110px; height: 36px; }
.totals-bar .acts { margin-inline-start: auto; display: flex; gap: 8px; align-items: center; }
.save-state { font-size: 12px; color: var(--text-2); }

.conflict { border-color: color-mix(in srgb, var(--danger) 50%, transparent); }

/* ---------- phase 2: dropdown list, side panel, cards, client page ---------- */
.combo-list {
  position: fixed; z-index: 700;
  width: max-content; max-width: min(420px, 90vw); max-height: 280px; overflow: auto;
  background: var(--toast); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); padding: 4px;
}
.combo-list .opt { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.combo-list .opt small { color: var(--text-2); font-size: 12px; }
.combo-list .opt:hover, .combo-list .opt.on { background: var(--accent-soft); }
.combo-list .hint { padding: 8px 10px; font-size: 12px; color: var(--text-2); }

.client-pick { display: flex; gap: 8px; align-items: center; }
.client-pick .grow { flex: 1; min-width: 0; }
/* several-types dialog */
.vt { width: 100%; border-collapse: collapse; }
.vt th { font-size: 12px; font-weight: 600; color: var(--text-2); text-align: start; padding: 0 6px 6px; border-bottom: 1px solid var(--line); }
.vt td { padding: 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.vt .vq { width: 96px; }
.vt .vq .input { height: 34px; text-align: center; }
.vt .vx { width: 40px; }
.vt .vsel { display: flex; gap: 6px; flex-wrap: wrap; }
.vt .vsel .input { height: 34px; width: auto; min-width: 120px; flex: 1 1 120px; }

.panel-wrap { position: fixed; inset: 0; z-index: 800; }
.panel-back { position: absolute; inset: 0; background: rgba(0,0,0,.45); opacity: 0; transition: opacity .2s; }
.panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(440px, 100vw);
  border-radius: var(--radius) 0 0 var(--radius); display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .22s var(--ease); background: var(--toast); backdrop-filter: none;
}
.panel-wrap.open .panel { transform: none; }
.panel-wrap.open .panel-back { opacity: 1; }
.panel header { display: flex; align-items: center; gap: 10px; padding: 18px 20px 10px; }
.panel header h2 { flex: 1; }
.panel-body { flex: 1; overflow: auto; padding: 8px 20px 20px; }
.panel footer { display: flex; gap: 8px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--line); }
.fgroup { display: grid; grid-template-columns: 1fr 2fr auto; gap: 6px; }

.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.tile { display: flex; flex-direction: column; gap: 6px; padding: 16px; color: var(--text); text-align: start; cursor: pointer; font: inherit; transition: border-color .15s, transform .1s; }
.tile:hover { border-color: color-mix(in srgb, var(--accent) 45%, transparent); text-decoration: none; }
.tile b { font-size: 15px; }
.tile-foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 6px; }
.seg button svg { width: 15px; height: 15px; vertical-align: -3px; }
.seg button span { margin-inline-start: 6px; }
@media (max-width: 560px) { .seg button span { display: none; } }

.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 16px; }
.stat { padding: 14px 18px; display: flex; flex-direction: column; gap: 4px; }
.stat span { font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.stat b { font-size: 18px; }
.stat b.ok { color: var(--ok); }
.client-grid { display: grid; gap: 16px; grid-template-columns: 320px minmax(0, 1fr); align-items: start; }
@media (max-width: 960px) { .client-grid { grid-template-columns: 1fr; } }
.dialog.wide { width: min(620px, 100%); max-height: calc(100vh - 32px); overflow: auto; }
.dialog .muted svg { width: 14px; height: 14px; vertical-align: -2px; }

/* ---------- A4 quotation page (always light: it is paper) ---------- */
.a4 {
  --ink: #1b1c1e;
  --ink-2: #5b5d63;
  --rule: #e2e2e6;
  --orange: #ff7300;
  width: 210mm; height: 297mm;
  background: #ffffff; color: var(--ink);
  font-family: 'Plus Jakarta Sans', 'IBM Plex Sans Arabic', 'Segoe UI', sans-serif;
  font-size: 9pt; line-height: 1.4;
  display: flex; flex-direction: column;
  overflow: hidden;
  position: relative;
  direction: ltr; text-align: left;
}
.a4 * { box-sizing: border-box; }
.a4 .band { height: 6mm; flex: none; background: linear-gradient(90deg, var(--orange) 0 26%, var(--ink) 26% 100%); }
.a4 .pgno { position: absolute; top: 1.5mm; right: 14mm; font-size: 6.6pt; letter-spacing: .08em; text-transform: uppercase; color: #c9c9cf; }
.a4.minimal .pgno { top: 3.2mm; color: var(--ink-2); }
.a4 .body { padding: 7mm 14mm 0; display: flex; flex-direction: column; gap: 4.5mm; flex: 1; min-height: 0; overflow: hidden; }
.a4 .head { display: flex; justify-content: space-between; align-items: center; gap: 10mm; }
.a4 .head img { height: 11mm; width: auto; }
.a4 .head h1 { font-family: 'Outfit', sans-serif; font-weight: 800; font-size: 21pt; letter-spacing: .14em; margin: 0; color: var(--ink); line-height: 1; }
.a4 .head.cont img { height: 8mm; }
.a4 .cont-t { display: flex; flex-direction: column; align-items: flex-end; gap: .6mm; }
.a4 .cont-t b { font: 800 10pt 'Outfit', sans-serif; letter-spacing: .1em; }
.a4 .cont-t span { font-size: 7.5pt; color: var(--ink-2); }
.a4 .cont-next { text-align: right; font-size: 7pt; font-style: italic; color: var(--ink-2); margin-top: -2mm; }
/* No. · Date · Valid until · Currency · Rate: one strip under the logo */
.a4 .meta { display: flex; justify-content: space-between; gap: 4mm; margin: -1.5mm 0 0; padding: 1.6mm 0; border-top: .25mm solid var(--rule); border-bottom: .25mm solid var(--rule); }
.a4 .meta dt { color: var(--ink-2); text-transform: uppercase; letter-spacing: .08em; font-size: 6.6pt; line-height: 1.2; }
.a4 .meta dd { margin: .4mm 0 0; font-weight: 600; font-size: 8.5pt; line-height: 1.2; white-space: nowrap; }
.a4 .meta > div:last-child { text-align: right; }
.a4 .blocks { display: grid; grid-template-columns: 1fr 1fr; gap: 5mm; }
.a4 .block { border-left: 1.2mm solid var(--orange); background: #f6f6f8; padding: 2.3mm 3.5mm; line-height: 1.3; }
.a4 .block h4 { font: 700 7pt 'Plus Jakarta Sans', sans-serif; text-transform: uppercase; letter-spacing: .12em; color: var(--orange); margin: 0 0 1mm; }
.a4 .block .big { font-weight: 700; font-size: 10pt; }
.a4 .block div { min-height: 1em; }
.a4 table.items-print { width: 100%; border-collapse: collapse; font-size: 8.5pt; }
.a4 .items-print th { background: var(--ink); color: #fff; font-weight: 600; font-size: 7.5pt; letter-spacing: .08em; text-transform: uppercase; padding: 1.9mm 2mm; text-align: left; }
.a4 .items-print th.r, .a4 .items-print td.r { text-align: right; }
.a4 .items-print th.c, .a4 .items-print td.c { text-align: center; }
.a4 .items-print td { padding: 1.4mm 2mm; border-bottom: .25mm solid var(--rule); vertical-align: top; line-height: 1.3; }
.a4 .items-print tr:nth-child(even) td { background: #fafafb; }
.a4 .items-print td.det { white-space: pre-wrap; }
.a4 .items-print tr.grp td { font-family: 'Outfit', 'IBM Plex Sans Arabic', sans-serif; font-weight: 800; font-size: 9pt; letter-spacing: .02em; color: var(--ink); background: #f3f3f5 !important; border-bottom: .25mm solid var(--rule); padding-top: 1.1mm; padding-bottom: 1.1mm; }
.a4 .items-print tr.sub td { background: #fff !important; }
.a4 .items-print tr.sub td:first-child { color: var(--ink-2); font-size: 7.5pt; }
.a4 .items-print tr.sub td.det { padding-left: 5mm; }
.a4 .items-print tr.one td.det { font-family: 'Outfit', 'IBM Plex Sans Arabic', sans-serif; font-weight: 800; font-size: 9pt; letter-spacing: .02em; color: var(--ink); }
/* the line's note, under its text */
.a4 .items-print .ln { font: 400 7.4pt/1.25 'Plus Jakarta Sans', 'IBM Plex Sans Arabic', sans-serif; letter-spacing: 0; color: var(--ink-2); margin-top: .5mm; white-space: pre-wrap; }
.a4 .items-print small.u { font-size: 6.8pt; color: var(--ink-2); font-weight: 500; }
.a4 .items-print tr.grp td.r { font-size: 8.5pt; }
.a4 .items-print tr.grp td.usd { color: #1f45a8; }
.a4 .items-print tr.grp.cont small { font: 500 7pt 'Plus Jakarta Sans', sans-serif; font-style: italic; color: var(--ink-2); letter-spacing: 0; margin-left: 1.5mm; }
.a4.dense .items-print td { padding: .9mm 2mm; font-size: 8pt; }
.a4.dense .items-print tr.grp td { padding-top: .8mm; padding-bottom: .8mm; }
.a4.dense .body { gap: 4mm; }
.a4.tight .items-print td { padding: .55mm 1.8mm; font-size: 7.6pt; line-height: 1.2; }
.a4.tight .items-print tr.grp td { padding-top: .5mm; padding-bottom: .5mm; font-size: 8.2pt; }
.a4.tight .items-print tr.one td.det { font-size: 8.2pt; }
.a4.tight .items-print th { padding: 1.4mm 1.8mm; }
.a4.tight .items-print .ln { font-size: 6.8pt; margin-top: .2mm; }
.a4.tight .body { gap: 3.2mm; }
.a4 .lower { display: grid; grid-template-columns: minmax(0, 1fr) 72mm; gap: 8mm; align-items: start; }
.a4 .words { margin-top: 1.6mm; font-size: 7pt; line-height: 1.3; color: var(--ink-2); text-align: right; }
.a4 .words b { color: var(--ink); font-weight: 600; }
/* signatures: ours (with the stamp) and the client's acceptance */
.a4 .signs { display: grid; grid-template-columns: 1fr 1fr; gap: 12mm; }
.a4 .sig-space { height: 10mm; position: relative; }
.a4 .sig .stamp-img { position: absolute; right: 2mm; bottom: -1.5mm; width: 38mm; height: auto; transform: rotate(-3deg); opacity: .92; }
.a4 .sig .sl { position: relative; border-top: .3mm solid var(--ink); padding-top: 1.2mm; font-size: 7.6pt; line-height: 1.3; color: var(--ink-2); }
.a4 .sig .sl b, .a4 .sig .sl span { display: block; }
.a4 .sig .sl b { color: var(--ink); }
.a4 .sig .sl span { font-size: 7pt; white-space: pre; }
.a4 .terms h4 { font: 700 7.5pt 'Plus Jakarta Sans', sans-serif; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-2); margin: 0 0 1.5mm; }
.a4 .terms ul { margin: 0; padding-left: 3.5mm; color: var(--ink-2); font-size: 6.8pt; line-height: 1.3; }
.a4 .terms li { margin-bottom: .3mm; }
.a4 .tot { width: 100%; border-collapse: collapse; font-size: 9pt; }
.a4 .tot td { padding: 1.5mm 2mm; }
.a4 .tot td:last-child { text-align: right; font-weight: 600; white-space: nowrap; }
.a4 .tot tr.grand td { background: var(--orange); color: #fff; font-weight: 800; font-size: 11pt; padding: 2.6mm 2mm; }
.a4 .items-print th { white-space: nowrap; vertical-align: middle; }
.a4 .items-print th small { font-size: 6.3pt; font-weight: 500; letter-spacing: .04em; opacity: .75; }
.a4 .items-print td.usd { color: #1f45a8; }
.a4 .lower.two { grid-template-columns: minmax(0, 1fr) 88mm; }
.a4 .tot.two td:nth-child(2) { text-align: right; font-weight: 600; white-space: nowrap; }
.a4 .tot.two tr.hd td { font-size: 7pt; font-weight: 700; letter-spacing: .12em; color: var(--ink-2); padding-bottom: .5mm; border-bottom: .25mm solid var(--rule); }
.a4 .tot.two td:last-child { color: #1f45a8; }
.a4 .tot.two tr.hd td:last-child { color: var(--ink-2); }
.a4 .tot.two tr.grand td { font-size: 10pt; }
.a4 .tot.two tr.grand td:last-child { color: #fff; }
.a4.minimal .tot.two tr.grand td:last-child { color: #1f45a8; }
.a4 .foot { margin-top: auto; flex: none; background: var(--ink); color: #fff; padding: 3.6mm 14mm; display: flex; align-items: center; gap: 8mm; font-size: 7.8pt; }
.a4 .foot .lines { display: flex; flex-direction: column; gap: 1.4mm; min-width: 0; }
.a4 .foot .lines b { color: var(--orange); font-family: 'Outfit', sans-serif; font-weight: 600; letter-spacing: .06em; font-size: 9pt; display: flex; align-items: baseline; gap: 4mm; }
.a4 .foot .lines b small { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 500; letter-spacing: .02em; font-size: 7.2pt; color: #b9bac0; }
.a4 .foot .row-ci { display: flex; align-items: center; gap: 3.5mm; flex-wrap: wrap; }
.a4 .foot .ci { display: inline-flex; align-items: center; gap: 1.6mm; }
.a4 .foot .ci svg { width: 3.4mm; height: 3.4mm; flex: none; }
.a4 .foot .sep { width: .25mm; height: 3.4mm; background: #4a4c52; }
.a4.minimal .foot .lines b small { color: var(--ink-2); }
.a4.minimal .foot .sep { background: #c9c9cf; }
.a4 .foot .qr { margin-left: auto; display: flex; align-items: center; gap: 3mm; font-size: 7pt; color: #c9c9cf; text-align: right; }
.a4 .foot .qr img { width: 16mm; height: 16mm; background: #fff; padding: 1mm; display: block; }
.a4 [dir="auto"] { unicode-bidi: plaintext; }
.a4 .rtl-ok { unicode-bidi: plaintext; }

/* design 2: minimal (no dark bands, thin orange rules) */
.a4.minimal .band { height: 2.2mm; background: var(--orange); }
.a4.minimal .items-print th { background: transparent; color: var(--ink); border-bottom: .6mm solid var(--orange); }
.a4.minimal .block { background: transparent; border-left-width: .8mm; }
.a4.minimal .tot tr.grand td { background: transparent; color: var(--ink); border-top: .6mm solid var(--orange); }
.a4.minimal .foot { background: #f4f4f6; color: var(--ink); border-top: .6mm solid var(--orange); }
.a4.minimal .foot .qr { color: var(--ink-2); }

/* ---------- phone: top bar, tab bar at the bottom, cards instead of tables ---------- */
.nav { display: flex; flex-direction: column; gap: 6px; }
.qcards { display: none; }
@media (max-width: 760px) {
  .shell { grid-template-rows: auto 1fr; } /* a short page must not stretch the top bar */
  .seg:has([data-view]) { display: none; } /* phones always show cards */
  .sidebar {
    position: sticky; top: 0; z-index: 50; flex-wrap: nowrap; gap: 8px;
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: var(--toast);
    backdrop-filter: none; -webkit-backdrop-filter: none; /* a filter here would trap the fixed tab bar inside the top bar */
  }
  .sidebar .logo { height: 20px; margin: 0; }
  .sidebar .tools { padding: 0; gap: 4px; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: var(--toast); border-top: 1px solid var(--line-strong);
    backdrop-filter: var(--glass); -webkit-backdrop-filter: var(--glass);
  }
  .nav-item { flex-direction: column; justify-content: center; gap: 3px; height: 52px; padding: 0 2px; font-size: 11px; border: 0; text-align: center; }
  .nav-item svg { width: 21px; height: 21px; }
  .nav-item.on { background: var(--accent-soft); color: var(--accent); border: 0; }
  .main { padding: 14px 12px calc(84px + env(safe-area-inset-bottom)); }
  .page-head { gap: 8px; margin-bottom: 14px; }
  .page-head h1 { font-size: 22px; flex: 1 1 auto; min-width: 0; }
  .page-head > h1 ~ .btn, .page-head > h1 ~ a.btn { flex: 1 1 calc(50% - 4px); }
  .filters .search { min-width: 0; flex-basis: 100%; }
  .filters .input:not(.search) { flex: 1; }
  .card-pad { padding: 14px; }

  /* quotations list → cards */
  .qtable { display: none; }
  .qlist { background: none; border: 0; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .qcards { display: flex; flex-direction: column; gap: 10px; }
  .qcard {
    display: flex; flex-direction: column; gap: 4px; padding: 14px; color: var(--text);
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  }
  .qcard:hover, .qcard:active { text-decoration: none; border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
  .qc-top { display: flex; justify-content: space-between; align-items: center; }
  .qc-client { font-weight: 600; font-size: 15px; }
  .qc-sub { font-size: 13px; color: var(--text-2); }
  .qc-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line); }
  .qc-date { font-size: 12px; color: var(--text-2); }
  .qc-total { display: flex; flex-direction: column; align-items: flex-end; }
  .qc-usd { color: var(--usd); font-size: 12px; }

  /* preview */
  .preview { gap: 14px; }
  .preview > .card { padding: 6px !important; }

  /* editor: each item line becomes a small card inside its section card */
  .editor { padding-bottom: 150px; }
  .items-card { padding: 12px 10px; }
  .line-cols { display: none; }
  .line, #secList.both .line {
    grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 10px;
  }
  .sec-body > .line + .line { border-top: 1px solid var(--line-strong); }
  .line .grip { grid-column: 1; grid-row: 1; width: auto; justify-content: flex-start; padding: 0 6px; background: var(--btn); justify-self: start; }
  .line .acts { grid-column: 2 / -1; grid-row: 1; }
  .line .pick { grid-column: 1 / -1; }
  .line .pick > select.opt[data-opt] { flex: 1 1 130px; max-width: none; }
  .line [data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--text-2); margin-bottom: 3px; font-weight: 400; }
  .line .lt { padding-top: 0; text-align: start; align-self: center; }
  .line .lt:not(.usd) { grid-column: 1 / 3; }
  .line .lt.usd { grid-column: 3; }
  .note-line, .txt-line { grid-column: 1 / -1; }
  .line .num-in.qty-u { flex-wrap: wrap; }
  .line .qty-u::before { flex: 0 0 100%; }
  .line .input.unit { flex-basis: 46px; width: 46px; padding: 0 4px; }
  .line .qty-u .input.n { flex-basis: 30px; }
  .sec-head { padding: 6px 6px; gap: 4px; flex-wrap: wrap; }
  .sec-count { display: none; }
  .sec-sum { min-width: 0; }
  .sec-foot, [dir="rtl"] .sec-foot { padding: 6px 10px 4px; }
  .svc-card { padding: 12px 10px; gap: 6px; }

  /* totals bar sits above the tab bar; only the grand totals and the buttons */
  .totals-bar {
    position: fixed; left: 8px; right: 8px; bottom: calc(72px + env(safe-area-inset-bottom));
    gap: 8px 14px; padding: 10px 12px;
  }
  .totals-bar .t:not(.grand) { display: none; }
  .totals-bar .t.grand b { font-size: 17px; }
  .totals-bar .acts { flex: 1 1 auto; justify-content: flex-end; gap: 6px; }
  .totals-bar .acts .btn:not(.primary) { font-size: 0; gap: 0; padding: 0 11px; } /* icon only */
  .totals-bar .acts .btn.primary { padding: 0 14px; }
  .totals-bar .save-state { display: none; }

  /* dialogs and the side panel use the whole screen width */
  .overlay { padding: 10px; align-items: end; }
  .dialog, .dialog.wide { width: 100%; max-height: calc(100vh - 20px); overflow: auto; padding: 18px; }
  .panel { border-radius: 0; }
  .vt .vq { width: 76px; }
  .combo-list { max-width: calc(100vw - 16px); }
}

/* ---------- printing: only the A4 page ---------- */
#print-root { display: none; }
@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff !important; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; }
  #print-root .a4 { box-shadow: none; margin: 0; break-after: page; page-break-after: always; }
  #print-root .a4:last-child { break-after: auto; page-break-after: auto; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}
