:root { --primary: #123c8c; --accent: #e63946; --dark: #0a1f44; --bg: #f3f5fa; --line: #e1e6f0; --muted: #6b7690; }
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif; background: var(--bg); color: #1b2540; }
button, input, select, textarea { font: inherit; }
[hidden] { display: none !important; }
code { background: #eef1f8; padding: 1px 6px; border-radius: 6px; direction: ltr; display: inline-block; }

.login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, var(--dark), var(--primary)); }
.login-box { background: #fff; padding: 36px; border-radius: 20px; width: min(380px, 92%); display: grid; gap: 14px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-box h1 { margin: 0; color: var(--dark); }
.login-box p { margin: 0; color: var(--muted); }
.login-box input { padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; text-align: center; }
.err { color: var(--accent); min-height: 1em; }

.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { background: var(--dark); color: #cdd6ee; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side-brand { font-size: 26px; font-weight: 800; color: #fff; padding: 22px; border-bottom: 1px solid rgba(255,255,255,.08); }
.side-brand small { display: block; font-size: 13px; color: #9fb0d8; font-weight: 600; }
.side nav { display: grid; padding: 10px; gap: 4px; }
.side nav button { text-align: start; background: none; border: 0; color: #cdd6ee; padding: 11px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; }
.side nav button:hover { background: rgba(255,255,255,.06); }
.side nav button.active { background: var(--primary); color: #fff; }
.side-foot { margin-top: auto; padding: 14px; display: grid; gap: 8px; }
.side-foot .btn { color: #fff; border-color: rgba(255,255,255,.2); text-align: center; }

.main { padding: 0 28px 60px; min-width: 0; }
.bar { display: flex; justify-content: space-between; align-items: center; padding: 18px 0; position: sticky; top: 0; background: var(--bg); z-index: 5; gap: 10px; flex-wrap: wrap; }
.bar h2 { margin: 0; color: var(--dark); }
.bar-right { display: flex; gap: 12px; align-items: center; }
.saved { color: #1a8f4c; font-size: 14px; font-weight: 600; opacity: 0; transition: .3s; }
.saved.show { opacity: 1; }

.cardx { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 22px; margin-bottom: 18px; }
.cardx h3 { margin: 0 0 14px; color: var(--dark); font-size: 18px; }
.row-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; }
.row-head h3 { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
label { display: grid; gap: 6px; font-weight: 600; font-size: 14px; color: #3a4562; margin-bottom: 10px; }
label.inline { display: flex; align-items: center; gap: 8px; }
input, select, textarea { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: #1b2540; width: 100%; font-weight: 400; }
input[type=checkbox] { width: 18px; height: 18px; }
input[type=color] { height: 46px; padding: 4px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(18,60,140,.25); border-color: var(--primary); }
.hint { color: var(--muted); font-size: 13px; font-weight: 400; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 700; color: #1b2540; text-decoration: none; }
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--accent); border-color: #f5c2c7; }
.btn.danger:hover { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 7px 12px; font-size: 14px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.btn-row.end { align-items: center; border-top: 1px solid var(--line); padding-top: 16px; margin-top: 18px; }

.list-row { display: grid; gap: 10px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; background: #fafbfe; }
.list-row label { margin: 0; }
.wa-row { grid-template-columns: 1fr 1fr auto auto auto; }
.stat-row { grid-template-columns: 160px 1fr auto; }
.feat-row { grid-template-columns: 1fr 2fr auto; }
.branch-row { grid-template-columns: 1fr 1fr 1fr auto; }
.branch-row > label:nth-child(4), .branch-row > label:nth-child(5), .branch-row > label:nth-child(6) { grid-column: span 3; }
.cat-row { grid-template-columns: 70px 1fr 1fr 150px auto; }
.slide-row { grid-template-columns: 150px 2fr 1fr auto auto; }
.slide-thumb { width: 150px; height: 100px; border-radius: 10px; border: 1px dashed var(--line); background: #f8f9fd center/cover no-repeat; cursor: pointer; display: grid; place-items: center; color: var(--primary); font-weight: 700; }
.slide-move { display: flex; flex-direction: column; gap: 4px; }
.icon-x { width: 36px; height: 36px; border-radius: 10px; border: 1px solid #f5c2c7; background: #fff; color: var(--accent); cursor: pointer; font-size: 18px; }
.icon-x:hover { background: var(--accent); color: #fff; }
.wa-test { font-size: 13px; color: #128c4a; white-space: nowrap; }

.img-field { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.img-prev { width: 140px; height: 100px; border: 1px dashed var(--line); border-radius: 12px; display: grid; place-items: center; background: #f8f9fd center/contain no-repeat; color: var(--primary); }
.img-prev.wide { width: 260px; background-size: cover; }
.img-prev svg { height: 50px; }
.cat-thumb { width: 60px; height: 50px; border-radius: 8px; border: 1px dashed var(--line); background: #f8f9fd center/contain no-repeat; cursor: pointer; }

.ptools { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.ptools input { flex: 1 1 240px; width: auto; }
.ptools select { width: auto; }
.bulk { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: #f8f9fd; padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.bulk input { width: auto; }
.pinfo { color: var(--muted); font-size: 14px; margin: 12px 0; }
.table-wrap { overflow-x: auto; }
.ptable { width: 100%; border-collapse: collapse; font-size: 14px; }
.ptable th { text-align: start; background: #f3f5fa; padding: 10px 8px; color: #3a4562; font-weight: 700; white-space: nowrap; }
.ptable td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ptable tr:hover td { background: #fafbff; }
.ptable img, .ptable .ph { width: 52px; height: 52px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; display: block; }
.ptable .ph { display: grid; place-items: center; color: #aab; font-size: 20px; }
.ptable input, .ptable select { padding: 6px 8px; border-radius: 8px; }
.ptable .c-code { width: 110px; direction: ltr; }
.ptable .c-price { width: 120px; direction: ltr; }
.ptable .c-name { min-width: 240px; }
.ptable .c-cat { width: 170px; }
.ptable tr.is-hidden td { opacity: .5; }
.pager { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 16px; }
.pager button { min-width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.pager button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.modal { position: fixed; inset: 0; background: rgba(8,18,40,.6); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-box { background: #fff; border-radius: 18px; padding: 24px; width: min(760px, 100%); max-height: 92vh; overflow: auto; }
.x { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--bg); font-size: 24px; cursor: pointer; }
.pm-imgs { display: flex; gap: 10px; flex-wrap: wrap; }
.pm-img { position: relative; width: 110px; height: 110px; border: 2px solid var(--line); border-radius: 12px; background: #fff center/contain no-repeat; }
.pm-img:first-child { border-color: var(--primary); }
.pm-img .acts { position: absolute; bottom: 4px; left: 4px; right: 4px; display: flex; gap: 4px; justify-content: center; }
.pm-img .acts button { border: 0; border-radius: 6px; padding: 2px 8px; cursor: pointer; background: rgba(10,31,68,.85); color: #fff; font-size: 12px; }
.pm-img .acts button.del { background: var(--accent); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--dark); color: #fff; padding: 12px 22px; border-radius: 12px; opacity: 0; transition: .3s; z-index: 100; pointer-events: none; font-weight: 600; }
.toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .side nav { grid-template-columns: repeat(2, 1fr); }
  .main { padding: 0 14px 40px; }
  .wa-row, .stat-row, .feat-row, .branch-row { grid-template-columns: 1fr 1fr 1fr auto; }
.branch-row > label:nth-child(4), .branch-row > label:nth-child(5), .branch-row > label:nth-child(6) { grid-column: span 3; }
.cat-row { grid-template-columns: 1fr; }
.slide-row { grid-template-columns: 120px 1fr auto; }
.slide-row > label { grid-column: span 3; }
}

.live-card { border: 2px solid #1a8f4c; background: #f3fbf6; }
.btn:disabled { opacity: .6; cursor: wait; }

/* الكتالوج PDF */
.cat-file { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #fafbfe; flex-wrap: wrap; }
.cat-file-ico { width: 54px; height: 64px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 14px; box-shadow: inset 0 -8px 0 rgba(0,0,0,.12); }
.cat-file-info { flex: 1 1 200px; display: grid; gap: 2px; min-width: 0; }
.cat-file-info b { direction: ltr; text-align: start; overflow-wrap: anywhere; }
.cat-progress { position: relative; height: 30px; border-radius: 10px; background: #eef1f8; overflow: hidden; margin-top: 14px; }
.cat-progress i { position: absolute; inset: 0 0 0 auto; width: 0; background: linear-gradient(90deg, #1a8f4c, #2bb673); transition: width .3s; }
.cat-progress span { position: relative; display: block; text-align: center; line-height: 30px; font-weight: 700; font-size: 14px; color: var(--dark); }

/* ---------- إحصائيات الزوار ---------- */
.an { --s1: #257de0; --ink: #1b2540; --ink2: #6b7690; }
.an-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.an-presets { display: flex; flex-wrap: wrap; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 2px; }
.an-presets button { border: 0; background: none; padding: 7px 12px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--ink2); font-size: 14px; }
.an-presets button:hover { background: #f1f4fa; }
.an-presets button.on { background: var(--primary); color: #fff; }
.an-custom { display: flex; gap: 6px; align-items: end; }
.an-custom label { margin: 0; font-size: 12px; gap: 2px; }
.an-custom input { padding: 6px 8px; width: 150px; }
.an-actions { display: flex; gap: 6px; margin-inline-start: auto; }
.an-msg { background: #fff8e6; border: 1px solid #f5d98b; color: #7a5a00; padding: 10px 14px; border-radius: 10px; margin: 0 0 14px; }
.an-body { transition: opacity .2s; }
.an-body.busy { opacity: .55; pointer-events: none; }
.an-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.an-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; display: grid; gap: 2px; }
.an-card small { color: var(--ink2); font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.an-card b { font-size: 32px; color: var(--ink); line-height: 1.2; font-variant-numeric: tabular-nums; }
.an-dot { width: 8px; height: 8px; border-radius: 50%; background: #1a8f4c; box-shadow: 0 0 0 0 rgba(26,143,76,.5); animation: anPulse 1.8s infinite; display: inline-block; }
@keyframes anPulse { 70% { box-shadow: 0 0 0 7px rgba(26,143,76,0); } 100% { box-shadow: 0 0 0 0 rgba(26,143,76,0); } }
.an-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--ink2); font-weight: 600; margin-bottom: 6px; }
.an-legend span { display: inline-flex; align-items: center; gap: 6px; }
.an-legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.an-chart { position: relative; direction: ltr; width: 100%; }
.an-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.an-chart .g { stroke: #eef1f6; stroke-width: 1; }
.an-chart .base { stroke: #c9d0de; stroke-width: 1; }
.an-chart .ax { fill: var(--ink2); font-size: 11px; font-family: inherit; }
.an-chart .lbl { fill: var(--ink); font-size: 12px; font-weight: 600; font-family: 'Cairo', sans-serif; }
.an-chart .cross { stroke: #9aa4b8; stroke-width: 1; stroke-dasharray: 3 3; }
.an-chart rect:focus { outline: none; }
.an-tip { position: absolute; background: #fff; border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(10,31,68,.14); border-radius: 10px; padding: 8px 12px; pointer-events: none; direction: rtl; min-width: 150px; z-index: 2; }
.an-tip .h { font-size: 12px; color: var(--ink2); margin-bottom: 4px; font-weight: 600; }
.an-tip .r { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink2); }
.an-tip .r i { width: 12px; height: 2px; border-radius: 1px; display: inline-block; }
.an-tip .r b { color: var(--ink); font-size: 14px; min-width: 34px; font-variant-numeric: tabular-nums; }
.an-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0 18px; }
.an-bars { display: grid; gap: 4px; }
.an-bar { display: grid; grid-template-columns: minmax(80px, 1.3fr) 2fr 44px 38px; gap: 8px; align-items: center; padding: 5px 6px; border-radius: 8px; font-size: 14px; }
.an-bar:hover, .an-bar:focus { background: #f3f6fc; outline: none; }
.an-bar .k { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.an-bar .t { height: 10px; background: #eef1f6; border-radius: 4px; overflow: hidden; display: block; }
.an-bar .t i { display: block; height: 100%; background: var(--s1); border-radius: 4px; }
.an-bar b { text-align: end; color: var(--ink); font-variant-numeric: tabular-nums; }
.an-bar small { color: var(--ink2); text-align: end; }
.an-table td, .an-table th { white-space: nowrap; }
.an-new { background: #e7f5ee; color: #1a7a43; padding: 1px 6px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.an-privacy { background: #f8f9fd; }
@media (max-width: 900px) {
  .an-cards { grid-template-columns: repeat(2, 1fr); }
  .an-card b { font-size: 26px; }
  .an-actions { margin-inline-start: 0; }
  .an-custom input { width: 130px; }
}
.an .btn { white-space: nowrap; }
.forgot { font-size: 14px; color: var(--primary); text-decoration: none; font-weight: 600; }
.forgot:hover { text-decoration: underline; }
.login-box .hint { line-height: 1.6; }
.side nav { overflow-y: auto; min-height: 0; flex: 1 1 auto; align-content: start; }
