:root {
  --g900: #0f3524; --g800: #154a32; --g700: #1b613f; --g600: #287953; --g200: #cfe3d7; --g100: #e6f1ea; --g50: #f3f8f5;
  --ink: #17302a; --muted: #4f6a5e; --line: #d4e1d9; --bg: #f2f5f3; --card: #ffffff;
  --err: #a8261d; --err-bg: #fdecea; --warn: #7a4f00; --warn-bg: #fff4d6; --ok: #1d6b3f; --ok-bg: #e3f4e8; --info-bg: #e8f0fb; --info: #1f4a85;
  --radius: .6rem;
  font-family: system-ui, -apple-system, "Segoe UI", Tahoma, "Geeza Pro", "Noto Sans Arabic", sans-serif;
  color: var(--ink); background: var(--bg); font-size: 16px; line-height: 1.55;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); overflow-x: hidden; }
a { color: var(--g700); }
code, .ltr { direction: ltr; unicode-bidi: isolate; font-family: inherit; }
.num { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; white-space: nowrap; }
.skip { position: absolute; inset-inline-start: -999px; top: 0; background: #fff; padding: .5rem; z-index: 10; }
.skip:focus { inset-inline-start: .5rem; }
:focus-visible { outline: 3px solid #e0a100; outline-offset: 2px; }

/* top bar */
.topbar { background: var(--g800); color: #fff; display: flex; align-items: center; gap: 1rem; padding: .5rem 1rem; flex-wrap: wrap; position: sticky; top: 0; z-index: 5; }
.topbar .brand { display: flex; align-items: center; gap: .6rem; }
.topbar .brand img { background: #fff; border-radius: .35rem; padding: 2px; }
.topbar .brand span { display: flex; flex-direction: column; line-height: 1.2; }
.topbar .brand small { opacity: .8; font-size: .75rem; }
.topbar nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.topbar nav a { color: #fff; text-decoration: none; padding: .5rem .75rem; border-radius: .4rem; min-height: 40px; display: inline-flex; align-items: center; gap: .35rem; }
.topbar nav a[aria-current="page"], .topbar nav a:hover { background: rgba(255,255,255,.14); }
.topbar .who { display: flex; align-items: center; gap: .6rem; font-size: .85rem; flex-wrap: wrap; }
.topbar .who button { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.5); min-height: 36px; padding: .25rem .7rem; }
.bell { color: #fff; text-decoration: none; position: relative; padding: .3rem .5rem; }
.bell .count { background: #e0a100; color: #1b1b1b; border-radius: 999px; font-size: .7rem; padding: 0 .4rem; margin-inline-start: .2rem; font-weight: 700; }
.menu-toggle { display: none; background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.5); margin-inline-start: auto; }
@media (max-width: 760px) {
  .topbar { position: static; }
  .menu-toggle { display: inline-flex; }
  .topbar nav { display: none; flex-basis: 100%; flex-direction: column; }
  .topbar nav.open { display: flex; }
  .topbar .who { flex-basis: 100%; justify-content: space-between; }
}

main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 1rem; }
main:focus { outline: none; }
.foot { text-align: center; font-size: .8rem; color: var(--warn); background: var(--warn-bg); padding: .5rem 1rem; }
.loading { color: var(--muted); }

h1 { font-size: 1.45rem; margin: .25rem 0 1rem; color: var(--g900); }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; color: var(--g800); }
h3 { font-size: 1rem; margin: .75rem 0 .5rem; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.page-head h1 { margin: 0; }
.sub { color: var(--muted); font-size: .9rem; margin: .2rem 0 0; }
.crumbs { font-size: .85rem; margin-bottom: .4rem; color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.card > h2:first-child { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* buttons */
button, .btn { font: inherit; border-radius: .45rem; border: 1px solid var(--g700); background: #fff; color: var(--g800); padding: .5rem 1rem; min-height: 44px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; text-decoration: none; }
button.primary, .btn.primary { background: var(--g700); color: #fff; }
button.primary:hover, .btn.primary:hover { background: var(--g800); }
button.danger { border-color: var(--err); color: var(--err); }
button.small, .btn.small { min-height: 36px; padding: .25rem .7rem; font-size: .9rem; }
button:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.actionbar { position: sticky; top: 58px; z-index: 3; background: var(--g50); border: 1px solid var(--g200); border-radius: var(--radius); padding: .5rem; margin-bottom: 1rem; }
@media (max-width: 760px) { .actionbar { top: 0; } .actionbar .btn, .actionbar button { flex: 1 1 auto; } }

/* forms */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
.field { margin-bottom: .75rem; min-width: 0; }
.field .hint { font-weight: 400; font-size: .8rem; color: var(--muted); margin-top: .2rem; }
input, select, textarea { font: inherit; width: 100%; padding: .5rem .6rem; border: 1px solid #b9cbc0; border-radius: .4rem; background: #fff; color: var(--ink); min-height: 44px; }
textarea { min-height: 5rem; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 1.2rem; height: 1.2rem; min-height: 0; accent-color: var(--g700); }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 600; }
.radios { display: flex; gap: 1rem; flex-wrap: wrap; }
.radios label { display: flex; align-items: center; gap: .35rem; font-weight: 600; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--err); background: var(--err-bg); }
.form-grid { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.err { color: var(--err); font-size: .85rem; font-weight: 600; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 1rem; padding: .75rem 1rem; min-width: 0; }
legend { font-weight: 700; color: var(--g800); padding: 0 .4rem; }

/* status & badges */
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 700; background: var(--g100); color: var(--g800); white-space: nowrap; }
.badge.draft { background: #eceff1; color: #37474f; }
.badge.issued, .badge.submitted, .badge.quoted { background: var(--info-bg); color: var(--info); }
.badge.accepted, .badge.approved, .badge.won { background: var(--ok-bg); color: var(--ok); }
.badge.rejected, .badge.lost, .badge.void { background: var(--err-bg); color: var(--err); }
.badge.held, .badge.expired, .badge.superseded, .badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.open { background: var(--g100); }
.alert { border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: 1rem; border: 1px solid; }
.alert.err { background: var(--err-bg); border-color: #f1b8b3; color: var(--err); }
.alert.warn { background: var(--warn-bg); border-color: #ecd38c; color: var(--warn); }
.alert.ok { background: var(--ok-bg); border-color: #a9d8b9; color: var(--ok); }
.alert.info { background: var(--info-bg); border-color: #b5cbe9; color: var(--info); }
.alert ul { margin: .4rem 0 0; padding-inline-start: 1.2rem; }

/* lists & tables */
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-bottom: 1px solid var(--line); padding: .65rem 0; display: flex; gap: .75rem; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; }
.list li:last-child { border-bottom: 0; }
.list .main { flex: 1 1 220px; min-width: 0; }
.list .meta { color: var(--muted); font-size: .85rem; }
.empty { color: var(--muted); font-style: italic; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: .55rem .5rem; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
.tbl th { background: var(--g50); font-size: .85rem; color: var(--g800); }
.tbl tfoot th, .tbl tfoot td { background: var(--g50); font-weight: 700; }
@media (max-width: 700px) {
  .tbl.stack thead { display: none; }
  .tbl.stack, .tbl.stack tbody, .tbl.stack tr, .tbl.stack td, .tbl.stack tfoot, .tbl.stack tfoot th { display: block; width: 100%; }
  .tbl.stack tr { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .6rem; padding: .3rem .6rem; background: #fff; }
  .tbl.stack td { border: 0; padding: .25rem 0; display: flex; justify-content: space-between; gap: .75rem; }
  .tbl.stack td::before { content: attr(data-label); font-weight: 700; color: var(--muted); font-size: .85rem; }
  .tbl.stack td > * { max-width: 65%; min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
  .tbl.stack td > details { flex: 1 1 auto; }
  .tbl.stack tfoot tr { display: flex; justify-content: space-between; }
}
dl.kv { display: grid; grid-template-columns: minmax(8rem, 35%) 1fr; margin: 0; }
dl.kv dt, dl.kv dd { margin: 0; padding: .4rem .25rem; border-bottom: 1px solid var(--line); min-width: 0; overflow-wrap: anywhere; }
dl.kv dt { color: var(--muted); font-size: .9rem; }
@media (max-width: 480px) { dl.kv { grid-template-columns: 1fr; } dl.kv dt { border-bottom: 0; padding-bottom: 0; } }

/* tasks */
.task { display: flex; gap: .75rem; align-items: center; justify-content: space-between; text-decoration: none; color: inherit; border: 1px solid var(--line); border-inline-start: 5px solid var(--g600); background: #fff; border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: .6rem; flex-wrap: wrap; }
.task:hover { background: var(--g50); }
.task .t { font-weight: 700; }
.task .m { color: var(--muted); font-size: .85rem; display: flex; gap: .6rem; flex-wrap: wrap; }
.task.old { border-inline-start-color: #c27c00; }

/* quote lines */
.qline { border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; margin-bottom: .75rem; background: #fff; }
.qline header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; gap: .5rem; flex-wrap: wrap; }
.qline .cols { display: grid; gap: .5rem 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }
.floor { font-size: .8rem; margin-top: .2rem; color: var(--muted); }
.floor.bad { color: var(--err); font-weight: 700; }
.floor.ok { color: var(--ok); }
.price-box.chosen { background: var(--warn-bg); border-radius: .4rem; padding: .25rem .4rem; }
.totals { margin-inline-start: auto; max-width: 360px; }
.totals div { display: flex; justify-content: space-between; padding: .3rem 0; border-bottom: 1px solid var(--line); }
.totals div.grand { font-weight: 800; font-size: 1.1rem; border-bottom: 0; color: var(--g900); }

/* clauses */
.clause { border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; margin-bottom: .6rem; background: #fff; }
.clause.changed { border-color: #d9a400; background: #fffaf0; }
.clause.removed { opacity: .6; background: #f6f6f6; }
.clause header { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .4rem; }
.clause p { margin: 0; }

/* dialog */
dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(640px, calc(100vw - 1.5rem)); max-height: calc(100vh - 2rem); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(10, 30, 20, .45); }
dialog form { padding: 1rem 1.25rem; }
dialog h2 { margin-top: 0; }
dialog .dlg-actions { display: flex; gap: .5rem; justify-content: flex-start; margin-top: 1rem; flex-wrap: wrap; position: sticky; bottom: 0; background: #fff; padding-top: .5rem; }

.toast { position: fixed; bottom: 1rem; inset-inline-start: 50%; transform: translateX(50%); background: var(--g900); color: #fff; padding: .6rem 1.2rem; border-radius: .5rem; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; max-width: calc(100vw - 2rem); }
.toast.show { opacity: 1; }
.toast.error { background: var(--err); }

.login { max-width: 420px; margin: 8vh auto; }
.login .logo { text-align: center; margin-bottom: 1rem; }
.login .demo { font-size: .85rem; color: var(--muted); }
details summary { cursor: pointer; color: var(--g700); font-weight: 600; min-height: 32px; }
pre.json { background: var(--g50); padding: .5rem; border-radius: .4rem; font-size: .75rem; white-space: pre-wrap; word-break: break-word; direction: ltr; text-align: left; max-height: 240px; overflow: auto; }
.muted { color: var(--muted); }
.right { text-align: end; }
.nowrap { white-space: nowrap; }
.mt0 { margin-top: 0; }
.wrap-any { overflow-wrap: anywhere; }

/* quick wins */
.quicklog { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; flex-basis: 100%; }
.quicklog button { min-height: 36px; }
.pct { display: flex; gap: .3rem; margin-top: .35rem; flex-wrap: wrap; }
.pct button { min-height: 32px; padding: .1rem .6rem; font-size: .85rem; }
@media (max-width: 760px) {
  .quicklog { flex-wrap: nowrap; }
  .quicklog > .muted { display: none; }
  .actionbar .quicklog button { flex: 1 1 0; min-width: 0; padding: .25rem .4rem; }
}

/* quote terms checklist */
.term { display: flex; gap: .5rem; align-items: flex-start; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.term input[type="checkbox"] { margin-top: .7rem; flex: none; }
.term textarea { min-height: 2.6rem; resize: none; overflow: hidden; }
.term.off textarea { color: var(--muted); background: #f5f6f5; }
.addterm { display: flex; gap: .5rem; margin-top: .6rem; }
.addterm input { flex: 1; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* tap-button choices */
.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .35rem; }
.chip { min-height: 40px; padding: .3rem .85rem; border-radius: 999px; border: 1px solid #b9cbc0; background: #fff; color: var(--ink); font-size: .95rem; }
.chip:hover { border-color: var(--g700); }
.chip[aria-pressed="true"] { background: var(--g700); border-color: var(--g700); color: #fff; font-weight: 700; }
[data-chips] input:not([type="hidden"]) { margin-top: .1rem; }
.lbl { font-weight: 600; font-size: .9rem; display: block; margin-bottom: .25rem; }
.qline .field.wide { margin-bottom: .5rem; }

.bottombar { position: sticky; bottom: 0; top: auto; }
@media (max-width: 760px) {
  .actionbar.bottombar { flex-wrap: nowrap; }
  .actionbar.bottombar > * { flex: 1 1 0; min-width: 0; padding: .35rem .3rem; font-size: .88rem; line-height: 1.25; }
  .actionbar.bottombar > .badge { display: none; }
}

/* customer file */
.filehead .page-head { margin-bottom: .5rem; }
.file-label { margin: 0; font-size: .8rem; font-weight: 700; color: var(--g600); letter-spacing: .02em; }
.filefacts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: .5rem 1rem; margin: 0; }
.filefacts div { background: var(--g50); border-radius: .4rem; padding: .4rem .6rem; min-width: 0; }
.filefacts dt { font-size: .78rem; color: var(--muted); }
.filefacts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.tabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 2px solid var(--g200); margin-bottom: 1rem; scrollbar-width: thin; }
.tabs [role="tab"] { border: 0; border-radius: .5rem .5rem 0 0; background: transparent; color: var(--g800); white-space: nowrap; min-height: 44px; padding: .4rem .9rem; flex: none; }
.tabs [role="tab"][aria-selected="true"] { background: var(--g700); color: #fff; font-weight: 700; }
.tabs .count { display: inline-block; min-width: 1.4rem; padding: 0 .35rem; border-radius: 999px; background: var(--g100); color: var(--g800); font-size: .78rem; font-weight: 700; }
.tabs [aria-selected="true"] .count { background: rgba(255,255,255,.25); color: #fff; }
.card > h2 > .small { font-size: .82rem; }

/* ---------- quote editor laid out as the printed letter (see print.css) ---------- */
.letter-hint { margin: 0 0 .5rem; }
.letter { --lg: #1f6b45; --lg2: #8cc97a; background: #fff; max-width: 210mm; margin: 0 auto 1rem; padding: 1.25rem 1.5rem; box-shadow: 0 2px 14px rgba(0,0,0,.1); border-radius: .3rem; }
.l-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: .75rem; flex-wrap: wrap; }
.l-brand { display: flex; align-items: center; gap: .6rem; color: var(--lg); }
.l-brand img { width: 80px; height: auto; }
.l-brand div { display: flex; flex-direction: column; line-height: 1.2; }
.l-brand b { font-size: 1.45rem; }
.l-brand span { font-size: .85rem; font-weight: 700; }
.l-ref { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; border: 1px solid #9aa89f; min-width: min(100%, 330px); font-size: .85rem; }
.l-ref .field { margin: 0; padding: .3rem .45rem; border-inline-start: 1px solid #9aa89f; }
.l-ref .field:first-child { border-inline-start: 0; }
.l-ref label { font-size: .78rem; margin-bottom: .1rem; }
.l-ref input { min-height: 36px; padding: .2rem .35rem; font-size: .9rem; }
.l-frame { border: 2px solid var(--lg); border-radius: 1rem; padding: 1rem 1.25rem .75rem; }
.l-title { text-align: center; text-decoration: underline; text-underline-offset: 4px; color: var(--ink); font-size: 1.2rem; margin: 0 0 .9rem; }
.l-to { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px solid #c9d3cd; padding: .2rem 0; margin-bottom: .4rem; }
.l-blank .field, .l-proj .field { margin-bottom: .35rem; }
.l-blank label, .l-proj label { font-weight: 400; }
.l-proj { background: #eef1ef; border: 1px solid #9aa89f; padding: .5rem .6rem .2rem; margin: .4rem 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 0 1rem; }
.letter input, .letter textarea { border-style: dashed; }
.letter .chips { margin-bottom: .25rem; }
.letter .chip { min-height: 34px; padding: .15rem .65rem; font-size: .88rem; }
.letter [data-chips] .chips, .letter .chips.strip { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; padding-bottom: .15rem; }
.letter [data-chips] .chip, .letter .chips.strip .chip { flex: none; white-space: nowrap; }
.l-salam { text-align: center; font-weight: 700; margin: .6rem 0 .2rem; }
.l-intro textarea { min-height: 3rem; }
.l-prices { margin: .5rem 0; }
.l-th, .l-line { display: grid; grid-template-columns: 3rem minmax(0, 1fr) 9rem 9rem 7.5rem; }
.l-qty { margin: 0; }
.l-qty label { margin: 0; }
.l-qty input { text-align: center; font-weight: 700; }
.l-qty .chips { flex-wrap: wrap; gap: .2rem; margin: .3rem 0 0; }
.l-qty .chip { min-height: 30px; padding: .05rem .45rem; font-size: .8rem; }
.l-xrow { flex-direction: row; align-items: center; gap: .5rem; }
.l-th { background: var(--lg2); font-weight: 700; font-size: .85rem; border: 1px solid #6f7d74; }
.l-th span { padding: .35rem .4rem; text-align: center; border-inline-start: 1px solid #6f7d74; display: flex; flex-direction: column; justify-content: center; }
.l-th span:first-child { border-inline-start: 0; }
.l-th small { font-weight: 400; }
.l-line { border: 1px solid #6f7d74; border-top: 0; }
.l-line > * { padding: .4rem; border-inline-start: 1px solid #6f7d74; min-width: 0; }
.l-line > .l-no { border-inline-start: 0; background: var(--lg2); font-weight: 700; display: flex; align-items: center; justify-content: center; }
.l-spec { font-size: .9rem; margin-top: .15rem; }
.l-price { margin: 0; }
.l-price label { font-size: .8rem; font-weight: 400; margin-bottom: .1rem; }
.l-price .l-plabel { display: none; }
.l-price.chosen { background: var(--warn-bg); }
.l-price input { font-size: 1.05rem; font-weight: 700; text-align: center; }
.l-price .floor { font-size: .75rem; line-height: 1.35; }
.l-price .pct { display: flex; gap: .25rem; margin-top: .25rem; }
.l-price .pct button { flex: 1; min-height: 32px; padding: .1rem; font-size: .8rem; }
.l-extra { grid-column: 1 / -1; border-inline-start: 0 !important; border-top: 1px dashed #c3cdc7; background: #fafbfa; display: flex; flex-wrap: wrap; align-items: flex-end; gap: .35rem 1rem; font-size: .88rem; }
.l-x { display: flex; flex-direction: column; min-width: 0; }
.l-x .lbl, .l-x label { font-size: .78rem; color: var(--muted); }
.l-x input { max-width: 8rem; min-height: 34px; }
.l-x .chips { flex-wrap: wrap; }
.l-lt { margin-inline-start: auto; font-weight: 700; color: var(--g800); align-self: center; }
#addLine { margin-top: .5rem; }
#tot { margin: 0 0 .75rem; }
.l-terms { margin: .75rem 0 .5rem; }
.l-sub { text-decoration: underline; }
.l-note { font-size: .8rem; }
.l-vars { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 0 1rem; margin: .4rem 0; padding: .4rem .6rem 0; background: var(--g50); border-radius: .4rem; }
.l-vars input { max-width: 7rem; }
.letter .term textarea { border-style: solid; border-color: transparent; background: transparent; padding-block: .3rem; }
.letter .term:not(.off) textarea:hover, .letter .term textarea:focus { border-color: var(--line); background: #fff; }
.l-inq { border: 1px solid #6f7d74; text-align: center; padding: .45rem; margin: .5rem 2rem; font-weight: 700; }
.l-closing { margin: .5rem 0; }
.l-sigs { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1rem; min-height: 5rem; }
.l-sigs > div { display: flex; flex-direction: column; align-items: center; text-align: center; }
.l-stamp { --ink-c: #1d4f91; width: 165px; min-height: 96px; padding: .5rem .7rem; border: 3px double var(--ink-c); outline: 1px solid var(--ink-c); outline-offset: 4px; border-radius: 50%; color: var(--ink-c);
  text-align: center; transform: rotate(-7deg); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.25; opacity: .6; flex: none; align-self: center; }
.l-stamp .st-co { font-size: .68rem; font-weight: 700; border-bottom: 1px solid var(--ink-c); padding: 0 .4rem .1rem; }
.l-stamp b { font-size: .8rem; }
.l-stamp .st-txt { font-size: .6rem; }
.l-stamp .st-no { font-size: .62rem; font-weight: 700; border-top: 1px solid var(--ink-c); padding: .1rem .4rem 0; }
.l-en { display: block; font-size: .78em; font-weight: 400; color: var(--muted); text-decoration: none; }
.l-pair { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.l-pair .field { margin-bottom: .4rem; }
.letter textarea[lang="en"], .letter .term textarea[data-te] { font-family: "Segoe UI", system-ui, Arial, sans-serif; text-align: left; font-size: .92em; }
.letter textarea.missing { background: var(--warn-bg) !important; border-color: #d9b86a !important; }
.en-warn { color: var(--warn); }
.term .tt { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; min-width: 0; }
.l-stamp .st-en { font-size: .52rem; }
.cl-pair { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.cl-pair > div { display: flex; flex-direction: column; gap: .25rem; }
.cl-en-title { font-weight: 700; font-size: .9rem; color: var(--g800); }
.cl-pair textarea[lang="en"], .cl-pair input[lang="en"] { font-family: "Segoe UI", system-ui, Arial, sans-serif; text-align: left; }
.cl-pair textarea.missing { background: var(--warn-bg); border-color: #d9b86a; }
@media (max-width: 760px) { .cl-pair { grid-template-columns: 1fr; } }
.l-contact { display: flex; flex-wrap: wrap; gap: .2rem 1.5rem; border-top: 1px solid var(--lg); margin-top: .75rem; padding-top: .35rem; font-size: .8rem; font-weight: 700; color: #3c4a42; }

/* issued quote: the printed letter embedded */
.letter-frame { max-width: 210mm; margin: 0 auto 1rem; box-shadow: 0 2px 14px rgba(0,0,0,.1); background: #fff; }
.letter-frame iframe { display: block; width: 100%; height: 297mm; border: 0; }
details.card > summary { cursor: pointer; font-weight: 700; color: var(--g800); }
details.card h3 { font-size: 1rem; margin: 1rem 0 .4rem; }

@media (max-width: 900px) {
  .letter { padding: .6rem; border-radius: 0; margin-inline: -1rem; box-shadow: none; border-block: 1px solid var(--line); }
  .l-frame { padding: .6rem .55rem; border-radius: .6rem; }
  .l-ref { grid-template-columns: 1fr 1fr; width: 100%; }
  .l-ref .field:nth-child(3) { grid-column: 1 / -1; border-inline-start: 0; border-top: 1px solid #9aa89f; }
  .l-brand b { font-size: 1.15rem; }
  .l-to { flex-direction: column; gap: 0; }
  .l-th { display: none; }
  .l-line { grid-template-columns: 2rem minmax(0, 1fr) minmax(0, 1fr); border-top: 1px solid #6f7d74; margin-bottom: .5rem; }
  .l-line > .l-no { grid-row: 1 / span 2; }
  .l-grade { grid-column: 2 / -1; }
  .l-line > .l-price { border-top: 1px solid #c3cdc7; }
  .l-price .l-plabel { display: inline; font-weight: 700; }
  .l-line > .l-extra { grid-column: 1 / -1; }
  .l-line > .l-qty { grid-column: 2 / -1; border-top: 1px solid #c3cdc7; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .6rem; }
  .l-qty .l-plabel { display: inline; font-weight: 700; font-size: .85rem; }
  .l-qty input { max-width: 6.5rem; }
  .l-qty .chips { margin: 0; }
  .l-inq { margin-inline: 0; }
  .l-pair, .term .tt { grid-template-columns: 1fr; gap: .2rem; }
  .letter-frame { margin-inline: -1rem; }
}

.bilingual-clause { display:grid; grid-template-columns:1fr 1fr; gap:1.5rem; border-bottom:1px solid #ccd8d0; padding:1rem 0; align-items:start; }
.bilingual-clause p { white-space:pre-line; line-height:1.7; }
.workflow-item { padding:1rem 0; border-bottom:1px solid #ccd8d0; }
dialog { max-height:90vh; overflow:auto; }
@media(max-width:700px){.bilingual-clause{grid-template-columns:1fr;}}

/* Touch layouts: usable controls and a compact quote editor on tablets. */
.sales-flow { color:var(--muted); font-size:.9rem; line-height:1.9; }
@media (max-width: 1024px) {
  .topbar { position:static; }
  .letter { padding:.65rem; max-width:100%; }
  .l-frame { padding:.6rem; }
  .l-th, .l-line { grid-template-columns:2rem minmax(0,1fr) minmax(0,1fr) minmax(0,1fr) 6rem; }
  button.small,.btn.small,.chip,.letter .chip,.l-qty .chip,.l-price .pct button,.quicklog button,.pct button,.topbar .who button,details summary { min-height:44px; }
  .letter input,.letter textarea,.l-ref input,.l-x input { min-height:44px; font-size:16px; }
  .actionbar.bottombar { bottom:0; padding-bottom:max(.5rem,env(safe-area-inset-bottom)); }
  .card { min-width:0; overflow-wrap:anywhere; }
  .table-scroll { max-width:100%; overflow-x:auto; }
}
@media (max-width:760px) {
  .l-line { grid-template-columns:2rem minmax(0,1fr) minmax(0,1fr); }
  .actionbar.bottombar { flex-wrap:wrap; }
  .actionbar.bottombar > button { flex:1 1 42%; min-height:48px; }
  .l-sigs { flex-wrap:wrap; }
  .l-stamp { max-width:100%; }
  dialog { max-height:calc(100dvh - 1rem); }
}

.quote-details { margin:.6rem 0; border:1px solid var(--line); border-radius:.4rem; padding:.5rem; }
.workflow-next p { margin:.35rem 0; }
.workflow-next h2 { margin-bottom:.25rem; }
@media(max-width:760px){.actionbar.bottombar #qVoid { flex:0 1 auto; font-size:.8rem; min-height:44px; padding:.3rem .6rem; }.workflow-next {padding:.75rem;}}

@media(min-width:761px) and (max-width:900px){.l-line{grid-template-columns:2rem minmax(0,1fr) minmax(0,1fr);}.letter{margin-inline:0;}}

.foot {color:var(--muted);background:var(--g50);}
