:root {
  --bg-0: #12100e;
  --bg-1: #1a1612;
  --bg-2: #231e18;
  --ink: #f4ede3;
  --muted: #9a8f82;
  --line: rgba(244, 237, 227, 0.1);
  --gold: #d4a35b;
  --gold-soft: #e8c48a;
  --good: #6fbf8a;
  --bad: #e07a6a;
  --radius: 14px;
  --space: 8px;
  --font: "Vazirmatn", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg-0);
}

body {
  position: relative;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 50% at 90% -10%, rgba(212, 163, 91, 0.18), transparent 55%),
    radial-gradient(ellipse 60% 40% at 0% 100%, rgba(90, 110, 80, 0.12), transparent 50%),
    linear-gradient(165deg, #161310 0%, #12100e 45%, #0e0d0b 100%);
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: calc(var(--space) * 4) calc(var(--space) * 3) calc(var(--space) * 6);
}

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: calc(var(--space) * 2);
  margin-bottom: calc(var(--space) * 3);
}

.brand {
  margin: 0 0 var(--space);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--gold);
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 700;
  line-height: 1.2;
}

h2 {
  margin: 0 0 var(--space);
  font-size: 1.05rem;
  font-weight: 600;
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

.actions {
  display: flex;
  gap: var(--space);
  flex-shrink: 0;
}

.btn {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--gold);
  color: #1a140c;
}

.btn.primary:hover:not(:disabled) {
  background: var(--gold-soft);
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.btn.ghost:hover:not(:disabled) {
  border-color: rgba(212, 163, 91, 0.45);
}

.status-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: calc(var(--space) * 3);
  padding: 0.7rem 1rem;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.dot.ok {
  background: var(--good);
  box-shadow: 0 0 0 3px rgba(111, 191, 138, 0.2);
}

.dot.err {
  background: var(--bad);
  box-shadow: 0 0 0 3px rgba(224, 122, 106, 0.2);
}

.dot.busy {
  background: var(--gold);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.4;
  }
}

#last-refresh {
  margin-inline-start: auto;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space);
  margin-bottom: calc(var(--space) * 3);
}

.filter-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.45rem 1rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.filter-btn:hover {
  border-color: rgba(212, 163, 91, 0.45);
  color: var(--ink);
}

.filter-btn.active {
  background: rgba(212, 163, 91, 0.18);
  border-color: rgba(212, 163, 91, 0.55);
  color: var(--gold-soft);
}

.section-head {
  margin-bottom: calc(var(--space) * 2);
}

.section-head h2 {
  margin-bottom: 0.2rem;
}

.compare-panel,
.other-panel {
  margin-bottom: calc(var(--space) * 3);
}

.compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: calc(var(--space) * 2);
}

.price-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: calc(var(--space) * 2);
}

.price-card {
  padding: calc(var(--space) * 2.5);
  background: linear-gradient(145deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.price-card:hover {
  border-color: rgba(212, 163, 91, 0.35);
}

.price-card.selected {
  border-color: rgba(212, 163, 91, 0.7);
  box-shadow: 0 0 0 1px rgba(212, 163, 91, 0.25);
}

.price-card.compare {
  min-height: 150px;
}

.price-card.empty-card {
  cursor: default;
}

.price-card.empty-card:hover {
  border-color: var(--line);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.source-name {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}

.kind-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.kind-badge.union {
  color: var(--gold-soft);
  border-color: rgba(212, 163, 91, 0.4);
  background: rgba(212, 163, 91, 0.1);
}

.kind-badge.commercial {
  color: #9cb4c9;
  border-color: rgba(156, 180, 201, 0.35);
  background: rgba(156, 180, 201, 0.08);
}

.price-card .label {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.price-card .value {
  margin: 0;
  font-size: clamp(1.35rem, 3.5vw, 1.85rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--gold-soft);
}

.price-card.compare .value {
  font-size: clamp(1.5rem, 4vw, 2rem);
}

.price-card .meta {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.change.up {
  color: var(--good);
}

.change.down {
  color: var(--bad);
}

.chart-panel,
.table-panel {
  margin-bottom: calc(var(--space) * 3);
  padding: calc(var(--space) * 2.5);
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.limit-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.limit-label select {
  font: inherit;
  font-size: 0.85rem;
  color: var(--ink);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
}

.chart-wrap {
  position: relative;
  min-height: 220px;
}

.empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 0.65rem 0.4rem;
  text-align: start;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.8rem;
}

td.num {
  font-variant-numeric: tabular-nums;
}

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

  .actions {
    width: 100%;
  }

  .btn {
    flex: 1;
  }

  #last-refresh {
    margin-inline-start: 0;
    width: 100%;
  }

  .status-bar {
    flex-wrap: wrap;
  }
}
