/* ===== Deskorders — تنسيقات عامة (موبايل أولاً، RTL) ===== */
:root {
  --green: #1f6f54;
  --green-d: #16523e;
  --green-l: #e7f3ee;
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1c2530;
  --muted: #6b7785;
  --line: #e3e7ec;
  --accent: #e8821e;
  --red: #d24b4b;
  --blue: #2f6fb0;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(20,30,40,.07);
  font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", sans-serif;
}

body.dark {
  --green: #2da57b;
  --green-d: #1f6f54;
  --green-l: #1f3329;
  --bg: #0f1418;
  --card: #1c2229;
  --ink: #f1f5f9;
  --muted: #b6c2d0;
  --line: #2b333d;
  --accent: #f0962a;
  --shadow: 0 2px 14px rgba(0,0,0,.4);
}
/* ==== Dark mode: ضمان وضوح النصوص الثانوية والأسعار ==== */
body.dark .muted,
body.dark .hint,
body.dark .small.muted,
body.dark .module-tile .m-desc,
body.dark .fav-card .fav-meta,
body.dark .prod-info .p-meta,
body.dark .order-items,
body.dark .order-meta,
body.dark .stat .s-lbl,
body.dark .track,
body.dark .msg-who,
body.dark .empty,
body.dark .auth-logo .l-sub { color: #b6c2d0; }
body.dark .fav-card .fav-meta,
body.dark .module-tile .m-desc { font-weight: 500; }
body.dark .section-title { color: var(--ink); }
body.dark .bottom-nav button { color: #aab5c2; }
body.dark .tabs button { color: #b6c2d0; }
body.dark .rep-table th { color: #aab5c2; }
body.dark .track-step b { color: #f1f5f9; }
body.dark .stars { color: #ffd34a; }
body.dark .badge.new { background: #5a3a14; color: #ffd5a5; }
body.dark .badge.accepted { background: #1f3a5c; color: #b9d4f0; }
body.dark .badge.in_progress { background: #2f2855; color: #c8baff; }
body.dark .badge.completed { background: #1f3329; color: #9fe0c0; }
body.dark .badge.cancelled { background: #4a1d1d; color: #f4b2b2; }
body.dark .sched-badge { background: #2f2855; color: #c8baff; }
body.dark .busy-badge { background: #4a1d1d; color: #f4b2b2; }
body.dark .card-row .brand-icon { background: #161b21; color: var(--ink); }
body.dark .field input,
body.dark .field select,
body.dark .field textarea { background: #0f1418; color: var(--ink); }
body.dark .field input:disabled { background: #161b21 !important; }
/* Catch-all for bare inputs/selects/textarea outside .field (e.g. SLA, inline rows) */
body.dark input:not([type="color"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]),
body.dark select,
body.dark textarea { background: #0f1418; color: var(--ink); border-color: var(--line); }
body.dark input:disabled { background: #161b21 !important; color: var(--ink-2, #a8b0b8); }
body.dark .btn.ghost { background: #1c2229; color: var(--ink); }
body.dark .qty-ctl button { background: #161b21; color: var(--green); }
body.dark .module-tile { border: 1px solid var(--line); }
body.dark .demo-box { background: #161b21; }
body.dark .demo-row { color: var(--ink); }
body.dark .topbar { background: var(--green-d); }
body.dark .bottom-nav { background: var(--card); border-top-color: var(--line); }
body.dark .msg-in { background: var(--card); border-color: var(--line); }
body.dark .modal { background: var(--card); }
body.dark .ticket-thread { background: #161b21; }
body.dark .chip { background: #161b21; border-color: var(--line); color: var(--ink); }
body.dark .chip.on { background: var(--green); color: #fff; }
body.dark .closed-card { background: #3a2a14; color: #f0b577; }
body.dark .call-card { background: linear-gradient(135deg, #c2691e, #8a4a14); }
body.dark .auth-tabs button { background: var(--green-l); color: #c7e3d3; }
body.dark .auth-tabs button.active { background: var(--green); color: #fff; }
body.dark .lang-btn-auth { background: var(--green-l); color: #c7e3d3; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font-family: inherit; font-size: 1rem; color: inherit; }
button { cursor: pointer; color: inherit; background: transparent; }
a { color: inherit; }

/* ===== Splash ===== */
.splash {
  height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(160deg, var(--green), var(--green-d)); color: #fff;
}
.splash-logo { font-size: 2.4rem; font-weight: 800; letter-spacing: .5px; }
.splash-sub { opacity: .85; }

/* ===== App shell ===== */
.app-wrap {
  max-width: 720px; margin: 0 auto; min-height: 100vh;
  display: flex; flex-direction: column; background: var(--bg);
  position: relative;
}
.topbar {
  background: var(--green); color: #fff; padding: 12px 16px;
  display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20;
}
.topbar .t-title { font-weight: 700; font-size: 1.05rem; flex: 1; }
.topbar .brand-logo {
  width: 32px; height: 32px; border-radius: 8px;
  object-fit: contain; background: rgba(255,255,255,.15); padding: 2px;
}
.topbar .t-sub { font-size: .72rem; opacity: .8; font-weight: 400; display: block; }
.icon-btn {
  background: rgba(255,255,255,.15); border: none; color: #fff;
  width: 36px; height: 36px; border-radius: 10px; font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
}
.content { flex: 1; padding: 16px; padding-bottom: 86px; }

/* ===== Bottom nav ===== */
.bottom-nav {
  position: sticky; bottom: 0; background: var(--card);
  border-top: 1px solid var(--line); display: flex; z-index: 20;
}
.bottom-nav button {
  flex: 1; background: none; border: none; padding: 9px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--muted); font-size: .68rem;
  position: relative;
  transition: background .18s ease, color .18s ease;
  border-radius: 10px;
  margin: 4px 2px;
}
.bottom-nav button .ic { font-size: 1.25rem; transition: transform .18s ease; }
/* v67 — تظليل واضح للتاب النشط */
.bottom-nav button.active {
  color: var(--green);
  font-weight: 700;
  background: var(--green-l);
}
.bottom-nav button.active .ic { transform: scale(1.12); }
/* شريط مؤشّر أعلى التاب النشط */
.bottom-nav button.active::before {
  content: "";
  position: absolute;
  top: -4px; left: 18%; right: 18%;
  height: 3px;
  border-radius: 0 0 4px 4px;
  background: var(--green);
}
.bottom-nav button:hover { background: rgba(127,127,127,.08); }

/* v73 — نبض الخطوة الحالية في تتبّع الطلب */
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* ===== Cards / generic ===== */
.card {
  background: var(--card); border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow); margin-bottom: 12px;
}
.section-title { font-size: 1rem; font-weight: 700; margin: 6px 2px 10px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 10px; }
.empty {
  text-align: center; color: var(--muted); padding: 40px 16px;
}
.empty .big { font-size: 2.4rem; margin-bottom: 6px; }

/* ===== Module grid (employee home) ===== */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.module-tile {
  background: var(--card); border: none; border-radius: var(--radius);
  padding: 18px 12px; box-shadow: var(--shadow); text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.module-tile .m-ic {
  width: 52px; height: 52px; border-radius: 14px; display: flex;
  align-items: center; justify-content: center; font-size: 1.7rem;
}
.module-tile .m-name { font-weight: 700; font-size: .92rem; }
.module-tile .m-desc { font-size: .72rem; color: var(--muted); }

/* ===== Buttons ===== */
.btn {
  background: var(--green); color: #fff; border: none; border-radius: 11px;
  padding: 12px 16px; font-weight: 700; width: 100%; font-size: .95rem;
}
.btn:active { transform: scale(.99); }
.btn.secondary { background: var(--green-l); color: var(--green-d); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn.danger { background: var(--red); }
.btn.accent { background: var(--accent); }
.btn.sm { width: auto; padding: 8px 14px; font-size: .82rem; border-radius: 9px; }
.btn:disabled { opacity: .5; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { width: auto; flex: 1; }

/* ===== Forms ===== */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--ink);
}
.field textarea { resize: vertical; min-height: 64px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--green-l); border-color: var(--green);
}

/* ===== Auth ===== */
.auth-wrap {
  max-width: 420px; margin: 0 auto; min-height: 100vh;
  display: flex; flex-direction: column; justify-content: center; padding: 24px;
}
.auth-logo { text-align: center; margin-bottom: 18px; }
.auth-logo .l-name { font-size: 1.9rem; font-weight: 800; color: var(--green); }
.auth-logo .l-sub { color: var(--muted); font-size: .85rem; }
.auth-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.auth-tabs button {
  flex: 1; background: var(--green-l); border: none; padding: 9px;
  border-radius: 9px; color: var(--green-d); font-weight: 600;
}
.auth-tabs button.active { background: var(--green); color: #fff; }
.demo-box {
  margin-top: 14px; background: #fff; border: 1px dashed var(--line);
  border-radius: 12px; padding: 12px; font-size: .8rem;
}
.demo-box b { color: var(--green-d); }
.demo-row {
  display: flex; justify-content: space-between; padding: 5px 0;
  border-bottom: 1px solid var(--line); cursor: pointer;
}
.demo-row:last-child { border-bottom: none; }

/* ============ v27 — coForm: New Company Plans & Add-ons ============ */
.cof-plans {
  display: grid; gap: 10px; margin-top: 6px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.cof-plan {
  background: var(--bg); border: 2px solid var(--border);
  border-radius: 12px; padding: 12px 10px; cursor: pointer;
  transition: transform .12s, border-color .12s, background .12s;
  position: relative;
}
.cof-plan:hover { transform: translateY(-1px); }
.cof-plan.selected { box-shadow: 0 4px 12px rgba(31,111,84,.15); }
.cof-plan-name { font-weight: 700; font-size: .92rem; margin-bottom: 4px; }
.cof-plan-price { font-size: 1.4rem; font-weight: 800; line-height: 1; }
.cof-plan-price .cof-unit { font-size: .65rem; font-weight: 500; color: var(--text-muted); margin-inline-start: 2px; }
.cof-plan-desc { margin-top: 4px; line-height: 1.4; font-size: .72rem; }
.cof-plan-check {
  position: absolute; top: 6px; inset-inline-end: 8px;
  background: var(--green); color: #fff;
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700;
}
body.dark .cof-plan { background: #0f1418; }

.cof-addons {
  display: flex; flex-direction: column; gap: 8px; margin-top: 6px;
}
.cof-addon {
  background: var(--bg); border: 2px solid var(--border);
  border-radius: 12px; padding: 10px; cursor: pointer;
  transition: transform .12s, border-color .12s;
}
.cof-addon:hover { transform: translateY(-1px); }
.cof-addon.selected { background: var(--green-l, #e7f3ee); }
.cof-addon-row {
  display: flex; align-items: center; gap: 10px;
}
.cof-addon-icon {
  width: 36px; height: 36px; border-radius: 9px; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.cof-addon-name { font-weight: 700; font-size: .9rem; }
.cof-addon-desc { font-size: .72rem; line-height: 1.35; margin-top: 2px; }
.cof-addon-price { text-align: end; flex-shrink: 0; font-size: .85rem; line-height: 1.1; }
.cof-addon-price .small { font-size: .58rem; opacity: .7; }
body.dark .cof-addon { background: #0f1418; }
body.dark .cof-addon.selected { background: #1c3328; }

.cof-summary {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; margin-top: 10px;
}
.cof-sum-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 0; font-size: .82rem;
  border-bottom: 1px dashed var(--border);
}
.cof-sum-row:last-child { border-bottom: none; }
.cof-sum-total {
  font-weight: 700; color: var(--green-d);
  border-top: 2px solid var(--green-l, #e7f3ee);
  padding-top: 8px; margin-top: 3px;
  font-size: .9rem;
}
body.dark .cof-summary { background: #0f1418; }
body.dark .cof-sum-total { color: #9fe0c0; }

/* ===== Badges / chips ===== */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px;
  font-size: .7rem; font-weight: 700;
}
.badge.new { background: #fdeede; color: #9a5a12; }
.badge.accepted { background: #dfeaf7; color: #285a8c; }
.badge.in_progress { background: #e6e1f7; color: #4b3a8c; }
.badge.completed { background: var(--green-l); color: var(--green-d); }
.badge.cancelled { background: #f7e0e0; color: #963535; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 20px; padding: 5px 10px;
  font-size: .78rem; cursor: pointer;
}
.chip.on { background: var(--green); color: #fff; border-color: var(--green); }

/* ===== Order card ===== */
.order-card { border-right: 4px solid var(--green); }
.order-card.new { border-color: var(--accent); }
.order-card.accepted { border-color: var(--blue); }
.order-card.in_progress { border-color: #6a52c4; }
.order-card.completed { border-color: var(--green); }
.order-card.cancelled { border-color: var(--red); }
.order-items { font-size: .85rem; color: var(--muted); margin: 6px 0; }
.order-meta { display: flex; gap: 12px; font-size: .76rem; color: var(--muted); flex-wrap: wrap; }

/* ===== Product / catalog ===== */
.prod-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.prod-row:last-child { border-bottom: none; }
.prod-ic {
  width: 44px; height: 44px; border-radius: 10px; background: var(--green-l);
  display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex-shrink: 0;
}
.prod-info { flex: 1; }
.prod-info .p-name { font-weight: 600; font-size: .9rem; }
.prod-info .p-meta { font-size: .74rem; color: var(--muted); }
.qty-ctl { display: flex; align-items: center; gap: 8px; }
.qty-ctl button {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; font-size: 1.1rem; font-weight: 700; color: var(--green);
}
.qty-ctl .q { min-width: 22px; text-align: center; font-weight: 700; }
.stock-low { color: var(--red); font-weight: 700; }
.stock-out { color: var(--red); }

/* ===== Cart bar ===== */
.cart-bar {
  position: sticky; bottom: 70px; background: var(--green-d); color: #fff;
  border-radius: 12px; padding: 12px 14px; display: flex; align-items: center;
  gap: 10px; box-shadow: var(--shadow); margin-top: 8px;
}
.cart-bar .c-total { font-weight: 800; }
.cart-bar button {
  margin-inline-start: auto; background: #fff; color: var(--green-d);
  border: none; border-radius: 9px; padding: 9px 16px; font-weight: 700;
}

/* ===== Stats ===== */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat {
  background: var(--card); border-radius: 12px; padding: 14px;
  box-shadow: var(--shadow);
}
.stat .s-num { font-size: 1.6rem; font-weight: 800; color: var(--green); }
.stat .s-lbl { font-size: .78rem; color: var(--muted); }
.progress-bar {
  height: 8px; background: var(--line); border-radius: 6px; overflow: hidden; margin-top: 6px;
}
.progress-bar > div { height: 100%; background: var(--green); }

/* ===== Tabs ===== */
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.tabs button {
  background: var(--card); border: 1px solid var(--line); white-space: nowrap;
  padding: 8px 13px; border-radius: 20px; font-size: .82rem; color: var(--muted);
}
.tabs button.active { background: var(--green); color: #fff; border-color: var(--green); font-weight: 700; }
.tab-count {
  background: var(--accent); color: #fff; border-radius: 10px;
  padding: 0 6px; font-size: .68rem; margin-inline-start: 4px;
}

/* ===== Stars ===== */
.stars { font-size: 1.4rem; color: #d9b400; letter-spacing: 2px; }
.stars.input span { cursor: pointer; }
.stars.sm { font-size: .9rem; }

/* ===== Modal ===== */
.modal-back {
  position: fixed; inset: 0; background: rgba(15,22,30,.5);
  display: flex; align-items: flex-end; justify-content: center; z-index: 100;
}
.modal {
  background: #fff; width: 100%; max-width: 720px;
  border-radius: 18px 18px 0 0; padding: 18px; max-height: 88vh; overflow-y: auto;
  animation: slideup .2s ease;
}
@keyframes slideup { from { transform: translateY(40px); opacity: .6; } }
.modal h3 { margin-bottom: 12px; }
.modal-close {
  width: 40px; height: 4px; background: var(--line); border-radius: 4px;
  margin: 0 auto 12px;
}

/* ===== Toast ===== */
#toast-root {
  position: fixed; top: 14px; left: 0; right: 0; z-index: 200;
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 22px;
  font-size: .85rem; box-shadow: var(--shadow); animation: slideup .2s ease;
}
.toast.ok { background: var(--green); }
.toast.err { background: var(--red); }

/* ===== misc ===== */
.list-row {
  display: flex; align-items: center; gap: 10px; padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: none; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--green-l);
  color: var(--green-d); display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0;
}
.divider { height: 1px; background: var(--line); margin: 12px 0; }
.hint { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.pill-radio { display: flex; flex-wrap: wrap; gap: 8px; }

/* ===== v2: أسطر السلة، الصور، التتبع، التقارير ===== */
.line-card {
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.line-card:last-child { border-bottom: none; }

.photo-thumb {
  display: block; max-width: 100%; max-height: 200px;
  border-radius: 10px; margin: 8px 0; border: 1px solid var(--line);
}

.track {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line);
  font-size: .72rem; color: var(--muted);
}
.track-step { white-space: nowrap; }
.track-step b { color: var(--ink); }
.track-sep { color: var(--green); font-weight: 700; }

.map-frame {
  width: 100%; height: 200px; border: 1px solid var(--line);
  border-radius: 10px; margin-bottom: 6px;
}
.card-row {
  display: flex; align-items: center; gap: 10px; padding: 12px;
  border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px;
}
.card-row .brand-icon {
  width: 44px; height: 44px; border-radius: 8px; background: #f4f5f7;
  display: flex; align-items: center; justify-content: center; font-size: 1.3rem; font-weight: 700;
}
.card-row.selected { border-color: var(--green); background: var(--green-l); }

/* SVG Charts */
.chart-wrap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.chart-legend { display: flex; flex-direction: column; gap: 4px; font-size: .78rem; }
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.chart-legend i {
  display: inline-block; width: 12px; height: 12px; border-radius: 3px;
}

.rep-table { width: 100%; border-collapse: collapse; font-size: .78rem; }
.rep-table th, .rep-table td {
  padding: 7px 5px; text-align: center; border-bottom: 1px solid var(--line);
}
.rep-table th { color: var(--muted); font-weight: 600; font-size: .72rem; }
.rep-table td:first-child, .rep-table th:first-child { text-align: start; }
.rep-table tbody tr:last-child td { border-bottom: none; }
.rep-ok { color: var(--green); font-weight: 700; }
.rep-warn { color: #b9742a; font-weight: 700; }
.rep-bad { color: var(--red); font-weight: 700; }

/* ===== v3: تذاكر الدعم، باقات الاشتراك ===== */
.ticket-thread {
  background: #f4f5f7; border-radius: 12px; padding: 10px;
  max-height: 50vh; overflow-y: auto; margin-bottom: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.msg {
  max-width: 85%; padding: 8px 11px; border-radius: 12px;
  font-size: .88rem; line-height: 1.45; word-wrap: break-word;
}
.msg-who { font-size: .68rem; color: var(--muted); margin-bottom: 3px; }
.msg-in { background: #fff; border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg-out { background: var(--green); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg-out .msg-who { color: rgba(255,255,255,.75); }

/* nav with 6 items: tighten on phone */
.bottom-nav button .ic { font-size: 1.1rem; }
.bottom-nav button { font-size: .64rem; padding: 8px 2px; position: relative; }
.bottom-nav button .nav-badge {
  position: absolute; top: 4px; inset-inline-end: 28%;
  background: var(--red); color: #fff; font-size: .58rem; font-weight: 700;
  min-width: 14px; height: 14px; padding: 0 4px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}

.lang-btn-auth {
  background: var(--green-l); color: var(--green-d); border: none;
  padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: .82rem;
}

.fav-btn {
  background: transparent; border: 1px solid var(--line); color: #b9742a;
  width: 34px; height: 34px; border-radius: 8px; font-size: 1.15rem;
  display: flex; align-items: center; justify-content: center;
}
.fav-btn.on { background: #fdeede; color: #b9742a; border-color: #fdeede; }

.prod-img {
  width: 44px; height: 44px; border-radius: 10px; object-fit: cover; flex-shrink: 0;
}
.prod-img-preview {
  display: block; max-width: 100%; max-height: 180px;
  border-radius: 12px; margin-bottom: 6px; border: 1px solid var(--line);
}

/* Favorites horizontal row on home */
.fav-row {
  display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 8px;
  scroll-snap-type: x mandatory;
}
.fav-card {
  flex: 0 0 130px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px; display: flex; flex-direction: column;
  align-items: center; gap: 4px; scroll-snap-align: start; cursor: pointer;
  box-shadow: var(--shadow);
}
.fav-card .fav-ic { font-size: 2rem; }
.fav-card .fav-img { width: 60px; height: 60px; border-radius: 10px; object-fit: cover; }
.fav-card .fav-name { font-weight: 600; font-size: .85rem; text-align: center; }
.fav-card .fav-meta { font-size: .75rem; color: var(--muted); }

/* ===== v104 — الرئيسية الجديدة للموظف: مركز «يومك» + الإجراءات السريعة ===== */
.day-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; cursor: pointer; text-align: start; font-size: .88rem;
  color: var(--ink);
}
.day-row + .day-row { margin-top: 6px; }
.day-row.urgent { background: #fee2e2; border-color: #fca5a5; color: #7f1d1d; }
.day-row .d-ic { font-size: 1.15rem; }
.day-row .d-lbl { flex: 1; }
.day-row .d-arrow { color: var(--muted); font-size: 1.1rem; font-weight: 700; }
[dir="ltr"] .day-row .d-arrow { transform: scaleX(-1); }
body.dark .day-row { background: #161b21; }
body.dark .day-row.urgent { background: #4a1515; border-color: #7f1d1d; color: #fecaca; }

.qa-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 2px 0 4px; }
.qa-tile {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 4px; display: flex; flex-direction: column; align-items: center;
  gap: 4px; cursor: pointer; box-shadow: var(--shadow); color: var(--ink);
}
.qa-tile .qa-ic { font-size: 1.35rem; }
.qa-tile .qa-lbl { font-size: .7rem; font-weight: 700; text-align: center; }
body.dark .qa-tile { border-color: var(--line); }

.sched-badge {
  display: inline-block; background: #e6e1f7; color: #4b3a8c;
  padding: 3px 9px; border-radius: 20px; font-size: .7rem; font-weight: 700;
}
.busy-badge {
  display: inline-block; background: #f7e0e0; color: #963535;
  padding: 3px 9px; border-radius: 20px; font-size: .7rem; font-weight: 700;
}
.closed-card {
  background: #fde8d6; color: #9a5a12; padding: 16px; border-radius: 12px;
  text-align: center; margin-bottom: 12px;
}
.call-card {
  background: linear-gradient(135deg, var(--accent), #c2691e); color: #fff;
  padding: 18px; border-radius: 14px; margin-bottom: 12px; cursor: pointer;
  border: none; width: 100%; text-align: start;
}
.call-card b { font-size: 1.05rem; }
.call-card .sm { opacity: .85; font-size: .82rem; display: block; margin-top: 4px; }

/* ===== Code box / code input (TOTP, lock screen) — متكيّف مع الوضع الداكن ===== */
.code-box {
  background: #f4f5f7; color: #1c2530;
  text-align: center; font-family: monospace; font-size: 1.05rem;
  font-weight: 700; letter-spacing: 2px;
}
body.dark .code-box { background: #161b21; color: var(--ink); }
.code-input {
  width: 100%; padding: 14px; font-size: 1.4rem; text-align: center;
  letter-spacing: 5px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink);
}
body.dark .code-input { background: #0f1418; color: var(--ink); border-color: var(--line); }

@media (min-width: 721px) {
  .content { padding: 22px; }
  .grid2 { grid-template-columns: 1fr 1fr 1fr; }
}

/* ============ v46 — U1+U2: Accessibility & Mobile Polish ============ */

/* رابط "تخطّى إلى المحتوى" — يظهر فقط عند التركيز (Tab) */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--green-d);
  color: #fff;
  padding: 10px 16px;
  z-index: 9999;
  font-weight: 700;
  text-decoration: none;
  border-radius: 0 0 8px 0;
  transition: top .15s ease;
}
.skip-link:focus { top: 0; outline: 3px solid #fde68a; }

/* تركيز مرئي واضح لكل العناصر التفاعلية */
*:focus-visible {
  outline: 3px solid #fde68a !important;
  outline-offset: 2px;
}
button:focus-visible,
.btn:focus-visible,
.chip:focus-visible,
[role="button"]:focus-visible {
  outline: 3px solid #fde68a !important;
  outline-offset: 2px;
}

/* U2: الحد الأدنى للأهداف اللمسية = 44×44 (توصية WCAG 2.5.5) على الموبايل */
@media (hover: none) and (pointer: coarse) {
  button, .btn, .chip, a.btn, .icon-btn, .module-tile, .card-row, .list-row button {
    min-height: 44px;
    min-width: 44px;
  }
  .icon-btn { width: 44px; height: 44px; }
  /* رفع حجم الأرقام في العناوين الأصغر للقراءة */
  .small { font-size: .82rem; }
  .p-meta.small { font-size: .76rem; }
}

/* تركيز محسّن لمحتوى المودال — Tab يدور داخل المودال فقط */
.modal-back {
  /* تحديد الدور للقارئات */
}
.modal-back[aria-hidden="true"] { display: none; }

/* aria-live region للتوست — تُقرأ أوتوماتيكيًا */
#toast-root {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1500;
  pointer-events: none;
}

/* تحسين contrast للنصوص الصفراء/البرتقالية */
.badge.cancelled, .badge.new {
  /* تأكد أن النص ليس أصفر فاتح على خلفية بيضاء */
  color: #92400e;
}

/* اختصار «اضغط هنا» على عناصر cursor:pointer */
[onclick] { cursor: pointer; }

/* U3: spinner عام */
.spinner-inline {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin-rotate .8s linear infinite;
  vertical-align: middle;
  margin-inline-end: 6px;
}
.spinner-inline.dark {
  border-color: rgba(0,0,0,.15);
  border-top-color: var(--green-d);
}
.spinner-block {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  gap: 10px;
  color: var(--muted);
}
.spinner-block .sp {
  width: 24px; height: 24px;
  border: 3px solid rgba(0,0,0,.1);
  border-top-color: var(--green-d);
  border-radius: 50%;
  animation: spin-rotate .8s linear infinite;
}
@keyframes spin-rotate { to { transform: rotate(360deg); } }

/* Skeleton screen للقوائم أثناء التحميل */
.skeleton {
  background: linear-gradient(90deg, #eee 0%, #f5f5f5 50%, #eee 100%);
  background-size: 200% 100%;
  animation: skel 1.4s ease-in-out infinite;
  border-radius: 6px;
}
body.dark .skeleton {
  background: linear-gradient(90deg, #1f2937 0%, #2d3748 50%, #1f2937 100%);
}
@keyframes skel { 0% { background-position: 0% 0; } 100% { background-position: -200% 0; } }
.skeleton-line { height: 14px; margin: 8px 0; }
.skeleton-card { height: 80px; margin-bottom: 10px; }

/* اقتراحات لقارئ الشاشة */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============ v47 — UX5: Accordion Sections + Sticky Index ============ */

/* فهرس الأقسام (sticky chip bar في أعلى الـ content)
   v102 — يلتصق أسفل الشريط العلوي (الذي هو sticky أيضًا) بدل الاختفاء خلفه */
.section-index {
  position: sticky;
  top: var(--topbar-h, 0px);
  background: var(--bg);
  z-index: 18;
  padding: 10px 0;
  margin: -16px -16px 14px;
  padding-inline: 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.section-index::-webkit-scrollbar { height: 4px; }
.section-index::-webkit-scrollbar-thumb { background: var(--muted); border-radius: 2px; }
.section-index button {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 6px 12px;
  font-size: .78rem;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background .15s ease, border-color .15s ease;
}
.section-index button:hover { background: var(--card); }
.section-index button.active {
  background: var(--green-d);
  color: #fff;
  border-color: var(--green-d);
}
.section-index button .badge-mini {
  background: rgba(255,255,255,.25);
  border-radius: 10px;
  padding: 1px 6px;
  font-size: .65rem;
  font-weight: 700;
}

/* القسم القابل للطيّ */
.acc-section {
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 10px;
  background: var(--card);
  overflow: hidden;
  scroll-margin-top: calc(var(--topbar-h, 0px) + 64px);   /* v102 — للقفز السلس أسفل الشريط العلوي + الفهرس */
}
.acc-section.has-alert {
  border-color: #d97706;
  border-inline-start: 4px solid #d97706;
}
.acc-section.has-error {
  border-color: #dc2626;
  border-inline-start: 4px solid #dc2626;
}
.acc-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  min-height: 56px;
}
.acc-header:hover { background: var(--bg); }
.acc-header .acc-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.acc-header .acc-title {
  flex: 1;
  font-weight: 700;
  font-size: .95rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.acc-header .acc-sub {
  font-size: .75rem;
  color: var(--muted);
  font-weight: 400;
}
.acc-header .acc-badge {
  background: var(--green-d);
  color: #fff;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: .7rem;
  font-weight: 700;
}
.acc-header .acc-badge.warn { background: #d97706; }
.acc-header .acc-badge.err { background: #dc2626; }
.acc-header .acc-chevron {
  font-size: 1.1rem;
  transition: transform .25s ease;
  color: var(--muted);
}
.acc-section.open .acc-chevron { transform: rotate(180deg); }

.acc-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height .35s ease, padding .25s ease;
  padding: 0 16px;
}
.acc-section.open .acc-body {
  max-height: 4000px;
  padding: 0 16px 16px;
}

/* تجميع أقسام تحت عنوان فئة */
.acc-group {
  margin-bottom: 18px;
}
.acc-group-title {
  font-size: .75rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  padding: 0 4px 8px;
}

/* تحسين الجداول داخل الـ accordion (يكون عرض أصغر أحيانًا) */
.acc-body .card { margin-bottom: 8px; }
.acc-body .card:last-child { margin-bottom: 0; }

/* RTL adjustments */
html[dir="rtl"] .acc-section.has-alert,
html[dir="rtl"] .acc-section.has-error {
  /* border-inline-start يعمل تلقائيًا */
}

/* ============ v48 — Search Bar ============ */
.search-bar-wrap {
  margin-bottom: 12px;
}
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 12px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.search-bar:focus-within {
  border-color: var(--green-d);
  box-shadow: 0 0 0 3px rgba(31,111,84,.15);
}
.search-bar .search-icon {
  font-size: 1.1rem;
  opacity: .55;
  flex-shrink: 0;
}
.search-bar .search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 6px 0;
  font-size: .95rem;
  color: var(--ink);
  min-height: 32px;
}
.search-bar .search-input::placeholder { color: var(--muted); }
/* أخفِ زر إفراغ المتصفح الافتراضي */
.search-bar .search-input::-webkit-search-decoration,
.search-bar .search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}
.search-bar .search-clear {
  background: var(--bg);
  border: none;
  border-radius: 50%;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  cursor: pointer;
  font-size: .8rem;
  flex-shrink: 0;
}
.search-bar .search-clear:hover { background: var(--line); color: var(--ink); }
.search-bar .search-count {
  font-size: .72rem;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Empty state عند عدم وجود نتائج */
.search-empty-state {
  border: 1px dashed var(--line);
  border-radius: 12px;
  margin-top: 4px;
}

/* Touch target على الموبايل */
@media (hover: none) and (pointer: coarse) {
  .search-bar .search-input { min-height: 38px; }
  .search-bar .search-clear { width: 32px; height: 32px; }
}
