/* 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; }
.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: 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 { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 860px; }
.items th { font: 600 12px var(--font-body); color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; text-align: start; padding: 0 6px 8px; white-space: nowrap; }
.items td { padding: 4px 6px; vertical-align: top; }
.items td.no { width: 34px; color: var(--text-3); padding-top: 14px; text-align: center; }
.items td.det { min-width: 280px; }
.items td.qty, .items td.days { width: 86px; }
.items td.price { width: 130px; }
.items td.tot { width: 120px; padding-top: 14px; text-align: end; font-weight: 600; }
.items td.notes { width: 170px; }
.items td.act { width: 76px; white-space: nowrap; padding-top: 7px; }
.items textarea.input { min-height: 40px; resize: vertical; }
.items .input.n { text-align: end; padding: 0 10px; }
.items tr:hover td { background: color-mix(in srgb, var(--accent) 3%, transparent); }

.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; }
.items td.tot.usd { color: var(--usd); }
.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; }
.svc-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.svc-pick { flex: 1 1 160px; min-width: 150px; }
.svc-row .input { height: 34px; font-size: 14px; }
.svc-row select.opt { width: auto; max-width: 140px; background-position: calc(100% - 16px) 14px, calc(100% - 11px) 14px; }
[dir="rtl"] .svc-row select.opt { background-position: 16px 14px, 21px 14px; }

.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: 7mm; flex: none; background: linear-gradient(90deg, var(--orange) 0 26%, var(--ink) 26% 100%); }
.a4 .body { padding: 9mm 14mm 0; display: flex; flex-direction: column; gap: 6mm; flex: 1; min-height: 0; }
.a4 .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10mm; }
.a4 .head img { height: 14mm; width: auto; }
.a4 .title { text-align: right; }
.a4 .title h1 { font-family: 'Outfit', sans-serif; font-weight: 800; font-size: 25pt; letter-spacing: .14em; margin: 0 0 2mm; color: var(--ink); line-height: 1; }
.a4 .meta { display: grid; grid-template-columns: auto auto; gap: .6mm 5mm; justify-content: end; align-items: baseline; font-size: 8.5pt; margin: 0; }
.a4 .meta dt { color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; font-size: 7.5pt; }
.a4 .meta dd { margin: 0; font-weight: 600; text-align: right; }
.a4 .blocks { display: grid; grid-template-columns: 1fr 1fr; gap: 6mm; }
.a4 .block { border-left: 1.2mm solid var(--orange); background: #f6f6f8; padding: 3mm 4mm; }
.a4 .block h4 { font: 700 7.5pt 'Plus Jakarta Sans', sans-serif; text-transform: uppercase; letter-spacing: .12em; color: var(--orange); margin: 0 0 1.4mm; }
.a4 .block .big { font-weight: 700; font-size: 10.5pt; }
.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: 2.4mm 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: 2.2mm 2mm; border-bottom: .25mm solid var(--rule); vertical-align: top; }
.a4 .items-print tr:nth-child(even) td { background: #fafafb; }
.a4 .items-print td.det { white-space: pre-wrap; }
.a4 .items-print td.note { color: var(--ink-2); font-size: 7.8pt; }
.a4.dense .items-print td { padding: 1.3mm 2mm; font-size: 8pt; }
.a4.dense .body { gap: 4mm; }
.a4 .lower { display: grid; grid-template-columns: minmax(0, 1fr) 72mm; gap: 8mm; align-items: start; }
.a4 .terms h4, .a4 .sign 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: 4mm; color: var(--ink-2); font-size: 8pt; }
.a4 .terms li { margin-bottom: .6mm; }
.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 small { display: block; font-size: 6.3pt; font-weight: 500; letter-spacing: .12em; opacity: .75; margin-top: .3mm; }
.a4 .items-print td.usd { color: #1f45a8; }
.a4 .lower.two { grid-template-columns: minmax(0, 1fr) 88mm; }
.a4 .lower.two .sign .stamp-img { width: 44mm; }
.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 .sign { display: flex; gap: 6mm; align-items: flex-end; margin-top: 1mm; }
.a4 .sign .line { flex: 1 1 auto; min-width: 0; border-top: .3mm solid var(--ink); padding-top: 1.5mm; font-size: 8pt; color: var(--ink-2); }
.a4 .sign .stamp-img { width: 50mm; flex: none; height: auto; transform: rotate(-3deg); opacity: .92; margin-bottom: -2mm; }
.a4 .foot { margin-top: auto; flex: none; background: var(--ink); color: #fff; padding: 4.5mm 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: 19mm; height: 19mm; 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); }

/* ---------- 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; page-break-after: avoid; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}
