/* Admin UI — brand colours / fonts via CSS variables (see :root and the generated theme.css). Desktop-first, usable on phones, RTL-aware. */
:root {
  /* Brand tokens. Defaults = ABN ALBLD; the generated theme.css (src/companies/<COMPANY>/theme.json), loaded after
     this file, overrides them per company. Components below only use the variables. */
  --brand-primary: #353535; --brand-primary-soft: #5A5A5A; --brand-primary-deep: #222222;
  --brand-accent: #D4AA3C; --brand-accent-bright: #EAD23E; --brand-accent-deep: #B8892A; --brand-on-accent: #222222;
  --brand-surface: #F6EDE2; --brand-paper: #FFFDF9; --brand-bg: #F7F3EC; --brand-line: #E7DFD2;
  --brand-ink: #2a2a2a; --brand-muted: #7d766b;
  --font-display: Montserrat; --font-body: Montserrat; --font-ar: 'IBM Plex Sans Arabic'; --font-ar-display: 'Aref Ruqaa';
  /* neutral tints that follow the palette (theme.json "css_vars" may override them) */
  --tint: #fbf8f3; --tint-hover: #fcf9f3; --tint-open: #fdfaf4; --tint-accent: #fffaf0; --tint-info: #f4f1ea; --readonly: #f6f3ee;
  --line-soft: #f0ebe2; --line-input: #d9d0c1; --line-strong: #ddd3c3; --line-dashed: #d9cfbf;
  --track: #efe9de; --track-2: #e5ddcf; --switch-off: #d6cebf; --toggle-bg: #efe8dc;
  --on-dark-1: #e6e1d8; --on-dark-2: #d8d0c2; --on-dark-3: #bdb5a8;
  /* names used by the components */
  --gold: var(--brand-accent); --gold-bright: var(--brand-accent-bright); --gold-deep: var(--brand-accent-deep);
  --charcoal: var(--brand-primary); --charcoal-soft: var(--brand-primary-soft); --cream: var(--brand-surface); --paper: var(--brand-paper);
  --bg: var(--brand-bg); --card: #FFFFFF; --line: var(--brand-line); --muted: var(--brand-muted); --text: var(--brand-ink);
  --green: #2f7d4f; --red: #b3392b; --amber: #a86b00; --blue: #2d5f8a;
  --radius: 10px; --shadow: 0 1px 2px color-mix(in srgb, var(--charcoal) 6%, transparent), 0 4px 16px color-mix(in srgb, var(--charcoal) 5%, transparent);
  --font: var(--font-body), var(--font-ar), system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
[lang="ar"], [dir="rtl"] { font-family: var(--font-ar), var(--font); }
a { color: var(--gold-deep); }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1, .brand-t b, .login-brand b, .tb-display { font-family: var(--font-display), var(--font); }
h1 { font-size: 22px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h3 { font-size: 15px; }
small, .muted { color: var(--muted); }
.block { display: block; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12.5px; }
.boot { display: grid; place-items: center; height: 100vh; font-weight: 600; letter-spacing: .2em; color: var(--gold-deep); }

/* ---------------------------------- shell --------------------------------- */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 236px; flex: none; background: var(--charcoal); color: #ddd; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; border-inline-end: 3px solid var(--gold);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px; text-decoration: none; color: #fff; }
.brand img { width: 40px; height: auto; }
.brand-t b { display: block; font-size: 16px; letter-spacing: .06em; background: linear-gradient(120deg, var(--gold-bright), var(--gold) 45%, var(--gold-deep)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-t small { color: #aaa; font-size: 11px; letter-spacing: .2em; text-transform: uppercase; }
.side nav { flex: 1; padding: 4px 8px; }
.nav-sec { font-size: 10.5px; letter-spacing: .18em; text-transform: uppercase; color: #8d8d8d; padding: 14px 10px 6px; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: #e4e4e4; text-decoration: none; font-weight: 500; }
.side nav a:hover { background: rgba(255,255,255,.06); }
.side nav a.on { background: color-mix(in srgb, var(--gold) 16%, transparent); color: var(--gold-bright); }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.dot-warn { margin-inline-start: auto; background: var(--gold); color: var(--brand-on-accent); font-style: normal; font-size: 11px; font-weight: 700; border-radius: 10px; padding: 0 7px; }
.side-foot { padding: 12px 16px 18px; display: flex; flex-direction: column; gap: 6px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12.5px; }
.side-foot .who { color: #aaa; }
.link-btn { background: none; border: 0; padding: 0; color: var(--gold-bright); cursor: pointer; font: inherit; text-align: start; text-decoration: none; }
.main { flex: 1; min-width: 0; }
.topbar { display: none; }
.side-scrim { display: none; }
#view:focus { outline: none; }

/* ---------------------------------- pages --------------------------------- */
.page { padding: 26px 30px 60px; max-width: 1320px; }
.page.narrow { max-width: 720px; }
.page.loading { color: var(--muted); }
.page-h { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back { display: inline-block; margin-bottom: 8px; text-decoration: none; font-size: 13px; }
.sec-h { font-size: 13px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); margin: 22px 0 10px; font-weight: 600; }
.sec-h small { letter-spacing: 0; text-transform: none; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0 14px; }
.empty { color: var(--muted); padding: 22px; text-align: center; margin: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card.flush .card-h { padding: 14px 16px 0; }
details.card summary { cursor: pointer; font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-doc { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }

/* ---------------------------------- buttons -------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--charcoal); font: 600 13.5px var(--font);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--gold); }
.btn.primary { background: var(--charcoal); border-color: var(--charcoal); color: #fff; }
.btn.primary:hover { background: var(--brand-primary-deep); box-shadow: inset 0 -3px 0 var(--gold); }
.btn.danger, .btn.ghost.danger { color: var(--red); }
.btn.danger:not(.ghost) { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 15px; line-height: 1; color: var(--charcoal); }
.icon-btn.danger { color: var(--red); }
.icon-btn:disabled { opacity: .35; }
.file-btn { position: relative; }

/* ---------------------------------- forms ---------------------------------- */
label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--charcoal-soft); }
input, select, textarea {
  font: 14px var(--font); color: var(--text); background: #fff; border: 1px solid var(--line-input); border-radius: 8px; padding: 8px 10px; width: 100%;
  min-height: 38px;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--gold) 45%, transparent); outline-offset: 0; border-color: var(--gold); }
input[readonly] { background: var(--readonly); }
input.bad { border-color: var(--red); background: #fff6f5; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-bottom: 4px; }
.fgrid + .fgrid { margin-top: 14px; }
.span2 { grid-column: span 2; }
.combo { display: flex; gap: 6px; }
.combo select { width: auto; flex: none; }
.combo input { flex: 1; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
label.check input, .seg input, .switch input { width: auto; min-height: 0; }
.seg { display: flex; gap: 14px; flex-wrap: wrap; padding: 6px 0; }
.seg label { flex-direction: row; align-items: center; gap: 6px; font-weight: 500; color: var(--text); }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0; }
legend { font-size: 12.5px; font-weight: 600; color: var(--charcoal-soft); padding: 0 4px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 22px; }
.form-foot { display: flex; justify-content: flex-end; margin-top: 10px; }
.unset-field input, .unset-field textarea { background: #fff8de; border-color: #e6c75a; }
.tag-warn { font-style: normal; background: #fff1bf; color: #8a5a00; border-radius: 4px; padding: 1px 6px; font-size: 11px; margin-inline-start: 6px; }

/* ---------------------------------- alerts --------------------------------- */
.alert { border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; font-size: 13.5px; border: 1px solid; }
.alert.err { background: #fdf0ee; border-color: #f1c7c0; color: #8f2a1e; }
.alert.warn { background: #fff8e1; border-color: #f0d98a; color: #6e4c00; }
.alert.info { background: var(--tint-info); border-color: var(--line); color: var(--charcoal-soft); }
.alert[hidden] { display: none; }

/* --------------------------------- tables ---------------------------------- */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: start; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--tint); white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.tbl tbody tr:hover td { background: var(--tint-hover); }
.tbl tr[data-href], .tbl tr.rowlink { cursor: pointer; }
.tbl tfoot td { background: var(--tint); font-size: 13px; color: var(--muted); border-bottom: 0; }
.tbl a { text-decoration: none; font-weight: 600; }
.num { text-align: end !important; white-space: nowrap; }
.row-act { text-align: end; white-space: nowrap; }
.row-act .btn + .btn { margin-inline-start: 4px; }
tr.voided td { opacity: .5; text-decoration: line-through; }
tr.voided td .badge { text-decoration: none; }
.card .tbl th:first-child, .card .tbl td:first-child { padding-inline-start: 16px; }

.badge { display: inline-block; font-size: 11.5px; font-weight: 600; border-radius: 999px; padding: 2px 10px; white-space: nowrap; vertical-align: middle; }
.b-grey { background: #eceae6; color: #555; } .b-blue { background: #e4eef7; color: var(--blue); }
.b-green { background: #e3f2e8; color: var(--green); } .b-red { background: #fbe6e3; color: var(--red); }
.b-amber { background: #fdf0d5; color: var(--amber); }
.pill { display: inline-block; font-size: 11.5px; background: var(--cream); border-radius: 999px; padding: 2px 9px; margin: 0 4px 4px 0; }
.pill.red { background: #fbe6e3; color: var(--red); font-weight: 600; }

/* ----------------------------- toolbar & chips ----------------------------- */
.toolbar-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar-row input[type=search] { max-width: 320px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 12px; font: 500 12.5px var(--font); cursor: pointer; color: var(--charcoal); }
.chip.on { background: var(--charcoal); color: #fff; border-color: var(--charcoal); }
.status-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.quick { display: flex; gap: 6px; align-items: end; flex-wrap: wrap; }

/* ----------------------------------- KPIs ---------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 8px; }
.kpis.small { margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi span { font-size: 12px; color: var(--muted); font-weight: 600; display: block; }
.kpi b { font-size: 22px; font-weight: 600; display: block; margin-top: 4px; letter-spacing: -.01em; }
.kpis.small .kpi b { font-size: 18px; }
.kpi small { font-size: 12px; }
.kpi.accent { border-top: 3px solid var(--gold); }
.kpi.accent b { color: var(--gold-deep); }
.kpis.k5 { grid-template-columns: repeat(5, 1fr); }
.kpi.ret { border-top: 3px solid var(--blue); }
.kpi small a { text-decoration: none; font-weight: 600; }

/* ------------------------------ key/value list ----------------------------- */
dl.kv { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; }
dl.kv div { min-width: 0; }
dl.kv dt { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
dl.kv dd { margin: 2px 0 0; white-space: pre-line; overflow-wrap: anywhere; }
pre.terms { white-space: pre-wrap; font: 13px/1.55 var(--font); margin: 10px 0 0; }

/* ------------------------------- line editor ------------------------------- */
.lines { display: flex; flex-direction: column; gap: 10px; }
.line {
  display: grid; grid-template-columns: 28px minmax(260px, 1fr) 90px 80px 110px 130px 110px 100px; gap: 8px; align-items: start;
  padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper);
}
.line label { gap: 3px; font-size: 11px; }
.line label span, .ln-total span { text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-size: 10.5px; }
.ln-no { padding-top: 10px; color: var(--muted); font-weight: 600; text-align: center; }
.ln-desc { display: flex; flex-direction: column; gap: 6px; }
.ln-desc textarea { min-height: 38px; }
.ln-total { display: flex; flex-direction: column; gap: 3px; align-items: flex-end; }
.ln-total b { padding-top: 8px; font-size: 14px; }
.ln-act { display: flex; gap: 4px; padding-top: 18px; justify-content: flex-end; }
.line-add { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.line-add select { max-width: 520px; flex: 1; }

.totals-panel { position: sticky; top: 16px; }
.totals-panel.static { position: static; }
.trow { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.trow b { font-weight: 600; }
.trow.sub { font-weight: 600; }
.trow.grand { border: 0; margin-top: 6px; padding: 10px 12px; background: var(--charcoal); color: #fff; border-radius: 8px; font-size: 16px; }
.trow.grand b { color: var(--gold-bright); }
.totals-panel small { display: block; margin-top: 8px; }

/* --------------------------------- catalogue ------------------------------- */
.rate-in { width: 110px; text-align: end; min-height: 32px; padding: 5px 8px; }
.rate-in.zero { background: #fff8de; border-color: #e6c75a; }

/* ---------------------------------- website -------------------------------- */
.proj-list { display: flex; flex-direction: column; gap: 12px; }
.proj { display: grid; grid-template-columns: 150px 1fr auto; gap: 16px; padding: 12px; margin: 0; align-items: center; }
.proj-img { display: block; width: 150px; height: 100px; border-radius: 8px; overflow: hidden; background: var(--cream); display: grid; place-items: center; color: var(--muted); font-size: 12px; text-decoration: none; }
.proj-img img { width: 100%; height: 100%; object-fit: cover; }
.proj-body h3 a { color: var(--charcoal); text-decoration: none; }
.proj-body p { margin: 4px 0 0; font-size: 13px; }
.proj-act { display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.switch { flex-direction: row; align-items: center; gap: 6px; cursor: pointer; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.photo { margin: 0; border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: var(--paper); position: relative; display: flex; flex-direction: column; gap: 6px; }
.photo.is-cover { border-color: var(--gold); box-shadow: 0 0 0 2px color-mix(in srgb, var(--gold) 30%, transparent); }
.photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; background: var(--cream); }
.photo input { min-height: 32px; padding: 5px 8px; font-size: 12.5px; }
.cover-tag { position: absolute; top: 14px; inset-inline-start: 14px; background: var(--gold); color: var(--brand-on-accent); font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 4px; }
.ph-act { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.ph-act [data-phdel] { margin-inline-start: auto; }
.logo-row { display: flex; gap: 18px; align-items: center; }
.logo-row img { width: 90px; height: 90px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: #fff; }

/* ---------------------------------- login ---------------------------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 500px at 80% -10%, color-mix(in srgb, var(--gold-bright) 18%, transparent), transparent), var(--charcoal); }
.login-card { width: min(380px, 100%); background: var(--paper); border-radius: 14px; padding: 30px 28px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.35); border-top: 4px solid var(--gold); }
.login-logo { width: 74px; align-self: center; }
.login-brand { text-align: center; display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.login-brand b { font-size: 22px; letter-spacing: .06em; background: linear-gradient(120deg, var(--gold-bright), var(--gold) 45%, var(--gold-deep)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-brand span { font-size: 10px; letter-spacing: .3em; color: var(--charcoal); }
.login-brand .ar-ruqaa { font-family: var(--font-ar-display), serif; font-size: 20px; letter-spacing: 0; margin-top: 4px; }
.login-card .link-btn { align-self: center; color: var(--gold-deep); }

/* --------------------------------- modals ---------------------------------- */
.modal-wrap { position: fixed; inset: 0; background: rgba(30,30,30,.45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: #fff; border-radius: 12px; width: min(520px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { width: min(760px, 100%); }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-b { padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding-top: 6px; }
.confirm-msg { margin: 0; font-size: 14.5px; }
.cheque[hidden] { display: none; }

#toasts { position: fixed; bottom: 18px; inset-inline-end: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--charcoal); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.25); border-inline-start: 4px solid var(--gold); max-width: 380px; transition: opacity .5s, transform .5s; }
.toast.t-err { border-inline-start-color: #ff7b6b; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---------------------------------- RTL ------------------------------------ */
[dir="rtl"] body, [dir="rtl"] input, [dir="rtl"] select, [dir="rtl"] textarea, [dir="rtl"] .btn { font-family: var(--font-ar), var(--font-body), sans-serif; }
[dir="rtl"] .tbl th { letter-spacing: 0; }

/* -------------------------------- responsive ------------------------------- */
@media (max-width: 1100px) {
  .line { grid-template-columns: 28px 1fr 1fr 1fr; }
  .ln-desc { grid-column: 2 / -1; }
  .ln-total { grid-column: 2 / 4; align-items: flex-start; }
  .ln-act { padding-top: 6px; }
  .grid-doc { grid-template-columns: 1fr; }
  .totals-panel { position: static; }
}
@media (max-width: 860px) {
  html, body { overflow-x: clip; }
  .side { position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 60; transform: translateX(-105%); visibility: hidden; transition: transform .2s, visibility 0s .2s; }
  [dir="rtl"] .side { transform: translateX(105%); }
  body.nav-open .side { transform: none; visibility: visible; transition: transform .2s; }
  body.nav-open .side-scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 55; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--charcoal); color: #fff; position: sticky; top: 0; z-index: 50; border-bottom: 3px solid var(--gold); }
  .topbar .icon-btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.25); }
  .tb-logo { width: 28px; }
  .page { padding: 16px 16px 50px; }
  .kpis, .kpis.k5 { grid-template-columns: 1fr 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  dl.kv { grid-template-columns: 1fr; }
  .proj { grid-template-columns: 96px 1fr; }
  .proj-img { width: 96px; height: 72px; }
  .proj-act { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: center; }
  .toolbar-row input[type=search] { max-width: none; }
  .tbl th, .tbl td { padding: 8px; }
  .page-h .actions { width: 100%; }
}
@media (max-width: 520px) {
  .line { grid-template-columns: 1fr 1fr; }
  .ln-no { display: none; }
  .ln-desc, .ln-total { grid-column: 1 / -1; }
  .kpi b { font-size: 18px; }
}
.tbl td:first-child a, .tbl td.nowrap { white-space: nowrap; }
.combo select[name=client_id] { flex: 1; width: 100%; min-width: 0; }
/* keep Latin dates / numbers / codes readable inside RTL layout */
[dir="rtl"] dd, [dir="rtl"] .tbl td, [dir="rtl"] .kpi b { unicode-bidi: plaintext; }
[dir="rtl"] .back { display: inline-block; }

/* ------------------------- sharing, periods, terms -------------------------- */
.share-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: -6px 0 14px; font-size: 13px; }
.share-bar { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.btn.wa { border-color: #25D366; color: #128C4B; }
.btn.wa:hover { background: #e9faf0; }
.btn.disabled, a.btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.share-acts { margin: 8px 0 4px; }
.share-msg pre { margin-top: 6px; }
.tbl.compact td, .tbl.compact th { padding: 6px 8px; font-size: 12.5px; }
.period-chips { margin-bottom: 12px; }
.period-chips .chip.vat { border-color: var(--gold); }
.period-card { padding-bottom: 4px; }
.period-card .kpis { grid-template-columns: repeat(5, 1fr); margin-bottom: 8px; }
.field-msg { display: block; font-size: 12px; min-height: 1em; margin-top: 3px; }
.ok-text { color: #17643a; }
.err-text { color: #a12a1a; }
.warn-text { color: #8a5a00; }
.preview-snippet { max-height: 240px; overflow: auto; margin-top: 10px; }
.terms-card textarea { font-size: 13px; line-height: 1.5; }
@media (max-width: 860px) { .period-card .kpis { grid-template-columns: repeat(2, 1fr); } }
.terms-card .card-h { flex-wrap: wrap; gap: 10px; }
.terms-card .card-h .actions { flex-wrap: wrap; }
.terms-card .card-h select { width: auto; min-width: 220px; }

/* ---------- Mobile filters: chips → dropdown (js/mobile-filters.js) ---------- */
.chips-select { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (max-width: 720px) {
  .chips[data-mobile-select] { display: none; }
  .chips-select { display: block; position: relative; width: 100%; margin: 4px 0 10px; }
  .chips-select select {
    width: 100%; appearance: none; -webkit-appearance: none;
    font: 500 15px var(--font); color: var(--charcoal);
    background: #fff; border: 1px solid var(--line); border-radius: 10px;
    padding: 11px 40px 11px 14px; min-height: 44px;
  }
  .chips-select::after {
    content: ""; position: absolute; inset-inline-end: 16px; top: 50%; width: 8px; height: 8px;
    border-right: 2px solid var(--charcoal); border-bottom: 2px solid var(--charcoal);
    transform: translateY(-70%) rotate(45deg); pointer-events: none;
  }
  .chips-select select:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold); }
}

/* ---------- Mobile: labelled dropdowns, compact KPI lists, table rows as cards ---------- */
@media (max-width: 720px) {
  .chips-select__label { display: block; font: 600 11px var(--font); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 2px 5px; }
  .chips-select::after { top: auto; bottom: 18px; transform: rotate(45deg); }

  .period-card .kpis, .kpis, .kpis.k5 { grid-template-columns: 1fr; gap: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
  .period-card .kpis { border: 0; box-shadow: none; }
  .kpi { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; border: 0; border-radius: 0; box-shadow: none; padding: 11px 14px; border-bottom: 1px solid var(--line); }
  .kpi:last-child { border-bottom: 0; }
  .kpi b, .kpis.small .kpi b { font-size: 16px; margin: 0; text-align: end; }
  .kpi small { display: none; }

  .tbl-wrap { overflow: visible; border: 0; background: none; box-shadow: none; }
  table.tbl-cards, table.tbl-cards tbody { display: block; width: 100%; }
  table.tbl-cards thead { display: none; }
  table.tbl-cards tr { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
  table.tbl-cards td { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 5px 0; border: 0; text-align: end; min-height: 0; }
  table.tbl-cards td:first-child { font-weight: 600; font-size: 15px; text-align: start; justify-content: flex-start; padding-bottom: 7px; border-bottom: 1px dashed var(--line); margin-bottom: 4px; }
  table.tbl-cards td[data-label]::before { content: attr(data-label); flex: none; font: 600 11px var(--font); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); text-align: start; }
  table.tbl-cards td:first-child[data-label]::before { content: none; }
  table.tbl-cards td:empty { display: none; }
  table.tbl-cards tfoot { display: block; }
  table.tbl-cards tfoot tr { display: flex; justify-content: space-between; flex-wrap: wrap; }
}

/* ------------------------------- Reports hub ------------------------------- */
.report-picker { margin: -4px 0 16px; }
.report-picker .chip { padding: 7px 14px; font-size: 13px; }
.reports .filters { padding-bottom: 12px; }
.reports .filters .fgrid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.rep-actions { margin-top: 12px; justify-content: flex-end; }
.tbl.rpt th { white-space: normal; vertical-align: bottom; line-height: 1.3; }
.tbl.rpt th.num { min-width: 64px; }
.tbl.rpt th, .tbl.rpt td { padding-inline: 9px; }
.tbl.rpt td:first-child a { white-space: normal; }
.tbl.rpt td:first-child { min-width: 150px; }
.grid2 > * { min-width: 0; }
@media (max-width: 1500px) { .grid2.wide-only { grid-template-columns: 1fr; } }
.tbl.rpt tr.tot td { background: var(--tint); font-weight: 600; border-top: 2px solid var(--line); }
.tbl.rpt tr.open td { background: var(--tint-open); }
.tbl.rpt td.ret { color: var(--blue); }
.tbl.ageing td.red-text, .red-text { color: var(--red); font-weight: 600; }
.neg { color: var(--red); }
.kpi.warn { border-top: 3px solid var(--red); }
.kpi.warn b { color: var(--red); }
.hint.pad { padding: 0 16px 14px; margin: 10px 0 0; }
ul.plain { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.share { display: inline-block; width: 54px; height: 6px; background: var(--track); border-radius: 3px; margin-inline-end: 8px; vertical-align: middle; overflow: hidden; }
.share i { display: block; height: 100%; background: var(--gold); }
.reports .card.flush .card-h { flex-wrap: wrap; }
.reports .kpis { margin-bottom: 16px; }
@media (max-width: 720px) {
  .rep-actions { justify-content: stretch; }
  .rep-actions .btn { flex: 1; }
  table.tbl-cards tr.tot { border-color: var(--gold); background: var(--tint-accent); }
  .tbl.rpt.tbl-cards tr.tot td { background: none; border-top: 0; }
  .tbl.rpt.tbl-cards td:first-child { flex-wrap: wrap; row-gap: 2px; }
  .tbl.rpt.tbl-cards td:first-child small.block { flex-basis: 100%; }
  table.tbl-cards.strip td:first-child { font-weight: 400; font-size: inherit; justify-content: space-between; text-align: end; border-bottom: 0; padding-bottom: 5px; margin-bottom: 0; }
  table.tbl-cards.strip td:first-child[data-label]::before { content: attr(data-label); }
  .tbl.rpt.tbl-cards td > div { min-width: 0; }
  table.tbl-cards tr.open td { background: none; }
  .share { width: 40px; }
  .hint.pad { padding: 0 2px 6px; }
  .reports .card.flush { background: none; border: 0; box-shadow: none; overflow: visible; }
  .reports .card.flush .card-h { padding: 4px 2px 10px; }
}

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.receipt-done p { margin: 0 0 8px; }
.rev-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: -6px 0 14px; font-size: 13px; }
.rev-row .chip { text-decoration: none; }
a.btn.busy, .fbtn.busy { opacity: .65; pointer-events: none; }
.ai-steps { margin: 0 0 6px; padding-inline-start: 20px; display: grid; gap: 14px; font-size: 14px; }
.ai-steps textarea { width: 100%; }
.ai-preview .card { margin: 0; max-height: 52vh; overflow: auto; }
.ai-preview .sm-h { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 4px; }
.modal-b > .alert.warn { margin-top: 10px; }
