/* Общая страница статистики (stats.html). Цвета — как у боковой панели сайта (style.css) */
:root {
  --bg: #eef1f5;
  --card: #ffffff;
  --fg: #262b33;
  --muted: #7d8592;
  --line: #e3e7ec;
  --track: #eef0f3;
  --head: #1f2b3a;
  --head-fg: #c9d3e0;
  --accent: #ff8a3d;
  --ok: #1f7a42;
  --ok-bg: #eaf7ef;
  --down: #c2462b;
  color-scheme: light;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161e; --card: #1a202b; --fg: #e8ecf3; --muted: #8f9bb0; --line: #283041; --track: #262d3a;
    --head: #0d1117; --head-fg: #aab6c6; --ok: #6fd69a; --ok-bg: rgba(47,165,90,.15); --down: #ff8a70;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12161e; --card: #1a202b; --fg: #e8ecf3; --muted: #8f9bb0; --line: #283041; --track: #262d3a;
  --head: #0d1117; --head-fg: #aab6c6; --ok: #6fd69a; --ok-bg: rgba(47,165,90,.15); --down: #ff8a70;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font-size: 14px; line-height: 1.45; }
a { color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.sp-head { background: var(--head); color: var(--head-fg); position: sticky; top: 0; z-index: 5; }
.sp-head__in { max-width: 1080px; margin: 0 auto; padding: 8px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sp-back { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; padding: 6px 10px 6px 4px; border-radius: 8px; font-weight: 500; }
.sp-back:hover { background: rgba(255,255,255,.08); color: #fff; }
.sp-lang { font: inherit; font-size: 13px; background: rgba(255,255,255,.08); color: inherit; border: 1px solid rgba(255,255,255,.14); border-radius: 8px; padding: 5px 8px; }
.sp-lang option { color: #262b33; }

.sp-wrap { max-width: 1080px; margin: 0 auto; padding: 24px 16px 40px; }
.sp-hero { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.sp-logo { flex: none; width: 48px; height: 48px; border-radius: 14px; background: var(--accent); color: #fff; display: grid; place-items: center; }
.sp-logo svg { width: 26px; height: 26px; stroke-width: 2.2; }
.sp-hero h1 { margin: 0; font-size: 26px; line-height: 1.2; letter-spacing: -.3px; }
.sp-hero p { margin: 4px 0 0; color: var(--muted); max-width: 640px; }

.sp-main { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.sp-main > .sp-kpis, .sp-main > .sp-foot, .sp-main > .sp-empty { grid-column: 1 / -1; }
.sp-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; min-width: 0; }
.sp-card h2 { margin: 0; font-size: 16px; }
.sp-card h3 { margin: 0 0 8px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.sp-note { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.sp-card > :not(h2):not(.sp-note):first-of-type, .sp-card > h2 + :not(.sp-note), .sp-card > .sp-note + * { margin-top: 12px; }
.sp-empty { color: var(--muted); font-size: 13px; margin: 12px 0 0; }
.sp-foot { color: var(--muted); font-size: 12px; margin: 4px 0 0; }

/* Итоги */
.sp-kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.sp-kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; min-width: 0; }
.sp-kpi span { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-kpi b { font-size: 24px; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.sp-kpi--live { background: var(--ok-bg); border-color: transparent; }
.sp-kpi--live b, .sp-kpi--live span { color: var(--ok); }
.st-dot { flex: none; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #2fa55a; animation: spPulse 1.8s infinite; }
@keyframes spPulse { 0% { box-shadow: 0 0 0 0 rgba(47,165,90,.55); } 70% { box-shadow: 0 0 0 7px rgba(47,165,90,0); } 100% { box-shadow: 0 0 0 0 rgba(47,165,90,0); } }

/* Полосы */
.sp-bar { display: block; height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.sp-bar span { display: block; height: 100%; border-radius: 4px; transition: width .6s ease; }

/* Таблицы */
.sp-table-wrap { overflow-x: auto; margin: 12px -18px 0; padding: 0 18px; }
.sp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sp-table th { text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); padding: 0 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.sp-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.sp-table tbody tr:last-child td { border-bottom: 0; }
.sp-table tbody tr:hover td { background: var(--bg); }
.sp-table th:first-child, .sp-table td:first-child { padding-left: 0; }
.sp-table th:last-child, .sp-table td:last-child { padding-right: 0; }
.sp-table .c-rank { width: 34px; }
.sp-table .c-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sp-table td.c-num { font-weight: 600; }
.sp-table .c-muted { color: var(--muted); }
.sp-table .c-nowrap { white-space: nowrap; }
.sp-table .c-act { text-align: right; width: 1%; }
.sp-table .c-share { width: 26%; min-width: 120px; }
.sp-table .c-ico { width: 34px; font-size: 20px; text-align: center; }
.sp-table .c-big { white-space: nowrap; }
.sp-table .c-src { color: var(--muted); font-size: 11.5px; max-width: 180px; }
.sp-rank { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 4px; border-radius: 7px; background: var(--track); font-weight: 700; font-size: 12px; font-variant-numeric: tabular-nums; }
.sp-rank--top { background: #fde7a8; color: #8a5a00; }
.sp-dot { flex: none; display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.sp-cell-name { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.sp-cell-name b { font-size: 14px; }
.sp-online { display: inline-flex; align-items: center; gap: 6px; color: var(--ok); }
.sp-share { display: grid; grid-template-columns: minmax(40px, 1fr) 46px; align-items: center; gap: 8px; }
.sp-share small { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.sp-trend { font-weight: 600; }
.sp-trend.up { color: var(--ok); }
.sp-trend.down { color: var(--down); }
.sp-btn { display: inline-block; text-decoration: none; font-size: 12.5px; font-weight: 600; padding: 6px 12px; border-radius: 9px; background: var(--accent); color: #fff; white-space: nowrap; }
.sp-btn:hover { filter: brightness(1.06); }
.sp-link { color: var(--accent); font-weight: 600; text-decoration: none; white-space: nowrap; }
.sp-link:hover { text-decoration: underline; }

/* График */
.sp-chart-wrap { position: relative; }
.sp-chart { width: 100%; height: 150px; display: block; stroke: none; }
.sp-chart g:hover rect:not([fill="transparent"]) { opacity: .8; }
.sp-chart__zero { fill: var(--line); }
.sp-chart__max { position: absolute; top: -2px; left: 0; font-size: 11px; color: var(--muted); background: var(--card); padding-right: 4px; }
.sp-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; }
.sp-legend { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; }
.sp-legend li { display: inline-flex; align-items: center; gap: 6px; }
.sp-legend i { width: 10px; height: 10px; border-radius: 3px; }

/* Экскурсии и места */
.sp-tour, .sp-place { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.sp-tour:hover, .sp-place:hover span { text-decoration: underline; }
.sp-tour__ico { flex: none; width: 24px; height: 24px; border-radius: 7px; color: #fff; display: grid; place-items: center; font-size: 12px; }
.sp-place img, .sp-place__noimg { flex: none; width: 36px; height: 36px; border-radius: 7px; object-fit: cover; background: var(--track); }

/* Откуда смотрят */
.sp-cols { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 28px; margin-top: 14px; }
.sp-cols .sp-table-wrap { margin-top: 0; }
.sp-country { display: inline-flex; align-items: center; gap: 8px; }
.sp-flag { font-family: "Twemoji Country Flags", "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; font-size: 15px; }

/* Вкладки */
.sp-tabs { display: flex; gap: 2px; overflow-x: auto; margin: -6px -8px 0; padding: 0 8px; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.sp-tabs::-webkit-scrollbar { display: none; }
.sp-tab { flex: none; font: inherit; font-size: 13.5px; font-weight: 600; color: var(--muted); background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 12px; margin-bottom: -1px; cursor: pointer; white-space: nowrap; }
.sp-tab:hover { color: var(--fg); }
.sp-tab[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
.sp-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px 6px 0 0; }
.sp-panel { margin-top: 12px; }
.sp-panel > .sp-note { margin: 0; }
.sp-panel > .sp-table-wrap:first-child, .sp-panel > .sp-empty:first-child { margin-top: 0; }

/* Факты */
.sp-card--wide { grid-column: 1 / -1; }
.sp-fact__big { font-size: 17px; letter-spacing: -.2px; color: var(--accent); font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .sp-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .sp-main { grid-template-columns: minmax(0, 1fr); }
  .sp-cols { grid-template-columns: minmax(0, 1fr); }
  .sp-table .c-src { display: none; }
  .sp-hero h1 { font-size: 22px; }
  .sp-kpi b { font-size: 20px; }
}
@media (max-width: 480px) {
  .sp-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
