:root {
  --ink: #16262c;
  --ink-2: #4a5a60;
  --ink-3: #7d8b90;
  --line: #e2e6e3;
  --line-2: #eef1ee;
  --bg: #f4f5f2;
  --surface: #ffffff;
  --brand: #0f3d4a;
  --brand-2: #17596b;
  --brand-soft: #e5eff1;
  --accent: #f2b84b;
  --accent-ink: #7a4f00;
  --ok: #1f7a4d;
  --ok-soft: #e3f3ea;
  --warn: #a85d00;
  --warn-soft: #fdf0dc;
  --bad: #b3261e;
  --bad-soft: #fbe7e5;
  --info: #255f9e;
  --info-soft: #e5eef9;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 38, 44, 0.06), 0 2px 8px rgba(16, 38, 44, 0.05);
  --font: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
img, video { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; font-weight: 600; }
h1 { font-size: 24px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 10px 24px;
  background: var(--brand);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-name { font-size: 20px; font-weight: 700; }
.brand-sub { font-size: 12px; opacity: 0.7; padding-inline-start: 10px; border-inline-start: 1px solid rgba(255,255,255,.25); }
.mainnav { display: flex; gap: 4px; flex: 1; }
.mainnav a {
  color: rgba(255,255,255,.8); padding: 7px 14px; border-radius: 999px; font-weight: 500;
}
.mainnav a:hover { background: rgba(255,255,255,.08); text-decoration: none; color: #fff; }
.mainnav a.active { background: rgba(255,255,255,.14); color: #fff; }
.user-chip {
  border: 1px solid rgba(255,255,255,.25); background: transparent; color: #fff;
  border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 13px; cursor: pointer;
}

.container { max-width: 1280px; margin: 0 auto; padding: 24px; outline: none; }

/* ---------- generic layout ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--ink-2); margin-top: 4px; }
.crumbs { font-size: 13px; color: var(--ink-3); margin-bottom: 6px; }
.crumbs a { color: var(--ink-2); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.split { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.split > * { min-width: 0; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.spacer { flex: 1; }
.hidden { display: none !important; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.card.flat { box-shadow: none; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head .hint { color: var(--ink-3); font-size: 13px; }
.section-title { font-size: 13px; font-weight: 600; color: var(--ink-3); margin: 4px 0 10px; letter-spacing: .2px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--line-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #3b2600; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--bad); border-color: #efc6c2; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--line-2); }
.btn.sm { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn.lg { min-height: 48px; padding: 10px 22px; font-size: 16px; }
.icon-btn { width: 32px; min-height: 32px; padding: 0; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field > span .req { color: var(--bad); }
.field .help { font-size: 12px; color: var(--ink-3); }
input[type=text], input[type=number], input[type=date], input[type=search], select, textarea {
  font: inherit; color: var(--ink); background: #fff;
  border: 1px solid #cfd6d2; border-radius: var(--radius-sm);
  padding: 9px 12px; min-height: 42px; width: 100%;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(23, 89, 107, .25); border-color: var(--brand-2); }
input.invalid { border-color: var(--bad); }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: 1 / -1; }
.checks { display: flex; gap: 14px; flex-wrap: wrap; }
.checks label { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; }

/* ---------- badges / chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--line-2); color: var(--ink-2); white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.brand { background: var(--brand-soft); color: var(--brand-2); }
.badge.sim { background: #f1ebfb; color: #5b3a9a; }

/* ---------- progress ---------- */
.bar { height: 8px; background: var(--line-2); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand-2); border-radius: 999px; transition: width .4s; }
.bar.ok > i { background: var(--ok); }
.bar.thin { height: 5px; }
.bar.accent > i { background: var(--accent); }
.ring { position: relative; width: 120px; height: 120px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .ring-label { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring .ring-label b { font-size: 26px; display: block; line-height: 1; }
.ring .ring-label small { color: var(--ink-3); font-size: 11px; }

/* ---------- KPIs ---------- */
.kpi { padding: 16px 18px; }
.kpi .kpi-label { font-size: 13px; color: var(--ink-3); }
.kpi .kpi-value { font-size: 28px; font-weight: 700; margin-top: 2px; }
.kpi .kpi-value small { font-size: 14px; color: var(--ink-3); font-weight: 500; }
.kpi .kpi-foot { font-size: 12px; color: var(--ink-3); margin-top: 4px; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: start; padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table th { font-size: 12px; color: var(--ink-3); font-weight: 600; background: #fafbf9; }
.table tr:last-child td { border-bottom: 0; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a {
  padding: 10px 16px; color: var(--ink-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }
.tabs a .badge { margin-inline-start: 6px; }

/* ---------- project cards ---------- */
.project-card { display: flex; flex-direction: column; gap: 12px; color: inherit; transition: border-color .15s, transform .15s; }
.project-card:hover { text-decoration: none; border-color: #b9c8c5; transform: translateY(-1px); }
.project-card .meta { color: var(--ink-3); font-size: 13px; }

/* ---------- stage list (side) ---------- */
.stage-list { display: flex; flex-direction: column; gap: 6px; }
.stage-item {
  display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff;
  color: inherit; cursor: pointer; text-align: start; font: inherit; width: 100%;
}
.stage-item:hover { border-color: #b9c8c5; text-decoration: none; }
.stage-item.active { border-color: var(--brand-2); background: var(--brand-soft); }
.stage-item .no {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; background: var(--line-2); color: var(--ink-2);
}
.stage-item.done .no { background: var(--ok); color: #fff; }
.stage-item.pending .no { background: var(--accent); color: #3b2600; }
.stage-item.progress .no { background: var(--brand-2); color: #fff; }
.stage-item .nm { font-weight: 600; font-size: 14px; }
.stage-item .st { font-size: 12px; color: var(--ink-3); }

/* ---------- timeline (overview) ---------- */
.timeline { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(104px, 1fr); gap: 0; overflow-x: auto; padding-bottom: 4px; }
.tl-step { position: relative; padding: 0 8px; text-align: center; }
.tl-step::before {
  content: ''; position: absolute; top: 15px; inset-inline-start: 50%; width: 100%; height: 3px; background: var(--line);
}
.tl-step:last-child::before { display: none; }
.tl-step.done::before { background: var(--ok); }
.tl-dot {
  position: relative; z-index: 1; width: 32px; height: 32px; border-radius: 50%; margin: 0 auto 8px;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
  background: #fff; border: 3px solid var(--line); color: var(--ink-3);
}
.tl-step.done .tl-dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.tl-step.progress .tl-dot { border-color: var(--brand-2); color: var(--brand-2); }
.tl-step.pending .tl-dot { border-color: var(--accent); background: var(--accent); color: #3b2600; }
.tl-name { font-weight: 600; font-size: 13px; }
.tl-meta { font-size: 12px; color: var(--ink-3); }

/* ---------- files ---------- */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.file-tile { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.file-thumb { aspect-ratio: 4 / 3; background: #f0f2ef; display: grid; place-items: center; overflow: hidden; position: relative; }
.file-thumb img, .file-thumb video { width: 100%; height: 100%; object-fit: cover; }
.file-thumb .ext { font-size: 22px; font-weight: 700; color: var(--ink-3); }
.file-thumb .plan-flag { position: absolute; top: 8px; inset-inline-start: 8px; }
.file-body { padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; }
.file-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-actions { display: flex; gap: 4px; padding: 0 6px 8px; flex-wrap: wrap; }

.dropzone {
  border: 2px dashed #c7d1cd; border-radius: var(--radius); padding: 22px; text-align: center; color: var(--ink-2);
  background: #fafbf9; cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone.drag { border-color: var(--brand-2); background: var(--brand-soft); }
.dropzone b { color: var(--brand-2); }
.pending-files { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.pending-file { display: grid; grid-template-columns: 44px 1fr 200px auto; gap: 10px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
.pending-file .pf-thumb { width: 44px; height: 44px; border-radius: 6px; background: #eef1ee; overflow: hidden; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--ink-3); }
.pending-file .pf-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- media strip ---------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.media-tile { position: relative; border-radius: var(--radius-sm); overflow: hidden; background: #e9ece9; aspect-ratio: 4 / 3; cursor: zoom-in; border: 1px solid var(--line); padding: 0; }
.media-tile img, .media-tile video { width: 100%; height: 100%; object-fit: cover; }
.media-tile .tag { position: absolute; bottom: 6px; inset-inline-start: 6px; background: rgba(15, 61, 74, .82); color: #fff; font-size: 11px; padding: 1px 8px; border-radius: 999px; }
.media-tile .rm { position: absolute; top: 6px; inset-inline-end: 6px; }
.media-tile .play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 28px; text-shadow: 0 1px 6px rgba(0,0,0,.5); pointer-events: none; }

/* ---------- plan / pins ---------- */
.plan-wrap { position: relative; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: #fff; touch-action: manipulation; user-select: none; }
.plan-wrap img { width: 100%; height: auto; pointer-events: none; }
.plan-wrap.editable { cursor: crosshair; }
.pin {
  position: absolute; transform: translate(-50%, -50%);
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bad); border: 2px solid #fff; box-shadow: 0 0 0 4px rgba(179, 38, 30, .22), 0 2px 6px rgba(0,0,0,.35);
  display: grid; place-items: center; cursor: pointer; padding: 0;
}
.pin span { color: #fff; font-size: 12px; font-weight: 700; }
.pin.muted { background: var(--brand-2); }
.pin.sel { background: var(--accent); }
.pin.sel span { color: #3b2600; }
.plan-empty { padding: 30px; text-align: center; color: var(--ink-3); background: #fafbf9; border-radius: var(--radius-sm); border: 1px dashed var(--line); }
.pins-list { display: flex; flex-direction: column; gap: 8px; }
.pins-list .pin-row { display: grid; grid-template-columns: 30px 1fr auto; gap: 8px; align-items: center; }
.pin-no { width: 26px; height: 26px; border-radius: 50%; background: var(--bad); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; }

/* ---------- analysis ---------- */
.inputs-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.input-box { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; background: #fcfcfb; }
.input-box .ib-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-weight: 600; font-size: 14px; }
.input-box .ib-no { width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 12px; display: grid; place-items: center; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.thumbs .t { width: 64px; height: 48px; border-radius: 6px; overflow: hidden; background: #e9ece9; border: 1px solid var(--line); position: relative; }
.thumbs .t img, .thumbs .t video { width: 100%; height: 100%; object-fit: cover; }
.thumbs .t .v { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 14px; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; font-weight: 500; }

.pipeline { display: flex; flex-direction: column; gap: 10px; padding: 8px 0; }
.pipe-step { display: flex; gap: 12px; align-items: center; color: var(--ink-3); }
.pipe-step .ps-ic { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: 12px; flex: none; }
.pipe-step.run { color: var(--ink); }
.pipe-step.run .ps-ic { border-color: var(--brand-2); border-top-color: transparent; animation: spin .8s linear infinite; }
.pipe-step.done { color: var(--ink); }
.pipe-step.done .ps-ic { background: var(--ok); border-color: var(--ok); color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

.det-wrap { position: relative; border-radius: var(--radius-sm); overflow: hidden; background: #ddd; }
.det-wrap img { width: 100%; height: auto; }
.det-box { position: absolute; border: 2px solid #2ee59d; background: rgba(46, 229, 157, .12); border-radius: 3px; }
.det-box em { position: absolute; top: -20px; inset-inline-start: -2px; background: #2ee59d; color: #06281a; font-style: normal; font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: 3px; white-space: nowrap; direction: rtl; }
.issues { display: flex; flex-direction: column; gap: 8px; }
.issue { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; padding: 10px 12px; border-radius: var(--radius-sm); background: #fafbf9; border: 1px solid var(--line-2); }
.sub-progress { display: grid; grid-template-columns: 1fr 60px; gap: 6px 12px; align-items: center; font-size: 13px; }
.compare { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; }
.compare .arrow { font-size: 22px; color: var(--ink-3); }
.review-box { border: 2px solid var(--brand-soft); background: #fbfdfd; }
.decision { padding: 14px; border-radius: var(--radius-sm); }
.decision.ok { background: var(--ok-soft); }
.decision.bad { background: var(--bad-soft); }
input[type=range] { width: 100%; accent-color: var(--brand-2); }
.sim-note { background: #f6f2fd; border: 1px solid #e3d8f6; color: #4a2f80; border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; }

/* ---------- admin ---------- */
.stage-editor { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.stage-editor + .stage-editor { margin-top: 12px; }
.se-head { display: grid; grid-template-columns: 34px 1fr 120px auto; gap: 12px; align-items: center; padding: 14px 16px; cursor: pointer; }
.se-head .no { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; }
.se-head .w { font-weight: 700; color: var(--brand-2); text-align: center; }
.se-body { border-top: 1px solid var(--line-2); padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.sub-table input { min-height: 36px; padding: 6px 10px; }
.sub-table td { padding: 6px 8px; }
.total-pill { padding: 8px 14px; border-radius: 999px; font-weight: 600; }
.total-pill.ok { background: var(--ok-soft); color: var(--ok); }
.total-pill.bad { background: var(--bad-soft); color: var(--bad); }
.errors { background: var(--bad-soft); color: var(--bad); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 14px; }
.errors ul { margin: 6px 0 0; padding-inline-start: 20px; }

/* ---------- empty / misc ---------- */
.empty { text-align: center; padding: 50px 20px; color: var(--ink-2); }
.empty h3 { margin-bottom: 6px; color: var(--ink); }
.empty .btn { margin-top: 16px; }
.loading { padding: 60px; text-align: center; color: var(--ink-3); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand-2); animation: spin .8s linear infinite; margin: 0 auto 10px; }
.divider { height: 1px; background: var(--line-2); margin: 4px 0; }
.upload-progress { margin-top: 10px; }

/* ---------- toasts / modal ---------- */
.toasts { position: fixed; top: 70px; inset-inline-start: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm); box-shadow: 0 6px 20px rgba(0,0,0,.2); font-size: 14px; max-width: 420px; animation: tin .2s ease-out; }
.toast.ok { background: var(--ok); }
.toast.bad { background: var(--bad); }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }
.modal-back { position: fixed; inset: 0; background: rgba(16, 30, 34, .55); z-index: 90; display: grid; place-items: center; padding: 20px; }
.modal { background: #fff; border-radius: var(--radius); max-width: min(980px, 100%); width: 100%; max-height: calc(100vh - 40px); overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal.sm { max-width: 460px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line-2); position: sticky; top: 0; background: #fff; z-index: 1; }
.modal-body { padding: 18px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line-2); }
.viewer img, .viewer video { max-height: 72vh; margin: 0 auto; border-radius: var(--radius-sm); }

/* ---------- responsive (iPad portrait & smaller) ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 240px minmax(0, 1fr); }
  .brand-sub { display: none; }
}
@media (max-width: 860px) {
  .container { padding: 16px; }
  .topbar { padding: 10px 14px; gap: 10px; flex-wrap: wrap; }
  .mainnav { order: 3; width: 100%; overflow-x: auto; }
  .split { grid-template-columns: 1fr; }
  .split > aside .stage-list { flex-direction: row; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x proximity; }
  .split > aside .stage-item { min-width: 190px; scroll-snap-align: start; }
  .grid-2, .grid-3, .grid-21, .inputs-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .pending-file { grid-template-columns: 44px 1fr; }
  .pending-file select, .pending-file .btn { grid-column: span 1; }
}

/* ---------- print (analysis report) ---------- */
@media print {
  body { background: #fff; }
  .topbar, .tabs, .no-print, .toasts, .crumbs { display: none !important; }
  .container { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
  .split { grid-template-columns: 1fr; }
  .split > aside .stage-list { flex-direction: row; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x proximity; }
  .split > aside .stage-item { min-width: 190px; scroll-snap-align: start; }
  .split > aside { display: none; }
  .print-only { display: block !important; }
}
.print-only { display: none; }

/* ===================== Bayyina v2 components ===================== */
.c-warn { color: var(--warn); }
.c-ok { color: var(--ok); }
.head-kpis { display: flex; gap: 22px; align-items: flex-end; }
.head-kpis > div { display: flex; flex-direction: column; }
.head-kpis b { font-size: 20px; }
.seg { display: inline-flex; background: var(--line-2); border-radius: 999px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; font: inherit; font-size: 13px; padding: 6px 14px; border-radius: 999px; cursor: pointer; color: var(--ink-2); }
.seg button.active { background: #fff; color: var(--brand); font-weight: 600; box-shadow: var(--shadow); }
.grid-21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.hash { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; color: var(--ink-3); word-break: break-all; }
.table-scroll { max-height: 560px; overflow: auto; }
code { background: var(--line-2); padding: 1px 6px; border-radius: 4px; font-size: 13px; }

/* plan */
.plan-box { background: #fbfcfa; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px; }
.plan { width: 100%; height: auto; display: block; max-height: 460px; }
.small-plan .plan { max-height: 240px; }
.plan.clickable { cursor: crosshair; }
.plan .pz { stroke: #b8c4bf; stroke-width: 0.06; }
.plan .pe { stroke: #6f7d78; stroke-width: 0.03; fill: #e4e8e5; cursor: pointer; }
.plan .k-slab { fill: none; stroke: #9aa7a2; stroke-width: 0.08; stroke-dasharray: 0.4 0.25; cursor: default; }
.plan .k-column, .plan .k-neck { fill: #b5c0bc; stroke: #3d4b47; stroke-width: 0.04; }
.plan .k-wall { fill: #d6dcd9; }
.plan .k-plaster { fill: #e8e2d4; stroke: none; }
.plan .k-footing { fill: #dfe5e2; }
.plan .k-blinding { fill: #eef0ee; stroke: #c9d0cd; }
.plan .k-tiebeam { fill: #d9dfdc; }
.plan .k-door, .plan .k-window, .plan .k-glazing { fill: #cfe0f2; stroke: #6d8fb4; }
.plan .pe.hl { stroke: var(--bad) !important; stroke-width: 0.18 !important; fill: #f6b4ad !important; }
.plan .pl { font-size: 0.55px; fill: #4a5a60; text-anchor: middle; font-family: var(--font); pointer-events: none; }
.plan .pwalk { fill: none; stroke: var(--brand-2); stroke-width: 0.09; stroke-dasharray: 0.3 0.15; opacity: .8; }
.plan .pf { fill: var(--brand-2); opacity: .65; cursor: pointer; }
.plan .pf.cur { fill: var(--accent); opacity: 1; stroke: #7a4f00; stroke-width: 0.06; }
.plan .pdir { stroke: var(--accent); stroke-width: 0.14; stroke-linecap: round; }
.plan .ppin circle { fill: var(--bad); stroke: #fff; stroke-width: 0.1; }
.plan .ppin text { fill: #fff; font-size: 0.6px; text-anchor: middle; font-weight: 700; font-family: var(--font); }
.plan .pnorth path { fill: var(--ink-2); }
.plan .pnorth text { font-size: 0.7px; text-anchor: middle; fill: var(--ink-2); font-family: var(--font); }

/* charts */
.chart { width: 100%; height: auto; display: block; }
.chart .cg { stroke: #e6eae7; stroke-width: 1; }
.chart .ct { font-size: 11px; fill: var(--ink-3); font-family: var(--font); }
.chart .cp { fill: none; stroke: #9aa7a2; stroke-width: 2.2; }
.chart .cx { fill: none; stroke: #b98ce0; stroke-width: 1.6; stroke-dasharray: 5 4; }
.chart .cv { fill: none; stroke: var(--brand-2); stroke-width: 2.4; }
.chart .cvd { fill: var(--brand-2); stroke: #fff; stroke-width: 2; }
.chart .ca { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 3 3; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin-top: 6px; }
.legend i { display: inline-block; width: 14px; height: 10px; border-radius: 3px; margin-inline-end: 6px; vertical-align: middle; }
.lg-p { background: #9aa7a2; } .lg-v { background: var(--brand-2); } .lg-x { background: #b98ce0; }
.pvbars { display: flex; flex-direction: column; gap: 10px; }
.pv-row { display: grid; grid-template-columns: 170px 1fr 92px; gap: 10px; align-items: center; font-size: 13px; }
.pv-track { position: relative; height: 12px; background: var(--line-2); border-radius: 999px; }
.pv-v { position: absolute; inset-block: 0; inset-inline-start: 0; background: var(--ok); border-radius: 999px; }
.pv-v.behind { background: var(--accent); }
.pv-p { position: absolute; top: -4px; bottom: -4px; width: 3px; background: var(--ink); border-radius: 2px; transform: translateX(50%); }
.pv-num { text-align: end; }

/* alerts */
.alert-row { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; padding: 10px 12px; border-radius: var(--radius-sm); background: #fafbf9; border: 1px solid var(--line-2); }
.alert-row.byc { background: #fff6f5; border-color: #f2d3cf; }
.alert-row.closed { opacity: .65; }
.en { color: var(--ink-3); }

/* gantt */
.gantt { display: flex; flex-direction: column; gap: 6px; }
.g-row { display: grid; grid-template-columns: 260px 1fr 110px; gap: 10px; align-items: center; }
.g-track { position: relative; height: 18px; background: #f6f7f4; border-radius: 4px; }
.g-bar { position: absolute; inset-block: 2px; background: #dfe7e4; border-radius: 4px; overflow: hidden; }
.g-bar i { display: block; height: 100%; background: var(--brand-2); opacity: .8; }
.g-now { position: absolute; inset-block: -3px; width: 2px; background: var(--accent); }

/* captures */
.cap-card { padding: 0; overflow: hidden; color: inherit; }
.cap-card:hover { text-decoration: none; border-color: #b9c8c5; }
.cap-cover { aspect-ratio: 2 / 1; background: #e3e7e4; position: relative; overflow: hidden; }
.cap-cover img { width: 100%; height: 100%; object-fit: cover; }
.cap-dev { position: absolute; top: 8px; inset-inline-start: 8px; background: rgba(15,61,74,.85); color: #fff; font-size: 12px; padding: 2px 10px; border-radius: 999px; }
.ds-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); }
.frame-strip { display: flex; gap: 4px; overflow-x: auto; margin-top: 8px; padding-bottom: 4px; }
.frame-strip button { flex: none; width: 84px; height: 46px; padding: 0; border: 2px solid transparent; border-radius: 4px; overflow: hidden; background: #ddd; cursor: pointer; }
.frame-strip button.on { border-color: var(--accent); }
.frame-strip img { width: 100%; height: 100%; object-fit: cover; }
.pin-row { display: grid; grid-template-columns: 28px 120px 1fr; gap: 8px; align-items: center; }
.mode-card { display: flex; flex-direction: column; gap: 4px; padding: 14px; border: 2px solid var(--line); border-radius: var(--radius); cursor: pointer; }
.mode-card.active { border-color: var(--brand-2); background: var(--brand-soft); }
.mode-card.disabled { opacity: .6; cursor: not-allowed; }
.mode-card input { display: none; }

/* evidence */
.det-wrap { position: relative; border-radius: var(--radius-sm); overflow: hidden; background: #d9ddda; cursor: zoom-in; min-height: 60px; }
.det-wrap img { width: 100%; height: auto; display: block; }
.det-wrap.noimg::after { content: 'الصورة غير متاحة — شغّل استخراج اللقطات'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; color: var(--ink-3); }
.det-wrap.noimg { aspect-ratio: 2 / 1; }
.det-box { position: absolute; border: 2px solid #2ee59d; background: rgba(46,229,157,.12); border-radius: 2px; }
.det-box em { position: absolute; bottom: 100%; inset-inline-start: -2px; background: #2ee59d; color: #06281a; font-style: normal; font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: 3px 3px 0 0; white-space: nowrap; }
.blur-box { position: absolute; backdrop-filter: blur(9px); -webkit-backdrop-filter: blur(9px); background: rgba(200,200,200,.25); border-radius: 4px; }
.frame-tag { position: absolute; bottom: 6px; inset-inline-end: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 999px; }

/* review */
.review-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.sticky-side { position: sticky; top: 76px; max-height: calc(100vh - 160px); overflow: auto; }
.items { display: flex; flex-direction: column; gap: 6px; max-height: 70vh; overflow: auto; }
.item { display: grid; grid-template-columns: 1fr 96px auto; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); cursor: pointer; background: #fff; }
.item:hover { border-color: #b9c8c5; }
.item.sel { border-color: var(--brand-2); background: var(--brand-soft); }
.item.d-approve { box-shadow: inset 4px 0 0 var(--ok); }
.item.d-correct { box-shadow: inset 4px 0 0 var(--info); }
.item.d-reject { box-shadow: inset 4px 0 0 var(--bad); opacity: .75; }
[dir=rtl] .item.d-approve { box-shadow: inset -4px 0 0 var(--ok); }
[dir=rtl] .item.d-correct { box-shadow: inset -4px 0 0 var(--info); }
[dir=rtl] .item.d-reject { box-shadow: inset -4px 0 0 var(--bad); }
.it-conf { display: flex; align-items: center; gap: 6px; }
.conf { flex: 1; height: 6px; background: var(--line-2); border-radius: 999px; overflow: hidden; }
.conf i { display: block; height: 100%; }
.conf i.hi { background: var(--ok); } .conf i.lo { background: var(--accent); }
.it-act { display: flex; gap: 4px; align-items: center; }
.it-act select { min-height: 32px; padding: 2px 6px; font-size: 12px; width: 108px; }
.signbar { position: sticky; bottom: 0; z-index: 10; display: flex; gap: 12px; align-items: center; justify-content: flex-end; padding: 12px 16px; margin-top: 14px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 -4px 16px rgba(16,38,44,.08); }
.signbar [data-progress] { margin-inline-end: auto; }

/* reports */
.report { max-width: 980px; margin: 0 auto; }
.report h3 { margin: 22px 0 10px; font-size: 15px; }
.rep-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid var(--brand); padding-bottom: 12px; margin-bottom: 14px; }
.rep-head h1 { font-size: 20px; }
.rep-date { display: flex; flex-direction: column; align-items: flex-end; }
.rep-date b { font-size: 18px; }
.bi { display: inline-flex; flex-direction: column; line-height: 1.25; }
.bi .en { font-size: .78em; font-weight: 400; }
.rep-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px 0; }
.rep-kpis > div { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.rep-kpis b { font-size: 22px; }
.rep-sign { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.rep-sign > div { display: flex; flex-direction: column; }
@media print {
  .report { box-shadow: none; border: 0; max-width: none; }
  .signbar, .seg { display: none !important; }
}
@media (max-width: 1100px) {
  .review-grid { grid-template-columns: 1fr; }
  .sticky-side { position: static; max-height: none; }
  .g-row { grid-template-columns: 180px 1fr 80px; }
}
@media (max-width: 860px) {
  .grid-21, .rep-kpis { grid-template-columns: 1fr 1fr; }
  .head-kpis { gap: 12px; }
  .pv-row { grid-template-columns: 110px 1fr 80px; }
}

/* ---- vision AI: live job panel, evidence crops, versions */
.modal.lg { max-width: min(1180px, 100%); }
.accent-card { border: 1px solid var(--accent); box-shadow: 0 0 0 3px rgba(242, 184, 75, .15); }
.job-panel { border-inline-start: 4px solid var(--brand-2); }
.live-feed { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 12px; }
.live-feed .lf { margin: 0; background: var(--line-2); border-radius: var(--radius-sm); overflow: hidden; animation: lfIn .35s ease; }
.live-feed .lf img { width: 100%; height: 110px; object-fit: contain; background: #1b2a2f; display: block; }
.live-feed .lf figcaption { font-size: 12px; padding: 4px 6px; line-height: 1.4; }
.live-feed .lf.flag { outline: 2px solid var(--warn); }
@keyframes lfIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.crop-ev { display: block; width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--line); cursor: zoom-in; }
.model-box { background: var(--line-2); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 12.5px; line-height: 1.6; }
.model-box .disagree { color: var(--bad); font-weight: 600; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--line-2); }
.ir-form th { width: 120px; color: var(--muted); font-weight: 600; }
