/* داشبوردِ بازارِ رقبا — استایلِ مشترکِ همه‌ی صفحات. RTL، فونتِ وزیرمتن،
   واکنش‌گرا در ۳۶۰/۷۶۸/۱۲۸۰px بدونِ اسکرولِ افقیِ کلِ صفحه (جدول‌های پهن
   داخلِ یه container اسکرول‌شونده‌ی خودشون می‌رن، نه خودِ صفحه). */

@font-face {
  font-family: "Vazirmatn";
  src: url("/static/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("/static/Vazirmatn-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0f1216;
  --surface: #171b21;
  --surface-2: #1f242c;
  --border: #2a313b;
  --text: #e7ebf0;
  --text-dim: #9aa6b2;
  --accent: #5aa9ff;
  --accent-2: #7cd992;
  --warn: #f4b942;
  --danger: #f4664a;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Vazirmatn", "Tahoma", sans-serif;
  line-height: 1.7;
  overflow-x: hidden;
  min-width: 0;
}

a {
  color: var(--accent);
}

h1, h2, h3 {
  font-weight: 700;
  margin: 0 0 0.6em;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.6rem;
}

.nav-link {
  display: inline-block;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.92rem;
}

.nav-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-link-active {
  background: var(--accent);
  color: #06121f;
  font-weight: 700;
}

.page-main {
  padding: 1rem;
  max-width: 1200px;
  margin: 0 auto;
  min-width: 0;
}

.bare-body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Vazirmatn", "Tahoma", sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bare-main {
  width: min(420px, 92vw);
  padding: 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.banner {
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--warn);
  background: rgba(244, 185, 66, 0.12);
  color: var(--warn);
}

.banner-list {
  margin: 0.4rem 0 0;
  padding-inline-start: 1.2rem;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 560px;
  font-size: 0.92rem;
}

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

th {
  background: var(--surface-2);
  font-weight: 700;
  position: sticky;
  top: 0;
}

tr:last-child td {
  border-bottom: none;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.badge-ok { background: rgba(124, 217, 146, 0.15); color: var(--accent-2); }
.badge-warn { background: rgba(244, 185, 66, 0.15); color: var(--warn); }
.badge-danger { background: rgba(244, 102, 74, 0.15); color: var(--danger); }
.badge-info { background: rgba(90, 169, 255, 0.15); color: var(--accent); }

.filters-details {
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.filters-details > summary {
  cursor: pointer;
  padding: 0.7rem 1rem;
  font-weight: 700;
  list-style: none;
  user-select: none;
}

.filters-details > summary::-webkit-details-marker {
  display: none;
}

.filters-details > summary::before {
  content: "▸";
  display: inline-block;
  margin-inline-end: 0.5rem;
  color: var(--text-dim);
  transition: transform 0.15s ease;
}

.filters-details[open] > summary::before {
  transform: rotate(90deg);
}

form.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: end;
  padding: 0 1rem 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.field label {
  font-size: 0.8rem;
  color: var(--text-dim);
}

input, select, button {
  font-family: inherit;
  font-size: 0.92rem;
}

input, select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.45rem 0.6rem;
  max-width: 100%;
}

.btn {
  display: inline-block;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #06121f;
  padding: 0.5rem 1rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-dim);
}

.btn-danger {
  border-color: var(--danger);
  background: transparent;
  color: var(--danger);
}

.error-box {
  border: 1px solid var(--danger);
  color: var(--danger);
  background: rgba(244, 102, 74, 0.1);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  margin-bottom: 1rem;
}

.muted {
  color: var(--text-dim);
}

.pagination {
  margin-top: 0.8rem;
  display: flex;
  justify-content: flex-end;
}

.stat-block {
  margin-bottom: 1.2rem;
}

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

.price-chart .grid-line {
  stroke: var(--border);
  stroke-width: 1;
}

.price-chart .price-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
}

.price-chart .price-dot {
  fill: var(--accent);
}

.price-chart .axis-label {
  fill: var(--text-dim);
  font-size: 10px;
}

.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.6rem;
}

.kv-grid dt {
  color: var(--text-dim);
  font-size: 0.8rem;
}

.kv-grid dd {
  margin: 0.1rem 0 0;
  font-weight: 700;
}

.note-box {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  color: var(--text-dim);
  font-size: 0.9rem;
}

code {
  background: var(--surface-2);
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  font-size: 0.85em;
}

@media (max-width: 767px) {
  .page-main {
    padding: 0.7rem;
  }
  form.filters {
    flex-direction: column;
    align-items: stretch;
  }
  .field {
    width: 100%;
  }

  /* زیرِ ۷۶۸px جدول به کارت تبدیل می‌شه (نه اسکرولِ افقی) — هر ردیف یه
     کارتِ عمودیه، هر سلول یه سطرِ «برچسب: مقدار» (برچسب از data-label).
     از ۷۶۸px به بالا table.responsive-table مثلِ جدولِ معمولی می‌مونه
     (قاعده‌های پایه‌ی table/th/td در همین فایل). */
  table.responsive-table {
    display: block;
    min-width: 0;
  }
  table.responsive-table thead {
    display: none;
  }
  table.responsive-table tbody {
    display: block;
  }
  table.responsive-table tr {
    display: block;
    padding: 0.5rem 0.65rem;
    border-bottom: 6px solid var(--bg);
  }
  table.responsive-table tr:last-child {
    border-bottom: none;
  }
  table.responsive-table td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    white-space: normal;
    overflow-wrap: anywhere;
    border-bottom: 1px solid var(--border);
    padding: 0.4rem 0;
  }
  table.responsive-table td:last-child {
    border-bottom: none;
  }
  table.responsive-table td::before {
    content: attr(data-label);
    flex-shrink: 0;
    color: var(--text-dim);
    font-weight: 700;
    font-size: 0.82rem;
  }
}

@media (max-width: 480px) {
  .site-header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }
}
