/* Цены ресурсов — публичная страница.
   Раскладка — из десктоп-приложения TzPriceHistory (web/app.css), оформление — общий стиль сайта:
   фон главной и просмотра боёв (шум, трещины, виньетка), ржавая рамка с заклёпками
   как у анализа боя, зелёные акценты, тема в cookie battle_view_theme. */

@font-face {
  font-family: 'Russo One'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/assets/site/russo-one-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Russo One'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/assets/site/russo-one-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* ---------- темы ---------- */
:root, html[data-theme="light"] {
  color-scheme: light;
  --text: #1f2937;
  --ink-2: #374151;
  --muted: #5b6b63;
  --surface: rgba(255, 255, 255, .82);
  --surface-2: rgba(240, 244, 242, .92);
  --surface-3: rgba(226, 233, 229, .95);
  --screen: linear-gradient(180deg, #f8faf9, #eef3f1);
  --screen-solid: #f4f7f5;
  --border: rgba(4, 120, 87, .22);
  --grid: rgba(4, 120, 87, .12);
  --accent: #047857;
  --accent-ink: #ffffff;
  --wash: rgba(16, 185, 129, .12);
  --hover: rgba(16, 185, 129, .08);
  --up: #15803d;
  --down: #dc2626;
  --best: #b45309;
  --best-bg: rgba(22, 163, 74, .14);
  --worst-bg: rgba(220, 38, 38, .11);
  --warn-bg: rgba(217, 119, 6, .12);
  --warn-ink: #92400e;
  --info-bg: rgba(16, 185, 129, .1);
  --info-ink: #065f46;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 6px 18px rgba(15, 23, 42, .08);
  --title: #1f2937;
  --title-shadow: 0 2px 0 rgba(255, 255, 255, .6);
  --brand: #16a34a;
  --brand-gradient: linear-gradient(90deg, #22c55e, #16a34a);
  --footer-line: rgba(100, 116, 139, .22);

  --bg-layer: linear-gradient(180deg, #f3f4f6 0%, #e7e9ee 45%, #dfe2e8 100%);
  --bg-spot-1: rgba(160, 170, 185, .25);
  --bg-spot-2: rgba(120, 135, 155, .20);
  --bg-spot-3: rgba(90, 110, 100, .15);
  --bg-glow: rgba(34, 197, 94, .06);
  --cracks-opacity: .10;
  --cracks-blend: multiply;
  --noise-opacity: .20;
  --vignette: rgba(15, 23, 42, .18);
  --vignette-opacity: .6;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --text: #e2e8f0;
  --ink-2: #cbd5e1;
  --muted: #94a3b8;
  --surface: rgba(15, 23, 42, .72);
  --surface-2: rgba(30, 41, 59, .85);
  --surface-3: rgba(51, 65, 85, .9);
  --screen: linear-gradient(180deg, #0f172a, #1e293b);
  --screen-solid: #142033;
  --border: rgba(52, 211, 153, .26);
  --grid: rgba(52, 211, 153, .12);
  --accent: #34d399;
  --accent-ink: #052e1f;
  --wash: rgba(52, 211, 153, .12);
  --hover: rgba(52, 211, 153, .07);
  --up: #4ade80;
  --down: #f87171;
  --best: #fbbf24;
  --best-bg: rgba(74, 222, 128, .14);
  --worst-bg: rgba(248, 113, 113, .13);
  --warn-bg: rgba(251, 191, 36, .14);
  --warn-ink: #fde68a;
  --info-bg: rgba(52, 211, 153, .1);
  --info-ink: #a7f3d0;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .25);
  --title: #f1e8dc;
  --title-shadow: 0 2px 0 #000, 0 0 1px #000;
  --brand: #63f382;
  --brand-gradient: linear-gradient(90deg, #5dff4a, #63f382);
  --footer-line: rgba(148, 163, 184, .15);

  --bg-layer: linear-gradient(180deg, #1a1a1c 0%, #222226 40%, #141416 100%);
  --bg-spot-1: rgba(90, 90, 95, .18);
  --bg-spot-2: rgba(60, 60, 65, .25);
  --bg-spot-3: rgba(50, 55, 50, .20);
  --bg-glow: rgba(80, 220, 100, .10);
  --cracks-opacity: .9;
  --cracks-blend: screen;
  --noise-opacity: .30;
  --vignette: rgba(0, 0, 0, .55);
  --vignette-opacity: 1;
}

/* ---------- основа и фон ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  color: var(--text);
  font: 14px/1.45 'Segoe UI', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
  background:
    radial-gradient(ellipse at 50% 0%, var(--bg-spot-1), transparent 60%),
    radial-gradient(ellipse at 80% 100%, var(--bg-spot-2), transparent 55%),
    radial-gradient(ellipse at 10% 80%, var(--bg-spot-3), transparent 55%),
    var(--bg-layer);
  background-attachment: fixed;
}
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  opacity: var(--noise-opacity); mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
}
body::after {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  opacity: var(--cracks-opacity); mix-blend-mode: var(--cracks-blend);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='800' height='800' viewBox='0 0 800 800'%3E%3Cg fill='none' stroke='%23000' stroke-width='2'%3E%3Cpath d='M0 120 L140 160 L210 90 L320 150 L420 80 L520 140 L640 60 L800 120'/%3E%3Cpath d='M0 320 L120 300 L230 360 L360 290 L470 350 L600 280 L720 340 L800 320'/%3E%3Cpath d='M0 520 L150 560 L260 500 L380 570 L500 490 L620 560 L740 500 L800 520'/%3E%3Cpath d='M0 700 L130 680 L250 730 L370 670 L490 720 L610 660 L730 710 L800 700'/%3E%3Cpath d='M120 0 L160 140 L90 260 L150 380 L80 500 L140 620 L60 740 L120 800'/%3E%3Cpath d='M420 0 L380 130 L450 250 L390 370 L460 490 L400 610 L470 730 L420 800'/%3E%3Cpath d='M680 0 L720 120 L650 240 L710 360 L640 480 L700 600 L630 720 L680 800'/%3E%3C/g%3E%3C/svg%3E"),
    radial-gradient(ellipse at 50% 110%, var(--bg-glow), transparent 55%),
    radial-gradient(ellipse at 50% 50%, transparent 60%, var(--vignette) 100%);
  background-size: 800px 800px, cover, cover;
  background-position: 0 0, center, center;
  background-repeat: repeat, no-repeat, no-repeat;
}
.vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(ellipse at center, transparent 40%, var(--vignette) 100%);
  opacity: var(--vignette-opacity);
}
button { font: inherit; color: inherit; }
a { color: inherit; }
.res-icon { height: 24px; width: 30px; object-fit: contain; flex: none; display: block; }
.res-icon.sm { height: 20px; width: 24px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* кнопки «Главная» и «Тема» в правом верхнем углу — как на главной и в других сервисах */
.corner-btns { position: fixed; top: 16px; right: 16px; z-index: 30; display: flex; gap: 8px; }
.home-link, .theme-btn {
  flex: none; width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center; padding: 0;
  border: 0; border-radius: 8px; background: none; cursor: pointer;
  transition: transform .2s ease, filter .2s ease;
}
.home-link:hover, .home-link:focus-visible, .theme-btn:hover, .theme-btn:focus-visible { transform: translateY(-2px); }
.home-link:hover, .home-link:focus-visible { filter: drop-shadow(0 4px 10px rgba(52, 211, 153, .55)); }
.home-link:active { transform: translateY(0) scale(.96); }
.home-link svg { display: block; width: 40px; height: 40px; }
html[data-theme="dark"] .theme-btn:hover, html[data-theme="dark"] .theme-btn:focus-visible { filter: drop-shadow(0 4px 10px rgba(255, 123, 0, .55)); }
html[data-theme="light"] .theme-btn:hover, html[data-theme="light"] .theme-btn:focus-visible { filter: drop-shadow(0 4px 10px rgba(14, 165, 233, .55)); }
.theme-btn:active { transform: translateY(0) scale(.96); }
.theme-btn svg { display: block; width: 40px; height: 40px; }
html[data-theme="dark"] .icon-moon, html[data-theme="light"] .icon-sun { display: none; }

/* ---------- каркас ---------- */
.page { position: relative; z-index: 2; max-width: 1360px; margin: 0 auto; padding: 18px 24px 24px; }

.head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap;
  padding-right: 104px;   /* место под кнопки «Главная» и «Тема» */
  margin-bottom: 18px;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; text-decoration: none; }
.brand img { width: 56px; height: 56px; flex: none; filter: drop-shadow(0 6px 12px rgba(0, 0, 0, .35)); transition: transform .3s ease; }
/* как у шапок остальных сервисов (rc-brand.css) и плиток главной: логотип поворачивается при наведении */
.brand:hover img, .brand:focus-visible img { transform: rotate(-6deg) scale(1.06); }
.brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { .brand img { transition: none; } }
.brand-title {
  font-family: 'Russo One', sans-serif; font-weight: 400; font-size: 30px; line-height: 1.05;
  letter-spacing: .02em; color: var(--title); text-shadow: var(--title-shadow);
}
.brand-title span { color: #d8342c; }

/* ---------- вкладки ---------- */
.tabs {
  display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}
.tab {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 16px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink-2); cursor: pointer;
  font-size: 13.5px; font-weight: 600; white-space: nowrap;
  transition: background .15s, color .15s;
}
.tab:hover { color: var(--text); background: var(--hover); }
.tab[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tab-badge {
  min-width: 20px; padding: 1px 7px; border-radius: 999px;
  background: var(--surface-3); color: var(--ink-2);
  font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: center;
}
.tab[aria-selected="true"] .tab-badge { background: rgba(255, 255, 255, .25); color: inherit; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; font-weight: 600;
}
.btn:hover { background: var(--hover); border-color: var(--accent); }
.btn:focus-visible, td.cell:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- уведомление ---------- */
.notice {
  margin: 0 0 16px; padding: 12px 16px; border-radius: 8px;
  background: var(--info-bg); color: var(--info-ink); border: 1px solid var(--border); font-size: 13.5px;
  display: flex; gap: 10px; align-items: flex-start;
}
.notice[hidden] { display: none; }
.notice.warn { background: var(--warn-bg); color: var(--warn-ink); }
.notice b { font-weight: 650; }

/* ---------- разделы ---------- */
.view { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; outline: none; min-width: 0; }
.view[hidden] { display: none; }
.view:not([hidden]) { animation: view-in .18s ease-out; }
@keyframes view-in { from { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) { .view:not([hidden]) { animation: none; } }
.view-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.view-head h1 {
  font-size: 20px; font-weight: 700; margin: 0; padding-left: 10px;
  border-left: 3px solid var(--accent); line-height: 1.2;
}
.view-sub { color: var(--muted); font-size: 13px; }

/* ---------- рамка: ржавый металл с заклёпками и «экран» внутри (как анализ боя) ---------- */
.frame {
  --frame: 12px; --cut: 14px; --notch: 4px;
  position: relative; min-width: 0;
  padding: calc(var(--frame) + 6px) calc(var(--frame) + 10px);
  background: #8C583A;
}
.frame, .frame::before {
  clip-path: polygon(
    var(--cut) 0,
    calc(50% - var(--notch) * 2) 0, 50% var(--notch), calc(50% + var(--notch) * 2) 0,
    calc(100% - var(--cut)) 0, 100% var(--cut),
    100% calc(50% - var(--notch) * 2), calc(100% - var(--notch)) 50%, 100% calc(50% + var(--notch) * 2),
    100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%,
    calc(50% + var(--notch) * 2) 100%, 50% calc(100% - var(--notch)), calc(50% - var(--notch) * 2) 100%,
    var(--cut) 100%, 0 calc(100% - var(--cut)),
    0 calc(50% + var(--notch) * 2), var(--notch) 50%, 0 calc(50% - var(--notch) * 2),
    0 var(--cut)
  );
}
.frame::before, .frame::after { content: ""; position: absolute; pointer-events: none; }
.frame::before {
  --cut: 13px; --notch: 3.5px;
  inset: 2px;
  background:
    radial-gradient(circle at 7px 7px, #A67B5B 2px, transparent 2.6px),
    radial-gradient(circle at calc(100% - 7px) 7px, #A67B5B 2px, transparent 2.6px),
    radial-gradient(circle at 7px calc(100% - 7px), #A67B5B 2px, transparent 2.6px),
    radial-gradient(circle at calc(100% - 7px) calc(100% - 7px), #A67B5B 2px, transparent 2.6px),
    linear-gradient(135deg, #5C4033 0%, #3E2A20 50%, #261913 100%);
}
.frame::after {
  inset: var(--frame);
  border: 1.1px solid var(--border); border-radius: 3px;
  background: var(--screen);
}
.frame > * { position: relative; z-index: 1; }

/* маленькая рамка — у каждой карточки (плитки, калькулятор, графики): тоньше, заклёпки мельче */
.frame-sm { --frame: 8px; --cut: 7px; --notch: 3px; padding: calc(var(--frame) + 8px) calc(var(--frame) + 9px); }
.frame.frame-sm::before {
  --cut: 6px; --notch: 2.5px;
  background:
    radial-gradient(circle at 3px 3px, #A67B5B 1.4px, transparent 1.9px),
    radial-gradient(circle at calc(100% - 3px) 3px, #A67B5B 1.4px, transparent 1.9px),
    radial-gradient(circle at 3px calc(100% - 3px), #A67B5B 1.4px, transparent 1.9px),
    radial-gradient(circle at calc(100% - 3px) calc(100% - 3px), #A67B5B 1.4px, transparent 1.9px),
    linear-gradient(135deg, #5C4033 0%, #3E2A20 50%, #261913 100%);
}
.frame-sm::after { border-radius: 2px; transition: border-color .15s, box-shadow .15s; }

/* ---------- плитки лучших цен ---------- */
/* 8 ресурсов: в ряд на широком экране, 4×2 на среднем, по 2 на телефоне — без «хвоста» */
.tiles { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 1240px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 600px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile {
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
  border: 0; text-align: left; cursor: pointer; transition: transform .15s;
}
.tile:hover { transform: translateY(-1px); }
.tile:hover::after { border-color: var(--accent); }
.tile:focus-visible { outline: none; }
.tile:focus-visible::after { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.tile[disabled] { cursor: default; opacity: .55; transform: none; }
.tile-head { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 13px; font-weight: 600; min-width: 0; }
.tile-head span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-value { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.tile-value .v { font-size: 24px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-shops { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--muted); font-size: 12px; white-space: nowrap; }
.tile-shops b { color: var(--ink-2); font-weight: 600; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
.tile-shops .more {
  flex: none; padding: 0 6px; border-radius: 999px; line-height: 16px;
  background: var(--surface-3); color: var(--ink-2); font-size: 11px; font-weight: 600;
}

/* ---------- таблица цен ---------- */
.table-wrap { overflow-x: auto; }
table.prices { border-collapse: separate; border-spacing: 0; width: 100%; font-variant-numeric: tabular-nums; }
.prices th, .prices td { padding: 8px 10px; text-align: right; white-space: nowrap; }
.prices thead th {
  font-size: 12px; font-weight: 600; color: var(--muted);
  border-bottom: 1px solid var(--border); vertical-align: bottom;
}
.prices thead .res-head { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.prices th.shop-col, .prices td.shop-col { text-align: left; }
.prices tbody tr + tr td { border-top: 1px solid var(--grid); }
.prices tbody tr:hover td { background: var(--hover); }
.shop-name { font-weight: 600; }
.shop-line { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.coords { color: var(--muted); font-size: 12px; font-weight: 400; white-space: nowrap; }
.shop-city-inline { color: var(--muted); font-size: 12px; white-space: nowrap; }
td.cell { cursor: pointer; border-radius: 4px; }
td.cell:hover { background: var(--wash) !important; }
.price-val { font-size: 14.5px; font-weight: 600; }
.price-val.stale { color: var(--muted); font-weight: 500; }
/* лучшая и худшая цена ресурса за последний день — цветом */
.prices td.cell.best-price { background: var(--best-bg); }
.prices td.cell.worst-price { background: var(--worst-bg); }
.prices td.cell.best-price .price-val { color: var(--up); font-weight: 700; }
.prices td.cell.worst-price .price-val { color: var(--down); font-weight: 700; }
.legend { display: inline-flex; align-items: center; gap: 5px; margin-left: 14px; white-space: nowrap; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-left: 6px; }
.legend-dot:first-child { margin-left: 0; }
.legend-dot.best { background: var(--up); }
.legend-dot.worst { background: var(--down); }
.delta { font-size: 12px; font-weight: 600; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.delta.flat, .delta.none { color: var(--muted); }
td.empty { color: var(--muted); }

/* ---------- калькулятор ---------- */
.calc-clear { margin-left: auto; align-self: center; }
.qty-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.qty-card { display: flex; flex-direction: column; gap: 8px; min-width: 0; cursor: text; }
.qty-card:focus-within::after { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.qty-head { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.qty-input {
  width: 100%; min-width: 0; padding: 0; border: 0; outline: none; background: transparent;
  color: var(--text); font: 700 22px/1.15 'Segoe UI', system-ui, sans-serif; font-variant-numeric: tabular-nums;
}
.qty-input::placeholder { color: var(--muted); opacity: .6; }

.calc-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; }
.calc-summary:empty { display: none; }
.sum-card { min-width: 0; }
.sum-card.best::after { border-color: var(--accent); background: linear-gradient(var(--wash), var(--wash)), var(--screen); }
.sum-label { color: var(--ink-2); font-size: 13px; font-weight: 600; }
.sum-value { font-size: 28px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.sum-value .delta { font-size: 14px; vertical-align: middle; }
.sum-note { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.calc-table td.calc-cell { cursor: default; }
.calc-table td.calc-cell.top .price-val { color: var(--accent); }
.calc-rate { color: var(--muted); font-size: 12px; }
.calc-rate.stale { color: var(--down); }
.calc-table .total-col { padding-left: 18px; }
.total-val { font-size: 16px; font-weight: 700; }
.best-row td { background: var(--wash); }
.best-row td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.best-badge { color: var(--accent); font-size: 11.5px; font-weight: 600; }
.need-mark {
  display: inline-block; width: 15px; height: 15px; margin-right: 5px; border-radius: 50%;
  background: var(--warn-bg); color: var(--warn-ink); font-size: 11px; font-weight: 700; line-height: 15px; text-align: center;
  vertical-align: 1px;
}
.calc-empty { text-align: center !important; padding: 28px 10px !important; white-space: normal !important; }

/* ---------- история: переключатели ---------- */
/* панель фильтров — в той же рамке, что карточки; при прокрутке прилипает к верху */
.toolbar { position: sticky; top: 8px; z-index: 10; display: grid; gap: 10px; }
.toolbar-row { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.seg { display: inline-flex; flex-wrap: wrap; background: var(--surface-2); border-radius: 8px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; padding: 5px 12px; border-radius: 6px; cursor: pointer;
  color: var(--ink-2); font-size: 13px; font-weight: 600;
}
.seg button:hover { color: var(--text); background: var(--hover); }
.seg button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); }
.seg button:focus-visible, .chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 12px 4px 6px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink-2);
  font-size: 13px; font-weight: 600; min-height: 34px;
}
.chip.text-only { padding: 4px 12px; }
.chip:hover { background: var(--hover); color: var(--text); }
.chip[aria-checked="true"] { border-color: var(--accent); color: var(--text); background: var(--wash); }
.chip[disabled] { opacity: .45; cursor: default; }
.chip .chip-sub { color: var(--muted); font-weight: 400; font-size: 12px; font-variant-numeric: tabular-nums; }

/* «по магазину»: магазины по городам */
.chips.grouped { gap: 8px; }
.chip-group {
  display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px;
  padding: 3px; border-radius: 12px; background: var(--surface-2); max-width: 100%;
}
.chip-group-label { padding: 0 6px 0 9px; color: var(--ink-2); font-size: 12px; font-weight: 700; white-space: nowrap; }
.chip-group .chip { min-height: 30px; border-color: transparent; background: var(--surface); }
.chip-group .chip[aria-checked="true"] { border-color: var(--accent); background: var(--wash); }

/* ---------- история: карточки с картинками графиков ---------- */
.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.card { min-width: 0; scroll-margin-top: 140px; }
.card.flash::after { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); transition-duration: .3s; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.card-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.card-title .t1 { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.card-title .t1-line { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.card-title .t2 { color: var(--muted); font-size: 12px; }
.card-value { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.card-value .v { font-size: 18px; font-weight: 700; line-height: 1.1; }
.card-value .delta { display: block; }
.chart-host { min-height: 150px; border-radius: 3px; overflow: hidden; background: var(--screen-solid); }
.chart-img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.chart-empty {
  min-height: 150px; display: flex; align-items: center; justify-content: center; text-align: center;
  color: var(--muted); font-size: 12.5px; padding: 0 24px;
}
.charts > .chart-empty { grid-column: 1 / -1; }

/* ---------- подвал — как у главной и соседних сервисов ---------- */
footer {
  width: 100%; margin-top: 30px; padding-top: 24px; border-top: 1px solid var(--footer-line);
  display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center;
}
.footer-line, .footer-status {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px;
  font-size: .95rem; color: var(--muted);
}
.footer-line .copyright { color: var(--text); font-weight: 600; }
.footer-line .brand-link {
  background-image: var(--brand-gradient); font-weight: 700;
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.footer-line a { color: inherit; text-decoration: none; text-underline-offset: 3px; }
.footer-line a:hover, .footer-line a:focus-visible { text-decoration: underline; }
.footer-status strong { color: var(--text); font-weight: 700; }
.gear {
  width: 26px; height: 26px; flex: none;
  stroke: var(--brand); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  animation: spin 4s linear infinite; filter: drop-shadow(0 0 6px rgba(99, 243, 130, .45));
}
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .gear { animation: none; } }

@media (max-width: 760px) {
  .page { padding: 14px 12px 20px; }
  .head { padding-right: 0; }
  .brand { padding-right: 100px; }   /* место под кнопки «Главная» и «Тема» — только в строке с названием */
  .brand img { width: 44px; height: 44px; }
  .brand-title { font-size: 24px; }
  .tabs { width: 100%; }
  .tab { flex: 1; justify-content: center; padding: 0 8px; }
  .tab span:not(.tab-badge) { overflow: hidden; text-overflow: ellipsis; }
  .frame:not(.frame-sm) { --frame: 9px; padding: calc(var(--frame) + 4px) calc(var(--frame) + 4px); }
  .charts { grid-template-columns: minmax(0, 1fr); }
  .toolbar { position: static; }
}

/* ---------- анализатор логов банковской ячейки ---------- */
td.empty.left { text-align: left; }
.card-title-text { min-width: 0; }
.btn[hidden] { display: none; }
.btn:disabled { opacity: .5; cursor: default; }
.view-actions { margin-left: auto; align-self: center; display: flex; flex-wrap: wrap; gap: 8px; }
.an-shop { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.an-label { color: var(--ink-2); font-size: 13px; font-weight: 700; }
.an-select {
  min-width: 260px; max-width: 100%; height: 34px; padding: 0 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font: 600 13.5px 'Segoe UI', system-ui, sans-serif; cursor: pointer;
}
.an-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.an-select option, .an-select optgroup { background: var(--screen-solid); color: var(--text); }
.an-hint { color: var(--muted); font-size: 12.5px; }
.an-reset { margin-left: auto; }
.an-price-hint { min-height: 16px; margin-top: -4px; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.an-price-hint .stale, .an-hint .stale { color: var(--down); }
.an-edited { color: var(--best); }
.an-log-frame { display: grid; gap: 8px; }
.an-log {
  width: 100%; min-height: 220px; resize: vertical; padding: 10px 12px; border-radius: 4px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: 12.5px/1.5 Consolas, 'Cascadia Mono', 'DejaVu Sans Mono', monospace;
}
.an-log:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--wash); }
.an-log::placeholder { color: var(--muted); opacity: .8; }
.an-stats { color: var(--muted); font-size: 12.5px; min-height: 18px; }
#anWarn { margin: 0; }
#anWarn > div > div + div { margin-top: 6px; }
#anWarn summary { cursor: pointer; font-weight: 600; }
.an-skipped {
  max-height: 220px; overflow: auto; margin: 6px 0 0; padding: 8px 10px; border-radius: 4px;
  background: var(--surface); color: var(--text); white-space: pre-wrap;
  font: 12px/1.45 Consolas, 'Cascadia Mono', monospace;
}
.an-noprice { color: var(--down); }
.an-table-title { margin: 0 0 10px; color: var(--ink-2); font-size: 13px; font-weight: 700; letter-spacing: .02em; }
.prices tfoot td { border-top: 1px solid var(--border); padding-top: 10px; }
.prices tfoot td.shop-col { font-weight: 700; }
@media (max-width: 760px) {
  .view-actions { margin-left: 0; }
  .an-select { min-width: 0; width: 100%; }
  .an-reset { margin-left: 0; }
}
/* четыре вкладки на узком экране — сеткой 2×2 */
@media (max-width: 560px) {
  .tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tab { justify-content: flex-start; padding: 0 10px; }
}

/* ---------- подсказка при наведении на график ---------- */
.chart-host { position: relative; }
.chart-img { cursor: crosshair; touch-action: pan-y; }
.crosshair { position: absolute; width: 1px; background: var(--muted); opacity: .7; pointer-events: none; }
.crosshair[hidden], .tooltip[hidden] { display: none; }
.tooltip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--screen-solid); color: var(--text); border: 1px solid var(--border);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .22); border-radius: 6px; padding: 8px 10px;
}
.tt-date { color: var(--ink-2); font-size: 12.5px; margin-bottom: 4px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tt-img { display: block; width: 200px; height: 64px; transition: opacity .1s; }
.tt-img.loading { opacity: .45; }
.tt-msg { width: 200px; min-height: 64px; display: flex; align-items: center; color: var(--muted); font-size: 12.5px; }
