/* Phase 5G — «الورقة» (invoice sheet) design system, copied from docs/mockups/invoice_and_voucher.html.
   Every class is scoped under .af-sheet / prefixed sh- so it never collides with Unfold's Tailwind classes.
   The sheet is deliberately a light paper in both themes (the desk around it follows the theme). */
:root {
  --sh-desk: #dfe6e1; --sh-paper: #ffffff; --sh-ink: #1b2a23; --sh-muted: #5d6f66; --sh-line: #d5ddd8;
  --sh-green: #14532d; --sh-green-2: #1f6b40; --sh-green-soft: #e8f2ec; --sh-field: #f6f8f7; --sh-field-line: #b9c6bf;
  --sh-amber: #a15c07; --sh-amber-soft: #fdf1dc; --sh-red: #b42318; --sh-red-soft: #fde8e6;
  --sh-toman: #7a3e9d; --sh-usd: #14532d; --sh-iqd: #8a5a00;
  --sh-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
}
.af-desk { display: grid; gap: 18px; max-width: 980px; margin-inline: auto; }
.af-desk.a5 { max-width: 640px; }
.af-sheet { background: var(--sh-paper); color: var(--sh-ink); border-radius: 4px; overflow: hidden; font-size: 15px;
  line-height: 1.55; box-shadow: 0 1px 2px rgba(20,50,35,.08), 0 10px 30px rgba(20,50,35,.12); color-scheme: light; }
.af-sheet *, .af-sheet *::before, .af-sheet *::after { box-sizing: border-box; }
.dark .af-sheet { box-shadow: 0 0 0 1px rgb(255 255 255 / .08), 0 10px 30px rgb(0 0 0 / .4); }

/* header band */
.af-sheet .sh-head { display: flex; justify-content: space-between; align-items: stretch; gap: 16px; padding: 22px 28px;
  border-bottom: 3px solid var(--sh-green); flex-wrap: wrap; }
.af-sheet .sh-brand { display: flex; gap: 12px; align-items: center; }
.af-sheet .sh-logo { width: 54px; height: 54px; border-radius: 10px; background: var(--sh-green); display: grid; place-items: center; overflow: hidden; }
.af-sheet .sh-logo img { width: 100%; height: 100%; object-fit: cover; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.af-sheet .sh-brand h2 { margin: 0; font-size: 22px; font-weight: 800; color: var(--sh-green); }
.af-sheet .sh-brand small { color: var(--sh-muted); font-size: 13px; display: block; }
.af-sheet .sh-doc { text-align: left; display: grid; gap: 3px; justify-items: end; }
.af-sheet .sh-doc .t { font-size: 24px; font-weight: 800; color: var(--sh-ink); }
.af-sheet .sh-doc .no { font-family: var(--sh-mono); font-size: 14px; color: var(--sh-muted); direction: ltr; }
.af-sheet .sh-doc .row { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--sh-muted); flex-wrap: wrap; justify-content: flex-end; }
.af-sheet .sh-doc .row .sh-in { height: 34px; width: auto; font-size: 14px; }
.af-sheet .sh-badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 3px 12px; font-size: 13px; font-weight: 700; }
.af-sheet .sh-badge.draft { background: var(--sh-amber-soft); color: var(--sh-amber); }
.af-sheet .sh-badge.draft::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--sh-amber); }
.af-sheet .sh-badge.ok { background: var(--sh-green-soft); color: var(--sh-green); }
.af-sheet .sh-badge.bad { background: var(--sh-red-soft); color: var(--sh-red); }
.af-sheet .sh-stage { font-size: 12px; color: var(--sh-muted); }

/* body + sections */
.af-sheet .sh-body { padding: 22px 28px; display: grid; gap: 22px; }
.af-sheet .sh-sec-t { font-size: 15px; font-weight: 800; color: var(--sh-green); margin: 0 0 10px; display: flex;
  justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.af-sheet .sh-sec-t span { font-weight: 500; color: var(--sh-muted); font-size: 13px; }

/* fields: label ABOVE the field, 44px inputs, 16px text, light background, 1.5px border */
.af-sheet .sh-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; }
.af-sheet .sh-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.af-sheet .sh-f { display: grid; gap: 5px; min-width: 0; align-content: start; }
.af-sheet .sh-f > label, .af-sheet .sh-f > .sh-lbl { font-size: 13px; font-weight: 700; color: var(--sh-muted); }
.af-sheet .sh-in, .af-sheet .sh-f input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]),
.af-sheet .sh-f select, .af-sheet .sh-f textarea {
  height: 44px; width: 100%; font: inherit; font-size: 16px; color: var(--sh-ink); background: var(--sh-field);
  border: 1.5px solid var(--sh-field-line); border-radius: 8px; padding: 0 12px; outline: none; }
.af-sheet .sh-f textarea, .af-sheet textarea.sh-in { min-height: 70px; height: auto; padding: 10px 12px; resize: vertical; }
.af-sheet .sh-in:focus, .af-sheet .sh-f input:focus, .af-sheet .sh-f select:focus, .af-sheet .sh-f textarea:focus {
  border-color: var(--sh-green-2); background: #fff; box-shadow: 0 0 0 3px rgba(31,107,64,.15); }
.af-sheet select.sh-in, .af-sheet .sh-f select { appearance: none; padding-left: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--sh-muted) 50%), linear-gradient(135deg, var(--sh-muted) 50%, transparent 50%);
  background-position: 16px 19px, 11px 19px; background-size: 5px 5px; background-repeat: no-repeat; }
.af-sheet .sh-f input[type=file] { font-size: 14px; }
.af-sheet .sh-ro { min-height: 44px; display: flex; align-items: center; padding: 0 12px; border-radius: 8px; background: var(--sh-green-soft);
  border: 1.5px dashed #a9cdb8; font-weight: 700; font-size: 16px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.af-sheet .sh-ro.plate { font-family: var(--sh-mono); font-size: 15px; direction: ltr; justify-content: flex-end; }
.af-sheet .sh-ro.empty { color: var(--sh-muted); font-weight: 500; }
.af-sheet .sh-hint { font-size: 12px; color: var(--sh-muted); }
.af-sheet .sh-num { font-variant-numeric: tabular-nums; direction: ltr; text-align: left; }
.af-sheet .errorlist { color: var(--sh-red); font-size: 12.5px; list-style: none; margin: 2px 0 0; padding: 0; }
.af-sheet .sh-errors { background: var(--sh-red-soft); color: var(--sh-red); border-radius: 8px; padding: 10px 14px; font-weight: 700; }
.af-sheet .sh-errors .errorlist { color: inherit; font-size: 14px; }
.af-sheet .related-widget-wrapper { display: flex; gap: 6px; align-items: center; }
.af-sheet .related-widget-wrapper select { flex: 1; min-width: 0; }

/* tables */
.af-sheet .sh-tw { overflow-x: auto; border: 1px solid var(--sh-line); border-radius: 8px; }
.af-sheet table.sh-table { width: 100%; border-collapse: collapse; min-width: 640px; }
.af-sheet table.sh-table.narrow { min-width: 560px; }
.af-sheet .sh-table th { background: var(--sh-green); color: #fff; font-size: 13px; font-weight: 700; text-align: right; padding: 9px 8px; white-space: nowrap; }
.af-sheet .sh-table td { border-top: 1px solid var(--sh-line); padding: 6px 6px; vertical-align: middle; color: var(--sh-ink); }
.af-sheet .sh-table tbody tr:nth-child(even) td { background: #fafcfb; }
.af-sheet .sh-table td.idx { width: 34px; text-align: center; color: var(--sh-muted); font-weight: 700; }
.af-sheet .sh-table td .sh-in, .af-sheet .sh-table td input:not([type=checkbox]), .af-sheet .sh-table td select {
  height: 40px; font-size: 15px; padding: 0 8px; width: 100%; font-family: inherit; color: var(--sh-ink);
  background: var(--sh-field); border: 1.5px solid var(--sh-field-line); border-radius: 8px; }
.af-sheet .sh-table td select { padding-left: 26px; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--sh-muted) 50%), linear-gradient(135deg, var(--sh-muted) 50%, transparent 50%);
  background-position: 13px 17px, 8px 17px; background-size: 5px 5px; background-repeat: no-repeat; }
.af-sheet .sh-table td input[inputmode] { text-align: left; direction: ltr; }
.af-sheet .sh-table td.sum { font-weight: 800; white-space: nowrap; padding-inline: 10px; text-align: left; font-variant-numeric: tabular-nums; direction: ltr; }
.af-sheet .sh-table .errorlist { font-size: 11.5px; }
.af-sheet .sh-cur { font-size: 12px; color: var(--sh-muted); font-weight: 500; margin-inline-start: 3px; }
.af-sheet .sh-table tfoot td { background: var(--sh-green-soft) !important; font-weight: 800; padding: 10px; }
.af-sheet .sh-table tr.sh-locked td { color: var(--sh-muted); }
.af-sheet .sh-table tr.sh-removed { display: none; }
.af-sheet .sh-del { border: 0; background: none; color: var(--sh-red); font-size: 18px; cursor: pointer; width: 32px; height: 32px; border-radius: 6px; }
.af-sheet .sh-del:hover { background: var(--sh-red-soft); }
.af-sheet .sh-add { border: 0; background: none; color: var(--sh-green-2); font: inherit; font-weight: 700; font-size: 15px; cursor: pointer; padding: 10px 4px; }
.af-sheet .sh-add:hover { text-decoration: underline; }

/* bottom: rates + totals */
.af-sheet .sh-bottom { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 360px); gap: 22px; align-items: start; }
.af-sheet .sh-rate { display: grid; gap: 12px; }
.af-sheet .sh-ratebox { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--sh-field);
  border: 1.5px solid var(--sh-field-line); border-radius: 10px; padding: 10px 12px; font-weight: 700; }
.af-sheet .sh-ratebox input { width: 150px !important; height: 40px !important; background: #fff !important; text-align: left; direction: ltr; }
.af-sheet .sh-ratebox + .sh-ratebox { margin-top: 8px; }
.af-sheet .sh-tot { border: 1.5px solid var(--sh-green); border-radius: 10px; overflow: hidden; }
.af-sheet .sh-tot .r { display: flex; justify-content: space-between; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--sh-line); font-size: 15px; }
.af-sheet .sh-tot .r .v { font-weight: 700; font-variant-numeric: tabular-nums; direction: ltr; overflow-wrap: anywhere; }
.af-sheet .sh-tot .r.grand { background: var(--sh-green); color: #fff; font-size: 17px; font-weight: 800; border: 0; }
.af-sheet .sh-tot .r.grand .sh-cur { color: #d7eadf; }
.af-sheet .sh-tot .r.loss { background: var(--sh-red); }
.af-sheet .sh-big { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.af-sheet .sh-big > div { border-radius: 10px; padding: 12px 10px; text-align: center; border: 1.5px solid var(--sh-line); background: #fff; min-width: 0; }
.af-sheet .sh-big small { display: block; font-size: 12px; color: var(--sh-muted); font-weight: 700; }
.af-sheet .sh-big strong { display: block; font-size: clamp(16px, 2.6vw, 22px); font-weight: 800; font-variant-numeric: tabular-nums; direction: ltr; overflow-wrap: anywhere; }
.af-sheet .sh-big .t strong { color: var(--sh-toman); } .af-sheet .sh-big .u strong { color: var(--sh-usd); } .af-sheet .sh-big .i strong { color: var(--sh-iqd); }

/* «تفاصيل إضافية» */
.af-sheet details.sh-more { border: 1px dashed var(--sh-field-line); border-radius: 8px; padding: 0 14px; }
.af-sheet details.sh-more summary { cursor: pointer; padding: 12px 0; font-weight: 700; color: var(--sh-muted); list-style: none; }
.af-sheet details.sh-more summary::-webkit-details-marker { display: none; }
.af-sheet details.sh-more summary::before { content: "＋ "; color: var(--sh-green-2); }
.af-sheet details.sh-more[open] summary::before { content: "－ "; }
.af-sheet details.sh-more .sh-grid { padding-bottom: 14px; }

.af-sheet .sh-sig { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding-top: 8px; }
.af-sheet .sh-sig.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.af-sheet .sh-sig div { border-top: 1px solid var(--sh-ink); padding-top: 6px; text-align: center; font-size: 13px; color: var(--sh-muted); }

/* action bar */
.af-sheet .sh-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-start; padding: 14px 28px; background: #f3f6f4; border-top: 1px solid var(--sh-line); }
.af-sheet .sh-btn { height: 46px; padding: 0 20px; border-radius: 9px; font: inherit; font-size: 16px; font-weight: 700; cursor: pointer;
  border: 1.5px solid var(--sh-green); display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.af-sheet .sh-btn.pri { background: var(--sh-green); color: #fff; }
.af-sheet .sh-btn.pri:hover { background: var(--sh-green-2); }
.af-sheet .sh-btn.sec { background: #fff; color: var(--sh-green); }
.af-sheet .sh-btn.ghost { background: transparent; color: var(--sh-muted); border-color: var(--sh-field-line); }
.af-sheet .sh-btn:focus-visible, .af-sheet .sh-add:focus-visible, .af-sheet .sh-del:focus-visible, .af-sheet summary:focus-visible {
  outline: 3px solid rgba(31,107,64,.35); outline-offset: 2px; }

/* notices inside the sheet */
.af-sheet .sh-alerts { display: grid; gap: 6px; }
.af-sheet .sh-alert { border-radius: 8px; padding: 8px 12px; font-size: 14px; background: #eff6ff; color: #1e40af; }
.af-sheet .sh-alert.alert { background: var(--sh-red-soft); color: var(--sh-red); font-weight: 700; }
.af-sheet .sh-box { display: flex; flex-wrap: wrap; gap: 6px 20px; align-items: center; background: var(--sh-field);
  border: 1px solid var(--sh-line); border-radius: 10px; padding: 10px 14px; font-size: 14px; }
.af-sheet .sh-box a { color: var(--sh-green-2); font-weight: 700; }

/* tabs above the sheet */
.af-sheet-tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--color-base-200, #d5ddd8); }
.af-sheet-tabs a { padding: 9px 16px; border-bottom: 3px solid transparent; font-weight: 700; color: var(--color-base-500, #5d6f66); }
.af-sheet-tabs a.active { border-color: #1f6b40; color: #14532d; }
.dark .af-sheet-tabs a.active { color: #86efac; border-color: #86efac; }
.af-sheet-tabs a .cnt { display: inline-grid; place-items: center; min-width: 20px; height: 20px; border-radius: 999px; background: #b42318; color: #fff; font-size: 11px; margin-inline-start: 4px; padding: 0 5px; }
.af-sheet-tabs a.muted { margin-inline-start: auto; font-weight: 500; font-size: 13px; }

/* voucher */
.af-sheet .sh-ft { display: grid; grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr); gap: 10px; align-items: end; }
.af-sheet .sh-arrow { height: 44px; display: grid; place-items: center; font-size: 24px; color: var(--sh-green); font-weight: 800; pointer-events: none; }
.af-sheet .sh-amt { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 12px; }
.af-sheet .sh-amt input.big-in { height: 52px !important; font-size: 22px !important; font-weight: 800; text-align: left; direction: ltr; }
.af-sheet .sh-seg { display: flex; border: 1.5px solid var(--sh-field-line); border-radius: 8px; overflow: hidden; height: 52px; }
.af-sheet .sh-seg label { flex: 1; display: grid; place-items: center; background: var(--sh-field); font-weight: 700; font-size: 15px; cursor: pointer; color: var(--sh-muted); margin: 0; }
.af-sheet .sh-seg label + label { border-inline-start: 1px solid var(--sh-field-line); }
.af-sheet .sh-seg input { position: absolute; opacity: 0; pointer-events: none; }
.af-sheet .sh-seg label:has(input:checked) { background: var(--sh-green); color: #fff; }
.af-sheet .sh-seg label:has(input:focus-visible) { outline: 3px solid rgba(31,107,64,.35); outline-offset: -3px; }
.af-sheet .sh-sentence { background: var(--sh-green-soft); border: 1.5px solid #a9cdb8; border-radius: 10px; padding: 14px 16px; font-size: 18px; font-weight: 700; line-height: 1.9; }
.af-sheet .sh-sentence .n { font-variant-numeric: tabular-nums; white-space: nowrap; }
.af-sheet .sh-sentence .eq { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.af-sheet .sh-sentence .eq span { background: #fff; border-radius: 999px; padding: 2px 12px; font-size: 15px; border: 1px solid #cfe3d7; }
.af-sheet .sh-auto { font-size: 12px; color: var(--sh-muted); font-weight: 500; }
.af-sheet .sh-kind { display: inline-flex; gap: 6px; align-items: center; background: #fff; border: 1px solid #cfe3d7; border-radius: 999px; padding: 2px 12px; font-size: 13px; color: var(--sh-green); font-weight: 700; }
.af-sheet .sh-kind.err { border-color: #f3b8b1; color: var(--sh-red); background: var(--sh-red-soft); }
.af-sheet [hidden] { display: none !important; }

@media (max-width: 700px) {
  .af-sheet .sh-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .af-sheet .sh-bottom { grid-template-columns: minmax(0, 1fr); }
  .af-sheet .sh-head, .af-sheet .sh-body, .af-sheet .sh-actions { padding-inline: 16px; }
  .af-sheet .sh-doc { justify-items: start; text-align: right; }
  .af-sheet .sh-doc .row { justify-content: flex-start; }
}
@media (max-width: 460px) {
  .af-sheet .sh-grid, .af-sheet .sh-grid.two { grid-template-columns: minmax(0, 1fr); }
  .af-sheet .sh-ft { grid-template-columns: minmax(0, 1fr); }
  .af-sheet .sh-arrow { height: 24px; transform: none; font-size: 0; }      /* 5H: rotating the full-width box covered the fields */
  .af-sheet .sh-arrow::after { content: "↓"; font-size: 24px; }
  .af-sheet .sh-amt { grid-template-columns: minmax(0, 1fr); }
  .af-sheet .sh-big { grid-template-columns: minmax(0, 1fr); }
  .af-sheet .sh-sig { grid-template-columns: minmax(0, 1fr); }
  .af-sheet .sh-btn { flex: 1 1 100%; justify-content: center; }
}

/* print: only the sheet, filling the page (A4 invoice / A5 voucher) */
@media print {
  @page { size: A4; margin: 10mm; }
  body * { visibility: hidden !important; }
  .af-print-root, .af-print-root * { visibility: visible !important; }
  .af-print-root { position: absolute; inset: 0 0 auto 0; margin: 0 !important; max-width: none !important; }
  .af-print-root .af-sheet { box-shadow: none; border-radius: 0; }
  .af-sheet .sh-actions, .af-sheet .sh-noprint, .af-sheet .sh-add, .af-sheet .sh-del, .af-sheet .related-widget-wrapper-link,
  .af-sheet details.sh-more:not([open]) { display: none !important; }
  .af-sheet .sh-in, .af-sheet .sh-f input, .af-sheet .sh-f select, .af-sheet .sh-table td input, .af-sheet .sh-table td select {
    background: transparent !important; border-color: transparent !important; appearance: none; }
  .af-sheet .sh-tw { overflow: visible; }
  .af-sheet table.sh-table { min-width: 0; }
}

/* ===== Phase 5G — ordinary admin change forms rendered as a sheet (core/admin_sheet.SheetFormMixin) ===== */
.af-form-desk { max-width: 1020px; }
.af-form-sheet #content-main > form > .flex { padding: 22px 28px; gap: 18px !important; }
.af-form-sheet fieldset.module { margin: 0; }
.af-form-sheet fieldset.module h2, .af-form-sheet .af-main h2 { color: var(--sh-green); font-weight: 800; font-size: 15px; }
.af-form-sheet .form-rows { display: grid !important; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px;
  border: 0 !important; box-shadow: none !important; overflow: visible !important; background: transparent !important; }
.af-form-sheet .form-rows > .form-row { flex-direction: column !important; align-items: stretch !important; gap: 5px;
  padding: 0 !important; border: 0 !important; min-height: 0 !important; min-width: 0; }
.af-form-sheet .form-rows > .form-row > div:first-child { min-width: 0 !important; width: auto !important; height: auto !important;
  line-height: 1.4 !important; display: block !important; }
.af-form-sheet .form-rows > .form-row > div:first-child label { font-size: 13px !important; font-weight: 700 !important; color: var(--sh-muted) !important; }
.af-form-sheet .form-rows > .form-row:has(textarea), .af-form-sheet .form-rows > .form-row.field-cost_summary,
.af-form-sheet .form-rows > .form-row.field-summary, .af-form-sheet .form-rows > .form-row.field-bridge,
.af-form-sheet .form-rows > .form-row.field-totals_html, .af-form-sheet .form-rows > .form-row.field-alerts_html,
.af-form-sheet .form-rows > .form-row.field-description { grid-column: 1 / -1; }
.af-form-sheet .form-row input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]),
.af-form-sheet .form-row select, .af-form-sheet .form-row textarea {
  min-height: 44px !important; height: 44px; font-size: 16px !important; background: var(--sh-field) !important; color: var(--sh-ink) !important;
  border: 1.5px solid var(--sh-field-line) !important; border-radius: 8px !important; box-shadow: none !important; max-width: none !important; width: 100% !important; }
.af-form-sheet .form-row textarea { height: auto; min-height: 70px !important; padding: 10px 12px !important; }
.af-form-sheet .form-row input:focus, .af-form-sheet .form-row select:focus, .af-form-sheet .form-row textarea:focus {
  border-color: var(--sh-green-2) !important; background: #fff !important; box-shadow: 0 0 0 3px rgba(31,107,64,.15) !important; }
.af-form-sheet .select2-container .select2-selection { min-height: 44px !important; background: var(--sh-field) !important;
  border: 1.5px solid var(--sh-field-line) !important; border-radius: 8px !important; font-size: 16px; }
.af-form-sheet .form-rows .readonly { min-height: 44px; display: flex; align-items: center; flex-wrap: wrap; padding: 6px 12px;
  border-radius: 8px; background: var(--sh-green-soft); border: 1.5px dashed #a9cdb8; font-weight: 700; color: var(--sh-ink); }
.af-form-sheet .related-widget-wrapper { gap: 6px; }
/* «تفاصيل إضافية» = the collapsed fieldset */
.af-form-sheet fieldset.af-more { border: 1px dashed var(--sh-field-line); border-radius: 8px; padding: 0 14px; }
.af-form-sheet fieldset.af-more summary { padding: 12px 0; list-style: none; cursor: pointer; }
.af-form-sheet fieldset.af-more summary::-webkit-details-marker { display: none; }
.af-form-sheet fieldset.af-more summary h2, .af-form-sheet fieldset.af-more summary * { color: var(--sh-muted) !important; font-weight: 700; }
.af-form-sheet fieldset.af-more details > .form-rows { padding-bottom: 14px; }
/* inlines = line tables with the green header */
.af-form-sheet .tabular table thead th, .af-form-sheet table thead th { background: var(--sh-green) !important; color: #fff !important; font-weight: 700; }
.af-form-sheet .tabular td input:not([type=checkbox]), .af-form-sheet .tabular td select { min-height: 40px; font-size: 15px; background: var(--sh-field);
  border: 1.5px solid var(--sh-field-line); border-radius: 8px; }
/* headings inside the sheet are paper-coloured in both themes */
.af-form-sheet, .af-form-sheet label, .af-form-sheet h2, .af-form-sheet td, .af-form-sheet th, .af-form-sheet p { color-scheme: light; }
.dark .af-form-sheet .text-font-important-light, .dark .af-form-sheet .text-important { color: var(--sh-ink) !important; }
.dark .af-form-sheet .bg-white, .dark .af-form-sheet [class*="dark:bg-base-9"] { background: #fff !important; }
@media (max-width: 900px) { .af-form-sheet .form-rows { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .af-form-sheet .form-rows { grid-template-columns: minmax(0, 1fr); }
  .af-form-sheet #content-main > form > .flex { padding: 16px; } }

/* phone: wide tables scroll inside their own box instead of widening the sheet */
.af-desk, .af-desk > *, .af-sheet, .af-sheet .sh-body, .af-sheet .sh-body > *, .af-sheet section, .af-sheet .sh-bottom > *,
.af-sheet .sh-rate > * { min-width: 0; max-width: 100%; }
.af-sheet .sh-tw { max-width: 100%; -webkit-overflow-scrolling: touch; }
.af-sheet input[type=file] { max-width: 100%; }

/* Arabic file picker («اختر صورة الوصل») instead of the browser's default button text */
.af-sheet .sh-file { position: relative; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; cursor: pointer; margin: 0; }
.af-sheet .sh-file input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.af-sheet .sh-file .sh-btn { height: 44px; font-size: 15px; }
.af-sheet .sh-file input:focus-visible + .sh-btn { outline: 3px solid rgba(31,107,64,.35); outline-offset: 2px; }
.af-sheet .sh-file-name { font-size: 13px; color: var(--sh-muted); overflow-wrap: anywhere; }

/* ===== Phase 5H — no dropdowns: type-to-search, segmented buttons, typed dates (mockup tokens) ===== */
.af-pick { position: relative; width: 100%; min-width: 0; }
.af-pick-input, .af-date { height: 44px !important; width: 100%; font: inherit; font-size: 16px !important; color: var(--sh-ink) !important;
  background: var(--sh-field) !important; border: 1.5px solid var(--sh-field-line) !important; border-radius: 8px !important;
  padding: 0 36px 0 12px !important; outline: none; box-shadow: none !important; }
.af-date { padding: 0 12px !important; direction: ltr; text-align: right; }
.af-pick-input:focus, .af-date:focus { border-color: var(--sh-green-2) !important; background: #fff !important;
  box-shadow: 0 0 0 3px rgba(31,107,64,.15) !important; }
.af-pick-icon { position: absolute; inset-inline-start: 12px; top: 0; height: 44px; display: grid; place-items: center;
  color: var(--sh-muted); pointer-events: none; font-size: 18px; }
.af-pick.multi .af-pick-icon { top: auto; bottom: 0; }
.af-pick-list { position: absolute; z-index: 60; inset-inline: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none;
  background: #fff; border: 1.5px solid var(--sh-field-line); border-radius: 10px; box-shadow: 0 10px 30px rgba(20,50,35,.18);
  max-height: 280px; overflow-y: auto; color: var(--sh-ink); text-align: right; }
.af-pick-list li { padding: 9px 12px; border-radius: 7px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; font-size: 15px; }
.af-pick-list li small { color: var(--sh-muted); font-size: 12px; }
.af-pick-list li.active, .af-pick-list li:hover { background: var(--sh-green-soft); }
.af-pick-list li[aria-selected="true"] b::after { content: " ✓"; color: var(--sh-green-2); }
.af-pick-list li.none { color: var(--sh-muted); cursor: default; background: none; }
.af-pick-list li.add { color: var(--sh-green-2); font-weight: 800; }
.af-pick-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.af-pick-tag { display: inline-flex; align-items: center; gap: 4px; background: var(--sh-green-soft); color: var(--sh-green);
  border: 1px solid #a9cdb8; border-radius: 999px; padding: 2px 4px 2px 10px; font-size: 14px; font-weight: 700; }
.af-pick-x { border: 0; background: none; color: var(--sh-red); font-size: 16px; cursor: pointer; width: 24px; height: 24px; border-radius: 50%; }
.af-pick.disabled .af-pick-input { opacity: .7; }
.af-seg { display: inline-flex; flex-wrap: wrap; max-width: 100%; border: 1.5px solid var(--sh-field-line); border-radius: 8px;
  overflow: hidden; background: var(--sh-field); }
.af-seg-opt { position: relative; margin: 0; cursor: pointer; display: flex; }
.af-seg-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.af-seg-opt span { min-height: 42px; min-width: 52px; padding: 0 16px; display: grid; place-items: center; font-weight: 700; font-size: 15px;
  color: var(--sh-muted); white-space: nowrap; }
.af-seg-opt + .af-seg-opt span { border-inline-start: 1px solid var(--sh-field-line); }
.af-seg-opt input:checked + span { background: var(--sh-green); color: #fff; }
.af-seg-opt input:focus-visible + span { outline: 3px solid rgba(31,107,64,.35); outline-offset: -3px; }
.af-seg.disabled { opacity: .7; pointer-events: none; }
.af-sheet .sh-table td .af-seg-opt span { min-height: 38px; min-width: 40px; padding: 0 9px; font-size: 13.5px; }
.af-sheet .sh-table td .af-pick-input { height: 40px !important; font-size: 15px !important; }
.af-date-cal { border: 0; background: none; cursor: pointer; font-size: 16px; margin-inline-start: -38px; width: 34px; height: 40px; vertical-align: middle; }
.af-date-bad { border-color: var(--sh-red) !important; }
.dark .af-pick-input, .dark .af-date { color-scheme: light; }
@media (max-width: 640px) {
  .af-pick-list { inset-inline: 0; max-height: 50vh; }      /* fields are full width on phone, so is the list */
  .af-pick-list li { padding: 12px; }
  .af-seg { display: flex; overflow-x: auto; flex-wrap: nowrap; }
}

/* ===== Phase 5H — smart bar above every list (replaces the filter dropdowns) ===== */
.af-smart-list #changelist-filter, .af-smart-list [x-data*="filterOpen"] > aside, .af-smart-list .changelist-filter,
.af-smart-list #changelist-search { display: none !important; }
.af-smart { display: grid; gap: 10px; margin-bottom: 14px; }
.af-smart-form { position: relative; }
.af-smart-q { height: 48px; width: 100%; font: inherit; font-size: 16px; color: var(--sh-ink); background: var(--sh-field);
  border: 1.5px solid var(--sh-field-line); border-radius: 10px; padding: 0 44px 0 14px; outline: none; }
.af-smart-q:focus { border-color: var(--sh-green-2); background: #fff; box-shadow: 0 0 0 3px rgba(31,107,64,.15); }
.af-smart-icon { position: absolute; inset-inline-start: 14px; top: 0; height: 48px; display: grid; place-items: center;
  color: var(--sh-muted); font-size: 20px; pointer-events: none; }
.af-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.af-chip-btn { display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 999px; font-size: 14px;
  font-weight: 700; border: 1.5px solid var(--sh-field-line); background: var(--sh-field); color: var(--sh-muted); white-space: nowrap; }
.af-chip-btn:hover { border-color: var(--sh-green-2); color: var(--sh-green); }
.af-chip-btn.on { background: var(--sh-green); border-color: var(--sh-green); color: #fff; }
.af-chip-btn.on::before { content: "✓ "; }
.af-tags { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.af-tag { display: inline-flex; gap: 4px; align-items: center; background: var(--sh-green-soft); color: var(--sh-green); border: 1px solid #a9cdb8;
  border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 700; }
.af-tag span { color: var(--sh-red); }
.af-tag.q { background: #fff; }
.af-clear { color: var(--sh-red); font-weight: 700; font-size: 13px; margin-inline-start: 4px; }
.dark .af-smart-q { color-scheme: light; }
.dark .af-chip-btn:not(.on) { background: rgb(255 255 255 / .04); color: var(--color-base-300, #cbd5e1); border-color: var(--color-base-700, #374151); }
.htmx-request #changelist, #changelist.htmx-swapping { opacity: .55; transition: opacity .15s; }
@media (max-width: 640px) {
  .af-chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .af-chips::-webkit-scrollbar { display: none; }
}
/* 5H layout fixes: the header date stays compact; segmented buttons in table rows stay on one line */
.af-sheet .sh-doc .row .af-date { width: 9.5em !important; height: 34px !important; font-size: 14px !important; display: inline-block; }
.af-sheet .sh-doc .row .af-date-cal { height: 34px; margin-inline-start: -36px; }
.af-sheet .sh-table td .af-seg { flex-wrap: nowrap; }
.af-sheet .sh-table td .af-seg-opt span { padding: 0 8px; min-width: 0; }
.af-sheet .sh-table td:has(.af-seg) { min-width: 0; }
/* phone: the one-line chip row scrolls inside the bar instead of widening the page */
.af-smart, .af-smart > *, .af-chips-wrap, .af-chips { min-width: 0; max-width: 100%; }

/* ===== Phase 5I — Fruity PDF import result ===== */
.fr-cards { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.fr-card { border: 1.5px solid var(--sh-line); border-radius: 10px; padding: 12px; display: grid; gap: 2px; text-align: center; background: #fff; }
.fr-card span { color: var(--sh-muted); font-weight: 700; font-size: 13px; }
.fr-card b { font-size: 26px; font-variant-numeric: tabular-nums; }
.fr-card.ok b { color: #15803d; } .fr-card.diff b { color: #b42318; } .fr-card.miss b { color: #a15c07; } .fr-card.fruity b { color: #1e40af; }
.fr-card.on { border-color: var(--sh-green); box-shadow: 0 0 0 3px rgba(31,107,64,.15); }
.af-sheet .fr-table td { vertical-align: top; font-size: 13.5px; }
.af-sheet .fr-table td.fr-stmt { min-width: 220px; white-space: normal; }
.fr-money { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.fr-money span { background: #f3e8ff; color: #6b21a8; border-radius: 999px; padding: 0 8px; font-size: 12px; font-weight: 700; }
.fr-status { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.fr-status.ok { background: #dcfce7; color: #166534; } .fr-status.diff { background: #fde8e6; color: #b42318; }
.fr-status.miss { background: #fdf1dc; color: #a15c07; } .fr-status.info { background: #eef2ff; color: #3730a3; }
.af-sheet .fr-table tr.fr-diff td { background: #fff7f6 !important; } .af-sheet .fr-table tr.fr-miss td { background: #fffaf0 !important; }
.fr-actions { white-space: nowrap; }
.af-sheet .fr-btn { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.fr-ignore { display: inline-block; } .fr-ignore summary { list-style: none; display: inline-flex; }
.fr-ignore summary::-webkit-details-marker { display: none; }
.fr-ignore form { display: flex; gap: 6px; margin-top: 6px; } .fr-ignore .sh-in { height: 34px; width: 160px; font-size: 14px; }
.fr-link { color: var(--sh-green-2); font-weight: 700; }
@media (max-width: 700px) { .fr-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.af-sheet .fr-table { min-width: 980px; }
.af-sheet .fr-table td.fr-kind { white-space: nowrap; }
.af-sheet .fr-table td.idx { width: 30px; }
.fr-actions { display: flex; flex-direction: column; gap: 4px; align-items: stretch; min-width: 70px; }
.fr-ignore form { flex-direction: column; position: relative; }
.fr-ignore[open] { background: #fff; }

/* ===== Phase 5J — info pills, status steps, month stepper, hub cards, rate boxes, name cells ===== */
.af-sheet .sh-info { display: flex; gap: 8px; flex-wrap: wrap; }
.af-sheet .sh-info span { background: var(--sh-field); border: 1px solid var(--sh-line); border-radius: 999px; padding: 3px 12px; font-size: 13px; font-weight: 700; }
.af-sheet .sh-info span.warn { background: var(--sh-amber-soft); color: var(--sh-amber); border-color: #f2d7a6; }
.af-sheet .sh-steps { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.af-sheet .sh-step { font-size: 13px; font-weight: 700; padding: 4px 12px; border-radius: 999px; background: var(--sh-field); color: var(--sh-muted); }
.af-sheet .sh-step.on { background: var(--sh-green); color: #fff; }
.af-sheet .sh-month { display: flex; align-items: center; gap: 8px; max-width: 380px; }
.af-sheet .sh-month button { width: 44px; height: 44px; border-radius: 8px; border: 1.5px solid var(--sh-field-line); background: #fff; font-size: 18px; cursor: pointer; color: var(--sh-green); }
.af-sheet .sh-month .sh-ro { flex: 1; justify-content: center; font-size: 18px; }
.af-sheet .sh-hub { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.af-sheet .sh-hub a { border: 1.5px solid var(--sh-line); border-radius: 10px; padding: 14px; background: #fff; color: var(--sh-ink); display: block; }
.af-sheet .sh-hub a:hover { border-color: var(--sh-green-2); }
.af-sheet .sh-hub b { display: block; font-size: 16px; }
.af-sheet .sh-hub small { color: var(--sh-muted); font-size: 13px; }
.af-sheet .sh-hub em { font-style: normal; float: left; font-weight: 800; color: var(--sh-green); font-size: 20px; }
.af-sheet .sh-rates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.af-sheet .sh-rates .r { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 800; font-size: 17px; background: var(--sh-field); border: 1.5px solid var(--sh-field-line); border-radius: 10px; padding: 10px 12px; }
.af-sheet .sh-rates .r input { width: 150px !important; height: 42px !important; background: #fff !important; font-weight: 800; text-align: left; direction: ltr; }
.af-sheet .sh-table td.name { font-weight: 700; white-space: nowrap; }
.af-sheet .sh-table td.name small { display: block; font-weight: 500; color: var(--sh-muted); font-size: 12px; }
.af-sheet .sh-table td.act a { color: var(--sh-green-2); font-weight: 700; font-size: 13px; }
.af-sheet .sh-tag { font-size: 11px; font-weight: 800; border-radius: 6px; padding: 1px 6px; background: #e8f0fb; color: #1d4f91; margin-inline-start: 4px; }
.af-sheet .sh-note { font-size: 13px; color: var(--sh-muted); background: #fff; border-inline-start: 4px solid var(--sh-green); padding: 8px 12px; border-radius: 6px; }
.af-sheet .sh-table tr.sh-click { cursor: pointer; }
.af-sheet .sh-table tr.sh-click:hover td { background: var(--sh-green-soft) !important; }
@media (max-width: 700px) { .af-sheet .sh-hub { grid-template-columns: repeat(2, minmax(0, 1fr)); } .af-sheet .sh-rates { grid-template-columns: minmax(0, 1fr); } }
.af-smart.with-add { grid-template-columns: minmax(0, 1fr) auto; }
.af-smart.with-add > .af-chips-wrap { grid-column: 1 / -1; }
.af-smart-add { order: 2; height: 48px; padding: 0 20px; border-radius: 10px; background: var(--sh-green); color: #fff !important;
  font-weight: 800; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; }
.af-smart-add:hover { background: var(--sh-green-2); }
@media (max-width: 640px) { .af-smart.with-add { grid-template-columns: minmax(0, 1fr); } .af-smart-add { order: 0; } }
/* 5J employee card on the admin change form */
.af-card .af-card-body { display: grid; gap: 14px; }
.af-card .af-card-more { margin-top: 4px; }
.af-card .af-card-inline { margin: 10px 0 14px; display: grid; gap: 8px; }
.af-card .af-salary-change summary { list-style: none; display: inline-flex; margin: 6px 0; }
.af-card .af-salary-change summary::-webkit-details-marker { display: none; }
.af-card .af-card-links { font-size: 14px; }
.af-card .sh-amt input.big-in { height: 52px !important; font-size: 22px !important; font-weight: 800; text-align: left; direction: ltr; }
/* 5J payroll run sheet */
.af-run .af-run-top { display: grid; gap: 12px; }
.af-run .af-pay-table { min-width: 0; table-layout: auto; }
.af-run .af-pay-table td input.sm, .af-run .af-pay-table td .sh-in.sm { width: 96px !important; height: 38px !important; }
.af-run .af-pay-table td.name { white-space: normal; min-width: 150px; }
.af-run .af-line-more summary { list-style: none; cursor: pointer; color: var(--sh-ink); font-weight: 800; }
.af-run .af-line-more summary::-webkit-details-marker { display: none; }
.af-run .af-line-more summary::after { content: " ▾"; color: var(--sh-green-2); font-size: 11px; }
.af-run .af-pop { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 6px 0; padding: 8px; border: 1px dashed var(--sh-field-line); border-radius: 8px; background: #fff; }
.af-run .af-pop .sh-lbl { font-size: 11px; }
.af-run .af-pop input { width: 100% !important; height: 34px !important; }
.af-run .af-why { display: none; margin-top: 4px; } .af-run .af-why.on { display: block; }
.af-run .af-why input { height: 34px !important; font-size: 13px !important; width: 150px !important; }
/* 5J «القوائم»: one row = one inline form (name + 1–2 fields + فعّال + حفظ) */
.af-sheet .af-list { display: grid; gap: 6px; }
.af-sheet .af-list-row { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)) 96px; gap: 8px; align-items: center;
  padding: 6px; border: 1px solid var(--sh-line); border-radius: 8px; background: #fff; }
.af-sheet .af-list-row.head { background: var(--sh-green); color: #fff; font-weight: 700; font-size: 13px; border: 0; }
.af-sheet .af-list-row.new { background: var(--sh-green-soft); }
.af-sheet .af-list-row.off { opacity: .6; }
.af-sheet .af-list-cell { min-width: 0; }
.af-sheet .af-list-cell input[type=text], .af-sheet .af-list-cell .sh-in, .af-sheet .af-list-cell .af-pick-input { height: 40px !important; width: 100%; }
.af-sheet .af-list-row .sh-btn { height: 40px; justify-content: center; padding: 0 10px; }
.af-sheet .af-list-err { grid-column: 1 / -1; color: var(--sh-red); font-size: 13px; }
@media (max-width: 700px) { .af-sheet .af-list-row { grid-template-columns: minmax(0, 1fr); } .af-sheet .af-list-row.head { display: none; } }
/* 5J user card / settings */
.af-sheet .af-stop { display: inline-block; } .af-sheet .af-stop summary { list-style: none; }
.af-sheet .af-stop summary::-webkit-details-marker { display: none; }
.af-sheet .af-stop-box { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.af-sheet .af-danger { border: 2px solid #b42318; border-radius: 10px; padding: 14px; display: grid; gap: 8px; background: #fff7f6; }
.af-sheet .af-danger b { color: #b42318; font-size: 16px; }
.af-sheet .af-danger .sh-btn { border-color: #b42318; color: #fff; background: #b42318; justify-self: start; }
/* 5J: date input + calendar icon as one box; «＋ جديد» beside the search box */
.af-date-wrap { position: relative; display: block; width: 100%; min-width: 0; }
.sh-doc .row .af-date-wrap { display: inline-block; width: auto; }
.af-date-wrap .af-date { padding-left: 46px !important; padding-right: 12px !important; width: 100%; }
.af-date-wrap .af-date-cal { position: absolute !important; left: 6px !important; right: auto !important; top: 50%;
  transform: translateY(-50%); margin: 0 !important; height: 32px; width: 32px; z-index: 1; }
.af-smart.with-add > .af-smart-form { grid-column: 1; grid-row: 1; }
.af-smart.with-add > .af-smart-add { grid-column: 2; grid-row: 1; }
.af-smart.with-add > .af-chips-wrap { grid-row: 2; }
@media (max-width: 640px) { .af-smart.with-add > .af-smart-form, .af-smart.with-add > .af-smart-add { grid-column: 1; grid-row: auto; } }
.sh-rates-hist th.sum, .sh-table th.sum { text-align: left; }
@media (max-width: 640px) { .af-sheet .inline-group, .af-sheet .tabular { overflow-x: auto; max-width: 100%; } }
/* 5J follow-up: save bar inside the sheet (employee, party, payroll run) — like the truck invoice's sh-actions */
.af-sheet-savebar { position: static !important; margin: 0; }
.af-sheet-savebar .af-savebar-in { background: #f3f6f4; border-top: 1px solid var(--sh-line); padding: 14px 28px;
  border-radius: 0 0 10px 10px; }
.af-sheet-savebar .af-savebar-row { width: 100%; }
.af-sheet-savebar .af-reason-wrap { min-width: 220px; }
@media (max-width: 640px) { .af-sheet-savebar .af-savebar-in { padding: 14px 16px; } }
/* UI fix 6: trip-expense rows — rate box hidden for dinar; the currency buttons stay one compact line inside their
   cell (the formset wrapper scrolls sideways if the screen is narrow — nothing overlaps) */
.af-rate-off > * { visibility: hidden; }
.formset-wrapper td .af-seg { flex-wrap: nowrap; min-width: max-content; }
.formset-wrapper td .af-seg-opt span { padding: 0 10px; font-size: 13px; white-space: nowrap; }
.formset-wrapper td .af-pick { position: relative; min-width: 140px; }
.formset-wrapper td .af-pick-list { z-index: 60; }
/* on phones each trip-expense row is a small card (fields stacked) */
@media (max-width: 640px) {
  .model-trip .formset-wrapper table, .model-trip .formset-wrapper tbody,
  .model-trip .formset-wrapper tr.form-row, .model-trip .formset-wrapper tr.form-row > td { display: block; width: 100%; }
  .model-trip .formset-wrapper thead, .model-trip .formset-wrapper tr.form-row > td:empty { display: none; }
  .model-trip .formset-wrapper tr.form-row { border-bottom: 1px solid var(--sh-line, #e5e7eb); padding: 8px 0; }
  .model-trip .formset-wrapper tr.form-row > td { padding: 4px 12px !important; min-width: 0 !important; min-height: 0 !important; border: 0 !important; }
  .model-trip .formset-wrapper td .af-seg { width: 100%; min-width: 0; }
  .model-trip .formset-wrapper td .af-seg-opt { flex: 1 1 0; }
  .model-trip .formset-wrapper tbody.empty-form { display: none !important; }   /* Unfold's hidden «add row» template */
  .model-trip .formset-wrapper td.af-rate-off { display: none !important; }      /* dinar: no empty gap */
}

/* ── Phase 5K: toman screens (mockup docs/mockups/toman_transfers.html) ───────────────────────────────── */
.af-sheet .tm, .af-sheet input.tm { color: var(--sh-toman) !important; }
.af-sheet .iq, .af-sheet input.iq { color: var(--sh-iqd) !important; }
.af-sheet .sh-badge.wait { background: var(--sh-amber-soft); color: var(--sh-amber); }
.af-sheet .sh-badge.wait::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--sh-amber); display: inline-block; margin-inline-end: 6px; }
.af-sheet .sh-badge.late { background: #fde8e6; color: #b42318; }
.sh-prog { display: grid; gap: 6px; }
.sh-prog .row3 { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 14px; font-weight: 700; }
.sh-bar { height: 14px; border-radius: 999px; background: #eee6f3; overflow: hidden; }
.sh-bar i { display: block; height: 100%; background: var(--sh-toman); border-radius: 999px; }
.sh-mini { width: 100%; border-collapse: collapse; font-size: 14px; }
.sh-mini td { padding: 6px 4px; border-top: 1px solid var(--sh-line); }
.sh-mini td:last-child { text-align: left; font-weight: 700; direction: ltr; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sh-doclink { font-family: "IBM Plex Mono", ui-monospace, Consolas, monospace; font-size: 13px; color: var(--sh-green-2, #1f6b40); direction: ltr; display: inline-block; }
.sh-chip { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; background: var(--sh-green-soft, #e8f2ec);
  border: 1.5px solid #a9cdb8; border-radius: 8px; padding: 8px 12px; font-size: 14px; }
.sh-chip b { direction: ltr; }
.sh-drop { border: 2px dashed var(--sh-field-line); border-radius: 10px; padding: 14px; display: flex; gap: 14px; align-items: center;
  background: var(--sh-field); cursor: pointer; flex-wrap: wrap; }
.sh-drop .ph { width: 64px; height: 84px; border-radius: 6px; background: linear-gradient(#fff, #f1eef5); border: 1px solid var(--sh-line);
  display: grid; place-items: center; font-size: 11px; color: var(--sh-muted); text-align: center; flex: none; }
.sh-drop input[type=file] { max-width: 100%; }
.sh-effect { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.sh-effect > div { border: 1.5px solid var(--sh-line); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.sh-effect small { display: block; color: var(--sh-muted); font-weight: 700; font-size: 12px; }
.sh-effect .ba { font-weight: 800; font-variant-numeric: tabular-nums; direction: ltr; text-align: right; font-size: 15px; overflow-wrap: anywhere; }
.sh-effect .ba s { color: var(--sh-muted); font-weight: 500; }
.sh-note-y { background: var(--sh-amber-soft); border-radius: 8px; padding: 8px 12px; font-size: 13px; color: #6b3d00; }
.sh-headline { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.sh-headline > div { border-radius: 10px; padding: 14px; text-align: center; border: 1.5px solid var(--sh-line); min-width: 0; }
.sh-headline small { display: block; font-size: 13px; color: var(--sh-muted); font-weight: 700; }
.sh-headline strong { display: block; font-size: clamp(17px, 3vw, 26px); font-weight: 800; direction: ltr; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.sh-headline .due { background: var(--sh-toman); border-color: var(--sh-toman); color: #fff; }
.sh-headline .due small { color: #eadcf3; }
.sh-big { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.sh-big > div { border-radius: 10px; padding: 12px 10px; text-align: center; border: 1.5px solid var(--sh-line); background: #fff; min-width: 0; }
.sh-big small { display: block; font-size: 12px; color: var(--sh-muted); font-weight: 700; }
.sh-big strong { display: block; font-size: clamp(15px, 2.4vw, 20px); font-weight: 800; font-variant-numeric: tabular-nums; direction: ltr; overflow-wrap: anywhere; }
.sh-big .t strong { color: var(--sh-toman); } .sh-big .u strong { color: var(--sh-green); } .sh-big .i strong { color: var(--sh-iqd); }
.af-sheet table.led td { padding: 8px; }
.af-sheet table.led td.n { text-align: left; direction: ltr; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 700; }
.af-sheet table.led tr.carry td { background: #f3f6f4 !important; color: var(--sh-muted); font-weight: 700; }
.af-sheet tr.open td { background: #fff8ec !important; }
.af-sheet tr.late td { background: #fdf0ee !important; }
.af-sheet .gain { color: var(--sh-green); font-weight: 800; } .af-sheet .loss { color: #b42318; font-weight: 800; }
.af-sheet .sh-eq-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.af-sheet .sh-eq-chips span { background: #fff; border-radius: 999px; padding: 2px 12px; font-size: 15px; border: 1px solid #cfe3d7; }
.af-sheet .sh-filter { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.af-sheet .sh-filter .sh-f { min-width: 140px; }
@media (max-width: 700px) { .sh-headline, .sh-effect { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 460px) { .sh-big { grid-template-columns: minmax(0, 1fr); } }
@media print { .af-sheet .sh-filter, .sh-noprint { display: none !important; } }
.af-sheet input.big-in { height: 52px !important; font-size: 22px !important; font-weight: 800; text-align: left; direction: ltr; }

/* ── Truck invoice v2 — plain paper invoice (docs/mockups/truck_invoice_v2.html) ──────────────────────────── */
.inv2 { --inv-desk: #e4e9e6; --inv-paper: #fffefb; --inv-ink: #17251e; --inv-muted: #62736a; --inv-rule: #cfd9d3;
  --inv-green: #14532d; --inv-green-soft: #eef5f0; --inv-focus: #fff8e1;
  font-family: Tajawal, Tahoma, "Segoe UI", Arial, sans-serif; font-size: 16px; line-height: 1.5; color: var(--inv-ink);
  display: grid; gap: 18px; max-width: 820px; margin: 0 auto; min-width: 0; }
.inv2 [data-pages] { display: grid; gap: 18px; min-width: 0; }
.inv-sheet { background: var(--inv-paper); padding: 14px; box-shadow: 0 8px 28px rgba(20,50,35,.15); min-width: 0; }
.inv-frame { border: 2px solid var(--inv-green); outline: 1px solid var(--inv-green); outline-offset: -6px;
  padding: 26px 26px 20px; display: grid; gap: 20px; min-width: 0; }
.inv-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap;
  border-bottom: 2px solid var(--inv-green); padding-bottom: 14px; }
.inv-co { display: flex; align-items: center; gap: 12px; }
.inv-logo { width: 44px; height: 44px; border-radius: 10px; flex: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.inv-co h1 { margin: 0; font-size: 26px; font-weight: 800; color: var(--inv-green); }
.inv-co div { color: var(--inv-muted); font-size: 14px; }
.inv-title { text-align: left; }
.inv-title h2 { margin: 0; font-size: 24px; font-weight: 800; }
.inv-title > div { font-size: 15px; color: var(--inv-muted); }
.inv-title b { color: var(--inv-ink); font-variant-numeric: tabular-nums; }
.inv-title input { height: 34px; border: 0; border-bottom: 1.5px solid var(--inv-ink); background: transparent; font: inherit;
  font-size: 15px; color: var(--inv-ink); width: 150px; }
.inv-pg { font-size: 13px !important; }
.inv-info { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 28px; }
.inv-line { display: flex; align-items: center; gap: 10px; min-width: 0; }
.inv-line > label, .inv-line > .inv-lbl { font-weight: 700; white-space: nowrap; min-width: 92px; }
.inv-in { flex: 1; min-width: 0; }
.inv2 .inv-in input:not([type=hidden]), .inv2 .inv-in .af-pick-input, .inv2 .inv-line select {
  width: 100%; min-width: 0; height: 42px !important; border: 0 !important; border-bottom: 1.5px solid var(--inv-ink) !important;
  border-radius: 0 !important; background: transparent !important; font: inherit; font-size: 17px !important; padding: 0 4px !important;
  color: var(--inv-ink); box-shadow: none !important; }
.inv2 .inv-in .af-pick { width: 100%; }
.inv2 .inv-in .related-widget-wrapper { display: flex; gap: 6px; align-items: center; }
.inv-auto { flex: 1; min-width: 0; border-bottom: 1.5px dotted var(--inv-muted); height: 42px; display: flex; align-items: center;
  padding: 0 4px; color: var(--inv-muted); font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inv2 input:focus, .inv2 select:focus, .inv2 textarea:focus, .inv2 .af-pick-input:focus { outline: none !important; background: var(--inv-focus) !important; }
.inv-tw { overflow-x: auto; min-width: 0; }
.inv-table { width: 100%; border-collapse: collapse; min-width: 560px; }
.inv-table th { background: var(--inv-green); color: #fff; font-weight: 700; font-size: 15px; padding: 9px 6px; border: 1px solid var(--inv-green); text-align: right; }
.inv-table td { border: 1px solid var(--inv-rule); padding: 0; height: 42px; vertical-align: middle; }
.inv-table td.n { width: 40px; text-align: center; color: var(--inv-muted); font-weight: 700; background: var(--inv-green-soft); }
.inv-table td.ro { padding: 0 8px; color: var(--inv-muted); }
.inv2 .inv-table td input:not([type=hidden]), .inv2 .inv-table td select, .inv2 .inv-table td .af-pick-input {
  width: 100%; height: 42px !important; border: 0 !important; border-radius: 0 !important; background: transparent !important;
  font: inherit; font-size: 16px !important; padding: 0 8px !important; color: var(--inv-ink); box-shadow: none !important; min-width: 0; }
.inv2 .inv-table td select { cursor: pointer; }
.inv2 .inv-table td .af-pick { width: 100%; }
.inv2 .inv-table td .related-widget-wrapper-link, .inv2 .inv-table td .af-pick-add { display: none; }
.inv2 .num, .inv2 .inv-table td input[inputmode] { text-align: left; direction: ltr; font-variant-numeric: tabular-nums; }
.inv-table td.sum { padding: 0 10px; font-weight: 700; white-space: nowrap; }
.inv-table .c-item { width: 34%; } .inv-table .c-unit { width: 12%; } .inv-table .c-q { width: 12%; }
.inv-table .c-p { width: 18%; } .inv-table .c-s { width: 20%; }
.inv-table tfoot td { height: 52px; background: var(--inv-green-soft); font-weight: 800; font-size: 18px; padding: 0 10px; border-color: var(--inv-green); }
.inv-table tfoot td.sum { font-size: 20px; color: var(--inv-green); }
.inv-cap { font-weight: 800; font-size: 17px; margin: 0 0 8px; color: var(--inv-green); }
.inv-exp { border: 1.5px dashed var(--inv-rule); padding: 10px 12px; display: flex; justify-content: space-between; align-items: center;
  gap: 10px; flex-wrap: wrap; }
.inv-foot { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: end; }
.inv-note textarea { width: 100%; min-height: 64px; border: 1px solid var(--inv-rule); background: transparent; font: inherit; font-size: 16px; padding: 8px; resize: vertical; }
.inv-note .inv-cap { display: block; }
.inv-grand { border: 2px solid var(--inv-green); text-align: center; padding: 12px; }
.inv-grand small { display: block; font-weight: 700; color: var(--inv-muted); }
.inv-grand strong { display: block; font-size: clamp(22px, 4vw, 30px); font-weight: 800; color: var(--inv-green); font-variant-numeric: tabular-nums; direction: ltr; overflow-wrap: anywhere; }
.inv-sig { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; padding-top: 26px; }
.inv-sig div { border-top: 1px solid var(--inv-ink); text-align: center; padding-top: 4px; font-size: 14px; color: var(--inv-muted); }
.inv-bar { display: flex; gap: 10px; flex-wrap: wrap; }
.inv-btn { height: 48px; padding: 0 22px; border-radius: 8px; font: inherit; font-size: 17px; font-weight: 700; cursor: pointer; border: 1.5px solid var(--inv-green, #14532d); }
.inv-btn.pri { background: var(--inv-green, #14532d); color: #fff; } .inv-btn.sec { background: #fff; color: var(--inv-green, #14532d); }
.inv-btn:focus-visible, .inv-add:focus-visible, .inv-del:focus-visible { outline: 3px solid rgba(20,83,45,.35); outline-offset: 2px; }
.inv-errors { background: #fde8e6; color: #b42318; padding: 8px 12px; font-weight: 700; }
.inv-errors ul { margin: 0; padding-inline-start: 18px; }
.inv2 .errorlist { color: #b42318; font-size: 13px; margin: 0; padding: 0 8px; list-style: none; }
.inv2 tr.af-row-error > td { background: #fef2f2 !important; }
.inv-locked td { color: var(--inv-muted); }
/* the expenses modal */
.inv-modal { position: fixed; inset: 0; z-index: 1000; background: rgba(20,35,28,.45); display: grid; place-items: center; padding: 16px; }
.inv-modal[hidden] { display: none; }
.inv-dialog { background: var(--inv-paper); width: min(760px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 20px;
  border: 2px solid var(--inv-green); box-shadow: 0 16px 48px rgba(0,0,0,.3); }
.inv-modal-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.inv-add { border: 0; background: none; color: var(--inv-green); font: inherit; font-weight: 700; font-size: 16px; cursor: pointer; padding: 10px 4px; }
.inv-del { border: 0; background: none; color: #b42318; font-size: 20px; cursor: pointer; width: 36px; height: 36px; }
.inv2 tr.inv-removed { display: none; }
@media (max-width: 640px) {
  .inv-frame { padding: 16px 12px; }
  .inv-info, .inv-foot { grid-template-columns: minmax(0, 1fr); }
  .inv-title { text-align: right; }
  .inv-btn { flex: 1 1 100%; }
  .inv-sheet { padding: 8px; }
}
@media print {
  @page { size: A4; margin: 8mm; }
  .inv2 .inv-bar, .inv-modal, .af-sheet-tabs, .inv-exp .inv-btn { display: none !important; }
  .inv-sheet { box-shadow: none; padding: 0; page-break-after: always; break-after: page; }
  .inv-sheet:last-child { page-break-after: auto; break-after: auto; }
  .inv2 .inv-tw { overflow: visible; }
  .inv2 .inv-table { min-width: 0; }
  .inv2 input, .inv2 select, .inv2 textarea, .inv2 .af-pick-input { background: transparent !important; appearance: none; -webkit-appearance: none; }
  .inv2 .inv-table tr[data-row]:not(.filled) td select, .inv2 .inv-table tr[data-row]:not(.filled) td input { color: transparent !important; }
  .inv2 .inv-table td select { background-image: none !important; }
  .inv2 .af-pick-icon, .inv2 .af-date-cal { display: none !important; }
  .inv2 .inv-table td input.af-pick-input:not([type=hidden]), .inv2 .inv-in input.af-pick-input:not([type=hidden]) {
    padding-inline-start: 8px !important; }
  .inv2 .af-pick-input::placeholder, .inv2 input::placeholder { color: transparent; }
  .inv2 .errorlist, .inv2 .related-widget-wrapper-link { display: none !important; }
}
/* v2 fixes after comparing with the mockup: room for the search icon, the date as an underlined line, no «＋» */
.inv2 .inv-table td input.af-pick-input:not([type=hidden]), .inv2 .inv-in input.af-pick-input:not([type=hidden]) {
  padding-inline-start: 34px !important; }
.inv2 .af-pick-icon { inset-inline-start: 6px; height: 42px; }
.inv2 .inv-title .af-date-wrap { display: inline-block; width: 160px; vertical-align: middle; }
.inv2 .inv-title input.af-date, .inv2 .inv-title input[type=date], .inv2 .inv-title input[name=loaded_date] {
  height: 34px !important; border: 0 !important; border-bottom: 1.5px solid var(--inv-ink) !important; border-radius: 0 !important;
  background: transparent !important; box-shadow: none !important; font-size: 15px !important; color: var(--inv-ink) !important;
  padding-right: 4px !important; }
.inv2 .inv-title .af-date-cal { height: 30px; width: 30px; }
/* the small «＋» quick-add (المورد / المكتب): a muted icon inside the underlined field, at its end */
.inv2 .inv-in .related-widget-wrapper { position: relative; display: block; }
.inv2 .inv-in .related-widget-wrapper input.af-pick-input:not([type=hidden]) { padding-inline-end: 30px !important; }
.inv2 .inv-in .related-widget-wrapper-link { position: absolute; inset-inline-end: 2px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px; display: grid; place-items: center; border-radius: 4px; opacity: .5; z-index: 2; }
.inv2 .inv-in .related-widget-wrapper-link img { width: 14px; height: 14px; filter: grayscale(1); }
.inv2 .inv-in .related-widget-wrapper-link:hover, .inv2 .inv-in .related-widget-wrapper-link:focus-visible {
  opacity: 1; background: var(--inv-focus); outline: none; }
.inv2 .inv-in .af-pick-add { display: none !important; }

/* ── Phase 5L: «صرفيات الشركة» + «الموظفين» (docs/mockups/employees_and_expenses.html) ───────────────────── */
.af-subtabs { border-bottom: 2px solid var(--sh-line, #d5ddd8); gap: 0; }
.af-subtabs a { min-height: 44px; display: inline-flex; align-items: center; margin-bottom: -2px; text-decoration: none; }
.af-subtabs a:focus-visible { outline: 3px solid #f2b84b; outline-offset: 2px; }
.co-amount { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; }
.co-amount input.big-in { flex: 1 1 220px; height: 60px !important; font-size: 30px !important; font-weight: 800; min-width: 0; }
.co-amount .sh-seg { height: 60px; flex: 0 0 auto; min-width: 160px; }
.co-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.co-chip { font: inherit; font-weight: 700; font-size: 15px; border: 1.5px solid var(--sh-field-line, #b9c6bf); background: #fff;
  border-radius: 999px; padding: 0 16px; min-height: 44px; cursor: pointer; color: var(--sh-ink, #1b2a23);
  display: inline-flex; align-items: center; text-decoration: none; }
.co-chip[aria-pressed=true] { background: var(--sh-green, #14532d); border-color: var(--sh-green, #14532d); color: #fff; }
.co-chip.more { border-style: dashed; color: var(--sh-green-2, #1f6b40); }
.co-chip.link { border-color: #e4c48a; background: var(--sh-amber-soft, #fdf1dc); color: var(--sh-amber, #a15c07); }
.co-chip.small { min-height: 36px; font-size: 14px; padding: 0 12px; }
.co-chip:focus-visible { outline: 3px solid #f2b84b; outline-offset: 2px; }
.co-all { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; border: 1.5px dashed var(--sh-field-line, #b9c6bf); border-radius: 10px; }
.co-drop { justify-content: space-between; }
.co-req { color: var(--sh-red, #b42318); font-size: 12px; font-weight: 700; }
.co-ph { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.co-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.co-month { height: 44px; border: 1.5px solid var(--sh-field-line, #b9c6bf); border-radius: 8px; padding: 0 10px; font: inherit; background: #f6f8f7; }
.co-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.co-kpi { background: var(--sh-green-soft, #e8f2ec); border-radius: 10px; padding: 10px 14px; min-width: 0; }
.co-kpi small { display: block; color: var(--sh-muted, #5d6f66); font-weight: 700; font-size: 12px; }
.co-kpi b { display: block; font-size: clamp(18px, 3vw, 24px); font-weight: 800; overflow-wrap: anywhere; direction: ltr; text-align: right; }
.co-bars { display: grid; gap: 6px; }
.co-brow { display: grid; grid-template-columns: 130px minmax(0, 1fr) 130px; gap: 10px; align-items: center; font-size: 14px; }
.co-brow .v { text-align: left; font-weight: 700; white-space: nowrap; }
.co-brow.payroll span:first-child a { color: var(--sh-amber, #a15c07); font-weight: 700; }
.co-btrack { height: 12px; background: #eef2f0; border-radius: 6px; overflow: hidden; }
.co-bfill { height: 100%; background: var(--sh-green-2, #1f6b40); border-radius: 6px; }
.co-brow.payroll .co-bfill { background: #e4c48a; }
.co-tag { display: inline-block; background: var(--sh-green-soft, #e8f2ec); color: var(--sh-green, #14532d); border-radius: 6px; padding: 1px 8px; font-size: 12px; font-weight: 700; }
.co-btn { height: 44px; padding: 0 20px; border-radius: 10px; font: inherit; font-weight: 800; font-size: 15px; cursor: pointer;
  border: 1.5px solid var(--sh-green, #14532d); background: #fff; color: var(--sh-green, #14532d); display: inline-flex; align-items: center; text-decoration: none; }
.co-btn.pri { background: var(--sh-green, #14532d); color: #fff; }
.co-hint { font-size: 13px; color: var(--sh-muted, #5d6f66); }
.co-job-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.co-job-chips .co-chip { min-height: 34px; font-size: 13px; padding: 0 12px; }
.af-emp-kpis { margin: 0 0 12px; }
@media (max-width: 640px) {
  .co-kpis { grid-template-columns: minmax(0, 1fr); }
  .co-brow { grid-template-columns: 84px minmax(0, 1fr) 100px; }
  .af-sheet table.co-stack { min-width: 0; font-size: 13px; }
  .af-sheet table.co-stack thead { display: none; }
  .af-sheet table.co-stack tr { display: grid; padding-block: 10px; border-top: 1px solid var(--sh-line, #d5ddd8); }
  .af-sheet table.co-stack td { display: flow-root; border: 0; padding: 3px 0; padding-inline-start: 7.5em; text-align: start; }
  .af-sheet table.co-stack td::before { content: attr(data-l); float: inline-start; width: 7em; margin-inline-start: -7.5em;
    color: var(--sh-muted, #5d6f66); font-weight: 700; }
  .af-sheet table.co-stack td, .af-sheet table.co-stack td.sum, .af-sheet table.co-stack td.sh-num {
    direction: rtl !important; text-align: right !important; white-space: normal;
    padding: 3px 0 !important; padding-inline-start: 7.5em !important; }
}
/* 5L fixes: «تغيير راتب» is a normal sheet button (no stray «－», no overflow) */
.af-sheet details.af-salary-change > summary { list-style: none; display: inline-flex; align-items: center; justify-content: center;
  width: auto; height: 44px; padding: 0 20px; border: 1.5px solid var(--sh-green); border-radius: 9px; background: #fff;
  color: var(--sh-green); font-weight: 700; font-size: 15px; white-space: nowrap; cursor: pointer; }
.af-sheet details.af-salary-change > summary::before, .af-sheet details.af-salary-change[open] > summary::before,
.af-sheet details.sh-more details.af-salary-change > summary::before { content: none !important; display: none !important; }
.af-sheet details.af-salary-change > summary::-webkit-details-marker { display: none; }
.af-sheet details.af-salary-change[open] > summary { background: var(--sh-green-soft); }
