/* منصة النشر — نظام التصميم
   ثلاث أوضاع: نهاري (افتراضي)، ليلي، تلقائي (حسب الجهاز). السايدبار غامق دائماً. */

:root {
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --surface-2: #F9FAFB;
  --border: #E4E7EC;
  --border-strong: #D0D5DD;
  --ink: #101828;
  --ink-2: #344054;
  --muted: #5B6474;
  --accent: #2F5BEA;
  --accent-hover: #1D3FB8;
  --accent-soft: #EFF4FF;
  --accent-ink: #1D3FB8;
  --ok: #067647; --ok-soft: #ECFDF3; --ok-dot: #17B26A;
  --warn: #93370D; --warn-soft: #FFFAEB; --warn-dot: #F79009;
  --bad: #B42318; --bad-soft: #FEF3F2; --bad-dot: #F04438;
  --info: #1D3FB8; --info-soft: #EFF4FF;
  --side-bg: #0B1220; --side-ink: #C9D1E0; --side-strong: #FFFFFF; --side-muted: #8A94A8;
  --side-hover: #141D33; --side-active: #1A2440; --side-border: #1E2940; --side-input: #121B2E;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --radius: 14px;
  --radius-sm: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B0F17; --surface: #121826; --surface-2: #0F1520; --border: #222B3B; --border-strong: #2E3A4F;
    --ink: #EEF1F6; --ink-2: #C7CEDA; --muted: #98A2B3;
    --accent: #5B82FF; --accent-hover: #7B9BFF; --accent-soft: #18233F; --accent-ink: #A9BEFF;
    --ok: #75E0A7; --ok-soft: #0E2A1D; --warn: #FEC84B; --warn-soft: #2D2210; --bad: #FDA29B; --bad-soft: #301414;
    --info: #A9BEFF; --info-soft: #18233F;
    --side-bg: #070A11; --side-hover: #0F1524; --side-active: #16203A; --side-border: #161E30; --side-input: #0D1322;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B0F17; --surface: #121826; --surface-2: #0F1520; --border: #222B3B; --border-strong: #2E3A4F;
  --ink: #EEF1F6; --ink-2: #C7CEDA; --muted: #98A2B3;
  --accent: #5B82FF; --accent-hover: #7B9BFF; --accent-soft: #18233F; --accent-ink: #A9BEFF;
  --ok: #75E0A7; --ok-soft: #0E2A1D; --warn: #FEC84B; --warn-soft: #2D2210; --bad: #FDA29B; --bad-soft: #301414;
  --info: #A9BEFF; --info-soft: #18233F;
  --side-bg: #070A11; --side-hover: #0F1524; --side-active: #16203A; --side-border: #161E30; --side-input: #0D1322;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  font-size: 15px; line-height: 1.6;
}
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
h1, h2, h3 { margin: 0; line-height: 1.35; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 0 0 8px; }
code { font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace; font-size: 13px; background: var(--surface-2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; }
.ic { flex-shrink: 0; vertical-align: middle; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; inset-inline-start: 12px; top: -60px; background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 50; }
.skip:focus { top: 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 700; }
.block { display: block; }
.grow { flex: 1; min-width: 0; }
.nowrap { white-space: nowrap; }
.ltr-inline { direction: ltr; unicode-bidi: isolate; }
.ltr-cell { direction: ltr; text-align: left; }
.break { word-break: break-all; }
.text-bad { color: var(--bad); }
.text-info { color: var(--info); }
.text-warn { color: var(--warn); }
.lead { margin-bottom: 16px; }

/* ===== الهيكل ===== */
.shell { min-height: 100vh; display: flex; flex-wrap: wrap; }
.sidebar {
  flex: 0 0 268px; background: var(--side-bg); color: var(--side-ink);
  display: flex; flex-direction: column; gap: 18px; padding: 20px 14px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.main { flex: 1 1 560px; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 0 28px 48px; display: flex; flex-direction: column; gap: 20px; width: 100%; }

.side-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; color: var(--side-strong); font-weight: 700; font-size: 17px; }
.logo-mark { width: 34px; height: 34px; border-radius: 10px; background: #2F5BEA; color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.side-label { display: block; padding: 0 10px 6px; font-size: 12px; font-weight: 600; color: var(--side-muted); }
.site-switch { position: relative; display: flex; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--side-border); background: var(--side-input); border-radius: 12px; color: var(--side-strong); }
.site-switch select { flex: 1; appearance: none; background: transparent; border: 0; color: inherit; font: inherit; font-size: 14px; font-weight: 600; padding: 11px 0; direction: ltr; text-align: right; cursor: pointer; }
.site-switch select option { color: #101828; }
.site-switch .ic { color: var(--side-muted); pointer-events: none; }
.site-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.side-group { display: flex; flex-direction: column; gap: 2px; }
.side-link { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--side-ink); text-decoration: none; font-size: 14px; min-height: 40px; }
.side-link:hover { background: var(--side-hover); color: var(--side-strong); }
.side-link[aria-current="page"] { background: var(--side-active); color: var(--side-strong); font-weight: 600; }
.side-link .num { width: 22px; height: 22px; border-radius: 7px; background: var(--side-hover); color: var(--side-muted); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.side-link[aria-current="page"] .num { background: #2F5BEA; color: #fff; }
.side-link.is-soon { color: var(--side-muted); }
.side-link .soon { margin-inline-start: auto; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--side-hover); color: var(--side-muted); }
.side-foot { margin-top: auto; border-top: 1px solid var(--side-border); padding-top: 14px; display: flex; align-items: center; gap: 10px; }
.side-user { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #2F5BEA; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.side-user-name { color: var(--side-strong); font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-role { color: var(--side-muted); font-size: 12px; }

.topbar { display: flex; align-items: center; gap: 14px; padding: 22px 28px 18px; flex-wrap: wrap; width: 100%; }
.topbar-title { flex: 1; min-width: 200px; }
.topbar-title h1 { font-size: 24px; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.theme-switch { display: inline-flex; padding: 3px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.theme-switch button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; padding: 7px 11px; border-radius: 9px; cursor: pointer; min-height: 36px; }
.theme-switch button[aria-checked="true"] { background: var(--accent-soft); color: var(--accent-ink); }
.theme-switch button:hover { color: var(--ink); }
.only-mobile { display: none; }

/* ===== المكونات ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card.narrow { max-width: 640px; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.two-col { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.col-main { flex: 999 1 520px; min-width: 0; }
.col-side { flex: 1 1 300px; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-ghost { background: var(--surface); color: var(--ink-2); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger-ghost { background: transparent; color: var(--bad); border-color: var(--border-strong); }
.btn-danger-ghost:hover { background: var(--bad-soft); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn-dark { width: 40px; height: 40px; background: transparent; border-color: var(--side-border); color: var(--side-muted); }
.icon-btn-dark:hover { color: #fff; background: var(--side-hover); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-inline-end: 6px; }
.dot-ok { background: var(--ok-dot); }
.dot-bad { background: var(--bad-dot); }

.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-radius: 12px; font-size: 14px; margin: 0 28px 16px; }
.content .alert, .blank-wrap .alert, .stack .alert, .wizard .alert { margin: 0; }
.alert .ic { margin-top: 3px; }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-bad { background: var(--bad-soft); color: var(--bad); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert-info { background: var(--info-soft); color: var(--info); }
.alert code { background: transparent; }

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field-label, .field legend { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.field legend { margin-bottom: 8px; }
.field small { color: var(--muted); font-size: 12.5px; }
.field-sm { max-width: 320px; }
input, select, textarea {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); flex-shrink: 0; }
input[type="color"] { padding: 4px; height: 44px; cursor: pointer; }
input[type="file"] { padding: 8px; }
.field-color input { max-width: 120px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; min-height: 36px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 14px; }
.radio-card { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; flex-wrap: wrap; }
.readonly { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px dashed var(--border-strong); font-size: 14px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.sticky-save { position: sticky; bottom: 0; padding: 14px 0; background: linear-gradient(to top, var(--bg) 70%, transparent); display: flex; justify-content: flex-start; }
.vars { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0; }

.copy-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.copy-row code { flex: 1; min-width: 200px; padding: 9px 12px; word-break: break-all; text-align: left; }

.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
.table th { text-align: right; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.cell-title { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.cell-title a { color: var(--ink); text-decoration: none; }
.cell-title a:hover { color: var(--accent); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi-label { color: var(--muted); font-size: 14px; }
.kpi-value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.kpi-note { font-size: 13px; font-weight: 500; color: var(--muted); }

.progress { height: 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 999px; }
.progress-mini { width: 120px; height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-bottom: 4px; }
.progress-mini > div { height: 100%; background: var(--accent); }
.setup { display: flex; flex-direction: column; gap: 14px; }
.setup-title { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 10px; font-size: 13px; font-weight: 600; text-decoration: none; min-height: 38px; }
.chip-todo { background: var(--warn-soft); color: var(--warn); }
.chip-todo:hover { color: var(--warn); filter: brightness(.97); }

.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--border); color: var(--ink); text-decoration: none; }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover { background: var(--surface-2); }
.empty { text-align: center; padding: 28px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--muted); }
.empty h3 { color: var(--ink); }
.empty-line { padding: 8px 0; }
.link { font-size: 14px; font-weight: 600; text-decoration: none; }
.link-ext { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 600; text-decoration: none; }
.back-link { font-size: 14px; font-weight: 600; text-decoration: none; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg a { padding: 7px 12px; font-size: 13px; font-weight: 600; color: var(--muted); text-decoration: none; }
.seg a[aria-current="true"] { background: var(--accent-soft); color: var(--accent-ink); }

/* ===== الحسابات ===== */
.pbadge { border-radius: 12px; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.platform-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.platform-card { display: flex; flex-direction: column; gap: 12px; color: var(--ink); text-decoration: none; transition: border-color .15s; }
.platform-card:hover { border-color: var(--accent); color: var(--ink); }
.platform-card .btn { align-self: flex-start; margin-top: auto; }
.platform-top { display: flex; align-items: center; gap: 12px; }
.platform-meta { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: 13px; }
.platform-meta span { display: inline-flex; align-items: center; gap: 5px; }
.inline-error { font-size: 13px; color: var(--bad); background: var(--bad-soft); padding: 8px 10px; border-radius: 8px; display: flex; gap: 6px; align-items: flex-start; }

.account-head { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.account-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.account-title h2 { font-size: 20px; }
.account-info { margin: 0; display: grid; gap: 8px; min-width: 220px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.account-info div { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.account-info dt { color: var(--muted); }
.account-info dd { margin: 0; font-weight: 600; }
.steps-progress { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); }

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.step { display: flex; gap: 16px; position: relative; padding-bottom: 18px; }
.step:not(:last-child)::before { content: ''; position: absolute; top: 40px; bottom: 0; inset-inline-start: 17px; width: 2px; background: var(--border); }
.step-done:not(:last-child)::before { background: var(--ok-dot); }
.step-marker { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; background: var(--surface); border: 2px solid var(--border-strong); color: var(--muted); position: relative; z-index: 1; }
.step-done .step-marker { background: var(--ok-dot); border-color: var(--ok-dot); color: #fff; }
.step-current .step-marker { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.step-body { flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.step-current .step-body { border-color: var(--accent); }
.step-body h3 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.step-body p { color: var(--ink-2); font-size: 14px; }
.step-links { display: flex; flex-wrap: wrap; gap: 16px; margin: 4px 0; }
.inline-form { padding: 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); margin-top: 6px; }
.pick-list { margin-top: 8px; }
.manual { margin-top: 10px; border-top: 1px dashed var(--border); padding-top: 10px; }
.manual summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--ink-2); padding: 6px 0; }
.manual form { margin-top: 10px; }

.logo-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.logo-preview { width: 96px; height: 96px; border-radius: 16px; border: 1px dashed var(--border-strong); background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 50% / 16px 16px; display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0; }
.logo-preview img { max-width: 84px; max-height: 84px; }
.upcoming { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }

/* ===== الصفحات المستقلة (دخول/تثبيت) ===== */
.blank-wrap { max-width: 560px; margin: 0 auto; padding: 48px 16px; display: flex; flex-direction: column; gap: 18px; }
.blank-brand { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 20px; font-weight: 700; }
.auth-card, .wizard { display: flex; flex-direction: column; gap: 14px; padding: 28px; }
.auth-card h1, .wizard h1 { font-size: 24px; }
.center-card { text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; padding: 36px; }
.stepper { list-style: none; margin: 4px 0; padding: 0; display: flex; gap: 8px; flex-wrap: wrap; }
.stepper li { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); flex: 1; min-width: 130px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); }
.stepper li span { width: 24px; height: 24px; border-radius: 50%; background: var(--border); color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0; }
.stepper li.current { background: var(--accent-soft); color: var(--accent-ink); }
.stepper li.current span { background: var(--accent); color: #fff; }
.stepper li.done span { background: var(--ok-dot); color: #fff; }
.hint-box { padding: 12px 14px; border-radius: 12px; background: var(--info-soft); color: var(--info); font-size: 14px; }
.step-box { padding: 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; }
.success-mark { width: 56px; height: 56px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: flex; align-items: center; justify-content: center; }

/* ===== الموبايل ===== */
@media (max-width: 900px) {
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 40; width: 280px; transform: translateX(110%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .sidebar.open { transform: translateX(0); }
  .only-mobile { display: inline-flex; }
  .topbar { padding: 16px; }
  .content { padding: 0 16px 40px; }
  .alert { margin: 0 16px 14px; }
  .theme-switch button span { display: none; }
  .table-wrap { margin: 0 -20px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* تصحيحات */
.icon-btn.only-mobile { display: none; }
@media (max-width: 900px) { .icon-btn.only-mobile { display: inline-flex; } }
.step-body > a.btn { align-self: flex-start; }

/* ===== المرحلة 2: الفلاتر والقواعد والخطة ===== */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.toolbar .grow { min-width: 260px; }
form.inline { display: inline-flex; }
.date-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.date-nav input[type="date"] { width: auto; min-height: 38px; padding: 6px 10px; }
.legend { display: flex; gap: 6px; flex-wrap: wrap; }
.logo-sm { width: 24px; height: 24px; object-fit: contain; flex-shrink: 0; vertical-align: middle; }
.icon-btn-sm { width: 34px; height: 34px; border-radius: 9px; font-size: 11px; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.row-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.rank-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.rank-list li { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.rank-list li:last-child { border-bottom: 0; }
.rank { width: 26px; height: 26px; border-radius: 8px; background: var(--accent-soft); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.scroll-list { max-height: 560px; overflow-y: auto; margin-top: 10px; }
.search-row { display: flex; gap: 8px; margin-bottom: 10px; }
.search-row input { flex: 1; }
.team-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.team-chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface-2); font-size: 14px; font-weight: 600; }
.team-chip button { border: 0; background: var(--surface); color: var(--muted); width: 26px; height: 26px; border-radius: 50%; cursor: pointer; font-size: 16px; line-height: 1; }
.team-chip button:hover { color: var(--bad); }
.group-title { margin: 18px 0 6px; font-size: 14px; color: var(--muted); }
.match-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.match-line .score { font-weight: 700; min-width: 44px; text-align: center; direction: ltr; }
.match-line.big { justify-content: space-between; font-weight: 600; margin-top: 6px; }
.match-line.big span { display: inline-flex; align-items: center; gap: 6px; }
.row-dim td { opacity: .55; }
.match-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.match-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--surface-2); }
.small-value { font-size: 20px; }
.plain-list { margin: 0 0 12px; padding-inline-start: 18px; display: flex; flex-direction: column; gap: 6px; color: var(--ink-2); font-size: 14px; }
.input-sm { width: 220px; min-height: 38px; padding: 6px 10px; }

.tchip { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 7px; font-size: 12px; font-weight: 600; border: 1px solid var(--border); background: var(--surface-2); color: var(--ink-2); }
.tchip-facebook { border-color: #B2CCFF; background: #EFF4FF; color: #1D3FB8; }
.tchip-instagram { border-color: #FCCEEE; background: #FDF2FA; color: #C11574; }
.tchip-telegram { border-color: #B9E6FE; background: #F0F9FF; color: #026AA2; }
.tchip-youtube { border-color: #FECDCA; background: #FEF3F2; color: #B42318; }
:root[data-theme="dark"] .tchip-facebook, :root[data-theme="dark"] .tchip-instagram, :root[data-theme="dark"] .tchip-telegram, :root[data-theme="dark"] .tchip-youtube { background: var(--surface-2); border-color: var(--border-strong); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tchip-facebook, :root:not([data-theme="light"]) .tchip-instagram, :root:not([data-theme="light"]) .tchip-telegram, :root:not([data-theme="light"]) .tchip-youtube { background: var(--surface-2); border-color: var(--border-strong); } }
:root[data-theme="dark"] .tchip-facebook { color: #A9BEFF; } :root[data-theme="dark"] .tchip-instagram { color: #FAA7E0; } :root[data-theme="dark"] .tchip-telegram { color: #7CD4FD; } :root[data-theme="dark"] .tchip-youtube { color: #FDA29B; }
.chips-row { display: flex; flex-wrap: wrap; gap: 6px; }

.rule-list { display: flex; flex-direction: column; gap: 12px; }
.rule { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.rule.is-off { opacity: .7; }
.rule-main { flex: 1; min-width: 280px; display: flex; flex-direction: column; gap: 8px; }
.rule-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rule-meta { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: 13px; }
.rule-meta span { display: inline-flex; align-items: center; gap: 5px; }
.rule-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.radio-list { display: flex; flex-direction: column; gap: 0; margin-bottom: 12px; }
.check-grid.days { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.check-grid.targets { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); margin-bottom: 8px; }
[hidden] { display: none !important; }

.add-manual summary { cursor: pointer; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.add-manual[open] summary { margin-bottom: 14px; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 14px; padding: 14px 4px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.tl-item:last-child { border-bottom: 0; }
.tl-time { width: 58px; flex-shrink: 0; font-size: 17px; font-weight: 700; padding-top: 1px; }
.tl-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.tl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-sub { display: flex; flex-wrap: wrap; gap: 6px; font-size: 14px; }
.tl-actions { flex-shrink: 0; }
.tl-skipped .tl-time, .tl-skipped .tl-head b { color: var(--muted); text-decoration: line-through; }
.tl-edit summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--accent); }
.tl-edit form { margin-top: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }

/* ===== المراحل 3–6 ===== */
.tl-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.results { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.res-ok { color: var(--ok); } .res-warn { color: var(--warn); } .res-failed { color: var(--bad); } .res-skipped { color: var(--muted); }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.tpl-card { padding: 12px; display: flex; flex-direction: column; gap: 10px; color: var(--ink); text-decoration: none; }
.tpl-card:hover { border-color: var(--accent); color: var(--ink); }
.tpl-thumb { border-radius: 10px; overflow: hidden; background: #04060B; display: flex; align-items: center; justify-content: center; aspect-ratio: 4 / 5; }
.tpl-thumb.tpl-story { aspect-ratio: 9 / 16; }
.tpl-thumb img { width: 100%; height: 100%; object-fit: contain; }
.tpl-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.editor { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.editor-stage-card { flex: 999 1 520px; min-width: 0; }
.editor-side { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 16px; position: sticky; top: 12px; }
.stage-wrap { display: flex; justify-content: center; }
.stage { position: relative; width: min(100%, 520px); overflow: hidden; border-radius: 12px; font-family: 'Cairo', sans-serif; user-select: none; touch-action: none; direction: rtl; }
.stage .glow { position: absolute; inset: 0; pointer-events: none; }
.stage .el { position: absolute; cursor: grab; color: #fff; line-height: 1.3; outline: 1px dashed transparent; }
.stage .el:hover { outline-color: rgba(255,255,255,.35); }
.stage .el.is-selected { outline: 2px solid #5B82FF; z-index: 5; }
.stage .el.is-hidden { opacity: .25; }
.stage .el-list { border: 1px dashed rgba(255,255,255,.35); color: rgba(255,255,255,.7); display: flex; align-items: center; justify-content: center; font-size: 12px; }
.stage .el-team_badge, .stage .el-image { color: #333; font-size: 11px; display: flex; align-items: center; justify-content: center; }
.stage .el-pitch { border: 1px solid rgba(255,255,255,.08); border-radius: 50%; pointer-events: none; }
.stage .el-goals { color: rgba(255,255,255,.8); white-space: nowrap; }
.real-preview { width: min(100%, 520px); display: flex; flex-direction: column; gap: 10px; align-items: center; }
.real-preview img { width: 100%; border-radius: 12px; }
.editor-status { min-height: 20px; margin-top: 8px; text-align: center; }
.layers { display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto; }
.layer { display: flex; align-items: center; gap: 6px; width: 100%; text-align: right; border: 0; background: transparent; padding: 7px 10px; border-radius: 8px; font: inherit; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.layer span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer small { flex: none; font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--ink-3); }
.layer small.is-anim { background: var(--accent-soft); color: var(--accent-ink); }
.layer.is-off span { text-decoration: line-through; opacity: .6; }
.layer:hover { background: var(--surface-2); }
.layer.is-selected { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.layer.is-hidden { opacity: .5; }
.props-head { font-weight: 700; margin-bottom: 10px; font-size: 14px; }
[data-props] .field { margin-bottom: 8px; }
textarea { font: inherit; font-size: 14px; resize: vertical; }

/* ===== GitHub لكل دومين + سجل النشر ===== */
.check-results { list-style: none; margin: 0 0 14px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.plain-list.numbered { list-style: decimal; padding-inline-start: 22px; }
.plain-list.numbered li { margin-bottom: 8px; line-height: 1.8; }
.plain-list.numbered ul { margin: 6px 0 0; padding-inline-start: 18px; list-style: disc; }
.res-uncertain { color: var(--warn); font-weight: 600; }
.res-duplicate { color: var(--muted); }
.resolve-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 2px; }

/* ===== الإحصائيات ===== */
.stats-toolbar { flex-wrap: wrap; gap: 10px; }
.stats-toolbar .grow { flex: 1; }
.kpis-5 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 16px; }
.kpi-sub { margin-top: 2px; }
.insights ul { margin: 0; }
.insights li { font-weight: 600; color: var(--ink-2); }
.hbars { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 16px; }
.hbar { display: grid; grid-template-columns: minmax(120px, 190px) 1fr 80px; align-items: center; gap: 12px; font-size: 14px; }
.hbar-label { color: var(--ink-2); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 14px; display: block; }
.hbar-track i { display: block; height: 100%; background: var(--accent); border-radius: 4px 0 0 4px; }
.hbar:hover .hbar-track i { filter: brightness(1.12); }
.hbar-value { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 700; text-align: left; }
svg.chart { width: 100%; height: auto; display: block; direction: ltr; overflow: visible; }
svg.chart .grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; }
svg.chart .baseline { stroke: var(--border); stroke-width: 1.5; }
svg.chart .axis { fill: var(--muted); font-size: 12px; font-family: inherit; }
svg.chart .mark path { fill: var(--accent); }
svg.chart .mark .hit { fill: transparent; }
svg.chart .mark:hover path { filter: brightness(1.15); }
svg.chart .mark:hover .hit { fill: var(--surface-2); }
.stats-charts { align-items: stretch; }
.table-view summary, details.card > summary { cursor: pointer; font-weight: 600; }
@media (max-width: 640px) { .hbar { grid-template-columns: 100px 1fr 64px; gap: 8px; font-size: 13px; } }

/* ===== لوحة المباريات (الفلاتر ← مباريات اليوم / الغد) ===== */
.mb-top { flex-wrap: wrap; gap: 12px; align-items: center; }
.mb-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.mb-stats span { padding: 5px 12px; border-radius: 999px; background: var(--surface-2, var(--bg)); border: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.mb-stats b { color: var(--ink); font-size: 15px; margin-inline-end: 3px; }
.mb-stats .is-imp b { color: var(--ok); }
.mb-stats .is-live b { color: var(--bad); }
.mb-group { border: 1px solid var(--border); border-radius: var(--radius); margin-top: 16px; overflow: hidden; background: var(--surface); }
.mb-group-other { opacity: .92; }
.mb-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface-2, var(--bg)); border-bottom: 1px solid var(--border); }
.mb-head h3 { margin: 0; font-size: 15px; }
.mb-comp-logo { width: 34px; height: 34px; object-fit: contain; flex-shrink: 0; background: #fff; border-radius: 8px; padding: 3px; }
.mb-list { display: flex; flex-direction: column; }
.mb-row { display: grid; grid-template-columns: 92px minmax(0, 1fr) 110px auto; align-items: center; gap: 14px; padding: 10px 16px; border-bottom: 1px solid var(--border); border-inline-start: 3px solid transparent; transition: background .15s; scroll-margin-top: 90px; }
.mb-row:last-child { border-bottom: 0; }
.mb-row:hover { background: var(--accent-soft); }
.mb-row.is-important { border-inline-start-color: var(--ok-dot, var(--ok)); background: color-mix(in srgb, var(--ok-soft) 55%, transparent); }
.mb-row.is-excluded { opacity: .5; }
.mb-row:target { outline: 2px solid var(--accent); outline-offset: -2px; }
.mb-time { display: flex; flex-direction: column; gap: 2px; }
.mb-time b { font-size: 15px; }
.mb-live { color: var(--bad); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 5px; }
.mb-live i { width: 7px; height: 7px; border-radius: 50%; background: var(--bad-dot, var(--bad)); animation: mb-pulse 1.2s infinite; }
@keyframes mb-pulse { 50% { opacity: .25; } }
.mb-teams { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 10px; min-width: 0; }
.mb-team { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 600; }
/* الشعارين لازقين في النتيجة بنفس المسافة من الناحيتين (والاسم جنب الشعار) */
.mb-home { justify-content: flex-end; }
.mb-away { justify-content: flex-start; }
.mb-team img { width: 28px; height: 28px; object-fit: contain; flex-shrink: 0; }
.mb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mb-score { display: inline-flex; align-items: center; min-width: 64px; padding: 4px 10px; border-radius: 10px; background: var(--surface-2, var(--bg)); border: 1px solid var(--border); }
.mb-score b { font-size: 17px; }
.mb-score em { font-style: normal; color: var(--muted); margin: 0 5px; }
.mb-score { flex-direction: row; flex-wrap: wrap; justify-content: center; }
.mb-score small { flex-basis: 100%; text-align: center; font-size: 11px; color: var(--muted); direction: rtl; }
.mb-score.is-vs { color: var(--muted); font-weight: 700; }
.mb-row.is-live .mb-score { border-color: var(--bad-dot, var(--bad)); }
.mb-tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-start; }
.mb-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.mb-more { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.mb-more > .btn { align-self: flex-start; }
.mb-star { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); }
.mb-star:hover { background: var(--ok-soft); }
.mb-logo-ph { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--surface-2, var(--bg)); border: 1px solid var(--border); color: var(--muted); font-size: 13px; font-weight: 700; }
.mb-head .mb-logo-ph { width: 34px; height: 34px; border-radius: 8px; }
.mb-more h3 { font-size: 14px; margin: 6px 0 0; }
@media (max-width: 900px) {
  .mb-row { grid-template-columns: 70px minmax(0, 1fr); gap: 8px 12px; }
  .mb-tags { grid-column: 1 / -1; }
  .mb-actions { grid-column: 1 / -1; justify-content: flex-start; }
}
@media (max-width: 520px) {
  .mb-row { grid-template-columns: minmax(0, 1fr); padding: 10px 12px; }
  .mb-time { flex-direction: row; align-items: center; gap: 8px; }
  .mb-head { padding: 10px 12px; }
  .mb-teams { gap: 6px; }
  .mb-team { font-size: 13px; gap: 5px; }
  .mb-team img { width: 22px; height: 22px; }
  .mb-score { min-width: 48px; padding: 3px 6px; }
}
