/* =========================================================
   وجهة رقمية | لوحة التحكم وبوابة الزبون
   شريط جانبي كحلي بهوية الشعار، مساحة عمل فاتحة، بطاقات بيضاء.
   ========================================================= */
:root {
  --ink: #071A3D; --ink-2: #0C2550; --ink-3: #16346A;
  --blue: #1463FF; --blue-600: #0E4FD6; --blue-50: #EEF3FF;
  --cyan: #2CC6EE;
  --bg: #F3F5F9; --surface: #FFFFFF; --surface-2: #F8FAFC;
  --line: #E3E8F0; --line-strong: #CDD5E2;
  --text: #0B1630; --muted: #5A6983; --faint: #8A97AE;
  --on-dark: #EAF1FF; --on-dark-muted: #9FB0D1;
  --ok: #0F9D66; --ok-bg: #E7F6EF;
  --warn: #B26B00; --warn-bg: #FFF4DF;
  --err: #C0352B; --err-bg: #FDECEA;
  --new: #6D3FD6; --new-bg: #F1EBFD;
  --f-display: "Alexandria", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --f-body: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --r: 14px; --r-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(7, 26, 61, .05), 0 1px 6px rgba(7, 26, 61, .04);
  --shadow: 0 12px 34px -14px rgba(7, 26, 61, .25);
  --side-w: 264px;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--f-body); font-size: 15px; line-height: 1.65; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-600); }
h1, h2, h3, h4 { font-family: var(--f-display); margin: 0; line-height: 1.35; font-weight: 600; text-wrap: balance; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; border-radius: 6px; }
.i { width: 20px; height: 20px; flex: none; }
.num, .mono { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--f-mono); font-size: .88em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
[hidden] { display: none !important; }
[dir="rtl"] .dl dd[dir="ltr"], [dir="rtl"] td[dir="ltr"] { text-align: right !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- الهيكل ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100%; }
.side {
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; gap: 6px;
  background: var(--ink); color: var(--on-dark);
  padding: 18px 14px calc(14px + env(safe-area-inset-bottom, 0px));
  padding-top: calc(18px + env(safe-area-inset-top, 0px));
  overflow-y: auto;
}
.side-brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 18px; color: #fff; }
.side-brand:hover { color: #fff; }
.side-brand img { width: 36px; height: 36px; border-radius: 9px; }
.side-brand span { display: flex; flex-direction: column; line-height: 1.2; }
.side-brand strong { font-family: var(--f-display); font-size: 1.05rem; }
.side-brand small { color: var(--on-dark-muted); font-size: .78rem; }
.side-nav { display: grid; gap: 2px; }
.side-nav a, .side-foot > a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--on-dark-muted); font-weight: 500; font-size: .95rem;
  transition: background-color .15s, color .15s;
}
.side-nav a:hover, .side-foot > a:hover { background: rgba(234, 241, 255, .06); color: #fff; }
.side-nav a.is-active { background: rgba(20, 99, 255, .22); color: #fff; box-shadow: inset 3px 0 0 var(--cyan); }
[dir="rtl"] .side-nav a.is-active { box-shadow: inset -3px 0 0 var(--cyan); }
.side-nav a span:first-of-type { flex: 1; }
.nav-badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--cyan); color: var(--ink); font-size: .74rem; font-weight: 700; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.side-foot { margin-top: auto; display: grid; gap: 6px; padding-top: 14px; border-top: 1px solid rgba(234, 241, 255, .08); }
.me { display: flex; align-items: center; gap: 10px; padding: 10px 8px 2px; }
.avatar { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; background: linear-gradient(135deg, var(--blue), var(--cyan)); color: #fff; font-weight: 700; font-size: .85rem; }
.me-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.me-text strong { font-size: .92rem; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { color: var(--on-dark-muted); font-size: .78rem; }
.side .icon-btn { color: var(--on-dark-muted); border-color: rgba(234, 241, 255, .14); background: transparent; }
.side .icon-btn:hover { color: #fff; border-color: rgba(234, 241, 255, .4); }
.side-scrim { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  min-height: 68px; padding: 10px max(28px, env(safe-area-inset-right, 0px)) 10px max(28px, env(safe-area-inset-left, 0px));
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: rgba(243, 245, 249, .9); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 1.3rem; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.topbar .menu-toggle { display: none; }
.content { padding: 26px max(28px, env(safe-area-inset-right, 0px)) 48px max(28px, env(safe-area-inset-left, 0px)); display: grid; gap: 22px; align-content: start; max-width: 1400px; width: 100%; }

/* ---------- أزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: 10px;
  font: 600 .92rem/1 var(--f-body); white-space: nowrap; cursor: pointer;
  border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--text);
  transition: background-color .15s, border-color .15s, color .15s, transform .15s;
}
.btn:hover { border-color: var(--text); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn .i { width: 18px; height: 18px; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }
.btn-danger { color: var(--err); border-color: #F0C4BF; background: var(--surface); }
.btn-danger:hover { background: var(--err-bg); border-color: var(--err); color: var(--err); }
.btn-ok { color: var(--ok); border-color: #BDE6D3; }
.btn-ok:hover { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line); }
.btn-lg { min-height: 48px; font-size: 1rem; padding: 0 20px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); color: var(--text); display: grid; place-items: center; cursor: pointer; flex: none; }
.icon-btn:hover { border-color: var(--line-strong); color: var(--text); }
.lang-btn { min-width: 48px; height: 40px; padding: 0 12px; display: grid; place-items: center; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); color: var(--text); font-weight: 600; font-size: .88rem; }
.lang-btn:hover { border-color: var(--text); color: var(--text); }

/* ---------- بطاقات ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head h2 { font-size: 1.02rem; }
.card-head .sub { color: var(--muted); font-size: .85rem; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }
.grid { display: grid; gap: 22px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); align-items: start; }

/* مؤشرات */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; box-shadow: var(--shadow-sm); min-width: 0; position: relative; }
.kpi-label { color: var(--muted); font-size: .86rem; display: flex; align-items: center; gap: 8px; }
.kpi-label .i { width: 17px; height: 17px; color: var(--blue); }
.kpi-value { font-family: var(--f-display); font-size: 1.85rem; font-weight: 700; line-height: 1.2; margin-top: 8px; font-variant-numeric: tabular-nums; }
.kpi-foot { margin-top: 6px; font-size: .82rem; color: var(--muted); }
.delta { font-weight: 600; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--ok); } .delta.down { color: var(--err); }
.kpi.attn { border-color: #F3D9A6; background: linear-gradient(0deg, var(--surface), var(--surface)) padding-box; box-shadow: inset 0 3px 0 var(--warn), var(--shadow-sm); }
.kpi a.kpi-link { position: absolute; inset: 0; border-radius: var(--r); }

/* ---------- جداول ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: .92rem; }
.t th, .t td { padding: 12px 16px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t thead th { font-weight: 600; font-size: .8rem; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
.t tbody tr { transition: background-color .12s; }
.t tbody tr:hover { background: var(--surface-2); }
.t tbody tr:last-child td { border-bottom: 0; }
.t tr.is-unread td { font-weight: 600; }
.t tr.is-unread td:first-child { box-shadow: inset 3px 0 0 var(--blue); }
[dir="rtl"] .t tr.is-unread td:first-child { box-shadow: inset -3px 0 0 var(--blue); }
.t .row-link { color: var(--text); font-weight: 600; }
.t .row-link:hover { color: var(--blue); }
.t td.end, .t th.end { text-align: end; }
.cell-sub { display: block; color: var(--muted); font-size: .82rem; font-weight: 400; }
.nowrap { white-space: nowrap; }

/* ---------- شارات ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; background: var(--blue-50); color: var(--blue); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.wait { background: var(--warn-bg); color: var(--warn); }
.pill.err { background: var(--err-bg); color: var(--err); }
.pill.new { background: var(--new-bg); color: var(--new); }
.pill.muted { background: #EEF0F4; color: var(--muted); }
.tag { display: inline-block; padding: 2px 9px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); font-size: .78rem; color: var(--muted); }

/* ---------- تنبيهات ---------- */
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 13px 16px; border-radius: 12px; font-size: .94rem; border: 1px solid; }
.flash .i { margin-top: 2px; }
.flash.ok { background: var(--ok-bg); color: #0A6E47; border-color: #BFE5D2; }
.flash.err { background: var(--err-bg); color: #9E2A21; border-color: #F2C6C1; }
.flash.info { background: var(--blue-50); color: #0E3FA8; border-color: #CCDBFF; }

/* ---------- نماذج ---------- */
.form { display: grid; gap: 16px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.f { display: grid; gap: 6px; min-width: 0; }
.f label, .f .label { font-weight: 600; font-size: .9rem; }
.f .hint { color: var(--muted); font-size: .82rem; }
.f .opt { color: var(--faint); font-weight: 400; font-size: .82rem; }
.f input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), .f select, .f textarea {
  width: 100%; font: inherit; font-size: .95rem; color: var(--text);
  padding: 10px 13px; border-radius: 10px; border: 1.5px solid var(--line-strong); background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.f textarea { min-height: 110px; resize: vertical; line-height: 1.6; }
.f input:focus, .f select:focus, .f textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(20, 99, 255, .13); }
.f input[dir="ltr"] { text-align: left; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--blue); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.choice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.choice span { display: grid; gap: 2px; height: 100%; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line-strong); background: var(--surface); }
.choice b { font-family: var(--f-display); font-weight: 600; }
.choice small { color: var(--muted); }
.choice input:checked + span { border-color: var(--blue); background: var(--blue-50); box-shadow: inset 0 0 0 1px var(--blue); }
.choice input:focus-visible + span { outline: 3px solid var(--cyan); outline-offset: 2px; }

/* ---------- تبويبات ---------- */
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: #E9EDF4; overflow-x: auto; width: fit-content; max-width: 100%; }
.tabs a { padding: 8px 14px; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: .9rem; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.toolbar form { display: flex; gap: 8px; flex-wrap: wrap; }
.search { position: relative; }
.search input { padding: 9px 13px; border-radius: 10px; border: 1.5px solid var(--line-strong); font: inherit; min-width: 240px; background: var(--surface); }
.search input:focus { outline: none; border-color: var(--blue); }
.select-sm { padding: 9px 12px; border-radius: 10px; border: 1.5px solid var(--line-strong); font: inherit; background: var(--surface); }

/* ---------- قائمة عناصر ---------- */
.list > li { display: flex; gap: 12px; align-items: center; padding: 13px 20px; border-bottom: 1px solid var(--line); min-width: 0; }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; color: var(--text); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .sub { color: var(--muted); font-size: .84rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--blue); flex: none; }

.empty { padding: 40px 24px; text-align: center; color: var(--muted); display: grid; gap: 10px; justify-items: center; }
.empty .i { width: 36px; height: 36px; color: var(--line-strong); }
.empty strong { color: var(--text); font-family: var(--f-display); font-weight: 600; }

/* ---------- الرسم البياني ---------- */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--faint); font-size: 11px; font-family: var(--f-body); }
.chart .bar { fill: #C9D8FF; }
.chart .bar.uv { fill: var(--blue); }
.chart .bar:hover { fill: var(--cyan); }
.chart-legend { display: flex; gap: 18px; font-size: .84rem; color: var(--muted); flex-wrap: wrap; }
.chart-legend span { display: inline-flex; align-items: center; gap: 7px; }
.chart-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.hbars { display: grid; gap: 12px; }
.hbar { display: grid; gap: 5px; }
.hbar-top { display: flex; justify-content: space-between; gap: 10px; font-size: .9rem; }
.hbar-top span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 8px; border-radius: 6px; background: #EDF1F7; overflow: hidden; }
.hbar-track i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--blue), var(--cyan)); }
[dir="rtl"] .hbar-track i { background: linear-gradient(270deg, var(--blue), var(--cyan)); }

/* ---------- الخط الزمني للطلب ---------- */
.stepper { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 0; position: relative; }
.stepper li { position: relative; display: grid; justify-items: center; text-align: center; gap: 8px; padding-top: 2px; font-size: .78rem; color: var(--faint); min-width: 0; }
.stepper li::before { content: ""; position: absolute; top: 14px; inset-inline-start: 50%; width: 100%; height: 2px; background: var(--line); z-index: 0; }
.stepper li:last-child::before { display: none; }
.stepper .node { position: relative; z-index: 1; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--line-strong); font-weight: 700; font-size: .75rem; color: var(--faint); }
.stepper .node .i { width: 15px; height: 15px; }
.stepper li.done { color: var(--text); }
.stepper li.done .node { background: var(--blue); border-color: var(--blue); color: #fff; }
.stepper li.done::before { background: var(--blue); }
.stepper li.current { color: var(--blue); font-weight: 600; }
.stepper li.current .node { border-color: var(--blue); color: var(--blue); box-shadow: 0 0 0 5px rgba(20, 99, 255, .14); }
.timeline { display: grid; gap: 0; }
.timeline li { position: relative; padding-inline-start: 26px; padding-bottom: 18px; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: 5px; top: 8px; bottom: -2px; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; inset-inline-start: 0; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2.5px solid var(--blue); }
.timeline .when { color: var(--faint); font-size: .8rem; }
.timeline .what { font-weight: 600; }
.timeline .note { color: var(--muted); font-size: .9rem; white-space: pre-wrap; margin-top: 2px; }
.timeline .private { display: inline-block; font-size: .72rem; color: var(--warn); background: var(--warn-bg); padding: 1px 7px; border-radius: 6px; margin-inline-start: 6px; }

/* ---------- تفاصيل ---------- */
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 10px 18px; font-size: .92rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; min-width: 0; word-break: break-word; }
.msg-body { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 16px; line-height: 1.8; }

/* ---------- المحادثة ---------- */
.chat { display: flex; flex-direction: column; height: calc(100vh - 210px); height: calc(100dvh - 210px); min-height: 460px; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.chat-head .grow { flex: 1; min-width: 0; }
.chat-head h2 { font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-log { flex: 1; overflow-y: auto; padding: 20px 18px; display: flex; flex-direction: column; gap: 10px; background:
  radial-gradient(circle at 1px 1px, #E6EBF3 1px, transparent 0) 0 0 / 22px 22px, var(--surface-2); }
.bubble-row { display: flex; gap: 8px; align-items: flex-end; max-width: 78%; }
.bubble-row.mine { align-self: flex-end; flex-direction: row-reverse; }
.bubble-row .avatar { width: 30px; height: 30px; border-radius: 9px; font-size: .72rem; }
.bubble { padding: 10px 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); min-width: 0; }
.bubble p { white-space: pre-wrap; word-break: break-word; }
.bubble .meta { display: block; font-size: .72rem; color: var(--faint); margin-top: 4px; }
.mine .bubble { background: var(--blue); border-color: var(--blue); color: #fff; }
.mine .bubble .meta { color: rgba(255, 255, 255, .7); }
.bubble .who { font-size: .76rem; font-weight: 600; color: var(--blue); display: block; margin-bottom: 2px; }
.mine .bubble .who { color: #DCE7FF; }
.bubble a.file { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; padding: 6px 10px; border-radius: 8px; background: rgba(20, 99, 255, .08); font-size: .84rem; font-weight: 600; }
.mine .bubble a.file { background: rgba(255, 255, 255, .18); color: #fff; }
.bubble img.thumb { margin-top: 8px; border-radius: 10px; max-height: 220px; width: auto; }
.sys-msg { align-self: center; font-size: .8rem; color: var(--muted); background: var(--surface); border: 1px solid var(--line); padding: 4px 12px; border-radius: 999px; text-align: center; }
.chat-day { align-self: center; font-size: .74rem; color: var(--faint); }
.composer { border-top: 1px solid var(--line); padding: 12px; display: flex; gap: 8px; align-items: flex-end; background: var(--surface); border-radius: 0 0 var(--r) var(--r); }
.composer textarea { flex: 1; min-height: 46px; max-height: 180px; resize: none; padding: 11px 14px; border-radius: 12px; border: 1.5px solid var(--line-strong); font: inherit; line-height: 1.5; }
.composer textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(20, 99, 255, .12); }
.composer .file-btn { position: relative; overflow: hidden; }
.composer .file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.composer .btn { min-height: 46px; }
.composer-file { font-size: .8rem; color: var(--muted); padding: 0 14px 8px; background: var(--surface); }
.chat-closed { padding: 16px; text-align: center; color: var(--muted); border-top: 1px solid var(--line); background: var(--surface); border-radius: 0 0 var(--r) var(--r); }
.typing-hint { font-size: .74rem; color: var(--faint); padding: 0 16px 6px; background: var(--surface); }

.pager { display: flex; gap: 6px; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--line); }
.pager a { min-width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; border: 1px solid var(--line); color: var(--text); font-variant-numeric: tabular-nums; }
.pager a.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }

.welcome { background: var(--ink); color: var(--on-dark); border-radius: var(--r); padding: 26px 28px; display: flex; gap: 20px; align-items: center; justify-content: space-between; flex-wrap: wrap; position: relative; overflow: hidden; isolation: isolate; }
.welcome::before { content: ""; position: absolute; inset: 0; z-index: -1; background: radial-gradient(500px 220px at 90% 0%, rgba(44, 198, 238, .22), transparent 60%), radial-gradient(400px 200px at 0% 100%, rgba(20, 99, 255, .35), transparent 60%); }
.welcome h2 { color: #fff; font-size: 1.35rem; }
.welcome p { color: var(--on-dark-muted); margin-top: 4px; }
.welcome .btn { border-color: #fff; }

.utm-out { font-family: var(--f-mono); font-size: .84rem; word-break: break-all; background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: 10px; padding: 12px; direction: ltr; text-align: left; }

/* ---------- صفحات الدخول ---------- */
body.auth { background: var(--surface); }
.auth-wrap { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); min-height: 100%; }
.auth-art { background: var(--ink); color: var(--on-dark); padding: 36px 44px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; isolation: isolate; }
.auth-art::before { content: ""; position: absolute; inset: 0; z-index: -1;
  background-image: linear-gradient(rgba(234, 241, 255, .05) 1px, transparent 1px), linear-gradient(90deg, rgba(234, 241, 255, .05) 1px, transparent 1px);
  background-size: 48px 48px; -webkit-mask-image: radial-gradient(ellipse at 40% 50%, #000 30%, transparent 75%); mask-image: radial-gradient(ellipse at 40% 50%, #000 30%, transparent 75%); }
.auth-art::after { content: ""; position: absolute; inset: 0; z-index: -1; background: radial-gradient(600px 300px at 100% 0%, rgba(44, 198, 238, .2), transparent 60%), radial-gradient(500px 300px at 0% 100%, rgba(20, 99, 255, .35), transparent 60%); }
.auth-art-copy h2 { color: #fff; font-size: clamp(1.6rem, 2.6vw, 2.2rem); max-width: 16ch; }
.auth-art-copy ul { display: grid; gap: 12px; margin-top: 26px; }
.auth-art-copy li { display: flex; gap: 10px; align-items: center; color: var(--on-dark); }
.auth-art-copy .i { color: var(--cyan); }
.auth-art .coords { font-family: var(--f-mono); font-size: .76rem; color: #6F80A3; }
[dir="rtl"] .auth-art .coords { text-align: right; }
.auth-main { display: flex; flex-direction: column; padding: 26px max(28px, env(safe-area-inset-right, 0px)) 40px max(28px, env(safe-area-inset-left, 0px)); padding-top: calc(26px + env(safe-area-inset-top, 0px)); }
.auth-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.back-link { color: var(--muted); font-weight: 500; }
.auth-card { width: 100%; max-width: 440px; margin: auto; padding-block: 36px; display: grid; gap: 18px; }
.auth-card h1 { font-size: 1.8rem; }
.auth-sub { color: var(--muted); margin-top: -8px; }
.auth-alt { text-align: center; color: var(--muted); font-size: .94rem; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-inline-end: 64px !important; }
.pw-toggle { position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--muted); font: 600 .82rem var(--f-body); padding: 6px 8px; cursor: pointer; border-radius: 8px; }
.pw-toggle:hover { color: var(--text); background: var(--surface-2); }

/* ---------- التجاوب ---------- */
@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .stepper { grid-template-columns: repeat(5, minmax(0, 1fr)); row-gap: 18px; }
  .stepper li:nth-child(5)::before { display: none; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset-block: 0; inset-inline-start: 0; width: min(290px, 86vw); z-index: 60; transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow); }
  [dir="rtl"] .side { transform: translateX(100%); }
  .side.is-open { transform: none !important; }
  .side-scrim { display: block; position: fixed; inset: 0; background: rgba(5, 15, 38, .45); z-index: 55; }
  .side-scrim[hidden] { display: none; }
  .topbar .menu-toggle { display: grid; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-art { display: none; }
}
@media (max-width: 640px) {
  .topbar { padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: max(14px, env(safe-area-inset-right, 0px)); gap: 10px; }
  .topbar h1 { font-size: 1.08rem; }
  .top-actions .btn { display: none; }
  .content { padding: 16px max(14px, env(safe-area-inset-right, 0px)) 36px max(14px, env(safe-area-inset-left, 0px)); gap: 16px; }
  .kpis { gap: 10px; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 1.45rem; }
  .form-row, .choice-grid { grid-template-columns: minmax(0, 1fr); }
  .stepper { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stepper li:nth-child(5)::before { display: block; }
  .stepper li:nth-child(3n)::before { display: none; }
  .bubble-row { max-width: 92%; }
  .chat { height: calc(100dvh - 150px); min-height: 380px; }
  .search input { min-width: 0; width: 100%; }
  .toolbar form, .search { width: 100%; }
  .dl { grid-template-columns: 1fr; gap: 2px 0; }
  .dl dd { margin-bottom: 10px; }
  .t th, .t td { padding: 10px 12px; }
  .hide-sm { display: none; }
  .welcome { padding: 20px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* اختيار أيقونة النظام */
.icon-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.icon-pick label { position: relative; cursor: pointer; }
.icon-pick input { position: absolute; opacity: 0; inset: 0; }
.icon-pick span { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; border: 1.5px solid var(--line, #E1E6EF); color: #55647E; }
.icon-pick svg { width: 22px; height: 22px; }
.icon-pick input:checked + span { border-color: #1463FF; color: #1463FF; background: rgba(20, 99, 255, .06); }
.icon-pick input:focus-visible + span { outline: 3px solid #2CC6EE; outline-offset: 2px; }
