/* ==========================================================================
   IRRadar — dashboard styles
   ========================================================================== */

@font-face {
  font-family: "Parsico";
  src: url("../fonts/parsico.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-sans: "Parsico", "Segoe UI", Tahoma, system-ui, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, monospace;

  --bg: #070b14;
  --bg-soft: #0b1120;
  --surface: rgba(17, 24, 39, 0.62);
  --surface-solid: #0f172a;
  --line: rgba(148, 163, 184, 0.14);
  --line-strong: rgba(148, 163, 184, 0.28);
  --text: #e6edf7;
  --text-soft: #9fb0c7;
  --text-mute: #64748b;

  --cyan: #22d3ee;
  --violet: #a78bfa;
  --amber: #fbbf24;
  --rose: #fb7185;
  --emerald: #34d399;
  --sky: #60a5fa;
  --slate: #94a3b8;

  --c-vless: #22d3ee;
  --c-vmess: #a78bfa;
  --c-reality: #34d399;
  --c-trojan: #fbbf24;
  --c-ss: #fb7185;

  --brand: var(--cyan);
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 20px 50px -28px rgba(0, 0, 0, 0.85);
  --glow-cyan: rgba(34, 211, 238, 0.28);
  --glow-violet: rgba(167, 139, 250, 0.28);
  --glow-amber: rgba(251, 191, 36, 0.26);
  --glow-rose: rgba(251, 113, 133, 0.26);
}

html[data-theme="light"] {
  --bg: #eef2f8;
  --bg-soft: #f7f9fc;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-solid: #ffffff;
  --line: rgba(15, 23, 42, 0.1);
  --line-strong: rgba(15, 23, 42, 0.2);
  --text: #0f172a;
  --text-soft: #45556d;
  --text-mute: #7b8aa1;

  --cyan: #0891b2;
  --violet: #7c3aed;
  --amber: #b45309;
  --rose: #e11d48;
  --emerald: #059669;
  --sky: #2563eb;
  --slate: #64748b;

  --c-vless: #0891b2;
  --c-vmess: #7c3aed;
  --c-reality: #059669;
  --c-trojan: #b45309;
  --c-ss: #e11d48;

  --shadow: 0 18px 40px -30px rgba(15, 23, 42, 0.45);
  --glow-cyan: rgba(8, 145, 178, 0.16);
  --glow-violet: rgba(124, 58, 237, 0.16);
  --glow-amber: rgba(180, 83, 9, 0.14);
  --glow-rose: rgba(225, 29, 72, 0.14);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
  background: radial-gradient(1200px 700px at 85% -10%, var(--glow-cyan), transparent 60%),
              radial-gradient(900px 600px at 0% 10%, var(--glow-violet), transparent 55%),
              var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3 { margin: 0; line-height: 1.35; font-weight: 800; letter-spacing: -0.01em; }
p { margin: 0; }
button { font-family: inherit; }

.muted { color: var(--text-soft); font-size: 13px; }

/* Background grid ---------------------------------------------------------- */
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, #000 30%, transparent 75%);
  opacity: 0.55;
  pointer-events: none;
}

.wrap {
  width: min(1240px, 100% - 40px);
  margin-inline: auto;
}

/* Topbar ------------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  border-bottom: 1px solid var(--line);
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 66px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.brand__mark { width: 40px; height: 40px; flex: none; }
.brand__mark svg { width: 100%; height: 100%; }
.brand__ring { fill: none; stroke: var(--brand); stroke-opacity: 0.35; stroke-width: 1.6; }
.brand__dot { fill: var(--brand); }
.brand__sweep {
  stroke: var(--brand);
  stroke-width: 2.4;
  stroke-linecap: round;
  transform-origin: 20px 20px;
  animation: sweep 3.2s linear infinite;
}
@keyframes sweep { to { transform: rotate(360deg); } }

.brand__text { display: grid; line-height: 1.25; }
.brand__text strong { font-size: 16px; font-weight: 800; }
.brand__text strong span { color: var(--brand); }
.brand__text small { color: var(--text-mute); font-size: 11.5px; }

.topbar__actions { display: flex; align-items: center; gap: 10px; }

.live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 12px;
  color: var(--text-soft);
  white-space: nowrap;
}

.live__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 0 var(--glow-amber);
}
.live.is-live .live__dot { background: var(--emerald); animation: pulse 2s ease-out infinite; }
.live.is-error .live__dot { background: var(--rose); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 11px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  transition: color .18s, border-color .18s, transform .18s, background .18s;
}
.icon-btn:hover { color: var(--text); border-color: var(--brand); transform: translateY(-1px); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.is-spinning svg { animation: spin 1s linear infinite; }
.icon-btn.is-active { color: var(--brand); border-color: var(--brand); }

.today-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-soft);
  white-space: nowrap;
}
.today-chip svg {
  width: 15px; height: 15px;
  fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round;
}
@keyframes spin { to { transform: rotate(360deg); } }

html[data-theme="light"] .icon-sun { display: none; }
html:not([data-theme="light"]) .icon-moon { display: none; }

/* Hero --------------------------------------------------------------------- */
.main { padding-block: 34px 60px; }

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.28em;
  color: var(--brand);
  margin-bottom: 10px;
}

.hero h1 { font-size: clamp(26px, 3.4vw, 40px); margin-bottom: 10px; }

.lede { color: var(--text-soft); max-width: 62ch; font-size: 15px; }

.pillbar {
  display: inline-flex;
  gap: 4px;
  padding: 5px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.pill {
  border: 0;
  background: transparent;
  color: var(--text-soft);
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: color .18s, background .18s, box-shadow .18s;
}
.pill:hover { color: var(--text); }
.pill.is-active {
  color: #04121a;
  background: linear-gradient(135deg, var(--cyan), #38bdf8);
  box-shadow: 0 8px 24px -12px var(--cyan);
}
html[data-theme="light"] .pill.is-active { color: #fff; }

/* Cards -------------------------------------------------------------------- */
.card {
  position: relative;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(160deg, var(--line-strong), transparent 42%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* KPI row ------------------------------------------------------------------ */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 30px;
}

.kpi {
  padding: 18px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
  transition: transform .2s ease, border-color .2s ease;
}
.kpi:hover { transform: translateY(-3px); border-color: var(--line-strong); }

.kpi::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--kpi-color, var(--cyan)), transparent);
  opacity: .9;
}
.glow-cyan { --kpi-color: var(--cyan); }
.glow-amber { --kpi-color: var(--amber); }
.glow-rose { --kpi-color: var(--rose); }
.glow-violet { --kpi-color: var(--violet); }

.kpi__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.kpi__label { font-size: 13px; color: var(--text-soft); font-weight: 600; }
.kpi__unit { font-family: var(--font-mono); font-size: 11px; color: var(--text-mute); direction: ltr; }
.kpi__suffix {
  font-size: 0.55em;
  font-weight: 400;
  color: var(--text-mute);
  margin-inline-start: 6px;
  font-family: var(--font-mono);
}

.kpi__value {
  font-family: var(--font-mono);
  font-size: clamp(26px, 2.6vw, 34px);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.25;
  transition: color .2s;
  /* Numbers are Latin; keep "1,366 ms" instead of RTL reordering to "ms 1,366". */
  direction: ltr;
  unicode-bidi: isolate;
  text-align: start;
}
html[dir="rtl"] .kpi__value { text-align: right; }

.kpi__delta { font-size: 12px; color: var(--text-mute); min-height: 20px; display: flex; align-items: center; gap: 6px; }
.kpi__delta .up::before { content: "▲ "; color: var(--rose); font-size: 10px; }
.kpi__delta .down::before { content: "▼ "; color: var(--emerald); font-size: 10px; }
.kpi__delta .flat::before { content: "■ "; color: var(--text-mute); font-size: 9px; }
.kpi__delta .good { color: var(--emerald); }
.kpi__delta .bad { color: var(--rose); }

.kpi__spark { height: 42px; margin-top: 2px; }
.kpi__spark svg { width: 100%; height: 100%; display: block; overflow: visible; }

.skeleton {
  color: transparent !important;
  background: linear-gradient(90deg, var(--line) 25%, var(--line-strong) 37%, var(--line) 63%);
  background-size: 400% 100%;
  border-radius: 8px;
  animation: shimmer 1.4s ease infinite;
  width: 56%;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* Sections ----------------------------------------------------------------- */
.section { margin-top: 38px; }

.section__head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.section__head h2 { font-size: 19px; white-space: nowrap; }
.section__head h2 span {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--text-mute);
  margin-inline-start: 8px;
  text-transform: uppercase;
}
.section__rule { flex: 1; height: 1px; background: linear-gradient(90deg, var(--line-strong), transparent); }

.info-btn {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text-soft);
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  transition: border-color .18s, color .18s;
}
.info-btn:hover, .info-btn[aria-expanded="true"] { color: var(--brand); border-color: var(--brand); }

.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 16px; }

/* Chart cards -------------------------------------------------------------- */
.chart-card { padding: 18px 18px 12px; }

.chart-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.chart-card__head h3 { font-size: 15px; }
.chart-card__head p { margin-top: 2px; }

.badge {
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--text-soft);
  background: color-mix(in srgb, var(--surface-solid) 60%, transparent);
  white-space: nowrap;
}

.chart {
  position: relative;
  height: 260px;
  direction: ltr;
  /* Tooltips are positioned inside the chart, so keep them from widening the page. */
  overflow: hidden;
}
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }

.chart .grid-line { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis-label {
  fill: var(--text-mute);
  font-family: var(--font-mono);
  font-size: 10px;
}
.chart .line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  transition: opacity .18s;
}
.chart .line.is-dim { opacity: .12; }
.chart .area { opacity: .16; }
.chart .hover-line { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .dot { stroke: var(--surface-solid); stroke-width: 1.5; }
.chart .no-data {
  fill: var(--text-mute);
  font-family: var(--font-sans);
  font-size: 12px;
}
.chart.is-drawing .line {
  stroke-dasharray: var(--len);
  stroke-dashoffset: var(--len);
  animation: draw 1.1s cubic-bezier(.4, 0, .2, 1) forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }

.chart-tip {
  position: absolute;
  z-index: 5;
  min-width: 160px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--surface-solid) 92%, transparent);
  box-shadow: var(--shadow);
  font-size: 12px;
  pointer-events: none;
  direction: rtl;
  transform: translate(-50%, -110%);
  opacity: 0;
  visibility: hidden;
  transition: opacity .12s, visibility .12s;
}
.chart-tip.is-visible { opacity: 1; visibility: visible; }
.chart-tip__time { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-mute); margin-bottom: 6px; direction: ltr; text-align: right; }
.chart-tip__row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.chart-tip__name { display: inline-flex; align-items: center; gap: 6px; color: var(--text-soft); }
.chart-tip__name i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.chart-tip__val { font-family: var(--font-mono); color: var(--text); font-weight: 600; direction: ltr; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-soft);
  font-size: 12px;
  cursor: pointer;
  transition: opacity .18s, border-color .18s, background .18s, color .18s;
}
.chip i {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--chip-color);
  box-shadow: 0 0 8px var(--chip-color);
}
.chip:hover { border-color: var(--line-strong); color: var(--text); }
.chip.is-dim { opacity: .38; }
.chip .chip__logo { width: 20px; height: 20px; border-radius: 6px; }
.chip .chip__logo svg { width: 17px; height: 17px; }

/* Protocol mix ------------------------------------------------------------- */
.proto { padding: 6px 0 4px; margin-bottom: 16px; }

.proto__bar {
  display: flex;
  height: 30px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface);
  gap: 2px;
}
.proto__seg {
  flex: 0 0 0;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c1) 92%, #fff 2%), var(--c1));
  transition: flex-basis .9s cubic-bezier(.4, 0, .2, 1), filter .18s;
  position: relative;
}
.proto__seg:hover { filter: brightness(1.18); }
.proto__seg span {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: #031018;
  font-weight: 600;
}

.proto__keys {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}
.proto__keys li {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-soft);
}
.proto__keys li i { width: 10px; height: 10px; border-radius: 3px; background: var(--c1); }
.proto__keys li b { font-family: var(--font-mono); color: var(--text); font-weight: 600; direction: ltr; }

/* Misery heatmap ----------------------------------------------------------- */
.misery-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  /* Stretch both columns so the heatmap card and the help panel share
     exactly the same height. */
  align-items: stretch;
}

.chart-card--heat {
  padding-bottom: 14px;
  display: flex;
  flex-direction: column;
}

.heat-scale { display: inline-flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-mute); white-space: nowrap; }
.heat-scale__grad {
  display: block; width: 110px; height: 8px; border-radius: 999px;
  background: linear-gradient(90deg, #5c1414, #9b1c1c, #dc2626, #f97316, #fde047);
}

.heat { position: relative; direction: ltr; }

.heat__row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  height: 34px;
}
.heat__label {
  font-size: 11.5px;
  color: var(--text-soft);
  direction: rtl;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.heat__cells { display: flex; gap: 1px; height: 100%; }
.heat__cell {
  flex: 1 1 0;
  min-width: 1px;
  border-radius: 2px;
  height: calc(100% - 6px);
  align-self: center;
  transition: transform .12s, filter .12s;
}
.heat__cell.is-active { filter: brightness(1.25); outline: 1px solid color-mix(in srgb, var(--text) 45%, transparent); }
.heat.is-hovering .heat__cell:not(.is-active) { opacity: .72; }

.heat__axis {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 8px;
  margin-top: 10px;
}
.heat__ticks {
  position: relative;
  height: 16px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-mute);
}
.heat__ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }

.heat-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
}

.heat-tip {
  position: absolute;
  z-index: 6;
  top: 0; left: 0;
  width: 210px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--surface-solid) 94%, transparent);
  box-shadow: var(--shadow);
  direction: rtl;
  font-size: 12px;
  pointer-events: none;
}
.heat-tip__head { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-mute); margin-bottom: 6px; direction: ltr; text-align: right; }
.heat-tip__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.heat-tip__row + .heat-tip__row { margin-top: 3px; }
.heat-tip__row.is-hovered .heat-tip__name { color: var(--text); font-weight: 700; }
.heat-tip__name { display: inline-flex; align-items: center; gap: 6px; color: var(--text-soft); }
.heat-tip__name i { width: 9px; height: 9px; border-radius: 2px; }
.heat-tip__val { font-family: var(--font-mono); color: var(--text); font-size: 11.5px; }

.misery-side {
  padding: 18px;
  display: flex;
  flex-direction: column;
}
.misery-side h3 { font-size: 14px; margin-bottom: 10px; }
.misery-side.is-hidden { display: none; }
/* Spread the legend rows over the full card height so the panel lines up
   with the heatmap card instead of ending short. */
.misery-side .legend-list { flex: 1 1 auto; justify-content: space-between; }

.legend-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.legend-list li { display: grid; gap: 2px; padding-inline-start: 12px; border-inline-start: 2px solid var(--line-strong); }
.legend-list b { font-size: 12.5px; font-family: var(--font-mono); direction: ltr; text-align: right; color: var(--text); }
.legend-list span { font-size: 12px; color: var(--text-soft); line-height: 1.6; }

/* Operator table ----------------------------------------------------------- */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.op-table-wrap { padding: 8px 8px 14px; overflow-x: auto; }

.op-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  min-width: 620px;
}

.op-table thead th {
  text-align: right;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--text-mute);
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.op-table thead th small {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  color: var(--text-mute);
  opacity: .8;
}

.op-table tbody tr {
  transition: background .16s;
}
.op-table tbody tr:hover { background: color-mix(in srgb, var(--brand) 6%, transparent); }
.op-table tbody tr + tr th,
.op-table tbody tr + tr td { border-top: 1px solid var(--line); }

.op-table tbody th {
  text-align: right;
  font-weight: 400;
  padding: 10px 14px;
  white-space: nowrap;
}
.op-table tbody td {
  padding: 10px 14px;
  color: var(--text-soft);
  white-space: nowrap;
  vertical-align: middle;
}

.op-name { display: inline-flex; align-items: center; gap: 10px; }
.op-name__text { display: grid; line-height: 1.3; }
.op-name__text b { color: var(--text); font-weight: 700; font-size: 13.5px; }
.op-name__text small {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-mute);
  direction: ltr;
  text-align: right;
}

/* Shared logo badge — identical geometry for every operator. */
.op-logo,
.chip__logo {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--op-color) 16%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--op-color) 32%, transparent);
}
.op-logo svg,
.chip__logo svg { width: 26px; height: 26px; display: block; }

.op-type {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  font-size: 11.5px;
  color: var(--text-soft);
  background: color-mix(in srgb, var(--surface-solid) 55%, transparent);
}

.op-value {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  direction: ltr;
  unicode-bidi: embed;
}
.op-spark {
  display: inline-block;
  width: 84px;
  height: 20px;
  margin-inline-start: 8px;
  vertical-align: middle;
  opacity: .9;
  overflow: visible;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}
.status::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status--good { color: var(--emerald); background: color-mix(in srgb, var(--emerald) 12%, transparent); border-color: color-mix(in srgb, var(--emerald) 35%, transparent); }
.status--fair { color: var(--sky); background: color-mix(in srgb, var(--sky) 12%, transparent); border-color: color-mix(in srgb, var(--sky) 35%, transparent); }
.status--warn { color: var(--amber); background: color-mix(in srgb, var(--amber) 12%, transparent); border-color: color-mix(in srgb, var(--amber) 35%, transparent); }
.status--bad  { color: var(--rose); background: color-mix(in srgb, var(--rose) 12%, transparent); border-color: color-mix(in srgb, var(--rose) 35%, transparent); }

.op-table__empty { text-align: center; color: var(--text-mute); padding: 22px; }
.op-table__note {
  margin: 10px 14px 4px;
  font-size: 11.5px;
  color: var(--text-mute);
}

/* News feed ---------------------------------------------------------------- */
.news-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.news-search {
  position: relative;
  flex: 1 1 280px;
  max-width: 420px;
  display: flex;
  align-items: center;
}
.news-search svg {
  position: absolute;
  inset-inline-start: 13px;
  width: 16px; height: 16px;
  fill: none; stroke: var(--text-mute); stroke-width: 1.8; stroke-linecap: round;
  pointer-events: none;
}
.news-search input {
  width: 100%;
  padding: 10px 40px 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.news-search input::placeholder { color: var(--text-mute); }
.news-search input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}

.news-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12.5px;
  color: var(--text-mute);
}
.news-channel {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--brand);
  text-decoration: none;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 5px 12px;
  transition: border-color .18s, color .18s;
}
.news-channel:hover { border-color: var(--brand); }
.news-channel svg { width: 14px; height: 14px; fill: currentColor; }

.news-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.news-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  font-size: 13.5px;
  line-height: 1.85;
}

.news-card img {
  width: 100%;
  height: auto;
  border-radius: 12px;
  cursor: zoom-in;
  border: 1px solid var(--line);
}

.news-card__text {
  direction: rtl;
  text-align: right;
  color: var(--text-soft);
  overflow-wrap: anywhere;
}
.news-card__text.is-en { direction: ltr; text-align: left; }
.news-card__text a { color: var(--brand); text-decoration: none; }
.news-card__text a:hover { text-decoration: underline; }
.news-card__text i.emoji {
  display: inline-block;
  width: 18px; height: 18px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  vertical-align: -3px;
}

.news-expand {
  align-self: flex-start;
  border: 0;
  background: none;
  color: var(--brand);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.news-card__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--text-mute);
}
.news-meta__item { white-space: nowrap; }

.news-open {
  margin-inline-start: auto;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--brand);
  text-decoration: none;
  font-size: 12px;
  transition: border-color .18s;
}
.news-open:hover { border-color: var(--brand); }

.news-empty { color: var(--text-mute); font-size: 13.5px; padding: 8px 0; }

.news-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
}
.news-pager:empty { display: none; }
.news-pager button {
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: 13px;
  cursor: pointer;
  transition: color .18s, border-color .18s, background .18s;
}
.news-pager button:hover:not(:disabled) { color: var(--text); border-color: var(--brand); }
.news-pager button.is-active {
  background: color-mix(in srgb, var(--brand) 18%, transparent);
  border-color: var(--brand);
  color: var(--text);
}
.news-pager button:disabled { opacity: .4; cursor: default; }

/* SEO text block ----------------------------------------------------------- */
.seo-intro {
  color: var(--text-soft);
  font-size: 14px;
  max-width: 78ch;
  margin-bottom: 16px;
}

.seo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.seo-item { padding: 18px; }
.seo-item h3 { font-size: 15px; margin-bottom: 6px; }
.seo-item p { color: var(--text-soft); font-size: 13.5px; }
.seo-item p + p { margin-top: 8px; }
.seo-item a { color: var(--brand); text-decoration: none; }
.seo-item a:hover { text-decoration: underline; }

.seo-links {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 12.5px;
}
.seo-links li { display: inline-flex; align-items: center; gap: 6px; }
.seo-links li::before {
  content: "←";
  color: var(--text-mute);
  font-size: 11px;
}

.seo-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.faq-list { display: grid; gap: 10px; }
.faq-item { padding: 0 18px; }
.faq-item summary {
  cursor: pointer;
  list-style: none;
  padding: 14px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary h3 { font-size: 14px; font-weight: 700; }
.faq-item summary::after {
  content: "+";
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--brand);
  transition: transform .2s;
  flex: none;
}
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item p {
  padding: 0 0 16px;
  color: var(--text-soft);
  font-size: 13.5px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

/* Image lightbox ----------------------------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  place-items: center;
  background: rgba(2, 6, 14, 0.88);
  backdrop-filter: blur(6px);
  padding: 24px;
}
.lightbox.is-open { display: grid; }
.lightbox__stage {
  max-width: 92vw;
  max-height: 88vh;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.lightbox__stage img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: 12px;
  transition: transform .12s ease-out;
  cursor: zoom-in;
  touch-action: none;
}
.lightbox__close {
  position: absolute;
  top: 16px;
  inset-inline-end: 16px;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(15, 23, 42, 0.7);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.lightbox__close:hover { border-color: #fff; }

/* Footer ------------------------------------------------------------------- */
.foot {
  margin-top: 48px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--text-mute);
}
.foot p + p { margin-top: 6px; }
.foot b { color: var(--text-soft); }
.foot a {
  color: var(--brand);
  text-decoration: none;
  border-bottom: 1px dashed color-mix(in srgb, var(--brand) 45%, transparent);
}
.foot a:hover { border-bottom-style: solid; }
#foot-sync { font-family: var(--font-mono); direction: ltr; unicode-bidi: embed; }

/* Overlays ----------------------------------------------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(6px);
  transition: opacity .3s;
}
.overlay[hidden] { display: none; }
.overlay.is-leaving { opacity: 0; pointer-events: none; }

.loader { display: grid; justify-items: center; gap: 18px; color: var(--text-soft); font-size: 13px; }
.loader__note { min-height: 20px; font-size: 12px; color: var(--text-mute); text-align: center; }

.loader__radar {
  position: relative;
  width: 92px; height: 92px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: radial-gradient(circle, color-mix(in srgb, var(--cyan) 12%, transparent), transparent 70%);
  overflow: hidden;
}
.loader__ring {
  position: absolute;
  inset: 20%;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
}
.loader__ring:last-child { inset: 38%; }
.loader__sweep {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0deg, color-mix(in srgb, var(--cyan) 55%, transparent) 60deg, transparent 62deg);
  animation: sweep 1.4s linear infinite;
}

.overlay--error { z-index: 99; }
.errorbox {
  max-width: 420px;
  padding: 28px;
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 10px;
  background: var(--surface-solid);
}
.errorbox__icon svg { width: 42px; height: 42px; fill: none; stroke: var(--rose); stroke-width: 1.6; stroke-linejoin: round; }
.errorbox h2 { font-size: 18px; }
.errorbox p { color: var(--text-soft); font-size: 13.5px; }

.btn {
  margin-top: 8px;
  padding: 10px 22px;
  border: 0;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--cyan), #38bdf8);
  color: #04121a;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
html[data-theme="light"] .btn { color: #fff; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 12px 26px -14px var(--cyan); }

/* Responsive --------------------------------------------------------------- */
@media (max-width: 1080px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .misery-wrap { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 780px) {
  .grid--2, .grid--3, .news-grid, .seo-grid, .seo-grid--3 { grid-template-columns: minmax(0, 1fr); }
  .op-spark { display: none; }

  /* Table becomes a compact stack of cards, centred, with each value
     directly beside its label so nothing floats far from where it belongs. */
  .op-table { min-width: 0; width: 100%; }
  .op-table thead { display: none; }
  .op-table tbody { display: grid; gap: 10px; }
  .op-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px 12px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface-solid) 55%, transparent);
  }
  .op-table tbody tr + tr th,
  .op-table tbody tr + tr td { border-top: 0; }
  .op-table tbody tr + tr { border-top: 1px solid var(--line); }

  /* Row 1: operator identity ...... network type */
  .op-table tbody th { grid-column: 1; grid-row: 1; padding: 0; }
  .op-table tbody td:nth-child(2) { grid-column: 2; grid-row: 1; justify-self: end; }

  /* Row 2: metrics, label + value inline, both centred */
  .op-table tbody td { padding: 0; justify-self: start; }
  .op-table tbody td:nth-child(3) { grid-column: 1; grid-row: 2; }
  .op-table tbody td:nth-child(4) { grid-column: 2; grid-row: 2; justify-self: end; }
  .op-table tbody td:nth-child(3),
  .op-table tbody td:nth-child(4) {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
    white-space: nowrap;
  }
  .op-table tbody td:nth-child(3)::before { content: "پینگ"; font-size: 10.5px; color: var(--text-mute); }
  .op-table tbody td:nth-child(4)::before { content: "اختلال"; font-size: 10.5px; color: var(--text-mute); }

  /* Row 3: status pill spans the row, centred */
  .op-table tbody td:nth-child(5) { grid-column: 1 / -1; grid-row: 3; justify-self: center; }
  .op-table__note { text-align: center; margin-inline: 8px; }
  .hero { align-items: flex-start; }
  .chart { height: 230px; }
  .wrap { width: calc(100% - 28px); }
}

@media (max-width: 560px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .brand__text small, .live__label, .today-chip { display: none; }
  .live { padding: 8px; }
  /* Compact header actions so the brand and buttons stay balanced. */
  .topbar__inner { height: 58px; gap: 10px; }
  .brand { gap: 8px; }
  .brand__mark { width: 32px; height: 32px; }
  .brand__text strong { font-size: 15px; }
  .topbar__actions { gap: 6px; }
  .icon-btn { width: 34px; height: 34px; border-radius: 10px; }
  .icon-btn svg { width: 16px; height: 16px; }
  .heat__row { grid-template-columns: 78px minmax(0, 1fr); height: 30px; }
  .heat__axis { grid-template-columns: 78px minmax(0, 1fr); }
  .heat__label { font-size: 10.5px; }
  .pill { padding: 8px 12px; font-size: 12px; }
  .wrap { width: calc(100% - 24px); }
  .hero__copy { text-align: center; }
  .hero__copy .lede { margin-inline: auto; }
  .hero { flex-direction: column; align-items: center; text-align: center; }
  .hero__controls { align-self: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
