@font-face {
  font-family: Vazirmatn;
  src: url(fonts/Vazirmatn.woff2) format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

/* Telegram injects --tg-theme-* ; fallbacks make the page usable in a plain browser */
:root {
  --bg: var(--tg-theme-secondary-bg-color, #f1f3f6);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #fff));
  --text: var(--tg-theme-text-color, #16181d);
  --muted: var(--tg-theme-hint-color, #6b7280);
  --accent: var(--tg-theme-button-color, #0f766e);
  --accent-text: var(--tg-theme-button-text-color, #fff);
  --link: var(--tg-theme-link-color, #0f766e);
  --line: color-mix(in srgb, var(--muted) 22%, transparent);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not(.tg) {
    --bg: #0f1115; --card: #181b21; --text: #e8eaed; --muted: #9aa0a6; --accent: #2dd4bf; --accent-text: #062925; --link: #5eead4;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.7 Vazirmatn, system-ui, sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
a { color: var(--link); }
h1, h2, h3 { margin: 0; line-height: 1.4; }
h1 { font-size: 18px; font-weight: 800; }
h2 { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
h2 small { color: var(--muted); font-weight: 400; font-size: 12px; margin-inline-start: 6px; }
h3 { font-size: 14px; margin: 14px 0 4px; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 16px 8px;
}
.sub { margin: 0; color: var(--muted); font-size: 13px; }
.badge { font-size: 12px; padding: 2px 10px; border-radius: 99px; background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }

main { padding: 0 12px; max-width: 760px; margin: 0 auto; }
.tab { display: none; }
.tab.active { display: block; animation: in .18s ease-out; }
@keyframes in { from { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) { .tab.active { animation: none; } }

.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 0 0 8px; }
.chart { position: relative; height: 220px; }
.chart.tall { height: 300px; }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--card); border-radius: var(--radius); padding: 12px 14px; }
.kpi b { display: block; font-size: 24px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: 12.5px; }
@media (min-width: 560px) { .kpis { grid-template-columns: repeat(4, 1fr); } }

.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.rows li:first-child { border-top: 0; }
.rows .v { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rows button { all: unset; cursor: pointer; flex: 1; }

.searchbar input, .filters select {
  width: 100%; font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; outline: none;
}
.searchbar input:focus, .filters select:focus { border-color: var(--accent); }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }

.list { list-style: none; margin: 0; padding: 0; }
.item { background: var(--card); border-radius: var(--radius); margin-bottom: 8px; }
.item button { all: unset; display: block; width: 100%; padding: 12px 14px; cursor: pointer; box-sizing: border-box; }
.item button:focus-visible { outline: 2px solid var(--accent); border-radius: var(--radius); }
.item .t { font-weight: 700; }
.item .m { color: var(--muted); font-size: 12.5px; }
.item .a { font-size: 13px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meter { height: 4px; border-radius: 4px; background: var(--line); margin-top: 8px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); }

.cluster h3 { margin-top: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.chips span, .tags span { font-size: 12px; padding: 2px 10px; border-radius: 99px; background: color-mix(in srgb, var(--accent) 13%, transparent); color: var(--text); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.cluster .names { font-size: 13px; color: var(--muted); }
.cluster .names button { all: unset; cursor: pointer; color: var(--link); }

.prose ul { padding-inline-start: 18px; margin: 4px 0; }
.prose p { margin: 6px 0; }

.tabs {
  position: fixed; inset-inline: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5;
}
.tabs button {
  all: unset; text-align: center; padding: 7px 0 8px; font-size: 11.5px; color: var(--muted); cursor: pointer;
}
.tabs button span { display: block; font-size: 19px; line-height: 1.3; filter: grayscale(1); opacity: .7; }
.tabs button.active { color: var(--accent); font-weight: 700; }
.tabs button.active span { filter: none; opacity: 1; }
.tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }

.sheet-backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / .35); z-index: 9; }
.sheet {
  position: fixed; inset-inline: 0; bottom: 0; max-height: 88vh; overflow: auto; z-index: 10;
  background: var(--card); border-radius: 18px 18px 0 0; padding: 18px 16px calc(24px + env(safe-area-inset-bottom));
  max-width: 760px; margin: 0 auto; box-shadow: 0 -8px 30px rgb(0 0 0 / .15);
}
.sheet .close { all: unset; position: absolute; inset-inline-end: 14px; top: 12px; font-size: 18px; color: var(--muted); cursor: pointer; padding: 4px 8px; }
.sheet h2 { font-size: 18px; padding-inline-end: 30px; }
.sheet dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 10px 0; font-size: 13.5px; }
.sheet dt { color: var(--muted); }
.sheet dd { margin: 0; overflow-wrap: anywhere; }
.btn { display: inline-block; background: var(--accent); color: var(--accent-text); text-decoration: none; padding: 9px 16px; border-radius: 10px; font-weight: 700; margin-top: 6px; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.empty { text-align: center; color: var(--muted); padding: 30px 0; }
