:root {
  --bg:        #EEF1F4;
  --surface:   #FFFFFF;
  --ink:       #17222E;
  --muted:     #667485;
  --line:      #DDE3EA;
  --accent:    #0B7A83;
  --accent-d:  #096169;
  --accent-soft:#E1F1F1;
  --danger:    #C2453D;
  --danger-soft:#FBE9E7;
  --radius:    12px;
  --shadow:    0 1px 2px rgba(23,34,46,.06), 0 6px 18px rgba(23,34,46,.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans Arabic", system-ui, "Segoe UI", Tahoma, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

button { font-family: inherit; }

/* ---------------- الشريط العلوي ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .mark {
  width: 22px; height: 22px; border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), var(--accent-d));
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.35);
}
.brand .title { font-weight: 700; font-size: 17px; letter-spacing: -.2px; }

.search { flex: 1; max-width: 420px; }
.search input {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 10px;
  background: #F7F9FB; color: var(--ink); font-size: 14px;
}
.search input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.top-actions { margin-inline-start: auto; }

/* ---------------- الأزرار ---------------- */
.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 9px 16px; border-radius: 9px; font-size: 14px; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: #F3F6F8; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-d); border-color: var(--accent-d); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: #F3F6F8; }
.btn.danger { color: var(--danger); border-color: transparent; }
.btn.danger:hover { background: var(--danger-soft); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------------- شريط التحديد ---------------- */
.selbar {
  position: sticky; top: 57px; z-index: 15;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 22px;
  background: var(--accent-soft);
  border-bottom: 1px solid #CFE6E7;
}
.selbar .spacer { flex: 1; }
.sel-count { font-weight: 600; color: var(--accent-d); }

/* ---------------- الحاوية ---------------- */
.wrap { max-width: 1200px; margin: 0 auto; padding: 22px; }

/* ---------------- منطقة الرفع ---------------- */
.dropzone {
  border: 1.5px dashed #B9C6D2; border-radius: var(--radius);
  background: var(--surface);
  padding: 26px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover { border-color: var(--accent); background: #FAFCFD; }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dz-title { font-weight: 600; }
.dz-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

.uploading {
  margin-top: 14px; display: flex; flex-direction: column; gap: 8px;
}
.up-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 14px; font-size: 13px;
}
.up-row .nm { flex: 1; color: var(--muted); word-break: break-all; }
.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- شريط الشبكة ---------------- */
.gridbar {
  display: flex; align-items: center; gap: 14px;
  margin: 22px 2px 12px;
}
.check-all { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check-all input { width: 16px; height: 16px; accent-color: var(--accent); }
.stats { margin-inline-start: auto; color: var(--muted); font-size: 13px; }

/* ---------------- الشبكة والبطاقات ---------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 16px;
}
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  transition: box-shadow .15s, border-color .15s;
}
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow); }

.thumb {
  position: relative; height: 168px; background: #F5F6F8;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.pick {
  position: absolute; top: 8px; inset-inline-start: 8px;
  width: 26px; height: 26px; border-radius: 7px;
  background: rgba(255,255,255,.92); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.pick input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

.meta { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.name {
  font-weight: 600; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: text;
}
.sub { color: var(--muted); font-size: 12px; direction: ltr; text-align: right; }

.links { display: flex; gap: 6px; }
.links .btn { flex: 1; padding: 7px 8px; font-size: 12.5px; }
.links .btn.copy { background: var(--accent-soft); border-color: transparent; color: var(--accent-d); }
.links .btn.copy:hover { background: #D2ECED; }

.row2 { display: flex; gap: 6px; }
.row2 .btn { flex: 1; padding: 6px 8px; font-size: 12.5px; color: var(--muted); }
.row2 .btn.del:hover { color: var(--danger); background: var(--danger-soft); }

/* ---------------- حالة فارغة ---------------- */
.empty { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty-title { font-weight: 600; font-size: 16px; color: var(--ink); }
.empty-sub { margin-top: 6px; font-size: 14px; }
.empty code { background: #E4E9EE; padding: 1px 6px; border-radius: 5px; direction: ltr; display: inline-block; }

/* ---------------- التنبيه ---------------- */
.toast {
  position: fixed; inset-block-end: 22px; inset-inline-start: 50%;
  transform: translateX(50%);
  background: var(--ink); color: #fff;
  padding: 11px 20px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 50;
}
.toast.err { background: var(--danger); }

/* ---------------- صفحة الدخول ---------------- */
.auth-body {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 500px at 80% -10%, #E1F1F1 0%, transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 30px 28px;
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-brand .mark {
  width: 24px; height: 24px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-d));
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.35);
}
.auth-brand .title { font-weight: 700; font-size: 17px; }
.auth-h1 { font-size: 20px; margin: 0 0 6px; font-weight: 700; }
.auth-sub { color: var(--muted); font-size: 14px; margin: 0 0 20px; }
.auth-form { display: flex; flex-direction: column; }
.auth-label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.auth-input {
  padding: 11px 14px; margin-bottom: 16px;
  border: 1px solid var(--line); border-radius: 10px;
  background: #F7F9FB; color: var(--ink); font: inherit;
}
.auth-input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.auth-submit { margin-top: 4px; padding: 12px; font-size: 15px; }
.auth-error {
  background: var(--danger-soft); color: var(--danger);
  border-radius: 10px; padding: 10px 14px; font-size: 13.5px; margin-bottom: 16px;
}
.auth-note {
  margin: 18px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.7;
}
.auth-note code {
  background: #E4E9EE; padding: 1px 6px; border-radius: 5px; direction: ltr; display: inline-block;
}

@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; }
  .search { order: 3; max-width: none; flex-basis: 100%; }
  .selbar { top: 106px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
.builder-toolbar{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin:18px 0}.builder-toolbar .spacer{flex:1}.hint{padding:12px 14px;background:#fff8e6;border:1px solid #f1e2b8;border-radius:10px;margin-bottom:14px}.products{display:grid;gap:12px}.product-row{display:flex;gap:14px;align-items:flex-start;background:var(--surface,#fff);border:1px solid var(--line,#ddd);border-radius:12px;padding:12px}.product-row>img,.noimg{width:110px;height:110px;object-fit:contain;background:#f5f6f8;border-radius:9px}.noimg{display:grid;place-items:center;color:#777}.pf{flex:1;display:grid;grid-template-columns:repeat(5,minmax(120px,1fr));gap:9px}.pf label{font-size:12px;color:#666}.pf input,.pf select,.pf textarea{box-sizing:border-box;width:100%;padding:8px;border:1px solid #d7dbe0;border-radius:7px;background:#fff}.pf textarea{min-height:65px;resize:vertical}.pf .wide{grid-column:span 5}.modal-back{position:fixed;inset:0;background:#0008;z-index:50;padding:30px}.modal{max-width:1000px;max-height:90vh;margin:auto;background:#fff;border-radius:14px;display:flex;flex-direction:column;overflow:hidden}.modal-head,.modal-foot{display:flex;gap:10px;align-items:center;padding:14px;border-bottom:1px solid #ddd}.modal-foot{border-top:1px solid #ddd;border-bottom:0}.modal-body{overflow:auto;padding:14px}.pick-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:10px}.pick-item{border:1px solid #ddd;border-radius:10px;padding:7px;display:grid;gap:6px}.pick-item img{width:100%;aspect-ratio:1;object-fit:contain;background:#f5f6f8}.pick-item span{font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}@media(max-width:800px){.pf{grid-template-columns:1fr 1fr}.pf .wide{grid-column:span 2}.product-row{flex-wrap:wrap}.modal-back{padding:8px}}
.image-links-box{border:1px solid var(--line,#ddd);border-radius:12px;padding:10px;margin-top:4px}.image-links-head{display:flex;align-items:center;gap:10px;justify-content:space-between;margin-bottom:8px}.image-links-box textarea{min-height:95px;font-family:monospace;direction:ltr;text-align:left}.product-thumbs{display:flex;gap:6px;flex-wrap:wrap;margin-top:8px}.product-thumbs img{width:54px;height:54px;object-fit:cover;border-radius:8px;border:1px solid var(--line,#ddd)}.product-main-img{width:120px;height:120px;object-fit:cover;border-radius:12px}.image-links-box small{display:block;margin-top:6px;opacity:.7}
