/* لوحة التاجر ولوحة المنصة بنفس تصميم المحاكاة (docs/demo/assets/app.css): نفس الألوان والمقاسات والهيكل.
   مفيش CSS أو JS جوه الصفحات (CSP صارم)، فالقائمة على الفون والوضع الليلي CSS بس. */
:root {
  --bg: #f6f5f1; --surface: #ffffff; --surface-2: #efede7; --ink: #1d1f24; --muted: #666a73;
  --line: #dedbd2; --accent: #0f766e; --accent-ink: #ffffff; --note-bg: #fff4d6; --note-ink: #7a5300;
  --danger: #dc2626; --danger-bg: #fee2e2; --ok: #15803d; --ok-bg: #dcfce7; --warn: #b45309; --warn-bg: #fef3c7;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg:#121417; --surface:#1b1e23; --surface-2:#23272e; --ink:#e8e6e1; --muted:#9aa0aa; --line:#30353d;
    --accent:#2dd4bf; --accent-ink:#062a27; --note-bg:#3a2f14; --note-ink:#f5d27a;
    --danger:#f87171; --danger-bg:#3a1f1f; --ok:#4ade80; --ok-bg:#1a2e20; --warn:#fbbf24; --warn-bg:#332707;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--ink); font: 15px/1.7 "IBM Plex Sans Arabic", "Segoe UI", Tahoma, "Noto Sans Arabic", Arial, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 17px; margin: 18px 0 10px; }
h3 { font-size: 15px; margin: 14px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; word-break: break-all; }
del { text-decoration: line-through; }
svg.ic { width: 18px; height: 18px; flex: none; vertical-align: middle; }

/* ---- هيكل اللوحة ---- */
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
#appShell { display: grid; grid-template-columns: 260px 1fr; grid-template-rows: auto 1fr; min-height: 100vh; grid-template-areas: "top top" "side main"; }
.topbar { grid-area: top; position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar .brand { font-weight: 700; display: flex; gap: 8px; align-items: center; margin-inline-end: 8px; }
.topbar .brand small { color: var(--muted); font-weight: 400; font-size: 12px; }
.topbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.user-chip { font-size: 13px; background: var(--surface-2); padding: 4px 12px; border-radius: 999px; }
.user-chip small { color: var(--muted); }
.icon-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; min-width: 36px; height: 36px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--surface-2); }
.menu-btn { display: none; }
.sidebar { grid-area: side; border-inline-end: 1px solid var(--line); background: var(--surface); padding: 14px 10px; overflow-y: auto; }
/* أقسام القائمة أكورديون: العنوان بيفتح ويقفل، والسهم بيلف مع الفتح */
.nav-group { margin-bottom: 4px; }
.nav-group-title { font-size: 13.5px; color: var(--ink); font-weight: 700; padding: 9px 12px; display: flex; gap: 8px; align-items: center; border-radius: 8px; cursor: pointer; list-style: none; user-select: none; }
.nav-group-title::-webkit-details-marker { display: none; }
.nav-group-title:hover { background: var(--surface-2); text-decoration: none; }
.nav-group-title .ic { width: 17px; height: 17px; color: var(--muted); }
/* السهم بحدود فعلية (مش logical) علشان اتجاهه مايتقلبش مع RTL: مقفول ← للشمال، مفتوح ← لتحت */
summary.nav-group-title::after { content: ""; margin-inline-start: auto; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(135deg); transition: transform .15s; }
details[open] > summary.nav-group-title::after { transform: rotate(45deg); }
details[open] > summary.nav-group-title { color: var(--accent); }
.nav-single { margin-bottom: 4px; }
.nav-single.active { background: var(--accent); color: var(--accent-ink); }
.nav-single.active .ic { color: var(--accent-ink); }
.nav-link { display: flex; align-items: center; gap: 8px; padding: 7px 10px 7px 10px; padding-inline-start: 31px; border-radius: 8px; color: var(--ink); font-size: 14px; }
.nav-link:hover { background: var(--surface-2); text-decoration: none; }
.nav-link.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.nav-backdrop { display: none; }
.main { grid-area: main; padding: 20px 22px 60px; min-width: 0; }
.page { max-width: 1100px; margin: 0 auto; padding: 20px 16px; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
@media (max-width: 860px) {
  #appShell { grid-template-columns: 1fr; grid-template-areas: "top" "main"; }
  .menu-btn { display: inline-flex; }
  .sidebar { position: fixed; inset-inline-start: 0; top: 0; bottom: 0; width: 270px; z-index: 50; transform: translateX(110%); transition: transform .2s; box-shadow: var(--shadow); }
  .nav-toggle:checked + #appShell .sidebar { transform: translateX(0); }
  .nav-toggle:checked + #appShell .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }
  .topbar { flex-wrap: wrap; }
  .topbar-actions { gap: 6px; }
  .main { padding: 14px; }
}

/* ---- عنوان الصفحة وشريط الأدوات ---- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.toolbar h1 { margin: 0; }
form.toolbar { justify-content: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
form.toolbar label { margin: 0; }
form.toolbar input, form.toolbar select { width: auto; min-width: 180px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13.5px; }
.row-actions > a:not(.button) { padding: 3px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.row-actions > a:not(.button):hover { background: var(--surface-2); text-decoration: none; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; border-bottom: 2px solid transparent; color: var(--muted); font-size: 14px; }
.tabs a.active { color: var(--accent); border-color: var(--accent); font-weight: 600; }

/* ---- البطاقات ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; box-shadow: var(--shadow); margin-bottom: 16px; width: 100%; max-width: 620px; }
.card.wide { max-width: none; }
.auth .card { max-width: 420px; }
.card h1 { font-size: 19px; }
.card h2:first-child, .card h1:first-child { margin-top: 0; }
.kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.kpi b { display: block; font-size: 24px; }
.kpi span { color: var(--muted); font-size: 13px; }
/* شارتات الرئيسية: SVG مرسوم في السيرفر (من غير JS) والألوان من الكلاسات */
.charts { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.charts .card { max-width: none; margin: 0; }
.charts h3 { margin: 0 0 10px; font-size: 15px; }
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .val { fill: var(--ink); font-weight: 600; }
.chart .axis { stroke: var(--line); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.chart .area { fill: var(--accent); opacity: .12; stroke: none; }
.chart .pt { fill: var(--accent); }
.chart .c0 { fill: #0f766e; } .chart .c1 { fill: #2563eb; } .chart .c2 { fill: #d97706; }
.chart .c3 { fill: #7c3aed; } .chart .c4 { fill: #db2777; } .chart .c5 { fill: #65a30d; }
.chart-empty { color: var(--muted); font-size: 13px; padding: 24px 0; text-align: center; }
.summary-box { display: grid; gap: 10px; }
.summary-box div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; background: var(--surface-2); border-radius: 8px; }
.summary-box span { color: var(--muted); }
.plan-strip { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.plan-strip b { color: var(--ink); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }

/* ---- الأزرار ---- */
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); border-radius: 8px; padding: 8px 16px; cursor: pointer; font-size: 14px; font-weight: 600; }
button:hover, .button:hover { filter: brightness(1.06); text-decoration: none; }
.btn, button.btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 8px; padding: 8px 14px; font-weight: 400; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: var(--surface-2); text-decoration: none; filter: none; }
.btn.sm, button.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.button.secondary, button.secondary, button.secondary-button { background: var(--surface); color: var(--ink); border-color: var(--line); font-weight: 400; }
.button.secondary:hover, button.secondary-button:hover { background: var(--surface-2); }
button.link { background: none; border: 0; color: var(--accent); padding: 0; font-weight: 400; }
button:disabled { opacity: .45; cursor: not-allowed; }
.actions { display: flex; gap: 8px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.auth button[type=submit] { width: 100%; margin-top: 16px; }
form.inline { display: inline; }

/* ---- الحالات ---- */
.status { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.status-active { background: var(--ok-bg); color: var(--ok); }
.status-trial, .status-grace, .status-disabled { background: var(--warn-bg); color: var(--warn); }
.status-suspended, .status-trial_expired, .status-cancelled { background: var(--danger-bg); color: var(--danger); }
.status-archived { background: var(--surface-2); color: var(--muted); }

/* ---- التنبيهات ---- */
.notice { padding: 9px 14px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border: 1px solid var(--line); margin: 0 0 14px; font-size: 14px; }
.notice ul { margin: 0; padding-inline-start: 18px; }
.notice-ok { background: var(--ok-bg); color: var(--ok); }
.notice-warn { background: var(--warn-bg); color: var(--warn); }
.notice-error { background: var(--danger-bg); color: var(--danger); }

/* ---- الجداول (table.grid = dtable في المحاكاة) ---- */
table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 14px; }
table.grid th, table.grid td { padding: 9px 12px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid thead th { background: var(--surface-2); font-weight: 700; white-space: nowrap; }
table.grid tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid td.value { max-width: 280px; overflow-wrap: anywhere; font-size: 13px; }
.table-scroll { overflow-x: auto; border-radius: 10px; }
.table-scroll table.grid { margin-bottom: 0; }
@media (max-width: 860px) { table.grid { display: block; overflow-x: auto; white-space: nowrap; } }
.pager { display: flex; align-items: center; gap: 10px; margin-top: 10px; justify-content: center; font-size: 13px; }
.thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; background: var(--surface-2); }

/* ---- الفورمات ---- */
label { display: block; margin: 12px 0 4px; font-weight: 600; font-size: 13.5px; }
input, select, textarea { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; min-height: 36px; padding: 6px 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 0; border-color: var(--accent); }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; accent-color: var(--accent); }
input[type=color] { height: 40px; padding: 2px; }
select[multiple] { min-height: 90px; }
.check, .choice { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.choice { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 6px 0; background: var(--surface); }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 16px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 14px; padding: 10px 14px; min-width: 0; }
legend { padding: 0 6px; font-weight: 700; color: var(--accent); }
fieldset.settings { border: 0; padding: 0; margin: 0; }
fieldset.checks { max-height: 360px; overflow-y: auto; }
fieldset.cost { margin-top: 14px; }
.cost-block { border-top: 1px dashed var(--line); margin-top: 12px; padding-top: 6px; }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: 17px; letter-spacing: .08em; background: var(--surface-2); padding: 10px; border-radius: 8px; text-align: center; word-break: break-all; }
pre.sample { background: var(--surface-2); padding: 10px; border-radius: 8px; overflow-x: auto; font-size: 13px; }

/* ---- متفرقات ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; }
.chips li { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; }
.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.label { border: 1px dashed var(--line); border-radius: 6px; padding: 8px; display: flex; flex-direction: column; gap: 2px; background: var(--surface); font-size: 13px; }
.label strong { font-family: ui-monospace, Consolas, monospace; font-size: 15px; letter-spacing: .05em; }

@media print {
  .topbar, .sidebar, .no-print, .notice { display: none !important; }
  #appShell { display: block; }
  body { background: #fff; }
  .main, .page { padding: 0; max-width: none; }
  .label { break-inside: avoid; border-color: #999; }
}

/* الفون: الشريط العلوي في سطر واحد، الأزرار أيقونات بس */
@media (max-width: 700px) {
  .topbar-actions .lbl, .brand small { display: none; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .btn.sm { padding: 6px 8px; }
}

/* ---- لوحة المنصة: الباقات والإضافات ---- */
fieldset.plain { border: 0; padding: 0; margin: 0; }
.feature-list { max-height: 420px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 8px; margin-bottom: 12px; }
.feature-list .choice { margin-bottom: 4px; padding: 6px 10px; }
.feature-list .depth-1 { margin-inline-start: 16px; }
.feature-list .depth-2 { margin-inline-start: 32px; }
.feature-list .depth-3 { margin-inline-start: 48px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.meter { width: 100%; min-width: 90px; height: 8px; appearance: none; border: 0; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter::-webkit-progress-bar { background: var(--surface-2); }
.meter::-webkit-progress-value { background: var(--accent); }
.meter::-moz-progress-bar { background: var(--accent); }
.meter.hot::-webkit-progress-value { background: var(--danger); }
.meter.hot::-moz-progress-bar { background: var(--danger); }

/* ---- لوحة التاجر: مركز القيادة ---- */
.greet { margin: 0 0 2px; font-size: 20px; }
.row-actions > a.is-on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.action-strip { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); margin-bottom: 16px; }
.action-card { display: flex; align-items: center; gap: 12px; background: var(--warn-bg); color: var(--warn); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.action-card:hover { text-decoration: none; filter: brightness(.97); }
.action-card b { font-size: 24px; }
.setup .steps { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.setup .steps li { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; }
.setup .steps li.done { background: var(--ok-bg); color: var(--ok); }
.kpi .delta { display: block; margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.kpi .delta.up { color: var(--ok); }
.kpi .delta.down { color: var(--danger); }
.grid.compact td, .grid.compact th { padding: 6px 8px; }
.usage { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin-bottom: 10px; font-size: 13.5px; }
.usage .meter { grid-column: 1 / -1; }

/* ---- الدخول كمتجر (S2.5) ---- */
.imp-bar { position: sticky; top: 0; z-index: 100; display: flex; gap: 12px; align-items: center; justify-content: center; padding: 8px 12px; background: #b91c1c; color: #fff; font-weight: 700; }
.imp-bar button { background: #fff; color: #b91c1c; border-color: #fff; padding: 4px 12px; }

/* ---- الأقسام المقفولة بالباقة (S3.5) ---- */
.nav-link.locked { color: var(--muted); }
.lock-tag { display: inline-block; margin-inline-start: 6px; padding: 0 7px; border-radius: 999px; background: var(--warn-bg); color: var(--warn); font-size: 11px; font-weight: 700; }

/* شريط العمليات المجمعة (6.1) */
.bulk-bar { justify-content: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.bulk-bar select, .bulk-bar input { width: auto; min-width: 200px; }

/* 7.1 كروت القوالب */
.tpl-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tpl-card { display: grid; gap: 8px; }
.tpl-card b { font-size: 17px; display: flex; gap: 8px; align-items: center; }
.tpl-swatch { width: 100%; height: 70px; border-radius: 8px; display: block; }

/* الأكواد (BR001 · TR1001) ماتتقسمش على سطرين */
table.grid code { white-space: nowrap; }
.slug-row { display: flex; align-items: center; gap: 6px; }
.slug-row input { flex: 1; }
.announcement { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.checklist { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.checklist li.done { color: var(--muted); }
.onboarding progress { width: 100%; height: 10px; }
