/* FridaERP — styles (v3). Restrained, neutral, one accent colour; no motion that moves the layout.
   Logical properties (inline-start/end) so Arabic (RTL) mirrors automatically; numbers stay left-to-right.
   Fonts are the ones Windows / phones already have — nothing is downloaded. */
:root {
  /* neutrals (cool slate) */
  --bg: #f6f7f9; --panel: #ffffff; --panel2: #f9fafb; --panel3: #f1f3f5; --hover: #f3f5f7;
  --text: #111827; --text2: #374151; --muted: #6b7280; --faint: #9ca3af;
  --line: #e5e7eb; --line2: #eef0f3; --line-strong: #d1d5db;
  --grid: #cdd3dc; --grid-head: #b3bcc8; /* table cell and header separators */
  /* one accent */
  --primary: #0f6e8c; --primary-d: #0b5870; --primary-l: #e8f3f7; --primary-ll: #f3f9fb; --ring: rgba(15,110,140,.25); --on-primary: #fff;
  /* status */
  --ok: #15803d; --ok-l: #ecf7f0; --warn: #a16207; --warn-l: #fdf6e3; --bad: #b91c1c; --bad-l: #fdf0f0;
  /* sidebar (light) */
  --side: #fbfbfc; --side-text: #374151; --side-muted: #8a919c; --side-hover: #f1f3f5; --side-active: #e8f3f7; --side-active-text: #0b5870;
  --shadow-s: 0 1px 2px rgba(17,24,39,.05);
  --shadow-pop: 0 10px 28px rgba(17,24,39,.12), 0 2px 6px rgba(17,24,39,.06);
  --radius: 8px; --radius-s: 6px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, "Noto Sans", Arial, sans-serif;
  --font-ar: "Segoe UI", "Noto Sans Arabic", "Noto Naskh Arabic", Tahoma, "Geeza Pro", Arial, sans-serif;
  --fs: 14px; --lh: 1.45;
  --side-w: 248px; --top-h: 56px; --pad: 24px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0d1117; --panel: #151b23; --panel2: #191f28; --panel3: #1f2630; --hover: #1c232c;
  --text: #e6e9ee; --text2: #c5cbd3; --muted: #8b949e; --faint: #6e7681;
  --line: #2a313c; --line2: #222933; --line-strong: #3a424e;
  --grid: #303845; --grid-head: #434c5a;
  --primary: #4cb3d4; --primary-d: #6cc4e0; --primary-l: rgba(76,179,212,.14); --primary-ll: rgba(76,179,212,.07); --ring: rgba(76,179,212,.3); --on-primary: #06202a;
  --ok: #4ade80; --ok-l: rgba(74,222,128,.12); --warn: #eab308; --warn-l: rgba(234,179,8,.12); --bad: #f87171; --bad-l: rgba(248,113,113,.12);
  --side: #11161d; --side-text: #c5cbd3; --side-muted: #6e7681; --side-hover: #1a2029; --side-active: rgba(76,179,212,.14); --side-active-text: #8fd3ea;
  --shadow-s: none; --shadow-pop: 0 12px 32px rgba(0,0,0,.55);
  color-scheme: dark;
}
/* Arabic script reads small at the same pixel size: larger type and more line height */
:root[lang="ar"] { --font: var(--font-ar); --fs: 15px; --lh: 1.65; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: var(--fs); line-height: var(--lh); color: var(--text); background: var(--bg); -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
button, input, select, textarea { font: inherit; color: inherit; line-height: 1.3; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
.nav a:hover, .bottom-nav a:hover, .quick a:hover, .btn:hover { text-decoration: none; }
img, svg { max-width: 100%; }
::selection { background: var(--ring); }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); font-size: 18px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
/* everything (numbers too) starts at the reading side: left in TR/EN, right in AR */
.num { text-align: start; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* numbers, codes and dates keep left-to-right order inside Arabic text (minus sign stays in front) */
[dir="rtl"] .num, [dir="rtl"] input.in.num, [dir="rtl"] input[type="date"], [dir="rtl"] .ltr { direction: ltr; text-align: right; }
[dir="rtl"] .ltr { display: inline-block; }
.neg { color: var(--bad); }
.pos { color: var(--ok); }
.nowrap { white-space: nowrap; }
.grow { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
[dir="rtl"] svg.i.dir { transform: scaleX(-1); }

/* ---------- layout */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); height: 100vh; height: 100dvh; }
.shell.mini { --side-w: 64px; }
.side { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; overflow: hidden; border-inline-end: 1px solid var(--line); min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 16px; height: var(--top-h); flex: none; font-weight: 650; font-size: 15px; color: var(--text); border-bottom: 1px solid var(--line); }
.brand .logo { width: 30px; height: 30px; border-radius: 7px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; font-size: 15px; font-weight: 750; flex: none; }
.brand > div:last-child { min-width: 0; line-height: 1.2; }
.brand small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { overflow-y: auto; overflow-x: hidden; padding: 8px 8px 16px; flex: 1; overscroll-behavior: contain; }
.nav .grp + .grp { margin-top: 6px; }
.nav .grp-title { font-size: 11.5px; font-weight: 600; letter-spacing: .02em; color: var(--side-muted); padding: 10px 10px 4px; cursor: pointer;
  display: flex; align-items: center; gap: 6px; user-select: none; border-radius: 6px; }
:root[lang="ar"] .nav .grp-title { font-size: 12.5px; letter-spacing: 0; }
.nav .grp-title:hover { color: var(--side-text); }
.nav .grp-title .chev { margin-inline-start: auto; width: 14px; height: 14px; opacity: .7; }
.nav .grp.closed .grp-title .chev { transform: rotate(-90deg); }
[dir="rtl"] .nav .grp.closed .grp-title .chev { transform: rotate(90deg); }
.nav .grp-items { display: grid; gap: 1px; }
.nav .grp.closed .grp-items { display: none; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 6px 10px; min-height: 34px; border-radius: 6px; color: var(--side-text); font-size: 13.5px; white-space: nowrap; }
:root[lang="ar"] .nav a { font-size: 14.5px; }
.nav a span { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.nav a:hover { background: var(--side-hover); color: var(--text); }
.nav a.active { background: var(--side-active); color: var(--side-active-text); font-weight: 600; }
.nav a .i { width: 17px; height: 17px; color: var(--side-muted); }
.nav a:hover .i { color: var(--side-text); }
.nav a.active .i { color: var(--side-active-text); }
.side-foot { padding: 8px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 6px; min-height: 48px; }
.side-foot .ver { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* collapsed (icon rail) */
.shell.mini .brand > div:last-child, .shell.mini .nav a span, .shell.mini .grp-title, .shell.mini .side-foot .ver { display: none; }
.shell.mini .brand { justify-content: center; padding: 0; }
.shell.mini .nav { padding-inline: 8px; }
.shell.mini .nav a { justify-content: center; padding: 0; height: 38px; }
.shell.mini .nav .grp + .grp { border-top: 1px solid var(--line); padding-top: 6px; }
.shell.mini .nav .grp.closed .grp-items { display: grid; }
.shell.mini .side-foot { justify-content: center; }
.shell.mini .side-foot .collapse .i { transform: scaleX(-1); }
[dir="rtl"] .shell.mini .side-foot .collapse .i { transform: none; }

.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; height: 100dvh; }
.top { display: flex; align-items: center; gap: 12px; padding: 0 var(--pad); background: var(--panel); border-bottom: 1px solid var(--line); height: var(--top-h); flex: none; position: relative; z-index: 20; min-width: 0; }
.top .menu-btn { display: none; }
.crumb { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 0 1 auto; font-size: 13.5px; color: var(--muted); white-space: nowrap; }
.crumb > * { overflow: hidden; text-overflow: ellipsis; }
.crumb b { color: var(--text); font-weight: 600; }
.crumb .sep { color: var(--faint); }
.search-btn { display: flex; align-items: center; gap: 8px; background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 0 10px; height: 34px; color: var(--muted); cursor: pointer;
  width: 100%; max-width: 380px; min-width: 0; margin-inline-start: auto; font-size: 13.5px; }
.search-btn:hover { border-color: var(--line-strong); background: var(--panel); }
.search-btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-btn kbd { margin-inline-start: auto; font-size: 11px; font-family: inherit; border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; background: var(--panel); color: var(--muted); white-space: nowrap; }
.top-tools { display: flex; align-items: center; gap: 4px; flex: none; }
.seg { display: inline-flex; background: var(--panel3); border-radius: var(--radius-s); padding: 2px; gap: 2px; }
.seg button { border: 0; background: none; padding: 3px 9px; border-radius: 4px; cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--muted); min-width: 32px; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 0 0 1px var(--line), var(--shadow-s); }
/* fiscal year selector and the closed-year strip */
.year-btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--panel); cursor: pointer; font-weight: 600; font-size: 13px; color: var(--text2); white-space: nowrap; }
.year-btn:hover { background: var(--hover); }
.year-btn .i { width: 15px; height: 15px; color: var(--primary); }
.year-btn.archive { background: var(--warn-l); border-color: color-mix(in srgb, var(--warn) 45%, transparent); color: var(--warn); }
.year-btn.archive .i { color: var(--warn); }
.year-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px var(--pad); background: var(--warn-l); color: var(--warn); border-bottom: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); font-size: 13.5px; flex: none; }
.year-banner > span { flex: 1; min-width: 0; }
.year-banner .btn { color: var(--text2); }
.shell.archive .side { box-shadow: inset 0 3px 0 var(--warn); }
.year-pop { width: 300px; }
.year-pop button.mi { align-items: center; }
.year-pop button.mi .grow { display: flex; flex-direction: column; min-width: 0; }
.year-pop button.mi small { color: var(--muted); font-size: 12px; }
.year-pop button.mi.on { background: var(--primary-l); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 650; font-size: 12px; color: var(--primary-d); background: var(--primary-l); flex: none; }
.user-btn { display: flex; align-items: center; gap: 8px; border: 0; background: none; border-radius: var(--radius-s); padding: 3px 6px; cursor: pointer; min-width: 0; }
.user-btn:hover { background: var(--hover); }
.user-btn .nm { display: flex; flex-direction: column; text-align: start; line-height: 1.2; min-width: 0; }
.user-btn .nm b { font-size: 13px; font-weight: 600; white-space: nowrap; }
.user-btn .nm small { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.menu-pop { position: absolute; top: calc(var(--top-h) - 4px); inset-inline-end: 12px; width: 248px; max-width: calc(100vw - 24px); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-pop); padding: 6px; z-index: 45; animation: fade .12s; }
.menu-pop .hd { display: flex; gap: 10px; align-items: center; padding: 8px; border-bottom: 1px solid var(--line2); margin-bottom: 4px; }
.menu-pop .hd div { min-width: 0; } .menu-pop .hd b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .menu-pop .hd small { color: var(--muted); }
.menu-pop button.mi { display: flex; width: 100%; align-items: center; gap: 10px; border: 0; background: none; padding: 8px; border-radius: var(--radius-s); cursor: pointer; text-align: start; }
.menu-pop button.mi:hover { background: var(--hover); }
.menu-pop button.mi.danger { color: var(--bad); }
.menu-pop .lbl { font-size: 12px; color: var(--muted); padding: 8px 8px 4px; }
.menu-pop .seg { margin: 0 8px 4px; display: flex; } .menu-pop .seg button { flex: 1; }
/* scrollbar-gutter keeps the page from jumping sideways when a scrollbar appears */
.content { flex: 1; overflow-y: auto; overflow-x: hidden; padding: var(--pad) var(--pad) 48px; scrollbar-gutter: stable; min-width: 0; }
.content > *:not(.doc-bar) { max-width: 100%; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; min-width: 0; }
.page-head > div:first-child { min-width: 0; }
.page-head h1 { font-size: 20px; margin: 0; font-weight: 650; line-height: 1.3; letter-spacing: -.01em; overflow-wrap: anywhere; }
:root[lang="ar"] .page-head h1 { font-size: 21px; letter-spacing: 0; }
.page-head .sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.page-head .actions { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }

/* ---------- controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--panel); border-radius: var(--radius-s); padding: 0 12px; height: 34px;
  cursor: pointer; font-weight: 550; font-size: 13.5px; white-space: nowrap; color: var(--text2); box-shadow: var(--shadow-s); }
:root[lang="ar"] .btn { font-size: 14px; }
.btn:hover { background: var(--hover); color: var(--text); }
.btn:active { background: var(--panel3); }
.btn:disabled { opacity: .5; cursor: default; }
.btn .i { width: 16px; height: 16px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-d); border-color: var(--primary-d); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-l); }
.btn.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--hover); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.sm .i { width: 15px; height: 15px; }
.btn.icon { padding: 0; width: 34px; }
.btn.sm.icon { width: 30px; }
.btn kbd { font-size: 10.5px; font-family: inherit; opacity: .7; border: 1px solid currentColor; border-radius: 3px; padding: 0 3px; line-height: 1.3; }
input.in, select.in, textarea.in { width: 100%; min-width: 0; border: 1px solid var(--line-strong); background: var(--panel); border-radius: var(--radius-s); padding: 0 10px; outline: none; height: 34px; }
textarea.in { height: auto; padding: 8px 10px; resize: vertical; min-height: 64px; line-height: var(--lh); }
input.in:hover, select.in:hover, textarea.in:hover { border-color: var(--faint); }
select.in { appearance: none; -webkit-appearance: none; padding-inline-end: 28px; cursor: pointer; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-size: 14px; background-position: right 8px center; }
[dir="rtl"] select.in { background-position: left 8px center; }
input.in:focus, select.in:focus, textarea.in:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
input.in[readonly], input.in:disabled, select.in:disabled { background-color: var(--panel2); color: var(--text2); }
input.in.bad, textarea.in.bad { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-l); }
input.in::placeholder, textarea.in::placeholder { color: var(--faint); }
.fld { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fld > label { font-size: 12.5px; color: var(--text2); font-weight: 550; }
:root[lang="ar"] .fld > label { font-size: 13.5px; }
.fld .hint { font-size: 12px; color: var(--muted); }
.grid { display: grid; gap: 14px 16px; grid-template-columns: repeat(auto-fill, minmax(min(190px, 100%), 1fr)); }
.grid > * { min-width: 0; }
.grid .span2 { grid-column: span 2; }
.grid .full { grid-column: 1 / -1; }
.chk { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; min-height: 34px; }
.chk input { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.card > .card-h { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; min-height: 48px; flex-wrap: wrap; }
.card > .card-h > .i { color: var(--muted); }
.card > .card-b { padding: 16px; }
.card + .card { margin-top: 16px; }
.kpis > .card + .card, .two > .card + .card, .quick > a { margin-top: 0; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 7px; border-radius: 4px; font-size: 12px; font-weight: 600; background: var(--panel3); color: var(--text2); white-space: nowrap; line-height: 1.6; }
.badge.ok { background: var(--ok-l); color: var(--ok); }
.badge.bad { background: var(--bad-l); color: var(--bad); }
.badge.warn { background: var(--warn-l); color: var(--warn); }
.badge.info { background: var(--primary-l); color: var(--primary-d); }
:root[data-theme="dark"] .badge.info { color: var(--primary); }
.banner { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; border: 1px solid; font-size: 13.5px; }
.banner .i { flex: none; }
.banner.warn { background: var(--warn-l); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.banner.bad { background: var(--bad-l); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.banner.info { background: var(--primary-ll); color: var(--primary-d); border-color: color-mix(in srgb, var(--primary) 25%, transparent); }
:root[data-theme="dark"] .banner.info { color: var(--primary); }
.banner a { font-weight: 600; text-decoration: underline; text-underline-offset: 2px; color: inherit; }
.filters { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.filters .fld { min-width: 140px; flex: 0 1 auto; }
.filters .fld.wide { min-width: 220px; flex: 1; max-width: 380px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; background: none; padding: 9px 12px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--muted); font-weight: 550; white-space: nowrap; flex: none; }
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--primary-d); border-bottom-color: var(--primary); }
:root[data-theme="dark"] .tabs button.on { color: var(--primary); }

/* ---------- tables */
.tbl-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); max-height: calc(100vh - 230px); max-height: calc(100dvh - 230px); }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
:root[lang="ar"] table.tbl { font-size: 14px; }
.tbl th { position: sticky; top: 0; z-index: 1; background: var(--panel2); text-align: start; font-weight: 600; color: var(--muted); font-size: 12.5px;
  padding: 0 12px; height: 38px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: default; user-select: none; }
.tbl th.sortable { cursor: pointer; }
.tbl th.sortable:hover { color: var(--text); }
.tbl th.sorted { color: var(--text); }
.tbl th.sorted::after { content: "↓"; margin-inline-start: 4px; color: var(--primary); }
.tbl th.sorted.asc::after { content: "↑"; }
.tbl td { padding: 8px 12px; height: 40px; border-bottom: 1px solid var(--line2); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--hover); }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.deleted td { text-decoration: line-through; color: var(--faint); }
.tbl tbody tr.group td { font-weight: 600; background: var(--panel2); }
.tbl tfoot td { position: sticky; bottom: 0; background: var(--panel2); font-weight: 650; border-top: 1px solid var(--line); }
.tbl .lvl1 td:first-child, .tbl .lvl1 td:nth-child(2) { font-weight: 650; }
.tbl .lvl2 td:first-child, .tbl .lvl2 td:nth-child(2) { font-weight: 600; }
/* tables with a header: thin column separators, and number columns only as wide as their numbers
   (otherwise a right-aligned number sits right against the next left-aligned column) */
.tbl:has(> thead) th + th, .tbl:has(> thead) td + td { border-inline-start: 1px solid var(--grid); }
.tbl:has(> thead) th { border-bottom-color: var(--grid-head); }
.tbl:has(> thead) th + th { border-inline-start-color: var(--grid-head); }
.tbl:has(> thead) td { border-bottom-color: var(--grid); }
.tbl:has(> thead) th, .tbl:has(> thead) td { padding-inline: 16px; }
/* number columns: as wide as the widest number, with clear room before the next column line */
.tbl:has(> thead) th.num, .tbl:has(> thead) td.num { width: 1%; }
/* one line per row: long texts are cut with … (full text in the tooltip set by app.js) */
.tbl:has(> thead) td { white-space: nowrap; max-width: 460px; overflow: hidden; text-overflow: ellipsis; }
/* notes: wrap onto a second line rather than push the table wider than the screen */
.tbl:has(> thead) td.wrap { white-space: normal; min-width: 180px; max-width: none; overflow-wrap: anywhere; }
.tbl tfoot td { border-top: 2px solid var(--grid-head); }
.tbl-wrap { border-color: var(--grid-head); }
@media (max-width: 640px) { .tbl-wrap { border: 0; } }
.tbl tfoot td.num { font-variant-numeric: tabular-nums; }
/* compact rows (user menu → row density) */
:root[data-density="compact"] .tbl td { height: 32px; padding-block: 4px; }
:root[data-density="compact"] .tbl th { height: 32px; }
:root[data-density="compact"] .lines td { padding-block: 1px; }
:root[data-density="compact"] .lines input.in, :root[data-density="compact"] .lines select.in { height: 28px; }
.card-b > table.tbl td { padding-inline: 10px; }
.card-b > table.tbl td.num { padding-inline-end: 12px; }
/* line editors (invoice / voucher lines): same column lines as the lists */
.lines th + th, .lines td + td { border-inline-start: 1px solid var(--grid); }
.lines th { border-bottom-color: var(--grid-head); }
.lines td { border-bottom-color: var(--grid); }
table.lines th { padding-inline: 12px; }

table.lines td { padding-inline: 4px; }
table.lines td.no { padding-inline: 4px; }
.card-b > table.tbl tr:first-child td { padding-top: 4px; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.tbl-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.tbl-tools > input.in { padding-inline-start: 32px; background-repeat: no-repeat; background-size: 15px; background-position: left 10px center; max-width: 280px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16M21 21l-4.3-4.3'/%3E%3C/svg%3E"); }
[dir="rtl"] .tbl-tools > input.in { background-position: right 10px center; }
.tbl-tools .count { color: var(--muted); font-size: 13px; white-space: nowrap; }

/* ---------- line editor grid (invoices, vouchers) */
.lines { width: 100%; border-collapse: collapse; }
.lines th { font-size: 12.5px; color: var(--muted); font-weight: 600; text-align: start; padding: 6px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.lines td { padding: 3px; border-bottom: 1px solid var(--line2); vertical-align: middle; }
.lines td.no { color: var(--faint); width: 32px; text-align: center; font-size: 12px; }
.lines input.in, .lines select.in { height: 32px; padding: 0 8px; border-color: transparent; background-color: transparent; box-shadow: none; }
.lines select.in { padding-inline-end: 24px; }
.lines input.in:hover, .lines select.in:hover { border-color: var(--line-strong); }
.lines input.in:focus, .lines select.in:focus { background-color: var(--panel); border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.lines tr:focus-within td { background: var(--primary-ll); }
.lines .info { font-size: 12px; color: var(--muted); white-space: nowrap; padding-inline: 6px; }
.lines .x { opacity: .4; }
.lines tr:hover .x, .lines .x:focus { opacity: 1; }
.lines-wrap { overflow-x: auto; }
.totals { display: grid; grid-template-columns: auto auto; gap: 6px 24px; justify-content: start; align-items: center; margin-top: 12px; width: fit-content; max-width: 100%; }
.totals .lbl { color: var(--muted); text-align: start; }
.totals .val { text-align: start; font-variant-numeric: tabular-nums; min-width: 140px; font-weight: 600; }
[dir="rtl"] .totals .val { direction: ltr; text-align: right; }
.totals .big { font-size: 18px; color: var(--text); font-weight: 700; }
.doc-bar { position: sticky; bottom: -48px; margin: 16px calc(-1 * var(--pad)) -48px; padding: 10px var(--pad); background: var(--panel);
  border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: nowrap; align-items: center; z-index: 5; }
.doc-bar .spacer { flex: 1; }
.doc-bar > .muted { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.pill-warn { color: var(--warn); font-size: 12px; }

/* ---------- lookup (autocomplete) */
.lk { position: relative; min-width: 0; }
.lk-list { position: fixed; z-index: 60; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-pop); max-height: 320px; overflow: auto; min-width: 280px; max-width: calc(100vw - 16px); padding: 4px; }
.lk-item { padding: 7px 8px; cursor: pointer; display: flex; gap: 10px; align-items: baseline; border-radius: 4px; }
.lk-item .c { color: var(--muted); font-size: 12px; min-width: 56px; font-variant-numeric: tabular-nums; }
.lk-item .r { margin-inline-start: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.lk-item.on { background: var(--primary-l); }
.lk-empty { padding: 10px; color: var(--muted); }

/* ---------- modal, toast */
.modal-back { position: fixed; inset: 0; background: rgba(17,24,39,.45); z-index: 50; display: grid; place-items: center; padding: 16px; animation: fade .12s; }
.modal { background: var(--panel); border-radius: 10px; box-shadow: var(--shadow-pop); width: min(560px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; border: 1px solid var(--line); min-width: 0; }
.modal.wide { width: min(980px, 100%); }
.modal.xwide { width: min(1200px, 100%); }
.modal-h { padding: 0 8px 0 18px; padding-inline: 18px 8px; height: 52px; flex: none; border-bottom: 1px solid var(--line); font-weight: 650; font-size: 15.5px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.modal-h .x { margin-inline-start: auto; }
.modal-b { padding: 18px; overflow: auto; }
.modal-f { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; flex: none; }
#toasts { position: fixed; bottom: 16px; inset-inline-end: 16px; z-index: 80; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: flex-start; gap: 10px; background: var(--panel); color: var(--text); padding: 11px 14px; border-radius: var(--radius); box-shadow: var(--shadow-pop); width: 360px; max-width: 100%;
  border: 1px solid var(--line); animation: fade .15s; font-size: 13.5px; }
.toast .i { margin-top: 1px; color: var(--primary); }
.toast.ok .i { color: var(--ok); }
.toast.bad { border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); } .toast.bad .i { color: var(--bad); }

/* ---------- command palette */
.modal.cmdk { width: min(640px, 100%); align-self: start; margin-top: 12vh; overflow: hidden; }
.cmdk .modal-h { display: none; }
.cmdk .modal-b { padding: 0; }
.cmdk input { border: 0; border-bottom: 1px solid var(--line); padding: 0 16px 0 44px; height: 52px; font-size: 15.5px; width: 100%; outline: none; background: var(--panel) no-repeat left 16px center / 18px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16M21 21l-4.3-4.3'/%3E%3C/svg%3E"); }
[dir="rtl"] .cmdk input { padding: 0 44px 0 16px; background-position: right 16px center; }
.cmdk .list { max-height: 55vh; overflow: auto; padding: 6px; }
.cmdk .it { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: var(--radius-s); cursor: pointer; min-width: 0; }
.cmdk .it .i { color: var(--muted); }
.cmdk .it.on { background: var(--primary-l); }
.cmdk .it .k { margin-inline-start: auto; color: var(--muted); font-size: 12px; }
.cmdk .sec { font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 10px 4px; }
.cmdk .foot { display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--line); background: var(--panel2); font-size: 12px; color: var(--muted); }
.cmdk .foot kbd { font-family: inherit; border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; background: var(--panel); margin-inline-end: 4px; }

/* ---------- dashboard */
.hero { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.hero h1 { font-size: 20px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
:root[lang="ar"] .hero h1 { font-size: 21px; letter-spacing: 0; }
.hero .sub { color: var(--muted); margin-top: 2px; font-size: 13.5px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.quick a { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; border-radius: var(--radius-s); background: var(--panel); border: 1px solid var(--line-strong); color: var(--text2); font-weight: 550; font-size: 13.5px; white-space: nowrap; box-shadow: var(--shadow-s); }
.quick a:hover { background: var(--hover); color: var(--text); }
.quick a .ic { display: contents; }
.quick a .i { width: 16px; height: 16px; color: var(--primary); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { padding: 14px 16px; min-width: 0; }
.kpi[style*="pointer"]:hover { border-color: var(--line-strong); background: var(--panel2); }
.kpi .l { color: var(--muted); font-size: 13px; font-weight: 500; display: flex; gap: 8px; align-items: center; min-width: 0; }
.kpi .l .chip { display: contents; }
.kpi .l .i { width: 16px; height: 16px; color: var(--faint); }
.kpi .v { font-size: 22px; font-weight: 650; margin-top: 8px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.25; }
[dir="rtl"] .kpi .v { direction: ltr; text-align: right; }
.kpi .s { color: var(--muted); font-size: 12px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .go { display: none; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.two.wide-l { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
.chart-card .card-h .tot { margin-inline-start: auto; font-weight: 650; font-size: 15px; font-variant-numeric: tabular-nums; }
[dir="rtl"] .chart-card .card-h .tot { direction: ltr; }
.area { position: relative; height: 220px; }
.area svg { width: 100%; height: 100%; display: block; overflow: visible; }
.area .gl { stroke: var(--line2); stroke-width: 1; }
.area .ln { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.area .ar { fill: url(#fridaArea); }
.area .ax { font-size: 11px; fill: var(--muted); font-family: var(--font); }
.area .dot { fill: var(--panel); stroke: var(--primary); stroke-width: 2; }
.area .vline { stroke: var(--line-strong); stroke-width: 1; }
.area .tip { position: absolute; pointer-events: none; background: var(--panel); color: var(--text); border: 1px solid var(--line); padding: 6px 10px; border-radius: var(--radius-s); font-size: 12px; white-space: nowrap; box-shadow: var(--shadow-pop); transform: translate(-50%, calc(-100% - 10px)); }
.area .tip span { color: var(--muted); }
.area .tip b { display: block; font-size: 13.5px; font-variant-numeric: tabular-nums; direction: ltr; }
.rank { display: grid; gap: 2px; }
.rank .r { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 7px 6px; border-radius: var(--radius-s); cursor: pointer; }
.rank .r:hover { background: var(--hover); }
.rank .r .n { font-size: 12px; font-weight: 600; color: var(--faint); text-align: center; font-variant-numeric: tabular-nums; }
.rank .r .nm div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank .r .bar { height: 4px; border-radius: 4px; background: var(--panel3); margin-top: 6px; overflow: hidden; }
.rank .r .bar i { display: block; height: 100%; border-radius: 4px; background: var(--primary); opacity: .75; }
.rank .r .amt { font-weight: 600; font-variant-numeric: tabular-nums; direction: ltr; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 8px; }
.bars div { flex: 1; background: var(--primary); border-radius: 2px 2px 0 0; min-height: 2px; opacity: .8; }
.bars div:hover { opacity: 1; }
.low-stock { display: flex; flex-wrap: wrap; gap: 6px; }
/* day / document banding in the stock journal and day book */
.tbl tbody tr.day-b td { background: var(--panel2); }
/* count sheet: the counted quantity is the field people type into */
.cnt-table th.cnt-h, .cnt-table td.cnt-in { width: 160px; min-width: 140px; }
.cnt-table td.cnt-in { padding-block: 4px; overflow: visible; }
.cnt-table td.cnt-in input.in { height: 32px; font-weight: 600; }
/* monthly account movement: debit / credit bars */
.am-bar { display: grid; gap: 2px; min-width: 120px; }
.am-bar i { display: block; height: 5px; border-radius: 3px; }
.am-bar i.d { background: var(--primary); }
.am-bar i.c { background: color-mix(in srgb, var(--warn) 70%, transparent); }
.ra-h { font-size: 14px; font-weight: 650; margin: 18px 0 10px; color: var(--text2); }
/* yearly comparison bars */
.year-bars { display: flex; gap: 24px; align-items: stretch; height: 220px; padding-top: 4px; }
.year-bars .yb { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.year-bars .yb-v { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.year-bars .yb-track { flex: 1; width: 100%; max-width: 90px; display: flex; align-items: flex-end; background: var(--panel2); border-radius: 4px 4px 0 0; border-bottom: 2px solid var(--grid-head); }
.year-bars .yb-fill { width: 100%; background: color-mix(in srgb, var(--primary) 55%, transparent); border-radius: 4px 4px 0 0; }
.year-bars .yb-fill.cur { background: var(--primary); }
.year-bars .yb-l { font-weight: 600; font-size: 13px; }
@media (max-width: 640px) { .year-bars { gap: 10px; height: 180px; } .year-bars .yb-v { font-size: 11px; } }

/* ---------- login */
.login { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); background: var(--panel); }
.login .art { background: #0f2533; color: #fff; padding: 40px 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; min-width: 0; }
.login .art .brand { padding: 0; height: auto; border: 0; color: #fff; }
.login .art .brand .logo { background: #fff; color: #0f2533; }
.login .art .brand small { color: rgba(255,255,255,.6); }
.login .art h2 { font-size: 30px; line-height: 1.25; margin: 0 0 12px; max-width: 460px; font-weight: 650; letter-spacing: -.015em; }
:root[lang="ar"] .login .art h2 { letter-spacing: 0; line-height: 1.5; }
.login .art p { color: rgba(255,255,255,.7); max-width: 440px; margin: 0; font-size: 15px; }
.login .art .feats { display: grid; grid-template-columns: repeat(2, minmax(0, max-content)); gap: 10px 24px; margin-top: 28px; }
.login .art .feats span { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; color: rgba(255,255,255,.85); }
.login .art .feats .i { width: 16px; height: 16px; color: #7cc7de; }
.login .art .foot { color: rgba(255,255,255,.45); font-size: 12.5px; }
.login .pane { display: grid; place-items: center; padding: 32px 20px; background: var(--panel); min-width: 0; }
.login .box { width: min(360px, 100%); }
.login .box.stack { gap: 14px; }
.login .box h1 { margin: 0; font-size: 24px; font-weight: 650; letter-spacing: -.01em; }
.login .box .btn.primary { height: 40px; font-size: 14.5px; }
.login .box input.in { height: 40px; }
.login .langs { display: flex; gap: 2px; margin-top: 4px; background: var(--panel3); padding: 2px; border-radius: var(--radius-s); }
.login .langs button { flex: 1; border: 0; background: none; border-radius: 4px; padding: 5px 8px; cursor: pointer; color: var(--muted); font-weight: 600; }
.login .langs button.on { background: var(--panel); color: var(--text); box-shadow: 0 0 0 1px var(--line); }
.login .mobile-brand { display: none; }
.login .mobile-brand .brand { padding: 0; height: auto; border: 0; }

/* ---------- tree */
.tree-row { display: flex; align-items: center; gap: 6px; }
.tree-tog { width: 20px; text-align: center; cursor: pointer; color: var(--muted); user-select: none; }

/* ---------- audit diff */
.diff td { font-size: 13px; }
.diff .old { color: var(--bad); text-decoration: line-through; }
.diff .new { color: var(--ok); }

/* ---------- skeleton */
.skel { border-radius: 4px; background: var(--panel3); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }

/* ---------- mobile bottom navigation */
.bottom-nav { display: none; }
.scrim { display: none; }

/* ---------- print */
.print-only { display: none; }
@media print {
  @page { margin: 12mm; }
  body { background: #fff; color: #000; font-size: 11.5px; }
  .side, .top, .no-print, .doc-bar, .filters, .tbl-tools, .page-head .actions, #toasts, .bottom-nav, .menu-pop, .scrim { display: none !important; }
  .shell { display: block; height: auto; }
  .main, .content { height: auto; overflow: visible; padding: 0; }
  .tbl-wrap { max-height: none; overflow: visible; border: 0; }
  .tbl th { position: static; background: #eee !important; color: #000; }
  .tbl tfoot td { position: static; }
  .card { border: 0; }
  .print-only { display: block; }
}

/* ---------- laptops / landscape tablets */
@media (max-width: 1180px) {
  :root { --pad: 20px; }
  .two.wide-l { grid-template-columns: minmax(0, 1fr); }
  .user-btn .nm { display: none; }
}
@media (max-width: 1024px) {
  .crumb { display: none; }
  .search-btn { margin-inline-start: 0; max-width: none; flex: 1; }
}
/* ---------- phones and portrait tablets: off-canvas menu + bottom bar */
@media (max-width: 900px) {
  :root { --pad: 16px; --top-h: 54px; }
  .shell, .shell.mini { grid-template-columns: minmax(0, 1fr); --side-w: 280px; }
  .shell.mini .brand > div:last-child, .shell.mini .nav a span, .shell.mini .grp-title, .shell.mini .side-foot .ver { display: revert; }
  .shell.mini .brand { justify-content: flex-start; padding: 0 16px; }
  .shell.mini .nav a { justify-content: flex-start; padding: 6px 10px; height: auto; }
  .shell.mini .nav .grp + .grp { border-top: 0; padding-top: 0; }
  /* the off-canvas menu is hidden with visibility, not only moved, so it can never widen the page */
  .side { position: fixed; inset-block: 0; inset-inline-start: 0; width: min(300px, 86vw); z-index: 40; visibility: hidden; transform: translateX(-100%); transition: transform .2s ease, visibility 0s .2s; box-shadow: var(--shadow-pop); }
  [dir="rtl"] .side { transform: translateX(100%); }
  .side.open, [dir="rtl"] .side.open { visibility: visible; transform: none; transition: transform .2s ease; }
  .side-foot .collapse { display: none; }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(17,24,39,.4); z-index: 35; animation: fade .15s; }
  .top { padding: 0 8px; gap: 6px; }
  .top .menu-btn { display: inline-flex; }
  .search-btn kbd { display: none; }
  .top .seg, .top .theme-btn { display: none; }
  .year-btn { padding: 0 8px; } .year-btn span { max-width: 70px; overflow: hidden; text-overflow: ellipsis; }
  .year-banner { padding: 8px 12px; font-size: 12.5px; }
  .content { padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); scrollbar-gutter: auto; }
  .two, .two.wide-l { grid-template-columns: minmax(0, 1fr); }
  .tbl-wrap { max-height: none; }
  .doc-bar { margin: 16px -16px calc(-84px - env(safe-area-inset-bottom)); padding: 10px 16px calc(10px + 60px + env(safe-area-inset-bottom)); bottom: calc(-84px - env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .doc-bar > .muted { display: none; }
  .hide-sm { display: none !important; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px; } .kpi .v { font-size: 17px; }
  #toasts { bottom: calc(72px + env(safe-area-inset-bottom)); inset-inline: 12px; max-width: none; }
  .toast { width: auto; }
  .bottom-nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; inset-inline: 0; bottom: 0; z-index: 30; background: var(--panel);
    border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .bottom-nav a, .bottom-nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 52px; font-size: 11px; font-weight: 550; color: var(--muted); border: 0; background: none; cursor: pointer; min-width: 0; border-radius: var(--radius-s); }
  :root[lang="ar"] .bottom-nav a, :root[lang="ar"] .bottom-nav button { font-size: 12px; }
  .bottom-nav a span, .bottom-nav button span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; padding-inline: 2px; }
  .bottom-nav .i { width: 21px; height: 21px; }
  .bottom-nav a.active { color: var(--primary); }
  .bottom-nav .fab .i { width: 34px; height: 26px; padding: 3px 7px; border-radius: 13px; background: var(--primary); color: var(--on-primary); }
  .login { grid-template-columns: minmax(0, 1fr); }
  .login .art { display: none; }
  .login .pane { background: var(--bg); align-items: start; padding-top: 12vh; }
  .login .box { background: var(--panel); padding: 24px 20px; border-radius: var(--radius); border: 1px solid var(--line); }
  .login .mobile-brand { display: block; }
}
@media (min-width: 641px) and (max-width: 900px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* touch screens: bigger targets */
@media (pointer: coarse) {
  .btn, input.in, select.in { height: 40px; } .btn.sm { height: 34px; } .btn.icon { width: 40px; } .btn.sm.icon { width: 34px; }
  .lines input.in, .lines select.in { height: 38px; }
  .nav a { min-height: 40px; }
}
/* ---------- phones: everything fits the width, tables become cards, dialogs become bottom sheets */
@media (max-width: 640px) {
  input.in, select.in, textarea.in { font-size: 16px; } /* stops iPhone zooming into fields */
  .page-head { margin-bottom: 12px; }
  .page-head > div:first-child { flex: 1 1 100%; }
  .page-head .actions { margin-inline-start: 0; width: 100%; }
  .page-head .actions > * { flex: 1 1 auto; }
  .page-head .actions > .btn.ghost { flex: 0 0 auto; margin-inline-start: auto; }
  .filters { padding: 10px; gap: 10px; }
  .filters > .fld, .filters > .fld.wide { min-width: 0; flex: 1 1 calc(50% - 10px); max-width: none; }
  .filters > .chk { flex: 1 1 calc(50% - 10px); }
  .filters > .btn { flex: 1 1 auto; }
  .tbl-tools > input.in { max-width: none !important; flex: 1 1 100%; }
  .tabs { margin-inline: -16px; padding-inline: 16px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .grid .span2 { grid-column: 1 / -1; }
  .totals { width: 100%; gap: 8px 12px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .totals .lbl { text-align: start; }
  .totals > * { min-width: 0 !important; }
  .totals .val { min-width: 0; }
  .modal-back { place-items: end stretch; padding: 0; }
  .modal, .modal.wide, .modal.xwide { width: 100%; max-height: 92vh; max-height: 92dvh; border-radius: 12px 12px 0 0; border-bottom: 0; }
  .modal-f { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .modal-f .btn { flex: 1 1 auto; }
  .modal.cmdk { margin-top: 0; align-self: end; }
  .cmdk .foot { display: none; }
  /* data tables as stacked cards: label from the column header (data-l, set by app.js) */
  .tbl-wrap { border: 0; background: none; overflow: visible; }
  table.tbl.cards, table.tbl.cards tbody, table.tbl.cards tfoot { display: block; }
  table.tbl.cards thead { display: none; }
  table.tbl.cards tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2px 12px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; }
  table.tbl.cards td { width: auto !important; max-width: none; overflow: visible; display: flex; flex-direction: column; height: auto; padding: 2px 0 !important; border: 0; min-width: 0; text-align: start; white-space: normal; overflow-wrap: anywhere; background: none !important; }
  table.tbl.cards td::before { content: attr(data-l); font-size: 11.5px; color: var(--muted); font-weight: 500; }
  table.tbl.cards td:empty, table.tbl.cards td[data-l=""]::before { display: none; }
  [dir="rtl"] table.tbl.cards td.num { direction: rtl; text-align: start; }
  [dir="rtl"] table.tbl.cards td.num > * { direction: ltr; }
  table.tbl.cards td.num { font-weight: 600; }
  table.tbl.cards tr.click:active { background: var(--hover); }
  table.tbl.cards tfoot tr { background: var(--panel2); position: static; }
  table.tbl.cards tfoot td { position: static; }
  table.tbl.cards tr.deleted { opacity: .6; }
  /* line editor rows as cards */
  .lines-wrap { overflow: visible; }
  table.lines, table.lines tbody { display: block; }
  table.lines thead { display: none; }
  table.lines tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 10px; padding: 10px 0 12px; border-bottom: 1px solid var(--line); position: relative; }
  table.lines td { display: flex; flex-direction: column; gap: 2px; padding: 0; border: 0; min-width: 0 !important; width: auto !important; }
  table.lines td::before { content: attr(data-l); font-size: 11.5px; color: var(--muted); }
  table.lines td[data-l=""]::before { display: none; }
  table.lines td.no { position: absolute; inset-inline-start: 0; top: 10px; width: auto; text-align: start; font-weight: 600; }
  table.lines td.no::before { display: none; }
  table.lines td.no + td { grid-column: 1 / -1; padding-inline-start: 26px; }
  table.lines td:last-child { position: absolute; inset-inline-end: 0; top: 4px; }
  table.lines td:last-child::before { display: none; }
  table.lines td.no + td:has(+ td:last-child) { padding-inline-end: 40px; }
  table.lines input.in, table.lines select.in { border-color: var(--line-strong); background-color: var(--panel); min-width: 0 !important; width: 100% !important; max-width: none !important; }
  table.lines tr:focus-within td { background: none; }
  table.lines .info { padding: 0; white-space: normal; }
  table.lines td .num { padding-inline: 0 !important; min-width: 0 !important; }
  .hero h1 { font-size: 18px; }
  .quick { flex-wrap: nowrap; overflow-x: auto; margin-inline: -16px; padding-inline: 16px; scrollbar-width: none; }
  .quick::-webkit-scrollbar { display: none; }
  .quick a { flex: none; }
  .menu-pop { inset-inline: 8px; width: auto; }
  .area { height: 180px; }
}
@media (max-width: 360px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.ye-steps { margin: 0; padding-inline-start: 20px; display: grid; gap: 4px; color: var(--text2); }
