/* =====================================================
   TOKENS
===================================================== */
:root {
  --bg: #08080e;
  --bg-glow-a: #1a1030;
  --panel: #131320;
  --panel-2: #171727;
  --panel-soft: #0d0d17;
  --border: #22222f;
  --border-soft: #1b1b28;

  --text: #f4f3f9;
  --muted: #918fa3;
  --muted-2: #63617a;

  --purple: #7305b3;
  --purple-2: #5903a0;
  --purple-glow: rgba(209, 5, 250, 0.38);
  --teal: #02f8e0;
  --blue: #4f8cf7;
  --gold: #f7a604;
  --pink: #f80371;
  --green: #02f869;
  --red: #fd020b;

  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
}
input,
select {
  font-family: inherit;
}
h1,
h2,
h3,
p {
  margin: 0;
}
.muted {
  color: var(--muted);
}

/* ===================== TOKENS ===================== */
:root {
  --bg: #060a16;
  --bg-alt: hsl(225, 56%, 7%);
  --surface: #0d1428;
  --surface-2: #111a33;
  --border: #1b2440;
  --border-soft: #161f38;
  --purple: #6f03ad;
  --purple-2: #9941fd;
  --purple-deep: #6f029b98;
  --cyan: #06c2db;
  --text: #f3f5fb;
  --text-dim: #a6adc4;
  --text-mute: #6b738f;
  --green: #02fa72;
  --font: "Cairo", "Tajawal", sans-serif;
  --neon-green: #00ff88;
  --neon-glow: rgba(0, 255, 136, 0.25);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden !important;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  display: block;
}
a {
  text-decoration: none;
  color: inherit;
}
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
}
ul {
  list-style: none;
}

.hero__text {
  width: 100%;
  margin: 0 auto;
  padding: 20px 32px;
}

.hero__inner {
  height: 400px;
}

.container {
  max-width: 1800px;
  margin: 0 auto;
  padding: 0 30px;
}

.container-fluid {
  width: 100%;
  padding: 0 30px;
}

/* ===================== BUTTONS ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 10px;
  font-size: 14.5px;
  font-weight: 600;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease,
    border-color 0.15s ease;
  white-space: nowrap;
}
.btn svg {
  flex-shrink: 0;
}
.btn--primary {
  background: linear-gradient(
    135deg,
    var(--purple) 0%,
    var(--purple-deep) 100%
  );
  color: #fff;
  box-shadow: 0 8px 24px -8px rgba(124, 92, 255, 0.65);
  display: inline-flex;
}
.btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px -6px rgba(124, 92, 255, 0.8);
}
.btn--ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn--ghost:hover {
  border-color: var(--purple-2);
}
.btn--outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn--outline:hover {
  border-color: var(--purple-2);
  background: rgba(124, 92, 255, 0.06);
}
.btn--lg {
  padding: 14px 26px;
  font-size: 15.5px;
}
.btn--block {
  width: 100%;
  margin-top: 18px;
}

/* ===================== HEADER ===================== */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(6, 10, 22, 0.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 76px;
  gap: 24px;
  padding: 20px 30px;
  direction: ltr !important;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  width: 200px;
}
.brand__logo {
  width: 48px;
  height: 48px;
  border: 2px solid #8d2bdf;
  clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
  display: grid;
  place-items: center;
  color: #f8f7f8;
  font-weight: 800;
  font-size: 17px;
  background: rgb(104, 3, 236);
  flex-shrink: 0;
}

.nav {
  display: flex;
  align-items: center;
  gap: 30px;
  flex: 1;
  justify-content: center;
  direction: rtl !important;
}
.nav__link {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  transition: color 0.15s ease;
  position: relative;
  background: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0;
}
.nav__link:hover {
  color: var(--text);
}
.nav__link--active {
  color: var(--text);
}
.nav__link--active::after {
  content: "";
  position: absolute;
  right: 0;
  left: 0;
  bottom: -27px;
  height: 2px;
  background: linear-gradient(90deg, var(--purple), var(--cyan));
}
.header__actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.lang-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 4px;
}
.lang-switch .chev {
  opacity: 0.6;
}
.burger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  padding: 6px;
  flex-shrink: 0;
}
.burger span {
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all 0.2s ease;
}
.burger.is-open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.burger.is-open span:nth-child(2) {
  opacity: 0;
}
.burger.is-open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Buttons duplicated inside the mobile hamburger menu.
   Hidden everywhere by default; only revealed on small screens
   when the mobile nav is open (see the 860px media query). */
.nav__mobile-actions {
  display: none;
}
.nav__mobile-btn-wrap {
  display: block;
  width: 100%;
}

/* =====================================================
   PAGE / TITLE
===================================================== */
.page {
  max-width: 1536px;
  margin: 0 auto;
  padding: 1.9rem 2rem 3.4rem;
}

.title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.6rem;
}
.crumbs {
  font-size: 0.78rem;
  color: var(--muted-2);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.crumbs .cur {
  color: var(--purple);
  font-weight: 700;
}
.title-text h1 {
  font-size: clamp(1.3rem, 1rem + 1.2vw, 1.65rem);
  font-weight: 800;
  letter-spacing: -0.01em;
}
.title-sub {
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 0.45rem;
  max-width: 640px;
}
.title-icon {
  width: 54px;
  height: 54px;

  color: var(--purple);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.title-icon .icon-slot {
  width: 24px;
  height: 24px;
}

/* =====================================================
   STAT STRIP
===================================================== */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
  margin-bottom: 1.9rem;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 1.05rem 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}
.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-icon .icon-slot {
  width: 21px;
  height: 21px;
}
.stat-value {
  font-size: 1.28rem;
  font-weight: 800;
  line-height: 1.1;
}
.stat-label {
  font-size: 0.71rem;
  color: var(--muted-2);
  margin-top: 0.28rem;
  line-height: 1.35;
}

/* =====================================================
   DASH GRID  (left | main | right) — logical LTR order,
   text inside stays RTL
===================================================== */
.dash {
  display: grid;
  grid-template-columns: 254px 1fr 322px;
  gap: 1.5rem;
  direction: ltr;
}
.dash > * {
  direction: rtl;
  min-width: 0;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
}
.card.pad {
  padding: 1.15rem;
}
.rail-left .card + .card {
  margin-top: 1rem;
}
.rail-right .card + .card {
  margin-top: 1rem;
}

/* --------- Left rail: search + categories --------- */
.search-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  margin-bottom: 1rem;
}
.search-field .icon-slot {
  color: var(--muted-2);
}
.search-field input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  width: 100%;
  font-size: 0.85rem;
}
.search-field input::placeholder {
  color: var(--muted-2);
}

.rail-heading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.7rem;
  padding: 0 0.15rem;
}
.rail-heading.strong {
  font-size: 0.92rem;
  margin-bottom: 1.05rem;
}
.count-chip {
  margin-inline-start: auto;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--panel-soft);
  color: var(--muted);
  padding: 0.12rem 0.55rem;
  border-radius: var(--radius-pill);
}

.cat-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.62rem 0.7rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.25rem;
  font-size: 0.86rem;
  cursor: pointer;
  transition: background 0.15s;
}
.cat-list li:hover {
  background: var(--panel-2);
}
.cat-list li.active {
  background: linear-gradient(90deg, var(--purple-2), var(--purple));
  color: #fff;
  font-weight: 700;
}
.cat-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.cat-ico {
  width: 27px;
  height: 27px;
  border-radius: 8px;
  background: var(--panel-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.cat-list li.active .cat-ico {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}
.cat-ico .icon-slot {
  width: 14px;
  height: 14px;
}
.cat-num {
  font-size: 0.72rem;
  background: var(--panel-soft);
  color: var(--muted-2);
  padding: 0.08rem 0.5rem;
  border-radius: var(--radius-pill);
}
.cat-list li.active .cat-num {
  background: rgba(255, 255, 255, 0.24);
  color: #fff;
}

/* --------- Filter panel --------- */
.field-label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0.95rem 0 0.45rem;
  font-weight: 500;
}
.field-label:first-of-type {
  margin-top: 0;
}
.select-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.select-wrap select {
  appearance: none;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  width: 100%;
  padding: 0.55rem 2.1rem 0.55rem 0.8rem;
  font-size: 0.82rem;
}
.select-wrap .icon-slot {
  position: absolute;
  left: 0.7rem;
  color: var(--muted-2);
  pointer-events: none;
}
.select-wrap.sort {
  padding: 0.15rem 0.3rem 0.15rem 0.9rem;
  gap: 0.5rem;
  width: auto;
}
.select-wrap.sort select {
  width: auto;
  padding-inline-end: 1.8rem;
}
.select-wrap.sort .muted {
  font-size: 0.8rem;
  white-space: nowrap;
}

.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  outline: none;
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--purple);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.22);
  cursor: pointer;
}
.range::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: none;
  background: var(--purple);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.22);
  cursor: pointer;
}
.range-scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.71rem;
  color: var(--muted-2);
  margin-top: 0.4rem;
}

.btn-reset {
  width: 100%;
  margin-top: 1.2rem;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: var(--radius-sm);
  padding: 0.65rem;
  font-size: 0.82rem;
  font-weight: 600;
}
.btn-reset:hover {
  border-color: var(--red);
  color: var(--red);
}

/* =====================================================
   MAIN RAIL
===================================================== */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.05rem;
}
.section-head.lower {
  margin-top: 2.1rem;
}
.section-head h2 {
  font-size: 1.18rem;
  font-weight: 800;
}
.section-head h3 {
  font-size: 1.02rem;
  font-weight: 800;
}
.link-more {
  font-size: 0.8rem;
  color: var(--muted-2);
}
.link-more:hover {
  color: var(--purple);
}

.sector-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.1rem;
}

.sector-card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease;
}
.sector-card:hover {
  transform: translateY(-4px);
  border-color: rgba(139, 92, 246, 0.5);
}

.sector-media {
  position: relative;
  aspect-ratio: 13 / 7;
  overflow: hidden;
}
.sector-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(1.05);
}
.sector-media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0) 40%,
    rgba(19, 19, 32, 0.55) 100%
  );
}
.sector-badge {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  z-index: 2;
  font-size: 0.66rem;
  font-weight: 700;
  padding: 0.28rem 0.65rem;
  border-radius: var(--radius-pill);
  color: #fff;
  letter-spacing: 0.01em;
}
.badge-high {
  background: rgba(139, 92, 246, 0.92);
}
.badge-elevated {
  background: rgba(45, 212, 196, 0.92);
  color: #062c27;
}
.badge-medium {
  background: rgba(79, 140, 247, 0.92);
}

.sector-icon {
  position: absolute;
  bottom: 10px;
  right: 1rem;
  z-index: 2;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--panel);
  color: #fff;
}
.sector-icon .icon-slot {
  width: 18px;
  height: 18px;
}

.sector-body {
  padding: 1.55rem 1rem 0.95rem;
}
.sector-name {
  font-size: 1.03rem;
  font-weight: 800;
  margin-bottom: 0.35rem;
}
.sector-desc {
  font-size: 0.735rem;
  color: var(--muted-2);
  line-height: 1.55;
  min-height: 2.3em;
  margin-bottom: 0.9rem;
}

.sector-metrics {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.metric-block + .metric-block {
  margin-top: 0.55rem;
}
.metric-value {
  font-size: 1.06rem;
  font-weight: 800;
}
.metric-label {
  font-size: 0.65rem;
  color: var(--muted-2);
  margin-top: 0.05rem;
}

.ring {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ring-inner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.ring-score {
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1;
}
.ring-max {
  font-size: 0.55rem;
  color: var(--muted-2);
  font-weight: 500;
}

.sparkline {
  height: 42px;
  margin-bottom: 0.75rem;
}
.sparkline svg {
  width: 100%;
  height: 100%;
  display: block;
}

.sector-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px dashed var(--border);
  padding-top: 0.65rem;
  margin-bottom: 0.85rem;
  font-size: 0.71rem;
  color: var(--muted-2);
}
.foot-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.foot-item .icon-slot {
  width: 13px;
  height: 13px;
}
.risk-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.btn-detail {
  width: 100%;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.62rem;
  font-size: 0.82rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.btn-detail .icon-slot {
  width: 14px;
  height: 14px;
}
.btn-detail:hover {
  background: var(--purple);
  border-color: var(--purple);
  color: #fff;
}

/* --------- Opportunity strip --------- */
.opp-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.1rem;
}
.opp-card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  overflow: hidden;
  min-width: 0;
}
.opp-media {
  position: relative;
  aspect-ratio: 16 / 10;
}
.opp-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.opp-tag {
  position: absolute;
  top: 0.55rem;
  left: 0.55rem;
  font-size: 0.63rem;
  font-weight: 700;
  color: #fff;
  padding: 0.24rem 0.6rem;
  border-radius: var(--radius-pill);
}
.opp-body {
  padding: 0.85rem 0.9rem;
}
.opp-title {
  font-size: 0.87rem;
  font-weight: 700;
  margin-bottom: 0.1rem;
}
.opp-sub {
  font-size: 0.68rem;
  color: var(--muted-2);
  margin-bottom: 0.8rem;
}
.opp-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.opp-value {
  font-size: 0.86rem;
  font-weight: 800;
}
.opp-label {
  font-size: 0.63rem;
  color: var(--muted-2);
  margin-top: 0.05rem;
}
.opp-ring {
  width: 42px;
  height: 42px;
}
.opp-ring-inner {
  width: 33px;
  height: 33px;
}
.opp-ring-inner .ring-score {
  font-size: 0.68rem;
}

/* =====================================================
   RIGHT RAIL
===================================================== */
.panel-title {
  font-size: 0.95rem;
  font-weight: 800;
  margin-bottom: 1rem;
}

.donut-wrap {
  position: relative;
  width: 172px;
  height: 172px;
  margin: 0 auto 1.1rem;
}
.donut-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
}
.donut-center b {
  font-size: 1.3rem;
  font-weight: 800;
}
.donut-center span {
  font-size: 0.65rem;
  color: var(--muted-2);
}

.legend-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.1rem;
  font-size: 0.82rem;
}
.legend-left {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend-pct {
  font-weight: 700;
}

.growth-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.62rem 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.83rem;
}
.growth-list li:last-child {
  border-bottom: none;
}
.growth-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.growth-ico {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.growth-ico .icon-slot {
  width: 14px;
  height: 14px;
}
.growth-pct {
  color: var(--green);
  font-weight: 700;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.growth-pct .icon-slot {
  width: 12px;
  height: 12px;
}

.btn-outline-purple {
  width: 100%;
  margin-top: 0.9rem;
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid var(--purple);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 0.65rem;
  font-size: 0.83rem;
  font-weight: 700;
}
.btn-outline-purple:hover {
  background: var(--purple);
}

.ai-card {
  background:
    linear-gradient(
      160deg,
      rgba(139, 92, 246, 0.16),
      rgba(19, 19, 32, 0.2) 60%
    ),
    var(--panel);
  border: 1px solid rgba(139, 92, 246, 0.4);
}
.ai-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0;
}
.ai-badge {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--purple), var(--purple-2));
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ai-head .panel-title {
  margin-bottom: 0;
}
.ai-text {
  font-size: 0.82rem;
  line-height: 1.75;
  color: #d9d6ea;
  margin: 0.9rem 0 1rem;
}
.btn-ai {
  width: 100%;
  background: linear-gradient(135deg, var(--purple), var(--purple-2));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.68rem;
  font-size: 0.84rem;
  font-weight: 700;
}
.btn-ai .icon-slot {
  width: 15px;
  height: 15px;
}

/* =====================================================
   RESPONSIVE
===================================================== */
@media (max-width: 1180px) {
  .dash {
    grid-template-columns: 220px 1fr;
  }
  .rail-right {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
  }
  .rail-right .card + .card {
    margin-top: 0;
  }
  /* rail-right cards are now narrower (1/3 of the row), so shrink the
     donut so it never gets cramped against the legend below it */
  .donut-wrap {
    width: 140px;
    height: 140px;
  }
}
@media (max-width: 980px) {
  .stat-strip {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }
  .sector-grid,
  .opp-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .dash {
    grid-template-columns: 1fr;
  }
  .rail-left {
    order: 2;
  }
  .rail-main {
    order: 1;
  }
  .rail-right {
    order: 3;
    grid-template-columns: 1fr;
  }
  .main-nav {
    display: none;
  }
  /* main-nav just disappeared above, so the burger must appear here —
     not further down at 620px, or there is no way to navigate at all
     between this breakpoint and that one */
  .burger {
    display: flex;
  }
}
@media (max-width: 620px) {
  .page {
    padding: 1.4rem 1rem 2.4rem;
  }
  .stat-strip {
    grid-template-columns: repeat(2, 1fr);
  }
  .sector-grid,
  .opp-grid {
    grid-template-columns: 1fr;
  }
  .topbar-inner {
    padding: 0.7rem 1rem;
    gap: 1rem;
  }
  .nav-actions .btn-outline {
    display: none;
  }
  .title-row {
    flex-direction: column-reverse;
    gap: 1rem;
  }
  .select-wrap.sort {
    flex-wrap: wrap;
  }
}

/* Very small phones: single column everywhere, tighter spacing so
   nothing gets cramped or forces horizontal scrolling */
@media (max-width: 420px) {
  .stat-strip {
    grid-template-columns: 1fr;
  }
  .title-icon {
    width: 44px;
    height: 44px;
  }
  .title-icon .icon-slot {
    width: 20px;
    height: 20px;
  }
  .donut-wrap {
    width: 150px;
    height: 150px;
  }
  .brand-text {
    font-size: 0.85rem;
  }
}

/* =====================================================
   MOBILE
===================================================== */

@media (max-width: 768px) {
  .topbar {
    height: 64px;
  }

  .topbar-inner {
    padding: 0 16px;
  }

  /* Hide desktop elements */

  .desktop-nav,
  .top-actions {
    display: none;
  }

  /* Brand */

  .dlogo {
    width: 36px;
    height: 36px;

    font-size: 20px;
  }

  .brand-text strong {
    font-size: 15px;
  }

  .brand-text small {
    font-size: 8px;
  }

  /* Hamburger */

  .burger {
    display: flex;
  }

  /* Mobile dropdown */

  .mobile-nav {
    position: absolute;

    top: calc(100% + 8px);
    left: 12px;
    right: 12px;

    display: flex;
    flex-direction: column;

    padding: 10px;

    background: linear-gradient(
      145deg,
      rgba(8, 14, 28, 0.98),
      rgba(5, 10, 22, 0.98)
    );

    border: 1px solid rgba(92, 105, 139, 0.22);

    border-radius: 14px;

    box-shadow:
      0 20px 45px rgba(0, 0, 0, 0.45),
      0 0 25px rgba(91, 33, 182, 0.08);

    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);

    opacity: 0;
    visibility: hidden;

    transform: translateY(-8px);

    transition:
      opacity 0.25s ease,
      transform 0.25s ease,
      visibility 0.25s ease;
  }

  /* Open state */

  .mobile-nav.show {
    opacity: 1;
    visibility: visible;

    transform: translateY(0);
  }

  /* Links */

  .mobile-nav a {
    min-height: 47px;

    display: flex;
    align-items: center;

    gap: 13px;

    padding: 0 13px;

    border-radius: 9px;

    color: #8995ad;

    text-decoration: none;

    font-size: 13px;
    font-weight: 500;

    transition:
      background 0.2s ease,
      color 0.2s ease;
  }

  .mobile-nav a i {
    width: 20px;

    text-align: center;

    font-size: 16px;

    color: #74819a;
  }

  .mobile-nav a:hover {
    color: #fff;

    background: rgba(124, 58, 237, 0.08);
  }

  .mobile-nav a:hover i {
    color: #a78bfa;
  }

  /* Active */

  .mobile-nav a.active {
    color: #fff;

    background: linear-gradient(
      90deg,
      rgba(124, 58, 237, 0.16),
      rgba(34, 211, 238, 0.04)
    );

    border: 1px solid rgba(124, 58, 237, 0.14);
  }

  .mobile-nav a.active i {
    color: #a78bfa;
  }

  /* Divider */

  .mobile-divider {
    height: 1px;

    margin: 9px 4px;

    background: rgba(100, 115, 145, 0.14);
  }

  /* Account */

  .mobile-account {
    display: flex;
    align-items: center;

    gap: 11px;

    padding: 10px 8px 7px;
  }

  .mobile-account .avatar {
    width: 36px;
    height: 36px;
  }

  .mobile-account > div:last-child {
    display: flex;
    flex-direction: column;

    line-height: 1.1;
  }

  .mobile-account strong {
    color: #e8edf7;

    font-size: 11px;
  }

  .mobile-account small {
    margin-top: 4px;

    color: #65728b;

    font-size: 9px;
  }
}

/* =====================================================
   VERY SMALL PHONES
===================================================== */

@media (max-width: 380px) {
  .topbar-inner {
    padding: 0 12px;
  }

  .brand-text small {
    display: none;
  }

  .mobile-nav {
    left: 8px;
    right: 8px;
  }
}

/* ---- Mobile nav / burger breakpoint (desktop untouched above 860px) ---- */
@media (max-width: 860px) {
  .header__actions {
    display: none;
  }
  .nav {
    display: flex;
    position: absolute;
    top: calc(100% + 10px);
    right: 16px;
    left: 16px;
    width: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    background: linear-gradient(
      160deg,
      rgba(9, 15, 30, 0.98),
      rgba(5, 9, 20, 0.98)
    );
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    padding: 14px 16px 18px;
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    box-shadow: 0 24px 50px -12px rgba(0, 0, 0, 0.55);

    /* Smooth reveal instead of an abrupt display:none/flex swap,
       and no inner scrollbar under normal use. */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-10px) scale(0.98);
    transform-origin: top center;
    transition:
      opacity 0.22s ease,
      transform 0.22s ease,
      visibility 0.22s ease;
    max-height: calc(100vh - 96px);
    overflow-y: auto;
    overscroll-behavior: contain;
    z-index: 45;
  }
  .nav.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
  }
  .nav__link {
    width: 100%;
    padding: 13px 6px;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-soft);
    font-size: 13px;
  }
  .nav__link--active::after {
    display: none;
  }

  .nav__pages {
    width: 100%;
  }
  .nav__pages-trigger {
    width: 100%;
  }
  .mega {
    position: static;
    transform: none;
    min-width: 0;
    width: 100%;
    grid-template-columns: 1fr;
    gap: 4px;
    box-shadow: none;
    border-color: var(--border-soft);
    background: var(--surface-2);
    margin-top: 6px;
    display: none;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
  .nav__pages.is-open .mega {
    display: grid;
  }
  .mega__col a {
    padding: 9px 4px;
  }

  /* Login / Explore buttons, moved out of the header and shown
     full-width inside the hamburger menu on mobile only. */
  .nav__mobile-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
    padding-top: 14px;
  }
  .nav__mobile-actions .lang-switch {
    justify-content: center;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
  }
  .nav__mobile-actions .btn--block {
    margin-top: 0;
    width: 100%;
  }
}

/* Extra safety for very narrow phones so the dropdown never
   touches the viewport edges or overlaps the burger/logo. */
@media (max-width: 380px) {
  .header__inner {
    padding: 16px 16px;
  }
  .brand {
    width: auto;
  }
  .nav {
    right: 10px;
    left: 10px;
    padding: 12px 12px 16px;
  }
}
