:root {
  color-scheme: dark;
  --bg-1: #0b1630;
  --bg-2: #122449;
  --hero-glow-1: rgba(87, 129, 255, 0.15);
  --hero-glow-2: rgba(9, 18, 39, 0.36);
  --panel: rgba(13, 24, 47, 0.76);
  --surface: rgba(16, 31, 61, 0.78);
  --surface-soft: rgba(20, 37, 73, 0.72);
  --border: rgba(132, 166, 221, 0.22);
  --border-strong: rgba(200, 166, 73, 0.46);
  --text: #e8f0ff;
  --muted: #c3d1ea;
  --soft: #94abd1;
  --accent: #5f86ff;
  --accent-2: #7ea2ff;
  --accent-soft: rgba(95, 134, 255, 0.18);
  --warning: #f4cc56;
  --shadow: 0 24px 44px rgba(1, 7, 20, 0.45);
  --shadow-md: 0 14px 28px rgba(1, 7, 20, 0.35);
  --focus-ring: rgba(95, 134, 255, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Vazirmatn", Tahoma, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 15% 12%, var(--hero-glow-1), transparent 38%),
    radial-gradient(circle at 85% 24%, var(--hero-glow-2), transparent 40%),
    linear-gradient(168deg, var(--bg-1), var(--bg-2));
  color: var(--text);
  direction: rtl;
}

.container {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 54px;
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.55rem);
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.hero p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.85;
}

.meta {
  min-width: min(360px, 100%);
  display: grid;
  gap: 10px;
  text-align: left;
  color: var(--soft);
  font-size: 14px;
}

.meta > div {
  padding: 12px 14px;
  border: 1px solid rgba(138, 170, 224, 0.16);
  border-radius: 14px;
  background: rgba(20, 36, 69, 0.3);
}

.section {
  background: var(--panel);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
}

.section h2 {
  margin: 0 0 14px;
  font-size: 22px;
  color: var(--text);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-note {
  color: var(--soft);
  font-size: 13px;
}

.small-note,
.footer-note {
  color: var(--soft);
  font-size: 13px;
}

.footer-note {
  text-align: center;
  margin-top: 8px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.kpi-card {
  background:
    radial-gradient(circle at 30% 0%, rgba(95, 134, 255, 0.16), transparent 46%),
    linear-gradient(180deg, rgba(28, 53, 101, 0.92), rgba(13, 31, 69, 0.92));
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow-md);
}

.kpi-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--warning);
}

.metric-inline {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 16px;
}

.metric-inline strong {
  font-size: 26px;
  color: var(--warning);
}

.metric-inline span {
  color: var(--soft);
}

.bar-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 112px 1fr 88px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.bar-label,
.bar-value {
  color: var(--muted);
  white-space: nowrap;
}

.bar-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(147, 179, 232, 0.12);
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(147, 179, 232, 0.16);
  text-align: right;
  font-size: 14px;
}

th {
  position: sticky;
  top: 0;
  background: rgba(16, 31, 61, 0.98);
  color: var(--muted);
  font-weight: 700;
  z-index: 1;
}

th.sortable {
  cursor: pointer;
}

th[data-active="asc"],
th[data-active="desc"] {
  color: var(--warning);
}

th.sortable::after {
  content: "↕";
  font-size: 11px;
  margin-inline-start: 6px;
  color: var(--soft);
}

tbody tr:hover {
  background: rgba(95, 134, 255, 0.08);
}

.controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.controls input {
  min-width: 280px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: rgba(12, 25, 53, 0.9);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.controls input::placeholder {
  color: var(--soft);
}

.controls input:focus,
.question-view-btn:focus,
.question-modal-close:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 4px var(--focus-ring);
}

code {
  direction: ltr;
  unicode-bidi: embed;
  background: rgba(95, 134, 255, 0.12);
  color: var(--text);
  border-radius: 6px;
  padding: 2px 6px;
}

.empty-state {
  color: var(--soft);
  padding: 16px;
}

.question-view-btn {
  border: 1px solid var(--border);
  background: rgba(12, 25, 53, 0.92);
  color: var(--text);
  border-radius: 10px;
  padding: 7px 12px;
  font: inherit;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.question-view-btn:hover {
  background: rgba(95, 134, 255, 0.14);
  border-color: var(--accent-2);
  transform: translateY(-1px);
}

.question-view-btn:disabled {
  cursor: not-allowed;
  color: rgba(195, 209, 234, 0.46);
  background: rgba(20, 37, 73, 0.5);
}

.question-modal[hidden] {
  display: none;
}

.question-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.question-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 10, 22, 0.72);
}

.question-modal-card {
  position: relative;
  width: min(720px, calc(100% - 24px));
  margin: 48px auto;
  background: rgba(13, 24, 47, 0.96);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 24px 70px rgba(1, 7, 20, 0.48);
  padding: 18px;
}

.question-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.question-modal-head h3 {
  margin: 0;
  font-size: 22px;
}

.question-modal-close {
  border: 1px solid var(--border);
  background: rgba(12, 25, 53, 0.92);
  color: var(--text);
  border-radius: 10px;
  padding: 7px 12px;
  font: inherit;
  cursor: pointer;
}

.question-modal-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.question-answer-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 13px;
  color: var(--accent-2);
  background: var(--accent-soft);
}

.question-modal-text {
  margin: 0;
  line-height: 1.95;
  font-size: 16px;
  color: var(--muted);
}

@media (max-width: 960px) {
  .hero {
    flex-direction: column;
  }

  .meta {
    min-width: 100%;
    text-align: right;
  }
}

@media (max-width: 720px) {
  .container {
    width: min(100% - 20px, 1200px);
  }

  .section {
    padding: 16px;
    border-radius: 16px;
  }

  .kpi-value {
    font-size: 24px;
  }

  .bar-row {
    grid-template-columns: 92px 1fr 76px;
  }

  .controls input {
    min-width: 0;
    width: 100%;
  }
}
