/* ── رادار السوق ─────────────────────────────────────────────────────── */

.radar-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.5rem 0 1rem;
  flex-wrap: wrap;
}
.radar-head h1 { font-size: 1.6rem; font-weight: 800; margin: 0; }
.radar-head .rh-accent { color: var(--primary-500); }
.radar-head .rh-sub { color: var(--neutral-500); font-size: 0.88rem; margin: 0.15rem 0 0; }
.rh-asof {
  font-size: 0.8rem; color: var(--neutral-500); font-weight: 600;
  background: #fff; border: 1px solid var(--neutral-200);
  border-radius: 20px; padding: 0.3rem 0.9rem; white-space: nowrap;
}
.rh-asof b { color: var(--primary-500); }

/* KPIs */
.radar-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.8rem;
  margin-bottom: 0.9rem;
}
.rk-card {
  background: #fff; border: 1px solid var(--neutral-200);
  border-radius: var(--radius-lg); padding: 0.85rem 1.1rem;
}
.rk-k { font-size: 0.78rem; font-weight: 700; color: var(--neutral-500); }
.rk-v { font-size: 1.55rem; font-weight: 800; color: var(--neutral-800, #2A2840); line-height: 1.2; }
.rk-d { font-size: 0.75rem; font-weight: 600; color: var(--neutral-500); }
.rk-d.rk-up { color: #D6335A; font-weight: 800; }
.rk-hero { background: linear-gradient(135deg, var(--primary-500) 0%, var(--accent-300) 100%); border: 0; }
.rk-hero .rk-k { color: #c9cfff; }
.rk-hero .rk-v { color: #fff; font-size: 1.25rem; }
.rk-hero .rk-d { color: #FFB3C4; font-weight: 800; font-size: 0.85rem; }

/* Controls */
.radar-controls {
  display: flex; align-items: center; gap: 0.9rem;
  margin-bottom: 0.9rem; flex-wrap: wrap;
}
.rc-label { font-size: 0.78rem; font-weight: 700; color: var(--neutral-500); }
.rc-seg {
  display: flex; background: #fff; border: 1.5px solid var(--neutral-200);
  border-radius: 10px; overflow: hidden;
}
.rc-seg button {
  border: 0; background: transparent; font-family: inherit;
  font-size: 0.82rem; font-weight: 700; color: var(--neutral-500);
  padding: 0.42rem 0.95rem; cursor: pointer;
}
.rc-seg button.on { background: var(--primary-500); color: #fff; }
.rc-seg.rc-orange button.on { background: #EB4A6C; }

/* Layout */
.radar-wrap {
  display: grid;
  grid-template-columns: 1fr 310px;
  gap: 0.9rem;
  align-items: start;
}
/* منع انفجار الغريد: المحتوى العريض ينسحب داخل بطاقته بدل توسيع الصفحة */
.radar-wrap > * { min-width: 0; }
.radar-matrix-card { min-width: 0; }

/* Matrix */
.rm-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.6rem; }
.rm-head h2 { font-size: 1.05rem; margin: 0; }
.rm-hint { font-size: 0.72rem; color: var(--neutral-500); font-weight: 600; }
.rm-scroll { overflow-x: auto; }
.rm-table { width: 100%; border-collapse: separate; border-spacing: 4px; min-width: 560px; }
.rm-table th {
  font-size: 0.75rem; font-weight: 800; color: var(--neutral-500);
  padding: 0.2rem 0.3rem; text-align: center;
}
.rm-table th.rm-area-h { text-align: right; }
.rm-table td.rm-area {
  font-size: 0.82rem; font-weight: 800; white-space: nowrap;
  padding-left: 0.5rem; text-align: right;
}
.rm-cell {
  border-radius: 10px; padding: 0.4rem 0.5rem; text-align: center;
  background: #f6f5f1; border: 1.5px solid transparent;
  cursor: pointer; min-width: 92px; transition: transform 0.08s ease;
}
.rm-cell:hover { transform: scale(1.04); }
.rm-cell .n { font-size: 1.02rem; font-weight: 800; }
.rm-cell .meta { font-size: 0.63rem; font-weight: 700; color: var(--neutral-500); }
.rm-cell .mom { font-size: 0.68rem; font-weight: 800; direction: ltr; color: var(--neutral-500); }
.rm-cell.st-hot { background: #fdedf1; border-color: #f6b9c8; }
.rm-cell.st-hot .mom { color: #c22a4d; }
.rm-cell.st-surge { background: #fdedf1; border-color: #EB4A6C; box-shadow: 0 0 0 1px #EB4A6C; }
.rm-cell.st-surge .mom { color: #D6335A; }
.rm-cell.st-cool { background: #eaf2fd; }
.rm-cell.st-cool .mom { color: #3573d9; }
.rm-cell.rm-empty {
  background: #fafafa; color: #c9c9d4; font-weight: 800;
  border: 1.5px dashed #eee; cursor: default;
}
.rm-cell.rm-empty:hover { transform: none; }
.rm-cell.rm-sel { outline: 3px solid var(--primary-500); outline-offset: 1px; }
.rm-cell.rm-dim { opacity: 0.42; }
.rm-table th.sel { color: var(--primary-500); }

/* value/deals color scale (metric modes) */
.rm-cell.q1 { background: #f2f4fd; }
.rm-cell.q2 { background: #dfe5fb; }
.rm-cell.q3 { background: #c3cdf6; }
.rm-cell.q4 { background: #9cabf0; }
.rm-cell.q4 .meta, .rm-cell.q4 .mom { color: var(--primary-800); }

.rm-legend {
  display: flex; gap: 0.9rem; align-items: center; flex-wrap: wrap;
  margin-top: 0.6rem; font-size: 0.7rem; font-weight: 700; color: var(--neutral-500);
}
.rm-legend .sw {
  display: inline-block; width: 18px; height: 11px; border-radius: 3px;
  vertical-align: -1px; margin-left: 4px;
}
.sw-surge { background: #fdedf1; border: 1.5px solid #EB4A6C; }
.sw-hot { background: #fdedf1; border: 1.5px solid #f6b9c8; }
.sw-norm { background: #f6f5f1; }
.sw-cool { background: #eaf2fd; }
.sw-empty { background: #fafafa; border: 1.5px dashed #ddd; }
.rm-note {
  font-size: 0.68rem; color: var(--neutral-500); font-weight: 600;
  margin-top: 0.55rem; border-top: 1px dashed var(--neutral-200); padding-top: 0.45rem;
  line-height: 1.7;
}

/* Side panel */
.radar-panel { display: flex; flex-direction: column; gap: 0.9rem; }
.radar-panel .card { margin: 0; }
.radar-panel h3 { font-size: 0.9rem; margin: 0 0 0.5rem; }

.rp-d-head { display: flex; justify-content: space-between; align-items: center; }
.rp-d-name { font-size: 1.1rem; font-weight: 800; }
.rp-d-name small { font-size: 0.75rem; color: var(--neutral-500); font-weight: 700; }
.rp-d-badge {
  background: #fdedf1; color: #c22a4d; font-weight: 800; font-size: 0.85rem;
  border-radius: 8px; padding: 0.15rem 0.6rem; direction: ltr;
}
.rp-d-badge.cool { background: #eaf2fd; color: #3573d9; }
.rp-d-rows { margin-top: 0.5rem; }
.rp-d-rows .r {
  display: flex; justify-content: space-between; font-size: 0.8rem;
  font-weight: 600; color: var(--neutral-500);
  padding: 0.35rem 0; border-bottom: 1px solid var(--neutral-100);
}
.rp-d-rows .r b { color: var(--neutral-800, #2A2840); font-weight: 800; }
.rp-d-verdict {
  margin-top: 0.6rem; border-radius: 8px; padding: 0.35rem 0.7rem;
  text-align: center; font-weight: 800; font-size: 0.78rem;
  background: #f6f5f1; color: var(--neutral-500);
}
.rp-d-verdict.surge { background: #fdedf1; color: #c22a4d; }
.rp-d-verdict.cool { background: #eaf2fd; color: #1c5fbf; }

.rp-reading { background: linear-gradient(135deg, var(--primary-500) 0%, var(--accent-300) 100%); border: 0; }
.rp-reading h3 { color: #fff; }
.rp-reading p { font-size: 0.8rem; line-height: 1.9; font-weight: 600; color: #e8ebff; margin: 0; }

.rp-movers .m {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.35rem 0; border-bottom: 1px solid var(--neutral-100);
}
.rp-movers .m:last-child { border-bottom: 0; }
.rp-movers .a { font-size: 0.8rem; font-weight: 800; }
.rp-movers .a small { display: block; font-size: 0.66rem; color: var(--neutral-500); font-weight: 600; }
.rp-movers .chip {
  font-size: 0.76rem; font-weight: 800; border-radius: 7px;
  padding: 0.05rem 0.5rem; direction: ltr;
}
.rp-movers .chip.up { background: #fdedf1; color: #c22a4d; }
.rp-movers .chip.dn { background: #e7f0fd; color: #1c5fbf; }
.rp-m-down { margin-top: 0.8rem !important; }
.rp-empty { font-size: 0.75rem; color: var(--neutral-500); font-weight: 600; }

/* Tabs */
.rc-tabs {
  display: flex; background: #fff; border: 1.5px solid var(--neutral-200);
  border-radius: 10px; overflow: hidden;
}
.rc-tabs button {
  border: 0; background: transparent; font-family: inherit;
  font-size: 0.88rem; font-weight: 800; color: var(--neutral-500);
  padding: 0.45rem 1.2rem; cursor: pointer;
}
.rc-tabs button.on { background: var(--primary-500); color: #fff; }

/* ── Treemap (بنية السوق) ── */
.tm-typebar { display: flex; gap: 0.5rem; margin-bottom: 0.6rem; flex-wrap: wrap; }
.tm-chip {
  flex: 1; min-width: 130px; display: flex; align-items: center; gap: 0.5rem;
  background: #fff; border: 1.5px solid var(--neutral-200); border-radius: 10px;
  padding: 0.4rem 0.7rem; cursor: pointer; transition: border-color 0.12s;
}
.tm-chip:hover { border-color: var(--primary-500); }
.tm-chip.active { border-color: var(--primary-500); box-shadow: 0 0 0 1.5px var(--primary-500); }
.tm-chip .dot { width: 12px; height: 12px; border-radius: 4px; flex-shrink: 0; }
.tm-chip .tn { font-size: 0.8rem; font-weight: 800; }
.tm-chip .tv { font-size: 0.68rem; font-weight: 600; color: var(--neutral-500); margin-right: auto; white-space: nowrap; }

#tmCanvas { position: relative; width: 100%; height: 560px; }
.tm-node {
  position: absolute; overflow: hidden; cursor: pointer;
  border-radius: 8px; padding: 0.4rem 0.55rem; color: #fff;
  transition: filter 0.1s ease;
}
.tm-node:hover { filter: brightness(1.08); z-index: 5; }
.tm-node.light { color: var(--neutral-800, #2A2840); }
.tm-node .nm { font-size: 0.78rem; font-weight: 800; line-height: 1.3; }
.tm-node .vl { font-size: 0.66rem; font-weight: 600; opacity: 0.8; }
.tm-node .surge-badge {
  position: absolute; top: 5px; left: 5px;
  background: #fff; color: #D6335A; font-size: 0.66rem; font-weight: 900;
  border-radius: 6px; padding: 0 5px; box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}
.tm-tooltip {
  position: fixed; z-index: 50; display: none; pointer-events: none;
  background: #fff; border: 1px solid var(--neutral-200); border-radius: 12px;
  box-shadow: 0 8px 28px rgba(5,16,80,0.18); padding: 0.7rem 0.9rem; min-width: 220px;
}
.tm-tooltip .t-name { font-size: 0.88rem; font-weight: 900; }
.tm-tooltip .t-row {
  display: flex; justify-content: space-between; font-size: 0.74rem;
  font-weight: 600; color: var(--neutral-500); padding: 0.12rem 0;
}
.tm-tooltip .t-row b { color: var(--neutral-800, #2A2840); font-weight: 800; }
.tm-tooltip .t-surge { margin-top: 0.3rem; font-size: 0.72rem; font-weight: 800; color: #D6335A; }

/* بلوكات المستوى الأول (نوع لكل بلوك) */
.tm-type-block { border-radius: 14px; padding: 1.1rem 1.2rem; display: flex; flex-direction: column; }
.tm-type-block .tt-name { font-size: 1.5rem; font-weight: 900; }
.tm-type-block .tt-share { font-size: 2.6rem; font-weight: 900; line-height: 1.1; opacity: 0.95; }
.tm-type-block .tt-val { font-size: 0.85rem; font-weight: 700; opacity: 0.85; margin-top: 0.2rem; }
.tm-type-block .tt-top { font-size: 0.78rem; font-weight: 600; opacity: 0.75; margin-top: auto; line-height: 1.6; }
.tm-type-block .tt-cta { font-size: 0.72rem; font-weight: 800; opacity: 0.65; margin-top: 0.3rem; }
.tm-type-block:hover { filter: brightness(1.06); }

/* Responsive */
@media (max-width: 900px) {
  .radar-wrap { grid-template-columns: 1fr; }
  .radar-kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  /* keep the area column readable while the matrix scrolls horizontally */
  .rm-table td.rm-area, .rm-table th.rm-area-h {
    position: sticky; right: 0; z-index: 2;
    background: #fff;
    box-shadow: -6px 0 8px -6px rgba(0,0,0,0.12);
    font-size: 0.74rem;
    max-width: 96px; white-space: normal; line-height: 1.3;
  }
  .rm-cell { min-width: 76px; padding: 0.32rem 0.35rem; }
  .rm-cell .n { font-size: 0.95rem; }
  .rm-cell .meta { font-size: 0.58rem; }
  .rm-cell .mom { font-size: 0.62rem; }
}
@media (max-width: 480px) {
  .radar-kpis { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .rk-v { font-size: 1.2rem; }
  .radar-head h1 { font-size: 1.25rem; }
  #tmCanvas { height: 460px; }
  .tm-chip { min-width: calc(50% - 0.25rem); }
}
