:root {
  /* Neutrals (slate) */
  --bg: #f5faf8; --surface: #ffffff; --surface-2: #f8fcfa;
  --border: #e3ebe7; --border-strong: #d2ddd7;
  --text: #0f1f1a; --text-soft: #33514a; --muted: #6b8079;
  /* Brand + accents (Emerald — default theme) */
  --primary: #059669; --primary-600: #047857; --primary-700: #065f46; --primary-400: #34d399; --primary-050: #e6f6ef;
  --purple: #14b8a6; --sky: #0ea5b8;
  --hero-1: #064e3b; --hero-2: #059669; --hero-3: #10b981; --primary-shadow: 5,150,105;
  /* Semantic status colors (constant across themes) */
  --green: #15a34a; --green-050: #e8f7ee;
  --red: #e1483f; --red-050: #fdeceb;
  --amber: #d68309; --amber-050: #fdf3e3;
  --gray: #94a0b5;
  /* Effects */
  --shadow-xs: 0 1px 2px rgba(15,23,42,.05);
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 4px 12px rgba(15,23,42,.05);
  --shadow-lg: 0 10px 34px rgba(15,23,42,.13);
  --radius: 16px; --radius-sm: 12px;
  --sidebar: #0b1f18; --sidebar-2: #143028;
}
/* ===== Theme: Ocean Blue ===== */
:root[data-theme="blue"] {
  --bg: #f4f7fe; --surface: #ffffff; --surface-2: #f7faff;
  --border: #e2e8f4; --border-strong: #cfdaec;
  --text: #0f1a2f; --text-soft: #33465e; --muted: #6b7a90;
  --primary: #2563eb; --primary-600: #1d4ed8; --primary-700: #1e40af; --primary-400: #60a5fa; --primary-050: #e8eefe;
  --purple: #06b6d4; --sky: #0ea5e9;
  --hero-1: #172554; --hero-2: #2563eb; --hero-3: #3b82f6; --primary-shadow: 37,99,235;
  --sidebar: #0b1626; --sidebar-2: #142944;
}
/* ===== Theme: Royal Violet ===== */
:root[data-theme="violet"] {
  --bg: #faf7fe; --surface: #ffffff; --surface-2: #fdfaff;
  --border: #ece5f6; --border-strong: #ddd0ee;
  --text: #1c122f; --text-soft: #4a3d5e; --muted: #7d7290;
  --primary: #7c3aed; --primary-600: #6d28d9; --primary-700: #5b21b6; --primary-400: #a78bfa; --primary-050: #f1e9fe;
  --purple: #d946ef; --sky: #a855f7;
  --hero-1: #2e1065; --hero-2: #7c3aed; --hero-3: #a78bfa; --primary-shadow: 124,58,237;
  --sidebar: #1a1030; --sidebar-2: #2a1b47;
}
* { box-sizing: border-box; }
html { font-size: clamp(14px, 1.55vw, 15.5px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Inter", "Cairo", "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.6; letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
html[dir="rtl"] body { font-family: "Cairo", "Inter", "Segoe UI", Tahoma, system-ui, sans-serif; letter-spacing: 0; line-height: 1.7; }
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.02em; }
.hidden { display: none !important; }
.spacer { flex: 1; }
.muted { color: var(--muted); font-size: .88rem; }
.ico { width: 20px; height: 20px; display: block; flex: none; }

/* --- Login (split hero) --- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
.auth-hero { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; padding: 48px;
  background: linear-gradient(150deg, var(--hero-1) 0%, var(--primary-700) 45%, var(--primary-600) 100%); color: #eafff6; }
.auth-hero-inner { position: relative; z-index: 2; max-width: 440px; animation: rise .6s ease both; }
.auth-brand .brand-word { color: #fff; }
.auth-brand .brand-sub { color: rgba(255,255,255,.6); }
.auth-brand .brand-mark { background: rgba(255,255,255,.14); box-shadow: none; }
.hero-headline { font-size: clamp(1.9rem, 3vw, 2.6rem); font-weight: 900; margin: 26px 0 12px; line-height: 1.25; letter-spacing: -0.02em; }
.hero-sub { font-size: 1.02rem; color: rgba(255,255,255,.82); line-height: 1.8; margin: 0 0 28px; }
.auth-features { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.auth-features li { display: flex; align-items: center; gap: 12px; font-size: .98rem; font-weight: 500; }
.feat-ico { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 10px; background: rgba(255,255,255,.14); }
.feat-ico .ico { width: 18px; height: 18px; color: #eafff6; }
.auth-hero-foot { margin-top: 36px; font-size: .78rem; color: rgba(255,255,255,.55); letter-spacing: .02em; }
.blob { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .5; z-index: 1; }
.blob-1 { width: 380px; height: 380px; background: var(--hero-3); top: -80px; inset-inline-end: -60px; animation: float1 14s ease-in-out infinite; }
.blob-2 { width: 320px; height: 320px; background: var(--purple); bottom: -80px; inset-inline-start: -40px; animation: float2 16s ease-in-out infinite; }
.blob-3 { width: 240px; height: 240px; background: var(--primary-400); top: 40%; inset-inline-start: 30%; opacity: .3; animation: float1 20s ease-in-out infinite; }
@keyframes float1 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(-24px,30px); } }
@keyframes float2 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(26px,-24px); } }

.auth-form { display: grid; place-items: center; padding: 30px; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); padding: clamp(26px,4vw,40px); border-radius: 22px; box-shadow: 0 20px 50px rgba(15,23,42,.10); border: 1px solid var(--border); animation: rise .5s ease both; }
.auth-card-brand { display: none; justify-content: center; margin-bottom: 16px; }
.auth-card-brand .brand-word { background: linear-gradient(120deg,var(--primary),var(--purple)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.auth-title { font-size: 1.7rem; font-weight: 800; }
.auth-subtitle { color: var(--muted); margin: 6px 0 26px; }
.btn-lg { padding: 13px 20px; font-size: .98rem; border-radius: 13px; }
.demo { margin-top: 20px; font-size: .74rem; color: var(--muted); border-top: 1px solid var(--border); padding-top: 14px; line-height: 1.95; }
.demo code { background: var(--bg); padding: 1px 6px; border-radius: 5px; }
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-form { background:
      radial-gradient(900px 500px at 80% -10%, rgba(16,185,129,.16), transparent 60%),
      radial-gradient(700px 500px at 0% 110%, rgba(20,184,166,.14), transparent 55%), var(--bg); }
  .auth-card-brand { display: flex; }
  .auth-title, .auth-subtitle { text-align: center; }
}

/* --- Brand logo --- */
.brand-logo { display: flex; align-items: center; gap: 11px; }
.brand-mark { width: 38px; height: 38px; flex: none; border-radius: 11px; box-shadow: 0 6px 16px rgba(var(--primary-shadow),.4); }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-word { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; }
.brand-sub { font-size: .54rem; letter-spacing: .26em; font-weight: 700; margin-top: 4px; opacity: .8; }
.sidebar .brand-word { color: #fff; }
.sidebar .brand-sub { color: #8893ad; }
.login-card .brand-logo { justify-content: center; margin-bottom: 16px; }
.login-card .brand-mark { width: 58px; height: 58px; border-radius: 16px; }
.login-card .brand-word { font-size: 2.15rem; background: linear-gradient(120deg,var(--primary),var(--purple)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.login-card .brand-sub { color: var(--muted); }

/* --- Layout --- */
.app { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }
.scrim { display: none; }
.sidebar { background: var(--sidebar); color: #aeb8cc; padding: 18px 14px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { padding: 6px 10px 20px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px;
  color: #aeb8cc; cursor: pointer; border: none; background: none; width: 100%; text-align: start; font-size: .92rem; font-weight: 500;
  transition: background .15s, color .15s; position: relative; }
.nav-item:hover { background: var(--sidebar-2); color: #fff; }
.nav-item.active { background: linear-gradient(100deg, var(--primary), var(--primary-400)); color: #fff; box-shadow: 0 8px 20px rgba(var(--primary-shadow),.35); }
.nav-item.active .ico { stroke: #fff; }
.nav-ico { display: inline-flex; align-items: center; }
.nav-ico .ico { width: 19px; height: 19px; opacity: .92; }
.nav-item .badge { margin-inline-start: auto; background: var(--red); color: #fff; border-radius: 20px; padding: 1px 7px; font-size: .66rem; font-weight: 700; }
.nav-sep { height: 1px; background: rgba(255,255,255,.08); margin: 12px 8px; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { background: rgba(255,255,255,.85); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--border); padding: 12px 22px;
  display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 20; }
.topbar h2 { font-size: 1.12rem; font-weight: 700; }
.menu-btn { display: none; padding: 8px; color: var(--primary); }
.menu-btn:hover { background: var(--primary-050); border-color: var(--primary); }
.menu-btn .ico { width: 20px; height: 20px; }
.icon-btn { background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 8px 11px;
  font-size: .82rem; color: var(--text-soft); position: relative; display: inline-flex; align-items: center; gap: 6px; transition: all .15s; }
.icon-btn:hover { background: var(--bg); border-color: var(--border-strong); }
.icon-btn .ico { width: 18px; height: 18px; }
.icon-btn .dot { position: absolute; top: -6px; inset-inline-end: -6px; background: var(--red); color: #fff; border-radius: 20px; font-size: .62rem; padding: 1px 5px; font-weight: 700; }
.userchip { display: flex; align-items: center; gap: 9px; font-size: .82rem; color: var(--muted); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg,var(--primary),var(--purple)); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .82rem; box-shadow: var(--shadow-xs); }
.content { padding: clamp(16px,2.6vw,30px); overflow: auto; }

/* --- Dashboard --- */
.dash-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.dash-head h1 { font-size: 1.5rem; font-weight: 800; }
.dash-actions { margin-inline-start: auto; display: flex; gap: 10px; flex-wrap: wrap; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px,1fr)); gap: 14px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 17px 18px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 14px; transition: transform .14s, box-shadow .14s, border-color .14s; }
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.stat-ico { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--primary-050); color: var(--primary); }
.stat-ico .ico { width: 22px; height: 22px; }
.stat .num { font-size: 1.9rem; font-weight: 800; line-height: 1.1; letter-spacing: -0.03em; }
.stat .lbl { color: var(--muted); font-size: .82rem; }
.stat.p .stat-ico { background: var(--amber-050); color: var(--amber); } .stat.p .num { color: var(--amber); }
.stat.a .stat-ico { background: var(--green-050); color: var(--green); } .stat.a .num { color: var(--green); }
.stat.r .stat-ico { background: var(--red-050); color: var(--red); } .stat.r .num { color: var(--red); }
.stat.i .stat-ico { background: var(--primary-050); color: var(--primary); } .stat.i .num { color: var(--primary); }
.stat-primary { background: linear-gradient(135deg, var(--primary), var(--primary-600)); border-color: transparent; box-shadow: 0 10px 26px rgba(var(--primary-shadow),.32); }
.stat-primary .stat-ico { background: rgba(255,255,255,.18); color: #fff; }
.stat-primary .num, .stat-primary .lbl { color: #fff; }
.stat-primary .lbl { opacity: .88; }
.stat-primary:hover { box-shadow: 0 14px 34px rgba(var(--primary-shadow),.45); }
.trend-sub { font-size: .8rem; color: var(--muted); margin-top: 4px; display: flex; align-items: center; gap: 8px; }
.trend-sub b { color: var(--text); font-size: 1rem; }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* ---- Hero banner ---- */
.hero { position: relative; overflow: hidden; border-radius: 22px; padding: 30px 34px; margin-bottom: 20px;
  background: linear-gradient(120deg, var(--hero-1) 0%, var(--hero-2) 55%, var(--hero-3) 100%);
  color: #fff; display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  box-shadow: 0 20px 44px rgba(var(--primary-shadow),.34); }
.hero-main { position: relative; z-index: 2; flex: 1 1 340px; }
.hero-eyebrow { font-size: .74rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; opacity: .8; margin-bottom: 6px; }
.hero-greet { font-size: clamp(1.5rem, 3vw, 2.05rem); font-weight: 800; letter-spacing: -.02em; margin: 0; line-height: 1.15; }
.hero-greet .wave { display: inline-block; animation: wave 2.4s ease-in-out infinite; transform-origin: 70% 70%; }
@keyframes wave { 0%,60%,100%{transform:rotate(0)} 15%{transform:rotate(16deg)} 30%{transform:rotate(-8deg)} 45%{transform:rotate(12deg)} }
.hero-date { margin: 8px 0 20px; font-size: .92rem; opacity: .88; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-btn { display: inline-flex; align-items: center; gap: 8px; padding: 11px 20px; border-radius: 12px; border: none;
  background: #fff; color: var(--primary-700); font-weight: 700; font-size: .9rem; cursor: pointer;
  box-shadow: 0 8px 20px rgba(2,30,22,.24); transition: transform .12s, box-shadow .12s; }
.hero-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(2,30,22,.32); }
.hero-btn .ico { width: 18px; height: 18px; }
.hero-btn.ghost { background: rgba(255,255,255,.14); color: #fff; box-shadow: none; border: 1px solid rgba(255,255,255,.35); }
.hero-btn.ghost:hover { background: rgba(255,255,255,.24); }
.hero-kpi { position: relative; z-index: 2; text-align: center; padding: 4px 10px; border-radius: 18px; transition: transform .14s; }
.hero-kpi.has { cursor: pointer; }
.hero-kpi.has:hover { transform: translateY(-3px); }
.hero-kpi-ring { width: 118px; height: 118px; margin: 0 auto 12px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 40%, rgba(255,255,255,.28), rgba(255,255,255,.08));
  border: 2px solid rgba(255,255,255,.55); box-shadow: 0 0 0 8px rgba(255,255,255,.08), inset 0 2px 12px rgba(255,255,255,.25); }
.hero-kpi.has .hero-kpi-ring { animation: heropulse 2.6s ease-in-out infinite; }
@keyframes heropulse { 0%,100%{box-shadow:0 0 0 8px rgba(255,255,255,.08), inset 0 2px 12px rgba(255,255,255,.25)} 50%{box-shadow:0 0 0 15px rgba(255,255,255,.02), inset 0 2px 12px rgba(255,255,255,.3)} }
.hero-kpi-num { font-size: 3.1rem; font-weight: 800; line-height: 1; letter-spacing: -.03em; }
.hero-kpi-lbl { font-size: .9rem; font-weight: 600; opacity: .92; max-width: 150px; }
.hero-orbs span { position: absolute; border-radius: 50%; z-index: 1; }
.hero-orbs span:nth-child(1) { width: 300px; height: 300px; top: -130px; inset-inline-end: -60px; background: radial-gradient(circle, rgba(255,255,255,.22), transparent 68%); }
.hero-orbs span:nth-child(2) { width: 220px; height: 220px; bottom: -120px; inset-inline-start: 22%; background: radial-gradient(circle, rgba(16,185,129,.5), transparent 70%); }
.hero-orbs span:nth-child(3) { width: 150px; height: 150px; top: 30%; inset-inline-end: 30%; background: radial-gradient(circle, rgba(255,255,255,.14), transparent 70%); }

/* ---- KPI mini cards ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px,1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 18px 16px; box-shadow: var(--shadow); transition: transform .14s, box-shadow .14s, border-color .14s; }
.kpi::before { content: ''; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 4px; background: var(--muted); }
.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.kpi-ico { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 11px; margin-bottom: 12px; }
.kpi-ico .ico { width: 20px; height: 20px; }
.kpi-num { font-size: 2rem; font-weight: 800; line-height: 1; letter-spacing: -.03em; }
.kpi-lbl { color: var(--muted); font-size: .84rem; margin-top: 5px; }
.kpi-p::before { background: var(--amber); } .kpi-p .kpi-ico { background: var(--amber-050); color: var(--amber); } .kpi-p .kpi-num { color: var(--amber); }
.kpi-a::before { background: var(--green); } .kpi-a .kpi-ico { background: var(--green-050); color: var(--green); } .kpi-a .kpi-num { color: var(--green); }
.kpi-r::before { background: var(--red); } .kpi-r .kpi-ico { background: var(--red-050); color: var(--red); } .kpi-r .kpi-num { color: var(--red); }
.kpi-t::before { background: var(--primary); } .kpi-t .kpi-ico { background: var(--primary-050); color: var(--primary); } .kpi-t .kpi-num { color: var(--primary); }

/* ---- Trend + ring two-column ---- */
.dash-2col { display: grid; grid-template-columns: 1.7fr 1fr; gap: 18px; align-items: stretch; }
.dash-2col .panel { margin-bottom: 18px; }
.ring-panel { display: flex; flex-direction: column; }
.ring-wrap { flex: 1; display: grid; place-items: center; padding: 8px 0 14px; }
.donut { width: 168px; height: 168px; }
.donut-arc { transition: stroke-dashoffset 1s cubic-bezier(.4,0,.2,1); }
.ring-legend { display: flex; justify-content: center; gap: 22px; font-size: .86rem; color: var(--text-soft); }
.ring-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; }
.ring-legend b { color: var(--text); margin-inline-start: 3px; }
.ring-legend .d-a { background: var(--green); } .ring-legend .d-r { background: var(--red); }
@media (max-width: 860px) { .dash-2col { grid-template-columns: 1fr; } .hero { padding: 24px; } .hero-kpi { margin-inline: auto; } }

.bar-row { display: grid; grid-template-columns: minmax(80px,30%) 1fr auto; align-items: center; gap: 12px; margin: 10px 0; font-size: .88rem; }
.bar-label { color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { background: var(--bg); border-radius: 8px; height: 10px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 8px; transition: width .6s cubic-bezier(.4,0,.2,1); min-width: 2px; }
.bar-val { font-weight: 700; min-width: 24px; text-align: end; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 18px; }
.panel h3 { font-size: 1.02rem; margin-bottom: 15px; font-weight: 700; }
.panel-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.panel-head h3 { margin: 0; }
.panel-head .btn { margin-inline-start: auto; }

/* --- Forms --- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .8rem; color: var(--text-soft); margin-bottom: 6px; font-weight: 600; }
.field label.chk { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 500; }
.field label .req { color: var(--red); }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font: inherit; background: var(--surface); color: var(--text); transition: border-color .15s, box-shadow .15s; }
input[type=checkbox] { width: auto; }
input::placeholder, textarea::placeholder { color: #9aa3b5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3.5px var(--primary-050); }
textarea { min-height: 80px; resize: vertical; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 130px; margin-bottom: 0; }

.btn { background: var(--primary); color: #fff; border: none; padding: 10px 18px; border-radius: var(--radius-sm); font-size: .9rem; font-weight: 600; box-shadow: 0 2px 6px rgba(var(--primary-shadow),.28); transition: background .15s, transform .08s, box-shadow .15s; display: inline-flex; align-items: center; gap: 7px; }
.btn:hover { background: var(--primary-600); box-shadow: 0 4px 12px rgba(var(--primary-shadow),.4); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; box-shadow: none; }
.btn.ghost { background: var(--surface); color: var(--text-soft); border: 1px solid var(--border-strong); box-shadow: none; }
.btn.ghost:hover { background: var(--bg); border-color: var(--muted); }
.btn.green { background: var(--green); box-shadow: 0 2px 6px rgba(21,163,74,.3); } .btn.green:hover { background: #128a3f; }
.btn.red { background: var(--red); box-shadow: 0 2px 6px rgba(225,72,63,.3); } .btn.red:hover { background: #c43a32; }
.btn.amber { background: var(--amber); box-shadow: 0 2px 6px rgba(214,131,9,.3); } .btn.amber:hover { background: #b66f06; }
.btn.sm { padding: 6px 12px; font-size: .82rem; }

/* --- Tables --- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 13px; text-align: start; border-bottom: 1px solid var(--border); font-size: .9rem; white-space: nowrap; }
table.kv td { white-space: normal; }
th { color: var(--muted); font-weight: 600; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }
tr.clickable { cursor: pointer; }

.badge-status { display: inline-block; padding: 3px 11px; border-radius: 20px; font-size: .74rem; font-weight: 600; line-height: 1.4; }
.s-pending { background: var(--amber-050); color: var(--amber); }
.s-approved { background: var(--green-050); color: var(--green); }
.s-rejected { background: var(--red-050); color: var(--red); }
.s-returned { background: #fff0e0; color: #c2410c; }
.s-cancelled, .s-waiting { background: #eef1f6; color: var(--gray); }
.s-draft { background: #eef1f6; color: #5b6678; border: 1px dashed var(--border-strong); }
.chip { display: inline-block; padding: 2px 9px; border-radius: 7px; font-size: .73rem; background: var(--bg); color: var(--text-soft); border: 1px solid var(--border); }
.ref { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-weight: 700; color: var(--primary); letter-spacing: 0; }

/* --- Modal --- */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: grid; place-items: center; padding: 16px; z-index: 50; backdrop-filter: blur(3px); }
.modal { background: var(--surface); border-radius: 18px; width: 100%; max-width: 640px; max-height: 90vh; overflow: auto; box-shadow: 0 28px 80px rgba(2,6,23,.4); border: 1px solid var(--border); animation: pop .16s ease; }
.modal.wide { max-width: 920px; }
.confirm-bg { z-index: 60; background: rgba(15,23,42,.45); }
.confirm-modal { max-width: 460px; }
.confirm-modal .modal-body p { margin: 0; color: var(--text-soft); line-height: 1.65; }
@keyframes pop { from { transform: scale(.97) translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-head h3 { font-size: 1.05rem; }
.modal-body { padding: 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; position: sticky; bottom: 0; background: var(--surface); }
.modal-body h4 { margin: 18px 0 10px; font-size: .95rem; font-weight: 700; }
.detail-wrap { display: grid; grid-template-columns: 1fr 270px; gap: 22px; }
.detail-main { min-width: 0; }
.detail-side { background: var(--surface-2); border: 1px solid var(--border); border-radius: 13px; padding: 16px; align-self: start; position: sticky; top: 0; }
.detail-side h4 { margin: 0 0 14px; }
.detail-meta { display: flex; gap: 22px; flex-wrap: wrap; margin-bottom: 16px; }
.detail-meta .muted { font-size: .74rem; }
.count { display: inline-block; background: var(--primary); color: #fff; border-radius: 20px; font-size: .7rem; padding: 0 8px; font-weight: 700; vertical-align: middle; }

/* --- Attachments --- */
.hint { font-size: .76rem; color: var(--muted); margin-top: 5px; line-height: 1.6; }
.att-list { display: flex; flex-direction: column; gap: 7px; }
.att-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.att-item a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.att-item .muted { font-size: .75rem; white-space: nowrap; }
.att-ico { width: 22px; text-align: center; }
.att-preview { background: none; border: none; cursor: pointer; font-size: 1rem; padding: 2px 4px; border-radius: 6px; }
.att-preview:hover { background: var(--primary-050); }
.preview-img { display: block; max-width: 100%; max-height: 72vh; margin: 0 auto; border-radius: 8px; }
.preview-frame { width: 100%; height: 72vh; border: none; border-radius: 8px; }
.att-del { background: none; border: none; color: var(--red); font-size: .9rem; padding: 2px 6px; border-radius: 6px; }
.att-del:hover { background: var(--red-050); }
.att-upload { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.att-upload input[type=file] { flex: 1; min-width: 180px; }
.file-queue { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.fq-item { display: flex; align-items: center; gap: 10px; padding: 7px 11px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; font-size: .85rem; }
.fq-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fq-item .muted { white-space: nowrap; font-size: .75rem; }
input[type=file] { padding: 7px 9px; font-size: .85rem; }
input[type=file]::file-selector-button { font: inherit; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: 8px; padding: 5px 11px; margin-inline-end: 10px; cursor: pointer; }

/* --- Workflow diagram --- */
.wf { list-style: none; margin: 0; padding: 0; }
.wf-node { display: flex; gap: 12px; padding-bottom: 18px; position: relative; }
.wf-node:not(:last-child)::after { content: ''; position: absolute; inset-inline-start: 15px; top: 32px; bottom: -2px; width: 2px; background: var(--border-strong); }
.wf-dot { width: 32px; height: 32px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .82rem; z-index: 1;
  background: var(--surface); border: 2px solid var(--border-strong); color: var(--gray); transition: all .2s; }
.wf-body { padding-top: 4px; min-width: 0; }
.wf-title { font-weight: 600; font-size: .9rem; line-height: 1.3; }
.wf-sub { font-size: .74rem; color: var(--muted); margin-top: 1px; }
.wf-node.done .wf-dot { background: var(--green); border-color: var(--green); color: #fff; }
.wf-node.done:not(:last-child)::after { background: var(--green); }
.wf-node.bad .wf-dot { background: var(--red); border-color: var(--red); color: #fff; }
.wf-node.warn .wf-dot { background: var(--amber); border-color: var(--amber); color: #fff; }
.wf-node.current .wf-dot { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 0 0 4px var(--primary-050); animation: pulse 1.8s infinite; }
.wf-node.current .wf-title { color: var(--primary); }
.wf-node.skip { opacity: .5; }
.wf-node.skip .wf-dot { border-style: dashed; background: var(--surface); color: var(--gray); }
.wf-node.skip .wf-sub { color: var(--amber); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 4px var(--primary-050); } 50% { box-shadow: 0 0 0 8px rgba(var(--primary-shadow),.08); } }

/* --- New request page --- */
.new-wrap { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
.new-main { min-width: 0; }
.new-side { position: sticky; top: 84px; }
.new-side h4 { margin: 0 0 14px; }
.wf-empty { text-align: center; color: var(--muted); padding: 26px 8px; font-size: .88rem; }
.wf-empty > div { margin-top: 8px; }
.type-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px,1fr)); gap: 12px; }
.type-card { display: flex; align-items: center; gap: 12px; text-align: start; background: var(--surface); border: 1.5px solid var(--border); border-radius: 13px; padding: 14px; cursor: pointer; transition: all .16s ease; }
.type-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.type-card.active { border-color: var(--primary); background: linear-gradient(180deg, var(--primary-050), transparent); box-shadow: 0 0 0 3px var(--primary-050); }
.tc-ico { font-size: 26px; width: 46px; height: 46px; flex: none; display: grid; place-items: center; background: var(--bg); border-radius: 12px; }
.tc-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.tc-name { font-weight: 700; font-size: .95rem; }
.tc-desc { font-size: .76rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.form-panel { animation: rise .3s ease; }
@media (max-width: 820px) { .new-wrap { grid-template-columns: 1fr; } .new-side { position: static; } }

/* --- Search + reveal --- */
.reveal { background: var(--amber-050); border: 1px solid #f0d98a; color: #875b00; border-radius: 12px; padding: 12px 16px; margin-bottom: 16px; word-break: break-all; }
.reveal code { background: var(--surface); border: 1px solid #e7d9a0; padding: 2px 7px; border-radius: 6px; font-weight: 700; user-select: all; }
.search-bar { display: flex; gap: 14px; flex-wrap: wrap; }
.search-bar .field { flex: 1; min-width: 180px; margin-bottom: 8px; }
.combo-actions { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.combo-actions .btn { white-space: nowrap; }

/* --- Builder rows --- */
.frow, .stage-row { border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 11px; background: var(--surface-2); }
.frow-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.stage-depts { margin-top: 10px; border-top: 1px dashed var(--border-strong); padding-top: 10px; }
.stage-depts.hidden { display: none; }
.dept-map-row { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.dept-map-row .dept-name { flex: 0 0 130px; font-size: .86rem; font-weight: 600; }
.dept-map-row select { flex: 1; }
.field-error textarea { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-050); }
.field-error label { color: var(--red); }
.type-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* --- Combobox --- */
.combo { position: relative; }
.combo-input { width: 100%; padding-inline-end: 32px; }
.combo-caret { position: absolute; inset-inline-end: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; font-size: .8rem; }
.combo-list { position: absolute; inset-inline: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-lg), 0 0 0 1px rgba(15,23,42,.02); max-height: min(66vh, 460px); overflow-y: auto; overflow-x: hidden;
  z-index: 60; padding: 8px; animation: comboIn .18s cubic-bezier(.2,.9,.3,1); overscroll-behavior: contain; }
.combo-list.hidden { display: none; }
@keyframes comboIn { from { opacity: 0; transform: translateY(-6px) scale(.985); } to { opacity: 1; transform: none; } }
/* شريط تمرير أنيق */
.combo-list::-webkit-scrollbar { width: 11px; }
.combo-list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 9px; border: 3px solid var(--surface); }
.combo-list::-webkit-scrollbar-thumb:hover { background: var(--muted); }
.combo-group { font-size: .68rem; color: var(--muted); padding: 11px 12px 6px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; position: sticky; top: -8px; background: linear-gradient(var(--surface), var(--surface) 70%, transparent); z-index: 1; }
.combo-opt { position: relative; display: flex; align-items: center; gap: 12px; padding: 11px 13px; cursor: pointer; border-radius: 12px; transition: background .14s, transform .08s; }
.combo-opt::before { content: ''; position: absolute; inset-inline-start: 5px; top: 50%; transform: translateY(-50%); width: 3px; height: 0; border-radius: 3px; background: var(--primary); transition: height .16s ease; }
.combo-opt:hover, .combo-opt.sel { background: var(--primary-050); }
.combo-opt:hover::before, .combo-opt.sel::before { height: 58%; }
.combo-opt:active { transform: scale(.99); }
.combo-opt .co-ico { width: 40px; height: 40px; flex: none; display: grid; place-items: center; font-size: 20px; background: var(--bg); border-radius: 11px; box-shadow: inset 0 0 0 1px var(--border); transition: background .14s, box-shadow .14s; }
.combo-opt:hover .co-ico, .combo-opt.sel .co-ico { background: #fff; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 35%, var(--border)); }
.combo-opt .co-text { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.combo-opt .co-name { font-weight: 600; font-size: .95rem; }
.combo-opt .co-desc { font-size: .77rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-empty { padding: 22px 16px; color: var(--muted); font-size: .85rem; text-align: center; }

/* --- Notifications --- */
.notif-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.notif { display: flex; align-items: center; gap: 10px; padding: 11px 13px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.notif.unread { border-inline-start: 3px solid var(--primary); background: var(--primary-050); }
.notif.clickable { cursor: pointer; transition: all .15s ease; }
.notif.clickable:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.notif-body { flex: 1; min-width: 0; }
.notif-body .st-meta { font-size: .74rem; color: var(--muted); margin-top: 2px; }
.notif-go { flex: none; color: var(--primary); font-size: 1.1rem; font-weight: 700; }

/* --- About --- */
.about { text-align: center; padding: 8px 6px 4px; }
.about-logo { display: flex; justify-content: center; margin-bottom: 18px; }
.about-logo .brand-mark { width: 56px; height: 56px; border-radius: 16px; }
.about-logo .brand-word { font-size: 2rem; background: linear-gradient(120deg,var(--primary),var(--purple)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.about-logo .brand-sub { color: var(--muted); }
.about-by { color: var(--muted); font-size: .9rem; margin: 6px 0 2px; }
.about-company { font-size: 1.5rem; font-weight: 800; color: var(--text); letter-spacing: -0.02em; }
.about-company-en { font-size: 1rem; font-weight: 700; letter-spacing: .18em; color: var(--primary); margin-top: 2px; }
.about-divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .1em; margin: 22px 0 14px; }
.about-divider::before, .about-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.about-contacts { display: flex; flex-direction: column; gap: 9px; max-width: 320px; margin: 0 auto; }
.about-row { display: flex; align-items: center; gap: 11px; padding: 11px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); color: var(--text-soft); font-weight: 600; font-size: .9rem; transition: all .15s; }
.about-row:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-050); }
.about-row .ico { color: var(--primary); width: 19px; height: 19px; }

/* --- Comments --- */
.comments { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.comment { display: flex; gap: 10px; }
.avatar.sm { width: 28px; height: 28px; font-size: .72rem; flex: none; }
.comment-body { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 9px 13px; flex: 1; min-width: 0; }
.comment-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .82rem; margin-bottom: 3px; }
.comment-head .muted { font-size: .72rem; margin-inline-start: auto; }
.comment-text { font-size: .9rem; white-space: pre-wrap; word-break: break-word; }
.comment-box { display: flex; gap: 10px; align-items: flex-start; margin-top: 6px; }
.comment-box textarea { flex: 1; min-height: 40px; }

/* --- Timeline / history --- */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: flex; gap: 12px; padding: 9px 0; border-inline-start: 2px solid var(--border); padding-inline-start: 16px; position: relative; }
.timeline li::before { content: ''; position: absolute; inset-inline-start: -7px; top: 13px; width: 12px; height: 12px; border-radius: 50%; background: var(--gray); border: 2px solid var(--surface); }
.timeline li.approved::before { background: var(--green); }
.timeline li.rejected::before { background: var(--red); }
.timeline li.pending::before { background: var(--amber); }
.timeline .st-name { font-weight: 600; }
.timeline .st-meta { font-size: .78rem; color: var(--muted); }

/* --- Toast / empty --- */
.toast { position: fixed; bottom: 24px; inset-inline-end: 24px; background: var(--text); color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 100; font-size: .9rem; animation: pop .16s ease; }
.toast.err { background: var(--red); }
.empty { text-align: center; color: var(--muted); padding: 38px; }

/* --- Entrance animations --- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.content .panel { animation: rise .34s ease backwards; }
.content .panel:nth-child(2) { animation-delay: .04s; }
.content .panel:nth-child(3) { animation-delay: .08s; }
.content .panel:nth-child(4) { animation-delay: .12s; }
.stat { animation: rise .4s ease backwards; }
.stat:nth-child(2) { animation-delay: .05s; } .stat:nth-child(3) { animation-delay: .1s; }
.stat:nth-child(4) { animation-delay: .15s; } .stat:nth-child(5) { animation-delay: .2s; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* --- Responsive --- */
@media (max-width: 860px) { .dash-grid { grid-template-columns: 1fr; } }
@media (max-width: 680px) {
  .detail-wrap { grid-template-columns: 1fr; }
  .detail-side { position: static; order: -1; }
}
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset-inline-start: 0; top: 0; width: 264px; z-index: 40; height: 100vh; transform: translateX(-110%); transition: transform .25s ease; }
  html[dir="rtl"] .sidebar { transform: translateX(110%); }
  .sidebar.open, html[dir="rtl"] .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(2,6,23,.5); z-index: 30; opacity: 0; pointer-events: none; transition: opacity .25s; }
  .app:has(.sidebar.open) .scrim { opacity: 1; pointer-events: auto; }
  .menu-btn { display: inline-flex; }
  .userchip .uname, .userchip .urole { display: none; }
  .dash-actions { margin-inline-start: 0; width: 100%; }
  .dash-actions .btn { flex: 1; }
}

/* --- Breadcrumbs --- */
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; }
.crumb-root { color: var(--muted); font-size: .92rem; font-weight: 600; }
.crumb-sep { color: var(--border-strong); }
.crumb-cur { font-size: 1.12rem; font-weight: 700; margin: 0; }

/* --- Header dropdowns --- */
.dd { position: relative; }
.dd-panel { position: absolute; top: calc(100% + 8px); inset-inline-end: 0; min-width: 300px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); z-index: 50; overflow: hidden; animation: pop .14s ease; }
.dd-panel.hidden { display: none; }
.dd-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: .9rem; }
.dd-head b { flex: 1; }
.dd-name { font-weight: 700; font-size: .9rem; }
.dd-link { background: none; border: none; color: var(--primary); font-size: .8rem; font-weight: 600; cursor: pointer; padding: 0; }
.dd-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 14px; background: none; border: none; text-align: start; font-size: .9rem; color: var(--text-soft); cursor: pointer; transition: background .12s; }
.dd-item:hover { background: var(--bg); color: var(--text); }
.dd-item.danger { color: var(--red); }
.dd-item.danger:hover { background: var(--red-050); }
.dd-theme { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--border); }
.dd-theme-lbl { font-size: .9rem; color: var(--text-soft); }
.theme-swatches { display: flex; gap: 8px; }
.theme-swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border-strong); cursor: pointer; padding: 0; transition: transform .12s, box-shadow .12s; position: relative; }
.theme-swatch:hover { transform: scale(1.12); }
.theme-swatch.active { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px currentColor; }
.theme-swatch.active::after { content: '✓'; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 800; }
.dd-item .ico { width: 18px; height: 18px; color: var(--muted); }
.dd-item.danger .ico { color: var(--red); }
.dd-loading { padding: 22px; text-align: center; color: var(--muted); }
.notif-panel { width: 340px; }
.notif-scroll { max-height: 380px; overflow: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }

/* --- Stat card: delta + sparkline --- */
.stat-main { display: flex; flex-direction: column; min-width: 0; }
.num-row { display: flex; align-items: baseline; gap: 8px; }
.stat-delta { font-size: .78rem; font-weight: 700; }
.stat-delta.up { color: var(--green); }
.stat-delta.down { color: var(--red); }
.stat-spark { margin-inline-start: auto; align-self: center; }
.spark { width: 90px; height: 26px; display: block; }

/* --- Trend chart --- */
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: none; background: none; padding: 5px 13px; border-radius: 8px; font-size: .82rem; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-xs); }
.chart-legend { display: flex; gap: 18px; margin: 2px 0 12px; font-size: .82rem; color: var(--muted); }
.chart-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-inline-end: 6px; vertical-align: middle; }

/* --- Activity feed --- */
.activity { list-style: none; margin: 0; padding: 0; }
.act { display: flex; gap: 12px; padding: 9px 0; position: relative; border-inline-start: 2px solid var(--border); padding-inline-start: 16px; }
.act.clickable { cursor: pointer; }
.act.clickable:hover .act-main { color: var(--primary); }
.act-dot { position: absolute; inset-inline-start: -7px; top: 13px; width: 12px; height: 12px; border-radius: 50%; background: var(--gray); border: 2px solid var(--surface); }
.act-approved .act-dot { background: var(--green); }
.act-rejected .act-dot { background: var(--red); }
.act-returned .act-dot, .act-escalated .act-dot { background: var(--amber); }
.act-submitted .act-dot, .act-resubmitted .act-dot, .act-reopened .act-dot { background: var(--primary); }
.act-body { min-width: 0; }
.act-main { font-weight: 600; font-size: .9rem; }
.act-sub { font-size: .76rem; color: var(--muted); margin-top: 1px; }

@media (max-width: 560px) {
  .crumb-root, .crumb-sep { display: none; }
  .dd-panel { position: fixed; inset-inline: 10px auto; inset-inline-end: 10px; top: 62px; }
  .notif-panel { width: auto; min-width: 260px; }
}

/* --- Approval certificate (print) --- */
#printArea { display: none; }
.cert { color: #0f172a; font-size: 13px; }
.cert-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 3px solid var(--primary); padding-bottom: 12px; }
.cert-logo { font-size: 20px; font-weight: 800; color: var(--primary); }
.cert-stamp { border: 3px solid var(--green); color: var(--green); font-weight: 800; padding: 8px 18px; border-radius: 10px; transform: rotate(-6deg); letter-spacing: 2px; font-size: 18px; }
.cert h1 { font-size: 22px; text-align: center; margin: 22px 0 6px; }
.cert-ref { text-align: center; font-family: ui-monospace, Consolas, monospace; font-weight: 700; color: var(--primary); font-size: 18px; margin-bottom: 18px; }
.cert h2 { font-size: 15px; margin: 20px 0 8px; border-inline-start: 4px solid var(--primary); padding-inline-start: 8px; }
.cert table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.cert td, .cert th { border: 1px solid #d8deea; padding: 7px 10px; text-align: start; font-size: 12.5px; }
.cert th { background: #f0f3fa; }
.cert .k { background: #f7f9fc; color: #6b7589; width: 32%; font-weight: 600; }
.cert-verify { margin-top: 22px; border-top: 1px dashed #c2cbe0; padding-top: 12px; font-size: 11.5px; color: #44506a; word-break: break-all; }
.cert-hash { margin-top: 4px; font-family: ui-monospace, Consolas, monospace; }
.cert-note { margin-top: 10px; font-style: italic; color: #6b7589; }

/* ---- E-signature UI (screen) ---- */
.sig-pick { cursor: pointer; display: inline-flex; }
.sig-preview { border: 1px dashed var(--border-strong); border-radius: 12px; background: var(--surface-2); min-height: 90px; display: grid; place-items: center; padding: 10px; }
.sig-preview img { max-height: 120px; max-width: 100%; object-fit: contain; }
.sig-preview.empty { color: var(--muted); font-size: .88rem; }
.sig-savechk { display: flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--text-soft); }
.sig-savechk input { width: auto; }
.sig-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 6px; }
.sig-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px; text-align: center; background: var(--surface-2); }
.sig-card-img { height: 64px; display: grid; place-items: center; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.sig-card-img img { max-height: 60px; max-width: 100%; object-fit: contain; }
.sig-none-line { color: var(--muted); font-size: .78rem; }
.sig-card-name { font-weight: 700; font-size: .9rem; }
.sig-card-role { font-size: .78rem; color: var(--text-soft); }
.sig-card-date { font-size: .74rem; }

/* ---- Official document (print) ---- */
.doc { color: #0f172a; font-size: 13px; line-height: 1.5; }
.doc-head { display: flex; align-items: flex-start; justify-content: space-between; border-bottom: 3px solid var(--primary); padding-bottom: 14px; }
.doc-brand { display: flex; align-items: center; gap: 12px; }
.doc-seal { width: 46px; height: 46px; border-radius: 12px; background: linear-gradient(135deg, var(--primary), var(--purple)); color: #fff; display: grid; place-items: center; font-size: 26px; font-weight: 800; }
.doc-app { font-size: 20px; font-weight: 800; color: var(--primary); }
.doc-org { font-size: 11px; color: #64748b; }
.doc-refbox { text-align: end; }
.doc-reflbl { font-size: 10px; color: #94a3b8; text-transform: uppercase; letter-spacing: .08em; }
.doc-ref { font-family: ui-monospace, Consolas, monospace; font-weight: 800; color: var(--primary); font-size: 16px; }
.doc-status { display: inline-block; margin-top: 4px; padding: 2px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; background: #eef2f7; color: #475569; }
.doc-status.approved { background: #dcfce7; color: #15803d; }
.doc-status.rejected { background: #fee2e2; color: #b91c1c; }
.doc-status.pending { background: #fef3c7; color: #b45309; }
.doc-title { font-size: 21px; text-align: center; margin: 20px 0 2px; }
.doc-sub { text-align: center; color: #64748b; margin-bottom: 16px; }
.doc-h2 { font-size: 14px; margin: 18px 0 8px; border-inline-start: 4px solid var(--primary); padding-inline-start: 8px; }
.doc table { width: 100%; border-collapse: collapse; }
.doc-meta td, .doc-fields td { border: 1px solid #d8deea; padding: 7px 10px; text-align: start; font-size: 12.5px; }
.doc .k { background: #f1f5f9; color: #64748b; font-weight: 600; width: 22%; }
.doc-sigs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 4px; }
.doc-sig { border: 1px solid #d8deea; border-radius: 10px; padding: 12px 10px; text-align: center; break-inside: avoid; }
.doc-sig-img { height: 70px; display: grid; place-items: center; border-bottom: 2px solid #0f172a; margin-bottom: 8px; }
.doc-sig-img img { max-height: 66px; max-width: 100%; object-fit: contain; }
.doc-sig-line { display: block; width: 90%; }
.doc-sig-name { font-weight: 800; font-size: 13px; }
.doc-sig-role { font-size: 11px; color: #475569; }
.doc-sig-meta { font-size: 10.5px; color: #94a3b8; margin-top: 2px; }
.doc-sig-note { font-size: 9.5px; color: #94a3b8; font-style: italic; margin-top: 4px; }
.doc-foot { margin-top: 24px; border-top: 1px dashed #c2cbe0; padding-top: 12px; font-size: 11px; color: #64748b; word-break: break-all; }
.doc-verify, .doc-hash { margin-top: 3px; font-family: ui-monospace, Consolas, monospace; }
.doc-empty { color: #94a3b8; font-style: italic; padding: 8px 0; }

@media print {
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block !important; position: absolute; inset: 0; padding: 24px; background: #fff; }
  @page { margin: 16mm; }
}

/* ===== Embed mode (تضمين داخل «مسار») ===== */
/* عند العرض داخل إطار مسار: نخفي الشريط الجانبي والعلوي الخاصّين بسند، ويملأ
   المحتوى المساحة. مفعّل فقط عبر ?embed=1 — لا أثر على التشغيل المنفرد. */
html.embed .sidebar,
html.embed .topbar { display: none !important; }
/* طيّ شبكة الغلاف إلى عمود واحد كي يملأ المحتوى العرض بعد إخفاء الشريط الجانبي. */
html.embed .app { grid-template-columns: 1fr !important; }
/* التمرير ينتقل إلى .main، و.content يسمح بالتجاوز كي لا تُقصّ القوائم المنسدلة. */
html.embed .main { margin: 0 !important; grid-column: 1 / -1 !important; align-items: stretch !important; overflow-y: auto !important; overflow-x: hidden !important; }
/* المحتوى يملأ العرض بالكامل. لا margin:auto (يُلغي تمدّد عنصر flex ويُصغّر الواجهات). */
html.embed .content { padding: clamp(16px, 3vw, 28px) !important; width: 100% !important; max-width: none !important; margin-inline: 0 !important; box-sizing: border-box; overflow: visible !important; height: auto !important; flex: 0 0 auto !important; }
html.embed, html.embed body { background: var(--bg) !important; }
/* ضمان تمدّد الصفوف/الأغلفة الداخلية إلى كامل العرض داخل التضمين. */
html.embed .new-wrap, html.embed .content > * { width: 100%; max-width: 100%; }
/* الثيم الموحّد (هوية مسار) — يُطبَّق فقط داخل التضمين، لا يمسّ التشغيل المنفرد. */
html.embed {
  --bg: #f6f7fb; --surface: #ffffff; --surface-2: #f9fafd;
  --border: #e7e9f2; --border-strong: #d6d9e6;
  --text: #14162b; --text-soft: #3c4162; --muted: #7a809b;
  --primary: #4f46e5; --primary-600: #4338ca; --primary-700: #3730a3; --primary-400: #818cf8; --primary-050: #eef0fe;
  --purple: #0ea5b8; --sky: #0284c7;
  --hero-1: #1e1b4b; --hero-2: #4f46e5; --hero-3: #0ea5b8; --primary-shadow: 79,70,229;
}
