:root {
  --brown: #7a4a1e;
  --brown-dark: #5c3714;
  --gold: #e07e12;
  --gold-light: #f5a623;
  --green: #37a495;
  --cream: #faf6ef;
  --bg: #fffdfa;
  --text: #2c2117;
  --muted: #8a7d6f;
  --border: #ece3d6;
  --radius: 14px;
  --shadow: 0 6px 20px rgba(122,74,30,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Tajawal', sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.section { padding: 40px 16px; }
h1,h2,h3,h4 { line-height: 1.4; }

.btn { display: inline-block; border: none; cursor: pointer; font-family: inherit;
  font-weight: 700; padding: 10px 22px; border-radius: 999px; font-size: 15px; transition: .2s; }
.btn-primary { background: var(--gold); color: #fff; }
.btn-primary:hover { background: var(--gold-light); }
.btn-light { background: #fff; color: var(--brown); }
.btn-lg { padding: 13px 30px; font-size: 16px; }
.btn-block { width: 100%; }

.topbar { background: var(--brown-dark); color: #fff; font-size: 13px; }
.topbar-inner { display: flex; justify-content: space-between; padding: 8px 16px; flex-wrap: wrap; gap: 8px; }

.site-header { background: #fff; box-shadow: var(--shadow); position: sticky; top: 0; z-index: 50; }
.header-inner { display: flex; align-items: center; gap: 20px; padding: 14px 16px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; color: var(--brown); }
.logo img { height: 46px; width: auto; }
.search-box { flex: 1; display: flex; min-width: 200px; }
.search-box input { flex: 1; border: 1px solid var(--border); border-radius: 999px 0 0 999px;
  padding: 10px 16px; font-family: inherit; outline: none; }
.search-box button { background: var(--gold); color: #fff; border: none; padding: 0 20px;
  border-radius: 0 999px 999px 0; cursor: pointer; font-family: inherit; font-weight: 700; }
.main-nav { display: flex; align-items: center; gap: 18px; font-weight: 500; }
.main-nav a:hover { color: var(--gold); }
.cart-link { position: relative; font-weight: 700; }
.cart-badge { background: var(--gold); color: #fff; border-radius: 999px; font-size: 12px;
  padding: 1px 7px; margin-inline-start: 2px; }

.hero { background: linear-gradient(135deg, var(--cream), #fff); }
.hero-inner { display: flex; align-items: center; gap: 30px; padding: 50px 16px; flex-wrap: wrap; }
.hero-text { flex: 1; min-width: 280px; }
.hero-text h1 { font-size: 40px; color: var(--brown); margin-bottom: 14px; }
.hero-text p { font-size: 18px; color: var(--muted); margin-bottom: 24px; }
.hero-image { flex: 1; min-width: 240px; text-align: center; }
.hero-image img { max-height: 240px; margin: 0 auto; }

.features { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; padding: 30px 16px; }
.feature { background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; text-align: center; }
.feature span { font-size: 32px; }
.feature h4 { margin: 10px 0 4px; color: var(--brown); }
.feature p { color: var(--muted); font-size: 14px; }

.section-title { font-size: 26px; color: var(--brown); margin-bottom: 22px; text-align: center; position: relative; }
.section-title::after { content: ''; display: block; width: 60px; height: 3px; background: var(--gold);
  margin: 8px auto 0; border-radius: 3px; }

.cat-grid { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.cat-chip { background: var(--cream); border: 1px solid var(--border); padding: 10px 20px;
  border-radius: 999px; font-weight: 700; color: var(--brown); transition: .2s; }
.cat-chip:hover { background: var(--gold); color: #fff; }

.product-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 20px; }
.product-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; transition: .2s; display: flex; flex-direction: column; }
.product-card:hover { box-shadow: var(--shadow); transform: translateY(-3px); }
.pc-image { position: relative; aspect-ratio: 1/1; overflow: hidden; }
.pc-image img { width: 100%; height: 100%; object-fit: cover; }
.badge-sale { position: absolute; top: 10px; inset-inline-start: 10px; background: #e02424;
  color: #fff; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; z-index: 2; }
.pc-body { padding: 14px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.pc-body h3 { font-size: 16px; }
.pc-price { display: flex; gap: 8px; align-items: baseline; }
.pc-price .old, .pd-price .old { color: var(--muted); text-decoration: line-through; font-size: 14px; }
.pc-price .now, .pd-price .now { color: var(--gold); font-weight: 800; font-size: 18px; }
.pc-body form { margin-top: auto; }

.cta-banner { background: linear-gradient(135deg, var(--brown), var(--brown-dark)); color: #fff;
  text-align: center; padding: 50px 16px; margin-top: 20px; }
.cta-banner h2 { font-size: 28px; margin-bottom: 20px; }

.page-title { font-size: 28px; color: var(--brown); margin-bottom: 24px; }
.page-narrow { max-width: 800px; }
.page-narrow p { margin-bottom: 14px; }
.check-list, .cat-list { list-style: none; }
.check-list li { padding-inline-start: 26px; position: relative; margin-bottom: 8px; }
.check-list li::before { content: '✓'; position: absolute; inset-inline-start: 0; color: var(--green); font-weight: 800; }

.shop-layout { display: grid; grid-template-columns: 240px 1fr; gap: 26px; align-items: start; }
.shop-sidebar { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.shop-sidebar h4 { margin-bottom: 12px; color: var(--brown); }
.cat-list li a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--muted); }
.cat-list li a.active, .cat-list li a:hover { background: var(--cream); color: var(--brown); font-weight: 700; }
.shop-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; gap: 10px; }
.shop-toolbar select, .checkout-form input, .checkout-form textarea, .contact-form input,
.contact-form textarea, .qty-input, .inline-form select { font-family: inherit; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 8px; outline: none; }

.breadcrumb { color: var(--muted); margin-bottom: 20px; font-size: 14px; }
.product-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
.pd-image { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.pd-image img { width: 100%; aspect-ratio: 1/1; object-fit: cover; }
.pd-info h1 { color: var(--brown); margin-bottom: 8px; }
.pd-cat { color: var(--muted); margin-bottom: 12px; }
.pd-price { margin-bottom: 16px; display: flex; gap: 10px; align-items: baseline; }
.pd-desc { margin-bottom: 20px; }
.pd-form { display: flex; flex-direction: column; gap: 8px; max-width: 340px; }
.pd-form label { font-weight: 700; }
.pd-form select, .pd-form input { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; }
.pd-note { margin-top: 14px; color: var(--green); font-weight: 700; }

.cart-table, .admin-table { width: 100%; border-collapse: collapse; background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cart-table th, .cart-table td, .admin-table th, .admin-table td { padding: 12px; text-align: start;
  border-bottom: 1px solid var(--border); }
.cart-table th, .admin-table th { background: var(--cream); color: var(--brown); }
.ci-product { display: flex; align-items: center; gap: 10px; }
.ci-product img { width: 50px; height: 50px; object-fit: cover; border-radius: 8px; }
.qty-input { width: 70px; }
.inline-form { display: inline; }
.btn-remove { background: none; border: none; color: #e02424; cursor: pointer; font-family: inherit; }
.cart-summary { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; flex-wrap: wrap; gap: 14px; }
.cart-total { font-size: 20px; }

.checkout-layout { display: grid; grid-template-columns: 1.4fr 1fr; gap: 26px; align-items: start; }
.checkout-form { display: flex; flex-direction: column; gap: 8px; background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.checkout-form label { font-weight: 700; margin-top: 6px; }
.order-summary { background: var(--cream); border-radius: var(--radius); padding: 22px; }
.os-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.os-total { display: flex; justify-content: space-between; margin-top: 12px; font-size: 18px; }
.os-note { margin-top: 12px; color: var(--muted); font-size: 14px; }

.success-box, .empty-state { text-align: center; padding: 50px 16px; }
.success-icon { font-size: 54px; }
.success-box h1 { color: var(--brown); margin: 10px 0; }
.success-total { margin: 16px 0; font-size: 18px; }
.empty-state h1 { font-size: 48px; color: var(--gold); }
.empty { text-align: center; color: var(--muted); padding: 30px; }

.contact-info { background: var(--cream); border-radius: var(--radius); padding: 18px; margin-bottom: 20px; }
.contact-form { display: flex; flex-direction: column; gap: 8px; }
.contact-form label { font-weight: 700; }
.alert-success { background: #e6f7f4; color: var(--green); padding: 14px; border-radius: 10px; margin-bottom: 18px; }

.site-footer { background: var(--brown-dark); color: #f5ece0; margin-top: 40px; }
.footer-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 24px; padding: 40px 16px; }
.footer-grid h4 { margin-bottom: 12px; color: #fff; }
.footer-grid a { display: block; color: #d8c7b3; padding: 3px 0; }
.footer-grid a:hover { color: var(--gold-light); }
.footer-grid p { color: #cbb8a2; font-size: 14px; margin-bottom: 4px; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.1); padding: 14px 0; text-align: center; font-size: 13px; }

.admin-body { background: var(--cream); }
.admin-wrap { padding: 30px 16px; }
.admin-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; margin-bottom: 30px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; text-align: center; }
.stat-card span { display: block; color: var(--muted); }
.stat-card strong { font-size: 28px; color: var(--brown); }
.admin-table { margin-bottom: 20px; }

/* المصادقة والحساب والتتبّع */
.auth-box { max-width: 460px; margin: 0 auto; background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.auth-form, .track-form { display: flex; flex-direction: column; gap: 8px; }
.auth-form label, .track-form label { font-weight: 700; margin-top: 6px; }
.auth-form input, .track-form input { padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-family: inherit; outline: none; }
.auth-form input:focus, .track-form input:focus { border-color: var(--gold); }
.auth-alt { text-align: center; margin-top: 12px; color: var(--muted); }
.auth-alt a, .link { color: var(--gold); font-weight: 700; }
.alert-error { background: #fdecea; color: #c0392b; padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; }
.btn-outline { background: #fff; color: var(--brown); border: 1px solid var(--gold); }
.btn-outline:hover { background: var(--cream); }
.nav-logout { background: none; border: none; cursor: pointer; font-family: inherit; color: var(--muted); font-weight: 500; }
.nav-logout:hover { color: var(--gold); }

.account-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.status-badge { background: var(--cream); color: var(--brown); padding: 3px 12px; border-radius: 999px; font-size: 14px; }
.muted-text { color: var(--muted); font-size: 14px; display: block; }
.order-num { color: var(--gold); font-size: 20px; letter-spacing: .5px; }
.success-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.checkout-login-hint { background: var(--cream); padding: 10px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 8px; }

.track-form { max-width: 460px; margin-bottom: 26px; }
.track-result { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.tr-head { display: flex; gap: 30px; flex-wrap: wrap; margin-bottom: 22px; }
.tr-head strong { font-size: 18px; }
.tr-total { text-align: end; margin-top: 14px; font-size: 18px; }
.info-card { background: var(--cream); border-radius: var(--radius); padding: 16px; }

.timeline { display: flex; justify-content: space-between; margin: 20px 0 26px; position: relative; }
.timeline::before { content: ''; position: absolute; top: 16px; inset-inline: 6%; height: 3px; background: var(--border); z-index: 0; }
.tl-step { display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; z-index: 1; flex: 1; }
.tl-dot { width: 34px; height: 34px; border-radius: 50%; background: #fff; border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); }
.tl-step.done .tl-dot { background: var(--green); border-color: var(--green); color: #fff; }
.tl-step.current .tl-dot { background: var(--gold); border-color: var(--gold); color: #fff; box-shadow: 0 0 0 4px rgba(224,126,18,.2); }
.tl-label { font-size: 13px; color: var(--muted); }
.tl-step.done .tl-label, .tl-step.current .tl-label { color: var(--brown); font-weight: 700; }
.status-cancelled { background: #fdecea; color: #c0392b; padding: 14px; border-radius: 10px; text-align: center; font-weight: 700; margin: 18px 0; }

@media (max-width: 900px) {
  .product-grid, .features, .footer-grid { grid-template-columns: repeat(2,1fr); }
  .shop-layout, .product-detail, .checkout-layout { grid-template-columns: 1fr; }
  .admin-stats { grid-template-columns: 1fr; }
  .hero-text h1 { font-size: 30px; }
}
@media (max-width: 520px) {
  .product-grid { grid-template-columns: 1fr 1fr; }
  .main-nav { gap: 12px; font-size: 14px; }
  .cart-table { display: block; overflow-x: auto; }
}

/* ===================== الوضع المظلم Dark Mode ===================== */
html[data-theme="dark"] {
  --brown: #c3af96;
  --brown-dark: #1c140c;
  --gold: #e79b3a;
  --gold-light: #f5b95a;
  --green: #3fc0ad;
  --cream: #1c140d;
  --bg: #14100b;
  --text: #ede4d6;
  --muted: #a89a86;
  --border: #3a2e20;
  --shadow: 0 6px 20px rgba(0,0,0,0.45);
}
html[data-theme="dark"] body { background: var(--bg); color: var(--text); }
html[data-theme="dark"] .site-header,
html[data-theme="dark"] .product-card,
html[data-theme="dark"] .feature,
html[data-theme="dark"] .track-result,
html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .admin-card,
html[data-theme="dark"] .cart-box,
html[data-theme="dark"] .auth-card,
html[data-theme="dark"] .btn-light { background: #1e160d; color: var(--text); }
html[data-theme="dark"] .hero { background: linear-gradient(135deg, #1e160d, #14100b); }
html[data-theme="dark"] .tl-dot { background: #1e160d; }
html[data-theme="dark"] .search-box input,
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea { background: #1e160d; color: var(--text); border-color: var(--border); }
html[data-theme="dark"] .admin-table { background: #342f2aa6; }
html[data-theme="dark"] .admin-table th { background: #47413b }
html[data-theme="dark"] .admin-table td { border-color: var(--border); }
html[data-theme="dark"] .status-cancelled { background: #3a1f1c; color: #ff8c7a; }
html[data-theme="dark"] .alert-success { background: #17352f; color: #7ee0cf; }

/* زر تبديل الوضع */
.theme-toggle { background: transparent; border: 1px solid var(--border); color: inherit;
  cursor: pointer; font-family: inherit; font-size: 18px; line-height: 1; width: 38px; height: 38px;
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; transition: .2s; }
.theme-toggle:hover { border-color: var(--gold); color: var(--gold); }

/* ===================== لوحة الإدارة الموسّعة ===================== */
.admin-topbar { background: var(--brown-dark); color: #fff; }
.admin-topbar-inner { display: flex; align-items: center; gap: 18px; padding: 12px 16px; flex-wrap: wrap; }
.admin-topbar-inner .admin-brand { font-weight: 800; font-size: 18px; color: #fff; margin-inline-end: auto; }
.admin-topbar-inner a { color: #fff; font-weight: 500; opacity: .9; }
.admin-topbar-inner a:hover, .admin-topbar-inner a.active { opacity: 1; color: var(--gold-light); }
.admin-nav-links { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }

.admin-actions { display: flex; flex-wrap: wrap; gap: 14px; margin: 24px 0; }
.admin-action-card { flex: 1; min-width: 200px; background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; text-align: center; box-shadow: var(--shadow); transition: .2s; }
html[data-theme="dark"] .admin-action-card { background: #1e160d; }
.admin-action-card:hover { transform: translateY(-3px); border-color: var(--gold); }
.admin-action-card .icon { font-size: 34px; }
.admin-action-card h3 { margin: 10px 0 4px; color: var(--brown); }
.admin-action-card p { color: var(--muted); font-size: 14px; }

.admin-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow); margin-bottom: 24px; }
.admin-form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.admin-form-grid .full { grid-column: 1 / -1; }
.admin-form label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.admin-form input, .admin-form select, .admin-form textarea { width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 8px; font-family: inherit; font-size: 14px; background: #fff; color: var(--text); }
.admin-table-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-danger { background: #c0392b; color: #fff; }
.btn-danger:hover { background: #a93226; }
.btn-warn { background: #e0a012; color: #fff; }
.btn-warn:hover { background: #c88f10; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-admin { background: var(--gold); color: #fff; }
.badge-user { background: var(--cream); color: var(--brown); border: 1px solid var(--border); }
.badge-staff { background: #2f6fb0; color: #fff; }
.badge-on { background: #1e9e6a; color: #fff; }
.badge-off { background: #c0392b; color: #fff; }
.page-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.form-hint { color: var(--muted); font-size: 13px; margin-top: 4px; }
.maintenance-wrap { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 40px 20px; gap: 14px; }
.maintenance-wrap .m-icon { font-size: 64px; }
.maintenance-wrap h1 { color: var(--brown); font-size: 30px; }
.maintenance-wrap .m-reason { background: var(--cream); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 22px; max-width: 520px; }
@media (max-width: 700px) { .admin-form-grid { grid-template-columns: 1fr; } }

/* ====== صفحة مهام التسويق ====== */
.marketing-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:18px;margin-top:16px}
.marketing-card{padding:0;overflow:hidden;display:flex;flex-direction:column}
.marketing-media{height:180px;background:#f3f3f3;display:flex;align-items:center;justify-content:center;overflow:hidden}
.marketing-media img{width:100%;height:100%;object-fit:cover}
.marketing-body{padding:16px;display:flex;flex-direction:column;gap:10px}
.marketing-name{margin:0;font-size:1.1rem}
.marketing-badges{display:flex;flex-wrap:wrap;gap:6px}
.marketing-desc{margin:0;color:#666;font-size:.9rem;line-height:1.6}
.marketing-props{list-style:none;padding:0;margin:0;display:flex;flex-direction:column;gap:6px;font-size:.88rem}
.marketing-props li{display:flex;justify-content:space-between;gap:10px;border-bottom:1px dashed #eee;padding-bottom:5px}
.marketing-props li span{color:#888}
.marketing-actions{display:flex;gap:8px;margin-top:6px}
.marketing-actions form{margin:0}

/* ====== اختيار/رفع صورة المنتج ====== */
.image-picker{display:flex;gap:18px;flex-wrap:wrap;align-items:flex-start}
.image-picker-current{flex:0 0 140px;text-align:center}
.image-picker-current img{width:140px;height:140px;object-fit:cover;border-radius:12px;border:1px solid var(--border);display:block;margin-bottom:6px}
.image-picker-fields{flex:1;min-width:240px}
.image-picker-fields input[type="file"]{display:block;width:100%}
