/* ===== لوحة التحكم ===== */
:root {
  --navy: #0e2236; --navy-2: #16304a; --accent: #f2a900;
  --ink: #1a2533; --muted: #5a6677; --line: #e1e6ed; --bg: #f3f5f8;
  --ok: #157347; --ok-bg: #e7f5ed; --warn: #8a5a00; --warn-bg: #fff4d6;
  --err: #b42318; --err-bg: #fdecea; --info: #1d4f91; --info-bg: #e8f0fb;
  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.6; color: var(--ink); background: var(--bg); }
a { color: #1d4f91; }
a:hover { color: var(--navy); }
h1, h2, h3 { margin: 0 0 .6em; line-height: 1.35; color: var(--navy); }
h2 { font-size: 1.15rem; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.ltr-cell { text-align: right; unicode-bidi: plaintext; }
code { background: #eef1f5; padding: 1px 6px; border-radius: 4px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 260px; flex: none; background: var(--navy); color: #c9d3de; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 22px 20px; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.side-brand svg { color: var(--accent); }
.sidebar nav { padding: 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a, .side-foot a, .side-foot button { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 14px; border-radius: 10px; color: #c9d3de; text-decoration: none; font: 500 .95rem var(--font); background: none; border: 0; width: 100%; cursor: pointer; text-align: start; }
.sidebar nav a:hover, .side-foot a:hover, .side-foot button:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar nav a.active { background: rgba(242,169,0,.16); color: var(--accent); }
.count { margin-inline-start: auto; background: var(--accent); color: var(--navy); font-size: .75rem; min-width: 22px; height: 22px; border-radius: 11px; display: grid; place-items: center; padding: 0 6px; }
.side-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.side-foot form { margin: 0; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 0 28px; min-height: 68px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar h1 { font-size: 1.25rem; margin: 0; }
.who { margin-inline-start: auto; color: var(--muted); }
.icon-btn.menu-btn { display: none; }
.content { padding: 28px; max-width: 1280px; width: 100%; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px; border-radius: 10px; border: 1px solid #c9d1db; background: #fff; color: var(--ink); font: 600 .95rem var(--font); text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--navy); color: var(--navy); }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: .88rem; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); color: #fff; }
.btn-danger { color: var(--err); border-color: #f0b7b1; }
.btn-danger:hover { background: var(--err-bg); color: var(--err); border-color: var(--err); }
.btn-wa { background: #1a7f45; border-color: #1a7f45; color: #fff; }
.btn-wa:hover { background: #156b3a; color: #fff; }
.btn-block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; }
.icon-btn:hover { border-color: var(--navy); color: var(--navy); }
.icon-btn.danger:hover { border-color: var(--err); color: var(--err); background: var(--err-bg); }
form.inline { display: inline; margin: 0; }

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; border: 1px solid transparent; }
.alert-success { background: var(--ok-bg); color: var(--ok); border-color: #b9e0c9; }
.alert-error { background: var(--err-bg); color: var(--err); border-color: #f5c2bd; }
.alert-info { background: var(--info-bg); color: var(--info); border-color: #c4d7f2; }

.panel { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 24px; margin-bottom: 20px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.panel-head h2 { margin: 0; }
.panel-head p { margin: 4px 0 0; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; margin: 0; }
.cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { display: flex; align-items: center; gap: 14px; padding: 20px; border-radius: 14px; background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.stat:hover { border-color: var(--navy); }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; background: var(--warn-bg); color: var(--warn); }
.stat strong { display: block; font-size: 1.6rem; line-height: 1.1; color: var(--navy); }
.stat small { color: var(--muted); font-size: .9rem; }
.todo { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.todo li { display: flex; align-items: center; gap: 10px; }
.todo svg { color: var(--warn); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .85rem; color: var(--muted); font-weight: 600; background: #fafbfc; }
tr.unread td { background: #fffaeb; font-weight: 600; }
.actions-col { white-space: nowrap; text-align: end; width: 1%; }
.actions-col > * + * { margin-inline-start: 6px; }
.mini-icon { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; background: var(--warn-bg); color: var(--warn); }
.thumb { width: 64px; height: 44px; object-fit: cover; border-radius: 6px; display: block; }
.thumb-empty { display: grid; place-items: center; background: var(--bg); color: #8a96a5; }
.pill { display: inline-block; padding: 3px 12px; border-radius: 999px; font: 600 .8rem var(--font); border: 0; cursor: default; white-space: nowrap; }
button.pill { cursor: pointer; min-height: 30px; }
.pill-new { background: var(--warn-bg); color: var(--warn); }
.pill-in_progress { background: var(--info-bg); color: var(--info); }
.pill-done { background: var(--ok-bg); color: var(--ok); }
.pill-off { background: #eceff3; color: #4b5563; }

.form .field { margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.span-2 { grid-column: 1 / -1; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .92rem; }
.field input[type=text], .field input[type=url], .field input[type=email], .field input[type=number], .field input[type=password], .field input:not([type]), .field select, .field textarea { width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid #c4ccd6; border-radius: 9px; font: inherit; color: var(--ink); background: #fff; }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: #1d4f91; box-shadow: 0 0 0 3px rgba(29,79,145,.15); }
.field input[type=file] { font: inherit; }
.hint { color: var(--muted); font-size: .85rem; margin: 6px 0 0; }
label.check { display: inline-flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; min-height: 44px; }
label.check input { width: 20px; height: 20px; accent-color: var(--navy); }
.form-actions, .row-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.img-current { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.img-current img { max-width: 200px; max-height: 120px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px 4px; margin: 0 0 20px; }
legend { font-weight: 700; color: var(--navy); padding: 0 8px; }

.icon-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.icon-opt { position: relative; cursor: pointer; }
.icon-opt input { position: absolute; opacity: 0; inset: 0; }
.icon-opt span { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px; border: 1px solid var(--line); border-radius: 10px; text-align: center; color: var(--ink); }
.icon-opt small { font-size: .75rem; color: var(--muted); }
.icon-opt input:checked + span { border: 2px solid var(--navy); background: #f0f4f9; color: var(--navy); }
.icon-opt input:focus-visible + span { outline: 3px solid var(--accent); }

.filters-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters-bar .field { margin: 0; flex: 1 1 160px; }
.filters-actions { display: flex; gap: 8px; }
.pager { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.pager a { min-width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--ink); }
.pager a.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 24px; margin: 0 0 20px; }
.details div { display: flex; gap: 12px; }
.details dt { color: var(--muted); min-width: 70px; }
.details dd { margin: 0; font-weight: 600; }
.message-body { background: var(--bg); border-radius: 10px; padding: 18px; margin-bottom: 16px; white-space: normal; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.tabs a { padding: 8px 16px; min-height: 40px; display: inline-flex; align-items: center; border-radius: 999px; background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 500; }
.tabs a:hover { border-color: var(--navy); }
.sticky-save { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 20px 0; }
.panel[id] { scroll-margin-top: 84px; }

/* صفحة الدخول والتثبيت */
.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; background: var(--navy); }
.auth-card { width: 100%; max-width: 420px; background: #fff; border-radius: 18px; padding: 36px; }
.auth-card.wide { max-width: 680px; }
.auth-card h1 { font-size: 1.2rem; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.2rem; color: var(--navy); margin-bottom: 20px; }
.auth-brand svg { color: var(--accent); background: var(--navy); border-radius: 10px; padding: 6px; width: 40px; height: 40px; }
.auth-foot { text-align: center; margin: 18px 0 0; }
.auth-card .grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }

@media (max-width: 960px) {
  .icon-btn.menu-btn { display: inline-grid; }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 40; transform: translateX(100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .who { display: none; }
  .stats, .form-grid, .details, .auth-card .grid-2 { grid-template-columns: 1fr; }
  .panel { padding: 18px; }
  .auth-card { padding: 24px; }
}

/* الترجمات */
.lang-box { background: #fafbfc; }
.lang-box legend { display: inline-flex; align-items: center; gap: 6px; }
.lang-box > .hint { margin: 0 0 12px; }
.tr-inputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 8px; padding: 10px; background: #fafbfc; border: 1px dashed var(--line); border-radius: 10px; }
.tr-input .tr-label { font-size: .8rem; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.tr-input .tr-label span { font-weight: 500; }
.label-like { display: block; font-weight: 600; margin-bottom: 6px; font-size: .92rem; }
.check-row { display: flex; flex-wrap: wrap; gap: 4px 20px; }
@media (max-width: 640px) { .tr-inputs { grid-template-columns: 1fr; } }

/* معرض الصور */
.tabs a.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.tabs a.active .muted { color: #c9d3de; }
.upload-box { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; padding: 16px; border: 2px dashed #c4ccd6; border-radius: 12px; background: #fafbfc; }
.upload-box .field { margin: 0; flex: 1 1 320px; }
.gallery-admin { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.g-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: #fff; }
.g-item .field { margin-bottom: 8px; }
.g-item .field label { font-size: .8rem; margin-bottom: 3px; }
.g-thumb { display: block; aspect-ratio: 16/10; border-radius: 8px; overflow: hidden; background: var(--bg); margin-bottom: 10px; border: 1px solid var(--line); }
.g-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.g-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.g-sort { max-width: 110px; margin: 0 !important; }

/* ألوان الموقع */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.theme-opt { position: relative; cursor: pointer; }
.theme-opt input { position: absolute; opacity: 0; inset: 0; }
.theme-card { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff; height: 100%; }
.theme-card small { font-size: .82rem; color: var(--ink); font-weight: 500; }
.theme-swatch { position: relative; display: block; height: 54px; border-radius: 8px; overflow: hidden; }
.theme-swatch i { position: absolute; inset-inline-end: 10px; bottom: 10px; width: 44px; height: 16px; border-radius: 6px; }
.theme-swatch-custom { display: grid; place-items: center; background: conic-gradient(#0e2236, #5ed6c0, #f5a524, #ff8a65, #0f2557, #0e2236); color: #fff; }
.theme-opt input:checked + .theme-card { border: 2px solid var(--navy); box-shadow: 0 0 0 3px rgba(14,34,54,.12); }
.theme-opt input:focus-visible + .theme-card { outline: 3px solid var(--accent); }
.theme-custom { display: none; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; margin-top: 14px; }
.theme-custom.show { display: grid; }
.theme-custom input[type=color] { width: 100%; height: 48px; padding: 4px; border: 1px solid #c4ccd6; border-radius: 9px; background: #fff; cursor: pointer; }
.theme-preview { margin-top: 16px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; max-width: 520px; }
.tp-nav { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: #fff; border-bottom: 1px solid var(--line); }
.tp-nav b { color: var(--tp); }
.tp-hero { background: var(--tp); color: #fff; padding: 22px 18px; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.tp-hero strong { font-size: 1.15rem; }
.tp-badge { color: var(--ta); font-size: .8rem; font-weight: 600; }
.tp-btn { background: var(--ta); color: var(--tp); font-size: .8rem; font-weight: 700; padding: 6px 12px; border-radius: 8px; }
@media (max-width: 640px) { .theme-custom.show { grid-template-columns: 1fr; } }

/* الشعار */
.logo-range { width: 100%; accent-color: var(--navy); height: 32px; }
.logo-preview { display: flex; align-items: center; gap: 10px; min-height: 80px; padding: 14px 16px; margin-top: 8px; border: 1px dashed #c4ccd6; border-radius: 10px; background: #fff; }
.logo-preview img { height: var(--h); width: auto; max-width: 100%; object-fit: contain; }
.logo-preview b { font-size: 1.2rem; color: var(--navy); }
.logo-preview.is-dark { background: #0a1928; border-color: #0a1928; }
.logo-preview.is-dark b, .logo-preview.is-dark .muted { color: #fff; }
.logo-white { filter: brightness(0) invert(1); }
