/* BAYAN ETMS — Dallah Training Hub
   Hand-written RTL-first CSS (ADR-09). Logical properties only; no left/right for layout. */

:root {
  --dallah-blue: #0066B3; --dallah-blue-700: #004F8A; --dallah-blue-50: #E8F2FA;
  --health-green: #00A651;
  --alkamel-emerald: #00695C; --alkamel-turquoise: #00A896; --alkamel-50: #E6F4F2;
  --cert-gold: #B8941F; --cert-gold-50: #FBF5E2;
  --ink: #0F2233; --ink-2: #33475B; --muted: #5B6B7A; --line: #E3E8EE; --line-2: #D3DBE4;
  --surface: #FFFFFF; --canvas: #F4F6F9; --raised: #FAFBFC;
  --ok: #0B7A45; --ok-50: #E7F5EE; --warn: #9A5B00; --warn-50: #FDF3E3;
  --danger: #B42E24; --danger-50: #FBECEA; --info: #0066B3; --info-50: #E8F2FA;
  --neutral: #4D5D6C; --neutral-50: #EEF1F4;
  --radius: 10px; --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(15, 34, 51, .06), 0 1px 3px rgba(15, 34, 51, .05);
  --font-ar: "Cairo", "IBM Plex Sans Arabic", "Noto Sans Arabic", Tahoma, sans-serif;
  --font-en: "Inter", "Segoe UI", Roboto, Arial, sans-serif;
  --focus: 0 0 0 3px rgba(0, 102, 179, .35);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--canvas); color: var(--ink);
  font-family: var(--font-ar); font-size: 15px; line-height: 1.7;
}
html[lang="en"] body { font-family: var(--font-en); line-height: 1.55; }
a { color: var(--dallah-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; font-weight: 700; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.12rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .6rem; }
small, .small { font-size: .82rem; }
.muted { color: var(--muted); }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; inset-inline-start: 1rem; top: -3rem; background: var(--ink); color: #fff; padding: .4rem .8rem; border-radius: 6px; z-index: 50; }
.skip:focus { top: .5rem; }
svg.i { width: 1.1em; height: 1.1em; vertical-align: -.18em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[dir="rtl"] svg.i.dir { transform: scaleX(-1); }

/* ---------- shell ---------- */
.demo-ribbon { background: #2B3A4A; color: #F3F6F9; font-size: .8rem; text-align: center; padding: .2rem 1rem; }
.demo-ribbon b { color: #FFD873; font-weight: 600; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: 60px; display: flex; align-items: center; gap: 1rem;
  padding-inline: 1.25rem; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .65rem; color: var(--ink); text-decoration: none !important; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, var(--dallah-blue), var(--alkamel-turquoise)); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 1.05rem; }
.brand-name { font-weight: 700; font-size: 1rem; line-height: 1.1; }
.brand-sub { font-size: .72rem; color: var(--muted); line-height: 1.2; font-family: var(--font-en); letter-spacing: .02em; }
.topbar .spacer { flex: 1; }
.top-actions { display: flex; align-items: center; gap: .35rem; }
.icon-btn { position: relative; display: inline-flex; align-items: center; gap: .35rem; padding: .4rem .6rem; border-radius: 8px; color: var(--ink-2); background: transparent; border: 0; font: inherit; cursor: pointer; text-decoration: none !important; }
.icon-btn:hover { background: var(--canvas); }
.badge-count { position: absolute; top: 2px; inset-inline-end: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: .68rem; font-weight: 700; display: grid; place-items: center; font-family: var(--font-en); }
.user-chip { display: flex; align-items: center; gap: .55rem; padding-inline-start: .75rem; border-inline-start: 1px solid var(--line); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--dallah-blue-50); color: var(--dallah-blue-700); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.user-chip .who { line-height: 1.2; }
.user-chip .who b { display: block; font-size: .86rem; }
.user-chip .who span { font-size: .74rem; color: var(--muted); }

.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: calc(100vh - 60px); }
.sidebar { background: var(--surface); border-inline-end: 1px solid var(--line); padding: 1rem .75rem; position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto; }
.nav-group { margin-bottom: 1.1rem; }
.nav-title { font-size: .72rem; font-weight: 700; color: var(--muted); padding: 0 .65rem .3rem; text-transform: none; }
html[lang="en"] .nav-title { text-transform: uppercase; letter-spacing: .05em; }
.nav-link { display: flex; align-items: center; gap: .6rem; padding: .45rem .65rem; border-radius: 8px; color: var(--ink-2); font-size: .92rem; text-decoration: none !important; }
.nav-link:hover { background: var(--canvas); color: var(--ink); }
.nav-link.active { background: var(--dallah-blue-50); color: var(--dallah-blue-700); font-weight: 600; }
.nav-link .count { margin-inline-start: auto; background: var(--canvas); color: var(--ink-2); border-radius: 10px; padding: 0 .45rem; font-size: .74rem; font-family: var(--font-en); }
.nav-link.active .count { background: #fff; }
.main { padding: 1.5rem 1.75rem 3rem; min-width: 0; }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.crumbs { font-size: .8rem; color: var(--muted); margin-bottom: .2rem; display: flex; gap: .4rem; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.page-head .sub { color: var(--muted); margin-top: .25rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ---------- cards & grid ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card, .stack > * + * { margin-top: 1rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head h2 { font-size: 1rem; display: flex; align-items: center; gap: .5rem; }
.card-body { padding: 1rem 1.1rem; }
.card-foot { padding: .75rem 1.1rem; border-top: 1px solid var(--line); background: var(--raised); border-radius: 0 0 var(--radius) var(--radius); }
.card.learn { border-top: 3px solid var(--alkamel-turquoise); }
.card.accent { border-top: 3px solid var(--dallah-blue); }
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.split { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); align-items: start; }
.mt { margin-top: 1rem; } .mt2 { margin-top: 1.5rem; } .mb { margin-bottom: 1rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }

/* ---------- KPI ---------- */
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); }
.kpi .k-label { font-size: .82rem; color: var(--muted); font-weight: 600; }
.kpi .k-value { font-size: 1.75rem; font-weight: 700; line-height: 1.2; margin-top: .2rem; font-family: var(--font-en); font-variant-numeric: tabular-nums; }
.kpi .k-hint { font-size: .78rem; color: var(--muted); margin-top: .15rem; }
.kpi.ok .k-value { color: var(--ok); } .kpi.warn .k-value { color: var(--warn); } .kpi.danger .k-value { color: var(--danger); } .kpi.info .k-value { color: var(--dallah-blue); }

/* funnel */
.funnel { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .5rem; }
.funnel .step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem .9rem; position: relative; overflow: hidden; }
.funnel .step .bar { position: absolute; inset-inline-start: 0; bottom: 0; height: 4px; background: var(--dallah-blue); }
.funnel .step.s2 .bar { background: var(--warn); } .funnel .step.s3 .bar { background: var(--alkamel-turquoise); }
.funnel .step.s4 .bar { background: var(--ok); } .funnel .step.s5 .bar { background: var(--danger); }
.funnel .v { font-size: 1.6rem; font-weight: 700; font-family: var(--font-en); line-height: 1.2; }
.funnel .l { font-size: .82rem; color: var(--muted); font-weight: 600; }

/* ---------- chips & badges ---------- */
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; border: 1px solid transparent; line-height: 1.6; }
.chip svg.i { width: .95em; height: .95em; }
.t-ok { background: var(--ok-50); color: var(--ok); border-color: #CBE8D8; }
.t-warn { background: var(--warn-50); color: var(--warn); border-color: #F2DDB8; }
.t-danger { background: var(--danger-50); color: var(--danger); border-color: #F2CFCB; }
.t-info { background: var(--info-50); color: var(--info); border-color: #C9DFF1; }
.t-neutral { background: var(--neutral-50); color: var(--neutral); border-color: #DDE3E9; }
.t-learn { background: var(--alkamel-50); color: var(--alkamel-emerald); border-color: #C3E4DF; }
.t-gold { background: var(--cert-gold-50); color: #7A5F0A; border-color: #EBDDAF; }
.tag { display: inline-block; font-size: .72rem; padding: 0 .45rem; border-radius: 4px; background: var(--neutral-50); color: var(--neutral); font-family: var(--font-en); font-weight: 600; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .6rem .75rem; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th { background: var(--raised); color: var(--ink-2); font-size: .78rem; font-weight: 700; position: sticky; top: 0; white-space: nowrap; }
tbody tr:hover { background: #FBFCFD; }
td.n, th.n { text-align: end; font-family: var(--font-en); font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 700; background: var(--raised); }
table.compact th, table.compact td { padding: .4rem .6rem; }
dl.kv { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: .35rem 1rem; margin: 0; }
dl.kv dt { color: var(--muted); font-size: .86rem; }
dl.kv dd { margin: 0; font-weight: 600; }

/* ---------- buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .5rem 1rem; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; text-decoration: none !important; min-height: 38px; }
.btn:hover { background: var(--canvas); }
.btn.primary { background: var(--dallah-blue); border-color: var(--dallah-blue); color: #fff; }
.btn.primary:hover { background: var(--dallah-blue-700); }
.btn.success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.success:hover { background: #086338; }
.btn.danger { background: var(--surface); border-color: #E5B3AE; color: var(--danger); }
.btn.danger:hover { background: var(--danger-50); }
.btn.learn { background: var(--alkamel-emerald); border-color: var(--alkamel-emerald); color: #fff; }
.btn.learn:hover { background: #00574C; }
.btn.sm { padding: .25rem .65rem; min-height: 30px; font-size: .82rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.field { margin-bottom: .9rem; }
.field label, .label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .3rem; }
.field .hint { font-size: .78rem; color: var(--muted); margin-top: .2rem; }
.req { color: var(--danger); }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: .5rem .7rem; border: 1px solid var(--line-2); border-radius: 8px; background: #fff; font: inherit; color: var(--ink); min-height: 40px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--dallah-blue); box-shadow: var(--focus); }
input[type=number], input.ltr-input { direction: ltr; text-align: end; }
.error-text { color: var(--danger); font-size: .82rem; margin-top: .25rem; }
.radio-scale { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; }
.radio-scale label { display: block; border: 1px solid var(--line-2); border-radius: 8px; padding: .55rem .7rem; cursor: pointer; font-weight: 400; margin: 0; }
.radio-scale input { margin-inline-end: .35rem; }
.radio-scale label:has(input:checked) { border-color: var(--dallah-blue); background: var(--dallah-blue-50); box-shadow: inset 0 0 0 1px var(--dallah-blue); }
.radio-scale b { display: block; font-size: .92rem; }
.radio-scale span { font-size: .76rem; color: var(--muted); }
.check-list { list-style: none; margin: 0; padding: 0; }
.check-list li { display: flex; gap: .65rem; align-items: flex-start; padding: .55rem .2rem; border-bottom: 1px dashed var(--line); }
.check-list li:last-child { border-bottom: 0; }
.check-list input[type=checkbox] { width: 18px; height: 18px; margin-top: .3rem; accent-color: var(--ok); flex: none; }

/* ---------- alerts ---------- */
.alert { display: flex; gap: .6rem; align-items: flex-start; padding: .75rem 1rem; border-radius: var(--radius); border: 1px solid; margin-bottom: 1rem; font-size: .92rem; }
.alert svg.i { margin-top: .2rem; }
.alert.ok { background: var(--ok-50); border-color: #CBE8D8; color: #0A5C35; }
.alert.error { background: var(--danger-50); border-color: #F2CFCB; color: #8D231B; }
.alert.info { background: var(--info-50); border-color: #C9DFF1; color: #0A4A7F; }
.alert.warn { background: var(--warn-50); border-color: #F2DDB8; color: #7A4800; }
.callout { border-inline-start: 3px solid var(--dallah-blue); background: var(--dallah-blue-50); padding: .7rem .9rem; border-radius: 0 8px 8px 0; font-size: .9rem; }
[dir="rtl"] .callout { border-radius: 8px 0 0 8px; }
.callout.learn { border-color: var(--alkamel-turquoise); background: var(--alkamel-50); }
.callout.warn { border-color: var(--warn); background: var(--warn-50); }

/* ---------- explainable result ---------- */
.reasons { list-style: none; padding: 0; margin: .3rem 0 0; }
.reasons li { display: flex; gap: .45rem; align-items: flex-start; padding: .2rem 0; font-size: .9rem; }
.reasons li svg.i { color: var(--ok); margin-top: .3rem; }
.reasons li.neg svg.i { color: var(--warn); }
.score { display: flex; align-items: baseline; gap: .25rem; font-family: var(--font-en); }
.score b { font-size: 1.6rem; }
.meter { height: 8px; border-radius: 4px; background: var(--neutral-50); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--dallah-blue); border-radius: 4px; }
.meter.learn > span { background: var(--alkamel-turquoise); }
.meter.ok > span { background: var(--ok); }
.breakdown { display: grid; grid-template-columns: 1fr auto; gap: .2rem .8rem; font-size: .84rem; }
.breakdown span:nth-child(even) { font-family: var(--font-en); text-align: end; font-weight: 600; }

/* ---------- journey / timeline ---------- */
.journey { display: flex; gap: 0; overflow-x: auto; padding: .25rem 0 .5rem; }
.journey .st { flex: 1 0 104px; text-align: center; position: relative; font-size: .78rem; color: var(--muted); padding: 0 .2rem; }
.journey .st::before { content: ""; position: absolute; top: 15px; inset-inline-start: 50%; width: 100%; height: 2px; background: var(--line-2); z-index: 0; }
.journey .st:last-child::before { display: none; }
.journey .dot { width: 32px; height: 32px; border-radius: 50%; margin: 0 auto .3rem; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--line-2); position: relative; z-index: 1; color: var(--muted); }
.journey .st.done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.journey .st.done::before { background: var(--ok); }
.journey .st.now .dot { border-color: var(--dallah-blue); color: var(--dallah-blue); box-shadow: 0 0 0 4px var(--dallah-blue-50); }
.journey .st.now { color: var(--ink); font-weight: 700; }
.journey .st.done { color: var(--ink-2); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding-inline-start: 1.6rem; padding-bottom: .9rem; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: 6px; top: .5rem; bottom: -.2rem; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline li .tdot { position: absolute; inset-inline-start: 0; top: .45rem; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line-2); }
.timeline li.ok .tdot { background: var(--ok); border-color: var(--ok); }
.timeline li.danger .tdot { background: var(--danger); border-color: var(--danger); }
.timeline li.warn .tdot { background: #fff; border-color: var(--warn); }
.timeline .tmeta { font-size: .78rem; color: var(--muted); }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: .75rem 1.1rem; border-bottom: 1px solid var(--line); display: flex; gap: .75rem; align-items: center; }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; }
.need-card { display: block; padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: inherit; text-decoration: none !important; box-shadow: var(--shadow); transition: border-color .15s; }
.need-card:hover { border-color: var(--dallah-blue); }
.need-card .meta { font-size: .8rem; color: var(--muted); display: flex; gap: .75rem; flex-wrap: wrap; margin-top: .35rem; }
.empty { text-align: center; padding: 2.2rem 1rem; color: var(--muted); }
.empty svg.i { width: 2rem; height: 2rem; color: var(--line-2); margin-bottom: .4rem; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .5rem .85rem; color: var(--muted); font-weight: 600; font-size: .9rem; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none !important; }
.tabs a.active { color: var(--dallah-blue); border-color: var(--dallah-blue); }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }
.filters .field { margin: 0; min-width: 170px; }
.pager { display: flex; gap: .35rem; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }
.pager a, .pager span { padding: .25rem .65rem; border: 1px solid var(--line); border-radius: 6px; font-size: .85rem; background: var(--surface); }
.pager .on { background: var(--dallah-blue); color: #fff; border-color: var(--dallah-blue); }
.pager .off { color: var(--line-2); }
.certificate { border: 1px solid #EBDDAF; background: linear-gradient(135deg, #FFFDF6, var(--cert-gold-50)); border-radius: var(--radius); padding: 1rem 1.1rem; }
.certificate .title { color: #6F560A; font-weight: 700; }

/* ---------- Alkamel (simulated LMS) ---------- */
.alkamel-bar { background: var(--alkamel-emerald); color: #fff; border-radius: var(--radius) var(--radius) 0 0; padding: .7rem 1.1rem; display: flex; align-items: center; gap: .6rem; justify-content: space-between; }
.alkamel-bar b { font-size: 1.05rem; }
.alkamel-body { background: #fff; border: 1px solid #C3E4DF; border-top: 0; border-radius: 0 0 var(--radius) var(--radius); padding: 1.25rem; }
.video-mock { aspect-ratio: 16 / 7; border-radius: 10px; background: linear-gradient(135deg, #0B4F47, #00A896); color: #fff; display: grid; place-items: center; text-align: center; padding: 1rem; }
.video-mock .play { width: 56px; height: 56px; border-radius: 50%; background: rgba(255, 255, 255, .18); display: grid; place-items: center; margin: 0 auto .5rem; }
.quiz-q { padding: .75rem 0; border-bottom: 1px dashed var(--line); }
.quiz-q label { display: block; font-weight: 400; padding: .15rem 0; cursor: pointer; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
.auth-side { background: linear-gradient(160deg, #003E6E 0%, var(--dallah-blue) 55%, var(--alkamel-turquoise) 140%); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side h1 { font-size: 2rem; margin: 1.2rem 0 .6rem; }
.auth-side p { color: rgba(255, 255, 255, .85); max-width: 32rem; }
.auth-side .loop { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: 1.5rem; font-size: .8rem; }
.auth-side .loop span { background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .2); padding: .1rem .55rem; border-radius: 999px; }
.auth-main { padding: 3rem; display: flex; flex-direction: column; justify-content: center; max-width: 640px; width: 100%; margin: 0 auto; }
.demo-table td { padding: .35rem .5rem; font-size: .84rem; }
.demo-table button { font: inherit; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .g4, .g5, .funnel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; display: flex; gap: .25rem; overflow-x: auto; padding: .5rem; border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .nav-group { margin: 0; display: flex; gap: .25rem; }
  .nav-title { display: none; }
  .nav-link { white-space: nowrap; }
  .main { padding: 1rem; }
  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-side { padding: 1.5rem; }
  .auth-main { padding: 1.5rem 1rem; }
  .user-chip .who { display: none; }
  .brand-sub { display: none; }
}
@media (max-width: 520px) {
  .g4, .g5, .funnel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .k-value, .funnel .v { font-size: 1.35rem; }
  /* Tables marked .cards-sm become stacked cards on phones (skill §8). */
  table.cards-sm thead { display: none; }
  table.cards-sm tr { display: block; border-bottom: 1px solid var(--line); padding: .5rem .25rem; }
  table.cards-sm th, table.cards-sm td { display: flex; justify-content: space-between; gap: .75rem; border: 0; padding: .2rem .6rem; text-align: start; }
  table.cards-sm td.n { text-align: start; }
  table.cards-sm [data-label]::before { content: attr(data-label); color: var(--muted); font-size: .78rem; font-weight: 600; font-family: var(--font-ar); }
  html[lang="en"] table.cards-sm [data-label]::before { font-family: var(--font-en); }
  .radio-scale { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { padding-inline: .75rem; gap: .5rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print { .sidebar, .topbar, .demo-ribbon, .actions, .btn { display: none !important; } .shell { display: block; } }
