:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --ink: #1f2430;
  --muted: #6b7280;
  --line: #e8e3da;
  --brand: #0f766e;
  --brand-dark: #0b5a54;
  --accent: #f59e0b;
  --danger: #b91c1c;
  --ok: #15803d;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 36, 48, .06), 0 8px 24px rgba(31, 36, 48, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --surface: #1d2128;
    --ink: #eceef2;
    --muted: #9aa3b2;
    --line: #2c323c;
    --brand: #2dd4bf;
    --brand-dark: #14b8a6;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

/* الرأس */
header.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top-row { display: flex; align-items: center; gap: 12px; height: 64px; }
.logo { font-size: 1.35rem; font-weight: 800; color: var(--ink); text-decoration: none; letter-spacing: -.3px; }
.logo span { color: var(--brand); }
.search { flex: 1; max-width: 420px; margin-inline-start: auto; }
.search input {
  width: 100%; padding: 9px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); outline: none;
}
.search input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
.cart-btn {
  position: relative; border: 0; background: var(--brand); color: #fff;
  padding: 9px 16px; border-radius: 999px; cursor: pointer; font-weight: 700;
  display: inline-flex; gap: 8px; align-items: center;
}
.cart-btn:hover { background: var(--brand-dark); }
.cart-count {
  background: var(--accent); color: #1f2430; border-radius: 999px;
  min-width: 22px; height: 22px; display: grid; place-items: center; font-size: .78rem; padding: 0 6px;
}

/* البطل */
.hero { padding: 44px 0 18px; }
.hero h1 { margin: 0 0 8px; font-size: clamp(1.7rem, 4vw, 2.6rem); line-height: 1.25; }
.hero p { margin: 0; color: var(--muted); font-size: 1.05rem; }

/* التصنيفات */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 20px 0 8px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); padding: 7px 16px;
  border-radius: 999px; cursor: pointer; transition: .15s;
}
.chip:hover { border-color: var(--brand); }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* المنتجات */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; padding: 14px 0 60px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow);
  transition: transform .18s ease;
}
.card:hover { transform: translateY(-3px); }
.card .pic { aspect-ratio: 1; background: color-mix(in srgb, var(--line) 50%, var(--bg)); position: relative; cursor: pointer; }
.card .pic img { width: 100%; height: 100%; object-fit: cover; }
.badge {
  position: absolute; top: 10px; inset-inline-start: 10px;
  background: var(--danger); color: #fff; font-size: .75rem; font-weight: 700;
  padding: 3px 10px; border-radius: 999px;
}
.card .body { padding: 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card h3 { margin: 0; font-size: 1.02rem; }
.card .cat { color: var(--muted); font-size: .82rem; }
.price { font-weight: 800; font-size: 1.1rem; }
.card .row { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 6px; }
.btn {
  border: 0; border-radius: 10px; padding: 9px 14px; cursor: pointer; font-weight: 700;
  background: var(--brand); color: #fff; transition: .15s;
}
.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--brand); background: transparent; }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: .85rem; border-radius: 8px; }
.empty { text-align: center; color: var(--muted); padding: 60px 0; grid-column: 1 / -1; }

/* الدرج والنوافذ */
.overlay { position: fixed; inset: 0; background: rgba(10, 12, 16, .5); z-index: 40; display: none; }
.overlay.open { display: block; }
.drawer {
  position: fixed; top: 0; bottom: 0; inset-inline-start: 0; width: min(440px, 100%);
  background: var(--surface); z-index: 50; display: none; flex-direction: column;
  box-shadow: var(--shadow);
}
.drawer.open { display: flex; }
.drawer header { padding: 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.drawer header h2 { margin: 0; font-size: 1.15rem; }
.icon-btn { border: 0; background: transparent; font-size: 1.5rem; cursor: pointer; line-height: 1; padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { background: var(--bg); }
.drawer .content { flex: 1; overflow: auto; padding: 16px; }
.drawer footer { padding: 16px; border-top: 1px solid var(--line); }

.line { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: center; }
.line img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; background: var(--bg); }
.line .nm { font-weight: 700; font-size: .95rem; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; margin-top: 4px; }
.qty button { border: 0; background: transparent; width: 28px; height: 28px; cursor: pointer; font-size: 1.05rem; }
.qty span { min-width: 26px; text-align: center; font-weight: 700; }
.sum { display: flex; justify-content: space-between; padding: 3px 0; color: var(--muted); }
.sum.total { color: var(--ink); font-weight: 800; font-size: 1.1rem; padding-top: 8px; }

.modal {
  position: fixed; z-index: 50; inset: 0; display: none; place-items: center; padding: 16px;
}
.modal.open { display: grid; }
.modal .box {
  background: var(--surface); border-radius: var(--radius); width: min(720px, 100%);
  max-height: 92vh; overflow: auto; box-shadow: var(--shadow);
}
.modal .box.narrow { width: min(520px, 100%); }
.pd { display: grid; grid-template-columns: 1fr 1fr; }
.pd img { width: 100%; height: 100%; object-fit: cover; min-height: 260px; background: var(--bg); }
.pd .info { padding: 22px; display: flex; flex-direction: column; gap: 10px; }
.pd h2 { margin: 0; }
@media (max-width: 640px) { .pd { grid-template-columns: 1fr; } }

/* النماذج */
.form { display: grid; gap: 12px; padding: 20px; }
.form h2 { margin: 0 0 4px; }
label.f { display: grid; gap: 4px; font-size: .9rem; color: var(--muted); }
.f input, .f select, .f textarea {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); outline: none; color: var(--ink);
}
.f input:focus, .f select:focus, .f textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .two { grid-template-columns: 1fr; } }
.note { font-size: .88rem; color: var(--muted); background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.err { color: var(--danger); font-size: .9rem; min-height: 1.2em; }
.ok-box { text-align: center; padding: 34px 22px; }
.ok-box .tick { font-size: 3rem; color: var(--ok); }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(30px);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  opacity: 0; transition: .25s; z-index: 80; pointer-events: none; font-size: .92rem;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

footer.site { border-top: 1px solid var(--line); padding: 26px 0; color: var(--muted); text-align: center; font-size: .9rem; }
.wa {
  position: fixed; bottom: 20px; inset-inline-end: 20px; background: #25d366; color: #fff;
  width: 54px; height: 54px; border-radius: 50%; display: none; place-items: center;
  box-shadow: var(--shadow); text-decoration: none; font-weight: 800; z-index: 30;
}
.wa.on { display: grid; }

/* لوحة التحكم */
.admin-shell { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
.admin-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.admin-bar h1 { margin: 0; font-size: 1.4rem; margin-inline-end: auto; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tab { border: 0; background: transparent; padding: 10px 16px; cursor: pointer; font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.tab.on { color: var(--brand); border-color: var(--brand); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat b { display: block; font-size: 1.7rem; }
.stat span { color: var(--muted); font-size: .9rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: top; font-size: .93rem; }
th { background: var(--bg); color: var(--muted); font-weight: 700; font-size: .82rem; }
tr:last-child td { border-bottom: 0; }
.thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--bg); }
.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--bg); border: 1px solid var(--line); }
.tag.new { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.tag.confirmed { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.tag.shipped { background: #ede9fe; color: #5b21b6; border-color: #ddd6fe; }
.tag.delivered { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.tag.cancelled { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.scroll-x { overflow-x: auto; }
.login-box { max-width: 380px; margin: 14vh auto; }
.login-box .panel { padding: 22px; }
.items-list { margin: 4px 0 0; padding-inline-start: 18px; color: var(--muted); font-size: .85rem; }
