:root {
  --bg: #09090b;
  --panel: #18181b;
  --line: #27272a;
  --line-light: #3f3f46;
  --text: #fafafa;
  --text-dim: #a1a1aa;
  --blue: #3b82f6;
  --purple: #8b5cf6;
  --green: #10b981;
  --red: #ef4444;
  --orange: #f59e0b;
  --dim: #52525b;
}
* { box-sizing: border-box; }
/* Fix: native <option> elements ignore the parent <select>'s dark background in
   some browsers and render white-on-white when the dropdown is opened/unfocused.
   Force a dark background + light text on every option/select in the app. */
select, .form-input { color-scheme: dark; }
select option, .form-input option { background: var(--panel); color: var(--text); }
body { margin: 0; background: var(--bg); color: var(--text); font-family: "Inter", -apple-system, sans-serif; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
.shell { display: flex; min-height: 100vh; }
.mt-4 { margin-top: 16px; }
.hover-glow { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; transition: border-color 0.3s ease, transform 0.2s ease; }
.hover-glow::before { content: ""; position: absolute; top: 0; left: 0; right: 0; bottom: 0; border-radius: inherit; background: radial-gradient( 600px circle at var(--mouse-x, -100%) var(--mouse-y, -100%), rgba(255, 255, 255, 0.05), transparent 40% ); z-index: 0; pointer-events: none; opacity: 0; transition: opacity 0.5s ease; }
.hover-glow:hover::before { opacity: 1; }
.hover-glow > * { position: relative; z-index: 1; }
.view-section { opacity: 0; transform: translateY(10px); transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1); pointer-events: none; }
.view-section.active-view { opacity: 1; transform: translateY(0); pointer-events: auto; }
.sidebar { width: 220px; flex-shrink: 0; border-right: 1px solid var(--line); border-radius: 0; display: flex; flex-direction: column; background: rgba(24, 24, 27, 0.6); backdrop-filter: blur(12px); }
.sidebar-brand { padding: 24px 16px; border-bottom: 1px solid var(--line); text-align: center; }
.brand-title { font-size: 13px; font-weight: 700; color: #fff; white-space: nowrap; background: linear-gradient(135deg, var(--blue), var(--purple)); padding: 8px 12px; border-radius: 6px; display: inline-block; letter-spacing: 0.5px; text-shadow: 0 1px 2px rgba(0,0,0,0.3); }
.sidebar-nav { display: flex; flex-direction: column; padding: 16px 8px; flex: 1; }
.nav-item { display: flex; align-items: center; padding: 10px 12px; border-radius: 6px; font-size: 13px; font-weight: 500; color: var(--text-dim); cursor: pointer; margin-bottom: 4px; text-decoration: none; transition: all 0.2s; }
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.nav-item.active { background: rgba(59, 130, 246, 0.15); color: var(--blue); border-left: 3px solid var(--blue); border-radius: 0 6px 6px 0; }
.nav-caret { margin-left: auto; font-size: 10px; transition: transform 0.2s ease; }
.nav-caret.rotate { transform: rotate(180deg); }
.nav-submenu { display: flex; flex-direction: column; padding-left: 32px; gap: 4px; margin-bottom: 8px; }
.nav-item-sub { padding: 8px 10px; border-radius: 6px; font-size: 12px; color: var(--text-dim); cursor: pointer; text-decoration: none; transition: color 0.2s; }
.nav-item-sub:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.nav-item-sub.active { color: var(--text); font-weight: 600; }
.sidebar-footer { padding: 16px; border-top: 1px solid var(--line); font-size: 11px; color: var(--text-dim); font-family: 'JetBrains Mono', monospace; text-transform: uppercase; letter-spacing: 0.5px; }
.main { flex: 1; display: flex; flex-direction: column; overflow-x: hidden; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; background: rgba(24, 24, 27, 0.8); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-title { display: flex; flex-direction: column; min-width: 220px; }
.topbar-title h1 { margin: 0; font-size: 18px; font-weight: 700; color: var(--text); letter-spacing: -0.3px; }
.topbar-title p { margin: 4px 0 0 0; font-size: 12px; color: var(--text-dim); }
.ticker { flex: 1; overflow: hidden; position: relative; height: 18px; margin: 0 24px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); padding: 0 10px; }
.ticker-track { position: absolute; white-space: nowrap; font-size: 11px; color: var(--blue); font-family: 'JetBrains Mono', monospace; text-transform: uppercase; animation: scroll-left 35s linear infinite; font-weight: 600; letter-spacing: 1px; }
@keyframes scroll-left { from { transform: translateX(0%); } to { transform: translateX(-50%); } }
.topbar-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.filter-group select { padding: 6px 12px; border: 1px solid var(--line); border-radius: 6px; outline: none; font-family: inherit; color: var(--text); background: var(--bg); cursor: pointer; font-size: 12px; transition: border-color 0.2s; }
.filter-group select:hover { border-color: var(--line-light); }
.date-filter-input { padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; outline: none; font-family: inherit; color: var(--text); background: var(--bg); cursor: pointer; font-size: 12px; transition: border-color 0.2s; color-scheme: dark; }
.date-filter-input:hover { border-color: var(--line-light); }
.date-filter-input.active-range { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.btn { font-family: inherit; font-size: 12px; font-weight: 600; padding: 6px 14px; border-radius: 6px; border: none; cursor: pointer; transition: all 0.2s ease; letter-spacing: 0.3px; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.btn-outline { background: transparent; border: 1px solid var(--line-light); color: var(--text); }
.btn-outline:hover { background: rgba(255,255,255,0.05); border-color: var(--text); }
.btn-primary { background: var(--blue); color: #fff; box-shadow: 0 0 10px rgba(59,130,246,0.3); }
.btn-primary:hover { box-shadow: 0 0 15px rgba(59,130,246,0.5); }
.btn.small { padding: 4px 10px; font-size: 11px; }
.content { padding: 24px; }
.metrics-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.metric-card { padding: 20px; display: flex; flex-direction: column; }
.metric-card:hover { border-color: rgba(255,255,255,0.2); transform: translateY(-2px); }
.metric-card.highlight-card { border: 1px solid rgba(245, 158, 11, 0.4); box-shadow: 0 0 15px rgba(245, 158, 11, 0.05); }
.metric-title { font-size: 12px; color: var(--text-dim); font-weight: 600; margin-bottom: 12px; display: flex; justify-content: space-between; text-transform: uppercase; letter-spacing: 0.5px; }
.metric-value { font-size: 26px; font-weight: 800; color: var(--text); font-family: "Inter", sans-serif; letter-spacing: -0.5px; }
.metric-sub { font-size: 11px; margin-top: 6px; font-weight: 500; }
.text-red { color: var(--red) !important; }
.text-green { color: var(--green) !important; text-shadow: 0 0 10px rgba(16, 185, 129, 0.2); }
.text-blue { color: var(--blue) !important; text-shadow: 0 0 10px rgba(59, 130, 246, 0.2); }
.text-purple { color: var(--purple) !important; }
.text-orange { color: var(--orange) !important; }
.text-light { color: var(--text) !important; }
.text-dim { color: var(--text-dim) !important; }
.font-bold { font-weight: 600; }
.font-mono { font-family: 'JetBrains Mono', monospace; font-size: 11px; letter-spacing: 0.5px; }
.center { text-align: center !important; }
.charts-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; margin-bottom: 16px; }
.leaderboard-section { display: grid; grid-template-columns: 1fr; }
.panel { padding: 20px; }
.panel-head-modern { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.panel-title-wrapper { border-left: 3px solid var(--blue); padding-left: 14px; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.panel-title-wrapper.border-purple { border-left-color: var(--purple); }
.panel-title-wrapper.border-green { border-left-color: var(--green); }
.panel-title-wrapper.border-orange { border-left-color: var(--orange); }
.panel-title-wrapper.border-red { border-left-color: #ef4444; }
.panel-title-wrapper h2 { margin: 0; font-size: 15px; font-weight: 600; color: var(--text); letter-spacing: -0.2px; }
.panel-title-wrapper p { margin: 0; font-size: 12px; color: var(--text-dim); }
.chart-container { position: relative; height: 280px; width: 100%; }
.summary-panel { background: linear-gradient(135deg, rgba(15,23,42,0.8) 0%, rgba(30,41,59,0.8) 100%); padding: 24px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 20px; }
.summary-info h2 { margin: 0 0 6px 0; font-size: 18px; font-weight: 700; color: var(--text); }
.summary-info p { margin: 0; font-size: 12px; color: var(--text-dim); }
.summary-metrics { display: flex; gap: 32px; }
.sm-box { display: flex; flex-direction: column; gap: 6px; }
.sm-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; font-family: 'JetBrains Mono', monospace; }
.sm-value { font-size: 22px; font-weight: 800; color: var(--text); }
.summary-progress-wrapper { flex: 1; min-width: 250px; background: rgba(0,0,0,0.2); padding: 14px 18px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.05); }
.sp-header { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 10px; color: var(--text); font-weight: 600; text-transform: uppercase; }
.table-controls { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; justify-content: flex-end; margin-left: auto; }
.table-controls input { font-family: inherit; font-size: 12px; padding: 8px 12px; border-radius: 6px; border: 1px solid var(--line); background: rgba(0,0,0,0.2); color: var(--text); min-width: 220px; transition: border-color 0.2s, box-shadow 0.2s; }
.table-controls input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px rgba(59,130,246,0.2); }
.table-controls input.filter-number { min-width: 90px; }
.table-controls select.filter-select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background: rgba(0,0,0,0.2) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%23a1a1aa' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>") no-repeat right 10px center;
  border: 1px solid var(--line); border-radius: 6px; color: var(--text);
  padding: 8px 28px 8px 12px; font-family: inherit; font-size: 12px; font-weight: 600;
  cursor: pointer; min-width: 130px; transition: border-color 0.2s, box-shadow 0.2s;
}
.table-controls select.filter-select:hover { border-color: var(--line-light); }
.table-controls select.filter-select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px rgba(59,130,246,0.2); }
.rt-feedback-cell { display: flex; flex-direction: column; gap: 6px; min-width: 210px; }
.rt-feedback-view { font-size: 11px; color: var(--text-dim); line-height: 1.4; max-height: 48px; overflow-y: auto; white-space: pre-wrap; }
.rt-feedback-view.rt-feedback-empty { font-style: italic; opacity: 0.6; }
.rt-feedback-write { display: flex; gap: 6px; }
.rt-feedback-input { flex: 1; font-family: inherit; font-size: 11px; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--line); background: rgba(0,0,0,0.2); color: var(--text); min-width: 0; }
.rt-feedback-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px rgba(59,130,246,0.2); }
.rt-feedback-send { white-space: nowrap; }
.rt-feedback-send.is-saving { opacity: 0.6; pointer-events: none; }
.rt-feedback-status { font-size: 10px; }
.rt-feedback-status.ok { color: var(--green); }
.rt-feedback-status.err { color: var(--red); }
.table-footer { display: flex; align-items: center; justify-content: space-between; padding: 16px 6px 0; font-size: 12px; color: var(--text-dim); border-top: 1px solid var(--line); margin-top: 16px; font-weight: 500; }
.pager { display: flex; align-items: center; gap: 12px; }
.leaderboard-list { list-style: none; padding: 0; margin: 0; }
.leaderboard-item { display: flex; align-items: center; padding: 12px 10px; border-bottom: 1px solid var(--line); transition: background 0.2s; border-radius: 6px; }
.leaderboard-item:hover { background: rgba(255,255,255,0.03); }
.leaderboard-item:last-child { border-bottom: none; }
.lb-rank { width: 24px; height: 24px; background: rgba(255,255,255,0.1); border-radius: 4px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; margin-right: 12px; color: var(--text); }
.lb-rank.gold { background: rgba(250, 204, 21, 0.2); color: #facc15; box-shadow: 0 0 10px rgba(250, 204, 21, 0.1); border: 1px solid rgba(250, 204, 21, 0.3); }
.lb-name { flex: 1; font-size: 13px; font-weight: 600; color: var(--text); }
.lb-stats { text-align: right; }
.lb-ndr { font-weight: 800; color: var(--green); font-size: 14px; }
.lb-orders { font-size: 10px; color: var(--text-dim); font-family: 'JetBrains Mono', monospace; }
.table-responsive { overflow-x: auto; margin-top: 8px; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; white-space: nowrap; }
.seg-section-row td { background: rgba(139,92,246,0.08); color: #a78bfa; font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; padding: 10px 14px; border-bottom: 1px solid var(--line-light); }
.seg-sections-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.seg-section-card { min-width: 0; }
.seg-section-card .data-table th, .seg-section-card .data-table td { padding: 8px 10px; font-size: 11.5px; }
.seg-section-card .panel-head-modern { padding: 12px 14px; }
.seg-section-card h3 { font-size: 13px; margin: 0; color: var(--text); font-weight: 700; }
.seg-total-card .data-table th, .seg-total-card .data-table td { padding: 10px 14px; font-size: 12px; }
@media (max-width: 900px) {
  .seg-sections-grid { grid-template-columns: 1fr; }
}
.data-table th, .data-table td { padding: 12px 14px; font-size: 12px; border-bottom: 1px solid var(--line); transition: background 0.15s; }
.data-table th { color: var(--text-dim); font-weight: 600; border-bottom: 1px solid var(--line-light); text-align: left; cursor: pointer; user-select: none; text-transform: uppercase; font-size: 10.5px; letter-spacing: 0.5px; }
.data-table th:hover { color: var(--text); }
.data-table th.sorted { color: var(--blue); border-bottom-color: var(--blue); }
.data-table th.num, .data-table td.num { text-align: right; }
.data-table .truncate-cell { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-table th.truncate-cell { max-width: 180px; }
.data-table tbody tr:hover td { background: rgba(255,255,255,0.03); }
/* Purchase Cohort Tracker — تمييز الأسبوع المختار حاليًا في فلتر "Week" فوق
   (Weekly Inventory & Inbound Filters)، من غير أي فلترة فعلية للجدول. */
.data-table tbody tr.wi-cohort-row-selected td { background: rgba(59,130,246,0.1); border-left: 2px solid var(--blue); }
.data-table tbody tr.wi-cohort-row-selected:hover td { background: rgba(59,130,246,0.15); }
/* الصف الإضافي اللي بيمثل رينج فلتر "Purchase Start/End" الحر — بنفسجي عشان
   يتفرق عن تمييز الأسبوع المختار (أزرق) وباقي الصفوف العادية. */
.data-table tbody tr.wi-cohort-row-custom td { background: rgba(167,139,250,0.12); border-left: 2px solid #a78bfa; }
.data-table tbody tr.wi-cohort-row-custom:hover td { background: rgba(167,139,250,0.18); }
/* CM3 Analyst Products — Daily/Weekly breakdown: هوية كل عمود Period (يوم أو
   أسبوع) بتتنقل من خلال العنوان (header) + شريط خفيف تحته وتينت خلفية باهت
   جدًا للخلية — مش من تلوين كل رقم بلون مشبع زي الأول (ده اللي كان بيبان
   "غريب"/متعب للعين لما 8 أعمدة مختلفة (عدد/نسبة/فلوس) كلهم بنفس اللون
   الصارخ). الأرقام نفسها فضلت بلون النص العادي عشان تفضل مريحة وسهلة القراءة. */
.data-table th.cm3ap-pcol-0 { color: var(--blue); border-bottom: 2px solid rgba(59,130,246,0.5); }
.data-table th.cm3ap-pcol-1 { color: var(--purple); border-bottom: 2px solid rgba(139,92,246,0.5); }
.data-table th.cm3ap-pcol-2 { color: var(--green); border-bottom: 2px solid rgba(16,185,129,0.5); }
.data-table th.cm3ap-pcol-3 { color: var(--orange); border-bottom: 2px solid rgba(245,158,11,0.5); }
.data-table td.cm3ap-pcol-0 { background: rgba(59,130,246,0.045); color: var(--text); }
.data-table td.cm3ap-pcol-1 { background: rgba(139,92,246,0.045); color: var(--text); }
.data-table td.cm3ap-pcol-2 { background: rgba(16,185,129,0.045); color: var(--text); }
.data-table td.cm3ap-pcol-3 { background: rgba(245,158,11,0.045); color: var(--text); }
.data-table td.cm3ap-pcol-0 span.text-dim, .data-table td.cm3ap-pcol-1 span.text-dim, .data-table td.cm3ap-pcol-2 span.text-dim, .data-table td.cm3ap-pcol-3 span.text-dim { color: var(--text-dim); }
.data-table tbody tr:hover td.cm3ap-pcol-0 { background: rgba(59,130,246,0.09); }
.data-table tbody tr:hover td.cm3ap-pcol-1 { background: rgba(139,92,246,0.09); }
.data-table tbody tr:hover td.cm3ap-pcol-2 { background: rgba(16,185,129,0.09); }
.data-table tbody tr:hover td.cm3ap-pcol-3 { background: rgba(245,158,11,0.09); }
.badge-outline { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; border: 1px solid currentColor; font-family: 'JetBrains Mono', monospace; }
.badge-outline.green { color: #10b981; background: rgba(16,185,129,0.1); }
.badge-outline.blue { color: #3b82f6; background: rgba(59,130,246,0.1); }
.badge-outline.orange { color: #f59e0b; background: rgba(245,158,11,0.1); }
.badge-outline.red { color: #ef4444; background: rgba(239,68,68,0.1); }
.badge-outline.purple { color: #a78bfa; background: rgba(167,139,250,0.1); }
.badge-outline.yellow { color: #eab308; background: rgba(234,179,8,0.1); }
.badge-outline.gray { color: #94a3b8; background: rgba(148,163,184,0.1); }
.badge-status { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 4px; font-size: 11px; font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.badge-status.spike { background: rgba(16,185,129,0.15); color: #34d399; border: 1px solid rgba(16,185,129,0.2); }
.badge-status.stable { background: rgba(255,255,255,0.05); color: var(--text-dim); border: 1px solid rgba(255,255,255,0.1); }
.badge-status.decline { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.2); }
.text-change.positive { color: #34d399; font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.text-change.negative { color: #f87171; font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.text-change.neutral { color: var(--text-dim); font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.seg-badge { display: inline-block; padding: 4px 10px; border-radius: 4px; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; }
.seg-champions { background: rgba(245,158,11,0.15); color: #fbbf24; border: 1px solid rgba(245,158,11,0.3); box-shadow: 0 0 10px rgba(245,158,11,0.1); }
.seg-loyal { background: rgba(59,130,246,0.15); color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
.seg-potential { background: rgba(99,102,241,0.15); color: #818cf8; border: 1px solid rgba(99,102,241,0.3); }
.seg-promising { background: rgba(168,85,247,0.15); color: #c084fc; border: 1px solid rgba(168,85,247,0.3); }
.seg-occasional { background: rgba(249,115,22,0.15); color: #fb923c; border: 1px solid rgba(249,115,22,0.3); }
.seg-lowvalue { background: rgba(244,63,94,0.15); color: #fb7185; border: 1px solid rgba(244,63,94,0.3); }
.seg-inactive { background: rgba(255,255,255,0.05); color: #94a3b8; border: 1px solid rgba(255,255,255,0.1); }
.loading-state, .error-state { text-align: center; padding: 60px; }
.spinner { width: 30px; height: 30px; border: 3px solid rgba(255,255,255,0.1); border-top-color: var(--blue); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 16px; box-shadow: 0 0 15px rgba(59,130,246,0.4); }
@keyframes spin { 100% { transform: rotate(360deg); } }
.loading-state p { color: var(--blue); font-family: 'JetBrains Mono', monospace; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.error-state p { color: #fca5a5; font-weight: 600; margin-bottom: 16px; background: rgba(239,68,68,0.1); padding: 12px; border-radius: 6px; border: 1px solid rgba(239,68,68,0.2); }
.toast { position: fixed; bottom: 24px; right: 24px; background: rgba(16,185,129,0.9); backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,0.2); color: #fff; padding: 12px 20px; border-radius: 6px; font-size: 12px; font-weight: 600; box-shadow: 0 10px 25px rgba(0,0,0,0.5); animation: toast-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); z-index: 50; }
@keyframes toast-in { from { opacity: 0; transform: translateY(20px) scale(0.9); } to { opacity: 1; transform: translateY(0) scale(1); } }
.progress-bar { background-color: rgba(255,255,255,0.05); border-radius: 4px; height: 6px; width: 100%; overflow: hidden; margin-top: 6px; border: 1px solid rgba(255,255,255,0.05); }
.progress-bar.lg { height: 8px; border: none; background: rgba(0,0,0,0.3); }
.progress-fill { height: 100%; border-radius: 4px; transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1); position: relative; }
.progress-fill::after { content: ""; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent); animation: shimmer 2s infinite; }
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
.progress-fill.blue { background-color: var(--blue); box-shadow: 0 0 10px rgba(59,130,246,0.5); }
.progress-fill.green { background-color: var(--green); box-shadow: 0 0 10px rgba(16,185,129,0.5); }
.progress-fill.orange { background-color: var(--orange); box-shadow: 0 0 10px rgba(245,158,11,0.5); }
.progress-fill.red { background-color: var(--red); box-shadow: 0 0 10px rgba(239,68,68,0.5); }
.progress-fill.dim { background-color: var(--dim); }
.progress-fill.purple { background-color: var(--purple); box-shadow: 0 0 10px rgba(139,92,246,0.5); }
.cm3-toolbar { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; padding: 16px 20px; margin-bottom: 20px; }
.cm3-toolbar-group { display: flex; align-items: center; gap: 10px; }
.cm3-toolbar-label { font-size: 10.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.cm3-toolbar-range { margin-left: auto; font-size: 12px; color: var(--text-dim); font-family: 'JetBrains Mono', monospace; }
.segmented { display: inline-flex; background: rgba(0,0,0,0.25); border: 1px solid var(--line); border-radius: 8px; padding: 3px; gap: 2px; }
.segmented-btn { font-family: inherit; font-size: 11.5px; font-weight: 600; padding: 6px 12px; border-radius: 6px; border: none; background: transparent; color: var(--text-dim); cursor: pointer; transition: all 0.2s ease; letter-spacing: 0.2px; }
.segmented-btn:hover { color: var(--text); }
.segmented-btn.active { background: var(--blue); color: #fff; box-shadow: 0 0 10px rgba(59,130,246,0.35); }
.cm3-metrics-grid { grid-template-columns: repeat(4, 1fr); }
.badge-status.turned-positive, .badge-status.stayed-positive { background: rgba(16,185,129,0.15); color: #34d399; border: 1px solid rgba(16,185,129,0.2); }
.badge-status.turned-negative, .badge-status.stayed-negative { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.2); }
.badge-status.became-zero { background: rgba(148,163,184,0.15); color: #cbd5e1; border: 1px solid rgba(148,163,184,0.2); }
.badge-status.new-match { background: rgba(59,130,246,0.15); color: #60a5fa; border: 1px solid rgba(59,130,246,0.2); }
.cm3-period-cell { font-family: 'JetBrains Mono', monospace; font-weight: 700; color: var(--text); letter-spacing: 0.3px; }
/* بادجات الستاتس القابلة للدوس عليها في جدول CM3 Target — بتفتح قسم الدريل
   داون تحت الجدول (cm3DrilldownSection) بتفاصيل الـ Matches اللي مكوّنة الرقم. */
.cm3-badge-clickable { cursor: pointer; transition: transform 0.12s ease, box-shadow 0.12s ease; }
.cm3-badge-clickable:hover { transform: translateY(-1px) scale(1.05); box-shadow: 0 0 0 1px currentColor; }
#cm3DrilldownSection .panel-title-wrapper h2 { color: #fbbf24; }
.contr-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 800; font-family: 'JetBrains Mono', monospace; }
.contr-pill.ok { background: rgba(16,185,129,0.15); color: #34d399; border: 1px solid rgba(16,185,129,0.25); }
.contr-pill.warn { background: rgba(245,158,11,0.15); color: #fbbf24; border: 1px solid rgba(245,158,11,0.25); }
.contr-pill.bad { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.25); }

/* Download Modal CSS */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-content { background: var(--panel); border: 1px solid var(--line); padding: 24px; border-radius: 8px; width: 450px; max-width: 90%; box-shadow: 0 10px 25px rgba(0,0,0,0.5); }
.modal-content h3 { margin-top: 0; margin-bottom: 16px; color: var(--text); font-size: 16px; }
.radio-label { display: block; margin-bottom: 10px; cursor: pointer; color: var(--text-dim); font-size: 13px; }
.radio-label input { margin-right: 8px; }
.radio-label:hover { color: var(--text); }
.modal-actions { margin-top: 24px; display: flex; justify-content: flex-end; gap: 12px; }

@media (max-width: 1100px) {
  .cm3-metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .cm3-toolbar-range { margin-left: 0; }
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(255,255,255,0.25); }
/* Sellthrough Rate Filters — dropdowns */
.st-filter-select { padding: 8px 12px; border-radius: 6px; background: var(--panel); color: var(--text); border: 1px solid var(--line); font-family: inherit; font-size: 12px; cursor: pointer; transition: border-color 0.2s; }
.st-filter-select:hover { border-color: var(--line-light); }
.st-filter-select:focus { outline: none; border-color: var(--blue); }

/* Sellthrough Summary Sections (Confirmed / Delivered) — mirrors the "Summary" tab */
.st-summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .st-summary-grid { grid-template-columns: 1fr; } }
.st-summary-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.st-summary-table th { color: var(--text-dim); font-weight: 600; text-transform: uppercase; font-size: 9.5px; letter-spacing: 0.4px; text-align: right; padding: 8px 6px; border-bottom: 1px solid var(--line-light); white-space: nowrap; }
.st-summary-table th:first-child, .st-summary-table td:first-child { text-align: left; }
.st-summary-table td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; font-family: 'JetBrains Mono', monospace; }
.st-summary-table tr.st-grand-total td { font-weight: 700; color: var(--text); border-top: 1px solid var(--line-light); background: rgba(255,255,255,0.03); }
.st-summary-table td.st-rate { color: var(--purple); font-weight: 700; }
.st-summary-table td.st-inbound { color: var(--green); font-weight: 700; }

/* خلية اسم الستاتيوس (Placed/Confirmed — Status): التكست نفسه ملوّن من غير
   أي مربع/بوردر حواليه، ورينج % بخط Inter صغير ودّي تحته — بدل الفونت
   المونوسبيس الافتراضي بتاع باقي الأعمدة الرقمية في الجدول ده. */
.st-summary-table td.st-status-cell { white-space: normal; vertical-align: middle; padding-top: 8px; padding-bottom: 8px; }
.st-status-label { font-family: "Inter", -apple-system, sans-serif; font-size: 12.5px; font-weight: 700; letter-spacing: 0.1px; }
.st-status-label.green { color: #10b981; }
.st-status-label.blue { color: #3b82f6; }
.st-status-label.orange { color: #f59e0b; }
.st-status-label.red { color: #ef4444; }
.st-status-label.purple { color: #a78bfa; }
.st-status-label.yellow { color: #eab308; }
.st-status-label.gray { color: #94a3b8; }
.st-status-range { margin-top: 4px; font-family: "Inter", -apple-system, sans-serif; font-size: 10px; font-weight: 500; color: var(--text-dim); letter-spacing: 0.2px; }
.st-status-total-label { font-family: "Inter", -apple-system, sans-serif; font-weight: 700; color: var(--text); font-size: 12px; }

/* Sellthrough Progress Overlay */
#viewSellthroughPanel { position: relative; }

.st-progress-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(9, 9, 11, 0.85); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; border-radius: 8px;
}
.st-progress-box {
  background: var(--panel); border: 1px solid var(--blue);
  padding: 24px; border-radius: 8px; width: 320px; text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}
.st-progress-box h3 { margin: 0 0 16px; font-size: 14px; color: var(--text); }
.st-progress-text { 
  margin-top: 10px; font-size: 13px; color: var(--blue); 
  font-weight: bold; font-family: 'JetBrains Mono', monospace; 
}
/* CM3 Analyst / Products — Pipeline & Insights cards */
.cm3ap-insights-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px;
}
.cm3ap-insight-card {
  background: rgba(255,255,255,0.02); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px;
}
.cm3ap-insight-card h4 { margin: 0 0 10px; font-size: 12px; letter-spacing: 0.2px; color: var(--text); }
.cm3ap-insight-card ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cm3ap-insight-card li { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cm3ap-insight-name { font-size: 10.5px; color: var(--text-dim); opacity: 0.8; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* CM3 Analyst / Products — dark, styled dropdown (fixes native white/ugly select) */
.cm3-toolbar-group select.cm3ap-select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background: rgba(0,0,0,0.25) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%23a1a1aa' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>") no-repeat right 12px center;
  border: 1px solid var(--line); border-radius: 8px; color: var(--text);
  padding: 8px 32px 8px 14px; font-family: inherit; font-size: 12px; font-weight: 600;
  cursor: pointer; min-width: 160px; transition: border-color 0.2s, box-shadow 0.2s;
}
.cm3-toolbar-group select.cm3ap-select:hover { border-color: var(--line-light); }
.cm3-toolbar-group select.cm3ap-select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px rgba(59,130,246,0.2); }

/* Products Breakdown table — keep new columns from blowing up the section width */
#cm3apTable th, #cm3apTable td { white-space: nowrap; }
#cm3apTable .truncate-cell { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#cm3apTable { font-size: 11.5px; }
#cm3apTable th, #cm3apTable td { padding: 10px 10px; }

/* Pipeline & Insights — funnel chart */
.cm3ap-pipeline-chart-wrap { margin-bottom: 18px; }
.cm3ap-pipeline-chart-wrap .chart-container { height: 220px; }
.cm3ap-pipeline-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.cm3ap-pipeline-stat { flex: 1; min-width: 140px; background: rgba(255,255,255,0.02); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.cm3ap-pipeline-stat .k { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dim); font-weight: 700; }
.cm3ap-pipeline-stat .v { font-size: 16px; font-weight: 700; margin-top: 4px; }
.cm3ap-pipeline-stat .sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* Top Movers section (Top 4 Drops / Top 4 Positive) */
.cm3ap-movers-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.cm3ap-mover-col h4 { margin: 0 0 12px; font-size: 12px; letter-spacing: 0.2px; }
.cm3ap-mover-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.cm3ap-mover-row:last-child { border-bottom: none; }
.cm3ap-mover-rank { font-size: 11px; color: var(--text-dim); font-family: 'JetBrains Mono', monospace; width: 16px; flex-shrink: 0; }
.cm3ap-mover-info { flex: 1; min-width: 0; }
.cm3ap-mover-sku { font-size: 12px; font-weight: 700; font-family: 'JetBrains Mono', monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm3ap-mover-name { font-size: 11px; font-weight: 500; font-family: "Inter", -apple-system, sans-serif; color: var(--text-dim); opacity: 0.85; }
.cm3ap-mover-cat { font-size: 10.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm3ap-mover-bar-track { height: 5px; border-radius: 3px; background: rgba(255,255,255,0.06); margin-top: 5px; overflow: hidden; }
.cm3ap-mover-bar-fill { height: 100%; border-radius: 3px; }
.cm3ap-mover-value { font-size: 12px; font-weight: 700; flex-shrink: 0; white-space: nowrap; }

/* Search box duplicated inside Pipeline & Insights / Products Breakdown panel heads */
.cm3ap-search-slot { display: flex; gap: 8px; flex-wrap: wrap; }

/* Forecast Model (Admin Panel) */
#viewForecastModel { position: relative; }
.fc-data-status { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; font-size: 12px; }
.fc-kpi-grid { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-top: 16px; }
.fc-trend-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 20px; align-items: center; margin-top: 12px; }
@media (max-width: 1100px) { .fc-trend-grid { grid-template-columns: 1fr; } }
.fc-method summary { cursor: pointer; font-size: 13px; color: var(--text); list-style: none; }
.fc-method summary::-webkit-details-marker { display: none; }
.fc-method summary::before { content: "▸ "; color: var(--text-dim); }
.fc-method[open] summary::before { content: "▾ "; }
.fc-method-body { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.fc-method-body p { margin: 0; font-size: 12.5px; line-height: 1.55; color: var(--text-dim); }
.fc-method-body strong { color: var(--text); }
