/* Noto Sans Arabic + Noto Sans (SIL Open Font License, see /fonts/OFL-*.txt), shipped with the program so it works
   without internet: Arabic text in Noto Sans Arabic, Latin letters and digits in Noto Sans (equal-width digits for columns) */
@font-face { font-family: "Noto Sans"; src: url("/fonts/NotoSans.ttf") format("truetype"); font-weight: 100 900; font-display: swap; unicode-range: U+0020-007E, U+00A0-00FF, U+2000-206F, U+20AC, U+2122, U+2190-2193, U+2212, U+25B2, U+25BC, U+2713 }
@font-face { font-family: "Noto Sans Arabic"; src: url("/fonts/NotoSansArabic.ttf") format("truetype"); font-weight: 100 900; font-display: swap }
/* Osool – visual identity
   Layout: fixed top bar (app switcher + app menus), control panel, then list / form / report body.
   Palette: deep green for structure, vivid green for interaction, gold for primary emphasis, calm green-tinted neutrals. */
:root {
  --petrol: #0E3B2E; --petrol-2: #14624A; --petrol-ink: #EAF3EE;
  --brass: #C9A227; --brass-ink: #ffffff; --brass-soft: #F7EFD6;
  --paper: #F4F6F5; --sheet: #ffffff; --ink: #17251F; --muted: #5F7166; --faint: #93A69B; --rule: #E3E9E5; --rule-2: #EDF2EE;
  --hover: #EEF5F0; --sel: #E2EFE7;
  --ok: #2e7d4f; --ok-soft: #e3f2e9; --warn: #9a6a08; --warn-soft: #f8efd9; --bad: #b3362b; --bad-soft: #f9e6e3; --info: #2b6cb0; --info-soft: #e5eef9;
  --shadow: 0 1px 2px rgba(14, 59, 46, .06), 0 4px 16px rgba(14, 59, 46, .06);
  --f: "Noto Sans", "Noto Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --mono: "IBM Plex Mono", Consolas, "DejaVu Sans Mono", monospace;
  --r: 8px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --petrol: #0B2E24; --petrol-2: #0E3B2E; --petrol-ink: #DCEBE2;
    --brass: #E4C566; --brass-ink: #1b1406; --brass-soft: #38300F;
    --paper: #0D1512; --sheet: #16211C; --ink: #EDF3EF; --muted: #93A69B; --faint: #6F877A; --rule: #24352C; --rule-2: #1C2A23;
    --hover: #1B2B23; --sel: #213A2F;
    --ok: #5cc28a; --ok-soft: #173326; --warn: #e3b44f; --warn-soft: #362b13; --bad: #f08a7e; --bad-soft: #3b1f1c; --info: #79aef0; --info-soft: #18283c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --petrol: #0B2E24; --petrol-2: #0E3B2E; --petrol-ink: #DCEBE2;
  --brass: #E4C566; --brass-ink: #1b1406; --brass-soft: #38300F;
  --paper: #0D1512; --sheet: #16211C; --ink: #EDF3EF; --muted: #93A69B; --faint: #6F877A; --rule: #24352C; --rule-2: #1C2A23;
  --hover: #1B2B23; --sel: #213A2F;
  --ok: #5cc28a; --ok-soft: #173326; --warn: #e3b44f; --warn-soft: #362b13; --bad: #f08a7e; --bad-soft: #3b1f1c; --info: #79aef0; --info-soft: #18283c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}
* { box-sizing: border-box }
[hidden] { display: none !important }
html, body { margin: 0; min-height: 100% }
body { background: var(--paper); color: var(--ink); font-family: var(--f); font-size: 14px; line-height: 1.5; direction: rtl }
button, input, select, textarea { font: inherit; color: inherit }
a { color: var(--petrol-2) }
h1, h2, h3 { margin: 0; font-weight: 600; text-wrap: balance }
.num, td.n, .n { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; white-space: nowrap }
td.n, th.n { text-align: left }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--petrol); color: var(--petrol-ink); display: flex; align-items: center; gap: 6px; height: 48px; padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)) }
.topbar .home { display: flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; padding: 6px 8px; border-radius: 6px }
.topbar .home:hover { background: rgba(255, 255, 255, .08) }
.topbar .back { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border: 0; border-radius: 8px; background: rgba(255, 255, 255, .12); color: inherit; cursor: pointer; flex: none }
.topbar .back[hidden] { display: none }
.topbar .back:hover { background: rgba(255, 255, 255, .22) }
.topbar .back svg { width: 20px; height: 20px }
.topbar .home svg { width: 22px; height: 22px }
.topbar .appname { font-weight: 600; font-size: 15px; padding: 0 6px; white-space: nowrap }
.menus { display: flex; align-items: center; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0 }
.menus::-webkit-scrollbar { display: none }
.menu { position: relative }
.menu > button { background: none; border: 0; padding: 7px 11px; border-radius: 6px; cursor: pointer; white-space: nowrap; color: inherit; opacity: .9 }
.menu > button:hover, .menu.open > button { background: rgba(255, 255, 255, .1); opacity: 1 }
.dropdown { position: fixed; background: var(--sheet); color: var(--ink); border: 1px solid var(--rule); border-radius: var(--r); box-shadow: 0 10px 30px rgba(0, 0, 0, .16); min-width: 220px; padding: 6px 0; z-index: 60 }
.dropdown a, .dropdown button { display: block; width: 100%; text-align: start; padding: 8px 16px; color: var(--ink); text-decoration: none; background: none; border: 0; cursor: pointer }
.dropdown a:hover, .dropdown button:hover { background: var(--hover) }
.dropdown .sec { font-size: 11.5px; color: var(--faint); padding: 8px 16px 2px; letter-spacing: .02em }
.dropdown .sec.grp { font-size: 12.5px; font-weight: 700; color: var(--ink); border-top: 1px solid var(--rule); margin-top: 4px; padding-top: 10px }
.dropdown .sec.grp:first-child { border-top: 0; margin-top: 0; padding-top: 6px }
.dropdown.cols { column-gap: 0; column-rule: 1px solid var(--rule); max-width: calc(100vw - 16px) }
.dropdown.cols a { break-inside: avoid }
.dropdown.cols .sec { break-after: avoid; break-inside: avoid }
.topbar .right { display: flex; align-items: center; gap: 8px; margin-inline-start: auto }
.cochip { display: flex; align-items: center; gap: 6px; max-width: 220px; background: rgba(255, 255, 255, .1); color: inherit; border: 1px solid rgba(255, 255, 255, .18); border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.cochip:hover { background: rgba(255, 255, 255, .16) }
.cochip.single { cursor: default }
.cochip::before { content: ''; width: 7px; height: 7px; border-radius: 2px; background: var(--brass); flex: none }
.live { width: 8px; height: 8px; border-radius: 50%; background: #e57373 }
.live.on { background: #7fd6a8 }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brass); color: var(--brass-ink); display: grid; place-items: center; font-weight: 700; border: 0; cursor: pointer }

/* ---------- page frame ---------- */
.page { padding-block: 0 48px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)) }
.cp { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 14px 0 12px; border-bottom: 1px solid var(--rule); margin-bottom: 14px }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 18px; min-width: 0 }
.crumbs a { color: var(--petrol-2); text-decoration: none; cursor: pointer }
.crumbs a:hover { text-decoration: underline }
.crumbs .sep { color: var(--faint) }
.crumbs b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.cp .tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-inline-start: auto }
.search { display: flex; align-items: center; gap: 6px; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r); padding: 0 10px; min-width: min(320px, 100%) }
.search input { border: 0; background: none; padding: 7px 0; outline: none; width: 100%; min-width: 0 }
.search svg { width: 16px; height: 16px; color: var(--faint); flex: none }
.chips { display: flex; flex-wrap: wrap; gap: 6px }
.chipbtn { border: 1px solid var(--rule); background: var(--sheet); border-radius: 99px; padding: 4px 12px; cursor: pointer; font-size: 13px }
.chipbtn.on { background: var(--petrol); border-color: var(--petrol); color: var(--petrol-ink) }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; justify-content: center; border: 1px solid var(--rule); background: var(--sheet); color: var(--ink); border-radius: 6px; padding: 7px 14px; cursor: pointer; font-weight: 500; text-decoration: none; white-space: nowrap }
.btn:hover { border-color: var(--petrol-2); background: var(--hover) }
.btn.pri { background: var(--brass); border-color: var(--brass); color: var(--brass-ink) }
.btn.pri:hover { filter: brightness(1.05) }
.btn.dark { background: var(--petrol); border-color: var(--petrol); color: var(--petrol-ink) }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--rule)) }
.btn.sm { padding: 3px 10px; font-size: 13px }
.btn.ghost { border-color: transparent; background: none }
.btn:disabled { opacity: .45; cursor: not-allowed }
.btn svg { width: 16px; height: 16px }

/* ---------- home ---------- */
.launcher { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; padding: 26px 0 8px; max-width: 1320px; margin: 0 auto }
.tile { display: flex; flex-direction: column; align-items: center; gap: 11px; padding: 16px 8px; border-radius: 14px; text-decoration: none; color: var(--ink); cursor: pointer; background: var(--sheet); border: 1px solid var(--rule); box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease }
.tile:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--brass) 45%, var(--rule)); box-shadow: 0 8px 22px rgba(15, 40, 48, .12) }
.tile .ic { width: 76px; height: 76px; border-radius: 18px; display: grid; place-items: center; color: #fff; box-shadow: 0 6px 16px rgba(0, 0, 0, .12) }
.tile .ic svg { width: 38px; height: 38px }
.tile b { font-weight: 600 }
.welcome { max-width: 1240px; margin: 0 auto; padding-top: 22px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: end }
.welcome h1 { font-size: 24px }
.welcome p { margin: 2px 0 0; color: var(--muted) }
.dash { max-width: 1240px; margin: 18px auto 0; display: flex; flex-direction: column; gap: 16px }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 12px }
.dash .kpis { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)) }
.kpi { background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; cursor: default }
.kpi[data-go] { cursor: pointer }
.kpi[data-go]:hover { border-color: var(--petrol-2) }
.kpi .l { color: var(--muted); font-size: 13px }
.kpi .v { font-size: 22px; font-weight: 600 }
.kpi .s { color: var(--faint); font-size: 12px }
.kpi.accent { background: var(--petrol); color: var(--petrol-ink); border-color: var(--petrol) }
.kpi.accent .l, .kpi.accent .s { color: inherit; opacity: .78 }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px }

/* ---------- panels & tables ---------- */
.panel { background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; min-width: 0 }
.panel > .ph { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--rule) }
.panel > .ph h2 { font-size: 15px }
.panel > .pb { padding: 14px 16px }
.tw { overflow-x: auto }
table { width: 100%; border-collapse: collapse }
th { font-weight: 500; color: var(--muted); font-size: 12.5px; text-align: start; padding: 9px 12px; border-bottom: 1px solid var(--rule); white-space: nowrap; background: var(--sheet); position: sticky; top: 0 }
td { padding: 8px 12px; border-bottom: 1px solid var(--rule-2); vertical-align: middle }
tbody tr.click { cursor: pointer }
tbody tr.click:hover td { background: var(--hover) }
tfoot td { font-weight: 600; border-top: 1px solid var(--rule); border-bottom: 0 }
tr.sub td { color: var(--muted) }
tr.grp td { background: var(--rule-2); font-weight: 600 }
.list { background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; overflow: hidden }
.empty { padding: 44px 16px; text-align: center; color: var(--muted) }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px }
.neg { color: var(--bad) } .pos { color: var(--ok) } .muted { color: var(--muted) }
.pager { color: var(--muted); font-size: 13px }

/* ---------- badges ---------- */
.badge { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 99px; background: var(--rule-2); color: var(--muted); white-space: nowrap; font-weight: 500 }
.badge.ok { background: var(--ok-soft); color: var(--ok) }
.badge.warn { background: var(--warn-soft); color: var(--warn) }
.badge.bad { background: var(--bad-soft); color: var(--bad) }
.badge.info { background: var(--info-soft); color: var(--info) }
.badge.brass { background: var(--brass-soft); color: var(--brass) }

/* ---------- form ---------- */
.formbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px 10px 0 0; padding: 8px 12px }
.formbar .acts { display: flex; flex-wrap: wrap; gap: 6px }
.pipeline { display: flex; align-items: stretch; border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; direction: rtl }
.pipeline span { padding: 5px 14px; font-size: 13px; color: var(--muted); position: relative; background: var(--sheet); white-space: nowrap }
.pipeline span + span { border-inline-start: 1px solid var(--rule) }
.pipeline span.on { background: var(--petrol); color: var(--petrol-ink); font-weight: 600 }
.sheet { background: var(--sheet); border: 1px solid var(--rule); border-top: 0; border-radius: 0 0 10px 10px; padding: 22px 26px 28px; display: flex; flex-direction: column; gap: 18px }
.formbar, .sheet { max-width: 1240px }
.smart { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin: -6px 0 0 }
.smart button { display: flex; align-items: center; gap: 8px; border: 1px solid var(--rule); background: var(--sheet); border-radius: 8px; padding: 6px 12px; cursor: pointer; text-align: start }
.smart button:hover { background: var(--hover) }
.smart b { display: block; font-size: 15px }
.smart small { color: var(--muted); font-size: 12px; display: block }
.doctitle { display: flex; flex-direction: column; gap: 2px }
.doctitle small { color: var(--muted); font-size: 13px }
.doctitle h1 { font-size: 26px; font-weight: 600 }
.ribbon { align-self: flex-start }
.fgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 4px 40px }
.frow { display: grid; grid-template-columns: 150px minmax(0, 1fr); align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px solid transparent }
.frow > label { color: var(--muted); font-size: 13.5px; font-weight: 500 }
.frow .val { min-height: 32px; display: flex; align-items: center; gap: 8px; min-width: 0; word-break: break-word }
.frow.req > label::after { content: " *"; color: var(--bad) }
.inp, .frow input, .frow select, .frow textarea { width: 100%; border: 0; border-bottom: 1px solid var(--rule); background: transparent; padding: 6px 2px; border-radius: 0; outline: none; min-width: 0 }
.frow input:focus, .frow select:focus, .frow textarea:focus { border-bottom-color: var(--brass) }
.frow input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--petrol-2) }
.frow textarea { min-height: 60px; resize: vertical }
.invalid { border-bottom-color: var(--bad) !important; background: var(--bad-soft) !important }
.help { font-size: 12px; color: var(--faint) }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--rule); overflow-x: auto }
.tabs button { background: none; border: 1px solid transparent; border-bottom: 0; padding: 8px 16px; cursor: pointer; color: var(--muted); border-radius: 6px 6px 0 0; margin-bottom: -1px; white-space: nowrap }
.tabs button.on { background: var(--sheet); border-color: var(--rule); color: var(--ink); font-weight: 600 }
.lines { width: 100%; border-collapse: collapse }
.lines th { position: static }
.lines td { padding: 4px 6px; border-bottom: 1px solid var(--rule-2) }
.lines input, .lines select { width: 100%; border: 1px solid transparent; background: transparent; padding: 6px 6px; border-radius: 4px; outline: none; min-width: 64px }
.lines input:hover, .lines select:hover { border-color: var(--rule) }
.lines input:focus, .lines select:focus { border-color: var(--brass); background: var(--sheet) }
.lines td.prod input { min-width: 220px }
.lines td.pcode input { width: 100px; min-width: 100px }
.lines td.pcode { white-space: nowrap; min-width: 100px }
/* van load-request lines: fixed layout keeps the code column compact and gives the item name the extra width */
#ldLinesTbl { table-layout: fixed }
#ldLinesTbl th.pcode, #ldLinesTbl td.pcode { width: 84px; min-width: 0 }
#ldLinesTbl td.pcode input { width: 100%; min-width: 0 }
#ldLinesTbl th.n, #ldLinesTbl td.n { width: 110px }
#ldLinesTbl th.uom, #ldLinesTbl td.uom, #ldLinesTbl td.muted:last-child { width: 76px; white-space: nowrap }
#ldLinesTbl th:empty { width: 44px }
/* payroll lines: fit more columns, and keep الإجمالي/الصافي in view while scrolling sideways */
table.lines.pay th, table.lines.pay td { padding: 4px 8px }
table.lines.pay input, table.lines.pay select { min-width: 58px; padding: 6px 4px }
table.lines.pay td.prod input { min-width: 170px }
.lines td.stick1, .lines td.stick2, .lines th.stick1, .lines th.stick2 { position: sticky; background: var(--sheet); z-index: 1; width: 112px; min-width: 112px }
.lines .stick2 { left: 112px }
.lines .stick1 { left: 0; box-shadow: 1.5px 0 0 var(--rule) }
.lines th.stick1, .lines th.stick2 { z-index: 3 }
.lines td input.m2o { min-width: 140px }
.lines td input[data-c=description] { min-width: 160px }
.lines td input[type=number] { min-width: 80px; max-width: 120px }
.lines .del { border: 0; background: none; color: var(--faint); cursor: pointer; font-size: 18px; padding: 2px 8px }
.lines .del:hover { color: var(--bad) }
.addline { color: var(--petrol-2); background: none; border: 0; cursor: pointer; padding: 8px 6px; font-weight: 500 }
.totals { margin-inline-start: auto; width: min(380px, 100%); display: grid; grid-template-columns: 1fr auto; gap: 6px 24px; padding-top: 8px }
.totals span { color: var(--muted) }
.totals .grand { font-size: 18px; font-weight: 700; border-top: 1px solid var(--rule); padding-top: 6px; color: var(--ink) }
.notice { border-radius: 8px; padding: 10px 14px; font-size: 14px; background: var(--info-soft); color: var(--info) }
.notice.warn { background: var(--warn-soft); color: var(--warn) }
.notice.bad { background: var(--bad-soft); color: var(--bad) }
.notice.ok { background: var(--ok-soft); color: var(--ok) }
.etabox { border: 1px solid var(--rule); border-inline-start: 4px solid var(--brass); border-radius: 8px; padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; background: var(--rule-2) }
.etabox .eh { display: flex; flex-wrap: wrap; align-items: center; gap: 8px }
.etabox .ea { display: flex; flex-wrap: wrap; gap: 6px }
table.recon tr.todo td:first-child { box-shadow: inset -3px 0 0 var(--warn) }
table.recon tr.ok td:first-child { box-shadow: inset -3px 0 0 var(--ok) }
pre.json { direction: ltr; text-align: left; background: var(--rule-2); border: 1px solid var(--rule); border-radius: 6px; padding: 10px; max-height: 50vh; overflow: auto; font-size: 12px; white-space: pre; margin: 8px 0 0 }

/* ---------- modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(8, 20, 24, .5); z-index: 80; display: flex; align-items: flex-start; justify-content: center; overflow: auto; padding: calc(40px + env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) 24px max(12px, env(safe-area-inset-left, 0px)) }
.modal { background: var(--sheet); border-radius: 12px; width: 100%; max-width: 560px; box-shadow: 0 24px 70px rgba(0, 0, 0, .3) }
.modal.wide { max-width: 980px }
.modal .mh { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--rule) }
.modal .mh h2 { font-size: 17px }
.modal .mb { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px }
.modal .mf { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--rule) }
.x { background: none; border: 0; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px 8px }
.toast { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 8px; z-index: 99; max-width: 90vw; box-shadow: var(--shadow) }
.toast.bad { background: var(--bad); color: #fff }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); min-width: 0 }
label.f input, label.f select, label.f textarea { border: 1px solid var(--rule); border-radius: 6px; padding: 8px 10px; background: var(--paper); color: var(--ink); width: 100%; font-size: 14px }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 12px }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px }
.filters label.f { min-width: 150px }

/* ---------- reports ---------- */
.rep { display: flex; flex-direction: column; gap: 14px; max-width: 1240px }
.stmt .row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 4px; border-bottom: 1px dashed var(--rule-2) }
.stmt .row.sub { padding-inline-start: 22px; color: var(--muted) }
.stmt .row.tot { font-weight: 700; border-bottom: 0; border-top: 2px solid var(--ink); margin-top: 4px; padding-top: 9px }
.stmt .row.big { font-size: 17px }
.stmt a { color: inherit; text-decoration: none }
.stmt a:hover { color: var(--petrol-2); text-decoration: underline }
.stmt h3 { font-size: 13.5px; color: var(--petrol-2); margin: 16px 0 4px; letter-spacing: .02em }
.chart svg text { fill: var(--muted); font-size: 11px; font-family: var(--f) }

/* ---------- gate ---------- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--petrol) }
.gate .card { background: var(--sheet); border-radius: 14px; padding: 30px 26px; width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 30px 80px rgba(0, 0, 0, .3) }
.gate .logo { display: flex; align-items: center; gap: 11px }
.gate .logo .wordmark { color: var(--brass); font-size: 17px }
.gate .err { color: var(--bad); font-size: 14px; min-height: 1.2em }
.gate .btn { padding-block: 10px; font-size: 15px }

/* ---------- POS ---------- */
.posui { position: fixed; inset: 48px 0 0 0; display: grid; grid-template-columns: minmax(0, 1fr) 400px; background: var(--paper); padding-bottom: env(safe-area-inset-bottom, 0px) }
.posui .catalog { display: flex; flex-direction: column; min-width: 0; padding: 12px max(12px, env(safe-area-inset-left, 0px)) 12px 12px; gap: 10px }
.posui .bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center }
.posui .bar .search { flex: 1; min-width: 200px }
.posui .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; overflow-y: auto; align-content: start; padding-bottom: 12px }
.pcard { background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; min-height: 104px; text-align: start }
.pcard:hover { border-color: var(--brass); box-shadow: var(--shadow) }
.pcard .nm { font-weight: 600; font-size: 13.5px; line-height: 1.35 }
.pcard .pr { margin-top: auto; color: var(--petrol-2); font-weight: 700 }
.pcard .q { font-size: 11.5px; color: var(--faint) }
.posui .cart { background: var(--sheet); border-inline-start: 1px solid var(--rule); display: flex; flex-direction: column; min-height: 0 }
.cart .items { flex: 1; overflow-y: auto; padding: 6px 0 }
.citem { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 14px; cursor: pointer; border-inline-start: 3px solid transparent }
.citem.sel { background: var(--sel); border-inline-start-color: var(--brass) }
.citem .d { color: var(--muted); font-size: 12.5px }
.cart .sum { border-top: 1px solid var(--rule); padding: 10px 14px; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px }
.cart .sum .t { font-size: 22px; font-weight: 700 }
.keypad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--rule); border-top: 1px solid var(--rule) }
.keypad button { background: var(--sheet); border: 0; padding: 14px 0; font-size: 17px; cursor: pointer }
.keypad button:hover { background: var(--hover) }
.keypad button.on { background: var(--sel); font-weight: 700 }
.keypad .pay { background: var(--brass); color: var(--brass-ink); font-weight: 700; grid-row: span 2 }
@media (max-width: 860px) {
  .posui { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) minmax(0, 52vh); }
  .posui .cart { border-inline-start: 0; border-top: 1px solid var(--rule) }
  .frow { grid-template-columns: 1fr; gap: 2px }
  .sheet { padding: 16px }
  .topbar .appname { display: none }
  .cochip { max-width: 110px; padding: 4px 9px }
}

/* ---------- print ---------- */
#printArea { display: none }
tr.grp-acc td { background: var(--rule-2); font-weight: 600 }
.inst { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; padding-top: 10px }
.inst div { border: 1px solid var(--rule); border-radius: 8px; padding: 8px 12px; display: flex; flex-direction: column; gap: 2px }
.inst div.late { border-color: var(--bad); background: var(--bad-soft) }
.inst div.done { opacity: .6 }
@media print {
  body > *:not(#printArea) { display: none !important }
  #printArea { display: block !important; color: #000; background: #fff; font-size: 11.5pt; font-family: var(--f) }
  #printArea table { border-collapse: collapse; width: 100% }
  #printArea th, #printArea td { border: 1px solid #999; padding: 5px 7px; color: #000; background: #fff; position: static }
  #printArea .phead { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--pc, #0E3B2E); padding-bottom: 8px; margin-bottom: 14px }
  #printArea .phead h1 { font-size: 20pt; color: var(--pc, #0E3B2E); margin: 0 0 4px }
  #printArea th { background: #F4F6F5 }
  #printArea .pterms { margin-top: 14px; font-size: 9.5pt; border-top: 1px solid #bbb; padding-top: 6px }
  #printArea .psign { display: flex; justify-content: space-between; margin-top: 56px; padding: 0 20px }
  #printArea .psign div { border-top: 1px solid #555; min-width: 130px; text-align: center; padding-top: 4px; font-size: 10pt }
  #printArea .pfoot { margin-top: 18px; text-align: center; font-size: 9pt; color: #444 }
  #printArea.paper-a5 { font-size: 10pt }
  #printArea.paper-thermal { width: 72mm; font-size: 9.5pt }
  #printArea.paper-thermal .phead { flex-direction: column }
  #printArea .ptot { width: 45%; margin-inline-start: auto; margin-top: 10px }
  #printArea .receipt { width: 72mm; font-size: 10pt }
  #printArea .receipt td, #printArea .receipt th { border: 0; padding: 2px 0 }
  @page { margin: 12mm }
}
.seg { display: flex; gap: 6px; flex-wrap: wrap }
.seg .btn.on { background: var(--petrol); border-color: var(--petrol); color: var(--petrol-ink) }
.pltab tr.sub td { border-top: 1px solid var(--rule) }
.pltab tr.tot td { background: var(--rule-2); border-top: 1px solid var(--rule) }
.pltab tr.big td { font-size: 15px }

/* narrow screens: long button labels wrap instead of pushing the page sideways */
@media (max-width: 600px) { .acts .btn { white-space: normal; max-width: 100%; text-align: center } }

/* ======================= journal entry page ======================= */
.formbar[data-model=moves], .sheet[data-model=moves] { max-width: 1480px }
/* header: date · journal · description on one row, adjusting options below */
.sheet[data-model=moves] .fgrid { grid-template-columns: minmax(150px, 1fr) minmax(170px, 1.2fr) minmax(220px, 2.4fr); gap: 6px 28px; background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; padding: 14px 18px }
.sheet[data-model=moves] .fgrid .frow { grid-template-columns: 1fr; gap: 3px; padding: 2px 0 }
.sheet[data-model=moves] .fgrid .frow > label { font-size: 12px }
.sheet[data-model=moves] .fgrid .frow input:not([type=checkbox]), .sheet[data-model=moves] .fgrid .frow select { background: var(--sheet); border: 1px solid var(--rule); border-radius: 6px; padding: 7px 10px }
.sheet[data-model=moves] .fgrid .frow input:focus, .sheet[data-model=moves] .fgrid .frow select:focus { border-color: var(--brass) }
.sheet[data-model=moves] .fgrid .frow[data-k=number] { display: none }
.sheet[data-model=moves] .fgrid .frow[data-k=adjusting] .val { min-height: 36px }
.sheet[data-model=moves] .fgrid .frow .help { font-size: 11.5px; line-height: 1.5 }
.sheet[data-model=moves] .fgrid .frow > span:empty { display: none }
.sheet[data-model=moves] .doctitle h1 { font-size: 24px }
@media (max-width: 900px) { .sheet[data-model=moves] .fgrid { grid-template-columns: 1fr } }

/* lines grid */
.jewrap { border: 1px solid var(--rule); border-radius: 10px; background: var(--sheet) }
table.je { min-width: 980px }
table.je th { background: var(--paper); color: var(--muted); font-size: 12px; font-weight: 600; padding: 9px 8px; border-bottom: 1px solid var(--rule) }
table.je th:first-child { border-start-start-radius: 10px }
table.je th.c-debit, table.je th.c-credit { width: 150px }
table.je th.c-group { width: 210px } table.je th.c-account { min-width: 240px } table.je th.c-label { min-width: 200px }
table.je th.c-partner, table.je th.c-costCenter { width: 160px } table.je th.c-amountCurrency { width: 120px }
table.je td { padding: 3px 6px; border-bottom: 1px solid var(--rule-2); height: 40px }
table.je tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--paper) 45%, transparent) }
table.je tbody tr:hover td { background: var(--brass-soft) }
table.je tbody tr:focus-within td { background: color-mix(in srgb, var(--brass-soft) 70%, transparent) }
table.je td.no, table.je th.no { width: 34px; text-align: center; color: var(--faint); font-size: 12px }
table.je td.x, table.je th.x { width: 34px; text-align: center }
table.je .del { opacity: .35 } table.je tr:hover .del { opacity: 1 }
table.je input, table.je select { min-width: 0 !important; max-width: none !important; height: 32px; font-size: 13.5px }
table.je select.jeg { color: var(--muted); padding: 4px 4px; text-overflow: ellipsis }
table.je select.jeg:focus, table.je select.jeg:hover { color: var(--ink) }
table.je td.amt input { text-align: left; font-family: var(--fnum, inherit); font-variant-numeric: tabular-nums; font-weight: 600 }
table.je td.amt input::placeholder { font-weight: 400; color: var(--faint); opacity: .55 }
table.je td.amt input::-webkit-outer-spin-button, table.je td.amt input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0 }
table.je td.amt input[type=number] { -moz-appearance: textfield; appearance: textfield }
table.je td.amt { text-align: left; font-variant-numeric: tabular-nums }
table.je:not(.edit) td { padding: 8px 10px; height: auto }
table.je:not(.edit) td.amt { font-weight: 600 }
table.je .acode { display: inline-block; min-width: 58px; margin-inline-end: 8px; color: var(--petrol-2); font-weight: 600; font-variant-numeric: tabular-nums }
table.je td.g { font-size: 12.5px }
table.je tfoot td { background: var(--paper); border-top: 2px solid var(--rule); border-bottom: 0; font-weight: 700; padding: 10px 10px; height: auto }
table.je tfoot td.amt { font-size: 15px; color: var(--ink) }
table.je tfoot td:first-child { border-end-start-radius: 10px }
.jefoot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px }
.jefoot .addline { margin: 0 }
.jekeys { font-size: 12px }
.jebal { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px; background: var(--rule-2); color: var(--muted); font-size: 13px; font-weight: 600 }
.jebal b { font-variant-numeric: tabular-nums; color: inherit }
.jebal .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .8 }
.jebal.ok { background: var(--ok-soft); color: var(--ok) }
.jebal.bad { background: var(--bad-soft); color: var(--bad) }
.jebal .btn { margin-inline-start: 6px; padding: 3px 10px; font-size: 12px }
table.je .accc { display: flex; align-items: baseline; gap: 10px }
table.je .accc .acode { min-width: 0; margin: 0; flex: none }
table.je.edit input, table.je.edit select { border: 1px solid var(--rule-2); background: var(--sheet) }
table.je.edit input:hover, table.je.edit select:hover { border-color: var(--rule) }
table.je.edit input:focus, table.je.edit select:focus { border-color: var(--brass); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brass) 18%, transparent) }
table.je.edit input.invalid { border-color: var(--bad) }

/* ======================= search box for record fields ======================= */
.acpop { position: fixed; z-index: 1000; background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; box-shadow: 0 12px 32px rgba(10, 30, 36, .18); overflow: hidden; display: flex; flex-direction: column; max-height: 340px }
.acpop[hidden] { display: none }
.acpop .acl { overflow-y: auto; padding: 4px }
.acpop .aci { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 10px; padding: 7px 10px; border-radius: 6px; cursor: pointer; line-height: 1.35 }
.acpop .aci:hover { background: var(--rule-2) }
.acpop .aci.on { background: var(--brass-soft) }
.acpop .aci .acc-code { color: var(--petrol-2); font-weight: 600; font-variant-numeric: tabular-nums; min-width: 54px }
.acpop .aci .acn { flex: 1; min-width: 0 }
.acpop .aci small { flex-basis: 100%; color: var(--faint); font-size: 11.5px }
.acpop .aci .acc-code + .acn + small { padding-inline-start: 64px }
.acpop mark { background: color-mix(in srgb, var(--brass) 28%, transparent); color: inherit; border-radius: 2px; padding: 0 1px }
.acpop .acnone { padding: 10px 12px; color: var(--muted); font-size: 13px }
.acpop .acmore { padding: 6px 12px; color: var(--faint); font-size: 12px; border-top: 1px dashed var(--rule-2) }
.acpop .acnew { padding: 10px 12px; border-top: 1px solid var(--rule); color: var(--petrol-2); font-weight: 600; cursor: pointer; background: var(--paper) }
.acpop .acnew:hover { background: var(--brass-soft) }
input.m2o.invalid { border-color: var(--bad) !important; background: var(--bad-soft) !important }
.qc .frow { grid-template-columns: 130px minmax(0, 1fr) }

/* ======================= dates, amounts, month picker ======================= */
.dwrap { position: relative; display: flex; align-items: center; width: 100%; min-width: 0 }
.dwrap .ddisp { flex: 1; min-width: 0; text-align: right; font-variant-numeric: tabular-nums; letter-spacing: .3px }
.dwrap .dcal { position: absolute; left: 4px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); cursor: pointer; padding: 3px; display: flex; border-radius: 5px }
.dwrap .dcal:hover { color: var(--petrol-2); background: var(--rule-2) }
.dwrap .dcal svg { width: 17px; height: 17px }
.dwrap .ddisp { padding-left: 30px !important }
.dwrap .dnative { position: absolute !important; left: 0; bottom: 0; width: 1px !important; min-width: 0 !important; height: 1px; opacity: 0; pointer-events: none; border: 0 !important; padding: 0 !important }
.dwrap .ddisp.invalid { border-color: var(--bad) !important; background: var(--bad-soft) !important }
.filters .dwrap { width: auto }
.filters .dwrap .ddisp { width: 128px }
.mwrap { position: relative; display: block; width: 100%; min-width: 0 }
.mwrap > input { width: 100% }
.mwrap.fmt > input { color: transparent !important; caret-color: transparent }
.mwrap .mshow { position: absolute; inset: 0; display: none; align-items: center; pointer-events: none; border: 0 solid transparent; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; color: var(--ink) }
.mwrap.fmt .mshow { display: flex }
.mpick { display: inline-flex; gap: 6px; align-items: center }
.mpick select { width: auto; min-width: 0 }
.mpick select[data-mp=m] { min-width: 112px } .mpick select[data-mp=y] { min-width: 76px }

/* payment method: cash / bank / cheque */
.seg.paym { display: inline-flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; background: var(--sheet) }
.seg.paym button { border: 0; background: none; padding: 7px 14px; font: inherit; font-size: 13px; color: var(--muted); cursor: pointer; border-inline-start: 1px solid var(--rule) }
.seg.paym button:first-child { border-inline-start: 0 }
.seg.paym button.on { background: var(--petrol); color: #fff; font-weight: 600 }
.seg.paym button:not(.on):hover { background: var(--rule-2); color: var(--ink) }
.pmhelp:not(:empty) { margin-top: 6px; font-size: 12.5px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px }
.pmcheck { margin: -2px 0 8px }
.fgrid .frow[data-k=payMethod] { grid-column: 1 / -1 }
.frow[data-k=payMethod] .val { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px }
.frow[data-k=payMethod] .pmhelp { margin: 0; color: var(--muted) }
input[data-money]::-webkit-outer-spin-button, input[data-money]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0 }
input[data-money] { -moz-appearance: textfield; appearance: textfield }

/* =====================================================================================
   Form look (v2): label above its box, boxed fields, even grid, framed lines table and totals
   ===================================================================================== */
.formbar, .sheet { max-width: 1320px }
.formbar { padding: 10px 14px; box-shadow: none }
.sheet { padding: 24px 28px 30px; gap: 22px }
.doctitle small { font-size: 12.5px; font-weight: 600; letter-spacing: .2px; color: var(--muted) }
.doctitle h1 { font-size: 25px; font-weight: 700; letter-spacing: -.2px }

.fgrid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 248px), 1fr)); gap: 16px 22px; align-items: start }
.frow { grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 0; align-content: start; border: 0 }
.frow > label { font-size: 12.5px; font-weight: 600; color: var(--muted); line-height: 1.35 }
.frow .val { min-height: 38px; flex-direction: column; align-items: stretch; justify-content: center; gap: 5px }
.frow .val > * { max-width: 100% }

/* boxed fields */
.frow input:not([type=checkbox]):not([type=radio]):not(.dnative), .frow select, .frow textarea {
  border: 1px solid var(--rule); border-radius: 7px; background: var(--sheet); padding: 8px 11px; min-height: 38px; font-size: 14px; color: var(--ink);
  transition: border-color .12s, box-shadow .12s }
.frow input:not([type=checkbox]):hover, .frow select:hover, .frow textarea:hover { border-color: color-mix(in srgb, var(--rule) 55%, var(--muted)) }
.frow input:focus, .frow select:focus, .frow textarea:focus { border-color: var(--brass) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brass) 16%, transparent) }
.frow input[readonly]:not(.ddisp), .frow input:disabled, .frow select:disabled { background: var(--paper); color: var(--muted) }
.frow textarea { min-height: 76px; line-height: 1.6 }
.frow select { padding-inline-end: 8px }
.frow input::placeholder, .frow textarea::placeholder { color: var(--faint) }
.frow .help { font-size: 11.5px; line-height: 1.5; color: var(--faint) }
.frow .dwrap .ddisp { padding-left: 34px !important }
.frow .mwrap .mshow { padding-top: 0; padding-bottom: 0 }

/* yes/no fields: one tidy row with the box first */
.frow:has(> .val > input[type=checkbox]:only-child), .frow:has(> .val > input[type=checkbox] + .help) {
  grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "box label" "help help"; align-items: center; column-gap: 10px;
  border: 1px solid var(--rule-2); border-radius: 8px; padding: 9px 12px; background: var(--paper); min-height: 38px; margin-top: 21px }
.frow:has(> .val > input[type=checkbox]:only-child) > label, .frow:has(> .val > input[type=checkbox] + .help) > label { grid-area: label; color: var(--ink); font-weight: 500; font-size: 13.5px; cursor: pointer }
.frow:has(> .val > input[type=checkbox]:only-child) > .val, .frow:has(> .val > input[type=checkbox] + .help) > .val { display: contents }
.frow:has(> .val > input[type=checkbox]) input[type=checkbox] { grid-area: box; margin: 0 }
.frow:has(> .val > input[type=checkbox]) .help { grid-area: help; margin-top: 4px }

/* values of a saved / posted document */
.frow .val:not(:has(input, select, textarea, button, .seg)) { font-size: 14.5px; color: var(--ink); padding: 8px 0 7px; border-bottom: 1px solid var(--rule-2); justify-content: flex-start }
/* an empty read-only field stays blank */

/* tabs */
.tabs { gap: 4px; border-bottom: 1px solid var(--rule) }
.tabs button { border: 0; border-radius: 0; padding: 10px 14px; margin-bottom: -1px; border-bottom: 2px solid transparent; font-weight: 500 }
.tabs button:hover { color: var(--ink) }
.tabs button.on { background: none; border: 0; border-bottom: 2px solid var(--brass); color: var(--ink); font-weight: 700 }

/* lines table on every document */
.sheet .tw:has(> table.lines) { border: 1px solid var(--rule); border-radius: 10px; background: var(--sheet) }
table.lines th { background: var(--paper); color: var(--muted); font-size: 12px; font-weight: 600; padding: 9px 8px; border-bottom: 1px solid var(--rule); white-space: nowrap; text-align: start }
table.lines th.n { text-align: left }
table.lines td { padding: 5px 6px; border-bottom: 1px solid var(--rule-2); vertical-align: middle }
table.lines tbody tr:last-child td { border-bottom: 0 }
table.lines tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--paper) 45%, transparent) }
table.lines tbody tr:hover td { background: var(--hover) }
table.lines tbody tr:focus-within td { background: color-mix(in srgb, var(--brass-soft) 55%, transparent) }
table.lines input, table.lines select { border: 1px solid var(--rule-2); background: var(--sheet); border-radius: 6px; min-height: 34px; padding: 6px 8px }
table.lines input:hover, table.lines select:hover { border-color: var(--rule) }
table.lines input:focus, table.lines select:focus { border-color: var(--brass); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brass) 16%, transparent) }
table.lines input[type=number], table.lines input[data-money] { text-align: left; font-variant-numeric: tabular-nums }
table.lines tfoot td { background: var(--paper); border-top: 1px solid var(--rule) }
.addline { font-weight: 600 }

/* totals box */
.totals { background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; padding: 14px 18px; gap: 8px 28px; font-variant-numeric: tabular-nums }
.totals b { text-align: left }
.totals .grand { font-size: 19px; border-top: 1px solid var(--rule); padding-top: 9px; margin-top: 2px }

/* lists */
.list th { background: var(--paper); color: var(--muted); font-size: 12.5px; font-weight: 600 }
.list td { padding-top: 9px; padding-bottom: 9px }
.list tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--paper) 35%, transparent) }
.list tbody tr.click:hover td { background: var(--hover) }

/* the journal entry header keeps its own compact strip */
.sheet[data-model=moves] .fgrid .frow { gap: 4px }
.sheet[data-model=moves] .fgrid .frow:has(> .val > input[type=checkbox]) { margin-top: 20px }
@media (max-width: 700px) { .sheet { padding: 16px 14px 20px } .fgrid { gap: 12px } .frow:has(> .val > input[type=checkbox]) { margin-top: 0 } }
.frow[data-k=payMethod] .val { flex-direction: row; justify-content: flex-start }
.sheet .tw:has(> table.lines) + .totals, .sheet .jefoot + .totals { margin-top: 4px }
/* every cash box and bank on the dashboard (cash first), scrolling when there are many */
.hb.liqlist { max-height: 300px; overflow-y: auto }

/* =====================================================================================
   Fields (v3): softer filled boxes, clear labels, one height everywhere, custom select arrow,
   a pill switch for the payment method, and a red mark on a choice that still has to be made
   ===================================================================================== */
:root { --fld-bg: #F7FAF8; --fld-bd: #D9E4DC; --fld-h: 42px; --fld-r: 10px; --ring: color-mix(in srgb, var(--brass) 22%, transparent) }
:root[data-theme="dark"] { --fld-bg: #1B2A22; --fld-bd: #2E4438 }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --fld-bg: #1B2A22; --fld-bd: #2E4438 } }

.fgrid { gap: 18px 24px }
.frow { gap: 7px }
.frow > label { font-size: 13px; font-weight: 600; color: var(--ink); opacity: .78; letter-spacing: 0 }
.frow.req > label::after { content: " *"; color: var(--brass); font-weight: 700 }

.frow input:not([type=checkbox]):not([type=radio]):not(.dnative), .frow select, .frow textarea,
.modal .f input:not([type=checkbox]):not([type=radio]), .modal .f select, .modal .f textarea {
  background-color: var(--fld-bg); border: 1px solid var(--fld-bd); border-radius: var(--fld-r);
  min-height: var(--fld-h); padding: 9px 13px; font-size: 14px; color: var(--ink); width: 100%;
  transition: border-color .15s, box-shadow .15s, background-color .15s; outline: none }
.frow input:not([type=checkbox]):hover, .frow select:hover, .frow textarea:hover,
.modal .f input:hover, .modal .f select:hover, .modal .f textarea:hover { border-color: color-mix(in srgb, var(--fld-bd) 50%, var(--muted)) }
.frow input:focus, .frow select:focus, .frow textarea:focus,
.modal .f input:focus, .modal .f select:focus, .modal .f textarea:focus {
  background-color: var(--sheet); border-color: var(--brass) !important; box-shadow: 0 0 0 4px var(--ring) }
.frow input[readonly]:not(.ddisp), .frow input:disabled, .frow select:disabled { background-color: var(--rule-2); color: var(--muted); border-style: dashed }
.frow input::placeholder, .frow textarea::placeholder, .modal .f input::placeholder { color: var(--faint); opacity: 1 }
.frow textarea { min-height: 84px; line-height: 1.65 }

/* one arrow for every list, on the reading end of the box */
.frow select, .modal .f select, table.lines select {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a979b' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 13px center; background-size: 12px; padding-left: 34px !important }
.frow select:has(option[value=""]:checked), .modal .f select:has(option[value=""]:checked) { color: var(--faint) }
.frow select option, .modal .f select option { color: var(--ink) }

/* money and numbers line up like a ledger */
.frow input[data-money], .frow input[type=number] { text-align: left; font-variant-numeric: tabular-nums; direction: ltr; font-weight: 500 }

/* help text sits quietly under its box */
.frow .help { font-size: 12px; color: var(--faint); line-height: 1.55; padding-inline-start: 2px }

/* a choice the user still has to make */
.frow .need, .modal .need, input.m2o.need { border-color: var(--bad) !important; background-color: var(--bad-soft) !important; box-shadow: 0 0 0 4px color-mix(in srgb, var(--bad) 14%, transparent) !important }

/* payment method: a pill switch */
.seg.paym { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--fld-bd); border-radius: 12px; background: var(--fld-bg); overflow: visible }
.seg.paym button { border: 0 !important; border-radius: 9px; padding: 8px 18px; font-size: 13.5px; font-weight: 500; color: var(--muted); background: transparent; transition: background .15s, color .15s, box-shadow .15s }
.seg.paym button:not(.on):hover { background: var(--sheet); color: var(--ink) }
.seg.paym button.on { background: var(--petrol); color: #fff; font-weight: 600; box-shadow: 0 1px 3px rgba(15, 40, 48, .22) }
.frow[data-k=payMethod] .pmhelp:not(:empty) { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; width: 100%;
  background: var(--info-soft); color: var(--ink); border: 1px solid color-mix(in srgb, var(--info) 22%, transparent); border-radius: 10px; padding: 10px 14px; font-size: 13px; line-height: 1.6 }
.frow[data-k=payMethod] .pmhelp .btn { margin-inline-start: auto }

/* the form sheet itself */
.sheet { border-radius: 14px }
.doctitle h1 { font-size: 26px }
@media (max-width: 700px) { :root { --fld-h: 44px } .fgrid { gap: 14px } }
/* payment method, the cash box / bank and the bank operation sit together on one line */
.fgrid > .frow[data-k=pmKind] { grid-column-start: 1 }
.modal .pmnote { grid-column: 1 / -1; margin: -4px 0 0; font-size: 12.5px; background: var(--info-soft); border-radius: 8px; padding: 8px 12px; color: var(--ink) }
/* a table cell holding a code, a number or a date keeps the reading direction of its column, so it lines up
   under its header (the text inside stays isolated, so digits and Latin codes still read correctly) */
td.num:not(.n), th.num:not(.n) { direction: inherit; text-align: start }
th.num.n { direction: inherit }
/* a read-only number, code or date in a form sits under its label (it keeps its own left-to-right order inside) */
.frow .val > .num, .frow .val > .n, .frow .val > span[dir=ltr] { align-self: flex-start; text-align: start }

/* =====================================================================================
   Documents (v4): each kind of document carries its colour — sales teal, purchases indigo, treasury & accounting
   brass, stock amber, people violet — on a top strip, the document-type tag, the number box, the line-table header
   and the totals. Totals read like a ledger: a ruled box with a double rule under the grand total.
   ===================================================================================== */
.formbar, .sheet { --acc: var(--petrol); --acc-ink: var(--petrol) }
:is(.formbar, .sheet, .wb):is([data-key^=customer], [data-key^=quotation], [data-key^=sale], [data-key^=checks_in], [data-key^=pos], [data-key$=_s]) { --acc: #14624A; --acc-ink: #14624A }
:is(.formbar, .sheet, .wb):is([data-key^=vendor], [data-key^=purchase], [data-key^=rfq], [data-key^=checks_out], [data-key$=_p]) { --acc: #4053c4; --acc-ink: #3445a8 }
:is(.formbar, .sheet, .wb):is([data-key^=journal], [data-key^=moves], [data-key^=transfer], [data-key^=voucher], [data-key^=custod], [data-key^=bank], [data-key^=cash], [data-key^=tax], [data-key^=accru], [data-key^=asset], [data-key^=loan], [data-key^=guarant]) { --acc: #a8781f; --acc-ink: #8a6216 }
:is(.formbar, .sheet, .wb):is([data-key^=receipt], [data-key^=deliver], [data-key^=internal], [data-key^=stock], [data-key^=count], [data-key^=inventory], [data-key^=landed], [data-key^=scrap], [data-key^=production], [data-key^=mrp]) { --acc: #b45309; --acc-ink: #9a4708 }
:is(.formbar, .sheet, .wb):is([data-key^=employee], [data-key^=payroll], [data-key^=leave], [data-key^=attend], [data-key^=advance], [data-key^=hr]) { --acc: #7c3aed; --acc-ink: #6d28d9 }
:root[data-theme="dark"] :is(.formbar, .sheet, .wb) { --acc-ink: color-mix(in srgb, var(--acc) 55%, #fff) }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) :is(.formbar, .sheet, .wb) { --acc-ink: color-mix(in srgb, var(--acc) 55%, #fff) } }

/* top strip */
.formbar { border-top: 3px solid var(--acc) }
.formbar + .sheet, .sheet { border-color: var(--rule) }
.sheet:not(.formbar + .sheet) { border-top: 3px solid var(--acc) !important }

/* document head: type tag over a boxed number */
.doctitle { flex-direction: column; align-items: flex-start; gap: 8px; padding-bottom: 14px; border-bottom: 1px dashed var(--rule) }
.doctitle small { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--acc-ink);
  background: color-mix(in srgb, var(--acc) 10%, transparent); border: 1px solid color-mix(in srgb, var(--acc) 22%, transparent); padding: 3px 11px; border-radius: 99px }
.doctitle small::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--acc) }
.doctitle h1.docno { display: inline-block; font-size: 22px; font-weight: 700; letter-spacing: .5px; direction: ltr; unicode-bidi: isolate;
  padding: 7px 18px; border: 1.5px solid color-mix(in srgb, var(--acc) 45%, transparent); border-radius: 10px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--acc) 7%, var(--sheet)), var(--sheet)); color: var(--ink);
  box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--acc) 18%, transparent) }

/* tabs pick up the colour */
.sheet .tabs button.on { color: var(--acc-ink); border-bottom: 2px solid var(--acc); background: transparent; border-color: transparent transparent var(--acc) }

/* line table: tinted head, ruled body, figures in a ledger column */
.sheet table.lines:not(.je) { border: 1px solid var(--rule); border-radius: 10px; border-collapse: separate; border-spacing: 0; overflow: hidden }
.sheet table.lines:not(.je) thead th { background: color-mix(in srgb, var(--acc) 8%, var(--sheet)); color: var(--acc-ink); font-weight: 600; font-size: 12.5px;
  border-bottom: 2px solid color-mix(in srgb, var(--acc) 35%, transparent); padding: 10px 10px }
.sheet table.lines:not(.je) tbody td { border-bottom: 1px solid var(--rule-2); padding: 7px 10px }
.sheet table.lines:not(.je) tbody tr:last-child td { border-bottom: 0 }
.sheet table.lines:not(.je) tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--paper) 55%, transparent) }
.sheet table.lines:not(.je) tbody tr:hover td { background: color-mix(in srgb, var(--acc) 5%, transparent) }
.sheet table.lines td.n, .sheet table.lines td .num { font-variant-numeric: tabular-nums }

/* totals: a ruled box like a ledger summary, double rule under the grand total */
.sheet .totals { width: min(400px, 100%); background: var(--paper); border: 1px solid var(--rule); border-radius: 12px; padding: 14px 18px; gap: 9px 28px; margin-top: 4px }
.sheet .totals span { font-size: 13.5px }
.sheet .totals b { font-weight: 600; text-align: left }
.sheet .totals .grand { border-top: 1px solid var(--rule); padding-top: 10px; margin-top: 2px; font-size: 17px; color: var(--acc-ink) }
.sheet .totals b.grand { color: var(--ink); font-size: 19px; border-bottom: 3px double var(--ink); padding-bottom: 3px; justify-self: end }

/* read-only values look like entries on a form, not loose text */
.sheet .frow .val:not(:has(input, select, textarea, button, .seg)) { font-weight: 500 }

/* below-cost warning */
table.lines input.belowcost, table.lines [data-c=price].belowcost { border-color: var(--bad) !important; background: var(--bad-soft) !important; color: var(--bad); font-weight: 700 }
.costwarn { border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent); background: var(--bad-soft); border-radius: 12px; padding: 12px 16px; display: flex; flex-direction: column; gap: 8px }
.costwarn .cwh { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; color: var(--bad) }
.costwarn .cwh b.num { font-size: 15px }
.costwarn table { background: var(--sheet); border-radius: 8px; overflow: hidden }
.costwarn th { background: transparent; position: static; font-size: 12px }
.costwarn td { padding: 6px 12px; font-size: 13px }
.costwarn td.neg { color: var(--bad); font-weight: 600 }

/* lists: a calmer head row and clearer rows */
.list table thead th { background: var(--paper); color: var(--muted); font-weight: 600; font-size: 12.5px; border-bottom: 1px solid var(--rule) }
.list table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--paper) 45%, transparent) }
.list table tbody tr.click:hover td { background: var(--brass-soft) }
.list table td { padding: 10px 12px }

/* =====================================================================================
   Workbench (v5): the accountant's layout — one action bar, ruled field grid, spreadsheet lines,
   a side panel of figures and a fixed totals bar. Built around the document's colour (--acc).
   ===================================================================================== */
:root { --cellbg: #F2F6F3; --gridln: #D7E2DA; --gridln2: #B9CCC0; --focus: #14624A; --focus-soft: #F0F7F2 }
:root[data-theme="dark"] { --cellbg: #1B2A22; --gridln: #2C4034; --gridln2: #3A5546; --focus: #57C79A; --focus-soft: #16281F }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --cellbg: #1B2A22; --gridln: #2C4034; --gridln2: #3A5546; --focus: #57C79A; --focus-soft: #16281F } }

kbd { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 10.5px; background: color-mix(in srgb, var(--ink) 9%, transparent); border-radius: 3px; padding: 1px 5px; color: inherit; opacity: .8; font-weight: 500; margin-inline-start: 4px }
.btn.pri kbd { background: rgba(255, 255, 255, .22); opacity: 1 }

/* action bar */
.wbpage .cp .tools:empty { display: none }
.wbpage .formbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; border-radius: 10px 10px 0 0; padding: 9px 14px; background: var(--sheet); border: 1px solid var(--gridln2); border-top: 3px solid var(--acc); margin-bottom: 12px; border-radius: 8px; box-shadow: 0 1px 3px rgba(16, 40, 48, .06) }
.wbpage .formbar .acts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center }
.wbpage .formbar .btn { padding: 6px 12px; font-size: 13px; border-radius: 6px }
.wbpage .formbar .btn.pri { background: var(--acc); border-color: var(--acc); color: #fff }
.wbpage .formbar .pipeline { display: none }
.wdoc { margin-inline-start: auto; display: flex; align-items: center; gap: 10px }
.wdoc .wkind { color: var(--muted); font-size: 13px }
.wdoc .wno { font-weight: 600; font-size: 15px; letter-spacing: .3px; border: 1.5px solid var(--acc); color: var(--acc-ink); padding: 3px 12px; border-radius: 5px; background: color-mix(in srgb, var(--acc) 7%, var(--sheet)) }
.wdoc .wst { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 4px; background: var(--warn-soft, #fff5d6); color: var(--warn, #8a6100); border: 1px solid color-mix(in srgb, var(--warn, #8a6100) 30%, transparent) }
.wdoc .wst:not(.s-مسودة):not(.s-جديد):not(.bad) { background: var(--ok-soft, #e7f6ec); color: var(--ok, #146c2e); border-color: color-mix(in srgb, var(--ok, #146c2e) 30%, transparent) }
.wdoc .wst.bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent) }

/* body: sheet + side panel */
.wb { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; align-items: start }
.wb.noside { grid-template-columns: minmax(0, 1fr) }
.wb.noside .wbside { display: none }
.wb > .wfoot { grid-column: 1 / -1 }
.wbpage .sheet { border: 0 !important; background: transparent; padding: 0; box-shadow: none; border-radius: 0 }
.wbpage .sheet .doctitle { display: none }

/* fields: a ruled grid of label | value cells */
.wbpage .sheet .fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 0; border: 1px solid var(--gridln2); background: var(--sheet); border-radius: 6px; overflow: hidden }
.wbpage .sheet .fgrid > .frow { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 0; border-bottom: 1px solid var(--gridln); border-inline-start: 1px solid var(--gridln); margin: 0 -1px -1px 0; min-height: 40px }
.wbpage .sheet .fgrid > .frow > label { background: var(--cellbg); color: var(--ink); opacity: 1; font-weight: 600; font-size: 12.5px; padding: 8px 10px; display: flex; align-items: center; border-inline-end: 1px solid var(--gridln); line-height: 1.35 }
.wbpage .sheet .fgrid > .frow.req > label::after { color: var(--bad) }
.wbpage .sheet .fgrid > .frow > .val { padding: 0; display: flex; flex-direction: column; justify-content: center; min-width: 0 }
.wbpage .sheet .fgrid > .frow > .val:not(:has(input, select, textarea, .seg)) { padding: 8px 12px; font-weight: 500 }
.wbpage .sheet .fgrid > .frow input:not([type=checkbox]):not([type=radio]), .wbpage .sheet .fgrid > .frow select, .wbpage .sheet .fgrid > .frow textarea {
  border: 0 !important; border-radius: 0; background-color: transparent; min-height: 39px; padding: 8px 12px; box-shadow: none !important; font-size: 13.5px }
.wbpage .sheet .fgrid > .frow select { padding-left: 32px !important }
.wbpage .sheet .fgrid > .frow:focus-within { outline: 2px solid var(--focus); outline-offset: -2px; z-index: 1; position: relative }
.wbpage .sheet .fgrid > .frow:focus-within > .val { background: var(--focus-soft) }
.wbpage .sheet .fgrid > .frow:has(.need) { outline: 2px solid var(--bad); outline-offset: -2px; position: relative; z-index: 1 }
.wbpage .sheet .fgrid > .frow:has(.need) > .val { background: var(--bad-soft) }
.wbpage .sheet .fgrid > .frow .need { background: transparent !important; box-shadow: none !important }
.wbpage .sheet .fgrid > .frow .help { padding: 0 12px 6px; font-size: 11.5px }
.wbpage .sheet .fgrid > .frow:has(textarea), .wbpage .sheet .fgrid > .frow.wide, .wbpage .sheet .fgrid > .frow[data-k=memo], .wbpage .sheet .fgrid > .frow[data-k=description], .wbpage .sheet .fgrid > .frow[data-k=narration] { grid-column: 1 / -1 }
.wbpage .sheet .fgrid > .frow .seg.paym, .wbpage .sheet .fgrid > .frow > .val > select[name=pmKind], .wbpage .sheet .fgrid > .frow > .val > select[name=pmOp] { margin: 0 }

.wbpage .sheet .fgrid > .frow .dwrap, .wbpage .sheet .fgrid > .frow .mwrap { width: 100% }
.wbpage .sheet .fgrid > .frow .dwrap input { border: 0 !important }

/* section heads, tabs */
.wbpage .sheet .tabs { margin-top: 14px; border-bottom: 1px solid var(--gridln2); gap: 0 }
.wbpage .sheet .tabs button { font-size: 12.5px; font-weight: 700; padding: 7px 14px; border-radius: 6px 6px 0 0 }
.wbpage .sheet .tabs button.on { background: var(--sheet); color: var(--acc-ink); border: 1px solid var(--gridln2); border-bottom-color: var(--sheet); margin-bottom: -1px }
.wsec { margin: 14px 0 6px; font-weight: 700; color: var(--acc-ink); font-size: 12.5px; display: flex; gap: 10px; align-items: center }
.wsec::after { content: ""; flex: 1; height: 1px; background: var(--gridln2) }

/* lines: a spreadsheet */
.wbpage .sheet table.lines, .wbpage .sheet .wtbl { width: 100%; border-collapse: collapse !important; border-spacing: 0; background: var(--sheet); border: 1px solid var(--gridln2) !important; border-radius: 0 !important }
.wbpage .sheet table.lines th, .wbpage .sheet .wtbl th { background: var(--cellbg) !important; color: var(--ink) !important; font-weight: 600; font-size: 12px; padding: 6px 8px !important; border: 1px solid var(--gridln) !important; position: static }
.wbpage .sheet table.lines td, .wbpage .sheet .wtbl td { border: 1px solid var(--gridln) !important; padding: 0 !important; height: 34px; background: transparent !important }
.wbpage .sheet table.lines td:not(:has(input, select)), .wbpage .sheet .wtbl td { padding: 5px 8px !important }
.wbpage .sheet table.lines td input, .wbpage .sheet table.lines td select { border: 0 !important; border-radius: 0 !important; background: transparent !important; height: 33px; width: 100%; padding: 4px 8px; box-shadow: none !important }
.wbpage .sheet table.lines td:focus-within { outline: 2px solid var(--focus); outline-offset: -2px; background: var(--sheet) !important }
.wbpage .sheet table.lines tr:focus-within td { background: var(--focus-soft) !important }
.wbpage .sheet table.lines tr:focus-within td:focus-within { background: var(--sheet) !important }
.wbpage .sheet table.lines .rn { background: var(--cellbg) !important; color: var(--faint); text-align: center; width: 34px; font-family: 'IBM Plex Mono', monospace; font-size: 12px; padding: 0 4px !important }
.wbpage .sheet table.lines td input.belowcost { background: var(--bad-soft) !important; color: var(--bad) }
.wbpage .sheet table.lines td:has(input.belowcost) { outline: 2px solid var(--bad); outline-offset: -2px }
.wbpage .sheet table.lines tfoot td { background: var(--cellbg) !important; font-weight: 700; padding: 6px 8px !important }
.wbpage .sheet #totalsBox { display: none }
.wbpage .sheet .jebar { border-radius: 0 }

/* side panel */
.wbside { position: sticky; top: 64px; display: flex; flex-direction: column; gap: 12px }
.wcard { background: var(--sheet); border: 1px solid var(--gridln2); border-radius: 8px; padding: 13px 15px }
.wlbl { color: var(--muted); font-size: 12px }
.wbig { font-size: 25px; font-weight: 700; color: var(--acc-ink); text-align: left; margin: 2px 0 6px; font-family: 'IBM Plex Mono', monospace }
.wrow { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; color: var(--muted); border-bottom: 1px dashed var(--gridln); font-size: 13px }
.wrow:last-of-type { border-bottom: 0 }
.wrow b { color: var(--ink); font-weight: 600 }
.wrow b.neg { color: var(--bad) } .wrow b.pos { color: var(--ok, #146c2e) }
.wprog { height: 7px; background: var(--gridln); border-radius: 99px; overflow: hidden; margin: 10px 0 4px }
.wprog i { display: block; height: 100%; background: var(--acc) }
.wsteps { display: flex; gap: 4px; margin-top: 10px }
.wsteps i { flex: 1; font-style: normal; text-align: center; font-size: 11.5px; padding: 4px 2px; border-radius: 4px; background: var(--gridln); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.wsteps i.on { background: var(--acc); color: #fff; font-weight: 600 }
.wcust { display: flex; gap: 10px; align-items: center; margin-bottom: 8px }
.wcust b { display: block }
.wav { width: 36px; height: 36px; border-radius: 8px; background: var(--petrol); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none }
.wpill { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 4px }
.wpill.good { background: var(--ok-soft, #e7f6ec); color: var(--ok, #146c2e) } .wpill.bad { background: var(--bad-soft); color: var(--bad) }
.wwarn { background: var(--bad-soft); color: var(--bad); border-radius: 6px; padding: 6px 10px; font-size: 12.5px; margin-top: 6px }
.wbside .costwarn { margin: 0; border-radius: 8px; padding: 11px 13px }
.wbside .costwarn table { display: none }
.wbside .costwarn .cwh { flex-direction: column; gap: 4px; font-size: 13px }

/* totals bar */
.wfoot { position: sticky; bottom: 8px; z-index: 15; margin-top: 4px; background: #0E3B2E; color: #fff; display: flex; flex-wrap: wrap; border-radius: 8px; overflow: hidden; box-shadow: 0 6px 18px rgba(16, 40, 48, .25) }
.wfoot > div { padding: 8px 16px; border-inline-end: 1px solid rgba(255, 255, 255, .12) }
.wfoot span { display: block; font-size: 11px; opacity: .72 }
.wfoot b { font-size: 15.5px; font-weight: 600 }
.wfoot .w { background: #9a1f17 }
.wfoot .g { background: var(--acc); margin-inline-start: auto; border: 0 }
.wfoot .g b { font-size: 17px }

/* payment entry preview */
.wprev { margin-top: 4px }

/* lists: summary cards */
.wkpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-bottom: 10px }
.wkpis > div { background: var(--sheet); border: 1px solid var(--gridln2); border-radius: 6px; padding: 8px 12px; border-top: 3px solid var(--petrol) }
.wkpis span { display: block; font-size: 11.5px; color: var(--muted) }
.wkpis b { font-size: 17px; font-weight: 600 }
.list table thead th { background: var(--cellbg); color: var(--ink); border: 1px solid var(--gridln) }
.list table td { border-inline: 1px solid var(--gridln); border-bottom: 1px solid var(--gridln) }

@media (max-width: 1100px) { .wb { grid-template-columns: minmax(0, 1fr) } .wbside { position: static } }
@media (max-width: 700px) { .wbpage .sheet .fgrid > .frow { grid-template-columns: 110px minmax(0, 1fr) } .wdoc { margin-inline-start: 0 } }
@media print { .wbside, .wfoot, .wkpis { display: none !important } .wb { display: block } }
/* workbench fit: the line grid fits the main column; field help lives behind an ⓘ on the label */
.wbpage .sheet .lines td.prod input { min-width: 170px }
.wbpage .sheet .lines td input.m2o { min-width: 110px }
.wbpage .sheet .lines td input[data-c=description] { min-width: 120px }
.wbpage .sheet .lines td input[type=number] { min-width: 64px; max-width: 110px }
.wbpage .sheet .fgrid > .frow > label .wi { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; background: color-mix(in srgb, var(--acc) 16%, transparent); color: var(--acc-ink); font-size: 10px; font-weight: 700; margin-inline-start: 5px; cursor: help; flex: none }
.wbpage .sheet .fgrid > .frow > label { gap: 2px }


.wbpage { padding-bottom: 90px }
/* a yes/no field is an ordinary grid cell too: label cell | box */
.wbpage .sheet .fgrid > .frow:has(> .val > input[type=checkbox]) { display: grid !important; grid-template-columns: 128px minmax(0, 1fr) !important; grid-template-areas: none !important; background: transparent !important; border-radius: 0 !important; padding: 0 !important; margin: 0 -1px -1px 0 !important; box-shadow: none !important; border: 0; border-bottom: 1px solid var(--gridln); border-inline-start: 1px solid var(--gridln) }
.wbpage .sheet .fgrid > .frow:has(> .val > input[type=checkbox]) > label { grid-area: auto !important; font-weight: 600; font-size: 12.5px }
.wbpage .sheet .fgrid > .frow:has(> .val > input[type=checkbox]) > .val { display: flex !important; align-items: flex-start; padding: 0 12px }
.wbpage .sheet .fgrid > .frow:has(> .val > input[type=checkbox]) input[type=checkbox] { margin: 0 !important; grid-area: auto !important }
.wbpage .sheet[data-model=moves] .fgrid { padding: 0 !important; gap: 0 !important; background: var(--sheet) !important; box-shadow: none !important }
.wbpage .sheet[data-model=moves] .fgrid .frow:has(> .val > input[type=checkbox]) { margin-top: 0 !important }
/* payment allocation table */
.palloc { margin-top: 4px }
.palloc .pabtns { display: inline-flex; gap: 6px; margin-inline-start: 8px; order: 2 }
.palloc .wsec::after { order: 1 }
.palloc table.pat td input[data-inv] { text-align: left; font-weight: 600 }
.palloc table.pat td input.over { color: var(--bad) !important; background: var(--bad-soft) !important }
.palloc table.pat td.neg { color: var(--bad) }
.palloc table.pat tfoot b.neg { color: var(--bad) }
.palloc .panote { margin-top: 6px; font-size: 12.5px; color: var(--muted) }
.palloc .panote .neg { color: var(--bad) }
.wbpage .sheet .fgrid > .frow[hidden] { display: none !important }

/* journal entry: the automatic balancing line */
table.lines.je tr.jeauto td { background: color-mix(in srgb, var(--accent, #14624A) 6%, transparent); }
table.lines.je tr.jeauto td.amt input { font-style: italic; color: var(--muted, #6b7280); }
table.lines.je tr.jeauto td.no::after { content: "≈"; margin-inline-start: 3px; color: var(--muted, #6b7280); }
/* purchase request follow-up */
.prbar { height: 8px; border-radius: 6px; background: var(--line, #e5e7eb); overflow: hidden; }
.prbar i { display: block; height: 100%; background: var(--ok, #16a34a); border-radius: 6px; }
tr.prwarn td { background: color-mix(in srgb, #dc2626 8%, transparent); }
/* stock on screen: "now ← after" column and the side card */
.stk { display: flex; align-items: center; gap: 6px; justify-content: flex-end; white-space: nowrap; }
.stk-now, .stk-after { padding: 2px 7px; border-radius: 6px; font-weight: 600; background: #eef2f6; color: #334155; }
.stk-now.low { background: #fde8e8; color: #b42318; }
.stk-after.good { background: #e7f6ec; color: #15803d; font-weight: 700; }
.stk-after.warn { background: #fef3c7; color: #a16207; font-weight: 700; }
.stk-after.bad { background: #fde8e8; color: #b42318; font-weight: 700; }
.stk-ar { color: #94a3b8; }
.stk-na { color: #94a3b8; font-size: 12px; white-space: nowrap; }
th.stkh { white-space: nowrap; }
table.lines tr.stk-sel td { box-shadow: inset 0 0 0 9999px color-mix(in srgb, #4f46e5 5%, transparent); }
.stockcard { border-top: 3px solid #4f46e5 !important; }
.stockcard .stk-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.stk-tag { font-size: 11px; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.stk-tag.bad { background: #fde8e8; color: #b42318; }
.stk-sep { height: 8px; }
.stockcard .stk-in { color: #1d4ed8; } .stockcard .stk-out { color: #b45309; }
.stk-after-box { margin: 10px 0 4px; padding: 10px; border-radius: 10px; background: #e7f6ec; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.stk-after-box span { color: #15803d; font-weight: 600; } .stk-after-box b { font-size: 20px; color: #15803d; }
.stk-meta { font-size: 12px; color: #64748b; display: grid; grid-template-columns: 1fr auto; gap: 4px; margin-top: 8px; }
@media print { .stkh, .stkc, .stockcard { display: none !important; } }
/* a partner of the other kind on a customer / vendor line (warning only) */
input.m2o.pwarn { border-color: #d97706 !important; background: #fffbeb; }
/* data integrity check */
.integ-sum { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.integ-card { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line, #e5e7eb); background: var(--card, #fff); text-decoration: none; color: inherit; }
.integ-card .integ-t { flex: 1; font-size: 13px; }
.integ-card .integ-ic { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; }
.integ-card.ok .integ-ic { background: #16a34a; } .integ-card.ok b { color: #15803d; }
.integ-card.bad .integ-ic { background: #dc2626; } .integ-card.bad b { color: #b42318; font-size: 18px; }
.integ-card.bad { border-color: #fecaca; background: #fff7f7; }
/* a purchase order past its expected receipt date */
table tr.late td { background: #fff4f4 !important; }
/* keyboard shortcuts list */
.topbar .kbdhelp { background: transparent; border: 1px solid rgba(255,255,255,.25); color: inherit; border-radius: 8px; height: 30px; min-width: 34px; font-size: 16px; cursor: pointer; margin-inline-end: 6px; }
.topbar .kbdhelp:hover { background: rgba(255,255,255,.12); }
.kbdtbl { width: 100%; border-collapse: collapse; }
.kbdtbl td { padding: 6px 4px; border-bottom: 1px solid var(--line, #e5e7eb); }
.kbdtbl td:first-child { width: 42%; white-space: nowrap; }
.kbdtbl kbd { font-family: ui-monospace, monospace; font-size: 12px; padding: 2px 7px; border: 1px solid #cbd5e1; border-bottom-width: 2px; border-radius: 5px; background: #f8fafc; color: #334155; }

/* ===== document screens: calmer, more professional look (one strong action, card fields, roomy lines) ===== */
.num, .wbig, table.lines td, .wfoot b { font-variant-numeric: tabular-nums lining-nums }
:root { --gridln: #E6EDE8; --gridln2: #DBE5DE; --fieldbg: #FBFCFB; --zebra: #FAFBFA }
:root[data-theme="dark"] { --gridln: #263A2F; --gridln2: #2E463A; --fieldbg: #1B2A22; --zebra: #1C2A23 }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --gridln: #263A2F; --gridln2: #2E463A; --fieldbg: #1B2A22; --zebra: #1C2A23 } }
/* command bar */
body .wbpage .formbar { border: 1px solid var(--gridln2); border-top: 0; border-radius: 12px; padding: 10px 14px; box-shadow: 0 1px 2px rgba(16, 40, 48, .05), 0 6px 20px rgba(16, 40, 48, .05); margin-bottom: 14px }
body .wbpage .formbar .btn { background: transparent; border: 1px solid transparent; color: var(--ink); font-weight: 600; padding: 7px 12px; border-radius: 8px }
body .wbpage .formbar .btn:hover { background: var(--hover) }
body .wbpage .formbar .btn.pri { background: var(--acc); border-color: var(--acc); color: #fff; padding: 7px 18px; box-shadow: 0 2px 6px color-mix(in srgb, var(--acc) 35%, transparent) }
body .wbpage .formbar #saveBtn { border-color: var(--gridln2) }
body .wbpage .formbar .btn.danger { color: var(--bad) }
body .wdoc .wno { border: 0; background: color-mix(in srgb, var(--acc) 10%, var(--sheet)); font-size: 16px; font-weight: 700; padding: 4px 14px; border-radius: 8px }
body .wdoc .wst { border-radius: 999px; padding: 3px 12px; border: 0 }
/* header fields: one card, the label above its value */
body .wbpage .sheet .fgrid { border: 1px solid var(--gridln2); border-radius: 12px; padding: 16px 18px 6px; gap: 6px 26px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); box-shadow: 0 1px 2px rgba(16, 40, 48, .04) }
body .wbpage .sheet .fgrid > .frow { grid-template-columns: 1fr; border: 0; margin: 0; min-height: 0; padding-bottom: 10px }
body .wbpage .sheet .fgrid > .frow > label { background: none; border: 0; padding: 0 0 5px; color: var(--muted); font-weight: 600; font-size: 12.5px }
body .wbpage .sheet .fgrid > .frow input:not([type=checkbox]):not([type=radio]), body .wbpage .sheet .fgrid > .frow select { border: 1px solid var(--gridln2) !important; border-radius: 8px !important; background: var(--fieldbg) !important; height: 40px; padding: 0 12px !important; font-size: 14px }
body .wbpage .sheet .fgrid > .frow select { padding-left: 32px !important }
body .wbpage .sheet .fgrid > .frow textarea { border: 1px solid var(--gridln2) !important; border-radius: 8px !important; background: var(--fieldbg) !important; padding: 8px 12px !important }
body .wbpage .sheet .fgrid > .frow .dwrap input { border: 1px solid var(--gridln2) !important }
body .wbpage .sheet .fgrid > .frow > .val:not(:has(input, select, textarea, .seg)) { padding: 9px 0 }
body .wbpage .sheet .fgrid > .frow:focus-within { outline: 0 }
body .wbpage .sheet .fgrid > .frow:focus-within > .val { background: none }
body .wbpage .sheet .fgrid > .frow input:focus, body .wbpage .sheet .fgrid > .frow select:focus, body .wbpage .sheet .fgrid > .frow textarea:focus { border-color: var(--acc) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--acc) 15%, transparent) !important; background: var(--sheet) !important }
body .wbpage .sheet .fgrid > .frow:has(.need) { outline: 0 }
body .wbpage .sheet .fgrid > .frow:has(.need) > .val { background: none }
body .wbpage .sheet .fgrid > .frow:has(.need) input, body .wbpage .sheet .fgrid > .frow:has(.need) select { border-color: var(--bad) !important; background: var(--bad-soft) !important }
/* tabs */
body .wbpage .sheet .tabs { margin-top: 20px; border-bottom: 1px solid var(--gridln2) }
body .wbpage .sheet .tabs button { border: 0 !important; background: none !important; border-bottom: 3px solid transparent !important; border-radius: 0; font-size: 13.5px; padding: 9px 16px; color: var(--muted); margin-bottom: -1px }
body .wbpage .sheet .tabs button.on { color: var(--acc-ink); border-bottom-color: var(--acc) !important }
/* lines */
body .wbpage .sheet .tw:has(> table.lines) { border: 1px solid var(--gridln2); border-radius: 12px; overflow-x: auto; margin-top: 10px; box-shadow: 0 1px 2px rgba(16, 40, 48, .04) }
body .wbpage .sheet table.lines { border: 0 !important }
body .wbpage .sheet table.lines th { background: color-mix(in srgb, var(--acc) 6%, var(--paper)) !important; color: var(--muted) !important; font-size: 12.5px; font-weight: 700; padding: 11px 10px !important; border: 0 !important; border-bottom: 1px solid var(--gridln2) !important }
body .wbpage .sheet table.lines td { border: 0 !important; border-bottom: 1px solid var(--gridln) !important; height: 48px; font-size: 14px }
body .wbpage .sheet table.lines tbody tr:nth-child(even) td { background: var(--zebra) !important }
body .wbpage .sheet table.lines tbody tr:hover td { background: color-mix(in srgb, var(--acc) 5%, var(--sheet)) !important }
body .wbpage .sheet table.lines tr:focus-within td { background: var(--focus-soft) !important }
body .wbpage .sheet table.lines td input, body .wbpage .sheet table.lines td select { height: 47px; font-size: 14px; min-width: 0 }
body .wbpage .sheet table.lines .rn { background: transparent !important; font-family: inherit; color: var(--faint); width: 34px; min-width: 34px }
body .wbpage .sheet table.lines td:has(> input[data-model=products]) { width: 30%; min-width: 200px }
body .wbpage .sheet table.lines td:has(> input[data-model=products]) input { font-weight: 600 }
body .wbpage .sheet table.lines td:has(> input[data-c=description]) { min-width: 90px }
body .wbpage .sheet table.lines td:has(> input[data-model=taxes]) { min-width: 150px }
body .wbpage .sheet table.lines td:has(> .del) { width: 40px; min-width: 40px; text-align: center; padding: 0 !important; color: var(--faint) }
body .wbpage .sheet table.lines tfoot td { background: var(--paper) !important }
/* side panel */
body .wcard { border-radius: 12px; border-color: var(--gridln2); padding: 16px 18px; box-shadow: 0 1px 2px rgba(16, 40, 48, .04) }
body .wbig { font-family: inherit; font-size: 30px; font-weight: 700; letter-spacing: -.3px }
body .wrow { border-bottom-style: solid; font-size: 13.5px; padding: 7px 0 }
body .wsteps i { border-radius: 999px; padding: 5px 4px }
/* totals bar */
body .wfoot { border-radius: 12px; background: linear-gradient(90deg, #14624A, #0E3B2E); box-shadow: 0 10px 28px rgba(16, 40, 48, .22) }
body .wfoot > div { padding: 10px 20px }
body .wfoot b { font-size: 18px; font-weight: 700 }

/* ---------- lists: sortable, groupable, selectable; sticky header and total; zebra rows ---------- */
.list .tw { max-height: calc(100vh - 250px); overflow: auto; border: 1px solid var(--rule); border-radius: 10px; background: var(--sheet) }
.list table#tbl { border-collapse: separate; border-spacing: 0 }
.list table#tbl thead th { position: sticky; top: 0; z-index: 2; background: color-mix(in srgb, var(--paper) 70%, var(--sheet)); font-weight: 600; color: var(--muted); user-select: none }
.list table#tbl th.sort { cursor: pointer } .list table#tbl th.sort:hover { color: var(--ink) }
.list table#tbl th[data-dir]::after { color: var(--petrol-2); font-size: 10px; margin-inline-start: 5px }
.list table#tbl th[data-dir="asc"]::after { content: "▲" } .list table#tbl th[data-dir="desc"]::after { content: "▼" }
.list table#tbl tbody tr.click:nth-child(even) td { background: color-mix(in srgb, var(--paper) 45%, var(--sheet)) }
.list table#tbl tbody tr.click:hover td { background: var(--hover) }
.list table#tbl tbody tr.click.on td { background: var(--brass-soft) }
.list table#tbl tfoot td { position: sticky; bottom: 0; z-index: 2; background: var(--sheet); border-top: 2px solid var(--rule); font-weight: 700 }
.list table#tbl td.ck, .list table#tbl th.ck { width: 34px; min-width: 34px; text-align: center; padding-inline: 6px; color: var(--muted) }
.list table#tbl td.ck input, .list table#tbl th.ck input { width: 15px; height: 15px; cursor: pointer; accent-color: var(--petrol-2) }
.list table#tbl td.late { color: var(--bad, #b4322f); font-weight: 600 }
.list table#tbl tr.ugrp td { background: color-mix(in srgb, var(--petrol-2) 10%, var(--sheet)); font-weight: 700; cursor: pointer }
.list table#tbl tr.ugrp .gcnt { color: var(--muted); font-weight: 500; font-size: 12px }
.list.dense table#tbl td { padding-top: 4px; padding-bottom: 4px; font-size: 13px }
.list.dense table#tbl th { padding-top: 6px; padding-bottom: 6px }
.tools select#grpBy { height: 32px; border: 1px solid var(--rule); border-radius: 8px; background: var(--sheet); color: var(--ink); padding: 0 8px; font: inherit; font-size: 13px }
.colpick { position: relative; display: inline-block }
.colpick .pop { position: absolute; top: calc(100% + 4px); inset-inline-end: 0; z-index: 20; background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; padding: 8px; display: grid; gap: 2px; min-width: 210px; max-height: 60vh; overflow: auto; box-shadow: 0 10px 28px rgba(0, 0, 0, .12) }
.colpick .pop label { display: flex; gap: 8px; align-items: center; padding: 5px 6px; border-radius: 6px; cursor: pointer; font-size: 13px; white-space: nowrap }
.colpick .pop label:hover { background: var(--hover) }
.colpick .pop hr { border: 0; border-top: 1px solid var(--rule); margin: 4px 0 }
.bulkbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 10px; padding: 8px 12px; border: 1px solid var(--brass); background: var(--brass-soft); border-radius: 10px; font-size: 13px }
.bulkbar .btn.ghost { background: transparent; border-color: transparent }

/* ---------- two-tone app icons on the home screen ---------- */
.tile .ic.duo { background: color-mix(in srgb, var(--c) 15%, var(--sheet)); color: var(--c); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 26%, transparent), 0 4px 12px color-mix(in srgb, var(--c) 20%, transparent) }
.tile .ic.duo svg { width: 44px; height: 44px }
:root[data-theme="dark"] .tile .ic.duo { color: color-mix(in srgb, var(--c) 55%, #fff) }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tile .ic.duo { color: color-mix(in srgb, var(--c) 55%, #fff) } }

/* module tiles: thin ring in the module colour, lift and glow on hover / keyboard focus */
.tile { --tc: var(--c, var(--brass)); transition: transform .2s cubic-bezier(.2, .7, .3, 1), box-shadow .2s ease, border-color .2s ease }
.tile .ic.duo { box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--c) 55%, transparent), 0 4px 12px color-mix(in srgb, var(--c) 20%, transparent); transition: transform .22s cubic-bezier(.2, .7, .3, 1), box-shadow .22s ease }
.tile:hover, .tile:focus-visible { transform: translateY(-4px); outline: none; border-color: color-mix(in srgb, var(--tc) 60%, var(--rule)); box-shadow: var(--shadow), 0 14px 28px -12px color-mix(in srgb, var(--tc) 55%, transparent) }
.tile:hover .ic.duo, .tile:focus-visible .ic.duo { transform: scale(1.08) rotate(-3deg); box-shadow: 0 0 0 2px var(--tc), 0 0 0 6px color-mix(in srgb, var(--tc) 18%, transparent), 0 8px 18px color-mix(in srgb, var(--tc) 30%, transparent) }
.tile:active { transform: translateY(-1px) }
@media (prefers-reduced-motion: reduce) { .tile, .tile .ic.duo { transition: none !important } .tile:hover, .tile:focus-visible, .tile:hover .ic.duo, .tile:focus-visible .ic.duo { transform: none } }

/* ---------- small icons in menus and document buttons ---------- */
.dropdown a { display: flex; align-items: center; gap: 10px }
.dropdown a .mi { display: inline-grid; place-items: center; width: 18px; height: 18px; flex: none; color: var(--petrol-2); opacity: .85 }
.dropdown a .mi svg { width: 16px; height: 16px }
.formbar .acts .btn { display: inline-flex; align-items: center; gap: 6px }

/* a sale price the user may not change (filled from the price list) */
input.locked { background: color-mix(in srgb, var(--paper) 60%, var(--sheet)); color: var(--muted); cursor: not-allowed; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Crect x='5' y='11' width='14' height='9' rx='2'/%3E%3Cpath d='M8 11V8a4 4 0 018 0v3'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-size: 12px; background-position: right 6px center; padding-right: 22px }

/* account code: where it falls in its group, and what looks wrong */
.codehint { grid-column: 1 / -1; font-size: 12.5px; background: var(--info-soft); border-radius: 8px; padding: 7px 12px; margin-top: -4px; line-height: 1.7 }
.codehint .me { background: var(--sheet); border: 1px solid var(--rule); border-radius: 5px; padding: 0 6px }
.codehint .w { color: var(--bad, #b42318); font-weight: 600 }
/* a window taller than the screen scrolls inside; its title and buttons stay in sight */
.modal { display: flex; flex-direction: column; max-height: calc(100vh - 64px - env(safe-area-inset-top, 0px)); max-height: calc(100dvh - 64px - env(safe-area-inset-top, 0px)) }
.modal .mh, .modal .mf { flex: none }
.modal .mb { overflow-y: auto; min-height: 0 }

/* lines table: columns chooser */
.lcbar { position: relative; display: flex; justify-content: flex-end; margin: 0 0 6px }
.lcpop { position: absolute; top: 100%; inset-inline-end: 0; z-index: 30; display: flex; flex-direction: column; gap: 4px; background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; padding: 10px 14px; box-shadow: 0 8px 24px rgb(0 0 0 / .12); min-width: 220px; max-height: 60vh; overflow: auto }
.lcpop label { display: flex; gap: 8px; align-items: center; font-size: 13.5px }

/* reps' day settlement (repsettle.js) */
.rs { max-width: 1360px; margin: 0 auto; padding: 0 0 40px; font-size: 14px }
.rs .hd { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 4px 0 14px }
.rs .hd .ttl { display: flex; flex-direction: column } .rs .hd .ttl small { color: var(--muted) } .rs .hd .ttl b { font-size: 22px; letter-spacing: .3px }
.rs .who { display: flex; gap: 10px; align-items: center; background: var(--sheet); border: 1px solid var(--rule); border-radius: 12px; padding: 8px 14px }
.rs .av { width: 38px; height: 38px; border-radius: 50%; background: var(--petrol); color: #fff; display: grid; place-items: center; font-weight: 700 }
.rs .who small { display: block; color: var(--muted); font-size: 12px }
.rs .acts { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap }
.rs .stepper { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--sheet); border: 1px solid var(--rule); border-radius: 14px; overflow: hidden; margin-bottom: 14px }
.rs .stp { padding: 12px 16px; display: flex; gap: 12px; align-items: center; border-inline-end: 1px solid var(--rule); position: relative }
.rs .stp:last-child { border: 0 }
.rs .stp .dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--rule); color: var(--muted); flex: none }
.rs .stp.done .dot { background: var(--ok); color: #fff } .rs .stp.cur .dot { background: var(--petrol); color: #fff; box-shadow: 0 0 0 4px color-mix(in srgb, var(--petrol) 20%, transparent) }
.rs .stp b { display: block } .rs .stp small { color: var(--muted); font-size: 12px }
.rs .stp.cur { background: color-mix(in srgb, var(--petrol) 6%, var(--sheet)) }
.rs .stp.cur::after { content: ''; position: absolute; inset-inline: 0; bottom: 0; height: 3px; background: var(--petrol) }
.rs .kp { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 14px }
.rs .k { background: var(--sheet); border: 1px solid var(--rule); border-radius: 12px; padding: 12px 16px }
.rs .k small { color: var(--muted); display: block; font-size: 12.5px } .rs .k b { font-size: 21px; display: block; margin-top: 4px } .rs .k i { font-style: normal; color: var(--faint); font-size: 12px }
.rs .k.bad b, .rs .bad-t, .rs .big.bad { color: var(--bad) } .rs .k.ok b, .rs .ok-t { color: var(--ok) }
.rs .grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; align-items: start }
.rs .card { background: var(--sheet); border: 1px solid var(--rule); border-radius: 14px; margin-bottom: 14px; overflow: hidden }
.rs .ch { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--rule); flex-wrap: wrap }
.rs .ch h3 { margin: 0; font-size: 15.5px }
.rs .num1 { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--ok); color: #fff }
.rs .num1.cur { background: var(--petrol) } .rs .num1.off { background: var(--rule); color: var(--muted) }
.rs .lock { margin-inline-start: auto; font-size: 12.5px; color: var(--ok); background: var(--ok-soft); padding: 4px 10px; border-radius: 20px }
.rs .open { margin-inline-start: auto; font-size: 12.5px; color: var(--warn); background: var(--warn-soft); padding: 4px 10px; border-radius: 20px }
.rs .tw { overflow-x: auto }
.rs table { width: 100%; border-collapse: collapse }
.rs th { font-weight: 600; color: var(--muted); font-size: 12.5px; background: color-mix(in srgb, var(--rule) 35%, var(--sheet)); padding: 9px 10px; text-align: start; white-space: nowrap }
.rs td { padding: 9px 10px; border-top: 1px solid var(--rule) } .rs td.n, .rs th.n { text-align: center; font-variant-numeric: tabular-nums }
.rs tfoot td { font-weight: 700; background: color-mix(in srgb, var(--rule) 25%, var(--sheet)) }
.rs .pill { display: inline-block; padding: 2px 9px; border-radius: 12px; font-size: 12px; font-weight: 600; white-space: nowrap }
.rs .pill.bad { background: var(--bad-soft); color: var(--bad) } .rs .pill.ok { background: var(--ok-soft); color: var(--ok) }
.rs .sub { color: var(--faint); font-size: 12px }
.rs .cash { display: grid; grid-template-columns: 1fr 1fr } .rs .cash > div:first-child { border-inline-end: 1px solid var(--rule) }
.rs .mrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--rule) }
.rs .cash .mrow:first-child, .rs .card > div > .mrow:first-of-type { border-top: 0 }
.rs .mrow.t { font-weight: 700; font-size: 16px; background: color-mix(in srgb, var(--rule) 25%, var(--sheet)) }
.rs .inp { width: 120px; text-align: center; border: 1.5px solid var(--petrol-2); border-radius: 8px; padding: 6px; font: inherit; font-weight: 700; background: var(--sheet); color: inherit }
.rs .big { font-size: 30px; display: block; margin-bottom: 6px }
.rs .done { padding: 10px 16px; line-height: 2; font-size: 13.5px }
.rs .sig { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px 16px }
.rs .sig div { border: 1px dashed var(--rule); border-radius: 10px; padding: 10px; min-height: 54px } .rs .sig small { color: var(--muted); display: block }
.rs .je td { font-size: 13px }
.rs .badge.st-closed { background: var(--ok-soft); color: var(--ok) } .rs .badge.st-pending { background: var(--warn-soft); color: var(--warn) } .rs .badge.st-cancel { background: var(--bad-soft); color: var(--bad) }
.rs .notice.warn { margin-bottom: 14px }
@media (max-width: 1100px) { .rs .grid { grid-template-columns: 1fr } .rs .kp { grid-template-columns: repeat(2, 1fr) } .rs .stepper { grid-template-columns: repeat(2, 1fr) } .rs .cash { grid-template-columns: 1fr } }
@media print { .rs .acts, .rs .cp { display: none } .rs .grid { grid-template-columns: 1fr 300px } }

/* ======================================================================================================
   Osool design (approved Nov 2026): one field, one look, on every screen.
   - every field 40px, a visible grey frame (never hidden until hovered), 6px corners, white;
   - hover darkens the frame, typing gives the petrol frame with a soft ring;
   - read only: grey ground, no frame (a lock when locked by rights); required: a brass dot after the name;
   - an error: red frame on a pale red ground; names above the fields; 3 columns; titled groups;
   - one dark primary button per bar, the others framed or text only.
   ====================================================================================================== */
:root { --fld-bg: #ffffff; --fld-bd: #CFDCD2; --fld-bd-h: #8FA99B; --fld-h: 40px; --fld-r: 6px; --fld-ro: #F0F4F1; --ring: color-mix(in srgb, var(--petrol-2) 18%, transparent) }
:root[data-theme="dark"] { --fld-bg: #1B2A22; --fld-bd: #34493C; --fld-bd-h: #5B7A69; --fld-ro: #1C2A23 }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --fld-bg: #1B2A22; --fld-bd: #34493C; --fld-bd-h: #5B7A69; --fld-ro: #1C2A23 } }

/* the field */
.frow { gap: 6px }
.frow > label { font-size: 13px; font-weight: 500; color: var(--muted); opacity: 1 }
.frow.req > label::after { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--brass); margin-inline-start: 6px; vertical-align: middle }
.frow input:not([type=checkbox]):not([type=radio]):not(.dnative), .frow select, .frow textarea,
.modal .f input:not([type=checkbox]):not([type=radio]), .modal .f select, .modal .f textarea {
  background-color: var(--fld-bg); border: 1px solid var(--fld-bd); border-radius: var(--fld-r); min-height: var(--fld-h); padding: 8px 12px; font-size: 14px }
.frow input:not([type=checkbox]):hover, .frow select:hover, .frow textarea:hover,
.modal .f input:hover, .modal .f select:hover, .modal .f textarea:hover { border-color: var(--fld-bd-h) }
.frow input:focus, .frow select:focus, .frow textarea:focus,
.modal .f input:focus, .modal .f select:focus, .modal .f textarea:focus { background-color: var(--fld-bg); border-color: var(--petrol-2) !important; box-shadow: 0 0 0 3px var(--ring) }
.frow input[readonly]:not(.ddisp), .frow input:disabled, .frow select:disabled, .frow textarea[readonly],
.modal .f input[readonly], .modal .f input:disabled, .modal .f select:disabled { background-color: var(--fld-ro); border-color: var(--fld-ro); border-style: solid; color: var(--ink); box-shadow: none }
/* locked by rights (a rep's van and name): a lock on the reading end */
.frow input.locked:not([type=checkbox]), .frow input:disabled:not([type=checkbox]):not([type=radio]), .frow select:disabled {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%238a979b' stroke-width='1.5'%3E%3Crect x='3.5' y='7' width='9' height='6.5' rx='1.2'/%3E%3Cpath d='M5.5 7V5a2.5 2.5 0 015 0v2'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 12px center; background-size: 16px; padding-left: 36px !important }
[dir=ltr] .frow input.locked:not([type=checkbox]), [dir=ltr] .frow input:disabled:not([type=checkbox]):not([type=radio]), [dir=ltr] .frow select:disabled { background-position: right 12px center; padding-left: 12px !important; padding-right: 36px !important }
.frow input.invalid, .frow select.invalid, .frow textarea.invalid, .modal .f input.invalid, input.m2o.invalid { border-color: var(--bad) !important; background-color: var(--bad-soft) !important }
.frow .help { font-size: 12px; color: var(--muted) }
/* a value shown, not typed (a posted document): the read-only look */
.frow .val:not(:has(input, select, textarea, button, .seg)) { background: var(--fld-ro); border: 0; border-radius: var(--fld-r); min-height: var(--fld-h); padding: 8px 12px; font-size: 14px }
.frow .val:not(:has(input, select, textarea, button, .seg)):empty::before { content: "—"; color: var(--faint) }

/* the grid of fields and its titled groups */
.fgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px 20px }
@media (max-width: 1100px) { .fgrid { grid-template-columns: repeat(2, minmax(0, 1fr)) } }
@media (max-width: 640px) { .fgrid { grid-template-columns: minmax(0, 1fr) } }
.fgroups { display: flex; flex-direction: column; gap: 0 }
.fgroup { padding: 18px 0 20px }
.fgroup + .fgroup { border-top: 1px solid var(--rule-2) }
.fgroup:first-child { padding-top: 4px }
.fgroup > h3 { margin: 0 0 14px; font-size: 15px; font-weight: 600; color: var(--ink) }
.fgroup:not(:has(.frow:not([hidden]))) { display: none }

/* buttons: one dark primary, the others framed or text */
.btn { min-height: 38px; padding: 7px 16px; border-color: var(--fld-bd); border-radius: 6px; font-weight: 500 }
.btn:hover { border-color: var(--fld-bd-h); background: var(--hover) }
.btn.pri { background: var(--petrol); border-color: var(--petrol); color: #fff; font-weight: 600 }
.btn.pri:hover { background: var(--petrol-2); border-color: var(--petrol-2); filter: none }
.btn.sm { min-height: 30px; padding: 3px 10px }
.btn.ghost { border-color: transparent }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--fld-bd)) }

/* the document's stages: a pill */
.pipeline { border-radius: 999px; border-color: var(--rule) }
.pipeline span { padding: 5px 14px; font-size: 12.5px }
.pipeline span.on { background: var(--petrol); color: #fff }

/* lines: a calm header, room to read, cells that look editable when they are */
.lines th { background: var(--rule-2); color: var(--muted); font-size: 12.5px; font-weight: 600; height: 40px; padding: 0 10px; white-space: nowrap }
.lines td { padding: 6px 8px; height: 48px }
.lines input, .lines select { min-height: 34px; border: 1px solid var(--rule); background: var(--fld-bg); border-radius: 5px; padding: 5px 8px }
.lines input:hover, .lines select:hover { border-color: var(--fld-bd-h) }
.lines input:focus, .lines select:focus { border-color: var(--petrol-2); box-shadow: 0 0 0 3px var(--ring); background: var(--fld-bg) }
.lines input[readonly], .lines input:disabled { border-color: transparent; background: transparent; box-shadow: none }
.lines input.invalid { border-color: var(--bad) !important; background: var(--bad-soft) !important }

/* tabs: an underline, not boxes */
.tabs { gap: 22px; border-bottom: 1px solid var(--rule) }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 10px 2px; background: none }
.tabs button.on { border: 0; border-bottom: 2px solid var(--petrol); color: var(--petrol); background: none }
:root[data-theme="dark"] .tabs button.on { color: var(--ink); border-bottom-color: var(--brass) }

/* the approved design on the document page (it comes after the page's own layers, so it wins) */
body .wbpage .sheet .fgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; border: 1px solid var(--rule); border-radius: 10px; padding: 18px 20px 22px; box-shadow: none }
@media (max-width: 1100px) { body .wbpage .sheet .fgrid { grid-template-columns: repeat(2, minmax(0, 1fr)) } }
@media (max-width: 640px) { body .wbpage .sheet .fgrid { grid-template-columns: minmax(0, 1fr) } }
body .wbpage .sheet .fgrid > .frow { padding-bottom: 0 }
body .wbpage .sheet .fgrid > .frow > label { padding: 0 0 6px; color: var(--muted); font-weight: 500; font-size: 13px }
body .wbpage .sheet .fgrid > .frow.req > label::after { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--brass); margin-inline-start: 6px; vertical-align: middle }
body .wbpage .sheet .fgrid > .frow input:not([type=checkbox]):not([type=radio]), body .wbpage .sheet .fgrid > .frow select,
body .wbpage .sheet .fgrid > .frow textarea, body .wbpage .sheet .fgrid > .frow .dwrap input { border: 1px solid var(--fld-bd) !important; border-radius: 6px !important; background-color: var(--fld-bg) !important }
body .wbpage .sheet .fgrid > .frow input:not([type=checkbox]):hover, body .wbpage .sheet .fgrid > .frow select:hover, body .wbpage .sheet .fgrid > .frow textarea:hover { border-color: var(--fld-bd-h) !important }
body .wbpage .sheet .fgrid > .frow input:focus, body .wbpage .sheet .fgrid > .frow select:focus, body .wbpage .sheet .fgrid > .frow textarea:focus { border-color: var(--petrol-2) !important; box-shadow: 0 0 0 3px var(--ring) !important }
body .wbpage .sheet .fgrid > .frow input[readonly]:not(.ddisp):not([type=checkbox]), body .wbpage .sheet .fgrid > .frow input:disabled:not([type=checkbox]), body .wbpage .sheet .fgrid > .frow select:disabled { background-color: var(--fld-ro) !important; border-color: var(--fld-ro) !important; color: var(--ink) }
body .wbpage .sheet .fgrid > .frow > .val:not(:has(input, select, textarea, .seg)) { background: var(--fld-ro); border-radius: 6px; min-height: 40px; padding: 9px 12px }
body .wbpage .sheet .fgroup .fgrid { margin: 0 }

/* lines: a calm header, room to read, and the cells you type in framed */
body .wbpage .sheet table.lines { border: 1px solid var(--rule) !important; border-radius: 10px !important; border-collapse: separate !important; overflow: hidden }
body .wbpage .sheet table.lines th { background: var(--rule-2) !important; color: var(--muted) !important; font-size: 12.5px; height: 40px; border: 0 !important; border-bottom: 1px solid var(--rule) !important }
body .wbpage .sheet table.lines td { border: 0 !important; border-bottom: 1px solid var(--rule-2) !important; padding: 6px 6px !important }
body .wbpage .sheet table.lines tbody tr:nth-child(even) td { background: transparent !important }
body .wbpage .sheet table.lines td:focus-within { outline: 0 }
body .wbpage .sheet table.lines td input:not([readonly]):not([type=checkbox]), body .wbpage .sheet table.lines td select {
  height: 36px !important; border: 1px solid var(--fld-bd) !important; border-radius: 5px !important; background: var(--fld-bg) !important; padding: 4px 8px }
body .wbpage .sheet table.lines td input:not([readonly]):hover, body .wbpage .sheet table.lines td select:hover { border-color: var(--fld-bd-h) !important }
body .wbpage .sheet table.lines td input:focus, body .wbpage .sheet table.lines td select:focus { border-color: var(--petrol-2) !important; box-shadow: 0 0 0 3px var(--ring) !important }
body .wbpage .sheet table.lines td input.invalid, body .wbpage .sheet table.lines td input.belowcost { border-color: var(--bad) !important; background: var(--bad-soft) !important }
body .wbpage .sheet table.lines .rn { padding: 0 4px !important }
body .wbpage .sheet .fgrid > .frow:has(> .val > input[type=checkbox]) { border: 0 !important; border-bottom: 0 !important; align-self: end; min-height: 40px; padding: 0 !important; align-items: center }

/* the same field on settings pages, dialogs and report filters */
label.f { font-size: 13px; font-weight: 500; color: var(--muted); gap: 6px }
label.f input:not([type=checkbox]):not([type=radio]), label.f select, label.f textarea {
  border: 1px solid var(--fld-bd); border-radius: 6px; background-color: var(--fld-bg); min-height: var(--fld-h); padding: 8px 12px; color: var(--ink); font-size: 14px; outline: none; transition: border-color .15s, box-shadow .15s }
label.f textarea { min-height: 84px }
label.f input:not([type=checkbox]):hover, label.f select:hover, label.f textarea:hover { border-color: var(--fld-bd-h) }
label.f input:focus, label.f select:focus, label.f textarea:focus { border-color: var(--petrol-2); box-shadow: 0 0 0 3px var(--ring) }
label.f input[readonly], label.f input:disabled, label.f select:disabled { background-color: var(--fld-ro); border-color: var(--fld-ro); color: var(--ink) }
.filters label.f input:not([type=checkbox]), .filters label.f select { min-height: 36px; padding: 6px 10px }
label.f select { -webkit-appearance: none; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a979b' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 12px center; background-size: 12px; padding-left: 34px }
[dir=ltr] label.f select { background-position: right 12px center; padding-left: 12px; padding-right: 34px }
body .wbpage .sheet .fgrid > .frow input.locked:not([type=checkbox]), body .wbpage .sheet .fgrid > .frow input:disabled:not([type=checkbox]):not([type=radio]) {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%238a979b' stroke-width='1.5'%3E%3Crect x='3.5' y='7' width='9' height='6.5' rx='1.2'/%3E%3Cpath d='M5.5 7V5a2.5 2.5 0 015 0v2'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important; background-position: left 12px center !important; background-size: 16px !important; padding-left: 36px !important; background-color: var(--fld-ro) !important; border-color: var(--fld-ro) !important }
[dir=ltr] body .wbpage .sheet .fgrid > .frow input.locked:not([type=checkbox]) { background-position: right 12px center !important; padding-left: 12px !important; padding-right: 36px !important }
#tabStart { position: absolute; width: 1px; height: 1px; overflow: hidden; outline: 0 }
/* the filters above a list's columns */
#tbl thead tr.cfrow th { background: var(--sheet) !important; padding: 4px 6px !important; position: static; border-top: 0 }
#tbl thead tr.cfrow input { width: 100%; min-width: 60px; height: 30px; border: 1px solid var(--fld-bd); border-radius: 5px; background: var(--fld-bg); padding: 2px 8px; font-size: 12.5px; color: var(--ink); outline: none; font-weight: 400 }
#tbl thead tr.cfrow input:focus { border-color: var(--petrol-2); box-shadow: 0 0 0 2px var(--ring) }
#tbl thead tr.cfrow input::placeholder { color: var(--faint) }
#tbl thead tr.cfrow input:not(:placeholder-shown) { border-color: var(--petrol-2); background: color-mix(in srgb, var(--petrol-2) 6%, var(--fld-bg)) }
/* Excel-like column filters: the arrow in a list heading and its menu */
#tbl th .cfb { display: inline-grid; place-items: center; width: 20px; height: 20px; margin-inline-start: 6px; vertical-align: middle; border: 1px solid transparent; border-radius: 4px; background: none; color: var(--faint); cursor: pointer; padding: 0 }
#tbl th .cfb svg { width: 12px; height: 12px }
#tbl th .cfb:hover { border-color: var(--fld-bd); color: var(--ink); background: var(--sheet) }
#tbl th .cfb.on { color: #fff; background: var(--petrol-2); border-color: var(--petrol-2) }
.cfpop { position: absolute; z-index: 60; width: 290px; max-width: calc(100vw - 16px); background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; box-shadow: 0 10px 30px rgba(15, 40, 48, .18); padding: 10px; display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; color: var(--ink) }
.cfpop .cfsort { display: flex; flex-direction: column; gap: 2px; border-bottom: 1px solid var(--rule-2); padding-bottom: 6px }
.cfpop .cfsort button { text-align: start; background: none; border: 0; padding: 6px 8px; border-radius: 6px; cursor: pointer; color: var(--ink); font: inherit }
.cfpop .cfsort button:hover { background: var(--hover) }
.cfpop .cfnum { display: flex; flex-direction: column; gap: 6px; border-bottom: 1px solid var(--rule-2); padding-bottom: 8px }
.cfpop .cfab { display: flex; gap: 6px }
.cfpop select, .cfpop input[type=number], .cfpop .cfq { width: 100%; min-height: 34px; border: 1px solid var(--fld-bd); border-radius: 6px; background: var(--fld-bg); padding: 4px 10px; font: inherit; color: var(--ink); outline: none }
.cfpop select:focus, .cfpop input:focus { border-color: var(--petrol-2); box-shadow: 0 0 0 3px var(--ring) }
.cfpop .cfall { display: flex; align-items: center; gap: 8px; padding: 4px 6px }
.cfpop .cflist { max-height: 260px; overflow: auto; border: 1px solid var(--rule-2); border-radius: 6px; padding: 4px }
.cfpop .cflist label { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 5px; cursor: pointer }
.cfpop .cflist label:hover { background: var(--hover) }
.cfpop .cflist label span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.cfpop .cflist label small { color: var(--faint); font-variant-numeric: tabular-nums }
.cfpop input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--petrol-2); margin: 0 }
.cfpop .cffoot { display: flex; gap: 8px; justify-content: flex-start }

/* van settlement for who does not see the money (the storekeeper): the amounts are not shown (nor sent) */
.rs.nomoney .money { display: none !important }

/* the line being worked on, and the cell with the cursor */
table.lines tbody tr:focus-within > td { background: rgba(31, 95, 107, .07) !important }
table.lines tbody tr:focus-within > td:first-child { box-shadow: inset 3px 0 0 #14624A }
[dir=rtl] table.lines tbody tr:focus-within > td:first-child { box-shadow: inset -3px 0 0 #14624A }
table.lines tbody td:focus-within input:not([type=checkbox]), table.lines tbody td:focus-within select { border-color: #14624A !important; box-shadow: 0 0 0 2px rgba(20, 98, 74, .22) !important; background: #fff !important }

/* a goods-only van settlement (the cash is received apart: توريد نقدية من مندوب) */
.rs.stockonly .cashpart { display: none !important }

/* payroll sticky totals: keep الإجمالي/الصافي pinned while scrolling sideways (override sheet wrapper rules) */
body .wbpage .sheet table.lines.pay { overflow: visible }
.wbpage .sheet table.lines th.stick1, .wbpage .sheet table.lines th.stick2 { position: sticky }

/* payroll sticky totals: opaque background so scrolled cells don't bleed through */
body .wbpage .sheet table.lines.pay td.stick1, body .wbpage .sheet table.lines.pay td.stick2 { background: var(--sheet) !important }

/* ================= design system pass: theme toggle, hierarchy, skeletons, empty states, mobile ================= */
.topbar .themebtn { display: inline-grid; place-items: center; padding: 0 }
.topbar .themebtn svg { display: block }

/* skeleton shimmer while figures load */
.skl { position: relative; overflow: hidden; background: var(--rule-2); border-radius: 7px }
.skl::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--sheet) 75%, transparent), transparent); animation: skl 1.3s infinite }
@keyframes skl { 100% { transform: translateX(100%) } }
.skwrap { display: grid; gap: 16px; padding-top: 18px }
.hk.sk { pointer-events: none; gap: 8px }
.skpanel { background: var(--sheet); border: 1px solid var(--rule); border-radius: 14px; padding: 18px }

/* empty states: an icon in a soft ring, calm wording */
.empty { padding: 52px 18px; text-align: center; color: var(--muted); font-size: 13.5px; line-height: 1.9 }
.empty::before { content: ''; display: block; width: 46px; height: 46px; margin: 0 auto 10px;
  background: var(--faint); opacity: .8;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 7.5L12 3.5l8.5 4v9L12 20.5l-8.5-4z'/%3E%3Cpath d='M3.5 7.5L12 11.5l8.5-4M12 11.5v9'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 7.5L12 3.5l8.5 4v9L12 20.5l-8.5-4z'/%3E%3Cpath d='M3.5 7.5L12 11.5l8.5-4M12 11.5v9'/%3E%3C/svg%3E") center / contain no-repeat }
.empty b { font-size: 15.5px }

/* dashboard hierarchy: the headline numbers lead, the rest follows */
.dashp .hero .hk .v { font-size: 28px; font-weight: 700 }
.dashp .hero .hk { padding: 16px 18px 12px }
.dashp .mini { opacity: .96 }
.dashp .mini .mk { box-shadow: none }

/* mobile & tablet */
@media (max-width: 980px) {
  .menus { overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch }
  .menus::-webkit-scrollbar { display: none }
}
@media (max-width: 720px) {
  .welcome { padding-top: 14px }
  .welcome h1 { font-size: 20px }
  .welcome p { font-size: 12.5px }
  .launcher { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; padding: 16px 0 6px }
  .tile { padding: 12px 6px; gap: 8px; border-radius: 12px }
  .tile .ic { width: 50px; height: 50px; border-radius: 13px }
  .tile .ic.duo svg { width: 27px; height: 27px }
  .tile b { font-size: 12.5px }
  .dashp .hero { gap: 10px }
  .dashp .hero .hk .v { font-size: 24px }
  .skwrap { padding-top: 12px }
}

/* saved filters popup (list screens) */
.colpick .pop .svrow { display: flex; gap: 4px; align-items: center }
.colpick .pop .svapp { flex: 1; text-align: start; background: none; border: 0; padding: 6px 8px; border-radius: 6px; cursor: pointer; font: inherit; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); min-width: 0 }
.colpick .pop .svapp:hover { background: var(--hover) }
.colpick .pop .svdel { background: none; border: 0; color: var(--faint); cursor: pointer; font-size: 15px; line-height: 1; padding: 4px 7px; border-radius: 6px }
.colpick .pop .svdel:hover { color: #c0392b; background: var(--hover) }
.colpick .pop #svAdd { background: none; border: 1px dashed var(--rule); border-radius: 8px; padding: 7px 8px; cursor: pointer; font: inherit; font-size: 13px; color: var(--ink) }
.colpick .pop #svAdd:hover:not(:disabled) { border-color: var(--petrol-2); color: var(--petrol-2) }
.colpick .pop #svAdd:disabled { opacity: .5; cursor: default }

/* phones: the top bar must never widen the page (it made the whole screen scroll sideways in RTL) */
@media (max-width: 860px) { html, body { overflow-x: clip; max-width: 100vw } .topbar { overflow: hidden } }

/* printing: white paper in every theme (dark mode and the grey page colour must not reach the printout) */
@media print { html, body { background: #fff !important; color: #000 !important } }
@media print { :root, :root[data-theme=dark] { color-scheme: light !important; background: #fff !important } }

/* point of sale icons (public/js/posicons.js): soft tinted chip per action; the app tile's pop on hover */
.pi{display:inline-grid;place-items:center;flex:none;vertical-align:middle}
.pi svg{width:100%;height:100%;overflow:visible}
.btn:has(.pi),button:has(.pi){display:inline-flex;align-items:center;justify-content:center;gap:8px}
/* B: soft duotone chip, rounded, tinted per action */
.pi.pb{width:30px;height:30px;border-radius:10px;padding:5px;color:var(--pc);background:color-mix(in srgb,var(--pc) 14%,transparent);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--pc) 28%,transparent)}
.pi.pb .ac{fill:color-mix(in srgb,var(--pc) 35%,transparent)}
:root[data-theme=dark] .pi.pb{color:color-mix(in srgb,var(--pc) 55%,#fff)}
@media (prefers-color-scheme:dark){:root:not([data-theme=light]) .pi.pb{color:color-mix(in srgb,var(--pc) 55%,#fff)}}
.btn.pri .pb{background:rgba(255,255,255,.16);color:#fff;box-shadow:none}
.btn.pri .pb .ac{fill:rgba(255,255,255,.4)}
/* on the dark top bar the chips go light */
.btn.sm .pb{color:color-mix(in srgb,var(--pc) 35%,#fff);background:rgba(255,255,255,.1);box-shadow:inset 0 0 0 1px rgba(255,255,255,.18)}
.btn.sm .pb .ac{fill:rgba(255,255,255,.3)}
@keyframes pop{0%{transform:scale(1) rotate(0)}30%{transform:scale(1.22) rotate(-10deg)}55%{transform:scale(.96) rotate(7deg)}75%{transform:scale(1.08) rotate(-3deg)}100%{transform:scale(1.04) rotate(0)}}
@keyframes ring{0%{box-shadow:0 0 0 0 color-mix(in srgb,var(--pc,var(--c,#14624A)) 45%,transparent)}100%{box-shadow:0 0 0 12px transparent}}
.tile:hover .ic svg,.btn:hover .pi svg,.btn:hover .pi{animation:pop .75s cubic-bezier(.3,1.6,.5,1) forwards}
.tile:hover .ic.duo{animation:ring .8s ease-out;transform:none}
@keyframes poplite{0%{transform:scale(1)}100%{transform:scale(1.06)}}
/* the owner asked for a lighter hover motion even when the system reduces motion: a plain 6% scale, no tilt, no ring */
@media (prefers-reduced-motion:reduce){.tile:hover .ic svg,.btn:hover .pi,.btn:hover .pi svg{animation:poplite .25s ease-out forwards}.tile:hover .ic.duo{animation:none}}
/* on the cashier's action grid the chip is smaller so the cart keeps its height on a short screen (600px) */
.pos-act .btn:not(.pri) .pb{width:24px;height:24px;padding:4px;border-radius:8px}

/* the home screen's app tiles (owner's pick, direction A): a big solid colour square with a white icon, no card around it;
   the card shows on hover and on focus. The name is centred under its icon, also when it wraps to two lines. */
.launcher { gap: 22px }
.launcher .tile { background: transparent; border-color: transparent; box-shadow: none; gap: 12px; text-align: center }
.launcher .tile b { text-align: center; max-width: 100%; line-height: 1.35; font-size: 15px }
.launcher .tile .ic, .launcher .tile .ic.duo { width: 84px; height: 84px; border-radius: 26px; background: linear-gradient(150deg, color-mix(in srgb, var(--c) 78%, #fff), var(--c)); color: #fff; box-shadow: 0 10px 22px -8px color-mix(in srgb, var(--c) 70%, transparent), inset 0 1px 0 rgba(255, 255, 255, .35) }
.launcher .tile .ic svg, .launcher .tile .ic.duo svg { width: 44px; height: 44px }
:root[data-theme="dark"] .launcher .tile .ic.duo { color: #fff }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .launcher .tile .ic.duo { color: #fff } }
.launcher .tile:hover, .launcher .tile:focus-visible { background: var(--sheet); border-color: color-mix(in srgb, var(--tc) 35%, var(--rule)); box-shadow: var(--shadow) }
@media (max-width: 860px) {
  .launcher { gap: 12px }
  .launcher .tile .ic, .launcher .tile .ic.duo { width: 64px; height: 64px; border-radius: 20px }
  .launcher .tile .ic svg, .launcher .tile .ic.duo svg { width: 34px; height: 34px }
  .launcher .tile b { font-size: 13px }
}

/* proposal (owner reviewing, not yet approved): exactly five app tiles per row on wide screens,
   two rows of five for the ten modules; small screens keep the responsive auto-fill */
@media (min-width: 721px) {
  .launcher { grid-template-columns: repeat(5, 1fr) }
}

/* icon motion: a gentle lift and colour shift on hover (menus, dashboard cards, icon buttons) */
.dropdown a .mi svg, .btn svg, .topbar .home svg, .topbar .back svg, .search svg, .smart button svg, .tile .ic svg { transition: transform .18s ease, color .18s ease }
.dropdown a:hover .mi svg { transform: translateY(-2px) scale(1.08); color: var(--brass) }
.btn:hover svg, .topbar .home:hover svg, .topbar .back:hover svg { transform: translateY(-2px) scale(1.08) }
@media (prefers-reduced-motion: reduce) { .dropdown a .mi svg, .btn svg, .topbar .home svg, .topbar .back svg, .search svg, .smart button svg, .tile .ic svg { transition: none } .dropdown a:hover .mi svg, .btn:hover svg, .topbar .home:hover svg, .topbar .back:hover svg { transform: none } }

/* brand: «أصول» word on a gold-gradient badge with accounting total lines (thick rule over a thin one) + animated OSOOL ERP wordmark */
.brandmark { min-width: 58px; height: 40px; border-radius: 11px; background: linear-gradient(145deg, #C9A227, #E4C566); display: inline-flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 3px 10px rgba(0, 0, 0, .25); padding: 2px 10px 4px; flex: none }
.brandmark b { font-size: 17px; font-weight: 800; color: #0E3B2E; line-height: 1.1 }
.brandmark i { display: block; width: 78%; border-top: 2px solid #0E3B2E; margin-top: 1px }
.brandmark u { display: block; width: 78%; border-top: 1px solid #0E3B2E; margin-top: 1.5px; text-decoration: none }
.brandmark.lg { min-width: 120px; height: 74px; border-radius: 18px }
.brandmark.lg b { font-size: 34px }
.wordmark { direction: ltr; font-weight: 800; color: #E4C566; letter-spacing: 2.5px; font-size: 15px; text-transform: uppercase; white-space: nowrap }
.wordmark span { display: inline-block; opacity: 0; animation: osoolLetter .45s both }
@keyframes osoolLetter { from { opacity: 0; transform: translateX(-14px) } to { opacity: 1; transform: translateX(0) } }
.topbar .brand { display: flex; align-items: center; gap: 11px; padding: 0 4px; flex: none }
@media (max-width: 860px) { .topbar .brand .wordmark { display: none } }
@media (prefers-reduced-motion: reduce) { .wordmark span { animation: none; opacity: 1 } }

/* splash: brief brand screen after a successful login (~1s, purely decorative, never blocks entry) */
.splash { position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 15px; color: #fff; background: radial-gradient(120% 140% at 50% 0%, #17614B 0%, #0E3B2E 55%, #0A2E23 100%); transition: opacity .3s ease }
.splash.out { opacity: 0; pointer-events: none }
.splash .wordmark { font-size: 24px; letter-spacing: 5px }
.splash .sbar { width: 150px; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .18); overflow: hidden }
.splash .sbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #C9A227, #E4C566) }
.splash .smsg { font-size: 12px; color: #CFE3D8; opacity: 0 }
.splash.play .smarkwrap { animation: osoolPop .55s cubic-bezier(.2, .9, .3, 1.3) both }
.splash.play .sbar i { animation: osoolLoad 2.4s .45s ease both }
.splash.play .smsg { animation: osoolUp .4s .6s both }
@keyframes osoolPop { from { opacity: 0; transform: scale(.65) translateY(14px) } to { opacity: 1; transform: scale(1) translateY(0) } }
@keyframes osoolUp { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: translateY(0) } }
@keyframes osoolLoad { from { width: 0 } to { width: 100% } }
@media (prefers-reduced-motion: reduce) { .splash { transition: none } .splash.play .smarkwrap, .splash.play .sbar i, .splash.play .smsg { animation: none } .splash .smsg { opacity: 1 } }
