/* RDN Store Panel — التحليلات.
   لون واحد للمقدار (أحمر رودن)، والفترة السابقة رمادية، والشبكة شعرية صلبة، والأعمدة رفيعة برأس مدوَّر. */

.rsp-an { --an-cur: var(--red); --an-prev: #B9ADA5; --an-grid: #F1E6DC; --an-surface: #fff; --an-good: #0B7A3B; --an-good-bg: #E3F5EA; --an-bad: #B4232B; --an-bad-bg: #FDECEC; }
.rsp-an [hidden] { display: none !important; }
.rsp-an-body { transition: opacity .18s ease; }
.rsp-an-body.is-loading { opacity: .5; pointer-events: none; }

/* ─── الفلتر: صف واحد فوق كل شيء ─── */
.rsp-an-filters { margin: 4px 0 14px; }
.rsp-an-presets { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.rsp-an-presets::-webkit-scrollbar { display: none; }
.rsp-an-preset { flex: none; min-height: 38px; padding: 0 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line-2); color: var(--ink-2); font-weight: 700; font-size: 14px; white-space: nowrap; }
.rsp-an-preset:hover { background: var(--cream); }
.rsp-an-preset.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.rsp-an-custom { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin-top: 8px; }
.rsp-an-custom label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 700; }
.rsp-an-custom input { min-height: 42px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 12px; background: #fff; font-size: 15px; }

/* ─── تجهيز البيانات ─── */
.rsp-an-sync { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 12px; border-radius: var(--radius); background: var(--amber-50); border: 1px solid #F5DDA0; }
.rsp-an-sync > div { flex: 1; min-width: 0; display: grid; gap: 2px; }
.rsp-an-sync strong { font-size: 14.5px; color: var(--amber-800); }
.rsp-an-sync small { font-size: 12.5px; color: var(--ink-2); }
.rsp-an-sync-bar { display: block; height: 6px; margin-top: 6px; border-radius: 999px; background: rgba(122, 78, 0, .14); overflow: hidden; }
.rsp-an-sync-bar b { display: block; height: 100%; border-radius: 999px; background: var(--amber-800); transition: width .3s ease; }

/* ─── البطاقة الرئيسية ─── */
.rsp-an-label { font-size: 13.5px; font-weight: 700; color: var(--muted); }
.rsp-an-hero { padding: 18px 16px 14px; margin-bottom: 12px; border-radius: 22px; background: var(--an-surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.rsp-an-hero-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.rsp-an-hero-val { display: flex; align-items: baseline; gap: 8px; margin: 6px 0 2px; }
.rsp-an-hero-val strong { font-size: 48px; line-height: 1.1; font-weight: 800; letter-spacing: -.5px; }
.rsp-an-hero-val small { font-size: 16px; font-weight: 700; color: var(--muted); }
.rsp-an-hero-prev { font-size: 12.5px; color: var(--muted); }
.rsp-an-spark { height: 44px; margin: 12px 0 10px; }
.rsp-an-spark svg { width: 100%; height: 100%; overflow: visible; }
.rsp-an-line { fill: none; stroke: var(--an-cur); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.rsp-an-line-prev { fill: none; stroke: var(--an-prev); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.rsp-an-break { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0; padding-top: 12px; border-top: 1px solid var(--line); }
.rsp-an-break div { display: flex; align-items: baseline; gap: 6px; }
.rsp-an-break dt { font-size: 12.5px; color: var(--muted); font-weight: 700; }
.rsp-an-break dd { margin: 0; font-size: 14px; font-weight: 800; }

/* التغيّر: السهم والنص معاً، لا اللون وحده */
.rsp-an-delta { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px 2px 6px; border-radius: 999px; font-size: 12.5px; font-weight: 800; line-height: 1.6; white-space: nowrap; }
.rsp-an-delta svg { width: 10px; height: 10px; }
.rsp-an-delta em { font-style: normal; font-weight: 600; opacity: .8; }
.rsp-an-delta.is-up { color: var(--an-good); background: var(--an-good-bg); }
.rsp-an-delta.is-down { color: var(--an-bad); background: var(--an-bad-bg); }
.rsp-an-delta.is-flat, .rsp-an-delta.is-none { color: var(--ink-2); background: #F3ECE6; }

/* ─── البلاطات ─── */
.rsp-an-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
@media (min-width: 900px) { .rsp-an-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.rsp-an-tile { display: grid; align-content: start; gap: 6px; padding: 14px; border-radius: var(--radius); background: var(--an-surface); border: 1px solid var(--line); }
.rsp-an-tile .rsp-an-delta { justify-self: start; }
.rsp-an-tile-val { display: flex; align-items: baseline; gap: 5px; }
.rsp-an-tile-val strong { font-size: 26px; line-height: 1.15; font-weight: 800; }
.rsp-an-tile-val small { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.rsp-an-foot { font-style: normal; font-size: 12px; color: var(--muted); }

/* ─── لمحات ─── */
.rsp-an-insights { display: flex; gap: 12px; align-items: flex-start; padding: 14px; margin-bottom: 12px; border-radius: var(--radius); background: var(--amber-50); border: 1px solid #F5DDA0; }
.rsp-an-ins-ico { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: #fff; color: var(--amber-800); flex: none; }
.rsp-an-insights ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 14px; font-weight: 700; color: var(--ink); }
.rsp-an-insights li::before { content: '•'; margin-left: 8px; color: var(--amber-800); }

/* ─── البطاقات ─── */
.rsp-an-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
@media (min-width: 900px) { .rsp-an-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .rsp-an-wide { grid-column: 1 / -1; } }
.rsp-an-card { padding: 16px; border-radius: var(--radius); background: var(--an-surface); border: 1px solid var(--line); min-width: 0; }
.rsp-an-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.rsp-an-card-head h3 { font-size: 16px; font-weight: 800; }
.rsp-an-card-head p { margin-top: 2px; font-size: 12.5px; color: var(--muted); }
.rsp-an-card-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.rsp-an-tool { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: var(--muted); border: 1px solid var(--line-2); background: #fff; }
.rsp-an-tool:hover { background: var(--cream); color: var(--ink); }
.rsp-an-tool.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }
.rsp-an-tool svg { width: 17px; height: 17px; }
.rsp-an-subbar { margin: -2px 0 12px; }
.rsp-an-seg { margin: 0; padding: 3px; max-width: 320px; }
.rsp-an-seg button { min-height: 32px; padding: 0 12px; font-size: 13px; }
.rsp-an-note { margin: 14px 2px 0; font-size: 13px; color: var(--muted); line-height: 1.8; }

/* ─── مخطط الأعمدة ─── */
.rsp-an-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; font-size: 13px; color: var(--ink-2); font-weight: 700; }
.rsp-an-legend span { display: inline-flex; align-items: center; gap: 6px; }
.rsp-an-key { display: inline-block; width: 12px; height: 4px; border-radius: 2px; background: var(--an-cur); flex: none; }
.rsp-an-key.is-prev { background: var(--an-prev); }
.rsp-an-key.is-none { background: transparent; width: 0; }
.rsp-an-plot { display: grid; grid-template-columns: auto 1fr; gap: 6px; outline: none; border-radius: 10px; }
.rsp-an-plot:focus-visible { box-shadow: 0 0 0 2px var(--red); }
.rsp-an-yaxis { display: flex; flex-direction: column; justify-content: space-between; height: 220px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: left; padding-left: 2px; direction: ltr; }
.rsp-an-area { position: relative; height: 244px; direction: rtl; }
.rsp-an-grid-lines { position: absolute; inset: 0 0 24px; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.rsp-an-grid-lines i { display: block; height: 1px; background: var(--an-grid); }
.rsp-an-cols { position: absolute; inset: 0 0 24px; display: flex; }
.rsp-an-col { position: relative; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; cursor: pointer; }
.rsp-an-bar { display: block; width: calc(100% - 2px); max-width: 24px; min-height: 0; border-radius: 4px 4px 0 0; background: var(--an-cur); transition: filter .12s ease, opacity .12s ease; align-self: center; }
.rsp-an-bar.is-zero { background: transparent; }
.rsp-an-col:hover .rsp-an-bar, .rsp-an-col.is-active .rsp-an-bar { filter: brightness(1.12) saturate(1.05); box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--red); }
.rsp-an-col::after { content: ''; position: absolute; inset: 0; border-radius: 6px; background: rgba(227, 38, 47, 0); transition: background .12s ease; pointer-events: none; }
.rsp-an-col:hover::after, .rsp-an-col.is-active::after { background: rgba(227, 38, 47, .05); }
.rsp-an-x { position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); font-style: normal; font-size: 11px; color: var(--muted); white-space: nowrap; }
.rsp-an-overlay { position: absolute; inset: 0 0 24px; width: 100%; height: calc(100% - 24px); pointer-events: none; overflow: visible; }

/* ─── الخريطة الحرارية ─── */
.rsp-an-heat { display: grid; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.rsp-an-heat-hours, .rsp-an-heat-grid { display: grid; gap: 2px; }
.rsp-an-heat-hours i { font-style: normal; font-size: 10.5px; color: var(--muted); white-space: nowrap; direction: rtl; overflow: visible; text-align: right; }
.rsp-an-day { align-self: center; font-size: 12px; color: var(--ink-2); font-weight: 700; }
.rsp-an-cell { display: block; aspect-ratio: 1; border-radius: 3px; outline: none; }
.rsp-an-cell.is-empty { background: #F6EFE9; }
.rsp-an-cell:hover, .rsp-an-cell:focus-visible { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink); position: relative; z-index: 1; }
.rsp-an-scale { display: flex; align-items: center; gap: 4px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.rsp-an-scale i { width: 22px; height: 10px; border-radius: 2px; }
.rsp-an-scale span:first-child { margin-left: 4px; }
.rsp-an-scale span:last-child { margin-right: 4px; }

/* ─── قوائم الترتيب ─── */
.rsp-an-rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.rsp-an-rank li { display: flex; align-items: center; gap: 10px; }
.rsp-an-rank-n { width: 18px; flex: none; text-align: center; font-size: 12.5px; font-weight: 800; color: var(--muted); }
.rsp-an-rank img, .rsp-an-noimg { width: 42px; height: 42px; border-radius: 11px; object-fit: cover; background: var(--line); flex: none; }
.rsp-an-rank-main { flex: 1; min-width: 0; display: grid; gap: 5px; }
.rsp-an-rank-line { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.rsp-an-rank-name { font-size: 14.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rsp-an-rank-line strong { font-size: 14px; font-weight: 800; white-space: nowrap; }
.rsp-an-track { display: block; height: 8px; border-radius: 4px; background: #F6EFE9; overflow: hidden; }
.rsp-an-track b { display: block; height: 100%; border-radius: 4px; background: var(--an-cur); min-width: 2px; transition: width .35s ease; }
.rsp-an-rank small { font-size: 12px; color: var(--muted); }

/* ─── الجدول الموازي ─── */
.rsp-an-tablewrap { overflow-x: auto; }
.rsp-an-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.rsp-an-table th, .rsp-an-table td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.rsp-an-table thead th { font-size: 12px; color: var(--muted); font-weight: 700; background: none; position: sticky; top: 0; }
.rsp-an-table tbody th { font-weight: 700; white-space: normal; }
.rsp-an-table td { font-variant-numeric: tabular-nums; }

/* ─── التلميح ─── */
.rsp-an-tip { position: fixed; z-index: 200; min-width: 150px; max-width: 260px; padding: 10px 12px; border-radius: 12px; background: var(--ink); color: #fff; font-family: 'Tajawal', system-ui, sans-serif; font-size: 13px; direction: rtl; text-align: right; box-shadow: 0 10px 30px rgba(20, 10, 5, .28); pointer-events: none; }
.rsp-an-tip-title { font-size: 12.5px; opacity: .78; margin-bottom: 6px; }
.rsp-an-tip-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.rsp-an-tip-row strong { font-size: 14.5px; font-weight: 800; }
.rsp-an-tip-row span { font-size: 12px; opacity: .8; }
.rsp-an-tip .rsp-an-key { background: #fff; }
.rsp-an-tip .rsp-an-key.is-prev { background: #C9BFB8; }

@media (max-width: 420px) {
	.rsp-an-hero-val strong { font-size: 44px; }
	.rsp-an-yaxis { font-size: 10.5px; }
}
@media (prefers-reduced-motion: reduce) {
	.rsp-an-body, .rsp-an-track b, .rsp-an-sync-bar b, .rsp-an-bar { transition: none; }
}
@media print {
	.rsp-an-filters, .rsp-an-card-tools, .rsp-an-sync { display: none; }
	.rsp-an-card, .rsp-an-hero, .rsp-an-tile { break-inside: avoid; box-shadow: none; }
}
