/* Modern Response ERP — UI stylesheet (RTL/LTR via logical properties, light/dark themes) */
:root {
  --primary: #0e7c86; --accent: #e3a21a; --fs: 14px;
  --bg: #f2f5f6; --surface: #ffffff; --surface-2: #f7f9fa; --line: #e1e7ea; --line-2: #eef2f4;
  --text: #17232a; --muted: #5f6f78; --faint: #8b989f;
  --side: #0f2a2e; --side-text: #c9d8da; --side-dim: #7f9a9e; --side-hover: #163a3f;
  --ok: #1f8a5b; --ok-bg: #e6f4ec; --warn: #b7791f; --warn-bg: #fdf3e1; --bad: #c0392b; --bad-bg: #fbeaea; --info: #2563a8; --info-bg: #e8f0fa;
  --r-card: 10px; --r-in: 7px; --shadow: 0 1px 2px rgba(15, 42, 46, .06), 0 2px 8px rgba(15, 42, 46, .04);
  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0e1719; --surface: #152124; --surface-2: #1a282b; --line: #26383c; --line-2: #1f2f33;
  --text: #e3ecee; --muted: #9fb1b6; --faint: #74888d;
  --side: #0a1214; --side-text: #c4d3d6; --side-dim: #6d8488; --side-hover: #13232600;
  --ok-bg: #12301f; --warn-bg: #33270f; --bad-bg: #3a1714; --info-bg: #13253b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { font-size: var(--fs); -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.55; font-feature-settings: "tnum" 1; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; font-weight: 600; }
h1 { font-size: 1.55rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
h3 { font-size: 1.02rem; display: flex; align-items: center; gap: .45rem; }
small, .small { font-size: .86em; }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: .92em; direction: ltr; unicode-bidi: embed; }
.center { text-align: center; } .num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.text-bad { color: var(--bad); } .yes { color: var(--ok); font-weight: 700; } .no { color: var(--faint); }
.ic { width: 1.15em; height: 1.15em; flex: none; vertical-align: -.2em; }
.sr, .skip { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip:focus { position: fixed; inset-inline-start: 1rem; top: 1rem; width: auto; height: auto; clip: auto; z-index: 100; background: var(--surface); padding: .5rem 1rem; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- shell */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 268px; flex: none; background: var(--side); color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 30; }
.brand { display: flex; align-items: center; gap: .7rem; padding: 1.1rem 1.1rem .9rem; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-logo { width: 38px; height: 38px; border-radius: 9px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 1rem; }
.brand-text small { color: var(--side-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-search { padding: 0 .9rem .6rem; }
.side-search input { width: 100%; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .08); color: #fff; border-radius: var(--r-in); padding: .45rem .7rem; font: inherit; }
.side-search input::placeholder { color: var(--side-dim); }
.nav { flex: 1; overflow-y: auto; padding: .2rem .55rem 1rem; scrollbar-width: thin; }
.nav-group summary { list-style: none; display: flex; align-items: center; gap: .65rem; padding: .55rem .6rem; border-radius: 8px; cursor: pointer; color: var(--side-text); font-weight: 500; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary:hover { background: rgba(255, 255, 255, .05); }
.nav-group summary .caret { margin-inline-start: auto; opacity: .5; transition: transform .2s; }
.nav-group[open] > summary .caret { transform: rotate(180deg); }
.nav-group[open] > summary { color: #fff; }
.nav-group ul { list-style: none; margin: 0 0 .4rem; padding: 0; padding-inline-start: 1.85rem; border-inline-start: 1px solid rgba(255, 255, 255, .07); margin-inline-start: 1.15rem; }
.nav-group li a { display: flex; align-items: center; justify-content: space-between; padding: .36rem .65rem; color: var(--side-dim); border-radius: 6px; font-size: .95em; }
.nav-group li a:hover { color: #fff; background: rgba(255, 255, 255, .05); text-decoration: none; }
.nav-group li a.active { color: #fff; background: color-mix(in srgb, var(--primary) 45%, transparent); }
.nav-h { color: var(--side-dim); font-size: .78em; padding: .5rem .65rem .15rem; opacity: .8; }
.pill { background: var(--accent); color: #2a1d00; border-radius: 999px; padding: 0 .45rem; font-size: .8em; font-weight: 700; }
.side-foot { padding: .7rem 1.1rem; color: var(--side-dim); font-size: .8em; border-top: 1px solid rgba(255, 255, 255, .06); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .75rem; padding: .55rem 1.25rem; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
#menuToggle { display: none; }
.gsearch { flex: 1; max-width: 520px; display: flex; align-items: center; gap: .5rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 0 .9rem; color: var(--muted); }
.gsearch input { border: 0; background: transparent; padding: .5rem 0; flex: 1; font: inherit; color: var(--text); outline: none; }
.top-actions { display: flex; align-items: center; gap: .35rem; margin-inline-start: auto; }
.ctx { display: flex; gap: .35rem; }
.ctx select { padding: .35rem .5rem; font-size: .9em; max-width: 190px; }
.icon-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 9px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn.on { color: var(--accent); }
.icon-btn.danger:hover { color: var(--bad); background: var(--bad-bg); }
.icon-btn.ok:hover { color: var(--ok); background: var(--ok-bg); }
.icon-btn.warn:hover { color: var(--warn); background: var(--warn-bg); }
.lang-tag { font-weight: 700; font-size: .85rem; }
.dot { position: absolute; top: 2px; inset-inline-end: 0; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.usermenu, .menu-btn { position: relative; }
.usermenu summary, .menu-btn summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .45rem; }
.usermenu summary::-webkit-details-marker, .menu-btn summary::-webkit-details-marker { display: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; }
.uname { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); min-width: 210px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: 0 10px 30px rgba(15, 42, 46, .14); padding: .35rem; z-index: 40; display: flex; flex-direction: column; gap: .3rem; }
.dropdown a, .dropdown button { display: flex; align-items: center; gap: .55rem; padding: .5rem .7rem; border-radius: 7px; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-align: start; width: 100%; }
.dropdown a:hover, .dropdown button:hover { background: var(--surface-2); text-decoration: none; }
.dropdown.pad { padding: .7rem; }
.content { padding: 1.25rem 1.5rem 3rem; max-width: 1560px; width: 100%; outline: none; }
.backdrop { display: none; }

/* ---------------------------------------------------------------- page head */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.crumbs { display: flex; gap: .4rem; font-size: .85em; color: var(--muted); margin-bottom: .25rem; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.head-actions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.count { font-size: .62em; font-weight: 600; background: var(--line-2); color: var(--muted); padding: .1rem .55rem; border-radius: 999px; }
.inline { display: inline; }
.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* ---------------------------------------------------------------- buttons */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .48rem .9rem; border-radius: var(--r-in); border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; line-height: 1.3; }
.btn:hover { border-color: var(--faint); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--primary) 86%, #000); border-color: transparent; }
.btn-success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 40%, transparent); color: var(--warn); }
.btn-danger { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 30%, transparent); color: var(--bad); }
.btn-danger:hover { background: var(--bad); color: #fff; }
.btn-sm { padding: .3rem .65rem; font-size: .9em; }
.btn-block { width: 100%; justify-content: center; padding: .7rem; }
.link-btn { background: none; border: 0; color: var(--primary); cursor: pointer; font: inherit; padding: 0; display: inline-flex; gap: .3rem; align-items: center; }

/* ---------------------------------------------------------------- cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow); margin-bottom: 1rem; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .8rem 1.1rem; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.card-b, .pad { padding: 1rem 1.1rem; }
.form-card .grid { padding: 1.1rem; }
.narrow { max-width: 560px; }
.table-card { overflow: hidden; }
.empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }
.empty .ic { width: 2.2em; height: 2.2em; opacity: .4; display: block; margin: 0 auto .5rem; }
.empty.sm { padding: 1.2rem; }
.empty .btn { margin-top: .8rem; }

/* ---------------------------------------------------------------- forms */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: .9rem 1rem; }
.col-1 { grid-column: span 1 } .col-2 { grid-column: span 2 } .col-3 { grid-column: span 3 } .col-4 { grid-column: span 4 } .col-5 { grid-column: span 5 } .col-6 { grid-column: span 6 }
.col-7 { grid-column: span 7 } .col-8 { grid-column: span 8 } .col-9 { grid-column: span 9 } .col-10 { grid-column: span 10 } .col-11 { grid-column: span 11 } .col-12 { grid-column: span 12 }
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; position: relative; }
.lbl { font-size: .9em; color: var(--muted); font-weight: 500; }
.req { color: var(--bad); }
.lang-badge { font-size: .72em; background: var(--line-2); padding: 0 .35rem; border-radius: 4px; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-in); padding: .5rem .65rem; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--primary); }
input[type="color"] { padding: .15rem; height: 38px; }
input.num { text-align: end; }
textarea { resize: vertical; }
.input-sm { padding: .3rem .5rem; font-size: .92em; width: auto; }
.help { color: var(--faint); font-size: .82em; }
.err { color: var(--bad); font-size: .84em; }
.has-err input, .has-err select, .has-err textarea { border-color: var(--bad); }
.ro { padding: .5rem .65rem; background: var(--surface-2); border-radius: var(--r-in); min-height: 38px; border: 1px dashed var(--line); }
.quick-add { position: absolute; inset-inline-end: 0; top: 0; font-weight: 700; font-size: 1.1em; padding: 0 .3rem; }
.file-cur { display: flex; gap: .8rem; align-items: center; font-size: .9em; }
.thumb { max-height: 64px; max-width: 120px; border-radius: 6px; border: 1px solid var(--line); }
.chk { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; }
.multi { display: flex; flex-wrap: wrap; gap: .35rem .9rem; padding: .55rem .65rem; border: 1px solid var(--line); border-radius: var(--r-in); max-height: 180px; overflow: auto; }
.multi-cols { max-height: 260px; }
.field-bool { justify-content: flex-end; }
.switch { display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; position: relative; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.slider { width: 38px; height: 22px; border-radius: 999px; background: var(--line); position: relative; flex: none; transition: background .15s; }
.slider::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::after { transform: translateX(16px); }
[dir="rtl"] .switch input:checked + .slider::after { transform: translateX(-16px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--primary); outline-offset: 2px; }
.form-actions { display: flex; justify-content: flex-end; gap: .5rem; padding: .9rem 1.1rem; border-top: 1px solid var(--line-2); flex-wrap: wrap; }
.form-actions.sticky { position: sticky; bottom: 0; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(6px); border: 1px solid var(--line); border-radius: var(--r-card); z-index: 5; }
.range { display: flex; gap: .3rem; }
.pw-wrap { position: relative; display: block; }
.pw-eye { position: absolute; inset-inline-end: .4rem; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); cursor: pointer; }
.err-list { margin: .3rem 0 0; padding-inline-start: 1.2rem; }

/* searchable select */
.ss { position: relative; }
.ss-btn { display: flex; align-items: center; justify-content: space-between; gap: .4rem; text-align: start; cursor: pointer; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-in); padding: .5rem .65rem; font: inherit; color: var(--text); min-height: 38px; }
.ss-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ss-btn .ph { color: var(--faint); }
.ss-pop { position: absolute; z-index: 50; top: calc(100% + 4px); inset-inline-start: 0; min-width: 100%; width: max-content; max-width: min(460px, 92vw); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: 0 12px 30px rgba(15, 42, 46, .16); padding: .4rem; }
.ss-pop input { margin-bottom: .35rem; }
.ss-list { max-height: 260px; overflow: auto; }
.ss-opt { padding: .4rem .55rem; border-radius: 6px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ss-opt:hover, .ss-opt.hl { background: var(--surface-2); }
.ss-opt.sel { color: var(--primary); font-weight: 600; }

/* ---------------------------------------------------------------- filters */
.filters { padding: .8rem 1rem; }
.filters-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.search-box { flex: 1 1 260px; display: flex; align-items: center; gap: .4rem; border: 1px solid var(--line); border-radius: var(--r-in); padding: 0 .6rem; color: var(--muted); background: var(--surface); }
.search-box input { border: 0; padding: .5rem 0; box-shadow: none !important; }
.flt { display: flex; flex-direction: column; gap: .2rem; font-size: .9em; color: var(--muted); min-width: 150px; }
.flt select, .flt input { padding: .42rem .55rem; }
.flt-actions { display: flex; gap: .4rem; }
.saved-row { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .55rem; }
.saved-row:empty { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .65rem; border-radius: 999px; background: var(--line-2); color: var(--text); font-size: .88em; }
.chip a { color: inherit; display: inline-flex; gap: .3rem; align-items: center; }
.chip-sm { font-size: .78em; padding: .1rem .5rem; }
.chip-x { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 1.1em; padding: 0; }
.chip-bad { background: var(--bad-bg); color: var(--bad); }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .6rem .8rem; text-align: start; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table thead th { font-size: .84em; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
.table th.num, .table td.num { text-align: end; }
.table tbody tr:last-child td { border-bottom: 0; }
.table-hover tbody tr[data-href] { cursor: pointer; }
.table-hover tbody tr:hover td { background: color-mix(in srgb, var(--primary) 5%, var(--surface)); }
.sort { color: inherit; } .sort.on { color: var(--primary); }
.sort.on.asc::after { content: " ▲"; font-size: .7em; } .sort.on.desc::after { content: " ▼"; font-size: .7em; }
.actions-col { width: 1%; white-space: nowrap; text-align: end; }
.row-link { color: var(--text); font-weight: 500; }
.ln { width: 36px; text-align: center; color: var(--faint); }
.pager { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .7rem 1rem; border-top: 1px solid var(--line-2); flex-wrap: wrap; }
.pager > div { display: flex; gap: .25rem; flex-wrap: wrap; }
tr.row-head td { background: var(--surface-2); font-weight: 600; }
tr.row-sub td { font-weight: 600; background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
tr.row-total td, .row-total td { font-weight: 700; border-top: 2px solid var(--line); background: var(--surface-2); }
tr.row-bad td { background: var(--bad-bg); }
.lines-total td { font-weight: 600; background: var(--surface-2); }
.matrix td, .matrix th { padding: .35rem .6rem; font-size: .9em; }
.compare td.best { background: var(--ok-bg); color: var(--ok); font-weight: 600; }

/* lines editor */
.lines-card .table td { padding: .3rem .35rem; }
.lines input, .lines select { padding: .38rem .45rem; }
.lines input[readonly] { background: var(--surface-2); border-style: dashed; }
.lines-foot { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem 1rem; border-top: 1px solid var(--line-2); flex-wrap: wrap; }
.calc-summary { display: flex; gap: 1.25rem; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.calc-summary div { display: flex; flex-direction: column; align-items: flex-end; }
.calc-summary span { color: var(--muted); font-size: .82em; }
.calc-summary strong { font-size: 1.05rem; }
.calc-summary .grand strong { color: var(--primary); font-size: 1.25rem; }
.calc-summary .bad strong { color: var(--bad); }

/* ---------------------------------------------------------------- badges & alerts */
.badge { display: inline-flex; align-items: center; padding: .12rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge-gray { background: var(--line-2); color: var(--muted); }
.badge-green { background: var(--ok-bg); color: var(--ok); }
.badge-blue { background: var(--info-bg); color: var(--info); }
.badge-amber { background: var(--warn-bg); color: var(--warn); }
.badge-orange { background: var(--warn-bg); color: #c2570c; }
.badge-red { background: var(--bad-bg); color: var(--bad); }
h1 .badge { font-size: .55em; }
.alert { display: flex; align-items: flex-start; gap: .6rem; padding: .75rem 1rem; border-radius: var(--r-card); margin-bottom: 1rem; border: 1px solid transparent; }
.alert > .ic { margin-top: .15rem; }
.alert-success { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 20%, transparent); }
.alert-error { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 20%, transparent); }
.alert-warning { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.alert-info { background: var(--info-bg); color: var(--info); border-color: color-mix(in srgb, var(--info) 20%, transparent); }
.alert-x { margin-inline-start: auto; background: none; border: 0; color: inherit; font-size: 1.2rem; cursor: pointer; line-height: 1; opacity: .6; }
.amount-words { padding: .55rem 1rem; background: var(--surface); border: 1px solid var(--line); border-inline-start: 3px solid var(--accent); border-radius: var(--r-in); margin-bottom: 1rem; color: var(--muted); }
.masked { letter-spacing: .1em; color: var(--faint); }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: middle; border: 1px solid var(--line); }

/* ---------------------------------------------------------------- detail page */
.show-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
.dl { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 0; margin: 0; }
.dl-i { padding: .7rem 1.1rem; border-bottom: 1px solid var(--line-2); min-width: 0; }
.dl-i dt { font-size: .84em; color: var(--muted); margin-bottom: .15rem; }
.dl-i dd { margin: 0; word-break: break-word; }
.dl-i dd.num { text-align: start; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: .8rem 1rem; border-inline-start: 3px solid var(--primary); }
.kpi-l { color: var(--muted); font-size: .85em; }
.kpi-v { font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi-bad { border-inline-start-color: var(--bad); } .kpi-bad .kpi-v { color: var(--bad); }
.meter { height: 6px; border-radius: 4px; background: var(--line-2); margin-top: .4rem; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.decide-card { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); border-inline-start: 4px solid var(--accent); }
.decide-form { display: flex; flex-direction: column; gap: .6rem; }
.decide-btns { display: flex; gap: .5rem; flex-wrap: wrap; }
.timeline { list-style: none; margin: 0; padding: .8rem 1.1rem; }
.timeline li { display: flex; gap: .7rem; padding-bottom: .9rem; position: relative; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: 5px; top: 14px; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.tl-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--faint); margin-top: 5px; flex: none; z-index: 1; }
.tl-approved .tl-dot { background: var(--ok); } .tl-rejected .tl-dot { background: var(--bad); } .tl-returned .tl-dot { background: var(--warn); }
.tl-submitted .tl-dot { background: var(--info); } .tl-escalated .tl-dot { background: #c2570c; }
.tl-waiting .tl-dot { background: var(--surface); border: 2px dashed var(--accent); }
.tl-c { background: var(--surface-2); padding: .4rem .6rem; border-radius: 7px; margin-top: .3rem; font-size: .92em; }
.files { list-style: none; margin: 0; padding: .4rem 1.1rem; }
.files li { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem .6rem; padding: .45rem 0; border-bottom: 1px solid var(--line-2); }
.files li a { display: inline-flex; gap: .35rem; align-items: center; word-break: break-all; }
.files li small { flex-basis: 100%; }
.upload-form { display: flex; gap: .4rem; padding: .7rem 1.1rem 1rem; flex-wrap: wrap; }
.upload-form input { flex: 1; min-width: 0; font-size: .85em; }
.history { list-style: none; margin: 0; padding: .4rem 1.1rem .9rem; max-height: 520px; overflow: auto; }
.history > li { padding: .5rem 0; border-bottom: 1px solid var(--line-2); }
.diff { list-style: none; padding: 0; margin: .3rem 0 0; font-size: .85em; }
.diff span { color: var(--muted); } .diff del { color: var(--bad); } .diff ins { color: var(--ok); text-decoration: none; }
.zatca-box { display: flex; gap: 1rem; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: .8rem 1rem; margin-bottom: 1rem; }
.zatca-box .qr svg, .qr svg { width: 120px; height: 120px; background: #fff; padding: 4px; border-radius: 6px; }

/* ---------------------------------------------------------------- dashboard */
.dash-head h1 { font-size: 1.7rem; }
.period-form { display: flex; gap: .5rem; align-items: center; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.seg button { border: 0; background: none; padding: .35rem .8rem; border-radius: 7px; cursor: pointer; font: inherit; color: var(--muted); }
.seg button.on { background: var(--primary); color: #fff; }
.filter-note { display: flex; align-items: center; gap: .35rem; margin: -.4rem 0 1rem; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.kpi-card { position: relative; display: flex; flex-direction: column; gap: .15rem; padding: 1rem 1.1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); color: var(--text); overflow: hidden; }
.kpi-card::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 4px; background: var(--primary); opacity: .75; }
.kpi-card:hover { text-decoration: none; border-color: color-mix(in srgb, var(--primary) 40%, var(--line)); }
.kpi-card.tone-pos::before { background: var(--ok); } .kpi-card.tone-neg::before { background: var(--bad); } .kpi-card.tone-warn::before { background: var(--accent); }
.kpi-card .kpi-ic { position: absolute; inset-inline-end: .9rem; top: .9rem; color: var(--faint); }
.kpi-card .kpi-v { font-size: 1.5rem; font-weight: 600; letter-spacing: -.01em; }
.kpi-card.tone-neg .kpi-v { color: var(--bad); }
.kpi-s { color: var(--muted); font-size: .84em; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1rem; align-items: start; }
.chart { padding: .6rem 1rem 1rem; min-height: 240px; }
.approval-list, .alert-list, .task-list, .notif-list { list-style: none; margin: 0; padding: 0; }
.approval-list li { display: flex; align-items: center; gap: .6rem; padding: .6rem 1.1rem; border-bottom: 1px solid var(--line-2); }
.approval-list li > a { flex: 1; display: flex; flex-direction: column; color: var(--text); }
.quick-decide { display: inline-flex; gap: .15rem; }
.alert-list li a, .alert-list li .al-row { display: flex; gap: .6rem; align-items: flex-start; padding: .6rem 1.1rem; border-bottom: 1px solid var(--line-2); color: var(--text); }
.alert-list li.muted { padding: .8rem 1.1rem; }
.al-error .ic { color: var(--bad); } .al-warning .ic { color: var(--warn); } .al-info .ic { color: var(--info); }
.task-list li { border-bottom: 1px solid var(--line-2); }
.task-list li > a, .task-list li > span { display: flex; justify-content: space-between; gap: .5rem; padding: .55rem 1.1rem; color: var(--text); }
.task-list li.muted { padding: .7rem 1.1rem; }
.shortcut-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; padding: .8rem; }
.shortcut { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .35rem; padding: .75rem .4rem; border-radius: 9px; background: var(--surface-2); color: var(--text); font-size: .86em; line-height: 1.3; }
.shortcut .ic { color: var(--primary); width: 1.4em; height: 1.4em; }
.shortcut:hover { background: color-mix(in srgb, var(--primary) 10%, var(--surface)); text-decoration: none; }
.announce { display: flex; gap: .7rem; padding: .8rem 1rem; border-radius: var(--r-card); background: var(--info-bg); color: var(--info); margin-bottom: 1rem; }
.announce.hi { background: var(--warn-bg); color: var(--warn); }
.punch-card { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .8rem 1.1rem; flex-wrap: wrap; }
.punch-card > div { display: flex; gap: .5rem; align-items: center; }
.sortable { list-style: none; padding: 0; margin: .5rem 0; max-height: 50vh; overflow: auto; }
.sortable li { display: flex; justify-content: space-between; align-items: center; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 7px; margin-bottom: .3rem; background: var(--surface); }
.sortable li.dragging { opacity: .5; }
.drag { cursor: grab; color: var(--faint); }
.notif-list li { display: flex; gap: .8rem; padding: .8rem 1.1rem; border-bottom: 1px solid var(--line-2); }
.notif-list li.unread { background: color-mix(in srgb, var(--primary) 5%, var(--surface)); }
.notif-list li.unread strong::before { content: "● "; color: var(--primary); }
.nt-ic { color: var(--muted); } .nt-warning .nt-ic { color: var(--warn); } .nt-approval .nt-ic { color: var(--accent); } .nt-success .nt-ic { color: var(--ok); }

/* ---------------------------------------------------------------- admin & reports */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tab { padding: .55rem .95rem; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.on { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .75rem; }
.tile { display: flex; flex-direction: column; gap: .4rem; padding: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); color: var(--text); }
.tile .ic { color: var(--primary); width: 1.5em; height: 1.5em; }
.tile:hover { border-color: var(--primary); text-decoration: none; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .6rem; padding: .9rem; }
.report-tile { display: flex; flex-direction: column; gap: .2rem; padding: .8rem .9rem; border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface-2); color: var(--text); }
.report-tile:hover { border-color: var(--primary); text-decoration: none; }
.perm-cells { display: flex; flex-wrap: wrap; gap: .25rem .9rem; }
.perm-chk { font-size: .92em; }
.field-perm { color: var(--warn); }
.perm-table th { width: 260px; font-weight: 500; }
.perm-mod > summary { cursor: pointer; list-style: none; }
.code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: .7rem .9rem; margin: .6rem 1.1rem; overflow-x: auto; font-size: .88em; }
.danger-zone { border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
.steps { padding-inline-start: 1.3rem; } .steps li { margin-bottom: .4rem; }
.cols-list { padding-inline-start: 1rem; max-height: 340px; overflow: auto; }
.mfa-setup { display: flex; gap: 1rem; align-items: center; margin: .6rem 0; flex-wrap: wrap; }
.secret { font-size: 1.05rem; letter-spacing: .08em; direction: ltr; display: inline-block; padding: .3rem .6rem; background: var(--surface-2); border-radius: 6px; }
.otp { font-size: 1.4rem; letter-spacing: .4em; text-align: center; }

/* org chart */
.org-wrap { overflow-x: auto; padding: 1.5rem; }
.org ul { list-style: none; margin: 0; padding: 0; padding-inline-start: 1.6rem; border-inline-start: 2px solid var(--line); }
.org > ul { border: 0; padding: 0; }
.org li { margin: .5rem 0; position: relative; }
.org ul ul li::before { content: ""; position: absolute; inset-inline-start: -1.6rem; top: 1.4rem; width: 1.4rem; border-top: 2px solid var(--line); }
.org-node { display: inline-flex; align-items: center; gap: .9rem; padding: .55rem .9rem; background: var(--surface-2); border: 1px solid var(--line); border-inline-start: 3px solid var(--primary); border-radius: 8px; color: var(--text); }
.org-node:hover { text-decoration: none; border-color: var(--primary); }
.org-count { display: inline-flex; gap: .25rem; align-items: center; color: var(--muted); font-size: .86em; }

/* dialog */
.dialog { border: 0; border-radius: 14px; padding: 0; width: min(460px, 94vw); background: var(--surface); color: var(--text); box-shadow: 0 30px 80px rgba(0, 0, 0, .3); }
.dialog-lg { width: min(640px, 94vw); }
.dialog::backdrop { background: rgba(10, 25, 28, .45); }
.dialog-body { padding: 1.3rem; display: flex; flex-direction: column; gap: .7rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .4rem; }

/* charts (charts.js) */
.ch-svg { width: 100%; height: auto; overflow: visible; }
.ch-axis { stroke: var(--line); } .ch-grid { stroke: var(--line-2); }
.ch-lbl { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.ch-legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .86em; color: var(--muted); margin-top: .4rem; }
.ch-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: .35rem; vertical-align: middle; }
.ch-tip { position: fixed; pointer-events: none; background: var(--text); color: var(--surface); font-size: 12px; padding: .3rem .55rem; border-radius: 6px; z-index: 60; white-space: nowrap; }

/* ---------------------------------------------------------------- auth */
.guest { background: var(--bg); }
.auth-wrap { display: grid; grid-template-columns: 1.05fr 1fr; min-height: 100vh; }
.auth-side { background: var(--side); color: #fff; position: relative; overflow: hidden; display: flex; align-items: center; padding: 3rem; }
.auth-side::after { content: ""; position: absolute; inset: auto -10% -30% auto; width: 520px; height: 520px; border: 60px solid color-mix(in srgb, var(--primary) 35%, transparent); border-radius: 50%; }
[dir="rtl"] .auth-side::after { inset: auto auto -30% -10%; }
.auth-side-in { position: relative; z-index: 1; max-width: 460px; }
.auth-logo { width: 72px; height: 72px; border-radius: 16px; margin-bottom: 1.6rem; }
.auth-side h1 { font-size: 2.1rem; display: block; margin-bottom: .7rem; }
.auth-side p { color: var(--side-text); font-size: 1.08rem; }
.auth-points { list-style: none; padding: 0; margin: 2rem 0 0; display: flex; flex-direction: column; gap: .8rem; color: var(--side-text); }
.auth-points li { display: flex; gap: .7rem; align-items: center; }
.auth-points .ic { color: var(--accent); }
.auth-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 400px; }
.auth-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.4rem; }
.auth-logo-sm { width: 44px; height: 44px; border-radius: 10px; display: none; }
.auth-card h2 { font-size: 1.5rem; margin-bottom: .3rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem; }
.auth-form input { padding: .7rem .8rem; }
.auth-foot { color: var(--faint); font-size: .85em; margin-top: 2rem; }
.mfa-ic .ic { width: 2.6em; height: 2.6em; color: var(--primary); }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1200px) { .dash-grid, .show-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) {
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; transform: translateX(-100%); transition: transform .2s; }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 25; }
  #menuToggle { display: inline-flex; }
  .uname, .ctx { display: none; }
  .content { padding: 1rem; }
  .grid, .dl { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  [class*="col-"] { grid-column: span 6; }
  .grid .col-2, .grid .col-3, .dl .col-2, .dl .col-3 { grid-column: span 3; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-logo-sm { display: block; }
}
@media (max-width: 560px) {
  .grid .col-2, .grid .col-3, .dl .col-2, .dl .col-3 { grid-column: span 6; }
  .gsearch { display: none; }
  .head-actions { width: 100%; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .shortcut-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print { .sidebar, .topbar, .head-actions, .filters, .form-actions, .pager { display: none !important; } .card { box-shadow: none; } }
