:root {
  --navy-950: #0b1120;
  --navy-900: #0f172a;
  --navy-800: #1e293b;
  --navy-700: #334155;
  --royal: #2563eb;
  --royal-dark: #1d4ed8;
  --teal: #0d9488;
  --emerald: #059669;
  --amber: #d97706;
  --danger: #dc2626;
  --purple: #7c3aed;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --radius: 14px;
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
}
* { box-sizing: border-box; font-family: 'Tajawal', system-ui, -apple-system, sans-serif; }
body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; overflow-x: hidden; }
button, input, select, textarea { font-family: inherit; }

/* Allow smooth text selection & Ctrl+C for codes, numbers, inputs, table cells */
.copyable, input, textarea, td, code, .qr-code-text { user-select: text !important; -webkit-user-select: text !important; }
.copy-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 6px; border: 1px solid #cbd5e1;
  background: #f8fafc; color: #475569; font-size: 11px; cursor: pointer;
  transition: all 0.15s; flex-shrink: 0; padding: 0;
}
.copy-btn:hover { background: #eff6ff; border-color: var(--royal); color: var(--royal); transform: scale(1.06); }

/* Scrollbar */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: #e2e8f0; }
::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 4px; }

/* Sleek Compact Floating Developer Watermark (Floats cleanly above content — detached from bottom edge) */
#brand-floating-shield {
  position: fixed; bottom: 14px; right: 16px; min-width: 205px; height: 44px;
  z-index: 2147483647;
  background: rgba(11, 17, 32, 0.86);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid rgba(56, 189, 248, 0.5);
  border-radius: 999px;
  display: flex; align-items: center; gap: 8px;
  padding: 4px 12px 4px 14px; color: #e2e8f0; cursor: pointer;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.34);
  user-select: none; transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
#brand-floating-shield:hover { transform: translateY(-2px); background: rgba(15, 23, 42, 0.96); box-shadow: 0 12px 28px rgba(37, 99, 235, 0.42); border-color: #38bdf8; }
#brand-floating-shield .bfs-logo {
  width: 28px; height: 30px; border-radius: 50%; background: rgba(255,255,255,0.96);
  padding: 2px; object-fit: contain; flex-shrink: 0; box-shadow: 0 2px 6px rgba(0,0,0,0.22);
}
#brand-floating-shield .bfs-info { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
#brand-floating-shield .bfs-top { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 900; color: #fff; }
#brand-floating-shield .bfs-dot { width: 6px; height: 6px; border-radius: 50%; background: #10b981; box-shadow: 0 0 7px rgba(16, 185, 129, 0.9); }
#brand-floating-shield .bfs-en { font-size: 8.5px; font-weight: 700; color: #cbd5e1; direction: ltr; }
#brand-floating-shield .bfs-call { font-size: 9px; font-weight: 800; color: #38bdf8; }
.mapper-box.kind-check { border-color: #059669; background: rgba(16,185,129,0.22); color: #065f46; }
.mapper-box.kind-sig { border-color: #db2777; background: rgba(219,39,119,0.18); color: #831843; }
#cloud-boot-banner {
  background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; border-radius: 10px;
  padding: 8px 12px; font-size: 12px; font-weight: 800; text-align: center; margin-bottom: 12px; display: none;
}

/* ==================== LOGIN VIEW ==================== */
#login-view {
  min-height: 100vh;
  background: radial-gradient(circle at top left, #1e3a8a 0%, #0f172a 55%, #020617 100%);
  display: flex; align-items: center; justify-content: center; padding: 24px 24px 68px;
}
.login-card {
  width: 100%; max-width: 510px; background: rgba(255,255,255,0.98);
  border-radius: 24px; padding: 30px 32px; box-shadow: 0 25px 60px rgba(0,0,0,0.45);
}
.login-logos-strip {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 16px; background: #f8fafc; border: 1.5px solid #e2e8f0;
  margin-bottom: 18px; width: 100%; overflow: hidden;
}
.login-logo-box {
  flex: 1 1 0; min-width: 0; max-width: 48%; height: 60px; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 2px 4px;
}
.login-logo-box img { max-height: 52px; max-width: 100%; width: auto; height: auto; object-fit: contain; display: block; }
.login-logo-fallback {
  font-size: 11.5px; font-weight: 900; color: #1e3a8a; line-height: 1.3;
  padding: 6px 10px; border-radius: 10px; background: #eff6ff; border: 1px dashed #93c5fd;
}
.login-logos-divider { width: 1.5px; height: 44px; background: #cbd5e1; }
.login-brand { text-align: center; margin-bottom: 20px; }
.login-brand h1 { margin: 0 0 6px; font-size: 20px; font-weight: 900; color: var(--navy-900); }
.login-brand p { margin: 0; font-size: 13px; color: var(--royal-dark); font-weight: 800; line-height: 1.5; }

.copyright-block {
  text-align: center; margin-top: 18px; padding-top: 12px; border-top: 1px solid #e2e8f0;
  font-size: 11px; color: #64748b; font-weight: 700; line-height: 1.65;
}
.copyright-block .en-copy { direction: ltr; font-family: system-ui, -apple-system, sans-serif; font-size: 10.5px; color: #475569; font-weight: 700; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 800; color: var(--navy-800); margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 10px 13px; border: 1.5px solid #cbd5e1; border-radius: 10px;
  font-size: 13.5px; font-weight: 600; color: var(--text); background: #f8fafc; transition: all 0.2s;
}
.form-control:focus { outline: none; border-color: var(--royal); background: #fff; box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
.form-control:disabled, .form-control[readonly] { background: #e2e8f0; color: #475569; cursor: not-allowed; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border: none; border-radius: 10px; font-size: 13px;
  font-weight: 800; cursor: pointer; transition: all 0.18s; text-decoration: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primary { background: linear-gradient(135deg, #2563eb, #1d4ed8); color: #fff; box-shadow: 0 4px 12px rgba(37,99,235,0.25); }
.btn-emerald { background: linear-gradient(135deg, #10b981, #059669); color: #fff; box-shadow: 0 4px 12px rgba(16,185,129,0.25); }
.btn-teal { background: linear-gradient(135deg, #14b8a6, #0d9488); color: #fff; }
.btn-amber { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; }
.btn-danger { background: linear-gradient(135deg, #ef4444, #dc2626); color: #fff; }
.btn-purple { background: linear-gradient(135deg, #8b5cf6, #7c3aed); color: #fff; }
.btn-outline { background: #fff; color: var(--navy-800); border: 1.5px solid #cbd5e1; }
.btn-outline:hover { background: #f8fafc; border-color: var(--royal); color: var(--royal); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }
.btn-xs { padding: 4px 9px; font-size: 11.5px; border-radius: 7px; }

.quick-login-box { margin-top: 16px; padding-top: 14px; border-top: 1.5px dashed #cbd5e1; }
.quick-login-title { font-size: 12px; font-weight: 800; color: var(--muted); margin-bottom: 9px; text-align: center; }
.quick-login-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.quick-btn {
  padding: 7px 6px; border-radius: 9px; border: 1px solid #cbd5e1; background: #f8fafc;
  font-size: 11.5px; font-weight: 800; color: var(--navy-800); cursor: pointer; transition: all 0.15s;
}
.quick-btn:hover { background: #eff6ff; border-color: var(--royal); color: var(--royal); }
.login-err {
  background: #fef2f2; border: 1.5px solid #fecaca; color: #b91c1c;
  padding: 10px; border-radius: 10px; font-size: 13px; font-weight: 700;
  margin-bottom: 14px; display: none; text-align: center;
}

/* ==================== APP SHELL ==================== */
#app-shell { display: none; min-height: 100vh; }
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 272px; flex-shrink: 0; background: linear-gradient(180deg, #0b1120 0%, #172038 100%);
  color: #e2e8f0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  z-index: 40; box-shadow: -4px 0 24px rgba(0,0,0,0.12); padding-bottom: 84px;
}
.sidebar-header {
  padding: 18px 16px; border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 12px;
}
.sb-icon {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #0d9488);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden;
}
.sb-title { font-size: 15px; font-weight: 900; color: #fff; line-height: 1.25; }
.sb-sub { font-size: 11px; color: #94a3b8; font-weight: 600; }

.sb-nav { padding: 14px 12px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 5px; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 13px; border-radius: 11px; color: #cbd5e1; font-size: 13.5px;
  font-weight: 700; cursor: pointer; transition: all 0.18s; border: 1px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,0.07); color: #fff; }
.nav-item.active {
  background: linear-gradient(135deg, rgba(37,99,235,0.92), rgba(29,78,216,0.92));
  color: #fff; box-shadow: 0 6px 16px rgba(37,99,235,0.3);
}
.nav-left { display: flex; align-items: center; gap: 10px; }
.nav-badge { background: #ef4444; color: #fff; font-size: 11px; font-weight: 900; padding: 2px 7px; border-radius: 20px; min-width: 22px; text-align: center; }
.nav-badge.teal { background: var(--teal); }

.sb-user-box {
  margin: 8px 12px 4px; padding: 12px; border-radius: 12px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08);
}
.sb-user-name { font-size: 13px; font-weight: 800; color: #fff; margin-bottom: 3px; }
.sb-user-role { display: inline-block; font-size: 11px; font-weight: 800; padding: 2px 9px; border-radius: 20px; background: rgba(13,148,136,0.25); color: #5eead4; margin-bottom: 8px; }
.sb-switcher { width: 100%; padding: 6px 8px; border-radius: 8px; background: #0f172a; color: #e2e8f0; border: 1px solid #334155; font-size: 11.5px; font-weight: 700; margin-bottom: 8px; }

/* Main Content */
.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: #fff; border-bottom: 1px solid var(--border); padding: 13px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  position: sticky; top: 0; z-index: 30;
}
.topbar-title { font-size: 18px; font-weight: 900; color: var(--navy-900); margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sync-pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 13px;
  border-radius: 20px; font-size: 12px; font-weight: 800;
  background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0;
}
.sync-pill.ready { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: #10b981; }
.sync-pill.ready .sync-dot { background: #2563eb; }
.sync-pill.syncing { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.sync-pill.syncing .sync-dot { background: #f59e0b; animation: pulseDot 1s infinite; }
@keyframes pulseDot { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.45); opacity: 0.45; } }
.studio-loader-overlay {
  position: absolute; inset: 0; background: rgba(15,23,42,0.78); backdrop-filter: blur(3px);
  display: none; flex-direction: column; align-items: center; justify-content: center;
  color: #fff; gap: 12px; z-index: 40; font-size: 14px; font-weight: 800; text-align: center; padding: 20px;
}
.spinner-ring {
  width: 42px; height: 42px; border: 4px solid rgba(255,255,255,0.22);
  border-top-color: #38bdf8; border-radius: 50%; animation: spinRing 0.75s linear infinite;
}
@keyframes spinRing { to { transform: rotate(360deg); } }

.content-pad { padding: 20px 24px 72px; flex: 1; }
.view-section { display: none; }
.view-section.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ==================== MODERN ROLE HERO & ANALYTICS DASHBOARD ==================== */
.dash-hero {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 60%, #0f766e 100%);
  border-radius: 18px; padding: 20px 24px; color: #fff; margin-bottom: 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.16);
}
.dash-hero-left { display: flex; align-items: center; gap: 16px; }
.dash-entity-logo {
  width: 72px; height: 72px; border-radius: 16px; background: rgba(255,255,255,0.96);
  display: flex; align-items: center; justify-content: center; padding: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.2); flex-shrink: 0; overflow: hidden;
}
.dash-entity-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.dash-hero-title { font-size: 19px; font-weight: 900; margin: 0 0 4px; }
.dash-hero-proj { font-size: 13px; color: #bfdbfe; font-weight: 700; margin: 0 0 8px; }
.dash-quick-chips { display: flex; gap: 7px; flex-wrap: wrap; }
.q-chip {
  padding: 5px 12px; border-radius: 20px; border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.12); color: #fff; font-size: 12px; font-weight: 800;
  cursor: pointer; transition: all 0.15s;
}
.q-chip:hover { background: rgba(255,255,255,0.24); transform: translateY(-1px); }
.dash-hero-logos-pair { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; max-width: 100%; overflow: hidden; }
.dash-mini-logo {
  height: 46px; width: 116px; max-width: 46vw; background: rgba(255,255,255,0.96);
  border-radius: 11px; padding: 5px 8px; display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 1; min-width: 0;
}
.dash-mini-logo img { max-height: 36px; max-width: 100%; width: auto; height: auto; object-fit: contain; display: block; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; transition: all 0.18s;
}
.kpi-card:hover { border-color: var(--royal); transform: translateY(-2px); }
.kpi-label { font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 5px; }
.kpi-val { font-size: 27px; font-weight: 900; color: var(--navy-900); line-height: 1; }
.kpi-icon { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 21px; flex-shrink: 0; }
.kpi-blue { background: #eff6ff; color: #2563eb; }
.kpi-amber { background: #fffbeb; color: #d97706; }
.kpi-purple { background: #f5f3ff; color: #7c3aed; }
.kpi-emerald { background: #ecfdf5; color: #059669; }

.analytics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }
.bar-row { margin-bottom: 10px; }
.bar-row-top { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 800; margin-bottom: 4px; color: var(--navy-800); }
.bar-track { height: 9px; background: #e2e8f0; border-radius: 10px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 10px; transition: width 0.45s ease; }

/* Panels & Tables */
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; padding-bottom: 11px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.panel-header h2, .panel-header h3 { margin: 0; font-size: 15.5px; font-weight: 900; color: var(--navy-900); }

.filters-bar { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters-bar .form-control { width: auto; min-width: 145px; padding: 8px 11px; font-size: 13px; }
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th { background: #f8fafc; color: var(--navy-800); font-weight: 800; text-align: right; padding: 11px 12px; border-bottom: 2px solid var(--border); white-space: nowrap; }
table.data-table td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; font-weight: 600; }
table.data-table tr:hover td { background: #f8fafc; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 800; white-space: nowrap; }
.b-proposal { background: #e0f2fe; color: #0369a1; }
.b-mir { background: #ede9fe; color: #6d28d9; }
.b-mar { background: #fef3c7; color: #b45309; }
.b-custom { background: #f1f5f9; color: #334155; }
.st-pending { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.st-owner { background: #f5f3ff; color: #6d28d9; border: 1px solid #ddd6fe; }
.st-dc { background: #ecfeff; color: #0e7490; border: 1px solid #a5f3fc; }
.st-approved { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.st-rejected { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

.stepper-mini { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.step-chip { font-size: 10.5px; font-weight: 800; padding: 2px 7px; border-radius: 6px; background: #f1f5f9; color: #64748b; }
.step-chip.done { background: #d1fae5; color: #065f46; }
.step-chip.curr { background: #dbeafe; color: #1d4ed8; box-shadow: 0 0 0 1px #93c5fd; }
.step-chip.rej { background: #fee2e2; color: #991b1b; }

/* Visual Folder Tree */
.visual-tree { background: #0f172a; color: #e2e8f0; border-radius: 14px; padding: 16px 18px; font-size: 13px; line-height: 1.7; max-height: 520px; overflow-y: auto; }
.vt-node { padding: 4px 0; }
.vt-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 8px; border-radius: 8px; }
.vt-row:hover { background: rgba(255,255,255,0.06); }
.vt-name { display: flex; align-items: center; gap: 7px; font-weight: 700; unicode-bidi: plaintext; }
.vt-count { font-size: 11px; font-weight: 800; padding: 1px 8px; border-radius: 12px; background: rgba(56,189,248,0.18); color: #38bdf8; }
.vt-count.zero { background: rgba(148,163,184,0.15); color: #94a3b8; }
.vt-children { margin-right: 20px; padding-right: 12px; border-right: 1.5px dashed rgba(148,163,184,0.35); }

/* Permissions Grid */
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; background: #f8fafc; padding: 12px; border-radius: 12px; border: 1.5px solid #cbd5e1; }
.perm-item { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid #e2e8f0; padding: 7px 10px; border-radius: 9px; font-size: 12px; font-weight: 800; color: #1e293b; cursor: pointer; }
.perm-item input { width: 16px; height: 16px; accent-color: var(--royal); cursor: pointer; }
.perm-item:hover { border-color: var(--royal); background: #eff6ff; }

/* ==================== SUBMIT VIEW (EXACT LOCKED A4 DIMENSIONS!) ==================== */
.model-tabs { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 16px; }
.model-tab { padding: 10px 16px; border-radius: 12px; border: 1.5px solid var(--border); background: #fff; font-size: 13.5px; font-weight: 800; color: var(--navy-700); cursor: pointer; transition: all 0.18s; display: flex; align-items: center; gap: 7px; }
.model-tab:hover { border-color: var(--royal); color: var(--royal); }
.model-tab.active { background: linear-gradient(135deg, #2563eb, #1d4ed8); color: #fff; border-color: #1d4ed8; box-shadow: 0 6px 16px rgba(37,99,235,0.25); }
.mode-toggle-bar { display: inline-flex; background: #e2e8f0; padding: 4px; border-radius: 12px; gap: 4px; }
.mode-btn { padding: 8px 15px; border-radius: 9px; border: none; background: transparent; font-size: 13px; font-weight: 800; color: #475569; cursor: pointer; transition: all 0.18s; }
.mode-btn.active { background: #fff; color: var(--royal); box-shadow: 0 2px 8px rgba(0,0,0,0.08); }

.split-workspace { display: grid; grid-template-columns: 1.02fr 0.98fr; gap: 20px; align-items: start; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.dropzone { border: 2px dashed var(--teal); background: #f0fdfa; border-radius: 14px; padding: 18px; text-align: center; cursor: pointer; transition: all 0.2s; }
.dropzone:hover, .dropzone.dragover { background: #ccfbf1; border-color: #0f766e; }
.dropzone p { margin: 4px 0 0; font-size: 13px; font-weight: 800; color: #0f766e; }
.dropzone small { color: #64748b; font-weight: 600; }

.file-chip-list { display: flex; flex-direction: column; gap: 7px; margin-top: 10px; }
.file-chip { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #f8fafc; border: 1px solid #cbd5e1; border-radius: 10px; padding: 8px 12px; font-size: 12.5px; font-weight: 700; }
.qr-preview-bar { background: #f8fafc; border: 1.5px solid #bfdbfe; border-radius: 12px; padding: 11px 14px; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.qr-code-text { font-family: monospace; font-size: 13.5px; font-weight: 900; color: #1d4ed8; direction: ltr; word-break: break-all; }

/* STRICT TRUE A4 PAPER LOCK (210x297 = 794x1123 px at 96dpi) — NEVER STRETCHES! */
.a4-preview-shell {
  background: #334155; padding: 14px; border-radius: 14px; overflow: hidden;
  display: flex; flex-direction: column; align-items: center;
}
.a4-preview-toolbar { width: 100%; display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; color: #fff; font-size: 12.5px; font-weight: 800; gap: 8px; flex-wrap: wrap; }
.a4-scale-wrap { width: 100%; display: flex; justify-content: center; overflow: hidden; }
.a4-paper {
  background: #fff; color: #000; position: relative; box-shadow: 0 12px 35px rgba(0,0,0,0.4);
  transform-origin: top center; direction: rtl; overflow: hidden; flex-shrink: 0;
}
.a4-paper.portrait { width: 794px; height: 1123px; padding: 14px; }
.a4-paper.landscape { width: 1123px; height: 794px; padding: 14px; }
.a4-paper.official-tpl { padding: 0 !important; }
.tpl-bg-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; pointer-events: none; }
.tpl-overlay-field {
  position: absolute; overflow: hidden; display: flex; align-items: center;
  line-height: 1.25; word-break: break-word; padding: 1px 3px;
}
.tpl-overlay-field img { width: 100%; height: 100%; max-width: 100%; max-height: 100%; object-fit: contain; display: block; margin: auto; }

/* Built-in Fallback Official Form Styles (fits cleanly inside locked 1123px height) */
.doc-header-box { border: 1.8px solid #000; border-radius: 8px; overflow: hidden; margin-bottom: 6px; }
.doc-header-tbl { width: 100%; border-collapse: collapse; table-layout: fixed; }
.doc-header-tbl td { border: 1px solid #000; padding: 3px 5px; text-align: center; vertical-align: middle; font-size: 10.5px; font-weight: 700; }
.doc-logo-slot { height: 48px; width: 100%; overflow: hidden; display: flex; align-items: center; justify-content: center; padding: 2px; }
.doc-logo-slot img { max-height: 44px; max-width: 100%; width: auto; height: auto; object-fit: contain; display: block; }
.doc-qr-cell { width: 108px; padding: 3px !important; background: #fff; }
.doc-qr-box { width: 98px; height: 98px; margin: 0 auto; display: flex; align-items: center; justify-content: center; }
.doc-qr-box img { width: 98px !important; height: 98px !important; display: block; }
.doc-title-band { background: #1e3a8a; color: #fff; text-align: center; padding: 5px; font-size: 13px; font-weight: 900; border-radius: 6px; margin-bottom: 6px; }
.doc-drawing-area { border: 1.8px solid #000; border-radius: 8px; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; background: #fff; }
.doc-sig-grid { display: grid; gap: 8px; margin-top: 6px; }
.doc-sig-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.doc-sig-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.doc-sig-box { border: 1.5px solid #000; border-radius: 10px; padding: 5px 8px; height: 90px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.doc-sig-title { text-align: center; font-size: 11px; font-weight: 900; border-bottom: 1px solid #000; padding-bottom: 2px; }
.doc-sig-co { text-align: center; font-size: 9.5px; font-weight: 800; }
.doc-sig-lines { font-size: 9px; font-weight: 700; line-height: 1.45; }
.doc-tbl { width: 100%; border-collapse: collapse; margin-bottom: 6px; font-size: 11px; }
.doc-tbl th, .doc-tbl td { border: 1px solid #000; padding: 4px 6px; text-align: right; }
.doc-tbl th { background: #eff6ff; font-weight: 800; color: #0f172a; }
.doc-sec-hdr { background: #e2e8f0; border: 1px solid #000; padding: 3px 8px; font-size: 11.5px; font-weight: 900; margin: 5px 0 3px; }

/* ==================== REVIEW STUDIO & TEMPLATE MAPPER MODALS ==================== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,0.75); backdrop-filter: blur(4px);
  z-index: 1000; display: none; align-items: center; justify-content: center; padding: 12px;
}
.modal-backdrop.open { display: flex; }
.studio-modal {
  width: 100%; max-width: 1460px; height: 94vh; background: var(--bg);
  border-radius: 18px; overflow: hidden; display: flex; flex-direction: column;
  box-shadow: 0 30px 70px rgba(0,0,0,0.45);
}
.studio-topbar { background: var(--navy-900); color: #fff; padding: 11px 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.studio-body { flex: 1; display: grid; grid-template-columns: 330px 1fr 140px; min-height: 0; overflow: hidden; }
.mapper-body { flex: 1; display: grid; grid-template-columns: 340px 1fr; min-height: 0; overflow: hidden; }
.studio-decision-panel { background: #fff; border-left: 1px solid var(--border); padding: 15px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.studio-canvas-zone { background: #334155; position: relative; overflow: auto; display: flex; flex-direction: column; align-items: center; padding: 16px; }
.studio-thumbs-strip { background: #1e293b; border-right: 1px solid #334155; padding: 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.thumb-item { width: 104px; background: #fff; border-radius: 8px; padding: 4px; cursor: pointer; border: 2.5px solid transparent; transition: all 0.15s; text-align: center; }
.thumb-item.active { border-color: #38bdf8; box-shadow: 0 0 12px rgba(56,189,248,0.45); }
.thumb-item canvas { width: 100%; height: auto; display: block; border-radius: 4px; }
.thumb-label { font-size: 11px; font-weight: 800; color: #0f172a; margin-top: 4px; }

.floating-toolbar {
  position: sticky; top: 8px; z-index: 25; background: rgba(15, 23, 42, 0.94); backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.14); border-radius: 14px; padding: 8px 12px;
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 14px; box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}
.ft-btn { padding: 7px 11px; border-radius: 9px; border: 1px solid rgba(255,255,255,0.12); background: rgba(255,255,255,0.08); color: #fff; font-size: 12px; font-weight: 800; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; transition: all 0.15s; }
.ft-btn:hover { background: var(--royal); border-color: var(--royal); }
.ft-btn.dc-accent { background: #0d9488; border-color: #14b8a6; }
.ft-sep { width: 1px; height: 22px; background: rgba(255,255,255,0.18); margin: 0 2px; }

/* PDF Stage & Smart Multi-Handle Stamps/Mapper Fields */
.pdf-stage { position: relative; display: inline-block; box-shadow: 0 12px 35px rgba(0,0,0,0.45); background: #fff; }
.pdf-stage canvas { display: block; }
.overlay-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.stamp-item {
  position: absolute; pointer-events: auto; cursor: move; user-select: none;
  border: 1.5px dashed transparent; transition: border-color 0.12s;
}
.stamp-item:hover, .stamp-item.selected { border-color: #2563eb; background: rgba(37,99,235,0.06); }
.stamp-item img { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.stamp-del {
  position: absolute; top: -11px; left: -11px; width: 22px; height: 22px; border-radius: 50%;
  background: #ef4444; color: #fff; border: 2px solid #fff; font-size: 11px; font-weight: 900;
  cursor: pointer; display: none; align-items: center; justify-content: center; z-index: 5;
}
.stamp-handle {
  position: absolute; background: #2563eb; border: 2px solid #fff; display: none; z-index: 5;
}
.stamp-handle.corner { bottom: -7px; right: -7px; width: 14px; height: 14px; border-radius: 3px; cursor: nwse-resize; }
.stamp-handle.edge-h { bottom: -6px; left: 50%; transform: translateX(-50%); width: 22px; height: 10px; border-radius: 4px; cursor: ns-resize; background: #0d9488; }
.stamp-handle.edge-w { top: 50%; left: -6px; transform: translateY(-50%); width: 10px; height: 22px; border-radius: 4px; cursor: ew-resize; background: #7c3aed; }
.stamp-item:hover .stamp-del, .stamp-item.selected .stamp-del,
.stamp-item:hover .stamp-handle, .stamp-item.selected .stamp-handle { display: flex; }

/* Visual Template Mapper Box */
.mapper-stage {
  position: relative; background: #fff; box-shadow: 0 12px 40px rgba(0,0,0,0.45);
  overflow: hidden; flex-shrink: 0;
}
.mapper-box {
  position: absolute; border: 2px dashed #2563eb; background: rgba(37,99,235,0.14);
  color: #1e3a8a; font-size: 11px; font-weight: 900; cursor: move; user-select: none;
  display: flex; align-items: center; justify-content: center; text-align: center; padding: 2px 4px;
}
.mapper-box.kind-logo { border-color: #0d9488; background: rgba(13,148,136,0.18); color: #115e59; }
.mapper-box.kind-qr { border-color: #7c3aed; background: rgba(124,58,237,0.18); color: #4c1d95; }
.mapper-box.kind-stamp { border-color: #d97706; background: rgba(217,119,6,0.18); color: #92400e; }
.mapper-box.selected { border-style: solid; border-width: 2.5px; box-shadow: 0 0 0 3px rgba(37,99,235,0.28); z-index: 10; }
.mapper-resize { position: absolute; bottom: -6px; right: -6px; width: 13px; height: 13px; background: #2563eb; border: 2px solid #fff; border-radius: 3px; cursor: nwse-resize; }

/* Admin Tabs */
.admin-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.admin-tab { padding: 10px 15px; border-radius: 11px; border: 1.5px solid var(--border); background: #fff; font-size: 13px; font-weight: 800; color: var(--navy-700); cursor: pointer; }
.admin-tab.active { background: var(--navy-900); color: #fff; border-color: var(--navy-900); }
.admin-subview { display: none; }
.admin-subview.active { display: block; }

.token-pill { display: inline-block; padding: 4px 10px; border-radius: 8px; background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; font-size: 12px; font-weight: 800; cursor: pointer; margin: 3px; direction: ltr; }
.audit-item { border-right: 3px solid var(--royal); padding: 6px 10px; background: #f8fafc; border-radius: 0 8px 8px 0; font-size: 12px; margin-bottom: 7px; }
.small-modal { width: 100%; max-width: 700px; max-height: 92vh; overflow-y: auto; background: #fff; border-radius: 18px; padding: 24px; box-shadow: 0 25px 60px rgba(0,0,0,0.4); }

/* Toast */
#toast-container { position: fixed; bottom: 58px; left: 20px; z-index: 2147483640; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--navy-900); color: #fff; padding: 11px 17px; border-radius: 12px; font-size: 13px; font-weight: 800; box-shadow: 0 10px 25px rgba(0,0,0,0.25); border-right: 5px solid #10b981; max-width: 390px; animation: fadeIn 0.2s ease; }
.toast.error { border-right-color: #ef4444; }
.toast.warn { border-right-color: #f59e0b; }

.page-footer-copy {
  text-align: center; padding: 14px 16px; margin-top: 24px; border-top: 1px solid var(--border);
  font-size: 11.5px; color: #64748b; font-weight: 700; line-height: 1.7;
}
.page-footer-copy .en-copy { direction: ltr; font-family: system-ui, sans-serif; font-size: 11px; color: #475569; }

@media (max-width: 1180px) {
  .split-workspace, .analytics-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .studio-body { grid-template-columns: 280px 1fr 110px; }
}
/* Water (Sky Blue) & Sewage (Orange) Visual Identity */
.b-water { background: #e0f2fe; color: #0369a1; border: 1px solid #38bdf8; }
.b-sewage { background: #ffedd5; color: #c2410c; border: 1px solid #fb923c; }
table.data-table tr.row-water td { background: #eef8ff !important; }
table.data-table tr.row-water:hover td { background: #dff1ff !important; }
table.data-table tr.row-water td:first-child { border-right: 4px solid #0284c7; }
table.data-table tr.row-sewage td { background: #fff4e6 !important; }
table.data-table tr.row-sewage:hover td { background: #ffe8cc !important; }
table.data-table tr.row-sewage td:first-child { border-right: 4px solid #ea580c; }
.detected-section-hdr {
  font-size: 11.5px; font-weight: 900; color: #0f766e; background: #f0fdfa;
  border: 1px solid #99f6e4; border-radius: 8px; padding: 5px 8px; margin: 6px 0 4px;
}

/* Mobile Drawer Trigger & Backdrop */
#mobile-menu-btn {
  display: none; width: 38px; height: 38px; border-radius: 10px; border: 1.5px solid #cbd5e1;
  background: #f8fafc; color: var(--navy-900); font-size: 19px; cursor: pointer;
  align-items: center; justify-content: center; flex-shrink: 0;
}
#mobile-sidebar-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.58);
  z-index: 90; backdrop-filter: blur(2px);
}
#mobile-sidebar-backdrop.open { display: block; }
#st-mobile-tabbar { display: none; }

@media (max-width: 860px) {
  #mobile-menu-btn { display: inline-flex; }
  .sidebar {
    position: fixed; top: 0; right: -290px; bottom: 0; width: 272px; height: 100dvh;
    z-index: 100; transition: right 0.24s ease; display: flex !important;
  }
  .sidebar.mobile-open { right: 0; }
  .topbar { padding: 10px 12px; gap: 8px; }
  .topbar-title { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55vw; }
  .sync-pill { padding: 4px 8px; font-size: 10.5px; }
  .content-pad { padding: 12px 12px 76px; }
  .login-card { padding: 20px 16px; border-radius: 18px; }
  .login-logos-strip { padding: 8px; gap: 6px; }
  .login-logo-box { height: 50px; }
  .login-logo-box img { max-height: 40px; }
  .login-logos-divider { height: 34px; }
  .dash-hero { padding: 14px; gap: 12px; }
  .dash-hero-left { gap: 10px; align-items: flex-start; }
  .dash-entity-logo { width: 54px; height: 54px; border-radius: 12px; }
  .dash-hero-title { font-size: 15.5px; }
  .dash-hero-proj { font-size: 11.5px; }
  .dash-hero-logos-pair { width: 100%; justify-content: center; }
  .dash-mini-logo { height: 40px; width: 46%; max-width: 140px; }
  .dash-mini-logo img { max-height: 30px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-card { padding: 12px; }
  .kpi-val { font-size: 22px; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .filters-bar .form-control { width: 100%; min-width: 0; }
  .perm-grid { grid-template-columns: 1fr; }

  /* Full-screen unobstructed Mobile Review Studio & Mapper */
  .modal-backdrop { padding: 0; }
  .studio-modal { height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .studio-topbar { padding: 8px 10px; gap: 6px; }
  #st-mobile-tabbar {
    display: flex; background: #1e293b; padding: 6px 10px; gap: 6px; border-bottom: 1px solid #334155;
  }
  #st-mobile-tabbar button {
    flex: 1; padding: 7px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.14);
    background: rgba(255,255,255,0.08); color: #e2e8f0; font-size: 12px; font-weight: 800; cursor: pointer;
  }
  #st-mobile-tabbar button.active { background: var(--royal); color: #fff; border-color: var(--royal); }
  .studio-body { display: flex; flex-direction: column; overflow: hidden; }
  .studio-canvas-zone { order: 1; flex: 1; padding: 8px; min-height: 0; }
  .studio-decision-panel { order: 2; border-left: none; border-top: 1px solid var(--border); max-height: none; flex: 1; display: none; }
  .studio-body.mobile-show-panel .studio-canvas-zone,
  .studio-body.mobile-show-panel .studio-thumbs-strip { display: none; }
  .studio-body.mobile-show-panel .studio-decision-panel { display: flex; }
  .studio-thumbs-strip { order: 3; flex-direction: row; overflow-x: auto; height: 86px; flex-shrink: 0; padding: 6px; border-right: none; border-top: 1px solid #334155; }
  .thumb-item { width: 66px; flex-shrink: 0; }
  .floating-toolbar {
    position: static; width: 100%; overflow-x: auto; flex-wrap: nowrap;
    padding: 6px 8px; margin-bottom: 8px; border-radius: 10px; justify-content: flex-start;
  }
  .ft-btn { white-space: nowrap; padding: 6px 9px; font-size: 11px; flex-shrink: 0; }
  .mapper-body { display: flex; flex-direction: column; overflow-y: auto; }
  .mapper-body .studio-decision-panel { display: flex; order: 2; border-left: none; }
  .mapper-body .studio-canvas-zone { order: 1; min-height: 48vh; }

  /* Compact floating developer watermark on mobile */
  #brand-floating-shield {
    bottom: 10px; right: 10px; min-width: 185px; height: 38px; padding: 3px 10px; gap: 7px; border-radius: 999px;
  }
  #brand-floating-shield .bfs-logo { width: 24px; height: 26px; }
  #brand-floating-shield .bfs-call { display: none; }
}

/* v8.0 Enterprise Enhancements CSS */
.prop-sn-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: #fef2f2; color: #dc2626; border: 1.5px solid #fca5a5;
  padding: 2px 8px; border-radius: 7px; font-family: monospace; font-size: 11.5px; font-weight: 900; direction: ltr;
}
.a4-prop-sn-tag {
  position: absolute; z-index: 18;
  color: #dc2626; font-family: monospace; font-size: 14px; font-weight: 900;
  background: rgba(255,255,255,0.94); padding: 2px 8px; border-radius: 6px;
  border: 1.5px solid #dc2626; direction: ltr; pointer-events: none; white-space: nowrap;
}
.a4-prop-sn-tag.sn-no-border { border: none; background: transparent; padding: 0 2px; }
.a4-prop-sn-tag.admin-draggable {
  pointer-events: auto; cursor: move; user-select: none;
  box-shadow: 0 0 0 2px rgba(220,38,38,0.28);
}
.a4-prop-sn-tag .sn-admin-hint {
  position: absolute; top: -18px; right: 0; background: #dc2626; color: #fff;
  font-family: 'Tajawal', sans-serif; font-size: 9px; font-weight: 800;
  padding: 1px 6px; border-radius: 4px; white-space: nowrap; pointer-events: none;
}
.html2canvas-capturing .a4-prop-sn-tag.admin-draggable { box-shadow: none !important; }
.html2canvas-capturing .a4-prop-sn-tag .sn-admin-hint { display: none !important; }
.live-drag-stamp {
  position: absolute; z-index: 20; cursor: move; user-select: none;
  border: 1.5px dashed rgba(37, 99, 235, 0.55); border-radius: 6px;
  background: rgba(37, 99, 235, 0.04); transition: border-color 0.15s;
}
.live-drag-stamp:hover { border-color: #2563eb; background: rgba(37, 99, 235, 0.09); }
.live-drag-stamp img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; display: block; }
.live-drag-stamp .lds-hint {
  position: absolute; top: -18px; right: 0; background: #1e3a8a; color: #fff;
  font-size: 9px; font-weight: 800; padding: 1px 6px; border-radius: 4px; white-space: nowrap;
  pointer-events: none; opacity: 0.88;
}
.html2canvas-capturing .live-drag-stamp { border-color: transparent !important; background: transparent !important; }
.html2canvas-capturing .live-drag-stamp .lds-hint { display: none !important; }
.pagination-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 12.5px; font-weight: 800; color: var(--muted);
}
.login-support-box {
  background: #eff6ff; border: 1.5px solid #93c5fd; color: #1e3a8a; border-radius: 12px;
  padding: 10px 12px; margin-bottom: 14px; font-size: 12.5px; font-weight: 800; text-align: center; display: none;
}
.cal-drag-box {
  position: absolute; cursor: move; border: 2px dashed #2563eb; background: rgba(37,99,235,0.08);
  user-select: none; box-sizing: border-box;
}
.cal-drag-box img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; display: block; }
.b-wir-w { background: #e0f2fe; color: #0369a1; border: 1px solid #7dd3fc; }
.b-wir-s { background: #ffedd5; color: #c2410c; border: 1px solid #fdba74; }


/* Mandatory Field Distinction & Validation Highlights */
.req-star { color: #dc2626; font-weight: 900; margin-right: 3px; font-size: 14px; }
.form-control.req-input { border-right: 3.5px solid #2563eb; background: #fbfdff; }
.form-control.req-input:focus { border-right-color: #1d4ed8; background: #fff; }
.field-invalid {
  border-color: #dc2626 !important; border-width: 2px !important;
  background: #fef2f2 !important; box-shadow: 0 0 0 3px rgba(220,38,38,0.16) !important;
}
.req-group-box {
  background: #fbfdff; border: 1.5px solid #cbd5e1; border-right: 3.5px solid #2563eb;
  border-radius: 10px; padding: 7px 10px;
}

/* WIR Structured Ordered Attachment Slots */
.wir-slots-wrap { display: flex; flex-direction: column; gap: 9px; }
.wir-slot-card {
  background: #fff; border: 1.5px solid #cbd5e1; border-radius: 11px; padding: 10px 12px;
  transition: all 0.16s;
}
.wir-slot-card.is-mandatory { border-right: 4px solid #2563eb; background: #fbfdff; }
.wir-slot-card.is-filled { border-color: #10b981; border-right: 4px solid #059669; background: #f0fdf4; }
.wir-slot-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.wir-slot-num {
  width: 24px; height: 24px; border-radius: 7px; background: #1e3a8a; color: #fff;
  font-size: 11.5px; font-weight: 900; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.wir-slot-card.is-filled .wir-slot-num { background: #059669; }
.wir-slot-title { font-size: 12.5px; font-weight: 800; color: #0f172a; flex: 1; min-width: 160px; }
.wir-slot-files { display: flex; flex-direction: column; gap: 5px; margin-top: 7px; }
.slot-admin-row {
  display: grid; grid-template-columns: 30px 1fr 110px auto; gap: 7px; align-items: center;
  background: #f8fafc; border: 1px solid #cbd5e1; border-radius: 10px; padding: 8px 10px;
}
@media (max-width: 680px) {
  .slot-admin-row { grid-template-columns: 26px 1fr; }
}


/* v8.2 Arabic PDF Ligature Fix + Studio Quick-Copy + Preset Notes + Emergency Attach */
.a4-paper, .a4-paper * {
  letter-spacing: 0 !important;
  word-spacing: normal !important;
  font-feature-settings: "liga" 1, "calt" 1;
}
.st-quick-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(56, 189, 248, 0.16); border: 1px solid rgba(56, 189, 248, 0.45);
  color: #e0f2fe; padding: 3px 8px; border-radius: 8px; font-size: 11.5px; font-weight: 800;
}
.st-quick-chip code { color: #fde047; font-size: 12px; font-weight: 900; direction: ltr; }
.st-quick-chip .copy-btn { width: 20px; height: 20px; font-size: 10px; background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.3); color: #fff; }
.st-quick-chip .copy-btn:hover { background: #38bdf8; color: #0f172a; }
.size-limit-note {
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
  border-radius: 9px; padding: 6px 10px; font-size: 11.5px; font-weight: 800;
  margin-bottom: 9px; display: flex; align-items: center; gap: 6px;
}
.preset-notes-box {
  background: #f0f9ff; border: 1.5px solid #bae6fd; border-radius: 10px;
  padding: 9px 10px; margin-bottom: 10px;
}
.emergency-att-box {
  background: #fef2f2; border: 1.5px dashed #f87171; border-radius: 10px;
  padding: 9px 10px; margin-bottom: 10px;
}


/* v8.3 Contractor Draggable Sign/Stamp/Date/Name Pack + Locked Foreign Overlays */
.live-drag-item {
  position: absolute; z-index: 22; cursor: move; user-select: none;
  border: 1.5px dashed rgba(37, 99, 235, 0.55); border-radius: 6px;
  background: rgba(37, 99, 235, 0.04); transition: border-color 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.live-drag-item:hover { border-color: #2563eb; background: rgba(37, 99, 235, 0.1); z-index: 25; }
.live-drag-item img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; display: block; }
.live-drag-item .ldi-hint {
  position: absolute; top: -18px; right: 0; background: #1e3a8a; color: #fff;
  font-size: 9px; font-weight: 800; padding: 1px 6px; border-radius: 4px; white-space: nowrap;
  pointer-events: none; opacity: 0.9;
}
.live-drag-item .ldi-del {
  position: absolute; top: -10px; left: -10px; width: 18px; height: 18px; border-radius: 50%;
  background: #ef4444; color: #fff; border: 1.5px solid #fff; font-size: 10px; font-weight: 900;
  cursor: pointer; display: none; align-items: center; justify-content: center; padding: 0;
}
.live-drag-item:hover .ldi-del { display: flex; }
.live-drag-item.ldi-text {
  padding: 2px 6px; white-space: nowrap; font-weight: 900; color: #0f1f6b;
  background: rgba(255, 255, 255, 0.82);
}
.html2canvas-capturing .live-drag-item { border-color: transparent !important; background: transparent !important; }
.html2canvas-capturing .live-drag-item .ldi-hint,
.html2canvas-capturing .live-drag-item .ldi-del { display: none !important; }
.stamp-item.locked-foreign {
  pointer-events: none !important; cursor: default !important; border-color: transparent !important;
}
.stamp-item.locked-foreign .stamp-del,
.stamp-item.locked-foreign .stamp-handle { display: none !important; }

/* ==================== v9.0 MODERN ACCOUNT, DONUT TASKS, SLA, EXCEL IMPORT & AL-MUKHALISATI BOT ==================== */
.sb-user-top { display: flex; align-items: center; gap: 9px; margin-bottom: 7px; }
.sb-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #2563eb, #0d9488); color: #fff;
  font-weight: 900; font-size: 14px; display: flex; align-items: center; justify-content: center;
  overflow: hidden; border: 2px solid rgba(56, 189, 248, 0.55);
}
.sb-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.login-pass-wrap { position: relative; }
.login-pass-toggle {
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  background: transparent; border: none; cursor: pointer; font-size: 15px; color: #64748b; padding: 3px;
}
.login-pass-toggle:hover { color: var(--royal); }
.login-email-hint {
  font-size: 11px; color: #475569; font-weight: 700; margin-top: 4px; display: block;
}

/* Donut Tasks Widget (Non-Contractors) */
.tasks-donut-card {
  background: #fff; border: 1.5px solid #bfdbfe; border-radius: 16px;
  padding: 15px 18px; margin-bottom: 18px; box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
}
.donut-wrap {
  position: relative; width: 92px; height: 92px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.donut-wrap svg { transform: rotate(-90deg); width: 92px; height: 92px; }
.donut-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; pointer-events: none;
}
.donut-num { font-size: 24px; font-weight: 900; color: var(--navy-900); line-height: 1; }
.donut-lbl { font-size: 9.5px; font-weight: 800; color: var(--muted); margin-top: 2px; }
.donut-breakdown { flex: 1; min-width: 220px; }
.donut-chips-row { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 8px; }
.donut-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px;
  border-radius: 10px; font-size: 11.5px; font-weight: 800; cursor: pointer;
  border: 1px solid #cbd5e1; background: #f8fafc; color: #0f172a; transition: all 0.15s;
}
.donut-chip:hover { transform: translateY(-1px); border-color: var(--royal); background: #eff6ff; }
.donut-chip.water { background: #e0f2fe; border-color: #7dd3fc; color: #0369a1; }
.donut-chip.sewage { background: #ffedd5; border-color: #fdba74; color: #c2410c; }
.donut-chip.overdue { background: #fef2f2; border-color: #fca5a5; color: #b91c1c; }

/* SLA Overdue Badge */
.badge-sla-overdue {
  background: #fef2f2; color: #dc2626; border: 1px solid #fca5a5;
  padding: 2px 7px; border-radius: 8px; font-size: 10px; font-weight: 900;
  display: inline-flex; align-items: center; gap: 3px;
}

/* Password Strength Checklist */
.pw-rules-box {
  background: #f8fafc; border: 1px solid #cbd5e1; border-radius: 10px;
  padding: 8px 11px; margin-bottom: 11px; font-size: 11.5px; font-weight: 800;
  display: grid; grid-template-columns: 1fr 1fr; gap: 5px;
}
.pw-rule { color: #94a3b8; }
.pw-rule.ok { color: #059669; }

/* My Account Locked Stamp Card */
.acc-locked-card {
  background: #f8fafc; border: 1.5px dashed #94a3b8; border-radius: 12px; padding: 11px;
  text-align: center;
}
.acc-locked-card img { max-height: 62px; max-width: 100%; object-fit: contain; display: block; margin: 6px auto; }

/* Assistant Bot ("المخلصاتي") — Bottom-Left Compact Floating Widget */
#bot-launcher {
  position: fixed; bottom: 14px; left: 16px; z-index: 2147483645;
  display: none; align-items: center; gap: 7px;
  background: linear-gradient(135deg, #1d4ed8, #0d9488);
  color: #fff; border: 1.5px solid rgba(255,255,255,0.45);
  border-radius: 999px; padding: 6px 13px 6px 11px; height: 42px;
  box-shadow: 0 8px 24px rgba(29, 78, 216, 0.38); cursor: pointer;
  font-size: 12px; font-weight: 900; user-select: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
#bot-launcher:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(13, 148, 136, 0.45); }
#bot-launcher .bot-pulse {
  width: 9px; height: 9px; border-radius: 50%; background: #fde047;
  box-shadow: 0 0 0 0 rgba(253, 224, 71, 0.75); animation: botPulse 2s infinite;
}
@keyframes botPulse {
  0% { box-shadow: 0 0 0 0 rgba(253, 224, 71, 0.75); }
  70% { box-shadow: 0 0 0 9px rgba(253, 224, 71, 0); }
  100% { box-shadow: 0 0 0 0 rgba(253, 224, 71, 0); }
}
#bot-launcher .bot-hide-x {
  width: 18px; height: 18px; border-radius: 50%; background: rgba(15, 23, 42, 0.38);
  color: #fff; font-size: 10px; display: inline-flex; align-items: center; justify-content: center;
  border: none; cursor: pointer; margin-right: 2px;
}
#bot-launcher .bot-hide-x:hover { background: #ef4444; }

#bot-drawer {
  position: fixed; bottom: 64px; left: 16px; width: 350px; max-width: calc(100vw - 24px);
  height: 460px; max-height: calc(100dvh - 88px); z-index: 2147483646;
  background: #fff; border: 1.5px solid #cbd5e1; border-radius: 18px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.34);
  display: none; flex-direction: column; overflow: hidden;
}
#bot-drawer.open { display: flex; animation: fadeIn 0.18s ease; }
.bot-header {
  background: linear-gradient(135deg, #0f172a, #1d4ed8); color: #fff;
  padding: 11px 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.bot-messages {
  flex: 1; overflow-y: auto; padding: 12px; background: #f8fafc;
  display: flex; flex-direction: column; gap: 9px;
}
.bot-msg {
  max-width: 90%; padding: 9px 11px; border-radius: 12px; font-size: 12.2px;
  font-weight: 700; line-height: 1.55; white-space: pre-line;
}
.bot-msg.bot { align-self: flex-start; background: #fff; border: 1px solid #e2e8f0; color: #0f172a; border-top-right-radius: 3px; }
.bot-msg.user { align-self: flex-end; background: #2563eb; color: #fff; border-top-left-radius: 3px; }
.bot-quick-bar {
  padding: 7px 10px; background: #fff; border-top: 1px solid #e2e8f0;
  display: flex; gap: 5px; overflow-x: auto; flex-wrap: nowrap;
}
.bot-qchip {
  padding: 4px 9px; border-radius: 999px; border: 1px solid #bfdbfe; background: #eff6ff;
  color: #1e40af; font-size: 11px; font-weight: 800; white-space: nowrap; cursor: pointer; flex-shrink: 0;
}
.bot-qchip:hover { background: #2563eb; color: #fff; }
.bot-input-bar {
  display: flex; gap: 6px; padding: 8px 10px; background: #fff; border-top: 1px solid #e2e8f0;
}
.bot-input-bar input { flex: 1; padding: 8px 10px; border: 1.5px solid #cbd5e1; border-radius: 10px; font-size: 12.5px; }
.bot-result-card {
  background: #f0f9ff; border: 1px solid #bae6fd; border-radius: 9px; padding: 7px 9px; margin-top: 6px; font-size: 11.5px;
}

/* Historical Import Preview & Activity Log */
.imp-map-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.act-log-item {
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
  padding: 7px 10px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 9px; font-size: 12px;
}
@media (max-width: 860px) {
  #bot-launcher { bottom: 10px; left: 10px; height: 38px; padding: 4px 10px; font-size: 11px; }
  .imp-map-grid { grid-template-columns: 1fr; }
}

/* ==================== v9.2 STRICT LAYER STACKING (DRAWING ALWAYS BELOW STAMPS/SIGS/FIELDS) ==================== */
.doc-drawing-area, .prop-draw-box-target { z-index: 1 !important; overflow: hidden !important; }
.tpl-bg-img { z-index: 0 !important; }
.doc-header-box { position: relative; z-index: 10; background: #fff; }
.doc-sig-grid { z-index: 16 !important; }
.tpl-overlay-field:not(.prop-draw-box-target) { z-index: 20 !important; }
.a4-prop-sn-tag { z-index: 25 !important; }
.live-drag-item { z-index: 32 !important; }
.live-drag-item:hover { z-index: 38 !important; }
.a4-paper.fg-capture-mode { background: transparent !important; box-shadow: none !important; }
.a4-paper.fg-capture-mode > :not(.fg-top-layer) { visibility: hidden !important; }

/* ==================== v10.0 QUIET NOTIFICATIONS, INQUIRIES, CIRCULARS, CONTACTS & LTR BILINGUAL ==================== */
.notif-bell-wrap { position: relative; }
.notif-bell-btn {
  position: relative; width: 38px; height: 38px; border-radius: 11px;
  border: 1.5px solid #cbd5e1; background: #f8fafc; font-size: 17px;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  transition: all 0.16s;
}
.notif-bell-btn:hover { background: #eff6ff; border-color: var(--royal); }
.notif-bell-badge {
  position: absolute; top: -5px; right: -5px; min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: 999px; background: #ef4444; color: #fff; font-size: 10.5px; font-weight: 900;
  display: inline-flex; align-items: center; justify-content: center; border: 2px solid #fff;
}
.notif-drawer {
  position: absolute; top: 46px; left: 0; width: 330px; max-width: 90vw;
  background: #fff; border: 1.5px solid #cbd5e1; border-radius: 16px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.25); z-index: 95; display: none; overflow: hidden;
}
html[dir="ltr"] .notif-drawer { left: auto; right: 0; }
.notif-drawer.open { display: block; animation: fadeIn 0.16s ease; }
.notif-drawer-hdr {
  background: #0f172a; color: #fff; padding: 10px 13px;
  display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 900;
}
.notif-drawer-body { max-height: 360px; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.notif-item {
  display: flex; align-items: flex-start; gap: 9px; padding: 9px 10px;
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 11px; cursor: pointer; transition: all 0.15s;
}
.notif-item:hover { background: #eff6ff; border-color: #93c5fd; }
.notif-item.is-urgent { background: #fef2f2; border-color: #fecaca; }
.notif-ico { font-size: 17px; flex-shrink: 0; }
.notif-ttl { font-size: 12px; font-weight: 900; color: #0f172a; line-height: 1.35; }
.notif-sub { font-size: 11px; color: #64748b; font-weight: 700; margin-top: 2px; }

.quiet-micro-banner {
  display: none; align-items: center; gap: 10px; padding: 8px 16px;
  background: linear-gradient(90deg, #eff6ff, #f0fdfa); border-bottom: 1.5px solid #93c5fd;
  font-size: 12.5px; font-weight: 800; color: #1e3a8a;
}
.quiet-micro-banner.show { display: flex; animation: fadeIn 0.2s ease; }
.qmb-close { background: transparent; border: none; color: #64748b; font-size: 14px; font-weight: 900; cursor: pointer; padding: 2px 6px; }

.submit-freeze-banner {
  background: #fef2f2; border: 2px solid #ef4444; border-radius: 13px;
  padding: 12px 15px; margin-bottom: 14px; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}

.circular-card {
  background: #fff; border: 1.5px solid #cbd5e1; border-radius: 15px; padding: 15px 17px;
  border-right: 5px solid #2563eb; box-shadow: 0 3px 12px rgba(15, 23, 42, 0.05);
}
.circular-card.prio-high { border-right-color: #f59e0b; }
.circular-card.prio-urgent { border-right-color: #dc2626; background: #fffafa; }
.circular-card.unread { box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.22); }

.contacts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 14px; }
.contact-card {
  background: #fff; border: 1.5px solid #e2e8f0; border-radius: 16px; padding: 15px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; transition: all 0.16s;
}
.contact-card:hover { border-color: #93c5fd; transform: translateY(-2px); }
.contact-card.is-primary { border-color: #34d399; background: linear-gradient(180deg, #f0fdf4 0%, #ffffff 34%); }
.contact-card.is-inactive { opacity: 0.65; background: #f8fafc; }
.cc-top { display: flex; align-items: center; gap: 11px; margin-bottom: 11px; }
.cc-avatar {
  width: 46px; height: 46px; border-radius: 13px; flex-shrink: 0;
  background: linear-gradient(135deg, #1d4ed8, #0d9488); color: #fff;
  font-weight: 900; font-size: 16px; display: flex; align-items: center; justify-content: center;
}
.cc-details {
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 11px; padding: 9px 11px;
  display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; margin-bottom: 11px;
}
.cc-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cc-row span { color: #64748b; font-weight: 700; }
.cc-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: auto; }

/* Clean English LTR Layout Support (while keeping official A4 paper strictly RTL!) */
html[dir="ltr"] table.data-table th,
html[dir="ltr"] table.data-table td { text-align: left; }
html[dir="ltr"] .audit-item { border-right: none; border-left: 3px solid var(--royal); border-radius: 8px 0 0 8px; }
html[dir="ltr"] .circular-card { border-right: 1.5px solid #cbd5e1; border-left: 5px solid #2563eb; }
html[dir="ltr"] .circular-card.prio-high { border-left-color: #f59e0b; }
html[dir="ltr"] .circular-card.prio-urgent { border-left-color: #dc2626; }
html[dir="ltr"] .form-control.req-input { border-right: 1.5px solid #cbd5e1; border-left: 3.5px solid #2563eb; }
html[dir="ltr"] .a4-paper { direction: rtl !important; }
html[dir="ltr"] #brand-floating-shield { right: auto; left: 16px; }
html[dir="ltr"] #bot-launcher, html[dir="ltr"] #bot-drawer { left: auto; right: 16px; }
@media (max-width: 860px) {
  html[dir="ltr"] .sidebar { right: auto; left: -290px; transition: left 0.24s ease; }
  html[dir="ltr"] .sidebar.mobile-open { left: 0; }
}
