/* أثر | قياس — نظام التصميم
   الحبر الأخضر الداكن للهيكل، ورق رمادي مخضر بارد للخلفية،
   و«الأثر» بالأزرق الحبري: لون واحد مخصص لإظهار التغير من القبلي إلى البعدي. */

@font-face { font-family: 'Plex'; src: url('fonts/plex-ar-400.woff2') format('woff2'); font-weight: 400; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E; font-display: swap; }
@font-face { font-family: 'Plex'; src: url('fonts/plex-ar-500.woff2') format('woff2'); font-weight: 500; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E; font-display: swap; }
@font-face { font-family: 'Plex'; src: url('fonts/plex-ar-600.woff2') format('woff2'); font-weight: 600; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E; font-display: swap; }
@font-face { font-family: 'Plex'; src: url('fonts/plex-ar-700.woff2') format('woff2'); font-weight: 700; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E; font-display: swap; }
@font-face { font-family: 'Plex'; src: url('fonts/plex-la-400.woff2') format('woff2'); font-weight: 400; unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2212; font-display: swap; }
@font-face { font-family: 'Plex'; src: url('fonts/plex-la-500.woff2') format('woff2'); font-weight: 500; unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2212; font-display: swap; }
@font-face { font-family: 'Plex'; src: url('fonts/plex-la-600.woff2') format('woff2'); font-weight: 600; unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2212; font-display: swap; }
@font-face { font-family: 'Plex'; src: url('fonts/plex-la-700.woff2') format('woff2'); font-weight: 700; unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2212; font-display: swap; }
@font-face { font-family: 'Readex'; src: url('fonts/readex-ar-500.woff2') format('woff2'); font-weight: 500; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; font-display: swap; }
@font-face { font-family: 'Readex'; src: url('fonts/readex-ar-600.woff2') format('woff2'); font-weight: 600; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; font-display: swap; }
@font-face { font-family: 'Readex'; src: url('fonts/readex-ar-700.woff2') format('woff2'); font-weight: 700; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; font-display: swap; }
@font-face { font-family: 'Readex'; src: url('fonts/readex-la-500.woff2') format('woff2'); font-weight: 500 700; unicode-range: U+0000-00FF, U+2000-206F; font-display: swap; }

:root {
  --ink: #142B2A;
  --ink-2: #1F3D3B;
  --ink-soft: #2E5450;
  --paper: #F1F4F0;
  --surface: #FFFFFF;
  --sunk: #E7ECE6;
  --line: #D6DDD5;
  --line-strong: #B9C4BA;
  --text: #142B2A;
  --text-2: #4A5C59;
  --text-3: #6F7F7B;
  --act: #0B6B5F;
  --act-hover: #08584E;
  --act-tint: #DCEEEA;
  --trace: #2D4FA0;
  --trace-tint: #E3E9F6;
  --lv-mastered: #1C7A55;
  --lv-partial: #B07D12;
  --lv-low: #B3402A;
  --lv-mastered-t: #DDF0E6;
  --lv-partial-t: #F6EBD0;
  --lv-low-t: #F6E0DA;
  --warn: #8A5A00;
  --warn-t: #FBF1DA;
  --danger: #A33522;
  --radius-s: 6px;
  --radius: 10px;
  --radius-l: 16px;
  --shadow-pop: 0 18px 50px -12px rgba(20, 43, 42, .35);
  --f-ui: 'Plex', 'Segoe UI', Tahoma, sans-serif;
  --f-display: 'Readex', 'Plex', sans-serif;
  --rail: 236px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--text); font: 400 15px/1.65 var(--f-ui); font-variant-numeric: tabular-nums; }
h1, h2, h3, h4 { font-family: var(--f-display); font-weight: 600; line-height: 1.3; margin: 0; color: var(--ink); }
h1 { font-size: 1.75rem; letter-spacing: -.01em; }
h2 { font-size: 1.22rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .6em; }
a { color: var(--act); text-decoration-thickness: 1px; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--act) 55%, transparent); outline-offset: 2px; border-radius: 4px; }
.num { font-family: var(--f-display); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); font-size: .88em; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[dir=ltr] { unicode-bidi: isolate; }

/* ===== الهيكل ===== */
.shell { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }
.rail { background: var(--ink); color: #DCE7E3; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 14px 16px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; color: #fff; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-word { font-family: var(--f-display); font-weight: 700; font-size: 1.35rem; letter-spacing: -.01em; }
.brand-word span { font-weight: 500; color: #9FC4BC; }
.brand-word i { font-style: normal; color: #5E8C84; margin: 0 6px; font-weight: 400; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: #C9DAD5; text-decoration: none; font-weight: 500; }
.nav a svg { width: 20px; height: 20px; flex: none; opacity: .85; }
.nav a:hover { background: var(--ink-2); color: #fff; }
.nav a[aria-current=page] { background: #F1F4F0; color: var(--ink); }
.nav a[aria-current=page] svg { opacity: 1; }
.nav-sep { height: 1px; background: #2C4B48; margin: 12px 6px; }
.rail-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid #2C4B48; font-size: .85rem; color: #9DB5AF; }
.rail-foot button { background: none; border: 0; color: #C9DAD5; padding: 4px 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.main { min-width: 0; padding: 28px clamp(16px, 3.4vw, 44px) 80px; }
.page { max-width: 1180px; margin: 0 auto; }
.topbar { display: none; }
.bottomnav { display: none; }

.demo-banner { background: var(--warn-t); color: var(--warn); border: 1px solid #EAD6A6; border-radius: var(--radius); padding: 8px 14px; margin-bottom: 18px; font-size: .9rem; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .sub { color: var(--text-2); margin-top: 4px; }
.crumbs { font-size: .88rem; color: var(--text-3); margin-bottom: 6px; }
.crumbs a { color: var(--text-2); }

/* ===== الأسطح ===== */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 20px 22px; }
.panel + .panel, .stack > * + * { margin-top: 18px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head p { margin: 2px 0 0; color: var(--text-2); font-size: .9rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-2 > .panel + .panel { margin-top: 0; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.sticky { position: sticky; top: 20px; }
.divide > * + * { border-top: 1px solid var(--line); }

/* ===== الأزرار ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--sunk); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--act); border-color: var(--act); color: #fff; }
.btn.primary:hover { background: var(--act-hover); }
.btn.ink { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.ink:hover { background: var(--ink-2); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--sunk); }
.btn.danger { color: var(--danger); border-color: #E2B9B0; }
.btn.small { min-height: 32px; padding: 4px 11px; font-size: .88rem; border-radius: 7px; }
.btn[disabled], .btn.busy { opacity: .55; pointer-events: none; }
.btn.busy::after { content: ''; width: 14px; height: 14px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ===== النماذج ===== */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span, .label { font-weight: 600; font-size: .92rem; }
.field small { color: var(--text-3); font-size: .83rem; }
.input, select.input, textarea.input { width: 100%; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: #fff; }
textarea.input { min-height: 96px; resize: vertical; line-height: 1.6; }
.input:focus { border-color: var(--act); outline: none; box-shadow: 0 0 0 3px var(--act-tint); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--act); flex: none; }

.seg { display: inline-flex; background: var(--sunk); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--text-2); }
.seg button[aria-pressed=true] { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(20,43,42,.15); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: #fff; border-radius: 999px; padding: 6px 14px; cursor: pointer; font-weight: 500; }
.chip[aria-pressed=true] { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip small { opacity: .7; }

.stepper-n { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 9px; overflow: hidden; background: #fff; }
.stepper-n button { width: 34px; height: 34px; border: 0; background: var(--sunk); cursor: pointer; font-size: 1.1rem; font-weight: 700; }
.stepper-n output { min-width: 34px; text-align: center; font-family: var(--f-display); font-weight: 600; }

/* ===== الوسوم ===== */
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--sunk); color: var(--text-2); white-space: nowrap; }
.tag.demo { background: var(--warn-t); color: var(--warn); }
.tag.verified { background: var(--lv-mastered-t); color: var(--lv-mastered); }
.tag.pending { background: #EEF0F4; color: #4D5870; }
.tag.ai { background: var(--trace-tint); color: var(--trace); }
.tag.ok { background: var(--lv-mastered-t); color: var(--lv-mastered); }
.tag.warn { background: var(--warn-t); color: var(--warn); }
.tag.bad { background: var(--lv-low-t); color: var(--lv-low); }
.tag.live { background: var(--act-tint); color: var(--act); }
.tag.live::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--act); }

.lv { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: middle; }
.lv.mastered { background: var(--lv-mastered); } .lv.partial { background: var(--lv-partial); } .lv.low { background: var(--lv-low); }

.note { border-inline-start: 3px solid var(--line-strong); padding: 6px 12px; color: var(--text-2); font-size: .9rem; margin: 8px 0; }
.note.warn { border-color: var(--lv-partial); background: var(--warn-t); color: #6B4700; border-radius: 0 8px 8px 0; }
.note.ok { border-color: var(--lv-mastered); }
.note.info { border-color: var(--trace); }

/* ===== الصفحة الرئيسية ===== */
.hello { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; flex-wrap: wrap; margin-bottom: 20px; }
.hello h1 { font-size: clamp(1.5rem, 2.6vw, 2.1rem); }
.launch { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 26px; }
.launch a { display: flex; flex-direction: column; gap: 10px; padding: 16px 14px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; font-family: var(--f-display); font-weight: 600; font-size: 1.02rem; }
.launch a svg { width: 26px; height: 26px; color: var(--act); }
.launch a:hover { border-color: var(--ink-soft); }
.launch a small { font-family: var(--f-ui); font-weight: 400; color: var(--text-3); font-size: .8rem; margin-top: -6px; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); }
.kpi { padding: 18px 20px; }
.kpi + .kpi { border-inline-start: 1px solid var(--line); }
.kpi .v { font-family: var(--f-display); font-size: 2rem; font-weight: 600; line-height: 1.1; color: var(--ink); }
.kpi .v small { font-size: .55em; color: var(--text-3); font-weight: 500; margin-inline-start: 2px; }
.kpi .k { font-weight: 600; margin-top: 6px; }
.kpi .d { color: var(--text-3); font-size: .84rem; line-height: 1.5; margin-top: 2px; }

.actions-list { list-style: none; margin: 0; padding: 0; }
.actions-list li { border-top: 1px solid var(--line); }
.actions-list li:first-child { border-top: 0; }
.actions-list a { display: flex; gap: 12px; align-items: center; padding: 12px 2px; color: var(--ink); text-decoration: none; }
.actions-list a:hover .t { text-decoration: underline; text-underline-offset: 3px; }
.actions-list .ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--act-tint); color: var(--act); }
.actions-list .ic svg { width: 17px; height: 17px; }
.actions-list .ic.k-plan, .actions-list .ic.k-remeasure, .actions-list .ic.k-impact { background: var(--trace-tint); color: var(--trace); }
.actions-list .ic.k-close, .actions-list .ic.k-participation, .actions-list .ic.k-skills { background: var(--warn-t); color: var(--warn); }

/* دورة التحسين */
.cycle { width: 100%; }
.cycle-row { display: grid; grid-template-columns: 170px 1fr; gap: 16px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); }
.cycle-row:first-of-type { border-top: 0; }
.cycle-name b { display: block; font-family: var(--f-display); font-weight: 600; }
.cycle-name span { color: var(--text-3); font-size: .85rem; }
.track { display: grid; grid-template-columns: repeat(7, 1fr); position: relative; }
.track::before { content: ''; position: absolute; top: 9px; inset-inline: 7%; height: 2px; background: var(--line); }
.track .st { position: relative; text-align: center; font-size: .76rem; color: var(--text-3); line-height: 1.35; padding: 0 2px; }
.track .st i { display: block; width: 20px; height: 20px; margin: 0 auto 6px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line-strong); position: relative; z-index: 1; }
.track .st.done i { background: var(--ink-soft); border-color: var(--ink-soft); }
.track .st.now i { background: var(--trace); border-color: var(--trace); box-shadow: 0 0 0 5px var(--trace-tint); }
.track .st.now { color: var(--trace); font-weight: 700; }
.track .st.done { color: var(--text-2); }
.track-fill { position: absolute; top: 9px; height: 2px; background: var(--ink-soft); inset-inline-start: 7%; }

/* ===== الرسوم ===== */
.chart { width: 100%; display: block; overflow: visible; }
.chart text { font-family: var(--f-ui); fill: var(--text-2); font-size: 12px; }
.chart .lbl { fill: var(--text); font-size: 13px; }
.chart .val { fill: var(--text); font-family: var(--f-display); font-weight: 600; font-size: 13px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .target { stroke: var(--ink); stroke-dasharray: 3 3; stroke-width: 1.5; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart g.row:hover .bar { filter: brightness(.92); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .85rem; color: var(--text-2); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend .sw.pre { border: 2px solid #8E9A97; border-radius: 50%; background: #fff; }
.legend .sw.post { background: var(--trace); border-radius: 50%; }
.tip { position: fixed; z-index: 90; pointer-events: none; background: var(--ink); color: #fff; padding: 7px 10px; border-radius: 8px; font-size: .84rem; line-height: 1.45; max-width: 280px; box-shadow: var(--shadow-pop); }

.levelbar { display: flex; height: 12px; border-radius: 4px; overflow: hidden; gap: 2px; background: var(--sunk); min-width: 120px; }
.levelbar span { display: block; height: 100%; }
.levelbar .m { background: var(--lv-mastered); } .levelbar .p { background: var(--lv-partial); } .levelbar .l { background: var(--lv-low); }

/* ===== الجداول ===== */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.t { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.t th { text-align: start; font-weight: 600; color: var(--text-2); font-size: .82rem; padding: 8px 10px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; background: var(--surface); }
table.t td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover td { background: #F8FAF7; }
table.t .n { text-align: end; font-family: var(--f-display); white-space: nowrap; }
table.t th.sortable { cursor: pointer; }
table.t th.sortable::after { content: ' ⇅'; opacity: .4; }
.heat td.c { text-align: center; font-family: var(--f-display); font-size: .85rem; min-width: 56px; }
.heat td.c.mastered { background: var(--lv-mastered-t); color: var(--lv-mastered); }
.heat td.c.partial { background: var(--lv-partial-t); color: #7A5600; }
.heat td.c.low { background: var(--lv-low-t); color: var(--lv-low); }
.heat th.sk { max-width: 120px; white-space: normal; line-height: 1.35; vertical-align: bottom; }

/* ===== القوائم ===== */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 14px 0; border-top: 1px solid var(--line); display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.list > li:first-child { border-top: 0; }
.list .title { font-weight: 600; color: var(--ink); text-decoration: none; }
.list a.title:hover { text-decoration: underline; }
.list .meta { color: var(--text-3); font-size: .86rem; display: flex; gap: 10px; flex-wrap: wrap; margin-top: 2px; }
.empty { text-align: center; padding: 36px 16px; color: var(--text-2); }
.empty h3 { margin-bottom: 6px; }
.empty .btn { margin-top: 12px; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }

/* ===== الأسئلة ===== */
.qcard { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: #fff; }
.qcard + .qcard { margin-top: 10px; }
.qcard.approved { border-inline-start: 4px solid var(--lv-mastered); }
.qcard.draft { border-inline-start: 4px solid var(--line-strong); }
.qcard.flagged { border-inline-start: 4px solid var(--lv-partial); }
.qhead { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 6px; }
.qstem { font-weight: 600; white-space: pre-wrap; }
.qopts { list-style: none; padding: 0; margin: 10px 0 6px; display: grid; gap: 6px; }
.qopts li { padding: 6px 10px; border-radius: 8px; background: var(--paper); display: flex; gap: 8px; }
.qopts li.key { background: var(--lv-mastered-t); color: #0F5139; font-weight: 600; }
.qopts li b { color: var(--text-3); font-weight: 600; min-width: 18px; }
.flags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
details.expl summary { cursor: pointer; color: var(--text-2); font-size: .88rem; }
details.expl p { margin: 6px 0 0; font-size: .92rem; color: var(--text-2); }

.coverage { display: grid; gap: 10px; }
.cov { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 14px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.cov:first-child { border-top: 0; }
.cov .bar { grid-column: 1 / -1; height: 6px; background: var(--sunk); border-radius: 3px; overflow: hidden; display: flex; gap: 2px; }
.cov .bar span { background: var(--act); }
.cov .bar span.pend { background: var(--line-strong); }

.linkbox { display: flex; gap: 8px; align-items: center; background: var(--paper); border: 1px dashed var(--line-strong); border-radius: 10px; padding: 8px 8px 8px 12px; }
.linkbox code { flex: 1; overflow-x: auto; white-space: nowrap; font-family: var(--f-ui); direction: ltr; text-align: left; }
.qr { background: #fff; padding: 10px; border-radius: 10px; border: 1px solid var(--line); width: 168px; }
.qr svg { width: 100%; height: auto; display: block; }

/* ===== النوافذ ===== */
.modal-back { position: fixed; inset: 0; background: rgba(15, 30, 29, .45); z-index: 60; display: grid; place-items: center; padding: 16px; animation: fade .12s ease-out; }
.modal { background: var(--surface); border-radius: var(--radius-l); width: min(640px, 100%); max-height: 92vh; overflow: auto; box-shadow: var(--shadow-pop); }
.modal.wide { width: min(920px, 100%); }
.modal-h { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px 0; }
.modal-b { padding: 16px 22px; }
.modal-f { padding: 0 22px 20px; display: flex; gap: 8px; justify-content: flex-start; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
.toasts { position: fixed; bottom: 22px; inset-inline-start: 50%; transform: translateX(50%); z-index: 99; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow-pop); max-width: min(560px, 92vw); font-weight: 500; animation: fade .15s ease-out; }
.toast.err { background: #7E2A1C; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--text-2); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a[aria-current=page] { color: var(--ink); border-color: var(--ink); }

.states { display: flex; gap: 0; margin: 4px 0 0; font-size: .84rem; }
.states span { padding: 4px 12px; border: 1px solid var(--line); color: var(--text-3); background: #fff; }
.states span:first-child { border-radius: 0 8px 8px 0; }
.states span:last-child { border-radius: 8px 0 0 8px; }
.states span + span { border-inline-start: 0; }
.states span.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.states span.past { color: var(--text-2); }

.statline { display: flex; gap: 0; flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--radius-l); background: var(--surface); }
.statline > div { padding: 14px 18px; flex: 1 1 140px; }
.statline > div + div { border-inline-start: 1px solid var(--line); }
.statline .v { font-family: var(--f-display); font-size: 1.55rem; font-weight: 600; line-height: 1.15; }
.statline .k { color: var(--text-2); font-size: .85rem; }

/* ===== تسجيل الدخول ===== */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-side { background: var(--ink); color: #DCE7E3; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-side h1 { color: #fff; font-size: clamp(2rem, 4vw, 3.1rem); font-weight: 700; line-height: 1.2; max-width: 12em; }
.auth-side p { color: #A9C2BC; max-width: 30em; font-size: 1.02rem; }
.auth-trace { position: absolute; inset-inline-end: -40px; bottom: 80px; width: 70%; opacity: .9; transform: scaleX(-1); }
.auth-form { display: grid; place-items: center; padding: 32px 20px; }
.auth-form form { width: min(380px, 100%); }
.auth-form h2 { font-size: 1.5rem; margin-bottom: 6px; }

/* ===== الطباعة والتقارير ===== */
.report { background: #fff; max-width: 210mm; margin: 0 auto; padding: 16mm 14mm; border: 1px solid var(--line); }
.report h1 { font-size: 1.5rem; }
.report-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--ink); padding-bottom: 10px; margin-bottom: 16px; gap: 16px; }
.report section { margin-top: 18px; break-inside: avoid; }
.report h2 { font-size: 1.05rem; margin-bottom: 8px; }
.cards-print { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; }
.slip { border: 1px dashed #999; padding: 10px 12px; break-inside: avoid; min-height: 34mm; }
.slip b { font-family: var(--f-display); font-size: 1.35rem; letter-spacing: .12em; direction: ltr; display: block; margin: 4px 0; }

@media print {
  @page { size: A4; margin: 10mm; }
  body { background: #fff; font-size: 11pt; }
  .rail, .topbar, .bottomnav, .no-print, .demo-banner, .toasts { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  .report { border: 0; padding: 0; max-width: none; }
  .panel { border: 0; padding: 0; }
  a { color: inherit; text-decoration: none; }
  .heat td.c, .levelbar span, .lv, .tag { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ===== الجوال ===== */
@media (max-width: 1100px) {
  .launch { grid-template-columns: repeat(3, 1fr); }
  .split { grid-template-columns: 1fr; }
  .sticky { position: static; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { display: none; }
  .topbar { display: flex; align-items: center; justify-content: space-between; background: var(--ink); color: #fff; padding: 10px 16px; position: sticky; top: 0; z-index: 40; }
  .topbar .brand { padding: 0; }
  .topbar .brand-mark { width: 28px; height: 28px; }
  .topbar .brand-word { font-size: 1.15rem; }
  .topbar button { background: none; border: 0; color: #C9DAD5; font-size: .85rem; }
  .bottomnav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; inset-inline: 0; background: var(--surface); border-top: 1px solid var(--line); z-index: 40; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .72rem; font-weight: 600; color: var(--text-3); text-decoration: none; padding: 6px 2px; border-radius: 8px; }
  .bottomnav a svg { width: 22px; height: 22px; }
  .bottomnav a[aria-current=page] { color: var(--ink); background: var(--act-tint); }
  .main { padding: 18px 14px 96px; }
  h1 { font-size: 1.4rem; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi:nth-child(3) { border-inline-start: 0; }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--line); }
  .kpi .v { font-size: 1.6rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .panel { padding: 16px; border-radius: 14px; }
  .cycle-row { grid-template-columns: 1fr; gap: 10px; }
  .track .st { font-size: .64rem; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { padding: 28px 22px; min-height: 0; }
  .auth-side h1 { font-size: 1.7rem; }
  .auth-trace { display: none; }
  .modal-back { align-items: end; padding: 0; }
  .modal { border-radius: 18px 18px 0 0; max-height: 94vh; }
  .cards-print { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .launch { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .launch a { padding: 12px 8px; font-size: .9rem; align-items: center; text-align: center; }
  .launch a small { display: none; }
  .statline > div { flex-basis: 45%; }
  .statline > div:nth-child(odd) { border-inline-start: 0; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ===== رسوم HTML ===== */
.hbars { display: grid; gap: 4px; }
.hbar, .drow { display: grid; grid-template-columns: minmax(140px, 40%) 1fr 56px; gap: 14px; align-items: center; padding: 7px 0; }
.hbar .hl, .drow .hl { font-size: .92rem; line-height: 1.4; }
.hbar .hl small, .drow .hl small { display: block; color: var(--text-3); font-size: .8rem; }
.hbar .hl a, .drow .hl a { color: var(--ink); text-decoration: none; }
.hbar .hl a:hover, .drow .hl a:hover { text-decoration: underline; }
.ht { position: relative; height: 14px; background: var(--sunk); border-radius: 4px; }
.ht span { position: absolute; inset-inline-start: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; min-width: 2px; }
.tgt { position: absolute; top: -5px; bottom: -5px; width: 0; border-inline-start: 2px dashed var(--ink); }
.sw.tgt-sw { width: 0; height: 14px; border-inline-start: 2px dashed var(--ink); border-radius: 0; background: none; }
.hbar b, .drow b { text-align: end; font-weight: 600; font-size: .95rem; }
.dt { position: relative; height: 22px; }
.dt::before { content: ''; position: absolute; inset-inline: 0; top: 10px; height: 2px; background: var(--sunk); border-radius: 2px; }
.dl { position: absolute; top: 9px; height: 4px; background: var(--trace); border-radius: 2px; }
.dl.down { background: var(--lv-low); }
.dp { position: absolute; top: 3px; width: 16px; height: 16px; border-radius: 50%; transform: translateX(50%); }
.dp.pre { background: #fff; border: 2.5px solid #8E9A97; }
.dp.post { background: var(--trace); border: 2px solid #fff; box-shadow: 0 0 0 1.5px var(--trace); }
.dp.post.down { background: var(--lv-low); box-shadow: 0 0 0 1.5px var(--lv-low); }
.drow b.up { color: var(--trace); } .drow b.dn { color: var(--lv-low); }
.dumb { display: grid; gap: 2px; }
.gain { font-family: var(--f-display); font-weight: 600; white-space: nowrap; }
.gain.up { color: var(--trace); } .gain.dn { color: var(--lv-low); }
.hist { display: flex; align-items: flex-end; gap: 4px; height: 150px; padding-top: 8px; border-bottom: 1px solid var(--line-strong); }
.hcol { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; position: relative; }
.hcol .hb { background: var(--ink-soft); border-radius: 4px 4px 0 0; min-height: 1px; }
.hcol.ok .hb { background: var(--lv-mastered); }
.hcol small { position: absolute; bottom: -20px; inset-inline: 0; text-align: center; font-size: .72rem; color: var(--text-3); }
.hist + .legend { margin-top: 26px; }
@media (max-width: 560px) {
  .hbar, .drow { grid-template-columns: 1fr 52px; gap: 4px 10px; }
  .hbar .hl, .drow .hl { grid-column: 1 / -1; }
}

/* ===== وضع الصيانة ===== */
.maint { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--ink); color: #DCE7E3; }
.maint-card { width: min(560px, 100%); text-align: center; }
.maint-card .brand-mark { width: 56px; height: 56px; }
.maint-card h1 { color: #fff; font-size: clamp(1.6rem, 4vw, 2.3rem); margin: 22px 0 10px; font-weight: 700; }
.maint-card p { color: #A9C2BC; font-size: 1.02rem; line-height: 1.8; margin: 0 auto 10px; max-width: 32em; }
.maint-card .maint-safe { display: inline-flex; gap: 8px; align-items: center; background: #1F3D3B; color: #DCE7E3; border-radius: 999px; padding: 6px 14px; font-size: .9rem; margin: 10px 0 22px; }
.maint-card .maint-safe::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #8FB0F0; }
.maint-card .btn { background: #F1F4F0; color: var(--ink); border-color: #F1F4F0; }
.maint-card small { display: block; margin-top: 14px; color: #6F948C; }
.maint-trace { width: 220px; margin: 26px auto 0; opacity: .8; transform: scaleX(-1); }
.service-banner { background: var(--warn-t); color: var(--warn); border: 1px solid #EAD6A6; border-radius: var(--radius); padding: 8px 14px; margin-bottom: 14px; font-size: .9rem; }
