/* theme.css v12 — إصلاح أولوية الأزرار: button.btn كانت تغلب btn-danger */

:root, [data-theme="dark"] {
  --bg:#0B1120; --surface:#131A2A; --surface2:#1B2436; --border:#1E293B;
  --accent:#2F6FED; --accent-light:#5B8DF0; --text:#F1F5F9; --muted:#8A94A6;
  --ok:#22C55E; --danger:#EF4444; --warn:#F59E0B;
  --shadow: 0 8px 30px rgba(0,0,0,.35);
  --radius: 9px;
  --radius-sm: 7px;
  --radius-lg: 12px;
  --page-max: 1100px;
  --accent-soft: rgba(47,111,237,.14);
  --accent-glow: rgba(47,111,237,.22);
}
[data-theme="light"] {
  --bg:#F8FAFC;
  --surface:#FFFFFF;
  --surface2:#F1F5F9;
  --border:#E2E8F0;
  --accent:#2563EB;
  --accent-light:#3B82F6;
  --text:#0F172A;
  --muted:#475569;
  --ok:#15803D;
  --danger:#DC2626;
  --warn:#D97706;
  --shadow: 0 4px 16px rgba(15,23,42,.06);
  --accent-soft: rgba(37,99,235,.12);
  --accent-glow: rgba(37,99,235,.15);
}

*{box-sizing:border-box;}
/* بلا هذا يخسر [hidden] أمام أي محدِّد صنف بالخصوصية نفسها يعرّف display لاحقًا في
   الملف (`.pm-pop` مثلًا) — والسمة تبقى في الـDOM بلا أثر مرئي. عامّ هنا لا في صفحة
   واحدة: أي عنصر بأي صفحة قد يُخفى بـ`hidden` مستقبلًا. */
[hidden]{display:none !important;}
html{color-scheme:light dark;}

/* أيقونات SVG خطّية موحّدة (icons.js) — بديل الإيموجي بأنحاء الواجهة تدريجيًا */
.icon{display:inline-block;vertical-align:-3px;flex-shrink:0;}
.btn .icon,button .icon{vertical-align:-2px;}
body{
  margin:0;background:var(--bg);color:var(--text);
  font-family:'Cairo','IBM Plex Sans Arabic',sans-serif;
  min-height:100vh;line-height:1.6;
  transition:background .15s ease, color .15s ease;
}
h1,h2,h3,.mono{font-family:'Space Grotesk',sans-serif;}
.tabular,.mono{font-variant-numeric:tabular-nums;font-feature-settings:"tnum" 1;}

.skip-link{
  position:absolute;top:-100px;right:16px;z-index:9999;
  background:var(--accent);color:#fff;padding:10px 16px;
  border-radius:var(--radius-sm);font-weight:700;font-size:13px;
  text-decoration:none;
}
.skip-link:focus{top:12px;outline:3px solid var(--warn);outline-offset:2px;}
*:focus-visible{
  outline:3px solid var(--accent) !important;
  outline-offset:2px !important;
}

/* ========== أزرار — base ثم variants بأولوية أعلى من button.btn ========== */
.btn, button.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:6px;
  background:var(--accent);color:#fff;border:1px solid transparent;
  padding:8px 14px;border-radius:var(--radius-sm);
  font-family:inherit;font-size:13px;font-weight:600;line-height:1.3;
  cursor:pointer;text-decoration:none;white-space:nowrap;
  transition:background .12s ease, border-color .12s ease, color .12s ease, opacity .12s ease, filter .12s ease;
}
.btn:disabled,.btn[disabled]{opacity:.55;cursor:not-allowed;pointer-events:none;}
.btn:focus-visible{outline:2px solid var(--accent);outline-offset:2px;}

/* أساسي */
button.btn.btn-primary,
.btn.btn-primary,
button.btn-primary{
  background:var(--accent);color:#fff;border-color:transparent;
}
button.btn.btn-primary:hover,
.btn.btn-primary:hover,
button.btn-primary:hover{
  background:var(--accent-light);color:#fff;
}
/* hover للأزرق الافتراضي فقط */
button.btn:hover:not(.btn-secondary):not(.secondary):not(.btn-danger):not(.danger):not(.btn-success):not(.btn-ok):not(.ok):not(.btn-ghost):not(.btn-outline):not(.btn-logout),
.btn:hover:not(.btn-secondary):not(.secondary):not(.btn-danger):not(.danger):not(.btn-success):not(.btn-ok):not(.ok):not(.btn-ghost):not(.btn-outline):not(.btn-logout){
  background:var(--accent-light);color:#fff;
}

/* ثانوي — رمادي (specificity: button.btn.btn-secondary = 0,2,1 > button.btn) */
button.btn.btn-secondary,
.btn.btn-secondary,
button.btn.secondary,
.btn.secondary{
  background:var(--surface) !important;
  color:var(--text) !important;
  border:1px solid var(--border) !important;
}
button.btn.btn-secondary:hover,
.btn.btn-secondary:hover,
button.btn.secondary:hover,
.btn.secondary:hover{
  background:var(--surface2) !important;
  border-color:var(--accent) !important;
  color:var(--accent) !important;
}

/* خطر / حذف — أحمر */
button.btn.btn-danger,
.btn.btn-danger,
button.btn.danger,
.btn.danger{
  background:var(--danger) !important;
  color:#fff !important;
  border-color:transparent !important;
}
button.btn.btn-danger:hover,
.btn.btn-danger:hover,
button.btn.danger:hover,
.btn.danger:hover{
  filter:brightness(1.12);
  color:#fff !important;
}

/* نجاح / تأكيد — أخضر */
button.btn.btn-success,
.btn.btn-success,
button.btn.btn-ok,
.btn.btn-ok,
button.btn.ok,
.btn.ok{
  background:var(--ok) !important;
  color:#fff !important;
  border-color:transparent !important;
}
button.btn.btn-success:hover,
.btn.btn-success:hover,
button.btn.btn-ok:hover,
.btn.btn-ok:hover,
button.btn.ok:hover,
.btn.ok:hover{
  filter:brightness(1.12);
  color:#fff !important;
}

button.btn.btn-ghost,
.btn.btn-ghost{
  background:transparent !important;
  color:var(--muted) !important;
  border-color:transparent !important;
}
button.btn.btn-ghost:hover,
.btn.btn-ghost:hover{
  background:var(--surface2) !important;
  color:var(--text) !important;
}

button.btn.btn-outline,
.btn.btn-outline{
  background:transparent !important;
  color:var(--accent) !important;
  border:1px solid var(--accent) !important;
}
button.btn.btn-outline:hover,
.btn.btn-outline:hover{
  background:var(--accent-soft) !important;
  color:var(--accent) !important;
}

.btn-sm,.btn.small,button.btn.small,button.btn.btn-sm{padding:5px 10px;font-size:12px;border-radius:6px;}
.btn-lg,button.btn.btn-lg{padding:12px 18px;font-size:14px;border-radius:var(--radius);}
.btn-block{width:100%;display:flex;}

/* زر مصادقة بعرض كامل */
button.btn-primary{
  width:100%;background:var(--accent);color:#fff;border:none;
  padding:12px;border-radius:var(--radius);font-family:inherit;
  font-size:14px;font-weight:700;cursor:pointer;margin-top:6px;
}
button.btn-primary:hover{background:var(--accent-light);color:#fff;}

.btn-logout{
  background:var(--surface);color:var(--text);border:1px solid var(--border);
  padding:7px 12px;border-radius:8px;font-family:inherit;font-size:12px;cursor:pointer;
}
.btn-logout:hover{border-color:var(--danger);color:var(--danger);background:var(--surface);}

.field,.form-group{margin-bottom:14px;}
.field label,.form-group label,
label{display:block;font-size:12.5px;color:var(--muted);margin-bottom:5px;font-weight:500;}
.field .hint,.form-hint,.hint{font-size:11.5px;color:var(--muted);margin-top:4px;}
.field .error,.form-error{font-size:12px;color:var(--danger);margin-top:4px;}

.input,.select,.textarea,
.field input,.form-group input,
.field select,.form-group select,
.field textarea,.form-group textarea,
input:not([type=checkbox]):not([type=radio]):not([type=file]),
select,textarea{
  width:100%;
  background:var(--surface);
  border:1px solid var(--border);
  color:var(--text);
  padding:10px 12px;
  border-radius:var(--radius);
  font-family:inherit;
  font-size:13.5px;
  transition:border-color .12s ease, box-shadow .12s ease;
}
[data-theme="dark"] input:not([type=checkbox]):not([type=radio]):not([type=file]),
[data-theme="dark"] select,
[data-theme="dark"] textarea{background:var(--surface2);}
input:not([type=checkbox]):not([type=radio]):not([type=file]):focus,
select:focus,textarea:focus,
.input:focus,.select:focus,.textarea:focus{
  outline:none;border-color:var(--accent);
  box-shadow:0 0 0 3px var(--accent-soft);
}
input:disabled,select:disabled,textarea:disabled{opacity:.6;cursor:not-allowed;}
textarea{min-height:90px;resize:vertical;line-height:1.5;}
.input-sm,.select-sm,input.inline-date,select.inline-role{
  padding:6px 8px;font-size:12px;border-radius:var(--radius-sm);
}
input.inline-date{width:130px;}
.row{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:10px;margin-bottom:12px;}

.radio-group,.checkbox-group{display:flex;flex-direction:column;gap:8px;}
.radio-group.horizontal,.checkbox-group.horizontal,.radio-group{
  flex-direction:row;flex-wrap:wrap;gap:6px 16px;
  margin-bottom:14px;padding:10px 12px;
  background:var(--surface2);border:1px solid var(--border);border-radius:10px;
}
.radio-group label,.checkbox-group label{
  display:flex;align-items:center;gap:5px;font-size:12px;
  color:var(--text);margin:0;white-space:nowrap;cursor:pointer;
}
.radio-group input[type=radio],.radio-group input[type=checkbox],.checkbox-group input{
  width:auto;margin:0;accent-color:var(--accent);
}

.radio,.checkbox{
  display:inline-flex;align-items:center;gap:8px;
  font-size:13.5px;color:var(--text);cursor:pointer;user-select:none;
}
.radio input,.checkbox input{position:absolute;opacity:0;width:0;height:0;}
.radio .control{
  width:18px;height:18px;border-radius:50%;
  border:2px solid var(--border);background:var(--surface);
  display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;
}
.radio input:checked + .control{border-color:var(--accent);background:var(--accent);}
.radio input:checked + .control::after{content:"";width:6px;height:6px;border-radius:50%;background:#fff;}
.checkbox .control{
  width:18px;height:18px;border-radius:5px;
  border:2px solid var(--border);background:var(--surface);
  display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;
}
.checkbox input:checked + .control{border-color:var(--accent);background:var(--accent);}
.checkbox input:checked + .control::after{
  content:"";width:10px;height:6px;
  border-left:2px solid #fff;border-bottom:2px solid #fff;
  transform:rotate(-45deg) translate(1px,-1px);
}

.badge{
  display:inline-flex;align-items:center;gap:5px;
  padding:3px 10px;border-radius:999px;
  font-size:12px;font-weight:600;white-space:nowrap;
}
.badge-ok,.badge.active,.badge.approved,.badge.delivered,.badge.confirmed{background:rgba(34,197,94,.15);color:var(--ok);}
.badge-danger,.badge.rejected,.badge.cancelled,.badge.expired,.badge.inactive,.badge.unpaid{background:rgba(239,68,68,.15);color:var(--danger);}
.badge-warn,.badge.pending,.badge.shipped{background:rgba(245,158,11,.15);color:var(--warn);}
.badge-neutral,.badge.soon{background:var(--surface2);color:var(--muted);border:1px solid var(--border);}
.badge.live{background:rgba(34,197,94,.15);color:var(--ok);}
.badge.pending-badge{background:rgba(245,158,11,.15);color:var(--warn);}

.kpi-strip,.stat{display:flex;gap:12px;flex-wrap:wrap;margin-bottom:16px;}
.kpi-card,.stat div{
  flex:1;min-width:140px;
  background:var(--surface);border:1px solid var(--border);
  border-radius:var(--radius-lg);padding:14px 18px;box-shadow:var(--shadow);
}
.kpi-card .kpi-label{font-size:12px;color:var(--muted);margin-bottom:6px;}
.kpi-card .kpi-value,.stat b{
  font-size:22px;font-weight:700;font-family:'Space Grotesk',sans-serif;
  font-variant-numeric:tabular-nums;display:block;
}
.kpi-card.accent .kpi-value{color:var(--accent);}
.kpi-card.ok .kpi-value{color:var(--ok);}
.kpi-card.danger .kpi-value{color:var(--danger);}
.kpi-bar{
  display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));
  gap:12px;padding:20px 28px 0;max-width:var(--page-max);margin:0 auto;
}
.kpi{
  background:var(--surface);border:1px solid var(--border);
  border-radius:12px;padding:16px 18px;display:flex;flex-direction:column;gap:4px;box-shadow:var(--shadow);
}
.kpi .num{
  font-family:'Space Grotesk';font-size:26px;font-weight:700;
  color:var(--accent);display:block;font-variant-numeric:tabular-nums;
}
.kpi .label{font-size:12px;color:var(--muted);}
.kpi .kpi-change{display:inline-flex;align-items:center;gap:3px;font-size:11.5px;font-weight:600;margin-top:4px;}
.kpi .kpi-change.up{color:var(--ok);}
.kpi .kpi-change.down{color:var(--danger);}
.kpi .kpi-change.flat{color:var(--muted);}

.table-wrap{overflow-x:auto;width:100%;-webkit-overflow-scrolling:touch;}
.data-table,table{width:100%;border-collapse:collapse;font-size:13.5px;margin-top:8px;}
.data-table th,table th{
  text-align:right;padding:10px 12px;color:var(--muted);font-weight:600;font-size:12px;
  border-bottom:1px solid var(--border);
}
.data-table th{position:sticky;top:0;background:var(--bg);z-index:1;}
.data-table td,table td{
  padding:10px 12px;border-bottom:1px solid var(--border);
  font-variant-numeric:tabular-nums;vertical-align:middle;
}
.data-table tbody tr:hover,tr.clickable-row:hover{background:var(--surface2);}
tr.clickable-row{cursor:pointer;transition:background .1s ease;}
.data-table .num,.num{text-align:left;}

.card{
  background:var(--surface);border:1px solid var(--border);
  border-radius:var(--radius-lg);padding:20px;margin-bottom:16px;box-shadow:var(--shadow);
}
.card h2{margin:0 0 12px;font-size:15px;color:var(--accent);}
.hint{font-size:11.5px;color:var(--muted);margin-bottom:12px;}
.msg{padding:10px 14px;border-radius:var(--radius);font-size:13px;margin-top:12px;display:none;}
.msg.ok{background:rgba(34,197,94,.1);color:var(--ok);border:1px solid rgba(34,197,94,.3);display:block;}
.msg.err{background:rgba(239,68,68,.1);color:var(--danger);border:1px solid rgba(239,68,68,.3);display:block;}

.tabs,nav.tabs,header + nav,body > nav{
  display:flex;gap:4px;border-bottom:1px solid var(--border);
  overflow-x:auto;padding:0 28px;-webkit-overflow-scrolling:touch;
}
.tab-btn,nav button{
  background:none;border:none;color:var(--muted);
  padding:14px 16px;font-family:inherit;font-size:14px;
  cursor:pointer;border-bottom:2px solid transparent;white-space:nowrap;
}
.tab-btn:hover,nav button:hover{color:var(--text);}
.tab-btn.active,nav button.active{color:var(--accent);border-bottom-color:var(--accent);}
.tab{display:none;}
.tab.active{display:block;}

header.app-header,body > header{
  padding:16px 28px;border-bottom:1px solid var(--border);
  display:flex;align-items:center;justify-content:space-between;
  flex-wrap:wrap;gap:10px;background:var(--surface);
}
header h1{margin:0;font-size:18px;font-weight:700;color:var(--accent);}
header span{color:var(--muted);font-size:13px;}
.back-link{color:var(--muted);text-decoration:none;font-size:13px;display:inline-flex;align-items:center;gap:6px;}
.back-link:hover{color:var(--accent);}
.header-right{display:flex;align-items:center;gap:10px;flex-wrap:wrap;}
.user-badge{
  font-size:12px;color:var(--muted);background:var(--surface2);
  border:1px solid var(--border);padding:6px 10px;border-radius:8px;
}
main,main.page{padding:24px 28px;max-width:var(--page-max);margin:0 auto;}

.tenant-bar{
  display:flex;align-items:center;gap:8px;
  background:var(--surface);border:1px solid var(--border);
  border-radius:8px;padding:6px 10px;
}
.tenant-bar select{
  background:transparent;border:none;color:var(--text);
  font-family:inherit;font-size:13px;min-width:180px;max-width:100%;
  padding:4px 0;box-shadow:none;
}
.tenant-bar label{color:var(--muted);font-size:12px;white-space:nowrap;margin:0;}
.toolbar{display:flex;gap:10px;align-items:center;margin-bottom:14px;flex-wrap:wrap;}
.toolbar input,.toolbar select{flex:1;min-width:150px;}
.toolbar .btn{flex:none;}
.add-panel{display:none;background:var(--surface2);border:1px solid var(--border);border-radius:10px;padding:14px;margin-bottom:14px;}
.add-panel.open{display:block;}
.inline-edit{background:var(--surface2);border:1px solid var(--border);border-radius:10px;padding:14px;margin:4px 0;}
.actions-bar,.row-actions{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin-top:10px;}
.empty{color:var(--muted);text-align:center;padding:28px 16px;font-size:13.5px;}
.item-row{display:grid;grid-template-columns:2fr 1fr auto;gap:8px;margin-bottom:8px;align-items:end;}
.legend{display:flex;gap:16px;align-items:center;flex-wrap:wrap;font-size:12px;color:var(--muted);}

.modal-backdrop{
  display:none;position:fixed;inset:0;background:rgba(10,22,40,.45);
  z-index:50;align-items:flex-start;justify-content:center;padding:40px 16px;overflow-y:auto;
}
.modal-backdrop.open{display:flex;}
.modal{background:var(--surface);border:1px solid var(--border);border-radius:14px;padding:24px;max-width:780px;width:100%;box-shadow:var(--shadow);}
.modal-header{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:16px;}
.modal-header h3{margin:0;font-size:17px;}
.modal-close{background:var(--surface2);border:1px solid var(--border);color:var(--text);width:32px;height:32px;border-radius:8px;cursor:pointer;font-size:14px;}
/* ===== محرّر صور المنتج ومتغيّراته (product-editor.js) =====
   هنا لا في صفحة واحدة: الوحدة تُستدعى من /products-manager واليوم، ومن /store لاحقًا. */
.btn-xs{padding:4px 9px;font-size:11.5px;border-radius:7px;}
.pe-modal{max-width:900px;}
.pe-tabs{display:flex;gap:6px;border-bottom:1px solid var(--border);margin-bottom:12px;}
.pe-tab{background:none;border:none;border-bottom:2px solid transparent;color:var(--muted);
  font-family:inherit;font-size:13px;padding:8px 14px;cursor:pointer;}
.pe-tab.on{color:var(--accent);border-bottom-color:var(--accent);font-weight:600;}
.pe-imgs{display:flex;gap:10px;flex-wrap:wrap;margin:12px 0;}
.pe-img{margin:0;position:relative;width:132px;border:1px solid var(--border);border-radius:11px;
  overflow:hidden;background:var(--surface2);}
.pe-img img{width:100%;height:96px;object-fit:cover;display:block;background:var(--surface2);}
.pe-img img.broken{min-height:96px;border-bottom:1px dashed var(--danger);}
.pe-main{position:absolute;top:6px;inset-inline-start:6px;background:var(--accent);color:#fff;
  font-size:10px;padding:2px 7px;border-radius:999px;}
.pe-img figcaption{display:flex;gap:4px;padding:6px;flex-wrap:wrap;}
.pe-del{color:var(--danger);}
.pe-drop{display:flex;flex-direction:column;align-items:center;gap:8px;text-align:center;
  padding:22px 16px;border:2px dashed var(--border);border-radius:12px;background:var(--surface2);
  transition:border-color .15s,background .15s;}
.pe-drop.over{border-color:var(--accent);background:var(--widget-bg,var(--surface));}
.pe-bylink{margin-top:12px;}
.pe-bylink summary{cursor:pointer;font-size:12.5px;color:var(--muted);padding:4px 0;}
.pe-bylink summary:hover{color:var(--accent);}
.pe-addimg{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin-top:10px;}
.pe-addimg input{flex:1;min-width:180px;padding:9px 11px;border-radius:9px;border:1px solid var(--border);
  background:var(--surface2);color:inherit;font-family:inherit;font-size:13px;}
.pe-opts-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px;}
.pe-opts-head h4{margin:0;font-size:13px;color:var(--accent);}
.pe-opt{display:flex;gap:8px;margin-bottom:8px;align-items:center;flex-wrap:wrap;}
.pe-opt input{padding:8px 10px;border-radius:8px;border:1px solid var(--border);background:var(--surface2);
  color:inherit;font-family:inherit;font-size:13px;}
.pe-opt input[data-f=oname]{width:150px;}
.pe-opt input[data-f=ovalues]{flex:1;min-width:200px;}
.pe-simple{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin-top:10px;}
.pe-simple input{width:120px;padding:8px 10px;border-radius:8px;border:1px solid var(--border);
  background:var(--surface2);color:inherit;font-family:'Space Grotesk',monospace;font-size:13px;}
.pe-wrap{overflow-x:auto;border:1px solid var(--border);border-radius:11px;margin:12px 0;}
table.pe-var{width:100%;border-collapse:collapse;font-size:13px;min-width:640px;}
table.pe-var th{text-align:right;padding:11px 10px;font-size:12px;color:var(--muted);
  border-bottom:1px solid var(--border);white-space:nowrap;cursor:default;}
table.pe-var td{padding:8px 10px;border-bottom:1px solid var(--border);vertical-align:middle;}
table.pe-var tr:last-child td{border-bottom:none;}
/* معرَّفة كاملةً لا اعتمادًا على `.cell-edit` المحلّية في /products-manager — الوحدة مستقلّة */
table.pe-var .cell-edit{width:100%;padding:6px 8px;border-radius:7px;border:1px solid var(--border);
  background:var(--surface2);color:inherit;font-family:inherit;font-size:13px;}
table.pe-var .cell-edit:focus{border-color:var(--accent);outline:none;}
table.pe-var .cell-edit.num{width:96px;font-family:'Space Grotesk',monospace;}
.pe-foot{display:flex;justify-content:space-between;align-items:center;gap:10px;flex-wrap:wrap;}

.ok-text{color:var(--ok);}
.err-text{color:var(--danger);}

/* تبويب التفاصيل: العلامة · الباركود · الوزن · الوسوم */
.pe-details{display:flex;flex-direction:column;gap:16px;max-width:420px;}
.pe-field{display:flex;flex-direction:column;gap:6px;font-size:12.5px;color:var(--muted);}
.pe-field input{padding:9px 11px;border-radius:9px;border:1px solid var(--border);background:var(--surface2);
  color:inherit;font-family:inherit;font-size:13.5px;}
.pe-field input:focus{border-color:var(--accent);outline:none;}
.pe-tags{display:flex;flex-wrap:wrap;gap:6px;min-height:28px;}
.pe-tag-chip{display:inline-flex;align-items:center;gap:6px;font-size:12px;padding:5px 10px;
  border-radius:999px;border:1px solid var(--accent);color:var(--accent);background:var(--accent-soft,transparent);}
.pe-tag-chip button{background:none;border:none;color:inherit;cursor:pointer;font-size:12px;line-height:1;padding:0;}
.pe-tag-add{position:relative;margin-top:8px;}
.pe-tag-add input{width:100%;padding:9px 11px;border-radius:9px;border:1px solid var(--border);
  background:var(--surface2);color:inherit;font-family:inherit;font-size:13px;}
.pe-tag-suggest{position:absolute;top:calc(100% + 4px);inset-inline:0;z-index:10;max-height:180px;overflow-y:auto;
  background:var(--surface);border:1px solid var(--border);border-radius:9px;box-shadow:var(--shadow);}
.pe-tag-opt{padding:8px 11px;font-size:13px;cursor:pointer;}
.pe-tag-opt:hover{background:var(--surface2);}

.detail-section{margin-bottom:18px;}
.detail-section h4{font-size:12.5px;color:var(--accent);margin:0 0 8px;}
.detail-section table{display:block;overflow-x:auto;max-width:100%;}
.mini-stats{display:flex;gap:12px;flex-wrap:wrap;}
.mini-stats div{background:var(--surface2);border:1px solid var(--border);border-radius:9px;padding:10px 14px;flex:1;min-width:110px;}
.mini-stats b{display:block;font-size:18px;font-family:'Space Grotesk',sans-serif;}

.theme-toggle{
  background:var(--surface);border:1px solid var(--border);color:var(--text);
  width:36px;height:36px;border-radius:var(--radius);cursor:pointer;font-size:15px;
  display:flex;align-items:center;justify-content:center;
}
.theme-toggle:hover{border-color:var(--accent);}
.auth-shell{min-height:100vh;display:flex;align-items:center;justify-content:center;padding:24px;}
.auth-card{background:var(--surface);border:1px solid var(--border);border-radius:16px;padding:32px;width:100%;max-width:400px;box-shadow:var(--shadow);}
.auth-card .logo{font-size:15px;font-weight:700;color:var(--accent);margin-bottom:4px;}
.auth-card h1{font-size:20px;margin:12px 0 6px;}
.auth-card p.subtitle{color:var(--muted);font-size:13px;margin:0 0 22px;}
.auth-links{margin-top:18px;text-align:center;font-size:13px;color:var(--muted);}
.auth-links a{color:var(--accent);text-decoration:none;}
.auth-links a:hover{text-decoration:underline;}

.intro{margin-bottom:28px;}
.intro h2{font-size:22px;margin:0 0 6px;}
.intro p{color:var(--muted);margin:0;font-size:14px;line-height:1.7;max-width:640px;}
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:16px;}
.grid .card{position:relative;transition:border-color .15s ease, transform .12s ease, box-shadow .12s ease;margin-bottom:0;}
.grid .card:hover{border-color:var(--accent);transform:translateY(-2px);box-shadow:var(--shadow);}
.card-icon{
  width:40px;height:40px;border-radius:10px;background:var(--accent-soft);
  display:flex;align-items:center;justify-content:center;font-size:20px;margin-bottom:14px;
}
.grid .card h3{margin:0 0 6px;font-size:15px;}
.grid .card p{margin:0;color:var(--muted);font-size:12.5px;line-height:1.6;}
a.card{text-decoration:none;color:inherit;display:block;cursor:pointer;}
a.card .card-icon{background:var(--accent-soft);color:var(--accent);}
.card.disabled{opacity:.55;cursor:default;}
.grid .badge{position:absolute;top:18px;left:18px;font-size:10.5px;padding:3px 9px;}
.btn-subscribe{background:var(--accent);color:#fff;border:none;padding:8px 16px;border-radius:8px;font-family:inherit;font-size:12.5px;font-weight:600;cursor:pointer;margin-top:8px;}
.btn-subscribe:hover{background:var(--accent-light);color:#fff;}
.btn-admin-link{background:var(--accent);color:#fff;border:none;padding:8px 14px;border-radius:8px;font-family:inherit;font-size:12.5px;cursor:pointer;text-decoration:none;display:none;}
.btn-admin-link:hover{background:var(--accent-light);color:#fff;}
.sub-msg{font-size:11.5px;margin-top:8px;display:none;}
.sub-msg.ok{color:var(--ok);display:block;}
.sub-msg.err{color:var(--danger);display:block;}
footer{text-align:center;padding:24px;color:var(--muted);font-size:12px;}

[id$="_table"],.table-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch;}
[id$="_table"] table{min-width:520px;}
/* كانت > (ابن مباشر) فقط — أي جدول يُبنى بجافاسكربت جوّا div وسيط داخل .card
   (نمط شائع بلوحة المعلّم/الأدمن، مثال: #instructor_students_list > table)
   كان يفلت من هذي القاعدة ويطلع عرضًا خارج حدود الكرت على الجوال. descendant
   selector يغطي أي عمق تداخل، بلا أثر جانبي إضافي عن نية القاعدة الأصلية. */
.card table{display:block;overflow-x:auto;max-width:100%;}

.segmented{
  display:inline-flex;flex-wrap:wrap;gap:4px;
  background:var(--surface2);border:1px solid var(--border);
  border-radius:10px;padding:4px;margin-bottom:12px;
}
.segmented button,.segmented .seg-btn{
  background:transparent;border:none;color:var(--muted);
  padding:7px 12px;border-radius:7px;font-family:inherit;
  font-size:12.5px;font-weight:600;cursor:pointer;white-space:nowrap;
}
.segmented button:hover,.segmented .seg-btn:hover{color:var(--text);}
.segmented button.active,.segmented .seg-btn.active,.segmented button[aria-pressed="true"]{background:var(--accent);color:#fff;}

.skeleton{
  background:linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
  background-size:200% 100%;animation:skeleton-shimmer 1.4s ease-in-out infinite;border-radius:var(--radius-sm);
}
.skeleton-line{height:12px;margin-bottom:8px;}
.skeleton-line.short{width:55%;}
.skeleton-line.medium{width:75%;}
.skeleton-avatar{width:36px;height:36px;border-radius:50%;}
.skeleton-block{height:64px;border-radius:var(--radius);}
@keyframes skeleton-shimmer{0%{background-position:200% 0;}100%{background-position:-200% 0;}}
@media (prefers-reduced-motion:reduce){.skeleton{animation:none;background:var(--surface2);}}

.progress{width:100%;height:8px;background:var(--surface2);border:1px solid var(--border);border-radius:999px;overflow:hidden;}
.progress-bar{height:100%;background:var(--accent);border-radius:999px;transition:width .35s ease;}
.progress-bar.ok{background:var(--ok);}
.progress-bar.warn{background:var(--warn);}
.progress-bar.danger{background:var(--danger);}
.progress-label{display:flex;justify-content:space-between;align-items:center;font-size:12px;color:var(--muted);margin-bottom:6px;}
.progress-label .val{font-family:'Space Grotesk',sans-serif;font-variant-numeric:tabular-nums;color:var(--text);}

.toast-host{position:fixed;bottom:20px;left:20px;z-index:200;display:flex;flex-direction:column;gap:8px;pointer-events:none;max-width:min(360px, calc(100vw - 32px));}
.toast{pointer-events:auto;display:flex;align-items:flex-start;gap:10px;padding:12px 14px;border-radius:10px;background:var(--surface);border:1px solid var(--border);box-shadow:var(--shadow);font-size:13px;line-height:1.45;}
.toast.ok{border-color:rgba(34,197,94,.35);}
.toast.err{border-color:rgba(239,68,68,.35);}
.toast.warn{border-color:rgba(245,158,11,.35);}
.toast .toast-body{flex:1;min-width:0;}
.toast .toast-close{background:transparent;border:none;color:var(--muted);cursor:pointer;font-size:16px;line-height:1;padding:0 2px;}

.pagination{display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:10px;margin-top:12px;font-size:12.5px;color:var(--muted);}
.page-numbers{display:flex;gap:4px;flex-wrap:wrap;}
.page-btn{
  min-width:32px;height:32px;padding:0 8px;border-radius:7px;border:1px solid var(--border);
  background:var(--surface);color:var(--text);font-family:inherit;font-size:12.5px;font-weight:600;
  cursor:pointer;display:inline-flex;align-items:center;justify-content:center;
}
.page-btn:hover{border-color:var(--accent);color:var(--accent);}
.page-btn.active{background:var(--accent);border-color:var(--accent);color:#fff;}
.page-btn:disabled{opacity:.45;cursor:not-allowed;}

.switch-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 0;}
.switch-row .switch-text{flex:1;min-width:0;}
.switch-row .switch-title{font-size:13.5px;font-weight:600;}
.switch-row .switch-desc{font-size:12px;color:var(--muted);margin-top:2px;}
.switch{
  position:relative;width:44px;height:24px;flex-shrink:0;
  background:var(--border);border:none;border-radius:999px;cursor:pointer;padding:0;
}
.switch[aria-checked="true"]{background:var(--accent);}
.switch .thumb{position:absolute;top:3px;right:3px;width:18px;height:18px;border-radius:50%;background:#fff;transition:transform .15s ease;}
.switch[aria-checked="true"] .thumb{transform:translateX(-20px);}

.kpi-change{display:inline-flex;align-items:center;gap:3px;font-size:11.5px;font-weight:600;margin-top:6px;}
.kpi-change.up{color:var(--ok);}
.kpi-change.down{color:var(--danger);}
.kpi-change.flat{color:var(--muted);}

.breadcrumbs{display:flex;align-items:center;flex-wrap:wrap;gap:6px;font-size:12.5px;color:var(--muted);margin-bottom:14px;}
.breadcrumbs a{color:var(--muted);text-decoration:none;}
.breadcrumbs a:hover{color:var(--accent);}
.breadcrumbs .current{color:var(--text);font-weight:600;}
.breadcrumbs .sep{opacity:.5;}

@media (max-width: 640px){
  body > header,header.app-header{padding:12px 16px;}
  header h1{font-size:16px;}
  header .mono{font-size:11px;}
  .header-right{width:100%;justify-content:space-between;}
  .user-badge{display:none;}
  body > nav,.tabs{padding:0 16px;}
  nav button,.tab-btn{padding:12px 10px;font-size:13px;}
  main,main.page{padding:16px 14px;}
  .card{padding:14px;}
  .row{grid-template-columns:1fr;}
  .item-row{grid-template-columns:1fr;align-items:stretch;}
  table{font-size:12px;}
  th,td{padding:6px;}
  .stat div{min-width:100%;}
  .actions-bar,.row-actions{flex-direction:column;align-items:stretch;}
  .actions-bar .btn,.row-actions .btn{width:100%;}
  .toolbar{flex-direction:column;align-items:stretch;}
  .toolbar input,.toolbar select,.toolbar .btn{width:100%;}
  .kpi-bar{padding:16px 14px 0;grid-template-columns:repeat(2,1fr);}
  .modal{padding:16px;}
  .tenant-bar{flex:1;min-width:0;}
  .tenant-bar select{min-width:0;flex:1;}
  input.inline-date{width:100%;}
  .grid{grid-template-columns:1fr;}
  .intro h2{font-size:19px;}
  #payments_table table{min-width:0;width:100%;table-layout:auto;}
  #payments_table table th:nth-child(6),#payments_table table td:nth-child(6),
  #payments_table table th:nth-child(7),#payments_table table td:nth-child(7){display:none;}
}
@media (prefers-reduced-motion: reduce){
  *,*::before,*::after{transition-duration:0.01ms !important;}
}

/* ========== مبدل اللغة — رموز مختصرة (AR/FR/EN) بحجم أزرار الهيدر الأخرى
   (.theme-toggle: 36px) بدل نص كامل لكل لغة بخلفية منفصلة — إعادة تصميم 9 أغسطس
   2026 بطلب حِيشام صراحة ("أزرار اللغة فكرت في تصميمهم؟"). ========== */
.language-switcher{
  display:flex;align-items:center;gap:3px;
  background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);
  padding:3px;margin-left:8px;
}
.lang-btn{
  background:transparent;color:var(--muted);border:none;
  min-width:30px;height:30px;padding:0 8px;border-radius:7px;
  font-size:11.5px;font-weight:700;letter-spacing:.02em;cursor:pointer;
  transition:background .12s ease,color .12s ease;
  font-family:'Space Grotesk',sans-serif;
}
.lang-btn:hover{background:var(--accent-soft);color:var(--accent);}
.lang-btn.active{background:var(--accent);color:#fff;}
[dir="rtl"] .language-switcher{margin-left:0;margin-right:8px;}
@media (max-width:640px){
  .lang-btn{min-width:26px;height:26px;padding:0 6px;font-size:10.5px;}
}

/* ========================================================================
   الهيكل الموحّد (shell.js)
   شريط علوي واحد في كل صفحات المنصة: هوية · مبدّل أوضاع · بحث · إشعارات
   · رسائل · سلة · حساب. يحلّ محل الرؤوس المكرّرة ونمط «الرجوع للوحة الرئيسية».
   ======================================================================== */
header.shell-header{position:sticky;top:0;z-index:60;gap:16px;padding:10px 22px;}
.shell-start{display:flex;align-items:center;gap:18px;min-width:0;}
.shell-brand{display:inline-flex;align-items:center;gap:9px;text-decoration:none;color:var(--text);font-weight:700;flex:none;}
.shell-brand .brand-mark{
  width:32px;height:32px;border-radius:9px;flex:none;background:var(--accent);color:#fff;
  display:flex;align-items:center;justify-content:center;font-size:17px;font-weight:700;
}
.shell-brand .brand-text{font-size:16px;color:var(--accent);}
.shell-brand:hover .brand-text{color:var(--accent-light);}

.mode-switcher{
  display:flex;align-items:center;gap:3px;
  background:var(--surface2);border:1px solid var(--border);border-radius:11px;padding:3px;
}
.mode-link{
  display:inline-flex;align-items:center;gap:6px;padding:7px 13px;border-radius:8px;
  color:var(--muted);text-decoration:none;font-size:13px;font-weight:600;white-space:nowrap;
  transition:color .12s ease,background .12s ease;
}
.mode-link:hover{color:var(--text);}
.mode-link.active{background:var(--surface);color:var(--accent);box-shadow:var(--shadow);}
.mode-link .mode-icon{display:inline-flex;}

.shell-search{flex:1;max-width:400px;min-width:0;position:relative;display:flex;align-items:center;}
.shell-search .search-icon{position:absolute;inset-inline-start:11px;display:inline-flex;opacity:.55;pointer-events:none;}
.shell-search input{width:100%;margin:0;padding-inline-start:34px;background:var(--surface2);font-size:13px;}
.shell-end{flex:none;gap:8px;}

.shell-icon-btn{
  position:relative;width:36px;height:36px;border-radius:var(--radius);
  background:var(--surface);border:1px solid var(--border);color:var(--text);
  display:inline-flex;align-items:center;justify-content:center;cursor:pointer;text-decoration:none;padding:0;
}
.shell-icon-btn:hover{border-color:var(--accent);color:var(--accent);}

.shell-login,.shell-register{text-decoration:none;font-size:12.5px;font-weight:600;padding:9px 14px;border-radius:8px;white-space:nowrap;}
.shell-login{color:var(--text);border:1px solid var(--border);background:var(--surface);}
.shell-login:hover{border-color:var(--accent);color:var(--accent);}
.shell-register{background:var(--accent);color:#fff;}
.shell-register:hover{background:var(--accent-light);color:#fff;}

.acct{position:relative;}
.acct-btn{
  width:36px;height:36px;border-radius:50%;cursor:pointer;background:var(--accent);color:#fff;border:none;
  font-family:inherit;font-size:15px;font-weight:700;display:flex;align-items:center;justify-content:center;
}
.acct-btn:hover{background:var(--accent-light);}
.acct-menu{
  display:none;position:absolute;top:calc(100% + 8px);inset-inline-end:0;min-width:236px;z-index:70;
  background:var(--surface);border:1px solid var(--border);border-radius:12px;box-shadow:var(--shadow);padding:6px;
}
.acct.open .acct-menu{display:block;}
.acct-head{padding:10px 12px 12px;border-bottom:1px solid var(--border);margin-bottom:6px;}
.acct-head strong{display:block;font-size:13.5px;margin-bottom:3px;}
.acct-head .user-badge{display:block;padding:0;border:none;background:none;font-size:11px;}
.acct-menu a,.acct-menu button{
  display:flex;align-items:center;gap:9px;width:100%;text-align:start;padding:9px 12px;border-radius:8px;
  color:var(--text);text-decoration:none;font-family:inherit;font-size:13px;background:none;border:none;cursor:pointer;
}
.acct-menu a:hover{background:var(--surface2);color:var(--accent);}
.acct-menu .btn-logout{margin-top:4px;border-top:1px solid var(--border);border-radius:0;}
.acct-menu .btn-logout:hover{color:var(--danger);background:var(--surface2);}

/* الإشعارات — كانت معرَّفة داخل education.html وحدها، نُقلت هنا لأن الجرس صار بالشريط */
.notif-wrap{position:relative;}
.notif-badge{
  position:absolute;top:1px;inset-inline-start:1px;background:var(--danger);color:#fff;border-radius:999px;
  font-size:10px;line-height:1;padding:3px 5px;min-width:16px;text-align:center;font-weight:700;
}
.notif-dropdown{
  position:absolute;top:calc(100% + 8px);inset-inline-end:0;width:320px;max-width:min(90vw,320px);
  max-height:min(420px,calc(100vh - 90px));overflow-y:auto;z-index:70;
  background:var(--surface);border:1px solid var(--border);border-radius:12px;box-shadow:var(--shadow);
}
.notif-dropdown-header{display:flex;justify-content:space-between;align-items:center;padding:10px 12px;border-bottom:1px solid var(--border);gap:8px;}
.notif-item{padding:10px 12px;border-bottom:1px solid var(--border);cursor:pointer;font-size:12.5px;}
.notif-item:last-child{border-bottom:none;}
.notif-item:hover{background:var(--surface2);}
.notif-item.unread{background:var(--accent-soft);}
.notif-item .notif-title{font-weight:700;margin-bottom:3px;}
.notif-item .notif-time{color:var(--muted);font-size:11px;margin-top:3px;}

/* ===== بوابة الخدمات داخل البروفايل ===== */
.svc-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:16px;}
.svc-card{position:relative;display:flex;flex-direction:column;background:var(--surface);border:1px solid var(--border);border-radius:14px;padding:18px;transition:border-color .15s ease, transform .12s ease, box-shadow .12s ease;}
.svc-card:hover{border-color:var(--accent);transform:translateY(-2px);box-shadow:var(--shadow);}
a.svc-card{text-decoration:none;color:inherit;}
a.svc-card:hover{cursor:pointer;}
.svc-card .svc-top{display:flex;align-items:flex-start;justify-content:space-between;gap:10px;margin-bottom:12px;}
.svc-card .svc-icon{width:38px;height:38px;border-radius:10px;background:var(--accent-soft);color:var(--accent);display:flex;align-items:center;justify-content:center;}
.svc-card h4{margin:0 0 6px;font-size:15px;}
.svc-card p{margin:0 0 14px;color:var(--muted);font-size:12.5px;line-height:1.6;}
.svc-card .svc-foot{margin-top:auto;display:flex;align-items:center;gap:8px;flex-wrap:wrap;}
.svc-note{font-size:11.5px;color:var(--muted);}
.svc-card.locked{border-style:dashed;}

/* شارة ثقة (حساب/تاجر/دفع مؤكَّد) — تظهر بجانب اسم صاحب الصفحة لكل زائر */
.verify-chip{
  display:inline-flex;align-items:center;gap:4px;
  background:rgba(34,197,94,.14);color:var(--ok);
  border-radius:999px;padding:2px 9px;font-size:11.5px;font-weight:700;white-space:nowrap;
}

/* نموذج رفع مستندات التوثيق داخل بطاقة الخدمة */
.vf-form{display:flex;flex-direction:column;gap:10px;}
.vf-form label{margin-bottom:4px;}
.vf-form input[type="file"]{font-size:12px;}

/* ===== الواجهة العامة (index.html) ===== */
.hero{
  padding:56px 28px 44px;text-align:center;border-bottom:1px solid var(--border);
  background:radial-gradient(120% 140% at 50% 0%,var(--accent-soft) 0%,transparent 62%);
}
.hero h1{margin:0 auto 14px;max-width:760px;font-size:34px;line-height:1.35;font-weight:700;}
.hero h1 .hl{color:var(--accent);}
.hero p{margin:0 auto 24px;max-width:600px;color:var(--muted);font-size:15px;line-height:1.8;}
.hero-cta{display:flex;gap:10px;justify-content:center;flex-wrap:wrap;}
.hero-cta a{text-decoration:none;font-size:14px;font-weight:600;padding:12px 24px;border-radius:10px;}
.hero-cta .primary{background:var(--accent);color:#fff;}
.hero-cta .primary:hover{background:var(--accent-light);color:#fff;}
.hero-cta .ghost{background:var(--surface);color:var(--text);border:1px solid var(--border);}
.hero-cta .ghost:hover{border-color:var(--accent);color:var(--accent);}
.stat-strip{display:flex;gap:14px;justify-content:center;flex-wrap:wrap;padding:22px 28px;border-bottom:1px solid var(--border);}
.stat-strip .s{text-align:center;min-width:120px;}
.stat-strip .s b{display:block;font-size:24px;color:var(--accent);font-family:'Space Grotesk',sans-serif;font-variant-numeric:tabular-nums;}
.stat-strip .s span{font-size:12px;color:var(--muted);}
.pillars{display:grid;grid-template-columns:repeat(auto-fit,minmax(250px,1fr));gap:16px;}
.pillar{background:var(--surface);border:1px solid var(--border);border-radius:14px;padding:20px;}
.pillar .n{font-family:'Space Grotesk',sans-serif;font-size:12px;color:var(--accent);font-weight:700;margin-bottom:8px;display:block;}
.pillar h3{margin:0 0 8px;font-size:16px;}
.pillar p{margin:0;color:var(--muted);font-size:13px;line-height:1.7;}
.section-head{display:flex;align-items:baseline;justify-content:space-between;gap:12px;flex-wrap:wrap;margin:30px 0 14px;}
.section-head h3{margin:0;font-size:17px;}
.section-head p{margin:2px 0 0;color:var(--muted);font-size:12.5px;}
.section-head a{color:var(--accent);text-decoration:none;font-size:12.5px;font-weight:600;}
.section-head a:hover{text-decoration:underline;}

@media (max-width:900px){ .shell-search{display:none;} }
@media (max-width:640px){
  header.shell-header{padding:10px 14px;gap:10px;position:static;}
  .shell-start{width:100%;justify-content:space-between;gap:10px;}
  .shell-end{width:100%;justify-content:flex-end;}
  .mode-link .mode-label{display:none;}
  .mode-link{padding:8px 11px;}
  .brand-text{display:none;}
  .hero{padding:36px 16px 30px;}
  .hero h1{font-size:24px;}
  .hero p{font-size:13.5px;}
  .stat-strip .s b{font-size:20px;}
  /* أسفل 640px يصبح `.shell-end{width:100%}` (أعلاه) فيتمدّد صفّ الأيقونات كاملَ العرض،
     ولم يعد الجرس بالضرورة على حافة الشاشة الحقيقية. تعليقه بموضعه (`inset-inline-end`
     نسبةً إلى الأيقونة) كان يُفيض القائمة خارج الشاشة أفقيًا لأن `body` بلا
     `overflow-x:hidden` — هنا تُثبَّت بحدود الشاشة نفسها بدل حدود الأيقونة. */
  .notif-dropdown{
    position:fixed;inset-inline:10px;top:64px;inset-inline-end:auto;
    width:auto;max-width:none;max-height:calc(100vh - 84px);
  }
}
