/* AezakmiSO — интерфейс в духе таблицы дожития: спокойная сланцевая основа,
   цвет несут только данные (синий — в сторе, красный — удалено). */

[hidden] { display: none !important; }

/* Флаги стран: на Windows своих флагов-эмодзи нет, поэтому берём их из маленького шрифта (только флаги, 78 КБ).
   unicode-range — шрифт применяется только к символам флагов, остальной текст рисует основной шрифт. */
@font-face {
  font-family: "Twemoji Country Flags";
  src: url("vendor/TwemojiCountryFlags.woff2") format("woff2");
  unicode-range: U+1F1E6-1F1FF, U+1F3F4, U+E0062-E0063, U+E0065, U+E0067, U+E006C, U+E006E, U+E0073-E0074, U+E0077, U+E007F;
  font-display: swap;
}

:root {
  color-scheme: light;
  --page: #eef1f4;
  --surface: #fbfcfd;
  --surface-2: #f4f6f8;
  --ink: #15202b;
  --ink-2: #4a5866;
  --muted: #6f7c88;
  --line: #dce2e8;
  --line-strong: #c3ccd5;
  --focus: #2a78d6;

  --alive: #2a78d6;
  --alive-faint: rgba(42, 120, 214, 0.28);
  --removed: #e34948;
  --missing: #b07800;
  --s3: #1baf7a;
  --s4: #eda100;

  --ok-text: #12642f;
  --bad-text: #b0282a;
  --star: #b07800;

  --radius: 6px;
  --font: "Twemoji Country Flags", "Golos Text", system-ui, -apple-system, "Segoe UI", sans-serif;
  --fs-xs: 12px;
  --fs-sm: 13.5px;
  --fs-base: 15px;
  --fs-md: 18px;
  --fs-lg: 22px;
  --fs-xl: 30px;
  --fs-hero: clamp(28px, 3.6vw, 42px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0f1419;
    --surface: #161c22;
    --surface-2: #1c232a;
    --ink: #e7ecf0;
    --ink-2: #a9b4be;
    --muted: #87939e;
    --line: #263039;
    --line-strong: #34404b;
    --focus: #3987e5;
    --alive: #3987e5;
    --alive-faint: rgba(57, 135, 229, 0.3);
    --removed: #e66767;
    --missing: #d9a234;
    --s3: #199e70;
    --s4: #c98500;
    --ok-text: #4cc46a;
    --bad-text: #f08a8a;
    --star: #e8b33c;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0f1419;
  --surface: #161c22;
  --surface-2: #1c232a;
  --ink: #e7ecf0;
  --ink-2: #a9b4be;
  --muted: #87939e;
  --line: #263039;
  --line-strong: #34404b;
  --focus: #3987e5;
  --alive: #3987e5;
  --alive-faint: rgba(57, 135, 229, 0.3);
  --removed: #e66767;
  --missing: #d9a234;
  --s3: #199e70;
  --s4: #c98500;
  --ok-text: #4cc46a;
  --bad-text: #f08a8a;
  --star: #e8b33c;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 var(--fs-base)/1.5 var(--font);
  font-feature-settings: "kern";
}
a { color: inherit; }
img { display: block; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- верхняя панель ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--page); border-bottom: 1px solid var(--line); }
.topbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 0 24px; height: 60px;
  display: flex; align-items: center; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: var(--fs-md); text-decoration: none; letter-spacing: -0.02em; }
.brand svg { width: 24px; height: 24px; fill: none; stroke: var(--alive); stroke-width: 3; stroke-linecap: round; }
.brand svg .x { stroke: var(--removed); stroke-width: 2.4; }
.nav { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav a {
  text-decoration: none; color: var(--ink-2); padding: 7px 12px; border-radius: var(--radius);
  white-space: nowrap; font-weight: 500; font-size: var(--fs-sm);
}
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.run-status { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; }
.progress { height: 2px; background: var(--line); }
.progress-bar { height: 100%; width: 0; background: var(--alive); transition: width .4s ease; }

/* ---------- кнопки и поля ---------- */
.btn {
  font: 500 var(--fs-sm)/1 var(--font); border-radius: var(--radius); padding: 9px 14px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn-primary:hover { opacity: .88; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--ink); }
.btn-small { padding: 6px 10px; font-size: var(--fs-xs); }
.icon-btn { padding: 7px; }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.icon-btn svg .fill { fill: currentColor; stroke: none; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link-btn:hover { color: var(--ink); }

input[type="text"], input[type="number"], input[type="search"], select {
  font: 400 var(--fs-sm)/1.2 var(--font); color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 8px 10px; min-height: 36px;
}
input[type="number"] { width: 84px; }
input:focus, select:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
.field { display: grid; gap: 5px; font-size: var(--fs-xs); color: var(--ink-2); font-weight: 500; }
label.check { display: inline-flex; align-items: center; gap: 7px; font-size: var(--fs-sm); color: var(--ink-2); }
.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 2px; background: var(--surface); }
.segmented button {
  font: 500 var(--fs-sm)/1 var(--font); border: 0; background: none; color: var(--ink-2);
  padding: 7px 11px; border-radius: 4px; cursor: pointer; white-space: nowrap;
}
.segmented button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }

/* ---------- раскладка ---------- */
.view { max-width: 1240px; margin: 0 auto; padding: 28px 24px 80px; outline: none; }
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 16px; margin-bottom: 28px; }
.spacer { flex: 1; }
.page-title { font-size: var(--fs-xl); margin-bottom: 6px; letter-spacing: -0.02em; }
.page-lead { color: var(--ink-2); max-width: 70ch; margin-bottom: 24px; }
.section { margin-top: 44px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.section-head h2 { font-size: var(--fs-md); }
.section-head .hint { color: var(--muted); font-size: var(--fs-xs); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 40px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-xs); }
.nowrap { white-space: nowrap; }

/* ---------- главный вывод ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px 48px; align-items: end; margin-bottom: 22px; }
.hero h1 { font-size: var(--fs-hero); font-weight: 600; letter-spacing: -0.03em; line-height: 1.08; max-width: 28ch; text-wrap: balance; }
.hero-sub { color: var(--ink-2); margin-top: 12px; max-width: 62ch; }
.hero-figures { display: flex; gap: 32px; }
.figure { min-width: 92px; }
.figure b { display: block; font-size: var(--fs-xl); font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.figure span { font-size: var(--fs-xs); color: var(--muted); }

/* ---------- линии жизни ---------- */
.lifelines { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px 10px; }
.lifelines canvas { display: block; width: 100%; cursor: crosshair; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: var(--fs-xs); color: var(--ink-2); margin-top: 8px; }
.legend i { display: inline-block; width: 18px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.legend i.dot { width: 9px; height: 9px; border-radius: 50%; }
.legend .x-mark { color: var(--removed); font-weight: 700; margin-right: 5px; }

/* ---------- графики ---------- */
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }
.chart-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; gap: 12px; }
.chart-note { color: var(--muted); font-size: var(--fs-xs); }
.data-table-wrap { margin-top: 12px; max-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); }

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: var(--fs-xs); background: var(--surface); position: sticky; top: 0; z-index: 1; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td:not(.hc) { background: var(--surface-2); }
tr.clickable:hover td.hc { outline: 1px solid var(--line-strong); outline-offset: -1px; }
.app-cell { display: flex; align-items: center; gap: 11px; min-width: 220px; }
.app-cell img, .icon-ph { width: 34px; height: 34px; border-radius: 8px; flex: none; background: var(--surface-2); object-fit: cover; box-shadow: inset 0 0 0 1px var(--line); }
.app-cell .t { font-weight: 500; line-height: 1.3; }
.app-cell .d { color: var(--muted); font-size: var(--fs-xs); }
.empty { padding: 36px 20px; text-align: center; color: var(--ink-2); }
.empty b { display: block; color: var(--ink); font-size: var(--fs-md); margin-bottom: 6px; font-weight: 600; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; font-size: var(--fs-sm); color: var(--ink-2); }

/* ---------- статусы ---------- */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 500; white-space: nowrap; color: var(--ink-2); }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.status.active::before { background: var(--alive); }
.status.removed { color: var(--bad-text); }
.status.removed::before { background: var(--removed); border-radius: 1px; transform: rotate(45deg); width: 7px; height: 7px; }
.status.missing { color: var(--missing); }
.status.missing::before { background: transparent; box-shadow: inset 0 0 0 2px var(--missing); }
.status.not_found::before, .status.pending::before { background: transparent; box-shadow: inset 0 0 0 2px var(--muted); }
.store-tag { font-size: var(--fs-xs); color: var(--ink-2); white-space: nowrap; }

/* ---------- лента событий ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 26px 34px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed .ev-icon { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; background: var(--surface-2); color: var(--ink-2); }
.feed .ev-icon.removed { color: var(--bad-text); }
.feed .ev-icon.discovered, .feed .ev-icon.restored { color: var(--alive); }
.feed .ev-text { min-width: 0; }
.feed .ev-text a { font-weight: 500; text-decoration: none; }
.feed .ev-text a:hover { text-decoration: underline; }
.feed .ev-text .what { color: var(--ink-2); font-size: var(--fs-sm); }
.feed time { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; }
.feed img { width: 30px; height: 30px; border-radius: 7px; }

/* ---------- сравнение групп ---------- */
.groups-key { display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: var(--fs-sm); color: var(--ink-2); margin: 4px 0 18px; }
.groups-key i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 7px; vertical-align: -1px; }
.dumbbells { display: grid; gap: 2px; }
.db-row { display: grid; grid-template-columns: minmax(150px, 260px) minmax(0, 1fr) 190px; align-items: center; gap: 18px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.db-row:last-child { border-bottom: 0; }
.db-label { font-weight: 500; font-size: var(--fs-sm); }
.db-track { position: relative; height: 22px; }
.db-track::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--line); }
.db-track::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--line-strong); }
.db-bar { position: absolute; top: 5px; height: 12px; }
.db-bar.long { left: 50%; background: var(--alive); border-radius: 0 4px 4px 0; }
.db-bar.short { right: 50%; background: var(--removed); border-radius: 4px 0 0 4px; }
.db-axis { display: grid; grid-template-columns: minmax(150px, 260px) minmax(0, 1fr) 190px; gap: 18px; padding-bottom: 6px; font-size: var(--fs-xs); color: var(--muted); }
.db-axis .ends { display: flex; justify-content: space-between; }
.db-axis .ends span:first-child { color: var(--bad-text); }
.db-axis .ends span:last-child { color: var(--alive); }
.db-values { font-size: var(--fs-xs); color: var(--ink-2); text-align: right; font-variant-numeric: tabular-nums; }
.db-values b { color: var(--ink); font-weight: 600; }
.share-bar { display: inline-block; width: 70px; height: 6px; border-radius: 3px; background: var(--surface-2); vertical-align: middle; margin-left: 8px; overflow: hidden; }
.share-bar span { display: block; height: 100%; border-radius: 3px; }

/* ---------- карточка приложения ---------- */
.app-head { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 22px; align-items: center; margin-bottom: 26px; }
.app-head .icon { width: 96px; height: 96px; border-radius: 22px; box-shadow: inset 0 0 0 1px var(--line); background: var(--surface-2); object-fit: cover; }
.app-head h1 { font-size: var(--fs-xl); letter-spacing: -0.02em; }
.app-head .sub { color: var(--ink-2); margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.app-head .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 28px; }
.fact { padding: 10px 0; border-bottom: 1px solid var(--line); }
.fact dt { font-size: var(--fs-xs); color: var(--muted); }
.fact dd { margin: 2px 0 0; font-size: var(--fs-sm); overflow-wrap: anywhere; }
.lifespan { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 30px; }
.lifespan > div { padding: 14px 18px; border-left: 1px solid var(--line); }
.lifespan > div:first-child { border-left: 0; }
.lifespan b { display: block; font-size: var(--fs-lg); font-weight: 600; letter-spacing: -0.01em; }
.lifespan span { font-size: var(--fs-xs); color: var(--muted); }
.devices { display: grid; gap: 10px; }
.device-row { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 14px; align-items: start; }
.device-row .name { font-weight: 500; font-size: var(--fs-sm); padding-top: 4px; }
.device-row .name small { display: block; color: var(--muted); font-weight: 400; font-size: var(--fs-xs); }
.shots { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.shots img { height: 150px; width: auto; border-radius: 8px; box-shadow: inset 0 0 0 1px var(--line); background: var(--surface-2); flex: none; }
.description { white-space: pre-wrap; max-width: 75ch; color: var(--ink-2); font-size: var(--fs-sm); max-height: 260px; overflow: auto; padding-right: 8px; }
.timeline { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line-strong); margin-left: 6px; }
.timeline li { position: relative; padding: 0 0 18px 20px; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--surface); box-shadow: inset 0 0 0 2px var(--muted); }
.timeline li.removed::before { background: var(--removed); box-shadow: none; }
.timeline li.update::before, .timeline li.discovered::before, .timeline li.restored::before { background: var(--alive); box-shadow: none; }
.timeline time { font-size: var(--fs-xs); color: var(--muted); }
.timeline .tl-title { font-weight: 500; font-size: var(--fs-sm); }
.change { margin-top: 6px; font-size: var(--fs-sm); }
.change .field { color: var(--ink-2); }
.diff { margin-top: 4px; padding: 8px 10px; background: var(--surface-2); border-radius: var(--radius); font-size: var(--fs-xs); line-height: 1.6; max-height: 220px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.diff del { background: color-mix(in srgb, var(--removed) 22%, transparent); text-decoration: line-through; text-decoration-color: var(--bad-text); }
.diff ins { background: color-mix(in srgb, var(--alive) 22%, transparent); text-decoration: none; }
.img-change { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.img-change img { width: 44px; height: 44px; border-radius: 10px; box-shadow: inset 0 0 0 1px var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: var(--fs-xs); padding: 3px 8px; border-radius: 4px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }

/* ---------- формы ключей ---------- */
.form-row { display: flex; flex-wrap: wrap; gap: 12px 14px; align-items: end; }
.form-row input[name="term"], .form-row input[name="ref"] { min-width: 260px; flex: 1; }
.form-note { color: var(--muted); font-size: var(--fs-xs); margin-top: 10px; max-width: 80ch; }
.switch { position: relative; width: 34px; height: 20px; flex: none; appearance: none; background: var(--line-strong); border-radius: 10px; cursor: pointer; margin: 0; transition: background .15s; }
.switch::after { content: ""; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); transition: transform .15s; }
.switch:checked { background: var(--alive); }
.switch:checked::after { transform: translateX(14px); }

/* ---------- всплывашки ---------- */
.tooltip {
  position: fixed; z-index: 50; pointer-events: none; max-width: 300px;
  background: var(--ink); color: var(--surface); padding: 8px 10px; border-radius: 6px;
  font-size: var(--fs-xs); line-height: 1.45; box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
}
.tooltip b { font-weight: 600; font-size: var(--fs-sm); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 8px; font-size: var(--fs-sm);
  max-width: min(560px, calc(100vw - 32px));
}
.toast.error { background: var(--bad-text); color: #fff; }
.demo-note { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--s4); padding: 10px 14px; border-radius: 6px; font-size: var(--fs-sm); color: var(--ink-2); margin-bottom: 22px; }
.loading { opacity: .55; transition: opacity .2s; }

@media (max-width: 920px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .hero { grid-template-columns: 1fr; }
  .db-row, .db-axis { grid-template-columns: 1fr; gap: 6px; }
  .db-axis > span:first-child, .db-axis > span:last-child { display: none; }
  .db-values { text-align: left; }
  .lifespan { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lifespan > div:nth-child(3) { border-left: 0; }
  .lifespan > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .app-head { grid-template-columns: 64px minmax(0, 1fr); align-items: start; }
  .app-head .actions .btn { white-space: normal; text-align: left; line-height: 1.3; }
  .app-head .icon { width: 64px; height: 64px; border-radius: 15px; }
}
@media (max-width: 640px) {
  .topbar-inner { padding: 0 16px; gap: 12px; height: auto; flex-wrap: wrap; padding-top: 10px; padding-bottom: 8px; }
  .nav { order: 3; flex-basis: 100%; gap: 0; justify-content: space-between; }
  .nav a { padding: 7px 6px; font-size: 13px; }
  .topbar-actions { margin-left: auto; }
  .run-status { display: none; }
  .view { padding: 20px 16px 60px; }
  .hero-figures { gap: 20px; flex-wrap: wrap; }
  .device-row { grid-template-columns: 1fr; }
  .feed li { grid-template-columns: 26px minmax(0, 1fr) auto; }
  .feed li img { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- позиции: последовательная шкала одного оттенка (1-е место — насыщеннее) ---------- */
:root {
  --h2-bg: #cde2fb; --h3-bg: #9ec5f4; --h4-bg: #5598e7; --h5-bg: #256abf; --h6-bg: #104281;
  --h-dark-ink: #ffffff; --h-light-ink: #15202b;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --h2-bg: #1b2f48; --h3-bg: #1c4a85; --h4-bg: #2a78d6; --h5-bg: #6da7ec; --h6-bg: #b7d3f6;
    --h-dark-ink: #0f1419; --h-light-ink: #e7ecf0;
  }
}
:root[data-theme="dark"] {
  --h2-bg: #1b2f48; --h3-bg: #1c4a85; --h4-bg: #2a78d6; --h5-bg: #6da7ec; --h6-bg: #b7d3f6;
  --h-dark-ink: #0f1419; --h-light-ink: #e7ecf0;
}
.h2 { background: var(--h2-bg); color: var(--h-light-ink); }
.h3 { background: var(--h3-bg); color: var(--h-light-ink); }
.h4 { background: var(--h4-bg); color: #fff; }
.h5 { background: var(--h5-bg); color: var(--h-dark-ink); }
.h6 { background: var(--h6-bg); color: var(--h-dark-ink); }

table.heat { border-collapse: separate; border-spacing: 2px; width: auto; }
table.heat td:first-child { min-width: 250px; }
table.heat .app-cell { min-width: 0; }
table.heat .app-cell .t, table.heat .app-cell .d { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
table.heat td { padding-top: 4px; padding-bottom: 4px; }
table.heat th, table.heat td { border-bottom: 0; }
table.heat td.hc { width: 24px; min-width: 24px; max-width: 24px; height: 24px; padding: 0; text-align: center; font-size: 11px; font-variant-numeric: tabular-nums; border-radius: 3px; }
table.heat th.hd { padding: 6px 0; font-size: 10px; white-space: nowrap; text-align: left; }
.heat-wrap { max-height: none; }
.legend .hc-key { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-right: 6px; }

textarea {
  font: 400 var(--fs-sm)/1.4 var(--font); color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 8px 10px; resize: vertical; min-height: 36px;
}
textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
.field > span { font-size: var(--fs-xs); color: var(--ink-2); font-weight: 500; }
.chip.own { margin-left: 8px; border-color: var(--alive); color: var(--alive); background: transparent; }
.app-cell + .chip.own { margin-left: 45px; }

/* ---------- видимость ---------- */
.own-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.own-tab { display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); text-decoration: none; min-width: 0; }
.own-tab img, .own-tab .icon-ph { width: 32px; height: 32px; border-radius: 8px; }
.own-tab b { display: block; font-weight: 500; font-size: var(--fs-sm); }
.own-tab small { color: var(--muted); font-size: var(--fs-xs); }
.own-tab[aria-selected="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
table.matrix td { vertical-align: top; }
.pos-cell { display: inline-grid; justify-items: end; gap: 3px; text-decoration: none; }
.pos-badge { display: inline-block; min-width: 34px; padding: 3px 8px; border-radius: 4px; font-weight: 600; text-align: center; }
.pos-badge:not(.h2):not(.h3):not(.h4):not(.h5):not(.h6) { background: var(--surface-2); color: var(--ink-2); }
.pos-line { display: inline-flex; align-items: center; justify-content: flex-end; }
.pos-cell small { color: var(--muted); font-size: 11px; font-weight: 400; white-space: nowrap; }
.delta { font-size: 11px; font-weight: 600; margin-left: 6px; }
.delta.up { color: var(--ok-text); }
.delta.down { color: var(--bad-text); }
.recs { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-width: 90ch; }
.recs li { padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; font-size: var(--fs-sm); }
.recs .chip { margin-right: 6px; }


/* ---------- общий переключатель гео ---------- */
.geo-bar { border-top: 1px solid var(--line); background: var(--page); }
.geo-inner { max-width: 1240px; margin: 0 auto; padding: 8px 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.geo-label { font-size: var(--fs-xs); color: var(--muted); font-weight: 500; }
.geo-inner .segmented button { padding: 6px 10px; }
.country-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.country-chips button {
  font: 600 var(--fs-xs)/1 var(--font); letter-spacing: 0.02em; border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink-2); padding: 7px 10px; border-radius: 4px; cursor: pointer; min-width: 40px;
}
.country-chips button:first-child { font-weight: 500; letter-spacing: 0; }
.country-chips button:hover { border-color: var(--ink-2); color: var(--ink); }
.country-chips button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }

/* ---------- заголовки страниц ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; margin-bottom: 18px; }
.page-head .page-title { margin: 0; }
.crumbs { margin-bottom: 14px; }
.add-panel { margin-bottom: 22px; padding: 0; }
.add-panel > summary { cursor: pointer; padding: 14px 20px; font-weight: 500; list-style: none; display: flex; align-items: center; gap: 8px; }
.add-panel > summary::-webkit-details-marker { display: none; }
.add-panel > summary::before { content: "+"; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 4px; background: var(--surface-2); color: var(--ink-2); font-weight: 600; }
.add-panel[open] > summary::before { content: "−"; }
.add-panel > form { padding: 0 20px 18px; }

/* ---------- позиции ---------- */
.pos-badge.small { min-width: 26px; padding: 2px 6px; font-size: 11px; }
.pos-badge.big { min-width: 42px; padding: 5px 10px; font-size: var(--fs-md); }
.delta.new { color: var(--alive); font-weight: 600; }
.pos-col { width: 1%; white-space: nowrap; }
th.pos-col, td.pos-col { text-align: left; }
.table-wrap.fit { display: inline-block; max-width: 100%; vertical-align: top; }
table.matrix { width: auto; }
table.matrix th:first-child, table.matrix td:first-child { min-width: 220px; padding-right: 32px; }
table.matrix th:not(:first-child), table.matrix td:not(:first-child) { min-width: 150px; }
.pos-col .pos-line { justify-content: flex-start; }
img.mini, .icon-ph.mini { width: 22px; height: 22px; border-radius: 5px; flex: none; }
.own-pos { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.own-pos-item { display: inline-flex; align-items: center; gap: 6px; }
.leader { display: inline-flex; align-items: center; gap: 8px; max-width: 220px; }
.leader span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: var(--fs-sm); }
.kw-term { font-weight: 600; text-decoration: none; }
a.kw-term:hover { text-decoration: underline; }
.kw-table td { vertical-align: middle; }

/* ---------- выдача ---------- */
.serp-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 14px 28px; margin-bottom: 14px; }
.serp-head h1 { font-size: var(--fs-hero); letter-spacing: -0.03em; line-height: 1.05; }
.serp-head p { margin-top: 8px; }
.geo-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.geo-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border-radius: 6px;
  border: 1px solid var(--line-strong); background: var(--surface); text-decoration: none; font-size: var(--fs-sm); font-weight: 500; color: var(--ink-2);
}
.geo-chip:hover { border-color: var(--ink-2); color: var(--ink); }
.geo-chip[aria-current="page"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); color: var(--ink); }
.score-strip { display: flex; flex-wrap: wrap; gap: 6px 28px; padding: 12px 0; margin-bottom: 8px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.score-strip b { display: block; font-size: var(--fs-md); font-weight: 600; }
.score-strip span { font-size: var(--fs-xs); color: var(--muted); }
.tabs { display: flex; gap: 2px; margin: 18px 0 14px; border-bottom: 1px solid var(--line); }
.tabs button {
  font: 500 var(--fs-sm)/1 var(--font); background: none; border: 0; border-bottom: 2px solid transparent; color: var(--ink-2);
  padding: 10px 14px; cursor: pointer; margin-bottom: -1px;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }

.serp { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.serp-item + .serp-item { border-top: 1px solid var(--line); }
.serp-item.own { background: color-mix(in srgb, var(--alive) 7%, var(--surface)); box-shadow: inset 3px 0 0 var(--alive); }
.serp-row {
  display: grid; grid-template-columns: 64px 56px minmax(200px, 300px) minmax(0, 1fr); gap: 16px; align-items: center;
  padding: 12px 16px; text-decoration: none; color: inherit;
}
.serp-row:hover { background: var(--surface-2); }
.serp-item.own .serp-row:hover { background: color-mix(in srgb, var(--alive) 12%, var(--surface)); }
.serp-pos { display: grid; justify-items: center; gap: 4px; }
.serp-pos .pos-badge { min-width: 40px; font-size: var(--fs-md); padding: 5px 8px; }
.serp-pos .delta { margin: 0; }
.serp-icon { width: 56px; height: 56px; border-radius: 13px; box-shadow: inset 0 0 0 1px var(--line); background: var(--surface-2); object-fit: cover; }
.serp-main { min-width: 0; }
.serp-title { font-weight: 600; line-height: 1.3; }
.serp-dev { color: var(--ink-2); font-size: var(--fs-sm); margin-top: 1px; }
.serp-sub { color: var(--ink-2); font-size: var(--fs-xs); margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.serp-meta { color: var(--muted); font-size: var(--fs-xs); margin-top: 5px; }
.serp-shots { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; min-width: 0; }
.serp-shots img { height: 132px; width: auto; max-width: 260px; border-radius: 7px; flex: none; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); object-fit: cover; }

/* ---------- видимость ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 26px; }
.kpis > div { padding: 12px 18px; border-left: 1px solid var(--line); }
.kpis > div:first-child { border-left: 0; }
.kpis b { display: block; font-size: var(--fs-lg); font-weight: 600; letter-spacing: -0.01em; }
.kpis span { font-size: var(--fs-xs); color: var(--muted); }
table.matrix td { padding-top: 12px; padding-bottom: 12px; }
table.matrix td:first-child { vertical-align: middle; }

@media (max-width: 920px) {
  .serp-row { grid-template-columns: 52px 48px minmax(0, 1fr); }
  .serp-shots { grid-column: 1 / -1; }
  .serp-shots img { height: 112px; }
  .serp-icon { width: 48px; height: 48px; border-radius: 11px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis > div:nth-child(3) { border-left: 0; }
  .kpis > div:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@media (max-width: 640px) {
  .geo-inner { padding: 8px 16px; }
}
@media (max-width: 640px) {
  .score-strip { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
}


/* ================= структура v3 ================= */
.demo-pill { font-size: var(--fs-xs); font-weight: 600; color: var(--missing); border: 1px solid currentColor; border-radius: 4px; padding: 2px 7px; margin-left: -14px; }
.page-head { justify-content: space-between; }
.page-head .tabs { margin: 0; border-bottom: 0; }
.tabs a {
  font: 500 var(--fs-sm)/1 var(--font); border-bottom: 2px solid transparent; color: var(--ink-2); text-decoration: none;
  padding: 10px 14px; margin-bottom: -1px; white-space: nowrap;
}
.tabs a:hover { color: var(--ink); }
.tabs a[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.page-head .tabs a { border: 1px solid transparent; border-radius: var(--radius); padding: 8px 12px; margin: 0; }
.page-head .tabs a[aria-selected="true"] { border-color: var(--line); background: var(--surface); }
.page-head + .tabs, .kpis + .tabs { margin-top: 0; }
.lead-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 12px 24px; }
.lead-row .page-lead { margin-bottom: 0; }
a.plain { text-decoration: none; }

/* меню «Ещё» / «Настройки ключа» */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: "▾"; font-size: 10px; margin-left: 2px; }
.menu-body {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 280px; display: grid; gap: 10px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; padding: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.18);
}
.app-head .menu-body { left: 0; right: auto; }
.menu-item { display: block; text-align: left; background: none; border: 0; font: 400 var(--fs-sm)/1.3 var(--font); color: var(--ink); padding: 6px 4px; border-radius: 4px; text-decoration: none; cursor: pointer; }
.menu-item:hover { background: var(--surface-2); }

/* сводка */
.onboard { max-width: 760px; padding: 24px 0; }
.onboard h1 { font-size: var(--fs-hero); letter-spacing: -0.03em; margin-bottom: 10px; }
.steps { list-style: none; counter-reset: step; margin: 26px 0 0; padding: 0; display: grid; gap: 10px; }
.steps li { counter-increment: step; display: flex; align-items: center; gap: 18px; justify-content: space-between; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px 18px 16px 62px; position: relative; }
.steps li::before { content: counter(step); position: absolute; left: 18px; top: 16px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; background: var(--surface-2); color: var(--ink-2); }
.steps li:first-child::before { background: var(--ink); color: var(--surface); }
.steps b { display: block; margin-bottom: 2px; }
.steps span { color: var(--ink-2); font-size: var(--fs-sm); }
.callout { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; padding: 16px 18px; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: 8px; }
.callout b { display: block; }
.callout span { color: var(--ink-2); font-size: var(--fs-sm); }
.own-list { display: grid; gap: 8px; }
.own-row { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: 14px 24px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; }
.own-app { display: flex; align-items: center; gap: 12px; text-decoration: none; min-width: 0; }
.own-app img, .own-app .icon-ph { width: 44px; height: 44px; border-radius: 10px; flex: none; }
.own-app b { display: block; font-weight: 600; line-height: 1.25; }
.own-app small { color: var(--muted); font-size: var(--fs-xs); }
.own-cells { display: flex; flex-wrap: wrap; gap: 6px; }
.cell-chip { display: inline-flex; align-items: center; gap: 7px; padding: 4px 6px 4px 10px; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; font-size: var(--fs-sm); background: var(--surface-2); }
.cell-chip:hover { border-color: var(--ink-2); }
.cell-chip small { color: var(--muted); font-size: 11px; }
.cell-chip .delta { margin-left: 0; }
.cell-more { align-self: center; font-size: var(--fs-xs); color: var(--ink-2); }
.moves, .mini-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.moves li + li, .mini-list li + li { border-top: 1px solid var(--line); }
.moves li.own { box-shadow: inset 3px 0 0 var(--alive); background: color-mix(in srgb, var(--alive) 6%, var(--surface)); }
.moves a, .mini-list a, .mini-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 9px 14px; text-decoration: none; color: inherit; }
.moves a:hover, .mini-list a:hover { background: var(--surface-2); }
.moves img, .moves .icon-ph, .mini-list img, .mini-list .icon-ph { width: 32px; height: 32px; border-radius: 8px; }
.move-text { min-width: 0; font-size: var(--fs-sm); }
.move-text b { font-weight: 600; }
.move-text > span:not(.chip) { display: block; color: var(--ink-2); font-size: var(--fs-xs); }
.move-text > .move-time { color: var(--muted); font-size: 11px; margin-top: 1px; }
.move-pos { display: inline-flex; align-items: center; gap: 6px; }
.move-pos .arrow { color: var(--muted); }
.mini-list b { display: block; font-weight: 500; font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-list small { color: var(--muted); font-size: var(--fs-xs); }
.mini-list time { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; }
.risk-val { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-sm); }
#own-results { margin-top: 10px; }
#own-results:empty { display: none; }

/* позиции: мастер-деталь */
.positions { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 28px; align-items: start; }
.kw-pane { position: sticky; top: 124px; max-height: calc(100vh - 140px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.kw-pane-head { display: flex; gap: 8px; padding: 10px; border-bottom: 1px solid var(--line); }
.kw-pane-head input { flex: 1; min-width: 0; }
.kw-list { list-style: none; margin: 0; padding: 4px; overflow-y: auto; }
.kw-list a { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 6px; text-decoration: none; }
.kw-list a:hover { background: var(--surface-2); }
.kw-list a[aria-current="page"] { background: var(--ink); color: var(--surface); }
.kw-list a[aria-current="page"] small { color: color-mix(in srgb, var(--surface) 70%, transparent); }
.kw-name { min-width: 0; font-weight: 500; font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; }
.kw-name small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }
.kw-right { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.kw-empty { padding: 14px 10px; color: var(--muted); font-size: var(--fs-sm); }
.serp-pane { min-width: 0; }
.serp-pane .serp-head h1 { font-size: var(--fs-xl); }
.back-link { display: none; margin-bottom: 12px; font-size: var(--fs-sm); color: var(--ink-2); }
.add-inline { margin-bottom: 18px; }
.facts.one-col { grid-template-columns: 1fr; }

@media (max-width: 920px) {
  .positions { grid-template-columns: 1fr; }
  .kw-pane { position: static; max-height: none; }
  .positions.has-detail .kw-pane { display: none; }
  .positions:not(.has-detail) .serp-pane { display: none; }
  .back-link { display: inline-block; }
  .own-row { grid-template-columns: 1fr; }
  .steps li { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 640px) {
  .demo-pill { display: none; }
  .moves a { grid-template-columns: 28px minmax(0, 1fr); }
  .move-pos { grid-column: 2; }
}
.serp-pane .score-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px 20px; }
@media (max-width: 640px) {
  table.matrix th:first-child, table.matrix td:first-child { min-width: 110px; padding-right: 12px; }
  table.matrix th:not(:first-child), table.matrix td:not(:first-child) { min-width: 96px; }
  .pos-cell small { white-space: normal; text-align: right; }
}

/* обновления и графика «было → стало» */
.updates { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.updates li + li { border-top: 1px solid var(--line); }
.updates li.own { box-shadow: inset 3px 0 0 var(--alive); }
.updates a { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 10px 14px; text-decoration: none; color: inherit; }
.updates a:hover { background: var(--surface-2); }
.updates a > img, .updates a > .icon-ph { width: 36px; height: 36px; border-radius: 9px; }
.upd-main { min-width: 0; display: grid; gap: 8px; font-size: var(--fs-sm); }
.upd-main b { font-weight: 600; }
.upd-what { color: var(--ink-2); margin-left: 6px; }
.updates time { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; }
.ba { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ba-label { font-size: 11px; color: var(--muted); width: 58px; flex: none; }
.ba .arrow { color: var(--muted); }
.ba-shots { display: flex; gap: 4px; overflow-x: auto; min-width: 0; }
.ba-shots img { height: 64px; width: auto; max-width: 120px; border-radius: 5px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); flex: none; }
.ba-block { display: grid; gap: 6px; margin-top: 6px; }
.change .ba-shots img { height: 84px; }

.storage-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 24px; margin: 14px 0 6px; }
.storage-grid b { display: block; font-size: var(--fs-lg); font-weight: 600; }
.storage-grid span { font-size: var(--fs-xs); color: var(--muted); }
.policy { margin: 10px 0 0; padding-left: 18px; color: var(--ink-2); font-size: var(--fs-sm); display: grid; gap: 4px; max-width: 90ch; }
@media (max-width: 640px) { .storage-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.small-seg button { padding: 5px 9px; font-size: var(--fs-xs); }

/* ---------- ключ сначала, страна потом ---------- */
.country-row { display: flex; flex-wrap: wrap; gap: 0 28px; margin-bottom: 16px; }
.country-row .geo-chips { align-items: center; margin-bottom: 6px; }
.country-row .row-label { font-size: var(--fs-xs); color: var(--muted); font-weight: 500; margin-right: 4px; }
.geo-pos { display: flex; flex-wrap: nowrap; gap: 4px; }
.geo-pos .gp {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 6px; border-radius: 4px;
  border: 1px solid var(--line); background: var(--surface); text-decoration: none; color: var(--ink-2);
}
.geo-pos .gp:hover { border-color: var(--ink-2); color: var(--ink); }
.geo-pos .gp small { font-size: 11px; font-weight: 600; letter-spacing: 0.02em; }
.geo-pos .delta { font-size: 11px; }

/* ---------- даты в карточке ---------- */
.dates-line { display: flex; flex-wrap: wrap; gap: 4px 22px; margin-top: 10px; font-size: var(--fs-sm); color: var(--ink-2); }
.dates-line b { color: var(--ink); font-weight: 600; }
.timeline li.released::before { background: var(--ink); box-shadow: none; }
.timeline li.prior_update::before { background: var(--surface); box-shadow: inset 0 0 0 2px var(--alive); }
.timeline .tl-note { font-size: var(--fs-xs); color: var(--muted); margin: 0 0 14px; max-width: 70ch; }

/* ---------- выбор стран ---------- */
.country-picker { display: grid; gap: 10px; font-weight: 400; }
.cp-quick, .cp-results { display: flex; flex-wrap: wrap; gap: 6px; }
.cp-results:empty { display: none; }
.cp-chip {
  font: 600 var(--fs-xs)/1 var(--font); letter-spacing: 0.02em; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface);
}
.cp-chip span { font-weight: 400; letter-spacing: 0; color: var(--muted); }
.cp-chip:hover { border-color: var(--ink-2); color: var(--ink); }
.cp-chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.cp-chip[aria-pressed="true"] span { color: var(--surface); opacity: 0.8; }
.cp-search-row input { width: min(100%, 360px); }
.cp-selected { font-size: var(--fs-sm); color: var(--ink-2); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.cp-tag {
  display: inline-flex; align-items: center; gap: 2px; padding: 2px 2px 2px 8px; border-radius: 4px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); font-size: var(--fs-xs); font-weight: 500;
}
.cp-tag button {
  border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1;
  width: 22px; height: 22px; border-radius: 3px;
}
.cp-tag button:hover { color: var(--bad-text); background: var(--surface); }

/* ---------- прогнозы: что и где ---------- */
.explain { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 8px 0 8px; }
.explain > div { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px 18px; display: grid; align-content: start; gap: 8px; }
.explain-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.explain-head h3 { font-size: var(--fs-base); }
.explain p { font-size: var(--fs-sm); color: var(--ink-2); margin: 0; }
.explain .where { font-size: var(--fs-xs); color: var(--muted); border-top: 1px solid var(--line); padding-top: 8px; margin-top: 2px; }
.ready { font-size: 11px; font-weight: 600; padding: 3px 7px; border-radius: 4px; white-space: nowrap; color: var(--missing); border: 1px solid currentColor; }
.ready.ok { color: var(--ok-text); }
@media (max-width: 920px) { .explain { grid-template-columns: 1fr; } }
/* фильтры в одну строку: ключ → страна → стор, одной высоты с полями */
.filters .country-chips button { min-height: 36px; padding: 0 11px; }
.filters .segmented { min-height: 36px; align-items: stretch; }
.filters .segmented button { padding: 0 11px; }
.filters .field > span { line-height: 1.2; }
@media (max-width: 640px) {
  /* вкладки страниц не вылезают за экран */
  .page-head .tabs { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .page-head .tabs a { white-space: nowrap; padding: 8px 9px; }
  /* форма ключей в столбик: поле ключей во всю ширину */
  .form-row > .field { flex: 1 1 100%; }
  .form-row textarea { width: 100%; }
  /* места по странам переносятся, а не растягивают таблицу */
  .geo-pos { flex-wrap: wrap; white-space: normal; max-width: 150px; }
  .app-head .menu-body { left: auto; right: 0; max-width: calc(100vw - 32px); }
}

input.depth { width: 72px; min-height: 30px; padding: 4px 8px; text-align: right; }

/* ---------- вход ---------- */
input[type="password"] {
  font: 400 var(--fs-sm)/1.2 var(--font); color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 8px 10px; min-height: 36px;
}
input[type="password"]:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
.user-box { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.user-name { font-size: var(--fs-xs); color: var(--muted); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login { width: min(100%, 360px); display: grid; gap: 18px; }
.login-brand { justify-self: center; font-size: var(--fs-md); }
.login-form { display: grid; gap: 14px; padding: 24px; }
.login-form h1 { font-size: var(--fs-lg); }
.login-form input { width: 100%; }
.login-form .btn { justify-content: center; min-height: 40px; }
.login-error { margin: 0; padding: 8px 10px; border-radius: var(--radius); font-size: var(--fs-sm);
  color: var(--bad-text); background: color-mix(in srgb, var(--removed) 10%, transparent); }
.login-note { text-align: center; font-size: var(--fs-xs); color: var(--muted); margin: 0; }
@media (max-width: 640px) { .user-name { display: none; } }

/* ---------- своё приложение: найти или добавить по ссылке ---------- */
.head-actions { display: flex; align-items: center; gap: 12px; }
.own-add { margin-bottom: 16px; }
.own-add-lead { margin: 0 0 14px; color: var(--ink-2); font-size: var(--fs-sm); }
.own-add-lead b { color: var(--ink); }
.own-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: start; }
.own-picker input[type="search"], .own-picker input[name="ref"] { width: 100%; }
.own-picker .mini-list { margin-top: 6px; }
@media (max-width: 920px) { .own-picker { grid-template-columns: minmax(0, 1fr); } }

/* ---------- отдельные листинги в выдаче ---------- */
.chip.listing { border-color: var(--missing); color: var(--missing); background: transparent; margin-left: 6px; }
.listings { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.listings li { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 12px 14px; display: grid; gap: 10px; }
.listing-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.listing-head a { color: var(--ink); text-decoration: none; }
.listing-head a:hover { text-decoration: underline; }
.listing-body { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: start; }
.listing-desc { margin-top: 4px; max-width: 70ch; }
@media (max-width: 640px) { .listing-body { grid-template-columns: auto minmax(0, 1fr); } .listing-body .ba-shots { grid-column: 1 / -1; } }

/* ---------- избранное ---------- */
.star-btn {
  flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0;
  background: none; border: 0; border-radius: 5px; cursor: pointer;
  font: 400 17px/1 system-ui, sans-serif; color: var(--muted); opacity: .5;
  transition: opacity .12s, color .12s, background .12s;
}
.star-btn:hover { opacity: 1; color: var(--star); background: var(--surface-2); }
.star-btn[aria-pressed="true"] { opacity: 1; color: var(--star); }
.star-btn:disabled { cursor: progress; }
.star-mark { color: var(--star); }
.btn.star-toggle[aria-pressed="true"] { color: var(--star); border-color: color-mix(in srgb, var(--star) 55%, var(--line-strong)); }

.kw-list li { display: flex; align-items: center; gap: 2px; }
.kw-list li > a { flex: 1; min-width: 0; }
.kw-list .star-btn { width: 24px; height: 24px; font-size: 15px; }
.kw-group { padding: 10px 10px 4px 32px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.kw-group:first-child { padding-top: 6px; }

.title-star { display: flex; align-items: center; gap: 4px; }
.title-star .star-btn { width: 36px; height: 36px; font-size: 26px; margin-left: -6px; }

.serp-item { display: flex; align-items: stretch; }
.serp-item > .star-btn { align-self: center; margin-left: 8px; }
.serp-item .serp-row { flex: 1; min-width: 0; padding-left: 4px; }
.serp-item:hover, .serp-item:hover .serp-row { background: var(--surface-2); }
.serp-item.own:hover, .serp-item.own:hover .serp-row { background: color-mix(in srgb, var(--alive) 12%, var(--surface)); }

th.star-col, td.star-col { width: 36px; padding-left: 8px !important; padding-right: 0 !important; }

/* ---------- изменить ключ ---------- */
.kw-edit { margin-bottom: 20px; padding-top: 14px; padding-bottom: 6px; }
.kw-edit-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-bottom: 12px; }
.kw-edit-head h2 { font-size: var(--fs-md); }
.kw-edit-block { padding: 14px 0; border-top: 1px solid var(--line); }
.kw-edit-block h3 { font-size: var(--fs-sm); margin-bottom: 10px; }
.kw-edit-block h3 .hint { font-weight: 400; color: var(--muted); font-size: var(--fs-xs); margin-left: 6px; }
.kw-edit-block .geo-chips { margin-bottom: 0; }
.kw-edit-block .form-note { margin-top: 8px; }
.kw-edit-danger { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.kw-edit-danger .form-note { margin: 0; }
.geo-chip.editable { gap: 4px; padding-right: 3px; }
.geo-chip.editable a { text-decoration: none; color: inherit; }
.geo-chip.editable[aria-current="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); color: var(--ink); }
.geo-chip.editable button {
  border: 0; background: none; color: var(--muted); font: 400 16px/1 var(--font); width: 22px; height: 22px;
  border-radius: 4px; cursor: pointer; display: inline-grid; place-items: center; padding: 0;
}
.geo-chip.editable button:hover { color: var(--bad-text); background: var(--surface-2); }

/* ---------- пользователи ---------- */
.users-intro p { margin: 8px 0 16px; max-width: 70ch; color: var(--ink-2); }
code { font: 500 0.92em/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; }
.kw-edit .form-row { align-items: flex-end; }
.kw-edit label.check { min-height: 36px; }
@media (max-width: 640px) {
  .page-head .tabs { flex-wrap: wrap; overflow: visible; }
  .tabs a { padding-left: 10px; padding-right: 10px; }
}
.run-status.bad { color: var(--bad-text); cursor: help; }
