/* ---------- design tokens ----------
   --accent is the company's main colour (Company settings); everything primary is derived from it. */
:root {
  --accent: #0d9488;
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --surface-3: #eef0f5;
  --border: #e5e7ef;
  --border-strong: #d4d8e4;
  --text: #0f1729;
  --text-2: #344054;
  --muted: #6b7489;
  --primary: var(--accent);
  --primary-hover: color-mix(in srgb, var(--accent) 85%, #000);
  --primary-ink: #ffffff;
  --primary-soft: color-mix(in srgb, var(--accent) 9%, #fff);
  --primary-line: color-mix(in srgb, var(--accent) 32%, #fff);
  --ok: #0e9f6e;
  --ok-soft: #e6f7f0;
  --ok-line: #b4e6d0;
  --warn: #b7791f;
  --warn-soft: #fdf4e3;
  --bad: #d92d43;
  --bad-soft: #fdecee;
  --bad-line: #f6c3ca;
  --info: #0b84d8;
  --info-soft: #e7f3fc;
  --chart-1: var(--primary);
  --chart-2: #f59e0b;
  --sidebar: #0a1a2f;
  --sidebar-2: #0f2440;
  --sidebar-text: #a3a9c4;
  --sidebar-muted: #646b8b;
  --sidebar-hover: rgba(255, 255, 255, .06);
  --sidebar-active: color-mix(in srgb, var(--accent) 26%, transparent);
  --sidebar-mark: color-mix(in srgb, var(--accent) 55%, #fff);
  --row-hover: #f8f9fc;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .05);
  --shadow-md: 0 8px 24px -6px rgba(16, 24, 40, .14), 0 2px 6px -2px rgba(16, 24, 40, .06);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Inter", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0a0d19;
  --surface: #121628;
  --surface-2: #161b30;
  --surface-3: #1d233b;
  --border: #252c46;
  --border-strong: #323b5c;
  --text: #e8eaf4;
  --text-2: #c3c8db;
  --muted: #8b92ad;
  --primary: color-mix(in srgb, var(--accent) 70%, #fff);
  --primary-hover: color-mix(in srgb, var(--accent) 58%, #fff);
  --primary-ink: #0b0e1a;
  --primary-soft: color-mix(in srgb, var(--accent) 20%, transparent);
  --primary-line: color-mix(in srgb, var(--accent) 45%, transparent);
  --ok: #34c58f;
  --ok-soft: rgba(52, 197, 143, .13);
  --ok-line: rgba(52, 197, 143, .35);
  --warn: #f0b350;
  --warn-soft: rgba(240, 179, 80, .13);
  --bad: #f26b7d;
  --bad-soft: rgba(242, 107, 125, .13);
  --bad-line: rgba(242, 107, 125, .35);
  --info: #4fb3f6;
  --info-soft: rgba(79, 179, 246, .13);
  --chart-2: #f5b14a;
  --sidebar: #06121f;
  --sidebar-2: #0a1a2c;
  --row-hover: #181e35;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-md: 0 12px 30px -8px rgba(0, 0, 0, .6);
  color-scheme: dark;
}
[dir="rtl"] { --font: "IBM Plex Sans Arabic", "Inter", system-ui, sans-serif; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1 { font-size: 24px; margin: 0; font-weight: 650; letter-spacing: -.02em; }
h2 { font-size: 15.5px; margin: 0 0 12px; font-weight: 600; letter-spacing: -.01em; }
h3 { font-size: 14px; font-weight: 600; }
.num, td.num, th.num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; direction: ltr; unicode-bidi: plaintext; }
.muted { color: var(--muted); }
small { color: var(--muted); }
::selection { background: var(--primary-soft); }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: middle; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 256px; flex: none; background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2)); color: var(--sidebar-text); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; z-index: 30; }
.brand { display: flex; gap: 11px; align-items: center; padding: 18px 18px 14px; color: #fff; text-decoration: none !important; }
.brand b { display: block; font-size: 15px; letter-spacing: -.01em; }
.brand small { display: block; color: var(--sidebar-muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.logo { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; color: #fff; font-weight: 700; font-size: 16px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 55%, #fff), var(--accent) 60%, color-mix(in srgb, var(--accent) 80%, #000));
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 45%, transparent), inset 0 1px 0 rgba(255, 255, 255, .25); }
.side-search { margin: 2px 14px 8px; position: relative; }
.side-search input { width: 100%; background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .08); color: #fff; border-radius: 9px; padding: 8px 34px; font: inherit; font-size: 13px; outline: none; }
.side-search input:focus { border-color: var(--sidebar-mark); background: rgba(255, 255, 255, .08); box-shadow: none; }
.side-search input::placeholder { color: var(--sidebar-muted); }
.side-search input::-webkit-search-cancel-button { display: none; }
.side-search .ic { position: absolute; inset-inline-start: 11px; top: 9px; width: 16px; height: 16px; color: var(--sidebar-muted); }
.side-search kbd { position: absolute; inset-inline-end: 9px; top: 8px; font: 11px var(--font); color: var(--sidebar-muted); border: 1px solid rgba(255, 255, 255, .12); border-radius: 5px; padding: 0 6px; }
.side-nav { overflow-y: auto; padding: 0 10px 20px; flex: 1; scrollbar-width: thin; scrollbar-color: #2a3050 transparent; }
.side-nav a { display: flex; align-items: center; gap: 11px; padding: 7px 10px; border-radius: 8px; color: var(--sidebar-text); text-decoration: none; font-size: 13.5px; position: relative; }
.side-nav a .ic { width: 17px; height: 17px; opacity: .85; }
.side-nav a:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.side-nav a.active { background: var(--sidebar-active); color: #fff; font-weight: 500; }
.side-nav a.active .ic { opacity: 1; color: var(--sidebar-mark); }
.side-nav a.active::before { content: ""; position: absolute; inset-inline-start: -10px; top: 7px; bottom: 7px; width: 3px; border-radius: 3px; background: var(--sidebar-mark); }
.nav-h { display: flex; align-items: center; justify-content: space-between; width: 100%; background: none; border: 0; color: var(--sidebar-muted); font: 600 10.5px var(--font); text-transform: uppercase; letter-spacing: .09em; padding: 16px 10px 6px; cursor: pointer; }
[dir="rtl"] .nav-h { letter-spacing: 0; font-size: 11.5px; }
.nav-h:hover { color: var(--sidebar-text); }
.nav-h .ic { width: 14px; height: 14px; transition: transform .15s; }
.nav-group.closed .nav-h .ic { transform: rotate(-90deg); }
[dir="rtl"] .nav-group.closed .nav-h .ic { transform: rotate(90deg); }
.nav-group.closed .nav-items { display: none; }
.side-nav.searching .nav-group .nav-items { display: block; }
.side-nav.searching .nav-h .ic { visibility: hidden; }
.nav-empty { padding: 14px 10px; font-size: 12.5px; color: var(--sidebar-muted); }
.side-foot { padding: 12px 16px; border-block-start: 1px solid rgba(255, 255, 255, .06); display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--sidebar-muted); }
.side-foot > span:first-of-type { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot .ic { width: 15px; height: 15px; }
.side-foot .plan { background: var(--sidebar-active); color: #fff; padding: 1px 8px; border-radius: 6px; font-weight: 600; font-size: 11px; white-space: nowrap; }
.scrim { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 62px; display: flex; align-items: center; gap: 10px; padding: 0 28px; background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: saturate(160%) blur(10px); -webkit-backdrop-filter: saturate(160%) blur(10px); border-block-end: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.crumbs { color: var(--muted); font-size: 13px; display: flex; gap: 8px; align-items: center; min-width: 0; white-space: nowrap; overflow: hidden; }
.crumbs a { color: var(--muted); }
.crumbs b { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.branch-switch { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 0 4px 0 12px; height: 36px; box-shadow: var(--shadow-sm); }
[dir="rtl"] .branch-switch { padding: 0 12px 0 4px; }
.branch-switch .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); flex: none; }
.branch-switch select { border: 0; background: transparent; box-shadow: none !important; font-size: 13px; color: var(--text-2); min-width: 200px; padding: 6px 4px; cursor: pointer; }
.branch-switch select:focus { outline: none; }
.icon-btn { height: 36px; min-width: 36px; display: inline-grid; place-items: center; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; box-shadow: var(--shadow-sm); padding: 0 8px; font: inherit; text-decoration: none !important; }
.icon-btn:hover { border-color: var(--border-strong); color: var(--text); }
.lang-btn { font-weight: 600; font-size: 13px; padding: 0 12px; }
#theme-btn .sun { display: none; }
[data-theme="dark"] #theme-btn .sun { display: block; }
[data-theme="dark"] #theme-btn .moon { display: none; }
.menu-btn { display: none; }
.user-menu { position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 3px 6px; border-radius: 10px; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: var(--surface-3); }
.user-menu .uname b { display: block; font-size: 13px; font-weight: 600; line-height: 1.25; }
.user-menu .uname small { display: block; font-size: 11.5px; }
.user-menu .chev { width: 15px; height: 15px; color: var(--muted); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; color: #fff; font-weight: 600; font-size: 13px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 50%, #fff), var(--accent)); }
.menu-pop { position: absolute; inset-inline-end: 0; top: calc(100% + 8px); width: 240px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-md); padding: 6px; z-index: 40; }
.menu-head { padding: 8px 10px 10px; border-block-end: 1px solid var(--border); margin-bottom: 4px; }
.menu-head b { display: block; font-size: 13.5px; }
.menu-pop a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text-2); font-size: 13.5px; text-decoration: none; }
.menu-pop a:hover { background: var(--surface-3); color: var(--text); }
.menu-pop a .ic { width: 16px; height: 16px; color: var(--muted); }
.menu-pop a.danger, .menu-pop a.danger .ic { color: var(--bad); }
.content { padding: 26px 28px 60px; max-width: 1500px; width: 100%; margin-inline: auto; box-sizing: border-box; }

/* ---------- common ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head > div > small { display: block; margin-top: 3px; font-size: 13px; }
.page-head > div > small:first-child { margin: 0 0 2px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.card.flush { padding: 0; overflow-x: auto; }
.card.flush > table:first-child th:first-child { border-start-start-radius: var(--radius); }
.card.flush > table:first-child th:last-child { border-start-end-radius: var(--radius); }
.card > h2:first-child { margin-top: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 0 15px; border-radius: 10px; border: 1px solid var(--primary); background: var(--primary); color: var(--primary-ink); font: 500 13.5px var(--font); cursor: pointer; text-decoration: none !important; white-space: nowrap;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .1), inset 0 1px 0 rgba(255, 255, 255, .14); transition: background .12s, border-color .12s, box-shadow .12s; }
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn:focus-visible { outline: 3px solid var(--primary-soft); outline-offset: 1px; }
.btn.ghost { background: var(--surface); color: var(--text-2); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn.ghost:hover { border-color: var(--border-strong); color: var(--text); background: var(--surface-2); }
.btn.danger { background: var(--surface); color: var(--bad); border-color: var(--bad-line); box-shadow: var(--shadow-sm); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.small { min-height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn .ic { width: 16px; height: 16px; }
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 11px; margin-bottom: 16px; border: 1px solid; font-size: 13.5px; }
.flash .ic { width: 17px; height: 17px; margin-top: 1px; }
.flash.success { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); }
.flash.error { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); }
.flash.message, .flash.info { background: var(--primary-soft); border-color: var(--primary-line); color: var(--primary); }
.flash.warning { background: #fff6e5; border-color: #f3d38b; color: #8a5a00; }
:root[data-theme="dark"] .flash.warning { background: #3a2c0d; border-color: #6b5214; color: #f3c766; }
.flash span { color: var(--text); }

input, select, textarea { font: inherit; color: inherit; padding: 7px 11px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); min-width: 0; min-height: 36px; transition: border-color .12s, box-shadow .12s; }
textarea { min-height: 72px; width: 100%; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--border-strong) 60%, var(--muted)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; min-height: 0; accent-color: var(--primary); }
input[type=file] { padding: 6px; background: var(--surface-2); }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px 20px; }
.field label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 5px; font-weight: 500; }
.field input:not([type=checkbox]):not([type=radio]), .field select { width: 100%; }
.field .help { font-size: 12px; color: var(--muted); margin-top: 5px; }
.field.check { display: flex; gap: 9px; align-items: center; padding-top: 22px; }
.field.check label { margin: 0; color: var(--text); font-size: 13.5px; }
.field.wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; margin-top: 20px; flex-wrap: wrap; align-items: center; }

table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { padding: 11px 14px; text-align: start; border-block-end: 1px solid var(--border); vertical-align: middle; }
th { font-size: 11.5px; color: var(--muted); font-weight: 600; background: var(--surface-2); text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
[dir="rtl"] th { letter-spacing: 0; font-size: 12.5px; }
tbody tr:hover > td { background: var(--row-hover); }
tbody tr:last-child > td { border-block-end: 0; }
tr.clickable, tr[data-href] { cursor: pointer; }
tfoot td { font-weight: 650; background: var(--surface-2); border-block-start: 1px solid var(--border); border-block-end: 0; }
.card:not(.flush) table th { background: var(--surface-2); }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.st-posted, .pay-paid { background: var(--ok-soft); color: var(--ok); }
.st-draft { background: var(--primary-soft); color: var(--primary); }
.st-cancelled { background: var(--bad-soft); color: var(--bad); }
.st-warn { background: var(--warn-soft); color: var(--warn); }
.pay-partial { background: var(--warn-soft); color: var(--warn); }
.pay-not_paid { background: var(--surface-3); color: var(--text-2); }
.badge.overdue { background: var(--bad-soft); color: var(--bad); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 6px; background: var(--surface-3); border: 1px solid var(--border); font-size: 11.5px; font-weight: 600; color: var(--text-2); }

.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-sm); }
.filters label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }
.filters input[type=search] { min-width: 220px; }
.branch-picks { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex !important; align-items: center; gap: 6px; padding: 5px 11px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); color: var(--text-2) !important; cursor: pointer; font-size: 12.5px; }
.chip:has(input:checked) { border-color: var(--primary-line); background: var(--primary-soft); color: var(--primary) !important; }
.tabs { display: flex; gap: 2px; margin-bottom: 16px; border-block-end: 1px solid var(--border); overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); border-block-end: 2px solid transparent; margin-block-end: -1px; text-decoration: none; font-weight: 500; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--primary); border-color: var(--primary); font-weight: 600; }

/* ---------- dashboard ---------- */
.dash-sub { color: var(--muted); font-size: 13px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.pill { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 1px 10px; font-size: 12px; color: var(--text-2); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 18px 16px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.kpi .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi .value { font-size: 26px; font-weight: 650; margin-top: 8px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; text-align: start; }
.kpi .value small { font-size: 12.5px; font-weight: 500; margin-inline-start: 5px; letter-spacing: 0; }
.kpi .sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; position: relative; }
.kpi.alert .value { color: var(--bad); }
.kpi .spark { position: absolute; inset-inline-end: 0; bottom: 0; width: 130px; height: 46px; pointer-events: none; }
[dir="rtl"] .kpi .spark { transform: scaleX(-1); }
.ibox { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.ibox .ic { width: 17px; height: 17px; }
.t-indigo { background: var(--primary-soft); color: var(--primary); }
.t-amber { background: var(--warn-soft); color: var(--warn); }
.t-green { background: var(--ok-soft); color: var(--ok); }
.t-blue { background: var(--info-soft); color: var(--info); }
.t-red { background: var(--bad-soft); color: var(--bad); }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-size: 12px; padding: 1px 7px; border-radius: 20px; direction: ltr; }
.delta.good { color: var(--ok); background: var(--ok-soft); }
.delta.bad { color: var(--bad); background: var(--bad-soft); }
.delta.flat { color: var(--muted); background: var(--surface-3); }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow-sm); color: var(--text); text-decoration: none !important; }
a.stat:hover { border-color: var(--border-strong); }
.stat .ibox { width: 42px; height: 42px; border-radius: 12px; }
.stat .l { color: var(--muted); font-size: 12.5px; }
.stat .v { font-size: 18px; font-weight: 650; text-align: start; }
.stat .r { margin-inline-start: auto; text-align: end; font-size: 12px; color: var(--muted); }
.track { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; margin-top: 6px; width: 120px; }
.track i { display: block; height: 100%; border-radius: 6px; background: var(--primary); }
.two-col { display: grid; grid-template-columns: 1.65fr 1fr; gap: 16px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 12px; flex-wrap: wrap; }
.card-h h2 { margin: 0; }
.card-h .link { font-size: 13px; font-weight: 500; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 9px; padding: 3px; }
.seg button { border: 0; background: none; font: 500 12.5px var(--font); color: var(--muted); padding: 4px 10px; border-radius: 7px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.chart { position: relative; display: flex; align-items: flex-end; gap: 8px; height: 250px; margin: 6px 18px 18px; padding: 0 0 24px; padding-inline-start: 50px; }
.chart .gridlines { position: absolute; inset: 0 0 24px 0; inset-inline-start: 50px; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.chart .gridlines div { border-block-start: 1px dashed var(--border); position: relative; height: 0; }
.chart .gridlines span { position: absolute; inset-inline-start: -50px; top: -9px; width: 44px; text-align: end; font-size: 11px; color: var(--muted); direction: ltr; }
.chart .m { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; position: relative; }
.chart .m.hide { display: none; }
.chart .bars { display: flex; gap: 4px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.chart .bar { width: 38%; max-width: 13px; border-radius: 5px 5px 2px 2px; min-height: 2px; transition: filter .12s; }
.chart .bar.rev { background: linear-gradient(180deg, color-mix(in srgb, var(--chart-1) 72%, #fff), var(--chart-1)); }
.chart .bar.exp { background: linear-gradient(180deg, color-mix(in srgb, var(--chart-2) 70%, #fff), var(--chart-2)); }
.chart .m:hover .bar { filter: brightness(1.1); }
.chart .lbl { position: absolute; bottom: -22px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-inline-end: 6px; vertical-align: 0; }
.tasks a { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-block-start: 1px solid var(--border); color: var(--text); text-decoration: none; }
.tasks a:hover { background: var(--row-hover); }
.tasks .ibox { width: 32px; height: 32px; border-radius: 9px; }
.tasks .ibox .ic { width: 16px; height: 16px; }
.tasks .n { margin-inline-start: auto; font-weight: 650; font-size: 12.5px; background: var(--surface-3); border-radius: 20px; padding: 1px 9px; }
.tasks .go { color: var(--muted); }
[dir="rtl"] .tasks .go { transform: scaleX(-1); }
.all-clear { padding: 30px 18px 34px; text-align: center; color: var(--muted); }
.all-clear .ibox { margin: 0 auto 10px; width: 44px; height: 44px; border-radius: 50%; }
.who { display: flex; align-items: center; gap: 11px; }
.who .av { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 650; font-size: 11.5px; flex: none; }
.who b { display: block; font-weight: 600; font-size: 13.5px; }
.who small { font-size: 12px; }
.hbar { height: 8px; border-radius: 8px; background: var(--surface-3); overflow: hidden; min-width: 80px; }
.hbar i { display: block; height: 100%; background: var(--chart-1); border-radius: 8px; }

/* ---------- documents ---------- */
.doc-head { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px 24px; }
.doc-head dt { color: var(--muted); font-size: 12px; font-weight: 500; }
.doc-head dd { margin: 3px 0 0; font-weight: 500; }
.lines th { background: var(--surface-2); }
.lines input, .lines select { width: 100%; padding: 6px 8px; min-height: 34px; }
.lines td { padding: 6px; }
.lines .del { color: var(--bad); border: none; background: none; cursor: pointer; font-size: 18px; border-radius: 6px; width: 28px; height: 28px; }
.lines .del:hover { background: var(--bad-soft); }
.lines tr.tpl { display: none; }
.totals { margin-inline-start: auto; width: 340px; max-width: 100%; }
.totals td { border: none; padding: 6px 14px; }
.totals tr:hover > td { background: none; }
.totals tr.grand td { font-size: 17px; font-weight: 700; border-block-start: 2px solid var(--text); }
.status-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.warn-text { color: var(--bad); font-weight: 600; }
.inline { display: inline; }

/* ---------- reports ---------- */
.report td.lvl-2 { padding-inline-start: 30px; }
.report tr.section td { font-weight: 700; background: var(--surface); padding-top: 18px; color: var(--text); border-block-end: 2px solid var(--border); }
.report tr.subtotal td { font-weight: 600; background: var(--surface-2); }
.report tr.total td { font-weight: 700; background: var(--surface-3); }
.report tr.grand td { font-weight: 750; background: var(--primary-soft); border-block: 2px solid var(--primary-line); color: var(--text); }
.report td.elim { color: var(--warn); }
.report th.cons, .report td.cons { background: color-mix(in srgb, var(--primary) 5%, transparent); font-weight: 600; }
.report-meta { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 12.5px; margin-bottom: 10px; }
.notes { font-size: 12px; color: var(--muted); padding: 11px 16px; }
.gl-head td { background: var(--surface-2); font-weight: 600; }
.neg { color: var(--bad); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--surface); }
.login-art { position: relative; overflow: hidden; color: #fff; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(1200px 600px at 0% 0%, color-mix(in srgb, var(--accent) 65%, #000) 0%, transparent 60%), linear-gradient(160deg, var(--sidebar), #05070f); }
.login-art::after { content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%; inset-inline-end: -160px; bottom: -180px;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 55%, transparent), transparent 65%); filter: blur(10px); opacity: .7; }
.login-art .brand { padding: 0; }
.login-co { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: color-mix(in srgb, var(--accent) 45%, #fff); margin-bottom: 14px; font-weight: 600; }
.login-art h1 { font-size: 36px; line-height: 1.2; max-width: 460px; margin: 0 0 14px; color: #fff; }
.login-art p { color: #b9bfd6; max-width: 440px; margin: 0; font-size: 15px; }
.login-feats { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; position: relative; z-index: 1; }
.login-feats li { display: flex; gap: 11px; align-items: center; color: #dfe2f0; font-size: 14px; }
.login-feats .ibox { background: rgba(255, 255, 255, .08); color: #fff; width: 32px; height: 32px; border-radius: 9px; }
.login-art small { color: #7d84a3; position: relative; z-index: 1; }
.login-side { display: grid; place-items: center; padding: 32px 20px; background: var(--bg); }
.login-card { width: 400px; max-width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 34px; box-shadow: var(--shadow-md); }
.login-card h2 { font-size: 22px; margin: 0 0 4px; }
.login-card .lead { color: var(--muted); margin: 0 0 22px; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; min-height: 42px; font-size: 14.5px; margin-top: 6px; }
.login-card .brand { display: none; color: var(--text); padding: 0 0 20px; }
.login-card .brand small { color: var(--muted); }
.pw { position: relative; } .pw input { width: 100%; padding-inline-end: 42px; }
.pw-toggle { position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); width: 32px; height: 32px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.pw-toggle:hover, .pw-toggle.on { color: var(--primary); background: var(--primary-soft); }
.login-help { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12.5px; margin: 16px 0 0; } .login-help svg { width: 14px; height: 14px; flex: none; }
.login-art { background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px), radial-gradient(1200px 600px at 0% 0%, color-mix(in srgb, var(--accent) 65%, #000) 0%, transparent 60%), linear-gradient(160deg, var(--sidebar), #05070f); background-size: 44px 44px, 44px 44px, auto, auto; }
.login-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; font-size: 13px; }

/* ---------- appearance ---------- */
.accent-picker { display: flex; flex-wrap: wrap; gap: 14px; }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; width: 64px; }
.swatch input[type=radio] { position: absolute; opacity: 0; pointer-events: none; }
.swatch span { width: 38px; height: 38px; border-radius: 12px; background: var(--sw); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); transition: transform .12s; }
.swatch:hover span { transform: translateY(-2px); }
.swatch input:checked + span { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--sw); }
.swatch small { font-size: 11.5px; text-align: center; }
.swatch.custom input[type=color] { width: 38px; height: 38px; min-height: 0; padding: 0; border-radius: 12px; border: 1px dashed var(--border-strong); cursor: pointer; background: none; }
.swatch.custom input[type=color]::-webkit-color-swatch-wrapper { padding: 3px; }
.swatch.custom input[type=color]::-webkit-color-swatch { border: 0; border-radius: 9px; }
.swatch.custom input[type=radio]:checked ~ input[type=color] { border: 2px solid var(--text); }

/* ---------------------------------------------------------------- apps: home screen and per-app sidebar */
.shell.no-side .main { width: 100%; }
.apps-btn .ic { width: 17px; height: 17px; }
.home-brand { padding: 0; color: var(--text); margin-inline-end: 6px; }
.home-brand small { color: var(--muted); }
.home { max-width: 1180px; margin: 0 auto; padding: 6px 4px 30px; }
.home-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.home-head p { margin: 3px 0 0; font-size: 13px; }
.home-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.home-search { position: relative; margin: 22px 0 4px; max-width: 520px; }
.home-search input { width: 100%; height: 42px; padding: 0 40px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow-sm); }
.home-search > .ic { position: absolute; inset-inline-start: 14px; top: 12px; width: 18px; height: 18px; color: var(--muted); }
.home-search kbd { position: absolute; inset-inline-end: 12px; top: 11px; font: 11px var(--font); color: var(--muted); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; background: var(--surface-2); }
.home-hits { max-width: 520px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-md); padding: 6px; margin-top: 6px; }
.home-hits a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none !important; }
.home-hits a:hover, .home-hits a:first-child { background: var(--surface-3); }
.home-hits a .ic { width: 16px; height: 16px; color: var(--muted); }
.home-hits a small { margin-inline-start: auto; color: var(--muted); }
.app-sec { margin-top: 26px; }
.app-sec h2 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 10px; }
[dir="rtl"] .app-sec h2 { letter-spacing: 0; font-size: 13px; }
.app-sec h2 span { text-transform: none; letter-spacing: 0; font-weight: 400; margin-inline-start: 8px; font-size: 12.5px; }
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.app-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; min-height: 74px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); color: var(--text); text-decoration: none !important; transition: border-color .15s, box-shadow .15s, opacity .15s; }
a.app-card:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); box-shadow: var(--shadow-md); }
.app-card.dim { opacity: .35; }
.app-ic { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; flex: none;
  background: color-mix(in srgb, var(--c, var(--accent)) 12%, var(--surface)); color: var(--c, var(--accent)); }
.app-ic .ic { width: 20px; height: 20px; }
.app-tx { flex: 1; min-width: 0; }
.app-tx b { display: block; font-size: 14px; font-weight: 600; }
.app-tx small { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-tx small.tone-bad { color: var(--bad); }
.app-count { flex: none; min-width: 24px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; display: grid; place-items: center;
  font-variant-numeric: tabular-nums; background: var(--surface-3); color: var(--text-2); }
.app-count.tone-bad { background: var(--bad-soft); color: var(--bad); }
.app-count.tone-warn { background: var(--warn-soft); color: var(--warn); }
.app-go { flex: none; width: 16px; height: 16px; color: var(--border-strong); }
a.app-card:hover .app-go { color: var(--muted); }
[dir="rtl"] .app-go { transform: scaleX(-1); }
.app-card.locked { background: transparent; box-shadow: none; border-style: dashed; }
.app-card.locked .app-ic { background: var(--surface-3); color: var(--muted); }
.app-card.locked b { color: var(--muted); }
.app-card.locked small { color: var(--primary); }
.side-app { display: flex; align-items: center; gap: 10px; margin: 6px 0 4px; padding: 10px; border-radius: 10px; background: rgba(255, 255, 255, .05); color: #fff; }
.side-app .app-ic { width: 32px; height: 32px; border-radius: 9px; background: color-mix(in srgb, var(--c) 30%, transparent); color: color-mix(in srgb, var(--c) 45%, #fff); }
.side-app .app-ic .ic { width: 17px; height: 17px; opacity: 1; }
.side-app b { flex: 1; font-size: 14px; }
.side-nav .side-app a.all { padding: 6px; color: var(--sidebar-muted); }
.side-nav .side-app a.all:hover { color: #fff; }
.side-nav .side-app a.all::before { display: none; }
.nav-app.other { display: none; }
.nav-app-h { display: none; color: var(--sidebar-muted); font: 600 10.5px var(--font); text-transform: uppercase; letter-spacing: .09em; padding: 16px 10px 6px; }
.side-nav.searching .nav-app.other { display: block; }
.side-nav.searching .nav-app-h { display: block; }
.side-nav.searching .side-app { display: none; }

/* ---------------------------------------------------------------- attachments */
.attach-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.attach-head h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 15px; }
.attach-head h2 .ic { width: 17px; height: 17px; color: var(--muted); }
.attach-list { list-style: none; margin: 0 0 12px; padding: 0; border: 1px solid var(--border); border-radius: 10px; }
.attach-list li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; }
.attach-list li + li { border-top: 1px solid var(--border); }
.attach-ic { width: 38px; height: 38px; border-radius: 8px; display: grid; place-items: center; flex: none; font: 700 10px var(--font); letter-spacing: .02em; background: var(--surface-3); color: var(--text-2); }
.attach-ic.ext-pdf { background: var(--bad-soft); color: var(--bad); }
.attach-ic.ext-img { background: var(--info-soft); color: var(--info); }
.attach-ic.ext-xls { background: var(--ok-soft); color: var(--ok); }
.attach-ic.ext-doc { background: var(--primary-soft); color: var(--primary); }
.attach-tx { flex: 1; min-width: 0; }
.attach-tx > a { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-tx small { display: block; font-size: 12px; }
.attach-list .btn.small { min-width: 32px; padding: 0 8px; }
.attach-drop input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.attach-drop label { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 18px; border: 1.5px dashed var(--border-strong); border-radius: 10px; color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; }
.attach-drop label .ic { width: 20px; height: 20px; }
.attach-drop label b { color: var(--primary); font-weight: 600; }
.attach-drop label:hover, .attach-drop.over label { border-color: var(--primary); background: var(--primary-soft); }
.attach-drop.busy label { opacity: .6; pointer-events: none; }
.clip { width: 14px; height: 14px; color: var(--muted); vertical-align: -2px; margin-inline-start: 6px; }

/* ---------------------------------------------------------------- statements and email */
.compose { max-width: 820px; }
.compose .field { margin-bottom: 14px; }
.compose textarea { width: 100%; font: inherit; line-height: 1.55; }
.attach-chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); font-size: 13px; }
.attach-chip .ic { width: 15px; height: 15px; color: var(--muted); }
tr.sub td { background: var(--surface-2); }

/* ---------------------------------------------------------------- recurring documents */
.inline-fields { display: flex; align-items: center; gap: 8px; }
.inline-fields select { flex: 1; }
.date-list { list-style: none; margin: 8px 0 0; padding: 0; }
.date-list li { padding: 7px 0; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.date-list li:last-child { border-bottom: 0; }
.date-list li.due { color: var(--warn); font-weight: 600; }
.due-bar { display: flex; align-items: center; gap: 12px; }
.due-bar span { flex: 1; }

/* ---------------------------------------------------------------- credit control */
.meter { height: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-bottom: 2px; }
.meter span { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.meter.high span { background: var(--warn); }
.meter.over span { background: var(--bad); }

@media (max-width: 1100px) {
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; inset-inline-start: 0; top: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-md); }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: none !important; }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(5, 7, 15, .45); z-index: 25; }
  .menu-btn { display: inline-grid; }
  .content { padding: 18px 16px; }
  .topbar { padding: 0 14px; gap: 8px; }
  .crumbs { display: none; }
  .branch-switch select { min-width: 0; max-width: 150px; }
  .user-menu .uname, .user-menu .chev { display: none; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .login-card .brand { display: flex; }
}
/* phones: the top bar wraps to two rows (buttons, then the branch) instead of pushing the page wider */
@media (max-width: 600px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 6px; }
  .topbar .spacer { display: none; }
  .branch-switch { order: 20; flex: 1 1 100%; }
  .branch-switch select { max-width: none; width: 100%; }
  .recent-menu, #theme-btn { display: none; }
  .topbar .icon-btn { width: 36px; height: 36px; }
  .content { padding: 14px 12px; }
  .page-head { flex-wrap: wrap; }
  .page-head .actions { flex-wrap: wrap; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi .value { font-size: 20px; }
  .doc-head { grid-template-columns: 1fr 1fr !important; }
  .card, .card.flush { overflow-x: auto; }
  .filters input[type=search] { min-width: 0; width: 100%; }
}

@media print {
  .sidebar, .topbar, .filters, .page-head .actions, .no-print, .flash, .scrim { display: none !important; }
  :root { --bg: #fff; }
  .content { padding: 0; max-width: none; }
  .card { border: none; padding: 0; box-shadow: none; }
  body { background: #fff; }
}

/* numbers, emails and codes stay left-to-right inside Arabic pages */
[dir="rtl"] input[name=phone], [dir="rtl"] input[name=email], [dir="rtl"] input[name=iban],
[dir="rtl"] input[name=website], [dir="rtl"] input[name=vat_no], [dir="rtl"] input[name=cr_no] { direction: ltr; text-align: right; }

/* ---------- CRM ---------- */
.kanban { display: grid; grid-template-columns: repeat(6, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kcol { background: var(--surface-3); border-radius: var(--radius); padding: 10px; min-height: 300px; transition: background .15s; }
.kcol.over { background: var(--primary-soft); }
.khead { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; padding: 2px 4px 10px; }
.khead .ksum { width: 100%; font-size: 12px; color: var(--muted); text-align: start; }
.kbody { display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.kcard { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 11px 12px; color: var(--text); text-decoration: none !important; cursor: grab; box-shadow: var(--shadow-sm); transition: border-color .12s, transform .12s; }
.kcard:hover { border-color: var(--primary-line); transform: translateY(-1px); }
.kcard.dragging { opacity: .5; }
.kcard .ktitle { font-weight: 600; margin-bottom: 2px; }
.kcard .kfoot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.stars { color: #e6a700; }
.stagebar { display: flex; gap: 0; margin-bottom: 16px; flex-wrap: wrap; }
.stagebar .step { border: 1px solid var(--border); background: var(--surface); padding: 7px 16px; font: inherit; cursor: pointer; color: var(--muted); margin-inline-start: -1px; }
.stagebar form:first-child .step { border-start-start-radius: 10px; border-end-start-radius: 10px; }
.stagebar form:last-child .step { border-start-end-radius: 10px; border-end-end-radius: 10px; }
.stagebar .step.active { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); position: relative; }
.stage-new { background: var(--surface-3); color: var(--text-2); }
.stage-qualified { background: var(--info-soft); color: var(--info); }
.stage-proposal { background: var(--primary-soft); color: var(--primary); }
.stage-negotiation { background: var(--warn-soft); color: var(--warn); }
.stage-won { background: var(--ok-soft); color: var(--ok); }
.stage-lost { background: var(--bad-soft); color: var(--bad); }

/* ---------- bank reconciliation ---------- */
.bank-lines tbody.is-open > tr > td { background: color-mix(in srgb, var(--warn-soft) 55%, var(--surface)); }
.bank-lines .sub-row td { border-bottom: 2px solid var(--border); padding-top: 0; }
.bank-lines details summary { cursor: pointer; color: var(--primary); padding: 4px 0; }
.match-form table td { border: 0; padding: 4px 8px; }
.mini { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.ok-text { color: var(--ok); font-weight: 700; }

/* ---------- data import ---------- */
.import-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; margin-bottom: 24px; }
.import-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 9px; box-shadow: var(--shadow-sm); }
.import-card h3 { margin: 0; font-size: 14.5px; display: flex; gap: 9px; align-items: center; }
.import-card p { margin: 0; color: var(--muted); font-size: 12.5px; flex: 1; }
.import-card .step { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-size: 12px; font-weight: 700; flex: none; }
.import-card .links { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.group-head { display: flex; align-items: baseline; gap: 10px; margin: 6px 0 12px; flex-wrap: wrap; }
.group-head h2 { margin: 0; }
.map-table td, .map-table th { vertical-align: top; }
.map-table select { min-width: 200px; max-width: 100%; }
.map-table .help { font-size: 12px; color: var(--muted); margin-top: 3px; max-width: 520px; }
.req { color: var(--bad); }
.result-ok { border-color: var(--ok-line); background: var(--ok-soft); }
.result-bad { border-color: var(--bad-line); background: var(--bad-soft); }
.sample td { white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; font-size: 12.5px; }

/* budgets */
.radio-list { display: grid; gap: 10px; }
.radio-list label { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 400; }
.radio-list select { max-width: 340px; }
.budget-grid { min-width: 1400px; }
.budget-grid td, .budget-grid th { padding: 4px 6px; }
.budget-grid input { width: 100%; min-width: 82px; padding: 5px 6px; }
.budget-grid input.year { font-weight: 600; background: var(--surface-2); }
.budget-grid .sticky { position: sticky; inset-inline-start: 0; background: var(--surface); z-index: 1; min-width: 220px; white-space: nowrap; }
.budget-grid tfoot td { font-weight: 600; border-top: 1px solid var(--border); }
.budget-grid tfoot tr.grand td { border-top: 2px solid var(--text); }
td.fav { color: var(--ok); font-weight: 600; }
td.unfav { color: var(--bad); font-weight: 600; }

/* ---------- chart of accounts tree ---------- */
.coa td { padding-block: 7px; }
.coa tr.grp td { font-weight: 650; background: var(--surface-2); }
.coa tr.grp td:first-child { color: var(--text); }
.coa tr.inactive td { opacity: .55; }
.coa .code { font-variant-numeric: tabular-nums; color: var(--muted); margin-inline-end: 6px; }
.coa tr.grp .code { color: var(--primary); }
.coa .tw { border: 0; background: none; width: 18px; padding: 0; margin-inline-end: 4px; color: var(--muted); cursor: pointer; font-size: 12px; }
.coa .tw-sp { display: inline-block; width: 22px; }
.coa .drcr { color: var(--muted); font-weight: 500; }
.coa-hint { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; border-inline-start: 3px solid var(--primary); }
.coa-hint small { display: block; margin-top: 3px; }
.report tr.group td { font-weight: 600; }
.report tr.group td:first-child { color: var(--text); }
/* product mark and the company logo preview */
.logo img { width: 24px; height: 24px; display: block; }
.logo-preview { width: 220px; height: 90px; border: 1px dashed var(--border-strong); border-radius: 12px; display: grid; place-items: center; background: repeating-conic-gradient(var(--surface-3) 0 25%, var(--surface) 0 50%) 0 0 / 14px 14px; }
.logo-preview img { max-width: 200px; max-height: 76px; }
.logo:has(img) { background: transparent; box-shadow: 0 0 0 1px rgba(255, 255, 255, .14); }
.logo:has(img) img { width: 36px; height: 36px; }
.export-group { display: inline-flex; gap: 6px; margin-inline-start: auto; flex-wrap: wrap; }
.export-group .btn .ic { width: 15px; height: 15px; }
/* searchable dropdown */
.cb { position: relative; display: block; width: 100%; min-width: 0; }
.cb-native { display: none !important; }
.cb-input { width: 100%; box-sizing: border-box; padding-inline-end: 28px !important;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
[dir="rtl"] .cb-input { background-position: 15px 50%, 10px 50%; }
.cb-input.cb-invalid { border-color: var(--bad); }
.cb-list { position: fixed; z-index: 200; inset-inline-start: 0; top: calc(100% + 3px); min-width: 100%; width: max-content; max-width: min(520px, 90vw);
  max-height: 300px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-md); padding: 4px; }
.cb-opt { padding: 7px 10px; border-radius: 7px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; color: var(--text); }
.cb-opt.on { background: var(--primary-soft); color: var(--primary); }
.cb-opt.sel { font-weight: 600; }
.cb-none { padding: 8px 10px; color: var(--muted); font-size: 13px; }
td .cb-list { max-width: min(460px, 90vw); }
/* approval workflow */
.approval-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.approval-head h2 { margin: 0; }
.approval-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.approval-steps li { display: flex; gap: 12px; align-items: flex-start; }
.ap-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none;
  background: var(--surface-3); color: var(--muted); }
.ap-done .ap-dot { background: var(--ok-soft, #e7f6ec); color: var(--ok, #15803d); }
.ap-current .ap-dot { background: var(--primary); color: #fff; }
.ap-rejected .ap-dot { background: var(--bad-soft); color: var(--bad); }
.ap-body small { display: block; }
.ap-people { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ap-person { font-size: 12.5px; padding: 3px 9px; border-radius: 20px; background: var(--surface-3); color: var(--text-2); }
.ap-person.ap-approved { background: var(--ok-soft, #e7f6ec); color: var(--ok, #15803d); }
.ap-person.ap-rejected { background: var(--bad-soft); color: var(--bad); }
.ap-person.ap-pending { background: var(--warn-soft); color: var(--warn); }
.ap-person.ap-skipped, .ap-person.ap-cancelled { opacity: .55; }
.approval-form { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.approval-history { margin-top: 12px; }
.approval-history summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.topbar .bell { position: relative; }
.topbar .bell .dot { position: absolute; top: -4px; inset-inline-end: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; box-sizing: border-box; }
.note-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 4px; max-height: 420px; overflow-y: auto; }
.note-list a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none !important; }
.note-list a:hover { background: var(--surface-3); }
.note-list li.unread a { background: var(--primary-soft); }
.note-list small { display: block; color: var(--muted); margin-top: 2px; }

/* vendor picker */
.vendor-picker .vp-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.vendor-picker .vp-tools input[type=search] { max-width: 260px; }
.vendor-picker .vp-tools select { width: auto; max-width: 220px; }
.vendor-picker .branch-picks { max-height: 260px; overflow-y: auto; }
.vendor-picker label.chip[hidden] { display: none; }
.sealed-box { padding: 26px 16px; text-align: center; color: var(--muted); }
.sealed-box b { color: var(--text); font-size: 15px; }

/* supplier portal (public pages) */
body.portal { background: var(--bg); min-height: 100vh; display: flex; flex-direction: column; }
.portal-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.portal-brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.portal-brand img { height: 38px; width: auto; }
.portal-brand span { display: flex; flex-direction: column; line-height: 1.2; }
.portal-brand small { color: var(--muted); }
.portal-top nav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.portal-main { flex: 1; padding: 28px 16px; width: 100%; max-width: 1040px; margin: 0 auto; box-sizing: border-box; }
.portal-narrow { max-width: 440px; margin: 30px auto; }
.portal-docs td, .portal-docs th { padding: 6px 8px; }
.portal-docs input, .portal-docs select { width: 100%; }
.portal-foot { text-align: center; padding: 18px; }
@media (max-width: 700px) { .portal-docs thead { display: none; } .portal-docs tr { display: grid; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--border); } }
.portal-nav { display: flex; gap: 4px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto; }
.portal-nav a { display: flex; align-items: center; gap: 6px; padding: 11px 12px; color: var(--muted); text-decoration: none; border-block-end: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.portal-nav a svg { width: 16px; height: 16px; }
.portal-nav a.active { color: var(--primary); border-color: var(--primary); }
.portal-nav a:hover { color: var(--text); }
.type-pick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.type-pick .chip { cursor: pointer; }
.type-pick .chip:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 600; }

/* record pager */
.pager { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.page-head > .pager { order: -1; flex: 0 0 100%; justify-content: flex-end; }
.page-head h1 .pager { margin-inline-start: 14px; vertical-align: middle; font-size: 14px; font-weight: 400; }
.page-head h1 .pager .pager-btn { font-size: 18px; }
.pager-pos { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; margin-inline-end: 4px; white-space: nowrap; }
.pager-btn { min-width: 32px; justify-content: center; font-size: 18px; line-height: 1; padding-block: 4px; }
[dir=rtl] .pager-btn { transform: scaleX(-1); }
.keys-help { position: fixed; inset: 0; background: rgba(15, 23, 42, .35); display: grid; place-items: center; z-index: 100; }
.keys-help .card { min-width: 320px; max-width: 92vw; }
.keys-help td { padding: 6px 10px; border: 0; }
kbd { font: 12px ui-monospace, Menlo, Consolas, monospace; background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; padding: 2px 6px; white-space: nowrap; }

/* Odoo-style search box */
.vx-search { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; flex: 1 1 320px; min-width: 240px;
  padding: 3px 6px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: text; }
.vx-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.vx-search .vx-q { flex: 1 1 140px; min-width: 120px; border: 0 !important; box-shadow: none !important; outline: 0; background: transparent; padding: 5px 4px; }
.facet { display: inline-flex; align-items: center; gap: 4px; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--text);
  border-radius: 7px; padding: 3px 4px 3px 8px; font-size: 13px; white-space: nowrap; max-width: 100%; }
.facet b { color: var(--accent); font-weight: 600; }
.facet-x { border: 0; background: transparent; color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer; padding: 0 4px; border-radius: 5px; }
.facet-x:hover { background: var(--surface-2); color: var(--text); }
.vx-menu { position: absolute; top: calc(100% + 4px); inset-inline-start: 0; min-width: 100%; max-width: 520px; z-index: 40; list-style: none; margin: 0; padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(15, 23, 42, .12); }
.vx-menu li { padding: 7px 10px; border-radius: 7px; cursor: pointer; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vx-menu li.on, .vx-menu li:hover { background: var(--surface-2); }
.vx-menu li i { font-style: normal; color: var(--accent); }

.crumbs a.trail { color: var(--accent); max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.crumbs a.trail:hover { text-decoration: underline; }

/* notes & history (chatter) */
.chatter-form { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 12px; }
.chatter-form textarea { flex: 1; min-height: 40px; }
.chatter-list { list-style: none; margin: 0; padding: 0; }
.chatter-list li { display: flex; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); }
.chatter-list li:first-child { border-top: 0; }
.chatter-dot { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: var(--surface-2); color: var(--muted); }
.chatter-list li.is-note .chatter-dot { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); color: var(--accent); }
.chatter-note { margin-top: 3px; white-space: pre-wrap; background: color-mix(in srgb, var(--accent) 6%, var(--surface)); border-radius: 8px; padding: 7px 10px; }
.chatter-act { margin-top: 2px; font-size: 13.5px; }

/* list tools */
th.sel, td.sel { width: 34px; text-align: center; padding-inline: 6px !important; }
td.sel input, th.sel input { width: 16px; height: 16px; cursor: pointer; }
.bulk-bar[hidden] { display: none !important; }
.bulk-bar { position: sticky; top: 70px; z-index: 8; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 10px; padding: 8px 12px;
  border-radius: 10px; background: color-mix(in srgb, var(--accent) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border)); }
tr.grp { cursor: pointer; background: var(--surface-2); }
tr.grp td { font-weight: 500; }
tr.grp.open .grp-caret { display: inline-block; transform: rotate(90deg); }
.grp-caret { color: var(--muted); display: inline-block; transition: transform .15s; }
.vx-groupby { max-width: 190px; }
.vx-favs { position: relative; }
.vx-favs > summary { list-style: none; cursor: pointer; }
.vx-favs > summary::-webkit-details-marker { display: none; }
.vx-favs-menu { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 40; min-width: 270px; padding: 12px !important; }
.vx-fav { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; }
.vx-fav-save { display: flex; gap: 6px; margin-top: 8px; border-top: 1px solid var(--border); padding-top: 10px; }
.vx-fav-save input { flex: 1; min-width: 0; }

.biz-types { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.biz { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; }
.biz input { position: absolute; opacity: 0; pointer-events: none; }
.biz.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.biz small { color: var(--muted); }

/* ---------- trading: overviews, cash forecast, labels ---------- */
a.kpi, a.kpi:hover { color: inherit; text-decoration: none; }
a.kpi:hover { border-color: var(--primary-line); }
.lot-in { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.lot-in input { padding: 5px 8px; font-size: 12.5px; }
.fc-chart { display: flex; gap: 6px; height: 220px; margin: 8px 18px 18px; }
.fc-col { flex: 1; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.fc-plot { position: relative; flex: 1; width: 100%; }
.fc-zero { position: absolute; inset-inline: -3px; border-top: 1px solid var(--border-strong, var(--border)); }
.fc-bar { position: absolute; inset-inline: 18%; background: var(--chart-1); border-radius: 4px; min-height: 2px; }
.fc-bar.neg { background: var(--bad); }
.fc-col .lbl { font-size: 10.5px; color: var(--muted); direction: ltr; white-space: nowrap; }
.fc-table td, .fc-table th { white-space: nowrap; font-size: 12.5px; }
.fc-table td:first-child { position: sticky; inset-inline-start: 0; background: var(--surface); }
.label-sheet { display: grid; gap: 0; }
.label-sheet.a4 { grid-template-columns: repeat(3, 70mm); grid-auto-rows: 37mm; }
.label-sheet.roll { grid-template-columns: 50mm; grid-auto-rows: 30mm; }
.label-sheet .label { border: 1px dashed var(--border); background: #fff; color: #000; padding: 2.5mm 3mm; overflow: hidden; display: flex;
  flex-direction: column; justify-content: space-between; text-align: center; break-inside: avoid; }
.label-sheet .label .l-name { font-weight: 650; font-size: 11px; line-height: 1.2; max-height: 2.4em; overflow: hidden; }
.label-sheet .label .l-meta { font-size: 8.5px; color: #333; direction: ltr; }
.label-sheet .label .l-code svg { max-width: 100%; height: auto; max-height: 15mm; }
.label-sheet .label .l-price { font-weight: 700; font-size: 12px; direction: ltr; }
.label-sheet.roll .label { padding: 1.5mm 2mm; }
.roll .label .l-code svg { max-height: 12mm; }
@media print {
  .label-sheet .label { border: none; }
  .label-sheet.roll .label { page-break-after: always; }
  @page { margin: 8mm; }
}

/* ---------- archive tabs, column chooser, recently viewed ---------- */
.seg-tabs { display: inline-flex; gap: 2px; background: var(--surface-3); border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.seg-tabs a { padding: 5px 14px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 13px; }
.seg-tabs a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }
.seg-tabs small { color: var(--muted); margin-inline-start: 4px; }
tr.archived td { color: var(--muted); }
.col-chooser { position: relative; display: inline-block; }
.col-chooser > summary { list-style: none; cursor: pointer; }
.col-chooser > summary::-webkit-details-marker { display: none; }
.col-chooser .menu-pop { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 40; min-width: 220px; max-height: 360px;
  overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg, var(--shadow-sm)); padding: 8px; }
.col-chooser .col-opt { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 7px; cursor: pointer; font-size: 13.5px; white-space: nowrap; }
.col-chooser .col-opt:hover { background: var(--surface-3); }
.col-chooser .btn { margin: 6px 4px 2px; }
.recent-menu > summary { list-style: none; }
.recent-menu > summary::-webkit-details-marker { display: none; }
.recent-menu .menu-pop { min-width: 300px; max-width: 380px; }
.recent-menu .menu-pop a { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.recent-menu .rv-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-menu .menu-pop a small { color: var(--muted); flex-shrink: 0; }
.recent-menu .menu-empty { padding: 10px 12px; color: var(--muted); font-size: 13px; }

/* ---------- ZATCA e-invoice panel ---------- */
.card.einv { display: flex; gap: 18px; align-items: flex-start; padding: 16px; border-inline-start: 3px solid var(--ok); }
.card.einv-warn { border-inline-start-color: var(--warn); }
.card.einv-bad { border-inline-start-color: var(--bad); }
.einv-qr { flex: none; background: #fff; padding: 6px; border-radius: 10px; border: 1px solid var(--border); }
.einv-qr svg { width: 120px; height: 120px; display: block; }
.einv-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.einv-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.einv-h small { color: var(--muted); }
.einv-meta { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; font-size: 13px; }
.einv-meta dt { color: var(--muted); }
.einv-meta dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.einv-meta code.hash { font-size: 11.5px; color: var(--muted); }
.einv-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.zatca-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.zatca-steps .step { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--surface-2); }
.zatca-steps .step b { display: block; margin-bottom: 4px; }
.zatca-steps .step.done { border-color: var(--ok-line); background: var(--ok-soft); }
@media (max-width: 640px) { .card.einv { flex-direction: column; } }

/* ---------- header actions: every control the same height, on one line ---------- */
.page-head .actions { align-items: center; }
.page-head .actions > form.filters { padding: 0; border: 0; background: none; box-shadow: none; margin: 0; }
.page-head .actions .btn, .page-head .actions select, .page-head .actions input, .col-chooser > summary.btn { height: 38px; min-height: 38px; }
.col-chooser > summary.btn { display: inline-flex; margin: 0; }
/* phones: menus opened from a button near the left edge must stay on the screen */
@media (max-width: 600px) {
  /* the menu spans the width of its bar instead of hanging from the button */
  .page-head .actions, .filters { position: relative; }
  .col-chooser, .vx-favs { position: static; }
  .col-chooser .menu-pop, .vx-favs-menu { inset-inline: 0; top: auto; margin-top: 6px; min-width: 0; max-width: none; width: auto; }
  .page-head .actions { width: 100%; }
  .page-head .actions > form.filters { flex: 1 1 100%; }
  .page-head .actions > form.filters input[type=search] { width: 100%; }
}

/* ---------- found by the layout audit of every page ---------- */
/* Favorites: the menu hangs from the filter bar's own edge, so it can never open under the sidebar or off the screen */
.filters { position: relative; }
.vx-favs { position: static; }
.vx-favs-menu { inset-inline-start: 10px; inset-inline-end: auto; top: calc(100% - 4px); max-width: min(420px, calc(100% - 20px)); }
/* Expand all / Collapse all sits level with the buttons beside it */
.page-head .actions .seg { min-height: 38px; align-items: stretch; }
.page-head .actions .seg button { display: inline-flex; align-items: center; }
/* approval history: a wide table scrolls inside its own box on a phone */
.approval-history { max-width: 100%; overflow-x: auto; }

/* phone top bar on the home screen: logo, name and buttons on one line; the name shortens instead of pushing
   the account button onto a line of its own (English) or under the language button (Arabic) */
@media (max-width: 600px) {
  .topbar .home-brand { flex: 1 1 0; min-width: 0; gap: 8px; }
  .topbar .home-brand > span:last-child { min-width: 0; overflow: hidden; }
  .topbar .home-brand b, .topbar .home-brand small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar .home-brand .logo { width: 32px; height: 32px; }
  .topbar .home-brand .logo img { width: 32px; height: 32px; }
  .topbar .user-menu > summary, .topbar .lang-btn, .topbar .bell { flex: none; }
  .topbar .user-menu { flex: none; position: relative; }
  .topbar .lang-btn { width: auto; padding: 0 8px; font-size: 12.5px; }
}
/* phones: nothing may widen the page sideways (in Arabic, the hidden side menu did on some overview pages) */
@media (max-width: 900px) { html, body { overflow-x: clip; } }
/* chart scale in Arabic: the numbers stay left-to-right but sit on the right-hand side, where the chart starts */
[dir="rtl"] .chart .gridlines span { left: auto; right: -50px; text-align: start; }

/* matching payments and credit notes to invoices */
.link-btn { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 4px; font-size: 12px; }
.link-btn:hover { color: var(--bad); }
.outstanding table td { vertical-align: middle; }
.nowrap { white-space: nowrap; }
.outstanding table { width: 100%; }
.outstanding td:first-child { overflow-wrap: anywhere; }
.outstanding td.num { white-space: nowrap; width: 1%; }
.writeoff { display: inline-block; text-align: start; }
.writeoff > summary { list-style: none; cursor: pointer; } .writeoff > summary::-webkit-details-marker { display: none; }
.writeoff-form { display: grid; gap: 6px; margin-top: 8px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); max-width: 340px; }
.writeoff-form label { font-size: 12.5px; color: var(--muted); }

/* Filters menu: ready-made filters and date shortcuts */
.vx-quick-menu { min-width: 260px; display: grid; gap: 10px; }
.qf-group { display: grid; gap: 2px; }
.qf-h { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 2px 6px; }
.qf { display: block; padding: 6px 8px; border-radius: 7px; color: var(--text-2); text-decoration: none !important; font-size: 13.5px; }
.qf:hover { background: var(--surface-3); color: var(--text); }
.qf.on { color: var(--primary); font-weight: 600; background: var(--primary-soft); }
.qf-clear { color: var(--bad); border-top: 1px solid var(--border); border-radius: 0; margin-top: 2px; padding-top: 8px; }

/* section and note lines (Settings > Features > Section and note lines): no amount; the amount cells stay for the form */
.lines tr.line-section td:not(.ln-desc):not(:last-child), .lines tr.line-note td:not(.ln-desc):not(:last-child) { visibility: hidden; }
.lines tr.line-section .ln-desc input { font-weight: 700; }
.lines tr.line-note .ln-desc input { font-style: italic; }
.doc-section td { font-weight: 700; background: var(--surface-2, rgba(0,0,0,.03)); }
.doc-note td { font-style: italic; color: var(--muted); }

/* mentions and activities in Notes & history */
.chatter-note .mention { color: var(--accent, #0d9488); }
.activities { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 14px; }
.activity { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; }
.activity.late { border-color: rgba(220, 38, 38, .35); }
.activity form.inline { margin-inline-start: auto; display: inline-flex; gap: 6px; }
.mention-pop { position: absolute; z-index: 50; background: var(--surface, #fff); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.12); padding: 4px; max-height: 220px; overflow: auto; }
.mention-pop div { padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.mention-pop div.on, .mention-pop div:hover { background: rgba(13, 148, 136, .12); }

/* barcode scanning on receipts and deliveries */
tr.scan-ok td { background: rgba(16, 185, 129, .08); }
tr.scan-short td { background: rgba(245, 158, 11, .08); }
tr.scan-over td { background: rgba(220, 38, 38, .10); }

/* per-user access tree (Settings > Users) */
.access-tree { display: flex; flex-direction: column; gap: 4px; }
.access-app { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }
.access-app summary { cursor: pointer; display: flex; gap: 10px; align-items: center; }
.access-app .app-count:empty { display: none; }

/* My HR */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 14px; margin-bottom: 14px; }
.grid2 > .card { margin: 0; }
details.req { border-top: 1px solid var(--border); padding: 10px 0; }
details.req:first-of-type { border-top: 0; }
details.req summary { cursor: pointer; }
@media print { .letter-sheet { box-shadow: none !important; border: 0 !important; } }

/* amounts never break over two lines in reports */
table.report td.num, table.report th.num, table td.num { white-space: nowrap; }


/* ---- My preferences (per user): text size, font, density, sidebar, contrast ---- */
html[data-size="s"] body { zoom: .92; }
html[data-size="l"] body { zoom: 1.1; }
html[data-size="xl"] body { zoom: 1.22; }
html[data-font="plex"] { --font: "IBM Plex Sans", "IBM Plex Sans Arabic", system-ui, sans-serif; }
html[data-font="noto"] { --font: "Noto Sans", "Noto Sans Arabic", "IBM Plex Sans Arabic", system-ui, sans-serif; }
html[data-font="system"] { --font: system-ui, -apple-system, "Segoe UI", Roboto, "IBM Plex Sans Arabic", sans-serif; }
html[dir="rtl"][data-font="inter"], html[dir="rtl"][data-font="plex"] { --font: "IBM Plex Sans Arabic", "Inter", system-ui, sans-serif; }
html[data-density="compact"] th, html[data-density="compact"] td { padding: 6px 10px; }
html[data-density="compact"] .card { padding-block: 12px; }
html[data-density="compact"] .field { margin-bottom: 8px; }
html[data-density="compact"] .nav-link { padding-block: 5px; }
@media (min-width: 900px) {
  html[data-sidebar="collapsed"] .sidebar { width: 68px; }
  html[data-sidebar="collapsed"] .sidebar .brand > span:not(.logo),
  html[data-sidebar="collapsed"] .sidebar .side-search,
  html[data-sidebar="collapsed"] .sidebar .nav-link span,
  html[data-sidebar="collapsed"] .sidebar .side-app b,
  html[data-sidebar="collapsed"] .sidebar .side-app .all,
  html[data-sidebar="collapsed"] .sidebar .nav-h,
  html[data-sidebar="collapsed"] .sidebar .nav-app-h,
  html[data-sidebar="collapsed"] .sidebar .side-foot { display: none; }
  html[data-sidebar="collapsed"] .sidebar .nav-group.closed .nav-items { display: block; }
  html[data-sidebar="collapsed"] .sidebar .nav-link { justify-content: center; }
}
html[data-contrast="high"] { --text: #000; --text-2: #111827; --muted: #374151; --border: #9aa3b2; --border-strong: #6b7280; --sidebar-text: #e5e7eb; --sidebar-muted: #cbd5e1; }
html[data-contrast="high"][data-theme="dark"] { --text: #fff; --text-2: #f3f4f6; --muted: #d1d5db; --border: #6b7280; --border-strong: #9ca3af; }
html[data-contrast="high"] a:focus-visible, html[data-contrast="high"] button:focus-visible, html[data-contrast="high"] input:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.pref-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px 20px; }
.pref-choices { display: flex; flex-wrap: wrap; gap: 6px; }
.pref-choices label { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong); border-radius: 9px; padding: 7px 12px; cursor: pointer; background: var(--surface); }
.pref-choices input { margin: 0; }
.pref-choices label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.pref-preview { border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 14px; background: var(--surface-2); }

/* employee photos */
.emp-photo { border-radius: 50%; object-fit: cover; vertical-align: middle; display: inline-block; background: var(--surface-3); }
.emp-photo.none { display: inline-grid; place-items: center; color: var(--muted); font-weight: 600; border: 1px solid var(--border); }
.avatar-img { object-fit: cover; padding: 0; }

/* pinned pages: always at the top of the sidebar, folded by default */
.side-nav details.pinned { margin: 2px 8px 10px; border-block-end: 1px solid rgba(255, 255, 255, .06); padding-block-end: 6px; }
.side-nav details.pinned > summary { list-style: none; cursor: pointer; display: flex; gap: 6px; align-items: center; }
.side-nav details.pinned > summary::-webkit-details-marker { display: none; }
.side-nav .nav-empty { color: var(--sidebar-muted); font-size: 12px; padding: 4px 12px 6px; }
.icon-btn.on { color: #f59e0b; }

/* activity panel on documents */
.chatter-top{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap;margin-bottom:10px}
.chatter-meta{display:flex;align-items:center;gap:8px}
.chatter-tabs{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:12px}
.chatter-tabs .ch-tab{flex:0 0 auto}.chatter-tabs .ch-tab[open]{flex:1 1 100%;order:2}
.chatter-tabs .ch-tab>summary{list-style:none;cursor:pointer}.chatter-tabs .ch-tab>summary::-webkit-details-marker{display:none}
.chatter-tabs .ch-tab[open]>summary{background:var(--accent,#0d9488);color:#fff}
.chatter-form{display:flex;flex-direction:column;gap:6px;margin-top:8px}
.planned{border-top:1px solid var(--line,#e5e7eb);padding-top:8px;margin-bottom:8px}.planned h3{font-size:.85rem;text-transform:uppercase;letter-spacing:.04em;margin:4px 0 8px;color:var(--muted,#6b7280)}
.activity{display:flex;gap:10px;align-items:flex-start;padding:6px 0}.activity .act-due{font-weight:600}
.activity.late .act-due{color:#dc2626}.activity.today .act-due{color:#d97706}
.act-actions{display:flex;gap:12px;flex-wrap:wrap;margin-top:4px;font-size:.85rem}
.inline-pop>summary{list-style:none;cursor:pointer;display:inline}.inline-pop[open]{flex-basis:100%}
button.link,.link{background:none;border:0;padding:0;color:var(--accent,#0d9488);cursor:pointer;font:inherit}
.chatter-list li.is-msg .chatter-note{background:color-mix(in srgb,var(--accent,#0d9488) 8%,transparent);border-radius:8px;padding:6px 10px}

/* to-do */
.todo-h{padding:12px 16px 4px;margin:0;font-size:.95rem}
.todo-list{list-style:none;margin:0;padding:4px 16px 12px}.todo-list li{display:flex;gap:10px;align-items:flex-start;padding:8px 0;border-bottom:1px solid var(--line,#eee)}
.todo-list li:last-child{border-bottom:0}.todo-list li.late .todo-main small{color:#dc2626}
.todo-check{width:22px;height:22px;border-radius:6px;border:2px solid var(--line,#cbd5e1);background:transparent;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:#fff;padding:0}
.todo-check.on{background:var(--accent,#0d9488);border-color:var(--accent,#0d9488)}.todo-main{display:flex;flex-direction:column;gap:2px}
/* discuss */
.discuss{display:grid;grid-template-columns:260px 1fr;gap:16px;align-items:start}
@media (max-width:760px){.discuss{grid-template-columns:1fr}}
.dz-side{padding:12px}.dz-h{font-size:.75rem;text-transform:uppercase;letter-spacing:.05em;color:var(--muted,#6b7280);margin:10px 0 4px}
.dz-item{display:flex;justify-content:space-between;align-items:center;padding:6px 8px;border-radius:8px;color:inherit;text-decoration:none}
.dz-item:hover,.dz-item.active{background:color-mix(in srgb,var(--accent,#0d9488) 12%,transparent)}
.dz-item .dot{background:#dc2626;color:#fff;border-radius:10px;padding:0 6px;font-size:.75rem}
.dz-main{display:flex;flex-direction:column;height:calc(100vh - 160px);min-height:420px;padding:0}
.dz-top{display:flex;justify-content:space-between;align-items:center;padding:12px 16px;border-bottom:1px solid var(--line,#eee)}
.dz-msgs{flex:1;overflow-y:auto;padding:12px 16px}.dz-msg{display:flex;gap:10px;padding:6px 0}.dz-body{white-space:normal;word-break:break-word}
.dz-msg.mine .dz-body{background:color-mix(in srgb,var(--accent,#0d9488) 8%,transparent);border-radius:8px;padding:4px 8px;display:inline-block}
.dz-form{display:flex;gap:8px;padding:12px 16px;border-top:1px solid var(--line,#eee)}.dz-form textarea{flex:1}
.mention{color:var(--accent,#0d9488);font-weight:600}.doc-link{font-weight:600}
.field.check-help{display:flex;flex-direction:column;gap:4px}
.field.check-help .check{display:flex;align-items:center;gap:8px}
.field.check-help .check input[type=checkbox]{flex:0 0 auto;width:18px;height:18px;margin:0}
.field.check-help .help{margin-inline-start:26px}
.pager{display:inline-flex;align-items:center;gap:6px;margin-inline-start:auto;white-space:nowrap}
.pager input[name=r]{width:96px;text-align:center;padding:5px 6px}
.pager .disabled{pointer-events:none;opacity:.35}
main.content > .pager{display:flex;justify-content:flex-end;margin:0 0 8px}
/* journal entry grid */
.jv-head{display:flex;align-items:baseline;justify-content:space-between;gap:12px;margin:22px 0 8px;flex-wrap:wrap}.jv-head h2{margin:0}
.jv-grid{border:1px solid var(--line,#e5e7eb);border-radius:10px;overflow:hidden}
.jv-grid thead th{background:var(--bg-soft,#f8fafc);font-size:.78rem;text-transform:uppercase;letter-spacing:.04em}
.jv-grid tbody tr:nth-child(even):not(.tpl){background:color-mix(in srgb,var(--accent,#0d9488) 3%,transparent)}
.jv-grid td{padding:4px 6px}.jv-grid input,.jv-grid select{border-color:transparent;background:transparent}
.jv-grid input:focus,.jv-grid select:focus{border-color:var(--accent,#0d9488);background:#fff}
.jv-grid input.num[data-auto]{color:var(--muted,#64748b);font-style:italic}
.jv-grid tfoot td{font-weight:700;border-top:2px solid var(--line,#e5e7eb);padding:10px 6px}
.jv-diff{margin-inline-start:12px}.jv-diff.ok{color:#16a34a}
.side-nav.searching [data-hide-searching]{display:none}
/* grouped document actions */
.actions.act-bar{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.act-group{display:inline-flex;border:1px solid var(--line,#e2e8f0);border-radius:10px;overflow:hidden}
.act-group > .btn{border:0;border-radius:0;border-inline-end:1px solid var(--line,#e2e8f0)}.act-group > .btn:last-child{border-inline-end:0}
.act-menu{position:relative}.act-menu > summary{list-style:none;cursor:pointer}.act-menu > summary::-webkit-details-marker{display:none}
.act-pop{position:absolute;inset-inline-end:0;top:calc(100% + 6px);z-index:40;min-width:230px;background:var(--card,#fff);border:1px solid var(--line,#e2e8f0);border-radius:12px;box-shadow:0 12px 32px rgba(15,23,42,.14);padding:6px;display:flex;flex-direction:column}
.act-pop > a,.act-pop > form{display:block;margin:0}
.act-pop .btn{display:block;width:100%;text-align:start;border:0;background:none;box-shadow:none;padding:9px 12px;border-radius:8px;justify-content:flex-start}
.act-pop .btn:hover{background:var(--bg-soft,#f1f5f9)}.act-pop .btn.danger,.act-pop button.danger{color:#dc2626}
.act-pop hr{border:0;border-top:1px solid var(--line,#e2e8f0);margin:4px 0}
/* AR / AP dashboard */
.dash-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:14px;margin-bottom:14px}
.dash-cols{display:grid;grid-template-columns:1.2fr 1fr;gap:14px}@media(max-width:900px){.dash-cols{grid-template-columns:1fr}}
.dash-cols h3,.card > h3{margin:0 0 10px;font-size:.95rem}
.dbar{display:grid;grid-template-columns:110px 1fr 120px;gap:10px;align-items:center;padding:4px 0;font-size:.88rem}
.dbar .dt{height:12px;background:var(--bg-soft,#f1f5f9);border-radius:6px;overflow:hidden}
.dbar .dt i{display:block;height:100%;background:var(--accent,#0d9488);border-radius:6px}.dbar .dt i.late{background:#f59e0b}.dbar .dt i.old{background:#dc2626}
.vbars{display:flex;align-items:flex-end;gap:8px;height:170px;padding-top:6px}
.vb{flex:1;display:flex;flex-direction:column;align-items:center;gap:4px;height:100%}.vb small{color:var(--muted,#64748b);font-size:.7rem}
.vbp{flex:1;width:100%;display:flex;align-items:flex-end;justify-content:center;gap:3px}
.vbp i{display:block;width:40%;border-radius:4px 4px 0 0;min-height:1px}
i.b1{background:var(--accent,#0d9488)}i.b2{background:#94a3b8}
.legend{display:flex;gap:16px;font-size:.8rem;color:var(--muted,#64748b);margin-top:8px}.legend i{display:inline-block;width:10px;height:10px;border-radius:2px;margin-inline-end:6px}
table.slim td,table.slim th{padding:6px 8px}

.dbar .dl{font-size:.85rem}.kpi .mini{display:flex;justify-content:space-between;font-size:.88rem;padding:2px 0}

a.kpi{color:inherit;text-decoration:none;transition:transform .15s,box-shadow .15s}a.kpi:hover{transform:translateY(-2px);box-shadow:0 10px 24px rgba(15,23,42,.08)}
.chart a.m{color:inherit;text-decoration:none}
/* phones: folded filters and journal lines as cards */
.f-fold{display:none}
@media (max-width:700px){
  form.filters.f-foldable{display:flex;flex-wrap:wrap;gap:8px}
  form.filters.f-foldable .f-fold{display:inline-flex}
  form.filters.f-foldable > :not(.f-fold):not(.vx-search):not(input[type=search]):not(.pager):not([type=hidden]){display:none}
  form.filters.f-foldable.f-open > *{display:revert}
  form.filters.f-foldable .vx-search,form.filters.f-foldable input[type=search]{flex:1 1 100%}
  .page-head .actions{gap:6px}.page-head .actions .btn{padding:7px 10px;font-size:.85rem}
  table.jv-grid,table.jv-grid tbody,table.jv-grid tr,table.jv-grid td{display:block;width:100%}
  table.jv-grid thead{display:none}
  table.jv-grid tbody tr:not(.tpl){border:1px solid var(--line,#e2e8f0);border-radius:10px;margin:8px 0;padding:6px 8px;background:var(--card,#fff)}
  table.jv-grid td{display:grid;grid-template-columns:96px 1fr;align-items:center;gap:8px;padding:3px 0}
  table.jv-grid td::before{content:attr(data-label);font-size:.75rem;color:var(--muted,#64748b);text-transform:uppercase}
  table.jv-grid input,table.jv-grid select{border-color:var(--line,#e2e8f0)!important;background:#fff!important}
  table.jv-grid td:last-child{grid-template-columns:1fr;justify-items:end}table.jv-grid td:last-child::before{content:none}
  table.jv-grid tfoot tr{display:flex;flex-wrap:wrap;gap:10px;justify-content:space-between}table.jv-grid tfoot td{display:block;width:auto}
}
