/* =============================================================================
   Daily Monitoring System — Dashboard (premium redesign)
   New, original enterprise UI. RTL-first. Light/Dark via design tokens.
   Pure HTML/CSS/JS + Chart.js. No framework.
   ========================================================================== */

/* ---------- Design tokens ---------- */
:root {
  --font: "Tajawal", "Segoe UI", Tahoma, system-ui, -apple-system, sans-serif;

  --primary: #5b5bf0;
  --primary-600: #4f46e5;
  --primary-700: #4338ca;
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --grad-blue: linear-gradient(135deg, #0ea5e9 0%, #6366f1 100%);
  --grad-emerald: linear-gradient(135deg, #10b981 0%, #0ea5e9 100%);
  --grad-amber: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);

  --ok: #15a34a;       --ok-bg: rgba(21, 163, 74, .12);
  --warn: #d97706;     --warn-bg: rgba(217, 119, 6, .14);
  --danger: #e11d48;   --danger-bg: rgba(225, 29, 72, .12);
  --info: #0891b2;     --info-bg: rgba(8, 145, 178, .12);
  --violet: #7c3aed;

  --bg: #eaeef7;
  --bg-glow:
    radial-gradient(1100px 560px at 100% -8%, rgba(99, 102, 241, .14), transparent 60%),
    radial-gradient(820px 460px at -8% 6%, rgba(139, 92, 246, .12), transparent 60%);
  --surface: #ffffff;
  --surface-2: #f3f5fb;
  --surface-3: #eaeef7;
  --glass: rgba(255, 255, 255, .72);
  --border: #e6e9f3;
  --border-2: #d8dcec;
  --text: #0f1729;
  --text-2: #586079;
  --text-3: #8b93a8;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow: 0 6px 16px -6px rgba(16, 24, 40, .12), 0 12px 32px -12px rgba(16, 24, 40, .14);
  --shadow-lg: 0 24px 48px -16px rgba(31, 38, 70, .28);

  --r-xl: 20px; --r-lg: 16px; --r: 13px; --r-sm: 10px; --r-pill: 999px;
  --sidebar-w: 270px;
}

[data-theme="dark"] {
  --bg: #070b15;
  --bg-glow:
    radial-gradient(1100px 560px at 100% -8%, rgba(99, 102, 241, .20), transparent 60%),
    radial-gradient(820px 460px at -8% 6%, rgba(139, 92, 246, .14), transparent 60%);
  --surface: #101a30;
  --surface-2: #0c1426;
  --surface-3: #0a1120;
  --glass: rgba(16, 26, 48, .66);
  --border: #1d2840;
  --border-2: #273350;
  --text: #eef2fb;
  --text-2: #9aa6c2;
  --text-3: #69748f;
  --ok-bg: rgba(21, 163, 74, .18);
  --warn-bg: rgba(217, 119, 6, .2);
  --danger-bg: rgba(225, 29, 72, .2);
  --info-bg: rgba(8, 145, 178, .2);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 10px 26px -10px rgba(0, 0, 0, .55);
  --shadow-lg: 0 28px 56px -18px rgba(0, 0, 0, .7);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg-glow), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary-600); text-decoration: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: padding-box; }

.icon { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.sm { width: 16px; height: 16px; }
.icon.lg { width: 24px; height: 24px; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow: hidden;
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  padding: 16px 14px 24px;
  display: flex; flex-direction: column;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 10px 16px; margin-bottom: 6px;
}
.brand .logo {
  width: 44px; height: 44px; border-radius: 13px;
  background: var(--grad); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 18px;
  box-shadow: 0 8px 20px -6px rgba(99, 102, 241, .6);
}
.brand .brand-txt h1 { margin: 0; font-size: 15px; font-weight: 800; letter-spacing: -.01em; }
.brand .brand-txt span { color: var(--text-3); font-size: 11px; font-weight: 500; }

/* nav is the only scroll region inside the sidebar (brand + footer stay fixed) */
.nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; gap: 0; padding-inline: 2px; }
.nav::-webkit-scrollbar { width: 8px; }
.nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
.nav::-webkit-scrollbar-track { background: transparent; }
.nav-label {
  font-size: 10.5px; font-weight: 700; color: var(--text-3);
  letter-spacing: .08em; text-transform: uppercase;
  padding: 16px 12px 7px;
}

/* ---- nav filter ---- */
.nav-filter {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 7px 10px; margin: 2px 4px 8px;
}
.nav-filter .icon { color: var(--text-3); flex: none; }
.nav-filter input { border: 0; background: transparent; outline: 0; width: 100%; font: inherit; font-size: 13px; color: var(--text); }

/* ---- static groups (no collapse) ---- */
/* Overview sits directly under the filter, with a subtle divider below it */
.nav-lead { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.nav-group { display: flex; flex-direction: column; }
/* Plain, non-interactive section heading — bolder & clearer than the items */
.nav-group-head {
  font-size: 12px; font-weight: 800; color: var(--text-2);
  letter-spacing: .02em; cursor: default; user-select: none;
  padding: 16px 10px 7px;
}
.nav-group-body { display: flex; flex-direction: column; gap: 2px; }
.nav-group.filtered-out, .nav-lead.filtered-out { display: none; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--r-sm);
  color: var(--text-2); cursor: pointer; font-size: 14px; font-weight: 600;
  transition: background .15s, color .15s;
}
.nav-item .icon { width: 18px; height: 18px; color: var(--text-3); transition: color .15s; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item:hover .icon { color: var(--text-2); }
.nav-item.active { background: color-mix(in srgb, var(--primary) 9%, transparent); color: var(--primary-600); }
.nav-item.active .icon { color: var(--primary-600); }
/* Inset accent (kept inside the item so the nav's overflow clip can't hide it) */
.nav-item.active::before {
  content: ""; position: absolute; inset-inline-start: 4px; top: 50%;
  transform: translateY(-50%); width: 3px; height: 17px;
  background: var(--primary); border-radius: 999px;
}
/* Quiet count badge: neutral, compact, tabular; tints only when its row is active */
.nav-badge {
  margin-inline-start: auto; min-width: 19px; height: 19px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 700; line-height: 1;
  background: var(--surface-3); color: var(--text-2);
  border-radius: var(--r-pill); font-variant-numeric: tabular-nums;
}
/* `hidden` must beat the class's inline-flex (author styles override UA [hidden]). */
.nav-badge[hidden] { display: none; }
.nav-item.active .nav-badge { background: color-mix(in srgb, var(--primary) 16%, transparent); color: var(--primary-700); }
.sidebar-foot {
  margin-top: auto; padding: 12px;
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface-2);
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  background: var(--grad-blue); color: #fff; font-weight: 700;
  display: grid; place-items: center; font-size: 13px;
}
.sidebar-foot .who { font-size: 13px; font-weight: 700; line-height: 1.2; }
.sidebar-foot .role { font-size: 11px; color: var(--text-3); }

/* ---------- Main ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 26px;
  background: var(--glass);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar .menu-btn { display: none; }
.titlebox .eyebrow { font-size: 11px; font-weight: 700; color: var(--primary-600); letter-spacing: .06em; text-transform: uppercase; }
.titlebox h2 { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -.02em; }
.spacer { flex: 1; }

.search {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 8px 14px; border-radius: var(--r-pill); min-width: 230px;
  color: var(--text-3); transition: border-color .15s, box-shadow .15s;
}
.search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91, 91, 240, .14); }
.search input { border: none; background: transparent; color: var(--text); outline: none; width: 100%; font-family: var(--font); font-size: 13.5px; }

.icon-btn {
  position: relative;
  width: 40px; height: 40px; border-radius: 11px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
  cursor: pointer; display: grid; place-items: center; transition: all .15s;
}
.icon-btn:hover { color: var(--primary-600); border-color: var(--primary); transform: translateY(-1px); }
.icon-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
/* Bell unread badge: hidden until there is a count, then a compact numeric pill. */
.icon-btn .dot-badge {
  position: absolute; top: 3px; inset-inline-end: 3px;
  min-width: 17px; height: 17px; padding: 0 4px; display: none;
  align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; line-height: 1; color: #fff;
  background: var(--danger); border: 2px solid var(--surface);
  border-radius: 999px; font-variant-numeric: tabular-nums;
}
.icon-btn .dot-badge.show { display: inline-flex; }

/* Authenticated-user badge: a calm, neutral chip (not a loud "demo" warning) */
#userBadge { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
#userBadge .icon { color: var(--text-3); }

.content { padding: 26px; max-width: 1500px; width: 100%; margin: 0 auto; }
.page { display: none; }
.page.active { display: block; animation: rise .3s cubic-bezier(.2, .7, .2, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Section header ---------- */
.sec { display: flex; align-items: flex-end; gap: 12px; margin: 6px 2px 18px;
  position: relative; padding-inline-start: 15px; }
/* prominent accent bar on every page title (shared touch across all pages) */
.sec::before { content: ""; position: absolute; inset-inline-start: 0; top: 3px; bottom: 4px;
  width: 5px; border-radius: 4px; background: linear-gradient(180deg, var(--primary), var(--primary-700));
  box-shadow: 0 1px 4px color-mix(in srgb, var(--primary) 45%, transparent); }
.sec .eyebrow { font-size: 11px; font-weight: 700; color: var(--primary-600); letter-spacing: .06em; text-transform: uppercase; }
.sec h3 { margin: 2px 0 0; font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.sec p { margin: 2px 0 0; color: var(--text-3); font-size: 12.5px; }
.sec .actions { margin-inline-start: auto; display: flex; gap: 8px; }

/* ---------- KPI ---------- */
.kpis { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); margin-bottom: 18px; }
.kpi {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 18px; box-shadow: var(--shadow-sm);
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--border-2); }
.kpi .ic {
  width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; color: #fff; margin-bottom: 14px;
}
.kpi .ic.g1 { background: var(--grad); }
.kpi .ic.g2 { background: var(--grad-blue); }
.kpi .ic.g3 { background: var(--grad-emerald); }
.kpi .ic.g4 { background: var(--grad-amber); }
.kpi .ic.g5 { background: linear-gradient(135deg, #ec4899, #8b5cf6); }
.kpi .ic.g6 { background: linear-gradient(135deg, #14b8a6, #6366f1); }
.kpi .label { color: var(--text-2); font-size: 13px; font-weight: 600; }
.kpi .value { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: var(--r-pill); }
.delta.up { background: var(--ok-bg); color: var(--ok); }
.delta.down { background: var(--danger-bg); color: var(--danger); }
.delta.flat { background: var(--surface-3); color: var(--text-3); }
.kpi .foot small { color: var(--text-3); font-size: 11.5px; }

/* ---------- Grid + cards ---------- */
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid.c12 { grid-template-columns: 1.6fr 1fr; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm); padding: 18px; min-width: 0;
}
.card.pad-lg { padding: 22px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.card-head .ic-chip { width: 34px; height: 34px; border-radius: 10px; background: var(--surface-2); color: var(--primary-600); display: grid; place-items: center; }
.card-head h4 { margin: 0; font-size: 15px; font-weight: 700; }
.card-head .sub { font-size: 12px; color: var(--text-3); }
.card-head .head-actions { margin-inline-start: auto; display: flex; gap: 8px; align-items: center; }

.chart-wrap { position: relative; width: 100%; height: 300px; }
.chart-wrap.tall { height: 360px; }
.chart-wrap canvas { max-width: 100%; }
.donut-center { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; text-align: center; }
.donut-center b { font-size: 26px; font-weight: 800; display: block; font-variant-numeric: tabular-nums; }
.donut-center span { font-size: 11.5px; color: var(--text-3); }

/* ---------- Chips / pills / badges ---------- */
.badge { font-size: 11px; font-weight: 700; padding: 4px 11px; border-radius: var(--r-pill); }
.badge.demo { background: var(--warn-bg); color: var(--warn); display: inline-flex; align-items: center; gap: 5px; }
.badge.live { background: var(--ok-bg); color: var(--ok); }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.tag { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 10px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary-600); }
.pill { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: var(--r-pill); display: inline-flex; align-items: center; gap: 5px; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok, .pill.completed, .pill.approved, .pill.active { background: var(--ok-bg); color: var(--ok); }
.pill.pending, .pill.running { background: var(--warn-bg); color: var(--warn); }
.pill.error, .pill.rejected, .pill.failed, .pill.completed_with_errors { background: var(--danger-bg); color: var(--danger); }
.pill.skipped, .pill.mock, .pill.muted { background: var(--surface-3); color: var(--text-3); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
thead th {
  position: sticky; top: 0;
  text-align: start; padding: 10px 14px; color: var(--text-3);
  font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
.cell-acct { display: flex; align-items: center; gap: 10px; }
.cell-acct .ava { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; flex: none; }
.cell-acct .nm { font-weight: 700; }
.cell-acct .hd { font-size: 11.5px; color: var(--text-3); }
.bar { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; min-width: 70px; }
.bar > i { display: block; height: 100%; background: var(--grad); border-radius: 999px; }

/* ---------- Alerts ---------- */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 13px 15px; border-radius: var(--r); margin-bottom: 10px; border: 1px solid var(--border); background: var(--surface-2); }
.alert:last-child { margin-bottom: 0; }
.alert .a-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; color: #fff; }
.alert.info .a-ic { background: var(--grad-blue); }
.alert.warning .a-ic { background: var(--grad-amber); }
.alert.danger .a-ic { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.alert strong { display: block; font-size: 13.5px; font-weight: 700; }
.alert span { color: var(--text-2); font-size: 13px; }

/* ---------- Empty / skeleton ---------- */
.empty { text-align: center; color: var(--text-3); padding: 36px 18px; }
.empty .em-ic { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 16px; background: var(--surface-2); display: grid; place-items: center; color: var(--text-3); }
.empty p { margin: 0; font-size: 13.5px; }
.skel { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.skel-line { height: 14px; margin: 8px 0; }
.skel-kpi { height: 122px; border-radius: var(--r-lg); }

/* ---------- Forms ---------- */
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field input, .field select, .field textarea {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--r-sm); padding: 10px 12px; font-family: var(--font); font-size: 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91, 91, 240, .14); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 3px; gap: 3px; }
.seg button { border: none; background: transparent; color: var(--text-2); font-family: var(--font); font-size: 13px; font-weight: 600; padding: 7px 14px; border-radius: 8px; cursor: pointer; transition: all .15s; }
.seg button.on { background: var(--surface); color: var(--primary-600); box-shadow: var(--shadow-sm); }

.btn { display: inline-flex; align-items: center; gap: 8px; background: var(--grad); color: #fff; border: none; cursor: pointer; padding: 11px 20px; border-radius: var(--r-sm); font-weight: 700; font-size: 14px; font-family: var(--font); box-shadow: 0 8px 18px -8px rgba(99, 102, 241, .7); transition: transform .15s, box-shadow .15s; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 12px 24px -8px rgba(99, 102, 241, .8); }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.btn.ghost:hover { border-color: var(--primary); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

.note { font-size: 12.5px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-inline-start: 3px solid var(--primary); border-radius: var(--r-sm); padding: 11px 14px; }
.note code { background: var(--surface-3); padding: 1px 6px; border-radius: 5px; font-size: 12px; }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; height: 440px; }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 6px 4px; }
.msg { max-width: 78%; padding: 11px 14px; border-radius: 16px; font-size: 13.8px; white-space: pre-wrap; line-height: 1.6; }
.msg.user { align-self: flex-start; background: var(--grad); color: #fff; border-end-start-radius: 5px; }
.msg.bot { align-self: flex-end; background: var(--surface-2); border: 1px solid var(--border); border-end-end-radius: 5px; }
.msg .cites { margin-top: 9px; padding-top: 8px; border-top: 1px dashed var(--border-2); font-size: 11.5px; color: var(--text-3); display: flex; gap: 6px; flex-wrap: wrap; }
.msg .cites .tag { font-size: 10.5px; }
.suggests { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 4px; }
.suggest { font-size: 12.5px; font-weight: 600; padding: 7px 13px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); cursor: pointer; transition: all .15s; }
.suggest:hover { border-color: var(--primary); color: var(--primary-600); }
.chat-input { display: flex; gap: 9px; margin-top: 12px; }
.chat-input input { flex: 1; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: var(--r-pill); padding: 12px 18px; font-family: var(--font); font-size: 14px; outline: none; }
.chat-input input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91, 91, 240, .14); }
.chat-input .btn { border-radius: var(--r-pill); padding: 0 18px; }

/* ---------- Hero strip (overview top) ---------- */
.hero {
  position: relative; overflow: hidden;
  background: var(--grad); color: #fff;
  border-radius: var(--r-xl); padding: 22px 24px; margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.hero::after { content: ""; position: absolute; inset-inline-end: -40px; top: -60px; width: 240px; height: 240px; background: radial-gradient(circle, rgba(255,255,255,.22), transparent 70%); }
.hero .h-row { position: relative; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.hero h3 { margin: 0; font-size: 20px; font-weight: 800; }
.hero p { margin: 4px 0 0; opacity: .9; font-size: 13.5px; }
.hero .h-stat { margin-inline-start: auto; display: flex; gap: 22px; }
.hero .h-stat .s b { font-size: 22px; font-weight: 800; display: block; font-variant-numeric: tabular-nums; }
.hero .h-stat .s span { font-size: 12px; opacity: .85; }

/* ---------- Evidence cards (internal review view) ---------- */
.nx-hidden { display: none !important; }
.more-row { text-align: center; margin-top: 10px; }
.more-row .btn { padding: 7px 16px; font-size: 13px; }
/* responsive 2-up grid on wide screens; single column on small */
.evidence-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(440px, 1fr)); gap: 16px; align-items: start; }
/* Each item card carries its own accent via --ev-accent; the card border, the
   number/volume badges and the evidence list all share it, so the reader instantly
   ties an item to its evidence group. */
.ev-card { margin: 0; padding: 16px 18px; border-inline-start: 3px solid var(--ev-accent, var(--border));
  scroll-margin-top: 84px; /* land below the sticky topbar when jumped-to */ }
.ev-card-head { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin-bottom: 10px;
  padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.ev-card-head strong { font-size: 14.5px; }
.ev-num { font-size: 11px; font-weight: 800; padding: 2px 9px; border-radius: var(--r-pill);
  color: var(--ev-accent, var(--primary-600));
  background: color-mix(in srgb, var(--ev-accent, var(--primary)) 14%, transparent); }
.ev-volume { font-size: 11.5px; font-weight: 700; padding: 2px 10px; border-radius: var(--r-pill);
  color: var(--ev-accent, var(--primary-700));
  background: color-mix(in srgb, var(--ev-accent, var(--primary)) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--ev-accent, var(--primary)) 30%, transparent); }
.ev-list { border-inline-start: 2px solid color-mix(in srgb, var(--ev-accent, var(--primary)) 30%, transparent);
  padding-inline-start: 12px; margin-inline-start: 2px; }
.ev-row { padding: 10px 0; border-top: 1px dashed var(--border); }
.ev-row:first-child { border-top: none; padding-top: 2px; }
.ev-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ev-snippet { margin: 5px 0; line-height: 1.75; }
/* Folded original tweet text under an AI description (reports page). */
.ev-orig { margin: 2px 0 4px; }
.ev-orig > summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--text-2);
  list-style: none; user-select: none; display: inline-flex; align-items: center; gap: 5px; }
.ev-orig > summary::-webkit-details-marker { display: none; }
.ev-orig > summary::before { content: "▾"; font-size: 10px; opacity: .7; }
.ev-orig[open] > summary::before { content: "▴"; }
.ev-orig-text { margin: 5px 0 2px; line-height: 1.75; color: var(--text-2);
  padding-inline-start: 9px; border-inline-start: 2px dashed var(--border); }
.ev-metrics { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.ev-metric { font-size: 11.5px; font-weight: 600; color: var(--text-2); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--r-pill); padding: 2px 9px; font-variant-numeric: tabular-nums; }
.ev-link { margin-top: 4px; }
.ev-open { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700;
  color: var(--primary-600); background: color-mix(in srgb, var(--primary) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent); border-radius: var(--r-sm); padding: 5px 11px; }
.ev-open:hover { background: color-mix(in srgb, var(--primary) 16%, transparent); }
@media (max-width: 560px) { .evidence-grid { grid-template-columns: 1fr; } }

/* ---------- Report text items (latest-report card) ---------- */
.rep-heading { font-size: 13px; font-weight: 800; color: var(--text-2); margin: 10px 0 6px; }
.rep-items { display: flex; flex-direction: column; gap: 10px; }
.rep-item { border: 1px solid var(--border); border-radius: var(--r); padding: 12px 14px;
  border-inline-start: 3px solid var(--ev-accent, var(--border)); background: var(--surface); }
.rep-item-head { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin-bottom: 7px; }
.rep-item-text { line-height: 1.95; }
/* Where this بند landed in the hierarchy — links to «مراجعة التصنيف». */
.rep-cls { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: var(--r-pill);
  cursor: pointer; font-family: inherit; color: var(--text-2);
  background: var(--surface-2); border: 1px dashed var(--border); }
.rep-cls:hover { color: var(--primary-700); border-color: var(--primary); border-style: solid; }
.rep-cls-unc { color: var(--warn, #b45309); }
/* Third action: jump to this item's evidence group */
.rep-jump { margin-inline-start: auto; font-size: 11.5px; font-weight: 700; cursor: pointer;
  color: var(--ev-accent, var(--primary-600)); font-family: inherit;
  background: color-mix(in srgb, var(--ev-accent, var(--primary)) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--ev-accent, var(--primary)) 35%, transparent);
  border-radius: var(--r-pill); padding: 3px 11px; transition: background .15s; }
.rep-jump:hover { background: color-mix(in srgb, var(--ev-accent, var(--primary)) 18%, transparent); }
/* ---------- Reject-reason picker (closed list) ---------- */
.reason-overlay { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center;
  justify-content: center; background: rgba(0,0,0,.42); padding: 16px; }
.reason-box { width: min(440px, 96vw); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: 0 14px 40px rgba(0,0,0,.28); padding: 16px; }
.reason-title { font-weight: 800; font-size: 15px; margin-bottom: 4px; }
.reason-hint { color: var(--text-2); font-size: 12.5px; margin-bottom: 10px; }
.reason-opts { display: flex; flex-direction: column; gap: 6px; }
.reason-opt { display: flex; flex-direction: column; gap: 2px; text-align: start; font: inherit;
  font-size: 13.5px; cursor: pointer; padding: 8px 12px; border-radius: var(--r);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }
.reason-opt:hover { border-color: var(--primary); }
.reason-opt.sel { background: var(--primary); color: #fff; border-color: var(--primary); }
.reason-opt-h { font-size: 11.5px; color: var(--text-2); font-weight: 400; }
.reason-opt.sel .reason-opt-h { color: rgba(255,255,255,.85); }
.reason-note { width: 100%; margin-top: 10px; font: inherit; font-size: 13px; line-height: 1.7;
  border-radius: var(--r); border: 1px solid var(--border); padding: 8px; resize: vertical; }
.reason-act { display: flex; gap: 8px; margin-top: 12px; justify-content: flex-start; }
/* ---------- Reorder mode (drag البنود in «التقارير والاعتماد») ---------- */
.rep-reorder-toggle { font-size: 12px; font-weight: 700; cursor: pointer; font-family: inherit;
  color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-pill); padding: 4px 12px; transition: all .15s; }
.rep-reorder-toggle:hover { color: var(--primary-700); border-color: var(--primary); }
.rep-reorder-toggle.active { color: #fff; background: var(--primary); border-color: var(--primary); }
.rep-drag-handle { display: none; cursor: grab; user-select: none; font-size: 15px; line-height: 1;
  color: var(--text-3, var(--text-2)); padding: 0 4px; touch-action: none; }
.rep-items.reordering .rep-drag-handle { display: inline-block; }
.rep-items.reordering .rep-item { cursor: grab; box-shadow: 0 1px 0 var(--border); }
.rep-items.reordering .rep-item:active,
.rep-items.reordering .rep-drag-handle:active { cursor: grabbing; }
.rep-item.rep-dragging { opacity: .45; }
.rep-item.rep-drop-target { box-shadow: 0 -3px 0 -1px var(--primary) inset, 0 0 0 1px var(--primary); }
.rep-reorder-bar { position: sticky; bottom: 8px; z-index: 5; display: flex; gap: 8px; align-items: center;
  margin-top: 12px; padding: 9px 12px; border-radius: var(--r); background: var(--surface);
  border: 1px solid var(--primary); box-shadow: 0 6px 20px rgba(0,0,0,.12); }
.rep-reorder-bar .muted { margin-inline-end: auto; }
/* Groups بند reorder — reuses .rep-reorder-toggle / .rep-reorder-bar / .rep-dragging */
.fbgi-drag-handle { display: none; cursor: grab; user-select: none; font-size: 15px; line-height: 1;
  color: var(--text-3, var(--text-2)); padding: 0 2px; touch-action: none; }
.reordering .fbgi-drag-handle { display: inline-block; }
.reordering .fbgi-card { cursor: grab; }
.reordering .fbgi-card:active, .reordering .fbgi-drag-handle:active { cursor: grabbing; }
/* Brief highlight on the targeted evidence card */
.ev-flash { animation: evFlash 1.6s ease; }
@keyframes evFlash {
  0%, 100% { box-shadow: none; }
  15% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ev-accent, var(--primary)) 55%, transparent); }
  70% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ev-accent, var(--primary)) 30%, transparent); }
}

/* ---------- Combined export toolbar ---------- */
.combined-export { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.combined-export .muted-h { margin: 0; }
.combined-export .btn { padding: 8px 14px; font-size: 13px; }

/* Unified export toolbar (section picker + variant toggle + actions + share) */
.exp2 { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.exp-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.exp-lbl { font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.exp-chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600;
  color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 9px; padding: 6px 11px; cursor: pointer; user-select: none; }
.exp-chk:hover { border-color: var(--primary); }
.exp-chk input { accent-color: var(--primary); margin: 0; cursor: pointer; }
.exp-div { width: 1px; align-self: stretch; background: var(--border); margin: 0 4px; }
.exp-var button { padding: 6px 13px; font-size: 12.5px; }
.exp-more { font-size: 12px; color: var(--text-2); margin-inline-start: 4px; }
.exp-link { border: none; background: none; color: var(--primary-600); font-family: var(--font);
  font-weight: 700; font-size: 12.5px; cursor: pointer; padding: 2px 3px; }
.exp-link:hover { text-decoration: underline; }
.exp-share { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 9px 11px; }
.exp-ok { font-size: 12.5px; font-weight: 700; color: var(--primary-600); }
.exp-url { flex: 1 1 240px; min-width: 200px; font-size: 12px; direction: ltr;
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px;
  background: var(--surface); color: var(--text); font-family: var(--font); }
.exp-share a.btn { text-decoration: none; }

/* ---------- Misc ---------- */
.mt { margin-top: 16px; }
.scrim { display: none; }
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.muted-h { font-size: 12.5px; font-weight: 700; color: var(--text-2); text-transform: uppercase;
  letter-spacing: .04em; margin: 18px 0 10px; border-inline-start: 3px solid var(--primary);
  padding-inline-start: 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) { .grid.c12 { grid-template-columns: 1fr; } }
@media (max-width: 920px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset-inline-start: 0; top: 0; z-index: 70; width: var(--sidebar-w); transform: translateX(100%); transition: transform .28s cubic-bezier(.2,.7,.2,1); box-shadow: var(--shadow-lg); }
  [dir="ltr"] .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .topbar .menu-btn { display: grid; }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(7, 11, 21, .5); backdrop-filter: blur(2px); z-index: 60; }
  .hero .h-stat { width: 100%; margin: 6px 0 0; }
}
@media (max-width: 560px) {
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .search { display: none; }
  .titlebox h2 { font-size: 16px; }
  .kpi .value { font-size: 25px; }
  .chart-wrap { height: 250px; }
  .hero .h-stat { gap: 16px; }
}

/* Methodology diff viewer */
.diff-box {
  border: 1px solid var(--line, #e5e7eb); border-radius: 8px; overflow: auto;
  max-height: 360px; font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12.5px; line-height: 1.6; direction: ltr; text-align: left;
  background: var(--card-bg, #fff); margin-top: 6px;
}
.diff-box > div { padding: 0 10px; white-space: pre-wrap; word-break: break-word; }
.diff-add { background: var(--ok-bg, #ecfdf5); color: var(--ok, #047857); }
.diff-del { background: var(--warn-bg, #fef2f2); color: #b91c1c; }
.diff-hunk { background: var(--grad-blue, #eff6ff); color: #1d4ed8; font-weight: 600; }
.diff-ctx { color: var(--muted, #6b7280); }

/* Methodology doc modal */
.mdl {
  position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center;
  justify-content: center; padding: 24px;
  background: rgba(7, 11, 21, .55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.mdl-card {
  background: var(--card-bg, #fff); border: 1px solid var(--line, #e5e7eb);
  border-radius: 16px; box-shadow: var(--shadow-lg, 0 20px 50px rgba(7,11,21,.3));
  width: min(940px, 96vw); max-height: 90vh; display: flex; flex-direction: column; overflow: hidden;
  animation: mdlIn .16s cubic-bezier(.2,.7,.2,1);
}
@keyframes mdlIn { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.mdl-head {
  display: flex; align-items: center; gap: 8px; padding: 14px 18px;
  border-bottom: 1px solid var(--line, #e5e7eb); flex-wrap: wrap;
}
.mdl-body { padding: 16px 18px; overflow: auto; }
.mdl-x {
  background: transparent; border: 0; cursor: pointer; color: var(--muted, #6b7280);
  width: 34px; height: 34px; border-radius: 9px; font-size: 17px; line-height: 1; flex: none;
}
.mdl-x:hover { background: var(--soft, #f1f5f9); color: var(--text, #0f172a); }

/* ---- Contextual grouping review ---- */
/* color-coded bundle cards — same treatment as the classification domains */
.grp-card { padding: 0; margin-bottom: 14px; overflow: hidden;
  border: 1px solid var(--border); border-inline-start: 5px solid var(--dc, var(--primary)); border-radius: 12px; }
.grp-head { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: color-mix(in srgb, var(--dc, var(--primary)) 12%, var(--surface));
  padding: 10px 14px; margin: 0; border-bottom: 1px solid var(--border); }
.grp-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grp-rank { width: 22px; height: 22px; border-radius: 50%; flex: 0 0 auto;
  background: var(--dc, var(--primary)); color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 12px; box-shadow: 0 1px 3px rgba(0, 0, 0, .18); }
.grp-name { font-size: 15.5px; font-weight: 800; color: var(--dc, var(--primary)); }
.grp-card-basket { --dc: var(--text-3); }
/* Reviewer-confirmed fold: recolour the whole card green (via --dc) so «what's done»
   is scannable at a glance, plus the «✓ مؤكَّد» chip where the button was. */
.grp-card.confirmed { --dc: var(--ok); }
.grp-card.confirmed .grp-head { background: var(--ok-bg); }
/* Confirmed = a green TOGGLE button; hover strikes it through to hint «اضغط للتراجع». */
.file-unconfirm { white-space: nowrap; font-weight: 700;
  background: var(--ok-bg); color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.file-unconfirm:hover { text-decoration: line-through; }
.grp-body { padding: 6px 14px 10px; }
.grp-head-act { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grp-row { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start;
  padding: 6px 0; border-bottom: 1px dashed var(--border, #eef0f2); }
.grp-row:last-child { border-bottom: 0; }
.grp-row.review { background: rgba(245, 158, 11, .10); border-radius: 6px; padding-inline: 6px; }
.grp-txt { flex: 1; font-size: 13px; line-height: 1.65; }
.grp-why { font-size: 11px; }
/* handle -> permalink, plus the publish time, so a tweet can be dated and opened */
.grp-handle { font-weight: 800; color: var(--primary-600); white-space: nowrap; }
.grp-handle:hover { text-decoration: underline; }
.grp-when { font-size: 11px; color: var(--text-3); white-space: nowrap;
  font-variant-numeric: tabular-nums; margin-inline-end: 4px; }
.grp-act { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.grp-move, .grp-merge { font-size: 12px; padding: 3px 5px; border-radius: 7px; }
.pill.grp-c-low { background: #f8d7da; color: #842029; }
.pill.grp-c-medium { background: #fff3cd; color: #664d03; }
.pill.grp-c-high { background: #d1e7dd; color: #0f5132; }
/* ---- grouping toolbar (sticky) + run picker + search + nav chips ---- */
.grp-toolbar { position: sticky; top: 0; z-index: 6; margin: 8px 0 4px;
  background: var(--surface); box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
  border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px; }
.grp-tb-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grp-tb-lbl { font-size: 13px; font-weight: 700; color: var(--text-2); white-space: nowrap; }
.grp-runsel { font-size: 13px; font-weight: 600; padding: 6px 8px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); max-width: 340px; }
.grp-search { flex: 1 1 220px; min-width: 160px; font-size: 13px; padding: 6px 10px;
  border-radius: 9px; border: 1px solid var(--border); background: var(--bg, var(--surface)); color: var(--text); }
.grp-hint { font-size: 11px; white-space: nowrap; }
@media (max-width: 640px) { .grp-hint { display: none; } .grp-runsel { max-width: 100%; } }
/* quick jump-to-bundle chips */
.grp-nav { display: flex; gap: 6px; overflow-x: auto; padding: 6px 2px 10px; scrollbar-width: thin; }
.grp-chip { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; cursor: pointer;
  font-size: 12px; padding: 4px 9px; border-radius: 999px; color: var(--text-2);
  border: 1px solid var(--border); border-inline-start: 3px solid var(--dc, var(--primary));
  background: color-mix(in srgb, var(--dc, var(--primary)) 8%, var(--surface)); }
.grp-chip:hover { background: color-mix(in srgb, var(--dc, var(--primary)) 18%, var(--surface)); }
.grp-chip-n { font-weight: 800; color: var(--dc, var(--primary)); }
.grp-chip-t { max-width: 190px; overflow: hidden; text-overflow: ellipsis; }
.grp-chip b { color: var(--dc, var(--primary)); }
/* collapsible bundle head */
.grp-toggle { cursor: pointer; user-select: none; }
.grp-toggle:hover { background: color-mix(in srgb, var(--dc, var(--primary)) 18%, var(--surface)); }
.grp-caret { font-size: 11px; width: 14px; display: inline-block; color: var(--dc, var(--primary)); }
.grp-basket-toggle { font-weight: 700; }
/* Below-threshold drawer (in-scope bundles < min accounts — can't become بنود) */
.grp-below { margin-top: 10px; }
.grp-below-toggle { font-weight: 700; color: var(--text-2); }
.grp-below-body { margin-top: 8px; opacity: .9; }
/* Multi-select merge (checkbox on each in-scope card + floating bar) */
.grp-pick { display: inline-flex; align-items: center; cursor: pointer; }
.grp-pick input { width: 16px; height: 16px; cursor: pointer; }
.grp-merge-bar { position: sticky; bottom: 10px; z-index: 6; display: flex; gap: 8px; align-items: center;
  flex-wrap: wrap; margin: 12px 0 0; padding: 9px 12px; border-radius: var(--r); background: var(--surface);
  border: 1px solid var(--primary); box-shadow: 0 6px 20px rgba(0,0,0,.14); }
.grp-merge-bar span { margin-inline-end: auto; font-size: 13px; }
/* File-assignment export/import bar (طبقة الملفّ) */
.file-io-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin: 0 0 12px; padding: 8px 10px; border-radius: var(--r);
  background: var(--surface-2, var(--surface)); border: 1px dashed var(--border); }
.file-io-bar .grp-hint { margin-inline-start: auto; font-size: 12px; }
.file-io-bar label.btn { cursor: pointer; }
/* rejecting an item is destructive-ish (undoable) — mark it, don't hide it */
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn.danger:hover { background: var(--danger-bg); }
.item-disposal:not(:empty) { margin-top: 4px; }
/* multi-select for merging items */
.item-pick { cursor: pointer; margin-inline-end: 2px; }
.item-pick input { transform: scale(1.15); vertical-align: -1px; }
/* درجة الخطورة — increasing severity */
.pill.risk-low { background: #e7eefc; color: #2952a3; }
.pill.risk-medium { background: #fff3cd; color: #664d03; }
.pill.risk-high { background: #ffe0cc; color: #9a4a12; }
.pill.risk-critical { background: #f8d7da; color: #842029; }
.fb-risk, .fb-act, .fb-status { font-size: 12px; padding: 3px 6px; border-radius: 7px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text); max-width: 160px; }
/* per-page daily summary inside the Facebook report cards (the "بند" body) */
.fb-page-summary { font-size: 13.5px; line-height: 1.85; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 8px 0 10px; }
.fb-page-link { text-decoration: none; color: var(--primary-600); }
.fb-page-link:hover { text-decoration: underline; }
.ev-sub { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; margin: 4px 0 6px; }
/* Facebook daily-stats panel */
.fbst-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.fbst-kpi { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px; text-align: center; }
.fbst-kpi .v { font-size: 22px; font-weight: 800; color: var(--primary-600); }
.fbst-kpi .k { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.fbst-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.fbst-bar { margin-bottom: 9px; }
.fbst-h { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 3px; }
.fbst-track { background: var(--surface-3); border-radius: 8px; height: 11px; overflow: hidden; }
.fbst-fill { height: 100%; border-radius: 8px; }
@media (max-width: 720px) { .fbst-cols { grid-template-columns: 1fr; } }

/* ---- Item drafting review ---- */
.item-card { padding: 12px 14px; margin-bottom: 12px; }
.item-card.review { border-inline-start: 3px solid #f59e0b; }
/* البند الموصول (linked to predecessor): indented + a side connector so it reads as
   "branches from the item above" — contextually dependent, still its own card. */
.item-card.linked { border-inline-start: 3px solid #8b5cf6; margin-inline-start: 22px; position: relative; }
.item-card.linked::before { content: "↳"; position: absolute; inset-inline-start: -20px;
  top: 10px; color: #8b5cf6; font-size: 17px; font-weight: 700; }
.item-linkbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px;
  margin: 4px 0 8px; padding: 4px 8px; border-radius: 7px; background: rgba(139, 92, 246, .10); }
.item-linkbar.broken { background: rgba(217, 130, 11, .14); color: #9a3412; }
.item-linkbar select { font: inherit; font-size: 12px; padding: 2px 6px; border-radius: 6px;
  border: 1px solid var(--border, #e5e7eb); background: var(--bg, #fff); }
.link-phrase { color: #7c3aed; font-weight: 600; }
/* Linked بند in the COMPILED report (التقارير والاعتماد) — same branch treatment as the
   drafting card, so review matches export. */
.rep-item.rep-linked { margin-inline-start: 22px; border-inline-start: 3px solid #8b5cf6; position: relative; }
.rep-item.rep-linked::before { content: "↳"; position: absolute; inset-inline-start: -20px;
  top: 8px; color: #8b5cf6; font-weight: 700; }
.item-linkpick { display: inline-flex; align-items: center; gap: 6px; }
.item-linkpick select { font: inherit; font-size: 12px; padding: 2px 6px; border-radius: 6px;
  border: 1px solid var(--border, #e5e7eb); background: var(--bg, #fff); }
/* شطر البند: checkbox per tweet in the drilldown + the split toolbar. */
.tw-splitbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 6px 0 8px;
  padding: 5px 8px; border-radius: 7px; background: rgba(16, 185, 129, .10); font-size: 12px; }
.tw-search { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.tw-filter { flex: 1 1 auto; min-width: 0; font: inherit; font-size: 13px; padding: 6px 10px;
  border-radius: 8px; border: 1px solid var(--border, #e5e7eb); background: var(--bg, #fff); }
.tw-filter-count { flex: none; font-size: 12px; }
.tw-split-row { display: flex; align-items: flex-start; gap: 6px; }
.tw-split-row .tw-row { flex: 1 1 auto; min-width: 0; }
.tw-pick { flex: none; padding-top: 8px; cursor: pointer; }
/* Collapsed strip for rejected/merged بنود — slim, dimmed, in place (position kept). */
.item-card.collapsed { padding: 6px 12px; margin-bottom: 6px; opacity: .62; }
.item-card.collapsed:hover { opacity: .9; }
.item-strip { display: flex; align-items: center; gap: 8px; min-width: 0; }
.item-strip-idx { font-weight: 700; color: var(--text-3, #64748b); flex: none; }
.item-strip-txt { font-size: 12.5px; color: var(--text-3, #64748b);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto; min-width: 0; }
.item-strip .item-strip-expand { flex: none; }
.item-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border, #e5e7eb); padding-bottom: 8px; margin-bottom: 8px; }
.item-body { font-size: 14px; line-height: 1.9; margin-bottom: 8px; }
.item-evrow { font-size: 12px; margin-bottom: 8px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.item-ev { padding: 2px 6px; border-radius: 7px; background: var(--chip, #f1f5f9); text-decoration: none; }
.item-act { display: flex; gap: 8px; }
.pill.item-claims { background: #fff3cd; color: #664d03; }
.pill.item-review { background: #ffe3c2; color: #9a3412; }
.pill.item-self { background: #e0e7ff; color: #3730a3; }
.pill.item-cont { background: #cfe9dd; color: #14532d; }
.item-card.cont { border-inline-start: 3px solid #10b981; }
/* Self-anticipation note: COMPACT + collapsed by default (a one-line summary), so it
   flags without shouting; expand for the detail + the note-aware AI-improve shortcut. */
.item-selfcard-c { margin: 6px 0; border-inline-start: 3px solid #d9820b;
  background: #d9820b0f; border-radius: 6px; font-size: 12px; }
.item-selfcard-c > summary { cursor: pointer; padding: 5px 9px; font-weight: 600;
  color: #b8690a; list-style: none; user-select: none; }
.item-selfcard-c > summary::-webkit-details-marker { display: none; }
.item-selfcard-c[open] > summary { border-bottom: 1px solid #d9820b33; }
.item-selfcard-c .ssc-note { padding: 6px 9px; line-height: 1.7; }
.item-selfcard-c .ssc-act { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 9px 8px; }
.item-card.self { border-inline-start: 3px solid #6366f1; }
.item-selfnote { font-size: 12.5px; margin-bottom: 8px; padding: 6px 8px; border-radius: 7px;
  background: rgba(99, 102, 241, .08); color: var(--fg, #1f2937); }
/* inline editing (items + lessons) */
.edit-lbl { display: block; font-size: 12px; color: var(--muted, #6b7280); margin: 8px 0 4px; }
.item-edit-body, .item-edit-reason, .lesson-rationale, .lesson-rule-edit,
.rep-edit-body, .rep-edit-reason {
  width: 100%; box-sizing: border-box; font: inherit; font-size: 14px; line-height: 1.9;
  padding: 10px 12px; border: 1px solid var(--border, #d1d5db); border-radius: 8px;
  background: var(--bg, #fff); color: var(--fg, #1f2937); resize: vertical; }
.item-edit-body, .rep-edit-body { min-height: 130px; }
.item-edit-reason, .lesson-rationale, .lesson-rule-edit, .rep-edit-reason { min-height: 52px; }
.tw-desc { font-size: 13px; line-height: 1.75; margin: 2px 0; }
.tw-toggle { margin: 2px 0 4px; }
.tw-orig { font-size: 12.5px; line-height: 1.7; color: var(--muted, #6b7280);
  padding: 6px 8px; border-inline-start: 2px solid var(--border, #d1d5db);
  background: rgba(0,0,0,.02); border-radius: 6px; }
/* all-tweets list under an item */
.item-tweets:not(:empty) { margin-top: 10px; border-top: 1px dashed var(--border, #e5e7eb); padding-top: 8px; }
.tw-head { font-size: 12px; margin-bottom: 6px; }
.tw-row { padding: 7px 0; border-bottom: 1px dashed var(--border, #eef0f2); }
.tw-row:last-child { border-bottom: 0; }
.tw-meta { font-size: 12px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tw-meta a { text-decoration: none; }
.tw-text { font-size: 13px; line-height: 1.7; margin-top: 3px; }
.tw-more { margin-top: 8px; }

/* ---- Report statistics panel ---- */
.st-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
.st-tile { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; text-align: center; }
.st-tile-v { font-size: 22px; font-weight: 800; color: var(--primary); line-height: 1.1; }
.st-tile-l { font-size: 12px; color: var(--text-2); margin-top: 4px; }
.st-tile-s { font-size: 11px; }
.st-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.st-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.st-panel.st-wide { grid-column: 1 / -1; }
.st-panel h4 { margin: 0 0 10px; font-size: 13px; color: var(--text-2); font-weight: 700; }
.st-bar { display: grid; grid-template-columns: 1fr 90px auto; align-items: center; gap: 8px; margin: 5px 0; font-size: 12.5px; }
.st-bar-l { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-track { height: 9px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.st-fill { height: 100%; background: linear-gradient(90deg, var(--primary-700), var(--primary)); border-radius: 999px; }
.st-val { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text-2); min-width: 34px; text-align: left; }
.st-timeline { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 6px; direction: ltr; }
.st-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.st-col-fill { width: 70%; background: linear-gradient(180deg, var(--primary), var(--primary-700)); border-radius: 4px 4px 0 0; min-height: 0; }
.st-col-h { font-size: 9px; color: var(--text-3); margin-top: 3px; }
.st-ring { width: 130px; height: 130px; border-radius: 50%; margin: 6px auto;
  background: conic-gradient(var(--primary) calc(var(--pct) * 1%), var(--surface-3) 0);
  display: flex; align-items: center; justify-content: center; }
.st-ring-in { width: 92px; height: 92px; border-radius: 50%; background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.st-ring-in b { font-size: 24px; color: var(--primary); }
.st-ring-in span { font-size: 11px; }
/* hierarchical classification */
.cl-domain { margin-bottom: 14px; padding-inline-start: 10px;
  border-inline-start: 4px solid var(--dc, var(--primary)); }
.cl-dhead { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 4px; font-size: 13.5px; }
.cl-dname { display: inline-flex; align-items: center; gap: 7px; color: var(--dc, var(--primary)); font-weight: 800; }
.cl-ddot { width: 9px; height: 9px; border-radius: 50%; background: var(--dc, var(--primary)); flex: 0 0 auto; }
.cl-dfill { background: var(--dc, var(--primary)); }
.cl-afill { background: color-mix(in srgb, var(--dc, var(--primary)) 65%, var(--surface-3)); }
.cl-axes { margin: 6px 12px 0; padding-inline-start: 8px;
  border-inline-start: 2px solid color-mix(in srgb, var(--dc, var(--primary)) 35%, var(--border)); }
.cl-axis { display: grid; grid-template-columns: 1fr 120px auto; align-items: center; gap: 8px; margin: 4px 0; font-size: 12px; }
.cl-al { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-atrack { height: 7px; }
/* classification review page — color-coded domain cards (visual only) */
.cl-domcard { padding: 0; margin-bottom: 14px; overflow: hidden;
  border: 1px solid var(--border); border-inline-start: 5px solid var(--dc, var(--primary)); border-radius: 12px; }
.cl-dom-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  background: color-mix(in srgb, var(--dc, var(--primary)) 12%, var(--surface));
  padding: 11px 15px; margin: 0; border-bottom: 1px solid var(--border); }
.cl-dom-title { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.cl-dom-rank { width: 24px; height: 24px; border-radius: 50%; flex: 0 0 auto;
  background: var(--dc, var(--primary)); color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 12.5px; box-shadow: 0 1px 3px rgba(0, 0, 0, .18); }
.cl-dom-name { font-size: 17px; font-weight: 800; color: var(--dc, var(--primary)); letter-spacing: .2px; }
.cl-dom-meta { font-size: 12px; color: var(--text-3); font-weight: 500; }
.cl-domcard-unc { --dc: var(--text-3); }
.cl-dom-body { padding: 10px 14px 12px; }
.cl-dom-act, .cl-axis-head { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.cl-axis-block { margin: 8px 0 10px; padding-inline-start: 10px;
  border-inline-start: 2px solid color-mix(in srgb, var(--dc, var(--primary)) 40%, var(--border)); }
.cl-axis-head { font-size: 13px; margin-bottom: 4px; }
.cl-axis-head::before { content: ""; width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto;
  background: var(--dc, var(--primary)); opacity: .85; }
.cl-axis-head > b { font-weight: 700; }
.cl-item { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 4px 0; font-size: 12.5px; }
.cl-item-l { flex: 1; min-width: 200px; }
.cls-move, .cls-ax-merge, .cls-ax-move, .cls-dom-merge { font-size: 12px; padding: 3px 5px; border-radius: 7px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text); max-width: 190px; }
.btn.sm { padding: 2px 8px; font-size: 12px; }
/* Archived accounts: dimmed row in the «حسابات X» table (still readable). */
tr.row-dim > td { opacity: .55; }
tr.row-dim > td .pill { opacity: 1; }
.cl-sec { font-size: 11px; }
/* Armed-move row: wraps to its own line under the item it belongs to. */
.cls-move-confirm { flex-basis: 100%; display: flex; gap: 6px; align-items: center; padding: 4px 0 2px; }
.cls-move-reason { flex: 1; min-width: 160px; padding: 3px 6px; border-radius: 7px; font-size: 12px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.cls-wbox { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; }
.cls-wbox input { width: 52px; padding: 2px 4px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-size: 12px; }

/* ---- Review-learning loop ---- */
.lesson-delta { font-size: 13px; line-height: 1.8; margin-bottom: 6px; }
.lesson-why { font-size: 13px; margin-bottom: 6px; }
.lesson-rule { font-size: 13px; margin-bottom: 8px; padding: 6px 8px; border-radius: 7px;
  background: rgba(59, 130, 246, .08); border-inline-start: 3px solid #3b82f6; }

/* ---- Raw archive: day × section table (one snapshot per section/scrape run) ---- */
.raw-day { margin-bottom: 18px; }
.raw-day-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 0 2px 8px;
  padding-bottom: 6px; border-bottom: 2px solid var(--border); }
.raw-day-name { font-size: 15px; font-weight: 800; color: var(--text); }
.raw-day-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.raw-day-count { margin-inline-start: auto; font-size: 12px; }
.raw-chip { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: var(--r-pill);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.raw-tbl { width: 100%; }
.raw-tbl th { font-size: 12px; font-weight: 700; color: var(--text-3); }
.raw-tbl td { vertical-align: middle; }
.raw-sec { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; font-size: 13.5px; color: var(--text); }
.raw-sec-ic { font-size: 14px; line-height: 1; }
.raw-time, .raw-rows, .raw-run { font-variant-numeric: tabular-nums; }
.raw-time { font-weight: 700; color: var(--text-2); }
.raw-rows { font-weight: 800; color: var(--text); }
.raw-run { font-size: 12px; color: var(--text-3); }
.raw-dls { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.raw-sz { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; margin-inline-end: 4px; }
.raw-dl-missing { font-size: 12px; opacity: .6; }
.raw-legacy td { background: color-mix(in srgb, var(--warn) 6%, transparent); }
.warn-pill { background: var(--warn-bg); color: var(--warn); font-size: 11px; font-weight: 800;
  padding: 2px 8px; border-radius: var(--r-pill); }

/* ---- Permissions editor modal ---- */
.mdl-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); }
.perm-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.perm-toolbar input { flex: 1; min-width: 180px; }
.perm-group { margin-bottom: 14px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.perm-group-h { display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--surface-2); font-weight: 800; font-size: 13.5px; color: var(--text); }
.perm-group-tools { font-size: 12px; font-weight: 600; color: var(--text-3); }
.perm-group-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 2px 12px; padding: 8px 10px; }
.perm-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.perm-item:hover { background: var(--surface-2); }
.perm-item.is-base { background: color-mix(in srgb, var(--primary) 7%, transparent); }
.perm-item .perm-cb { flex: none; width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.perm-lbl { flex: 1; font-size: 13.5px; color: var(--text); }
.perm-tag { font-size: 10px; font-weight: 700; color: var(--primary); border: 1px solid var(--primary);
  border-radius: 5px; padding: 0 4px; margin-inline-start: 4px; vertical-align: middle; }
.perm-key { font-size: 10.5px; color: var(--text-3); direction: ltr; }
.perm-item input:disabled ~ .perm-lbl { opacity: .7; }
.lnk { background: none; border: 0; color: var(--primary); cursor: pointer; font: inherit; padding: 0; }
.lnk:hover { text-decoration: underline; }
.ov-badge { display: inline-block; font-size: 11px; font-weight: 800; color: var(--warn);
  background: var(--warn-bg); border-radius: 6px; padding: 1px 6px; margin-inline-start: 4px; }

/* ---- Date-window: browse the daily archive of the three sections (reports page) ---- */
.date-window { position: relative; }
.dw-pill { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 13px;
  border: 1px solid var(--border-2); border-radius: var(--r-pill); background: var(--surface);
  color: var(--text); font-family: var(--font); font-size: 13.5px; font-weight: 700; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: border-color .15s; }
.dw-pill:hover:not(:disabled) { border-color: var(--primary); }
.dw-pill:disabled { opacity: .6; cursor: not-allowed; }
.dw-pill .dw-chev { color: var(--text-3); font-size: 11px; }
.dw-badge { font-size: 10.5px; font-weight: 800; padding: 2px 8px; border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary-600); }
.dw-badge.past { background: var(--warn-bg); color: var(--warn); }
/* newest available day, but NOT today (no run since) */
.dw-badge.stale { background: var(--warn-bg); color: var(--warn); }
.dw-gap { padding: 9px 13px; font-size: 12px; line-height: 1.7; color: var(--warn);
  background: var(--warn-bg); border-bottom: 1px solid var(--border); }

/* ---- Per-section date strip (reports page): each section shows its own day ---- */
.sec-dates { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -4px 0 14px; }
.sec-dates:empty { display: none; }
.sd-lead { font-size: 12px; font-weight: 700; color: var(--text-3); }
.sd-chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px;
  border: 1px solid var(--border-2); border-radius: var(--r-pill); background: var(--surface);
  font-family: var(--font); font-size: 12px; cursor: pointer; transition: border-color .15s; }
.sd-chip:hover { border-color: var(--primary); }
.sd-chip .sd-k { font-weight: 800; color: var(--text-2); }
.sd-chip .sd-v { font-weight: 700; color: var(--text); }
.sd-chip.sd-fresh .sd-v { color: var(--ok); }
.sd-chip.sd-stale { border-color: color-mix(in srgb, var(--warn) 45%, var(--border-2)); }
.sd-chip.sd-stale .sd-v { color: var(--warn); }
.sd-chip.sd-none { opacity: .75; }
.sd-chip.sd-none .sd-v { color: var(--text-3); font-weight: 600; }
.sd-rel { font-size: 10.5px; font-weight: 800; padding: 1px 7px; border-radius: var(--r-pill);
  background: var(--warn-bg); color: var(--warn); margin-inline-start: 4px; }
.sd-demo { font-size: 10.5px; font-weight: 800; padding: 1px 7px; border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--text-3); }
.sd-today { font-size: 11.5px; color: var(--text-3); margin-inline-start: 2px; }
/* date stamped on a section's card heading */
.tag.tag-stale { background: var(--warn-bg); color: var(--warn); }

.dw-pop { position: absolute; z-index: 60; top: calc(100% + 6px); inset-inline-start: 0;
  width: 344px; max-width: 88vw; max-height: 430px; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-lg); }
.dw-pop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 11px 13px;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface);
  font-size: 13px; font-weight: 800; color: var(--text); z-index: 1; }
.dw-pop-x { background: none; border: 0; color: var(--text-3); cursor: pointer; font-size: 15px; line-height: 1; padding: 2px 4px; }
.dw-pop-x:hover { color: var(--text); }
.dw-month { font-size: 11px; font-weight: 700; color: var(--text-3); padding: 9px 13px 3px; }
.dw-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 11px;
  margin: 1px 6px; border-radius: var(--r-sm); border: 1px solid transparent; cursor: pointer; }
.dw-row:hover { background: var(--surface-2); border-color: var(--border); }
.dw-row.is-current { background: color-mix(in srgb, var(--primary) 9%, transparent);
  border-color: color-mix(in srgb, var(--primary) 30%, transparent); }
.dw-row.is-sel { border-color: var(--primary); }
.dw-row-l { display: flex; align-items: center; gap: 10px; min-width: 0; }
.dw-day { font-variant-numeric: tabular-nums; font-size: 16px; font-weight: 800; width: 24px; text-align: center; color: var(--text); }
.dw-row.is-current .dw-day { color: var(--primary-600); }
.dw-row-t { font-size: 12.5px; color: var(--text); }
.dw-row-s { font-size: 11px; color: var(--text-3); }
.dw-count { font-size: 10.5px; font-weight: 800; padding: 3px 9px; border-radius: var(--r-pill); white-space: nowrap; }
.dw-count.c3 { background: var(--ok-bg); color: var(--ok); }
.dw-count.c-part { background: var(--warn-bg); color: var(--warn); }
.dw-legend { display: flex; flex-wrap: wrap; gap: 12px; padding: 9px 13px; border-top: 1px solid var(--border);
  font-size: 10.5px; color: var(--text-2); position: sticky; bottom: 0; background: var(--surface); }
.dw-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-inline-end: 4px; vertical-align: 1px; }

.archive-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 14px;
  border-radius: var(--r); background: var(--warn-bg); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  color: var(--warn); font-size: 13px; font-weight: 700; }
.archive-banner b { color: var(--text); }
.archive-banner .btn { margin-inline-start: auto; }
/* Earlier days stay fully editable/approvable (retroactive review is normal work) —
   the day is signalled by the banner + this accent, never by hiding the controls. */
#page-history.archive-ro { border-inline-start: 3px solid var(--warn); padding-inline-start: 11px; }

/* =============================================================================
   Notifications — bell dropdown, feed list, toasts. Level tints reuse the shared
   --ok/--warn/--danger/--info tokens so light/dark themes track automatically.
   ========================================================================== */
.notif-dd {
  position: fixed; z-index: 60; max-height: 72vh; overflow: hidden auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
}
/* The `hidden` attribute must win over the class's `display:flex` (author styles
   beat the UA `[hidden]{display:none}`, so the attribute alone would not hide it). */
.notif-dd[hidden] { display: none; }
.notif-dd-head {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center;
  gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.notif-dd-head b { font-size: 14px; }
.notif-dd-actions { margin-inline-start: auto; display: flex; gap: 6px; }
.notif-dd-actions .btn.sm { padding: 5px 10px; font-size: 11.5px; }

.notif-list { display: flex; flex-direction: column; }
.notif-item {
  position: relative; display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 14px; cursor: pointer; border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: color-mix(in srgb, var(--primary) 6%, transparent); }
.notif-item.unread:hover { background: color-mix(in srgb, var(--primary) 10%, transparent); }
.notif-ic {
  flex: none; width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center; margin-top: 1px;
}
.notif-ic .icon { width: 16px; height: 16px; }
.notif-ic.info    { background: var(--info-bg);   color: var(--info); }
.notif-ic.success { background: var(--ok-bg);     color: var(--ok); }
.notif-ic.warning { background: var(--warn-bg);   color: var(--warn); }
.notif-ic.danger  { background: var(--danger-bg); color: var(--danger); }
.notif-body { min-width: 0; flex: 1; }
.notif-title { font-size: 13px; font-weight: 700; color: var(--text); line-height: 1.35; }
.notif-sub { font-size: 12px; color: var(--text-2); margin-top: 2px; word-break: break-word; }
.notif-meta { font-size: 10.5px; color: var(--text-3); margin-top: 4px; display: flex; gap: 4px; flex-wrap: wrap; }
.notif-cat { font-weight: 700; color: var(--text-2); }
.notif-udot {
  flex: none; width: 8px; height: 8px; border-radius: 50%; margin-top: 8px;
  background: var(--primary);
}
.notif-list-page .notif-item { padding: 13px 14px; }

/* Toasts — bottom-start stack, slide in from the inline-start edge (RTL-aware). */
.notif-toasts {
  position: fixed; bottom: 18px; inset-inline-start: 18px; z-index: 80;
  display: flex; flex-direction: column; gap: 10px;
  width: min(360px, calc(100vw - 36px)); pointer-events: none;
}
.notif-toast {
  pointer-events: auto; display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border);
  border-inline-start: 3px solid var(--text-3);
  border-radius: var(--r); box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateX(-14px); transition: opacity .25s, transform .25s;
}
[dir="rtl"] .notif-toast { transform: translateX(14px); }
.notif-toast.show { opacity: 1; transform: translateX(0); }
.notif-toast.info    { border-inline-start-color: var(--info); }
.notif-toast.success { border-inline-start-color: var(--ok); }
.notif-toast.warning { border-inline-start-color: var(--warn); }
.notif-toast.danger  { border-inline-start-color: var(--danger); }
.notif-toast-x {
  flex: none; margin-inline-start: auto; background: none; border: 0;
  color: var(--text-3); cursor: pointer; font-size: 13px; line-height: 1;
  padding: 2px 4px; border-radius: 6px;
}
.notif-toast-x:hover { background: var(--surface-2); color: var(--text); }

/* Floating scroll-to-bottom / scroll-to-top toggle */
.scroll-toggle {
  position: fixed; inset-inline-end: 24px; bottom: 24px; z-index: 900;
  width: 46px; height: 46px; border-radius: 50%; border: none; cursor: pointer;
  font-size: 20px; line-height: 1; background: var(--accent, #6a5cff); color: #fff;
  box-shadow: 0 4px 14px rgba(0,0,0,.28); opacity: .85;
  transition: opacity .15s ease, transform .15s ease;
}
.scroll-toggle:hover { opacity: 1; transform: translateY(-2px); }
.scroll-toggle:active { transform: translateY(0); }

/* ---------- Manual raw ingest (الإدخال اليدوي للملفات الخام) ---------- */
.ing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; align-items: end; }
.ing-counts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.ing-count { display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 86px; padding: 8px 10px; border-radius: 10px; background: var(--surface-3); }
.ing-count b { font-size: 16px; }
.ing-count span { font-size: 11px; color: var(--text-3); }
.ing-count.warn b { color: var(--warn); }
.ing-count.good { background: var(--ok-bg); }
.ing-count.good b { color: var(--ok); }
.ing-warn { margin-top: 10px; padding: 8px 12px; border-radius: 10px;
  background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.ing-ok { border-inline-start: 4px solid var(--ok); }
.ing-sample { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.ing-sample-row { padding: 6px 10px; border-radius: 8px; background: var(--surface-3); font-size: 13px; }
.ing-sample-row .muted { font-size: 11px; margin-inline-end: 6px; }
#ingSaveProfile { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-1); color: var(--text-1); }

/* =============================================================================
   المساعد العائم — زرّ + لوحة محادثة (الطبقة 0: قراءة فقط).
   يجلس فوق الزرّ العائم للتمرير (bottom:24) فيُزاح هذا إلى 82px، ويأخذ z-index
   أعلى منه (910 مقابل 900) كي لا يختفي خلفه. الألوان كلها من متغيّرات السمة
   فيعمل في الفاتح والداكن بلا تفريع.
   ========================================================================== */
.asst-fab {
  position: fixed; inset-inline-end: 24px; bottom: 82px; z-index: 910;
  width: 52px; height: 52px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--grad); color: #fff; display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(99, 102, 241, .38);
  transition: transform .15s ease, box-shadow .15s ease;
}
.asst-fab:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(99, 102, 241, .46); }
.asst-fab:active { transform: translateY(0); }
.asst-fab .icon { width: 22px; height: 22px; }
.asst-fab.on { background: var(--surface); color: var(--primary-600); border: 1px solid var(--border-2); }

.asst-panel {
  position: fixed; inset-inline-end: 24px; bottom: 146px; z-index: 910;
  width: min(400px, calc(100vw - 32px)); max-height: min(620px, calc(100vh - 180px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow-lg, 0 18px 46px rgba(16, 24, 40, .2));
}
.asst-panel[hidden] { display: none; }

.asst-head {
  display: flex; align-items: center; gap: 8px; padding: 12px 14px;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.asst-head-main { flex: 1; min-width: 0; }
.asst-title { font-weight: 800; font-size: 14px; }
.asst-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.asst-sub.warn { color: var(--warn); }
.asst-icon-btn {
  border: none; background: transparent; color: var(--text-3); cursor: pointer;
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  font-size: 13px; transition: background .15s, color .15s;
}
.asst-icon-btn:hover { background: var(--surface-3); color: var(--text); }

.asst-log {
  flex: 1; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 10px; min-height: 140px;
}
.asst-msg {
  max-width: 88%; padding: 10px 13px; border-radius: 14px;
  font-size: 13.4px; line-height: 1.65; white-space: pre-wrap; word-break: break-word;
}
.asst-msg.user { align-self: flex-start; background: var(--grad); color: #fff; border-end-start-radius: 4px; }
.asst-msg.bot  { align-self: flex-end; background: var(--surface-2); border: 1px solid var(--border); border-end-end-radius: 4px; }
.asst-msg.bot.mock    { border-inline-end: 3px solid var(--info); }
.asst-msg.bot.blocked { border-inline-end: 3px solid var(--warn); }
.asst-msg.bot.failed  { border-inline-end: 3px solid var(--danger); }

.asst-meta { margin-top: 8px; padding-top: 7px; border-top: 1px dashed var(--border-2);
  display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.asst-chip {
  font-size: 10.5px; font-weight: 700; padding: 3px 8px; border-radius: var(--r-pill);
  background: var(--surface-3); color: var(--text-3); border: 1px solid var(--border);
}
.asst-chip.tool { color: var(--primary-600); border-color: var(--primary); }
.asst-chip.cite { color: var(--info); border-color: var(--info); }
.asst-chip.err  { color: var(--danger); border-color: var(--danger); }
.asst-goto {
  font-size: 11.5px; font-weight: 700; padding: 5px 11px; border-radius: var(--r-pill);
  background: var(--primary); color: #fff; border: none; cursor: pointer;
}
.asst-goto:hover { background: var(--primary-600); }

.asst-typing { display: inline-flex; gap: 4px; align-items: center; }
.asst-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3);
  animation: asstBlink 1.1s infinite ease-in-out; }
.asst-typing i:nth-child(2) { animation-delay: .18s; }
.asst-typing i:nth-child(3) { animation-delay: .36s; }
@keyframes asstBlink { 0%, 80%, 100% { opacity: .25 } 40% { opacity: 1 } }

.asst-suggests { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 14px 4px; }
.asst-suggests:empty { display: none; }
.asst-suggest {
  font-size: 11.5px; font-weight: 600; padding: 5px 11px; border-radius: var(--r-pill);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
  cursor: pointer; transition: border-color .15s, color .15s;
}
.asst-suggest:hover { border-color: var(--primary); color: var(--primary-600); }

.asst-input { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border); }
.asst-input input {
  flex: 1; min-width: 0; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--r-pill); padding: 10px 15px;
  font-family: var(--font); font-size: 13.5px; outline: none;
}
.asst-input input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91, 91, 240, .14); }
.asst-input .btn { border-radius: var(--r-pill); padding: 0 15px; }
.asst-input .btn[disabled] { opacity: .5; cursor: not-allowed; }

@media (max-width: 560px) {
  .asst-panel { inset-inline: 12px; width: auto; bottom: 96px; max-height: calc(100vh - 130px); }
  .asst-fab { bottom: 76px; inset-inline-end: 16px; }
}

/* ===== «التقرير المُوحّد» (م٢): unified X + groups review with manual merge ===== */
.unified-wrap { margin-top: 4px; }
.uni-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 12px; font-size: 13px; color: var(--text-2); }
.uni-day { font-weight: 800; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px 12px; }
.uni-cnt b { color: var(--primary-600); }
.uni-list { display: flex; flex-direction: column; gap: 9px; }
.uni-card { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); padding: 11px 14px; transition: border-color .15s, box-shadow .15s; }
.uni-card.src-both { border-inline-start: 3px solid #7c3aed; background: linear-gradient(90deg, rgba(124, 58, 237, .05), transparent 42%); }
.uni-card.src-x { border-inline-start: 3px solid #1d4ed8; }
.uni-card.src-groups { border-inline-start: 3px solid #7c3aed; }
.uni-card.picked { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 32%, transparent); }
.uni-c-h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.uni-num { font-size: 11.5px; font-weight: 800; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; }
.uni-src { display: inline-flex; align-items: center; gap: 3px; }
.uni-ic { width: 18px; height: 18px; display: inline-grid; place-items: center; }
.uni-ic svg { width: 16px; height: 16px; }
.uni-ic.uni-x { color: #1d4ed8; }
.uni-ic.uni-g { color: #7c3aed; }
.uni-badge { font-size: 11px; font-weight: 700; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 1px 9px; }
.uni-prov { font-size: 10.5px; font-weight: 700; color: #7c3aed; background: rgba(124, 58, 237, .1); border-radius: 999px; padding: 1px 9px; }
.uni-bsrc { font-size: 10.5px; font-weight: 700; color: var(--ok); background: var(--ok-bg); border-radius: 999px; padding: 1px 9px; }
.uni-sp { flex: 1; }
.uni-c-b { font-size: 13.5px; line-height: 1.85; color: var(--text); white-space: pre-wrap; }
.uni-pick.on { background: var(--primary); color: #fff; border-color: transparent; }
.uni-edit-box { margin-top: 10px; }
.uni-ta { width: 100%; border: 1px solid var(--border-2); border-radius: 10px; padding: 10px 12px; font-family: inherit; font-size: 13.5px; line-height: 1.8; background: var(--surface-2); color: var(--text); resize: vertical; }
.uni-edit-a { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.uni-pages { margin-top: 18px; border-top: 1px dashed var(--border); padding-top: 12px; }
.uni-pages-h { font-size: 12px; font-weight: 800; color: var(--text-3); margin-bottom: 8px; }
.uni-page { border: 1px solid var(--border); border-inline-start: 3px solid #0e7490; border-radius: 10px; padding: 8px 12px; margin-bottom: 7px; background: var(--surface); }
.uni-page b { font-size: 13px; color: var(--text); }
.uni-page-b { font-size: 12.5px; color: var(--text-2); line-height: 1.7; margin-top: 3px; }
.uni-merge-bar { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border-2); border-radius: 14px; padding: 10px 16px; box-shadow: var(--shadow-lg); font-size: 13px; font-weight: 700; color: var(--text); }
@media (max-width: 560px) { .uni-merge-bar { left: 12px; right: 12px; transform: none; flex-wrap: wrap; justify-content: center; } }

/* ===== «التقرير المُوحّد» م٣: hybrid merge suggestions ===== */
#uniSuggest:not(:empty) { margin: 4px 0 12px; }
.uni-sug-empty { font-size: 12.5px; color: var(--text-3); padding: 8px 2px; }
.uni-sug-h { font-size: 12.5px; font-weight: 800; color: var(--text-2); margin: 4px 0 8px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.uni-sug-ai { font-size: 10.5px; font-weight: 700; color: var(--warn); background: var(--warn-bg); border-radius: 999px; padding: 1px 9px; }
.uni-sug-ai.ok { color: var(--ok); background: var(--ok-bg); }
.uni-sug { border: 1px dashed var(--border-2); border-radius: 12px; padding: 10px 13px; margin: 0 0 8px; background: var(--surface-2); }
.uni-sug-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.uni-badge.ok { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.uni-sug-terms { font-size: 11px; color: var(--text-3); }
.uni-sug-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 620px) { .uni-sug-pair { grid-template-columns: 1fr; } }
.uni-sug-side { border: 1px solid var(--border); border-radius: 9px; padding: 7px 10px; background: var(--surface); }
.uni-sug-side.src-x { border-inline-start: 3px solid #1d4ed8; }
.uni-sug-side.src-groups { border-inline-start: 3px solid #7c3aed; }
.uni-sug-side b { font-size: 11.5px; color: var(--text-2); }
.uni-sug-side div { font-size: 12px; color: var(--text); line-height: 1.6; margin-top: 3px; }
.uni-sug-a { display: flex; gap: 8px; margin-top: 9px; }

/* ===== «التقرير المُوحّد»: reorder mode (same UX as X «وضع الترتيب») ===== */
.uni-drag { display: none; cursor: grab; color: var(--text-3); font-size: 16px; line-height: 1; user-select: none; padding: 0 2px; }
.uni-reordering .uni-drag { display: inline; }
.uni-reordering .uni-card { cursor: grab; border-style: dashed; }
.uni-reordering .uni-card:hover { border-color: var(--primary-600); }
.uni-card[draggable="true"] { transition: box-shadow .12s, opacity .12s; }
.uni-card.uni-dragging { opacity: .45; box-shadow: var(--shadow); }
.uni-reorder-bar { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.uni-reorder-bar .muted { flex: 1; font-size: 12.5px; min-width: 180px; }

/* ---------- المصادر والقوائم ---------- */
/* The section count rides ON the tab: the population is the thing, and its size
   is the first fact anyone wants about it. */
.seg .seg-n { font-weight: 700; font-size: 11.5px; opacity: .65; margin-inline-start: 4px; }
/* Files (issues) — a strip of what exists, not a rail of everything possible. */
.sh-files { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.sh-file { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; min-height: 40px;
  border: 1px solid var(--line, var(--border)); border-radius: 999px; background: var(--panel-2, var(--surface-2));
  color: var(--text); font: inherit; font-size: 13.5px; cursor: pointer; }
.sh-file:hover { border-color: var(--accent, currentColor); }
.sh-file.on { background: var(--surface-3, var(--panel)); border-color: var(--accent, currentColor); font-weight: 700; }
.sh-file b { font-weight: 700; font-size: 12px; opacity: .7; }
.sh-filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; align-items: flex-end; }
.sh-flags { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.sh-flag { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; min-height: 32px;
  border: 1px solid var(--line, var(--border)); border-radius: 8px; background: none;
  color: var(--text); font: inherit; font-size: 12.5px; cursor: pointer; }
.sh-flag:hover { background: var(--surface-2); }
.sh-flag.on { background: var(--surface-3, var(--panel)); border-color: var(--accent, currentColor); font-weight: 700; }
.sh-flag b { font-weight: 700; opacity: .7; }
.sh-chip { display: inline-flex; align-items: center; gap: 4px; margin: 2px 0; }
/* ---------- استيراد/تصدير القوائم ---------- */
.sio { margin-bottom: 14px; }
.sio-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sio-step { margin-top: 12px; border-top: 1px solid var(--line, var(--border)); padding-top: 12px; }
.sio-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sio-sub { font-size: 12.5px; font-weight: 700; color: var(--text-3); margin: 14px 0 6px; }
/* The mapping grid: one cell per column of the file, so a 20-column sheet stays
   readable instead of becoming a 20-row form. */
.sio-grid { display: grid; gap: 8px; margin-top: 10px;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.sio-col { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sio-col > span { font-size: 12px; color: var(--text-3); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.sio-col > select { width: 100%; }
.sio-vals { display: grid; gap: 8px; align-items: end; margin-bottom: 8px;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.sio-opts { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-top: 12px; }
.sio-counts { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 6px; }
.sio-counts .sh-flag { cursor: default; }
.sh-chip.ok { border-color: var(--ok); }
.linklike { background: none; border: 0; padding: 0 2px; cursor: pointer; color: var(--accent, inherit); font: inherit; font-size: 11.5px; }

/* ===== غرفة الموقف: البطاقة تُقرأ لا تُفكَّك =====================================
   The board's job is a VERDICT, and a verdict needs the words. The old card showed
   only metadata plus «دليل ١ · دليل ٢», so judging one incident meant opening three
   tabs — which is why 382 incidents sat unlabelled. Here the quoted text IS the card;
   the counts are a thin line above it, and the controls are one row of three buttons
   with the refinement revealed only after a verdict exists. */
.wbar { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:12px; }
.wbar-i { display:flex; flex-direction:column; align-items:center; justify-content:center;
  min-width:96px; padding:8px 14px; border:1px solid var(--line, #e5e7eb);
  border-radius:12px; background:var(--panel, #fff); line-height:1.25; }
.wbar-i b { font-size:17px; }
.wbar-i small { font-size:11px; opacity:.65; margin-top:2px; }
.wbar-i.warn { border-color:#f0b429; background:#fffaf0; }

.wfilters { display:flex; gap:10px; align-items:center; flex-wrap:wrap; margin-bottom:14px; }
.wfilters select { min-width:130px; }
.wfilters .chk { margin:0; white-space:nowrap; }

.wcard { border:1px solid var(--line, #e5e7eb); border-radius:14px;
  background:var(--panel, #fff); padding:14px 16px; margin-bottom:10px;
  /* The severity is a 3px edge, not a coloured block: it must be findable while
     scanning and silent while reading. */
  border-inline-start:3px solid transparent; }
.wcard.sev-danger { border-inline-start-color:#e5534b; }
.wcard.sev-warn   { border-inline-start-color:#f0b429; }
.wcard.sev-muted  { border-inline-start-color:#cbd5e1; }
.wcard-h { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.wsubj { font-size:16px; }
.wsev { font-size:11px; padding:2px 8px; border-radius:999px; border:1px solid currentColor; }
.wsev.danger { color:#b42318; } .wsev.warn { color:#9a6700; } .wsev.muted { color:#64748b; }
/* One line, one string, explicit «·» separators — spans spaced only by flex gap
   render glued under RTL with digits («20:00:00بدأت»). */
.wmeta { font-size:12.5px; opacity:.7; margin:6px 0 10px; }

.wq-wrap { display:flex; flex-direction:column; gap:8px; margin-bottom:12px; }
.wq { padding:9px 12px; border-radius:10px; background:var(--soft, #f8fafc);
  border:1px solid var(--line, #eef2f7); }
.wq-who { font-weight:600; font-size:12.5px; text-decoration:none; }
.wq-who:hover { text-decoration:underline; }
.wq-txt { font-size:14px; line-height:1.75; margin-top:4px; }

.wcard-f { display:flex; flex-direction:column; gap:8px; }
.w-ask, .w-done { display:flex; align-items:center; gap:6px; flex-wrap:wrap; }
.w-hint { margin-inline-start:4px; }
.w-more { display:flex; gap:6px; flex-wrap:wrap; align-items:center; }
/* `display:flex` beats the [hidden] attribute, so the refinement row rendered even
   before a verdict existed — which is exactly the "one click became a form" problem
   this row was introduced to avoid. */
.w-more[hidden] { display:none; }
.w-more input { flex:1; min-width:160px; }
.btn.sm.ok { background:#16a34a; color:#fff; border-color:#16a34a; }

@media (max-width: 720px) {
  .wbar-i { flex:1 1 calc(50% - 8px); min-width:0; }
  .wfilters { gap:8px; }
  .wfilters .seg { width:100%; overflow-x:auto; }
  .w-ask .btn, .w-more .btn { flex:1 1 auto; min-height:40px; }
  .w-hint { flex-basis:100%; }
}

/* ===== محور الذكرى: غرفة مراقبة ================================================
   تُقرأ في خمس ثوانٍ: الدرجة، ثمّ الأرقام، ثمّ الاتّجاه. ولا لون صارخ إلّا واحد،
   والأحمر محجوز للدرجة الرابعة — فإن استُعمل في كلّ مكان لم يعد يعني شيئًا. */
.aroom { margin-bottom: 16px; }

.abar { display:flex; align-items:center; gap:12px; flex-wrap:wrap;
  padding:12px 14px; border-radius:14px; border:1px solid var(--line,#e5e7eb);
  background:var(--panel,#fff); border-inline-start-width:4px; }
.abar.g1 { border-inline-start-color:#64748b; }
.abar.g2 { border-inline-start-color:#f0b429; }
.abar.g3 { border-inline-start-color:#f97316; }
.abar.g4 { border-inline-start-color:#e5534b; }
.abadge { display:inline-flex; align-items:center; gap:7px; padding:5px 12px;
  border-radius:999px; font-weight:700; font-size:13px; border:1px solid currentColor; }
.abar.g1 .abadge { color:#475569; } .abar.g2 .abadge { color:#9a6700; }
.abar.g3 .abadge { color:#b45309; } .abar.g4 .abadge { color:#b42318; }
/* الدرجة الرابعة وحدها تنبض، ونبضًا هادئًا: الوميض السريع يُطفَأ في اليوم الأوّل. */
.abar.g4 .abadge { animation: apulse 2.4s ease-in-out infinite; }
@keyframes apulse { 0%,100% { opacity:1 } 50% { opacity:.55 } }
@media (prefers-reduced-motion: reduce) { .abar.g4 .abadge { animation:none } }
.abar-why { display:flex; flex-direction:column; line-height:1.5; font-size:13px; }
.acd { display:flex; flex-direction:column; align-items:center; line-height:1.2; }
.acd small { font-size:11px; opacity:.6; }

.anote { margin-top:10px; padding:10px 14px; border-radius:12px;
  border:1px solid #f0b429; background:#fffaf0; font-size:13px; line-height:1.8; }

.akpis { display:grid; grid-template-columns:repeat(5,1fr); gap:10px; margin-top:12px; }
.akpi { padding:12px 14px; border-radius:14px; border:1px solid var(--line,#e5e7eb);
  background:var(--panel,#fff); position:relative; overflow:hidden; }
.akpi-v { font-size:24px; font-weight:700; line-height:1.1; }
.akpi-l { font-size:12px; opacity:.75; margin-top:3px; }
.akpi-s { font-size:11px; opacity:.55; margin-top:2px; min-height:14px; }
.akpi.hot { border-color:#f97316; }
.akpi.alarm { border-color:#e5534b; }
.akpi.alarm .akpi-v { color:#b42318; }
.aspark { display:block; width:100%; height:26px; margin-top:6px; }
.aspark polyline { fill:none; stroke:currentColor; stroke-width:1.5; opacity:.45; }

.acard { margin-top:12px; }
.acurve { width:100%; height:auto; }
.acurve .aline { fill:none; stroke:#6366f1; stroke-width:2.2; }
.acurve .adot { fill:#6366f1; opacity:.55; }
.acurve .adot.now { opacity:1; stroke:#fff; stroke-width:1.5; }
.acurve .abase { stroke:#94a3b8; stroke-width:1.2; }
.acurve .athr { stroke-dasharray:5 4; stroke-width:1.2; }
.acurve .athr.w { stroke:#f97316; } .acurve .athr.d { stroke:#e5534b; }
.acurve .athrlbl { font-size:10px; fill:#64748b; }
.acurve .athrlbl.w { fill:#b45309; } .acurve .athrlbl.d { fill:#b42318; }
.acurve .aseason { fill:#6366f1; opacity:.06; }
.acurve .apeak { stroke:#e5534b; stroke-width:1.4; stroke-dasharray:3 3; }
.acurve .apeaklbl { font-size:10px; fill:#b42318; font-weight:600; }
.acurve .axlbl { font-size:10px; fill:#94a3b8; }

@media (max-width: 900px) { .akpis { grid-template-columns:repeat(2,1fr); } }
@media (max-width: 520px) { .akpis { grid-template-columns:1fr 1fr; }
  .abar { gap:8px; } .acd { order:3; } }
