  :root {
    --bg: #faf9f6;
    --surface: #fff;
    --surface-2: #f3f1ea;
    --text: #1a1a1a;
    --muted: #6b6b67;
    --border: #e3e1d8;
    --green: #2d8a3e;
    --green-bg: rgba(45,138,62,0.12);
    --red: #c0392b;
    --red-bg: rgba(192,57,43,0.12);
    --amber: #b8830d;
    --amber-bg: rgba(184,131,13,0.12);
    --blue: #1a5fa5;
    --accent: #d4f06a;
    --accent-fg: #2a3308;
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --bg: #18181a; --surface: #232325; --surface-2: #2c2c2e;
      --text: #ebebe8; --muted: #9b9b95; --border: #34343a;
      --green-bg: rgba(45,138,62,0.22);
      --red-bg: rgba(192,57,43,0.22);
      --amber-bg: rgba(184,131,13,0.22);
    }
  }
  * { box-sizing: border-box; }
  body {
    margin: 0; font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI",
      Inter, system-ui, sans-serif;
    background: var(--bg); color: var(--text);
  }
  header {
    padding: 14px 24px; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
    background: var(--surface); position: sticky; top: 0; z-index: 5;
  }
  header h1 { margin: 0; font-size: 18px; font-weight: 500; }
  .pill {
    display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
    background: var(--surface-2); border-radius: 12px; font-size: 13px;
    color: var(--muted);
  }
  .pill.ok { color: var(--green); background: var(--green-bg); }
  .pill.warn { color: var(--amber); background: var(--amber-bg); }
  .pill.bad { color: var(--red); background: var(--red-bg); }

  main { padding: 16px 24px 40px; max-width: 1400px; margin: 0 auto; }

  .controls {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
    margin-bottom: 16px;
  }
  button {
    background: var(--surface); border: 1px solid var(--border); color: var(--text);
    padding: 8px 14px; border-radius: 6px; cursor: pointer; font: inherit;
    font-size: 14px; transition: background .12s;
  }
  button:hover:not(:disabled) { background: var(--surface-2); }
  button:disabled { opacity: 0.5; cursor: not-allowed; }
  button.primary {
    background: var(--accent); color: var(--accent-fg); border-color: var(--accent);
    font-weight: 500;
  }
  button.primary:hover:not(:disabled) { filter: brightness(0.96); }
  button.ghost { background: transparent; }

  .filter-chip { padding: 6px 10px; font-size: 13px; }
  .filter-chip.active {
    background: var(--text); color: var(--bg); border-color: var(--text);
  }

  details.config {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; margin-bottom: 16px;
  }
  details.config[open] { padding-bottom: 12px; }
  details.config summary {
    padding: 12px 16px; cursor: pointer; font-weight: 500; font-size: 14px;
    color: var(--muted); user-select: none;
  }
  .cfg-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
    padding: 0 16px;
  }
  @media (max-width: 700px) { .cfg-grid { grid-template-columns: 1fr; } }
  .cfg-grid label {
    display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted);
  }
  .cfg-grid input, .cfg-grid textarea {
    background: var(--bg); border: 1px solid var(--border); color: var(--text);
    padding: 8px 10px; border-radius: 5px; font: 14px ui-monospace, Menlo, monospace;
  }
  .cfg-grid textarea { min-height: 100px; resize: vertical; }
  .cfg-actions { padding: 12px 16px 0; display: flex; gap: 8px; }
  .cfg-note { padding: 8px 16px 0; color: var(--muted); font-size: 13px; }

  table { width: 100%; border-collapse: collapse; background: var(--surface);
          border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
  thead th {
    font-weight: 500; color: var(--muted); font-size: 12px;
    text-transform: uppercase; letter-spacing: 0.04em;
    background: var(--surface-2); padding: 10px 12px; text-align: left;
    border-bottom: 1px solid var(--border);
  }
  tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
  tbody tr:last-child td { border-bottom: none; }
  tbody tr.row { cursor: pointer; }
  tbody tr.row:hover { background: var(--surface-2); }

  /* Горизонтальный скролл широких таблиц (табы стран + модалка ASIN). На узком
     экране/мобильном колонки не сжимаются в кашу — таблица скроллится вбок (как матрица).
     Длинные ячейки (.asin-title/.hist-cat) ограничены своими max-width + ellipsis. */
  .table-scroll {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    max-width: 100%; scrollbar-width: thin;
  }
  .table-scroll::-webkit-scrollbar { height: 8px; }
  .table-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
  .table-scroll > table { width: max-content; min-width: 100%; }
  .mono { font: 13px ui-monospace, Menlo, monospace; }
  .badge { display: inline-block; padding: 2px 8px; border-radius: 4px;
           font-size: 12px; font-weight: 500; white-space: nowrap; }
  .b-ours    { background: var(--green-bg); color: var(--green); }
  .b-amazon  { background: var(--red-bg);   color: var(--red); }
  .b-other   { background: var(--amber-bg); color: var(--amber); }
  .b-none    { background: var(--surface-2); color: var(--muted); }
  .diff {
    display: inline-block; margin-left: 6px; padding: 1px 6px;
    border-radius: 3px; font-size: 11px; font-weight: 500;
  }
  .diff-up   { background: var(--red-bg); color: var(--red); }
  .diff-down { background: var(--green-bg); color: var(--green); }
  .diff-new  { background: var(--amber-bg); color: var(--amber); }

  .empty { padding: 50px; text-align: center; color: var(--muted); }
  .log { font-size: 13px; color: var(--muted); margin: 8px 0;
         font-family: ui-monospace, Menlo, monospace; }
  .tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border);
          margin-bottom: 16px; }
  .tab {
    background: transparent; border: none; border-bottom: 2px solid transparent;
    border-radius: 0; padding: 10px 16px; font: inherit; font-size: 15px;
    color: var(--muted); cursor: pointer; transition: color .12s, border-color .12s;
    display: flex; align-items: center; gap: 8px;
  }
  .tab:hover { color: var(--text); }
  .tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 500; }
  .tab .flag { font-size: 17px; line-height: 1; }

  /* Матрица */
  .matrix-wrap {
    overflow-x: auto;
    overflow-y: visible;  /* sticky-top шапки цепляется к window */
    max-width: 100%;
    border-radius: 6px;
    scrollbar-width: thin;
  }
  .matrix-wrap::-webkit-scrollbar { height: 8px; }
  .matrix-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
  table.matrix { width: max-content; min-width: max-content; border-collapse: separate; border-spacing: 0; }
  table.matrix .mp-col { min-width: 130px; max-width: 190px; }
  /* Sticky первая колонка (ASIN/название) при горизонтальном скролле */
  table.matrix th:first-child,
  table.matrix td:first-child {
    position: sticky; left: 0; z-index: 2;
    background: var(--bg);
    box-shadow: 1px 0 0 var(--border);
  }
  /* Sticky шапка при вертикальном скролле */
  table.matrix thead th {
    position: sticky; top: 0; z-index: 2;
    background: var(--bg);
    box-shadow: 0 1px 0 var(--border);
  }
  /* Пересечение: первая ячейка шапки залипает И сверху, И слева */
  table.matrix thead th:first-child { z-index: 3; }
  .mtx-cell {
    padding: 8px 10px; vertical-align: top;
    border-bottom: 1px solid var(--border);
    border-left: 1px solid var(--border);
    cursor: pointer; transition: filter .12s;
  }
  .mtx-cell:hover { filter: brightness(0.97); }
  .mtx-price { font-weight: 700; font-size: 17px; color: var(--text, #1a1a1a); letter-spacing: -0.01em; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; }
  .mtx-status { font-size: 13px; font-weight: 600; margin-top: 3px; color: var(--text, #1a1a1a); }
  .mtx-ours       { background: #f6fdf8; border-left: 3px solid #86c79a !important; }
  .mtx-ours .mtx-status { color: var(--green); }
  .mtx-amazon     { background: #fdf7f7; border-left: 3px solid #d99a9a !important; }
  .mtx-amazon .mtx-status { color: var(--red); }
  .mtx-other      { background: #fefcf6; border-left: 3px solid #e0b878 !important; }
  .mtx-other .mtx-status { color: #b45309; }

  /* Легенда цветов над матрицей */
  .matrix-legend {
    display: flex; flex-wrap: wrap; gap: 16px;
    margin-bottom: 8px; padding: 8px 12px;
    font-size: 12px; color: var(--muted);
    background: var(--surface); border-radius: 6px;
  }
  .matrix-legend > span { display: flex; align-items: center; gap: 6px; }
  .legend-swatch {
    display: inline-block; width: 16px; height: 16px; border-radius: 3px;
    border: 1px solid var(--border);
  }
  .swatch-ours { background: var(--green-bg); }
  .swatch-amazon { background: var(--red-bg); }
  .swatch-other { background: var(--amber-bg); }
  .swatch-suppressed { background: #fff5e6; border-left: 3px solid var(--amber, #f59e0b); }
  .swatch-not-on-market {
    background: repeating-linear-gradient(
      45deg, transparent, transparent 4px,
      var(--border) 4px, var(--border) 5px
    );
  }
  .mtx-suppressed {
    /* BB suppressed: товар есть, но Buy Box неактивен — оранжевый акцент */
    background: #fff5e6;
    border-left: 3px solid var(--amber, #f59e0b) !important;
  }
  .mtx-suppressed .mtx-status { color: #b45309; font-weight: 500; }
  .mtx-apifymiss {
    /* Apify miss: товар есть на маркете, но Apify не вернул — янтарный с пунктиром */
    background: #fffbeb;
    border-left: 3px dashed var(--amber, #f59e0b) !important;
  }
  .mtx-empty      {
    background: transparent; border-style: dashed;
    color: var(--muted); opacity: 0.7;
  }
  .mtx-not-on-market {
    background: repeating-linear-gradient(
      45deg, transparent, transparent 6px,
      rgba(0,0,0,0.03) 6px, rgba(0,0,0,0.03) 12px
    );
    color: var(--muted);
  }
  .mtx-not-on-market .mtx-price { font-size: 15px; opacity: 0.5; }
  .mtx-not-on-market .mtx-status { font-style: italic; }
  .price-alt { color: var(--muted); font-size: 12px; font-weight: 400; margin-left: 4px; }
  .channel-log {
    margin: 4px 0 8px;
    padding: 8px 12px;
    background: var(--surface);
    border-radius: 6px;
    font-size: 13px;
    font-family: ui-monospace, Menlo, monospace;
    display: flex; flex-direction: column; gap: 4px;
  }
  .ch-row { display: flex; gap: 10px; align-items: center; min-height: 18px; }
  .ch-label {
    flex-shrink: 0; width: 50px;
    color: var(--muted); font-weight: 500;
    font-size: 12px; text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .ch-msg { color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ch-msg.idle { color: var(--muted); opacity: 0.6; }
  .version-badge {
    display: inline-block; font-size: 12px; font-weight: 500;
    padding: 2px 8px; border-radius: 10px;
    background: var(--surface-2); color: var(--muted);
    vertical-align: middle; margin-left: 8px; user-select: none;
  }
  .changelog { font-size: 14px; }
  .changelog h3 { margin: 16px 0 6px; font-size: 14px; font-weight: 600; }
  .changelog ul { margin: 0 0 8px 18px; padding: 0; }
  .changelog li { margin: 2px 0; line-height: 1.4; }
  .changelog .ver { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 6px; }
  .mtx-diff {
    font-size: 11px; padding: 1px 4px; border-radius: 3px;
    margin-left: 4px; font-weight: 500;
  }
  .refresh-one {
    padding: 4px 8px; font-size: 14px; line-height: 1;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 4px; cursor: pointer; color: var(--muted);
  }
  .refresh-one:hover:not(:disabled) { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
  .refresh-one:disabled { opacity: 0.4; cursor: wait; }
  .asin-cell { display: flex; gap: 10px; align-items: center; max-width: 360px; }
  .thumb {
    width: 40px; height: 40px; flex-shrink: 0;
    border: 1px solid var(--border); border-radius: 4px;
    background: var(--surface-2) center/contain no-repeat;
  }
  .thumb.empty { opacity: 0.4; }
  .asin-info { min-width: 0; }
  .asin-code { font: 13px ui-monospace, Menlo, monospace; }
  .asin-title {
    font-size: 13px; color: var(--muted); margin-top: 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    max-width: 320px;
  }
  .asin-category {
    font-size: 11px; color: var(--muted); opacity: 0.7; margin-top: 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    max-width: 320px;
  }
  .mtx-meta {
    font-size: 12px; color: #444; margin-top: 4px;
    display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  }
  .mtx-meta .star { color: var(--amber, #f59e0b); }
  .bsr-badge {
    color: var(--muted); font-size: 11px;
    display: inline-flex; align-items: center; gap: 2px;
    cursor: help;
  }
  .bsr-trend {
    font-size: 10px; font-weight: 500;
    margin-left: 2px;
    cursor: help;
  }
  .bsr-trend.trend-up { color: #2a8a2a; }    /* BSR улучшился → зелёный */
  .bsr-trend.trend-down { color: #c14040; }  /* BSR ухудшился → красный */

  .discount-badge {
    display: inline-block;
    font-size: 11px; font-weight: 600;
    padding: 1px 6px; border-radius: 8px;
    background: #fff0e6; color: #c14a1a;
    border: 1px solid #ffd5b8;
    cursor: help;
    vertical-align: middle;
    margin-left: 4px;
  }

  /* Insights в модалке истории */
  .insights-row {
    display: flex; flex-wrap: wrap; gap: 14px;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: var(--surface); border-radius: 6px;
    font-size: 13px;
  }
  .insight-item { display: inline-flex; align-items: center; gap: 4px; }

  /* Histogram bar chart в модалке истории */
  .histogram-block {
    margin: 12px 0;
    padding: 12px 14px;
    background: var(--surface);
    border-radius: 8px;
    border: 1px solid var(--border, #e5e7eb);
  }
  .hg-title {
    font-size: 14px; display: flex; align-items: center; gap: 6px;
    margin-bottom: 8px; flex-wrap: wrap;
  }
  .hg-grid { display: grid; gap: 3px; }
  .hg-row {
    display: grid;
    grid-template-columns: 56px 1fr 36px 50px;
    align-items: center;
    gap: 8px;
    font-size: 12px;
  }
  .hg-stars { color: var(--amber, #f59e0b); letter-spacing: -1px; }
  .hg-bar-wrap {
    height: 12px; background: var(--bg, #f3f4f6); border-radius: 3px; overflow: hidden;
  }
  .hg-bar {
    display: block; height: 100%; background: linear-gradient(90deg, #f59e0b, #fbbf24);
    border-radius: 3px;
  }
  .hg-pct { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
  .hg-count { color: var(--muted); font-variant-numeric: tabular-nums; }
  .hg-meta { margin-top: 8px; font-size: 11px; color: var(--muted); }

  .precision-history { width: 100%; margin-top: 4px; font-size: 12px; }
  .precision-history th { text-align: left; color: var(--muted); font-weight: 500; padding: 4px 8px; border-bottom: 1px solid var(--border); }
  .precision-history td { padding: 4px 8px; border-bottom: 1px solid var(--border); }

  /* Precision rating drop — бейдж и подсветка строки */
  .precision-drop-badge {
    display: inline-block;
    font-size: 11px; font-weight: 700;
    padding: 1px 6px; border-radius: 8px;
    margin-left: 4px;
    vertical-align: middle;
    cursor: help;
    font-variant-numeric: tabular-nums;
  }
  .precision-drop-badge.drop-medium {
    background: #fff0e0; color: #c14a1a; border: 1px solid #ffd5a8;
  }
  .precision-drop-badge.drop-large {
    background: #ffe0e0; color: #b91c1c; border: 1px solid #f5a5a5;
    animation: precDropPulse 2s ease-in-out infinite;
  }
  @keyframes precDropPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.0); }
    50%      { box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.15); }
  }

  /* Подсветка строки в детальном табе при значимом падении precision */
  tr.precision-drop-medium {
    box-shadow: inset 4px 0 0 #f59e0b;  /* амбер полоса слева */
  }
  tr.precision-drop-large {
    box-shadow: inset 4px 0 0 #dc2626;  /* красная полоса слева */
    background: linear-gradient(90deg, rgba(220, 38, 38, 0.05), transparent 30%);
  }
  .mtx-category {
    font-size: 12px; color: #555; margin-top: 4px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    max-width: 100%;
  }
  .mtx-oos {
    display: inline-block;
    background: var(--red-bg); color: var(--red);
    padding: 1px 5px; border-radius: 3px;
    font-size: 11px; font-weight: 500;
  }

  .modal {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    display: none; align-items: flex-start; justify-content: center;
    padding: 40px 16px; z-index: 10; overflow-y: auto;
  }
  .modal.open { display: flex; }
  .modal-body {
    background: var(--surface); border-radius: 10px; padding: 20px;
    max-width: 900px; width: 100%;
  }
  .modal-body h2 { margin: 0 0 14px; font-size: 17px; font-weight: 500; }
  .close { float: right; background: none; border: none; color: var(--muted);
           font-size: 24px; cursor: pointer; line-height: 1; padding: 0 4px; }
  .modal table { border: 1px solid var(--border); }

  .region-switcher {
    margin-left: 10px;
    padding: 4px 8px;
    font-size: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    color: var(--text);
    font-family: inherit;
  }
  .region-switcher:hover { border-color: var(--text); }

  /* Read-only баннер при просмотре snapshot ссылки */
  .readonly-banner {
    display: flex; align-items: center; gap: 10px;
    margin: 0 0 12px;
    padding: 10px 14px;
    background: #fff8e6; border: 1px solid #f5d77a; border-radius: 6px;
    font-size: 14px; color: #6b5300;
  }
  .ro-icon { font-size: 18px; }
  .ro-text { flex: 1; }
  .ro-link { color: #6b5300; font-weight: 500; }

  .stale-histogram-banner {
    display: flex; align-items: center; gap: 10px;
    margin: 0 0 12px;
    padding: 10px 14px;
    background: #e8f4ff; border: 1px solid #91cbff; border-radius: 6px;
    font-size: 14px; color: #1a4480;
  }

  /* В read-only режиме прячем все интерактивные элементы записи */
  body.read-only #btn-refresh-all,
  body.read-only #btn-refresh-tab,
  body.read-only #btn-refresh-histogram,
  body.read-only #btn-recheck-notmarket,
  body.read-only #btn-ai-summary,
  body.read-only #btn-share,
  body.read-only #config-section,
  body.read-only .refresh-one,
  body.read-only #region-switcher { display: none !important; }
  body.read-only .mtx-cell { cursor: default; }

  /* В гостевом режиме прячем admin/cron/AI элементы — оставляем только manual Keepa UI */
  body.guest-mode #btn-ai-summary,
  body.guest-mode #btn-recheck-notmarket,
  body.guest-mode #cfg-slack-webhook,
  body.guest-mode #cfg-openrouter-key,
  body.guest-mode #cfg-openrouter-model,
  body.guest-mode #cfg-se-worker,
  body.guest-mode #cfg-se-auth,
  body.guest-mode #workspace-migration-row,
  body.guest-mode .cron-controls,
  body.guest-mode #cron-status-info,
  body.guest-mode #keepa-expired-banner,
  body.guest-mode #apify-expired-banner { display: none !important; }
  /* Прячем labels этих полей тоже (label-input wrapping) */
  body.guest-mode label:has(#cfg-slack-webhook),
  body.guest-mode label:has(#cfg-openrouter-key),
  body.guest-mode label:has(#cfg-openrouter-model),
  body.guest-mode label:has(#cfg-se-worker),
  body.guest-mode label:has(#cfg-se-auth) { display: none !important; }

  /* === Mode selector (Easy/Full переключатель) === */
  .mode-card {
    flex: 1; min-width: 240px; cursor: pointer;
    border: 2px solid var(--border); border-radius: 10px;
    padding: 14px; transition: all .15s; position: relative;
    background: transparent;
  }
  .mode-card:hover {
    border-color: #94a3b8;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
    transform: translateY(-1px);
  }
  .mode-card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .mode-radio { font-size: 18px; color: var(--muted); line-height: 1; }
  .mode-badge {
    display: none; margin-left: auto;
    font-size: 11px; font-weight: 700; color: #fff;
    padding: 2px 8px; border-radius: 999px;
  }
  /* Выбранная Easy */
  .mode-card.selected-easy { border-color: #22c55e; background: #f0fdf4; }
  .mode-card.selected-easy .mode-radio { color: #22c55e; }
  .mode-card.selected-easy .mode-badge { display: inline-block; background: #22c55e; }
  /* Выбранная Full */
  .mode-card.selected-full { border-color: #3b82f6; background: #eff6ff; }
  .mode-card.selected-full .mode-radio { color: #3b82f6; }
  .mode-card.selected-full .mode-badge { display: inline-block; background: #3b82f6; }
  .share-form { padding: 12px; background: var(--surface); border-radius: 6px; margin-bottom: 16px; }
  .share-form-title { font-weight: 500; margin-bottom: 10px; font-size: 14px; }
  .share-meta { width: 100%; margin-bottom: 12px; font-size: 13px; }
  .share-meta td { padding: 3px 0; }
  .share-meta td:first-child { color: var(--muted); width: 110px; }
  .share-note { color: var(--muted); font-size: 12px; margin: 10px 0 0; font-style: italic; }

  .share-result {
    padding: 14px; background: #e8f5e0; border: 1px solid #c1d99a; border-radius: 6px;
    margin-bottom: 16px;
  }
  .share-result-header { font-weight: 500; margin-bottom: 10px; color: #4a5e2a; font-size: 14px; }
  .share-link-row { display: flex; gap: 8px; }
  .share-link-row input {
    flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: 5px;
    font: 13px ui-monospace, Menlo, monospace; background: white;
  }
  .share-result-meta { font-size: 11px; color: var(--muted); margin-top: 8px; }

  .share-list { margin-top: 8px; }
  .share-list-title {
    font-weight: 500; font-size: 13px; margin-bottom: 8px;
    color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px;
  }
  .share-list-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 12px; border: 1px solid var(--border); border-radius: 5px;
    margin-bottom: 6px; font-size: 13px;
  }
  .share-list-item.expired { opacity: 0.5; }
  .share-item-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
  .share-item-date { color: var(--muted); font-size: 12px; }
  .share-item-region { font-weight: 500; }
  .share-item-stats { color: var(--muted); font-size: 12px; }
  .share-item-expires { color: var(--muted); font-size: 11px; font-style: italic; }
  .share-item-actions { display: flex; gap: 4px; align-items: center; }

  .btn-copy, .btn-open, .btn-delete {
    padding: 5px 9px; font-size: 12px;
    border: 1px solid var(--border); border-radius: 4px;
    background: var(--surface); cursor: pointer; color: var(--text);
    font-family: inherit; line-height: 1;
    text-decoration: none; display: inline-block;
  }
  .btn-copy:hover, .btn-open:hover { background: var(--text); color: var(--bg); border-color: var(--text); }
  .btn-copy.copied { background: #e8f5e0; color: #4a5e2a; border-color: #c1d99a; }
  .btn-delete { color: var(--muted); padding: 5px 8px; font-size: 16px; }
  .btn-delete:hover { background: var(--red-bg, #fde8e8); color: var(--red, #b91c1c); border-color: var(--red, #b91c1c); }

  /* Подсказка-action в модалке истории — "как вернуть BB" */
  .hint-box {
    padding: 12px 14px; margin-bottom: 14px;
    border-radius: 6px; border: 1px solid;
    font-size: 13px; line-height: 1.5;
  }
  .hint-box.hint-ok { background: #e8f5e0; border-color: #c1d99a; color: #4a5e2a; }
  .hint-box.hint-warn { background: #fff8e6; border-color: #f5d77a; color: #6b5300; }
  .hint-box code {
    background: rgba(0,0,0,0.06); padding: 1px 5px; border-radius: 3px;
    font: 12px ui-monospace, Menlo, monospace;
  }
  .hint-box ul { padding-left: 18px; }
  .hint-box a { color: inherit; text-decoration: underline; font-weight: 500; }

  /* ====================================================================
     v3.4.2 — Mobile layout + dark-mode contrast fixes
     ==================================================================== */

  /* Dark mode: ячейки матрицы были захардкожены светлыми (#f6fdf8 и т.п.)
     → светлый текст на светлом фоне = цена не видна. Полупрозрачные тинты
     работают на обоих фонах. */
  @media (prefers-color-scheme: dark) {
    .mtx-ours   { background: rgba(45,138,62,0.16);  border-left-color: #4d8a5e !important; }
    .mtx-amazon { background: rgba(192,57,43,0.16);  border-left-color: #9a544d !important; }
    .mtx-other  { background: rgba(184,131,13,0.16); border-left-color: #96763d !important; }
    .mtx-other .mtx-status { color: var(--amber); }
    .hint-box code { background: rgba(255,255,255,0.10); }
  }

  /* Шапка: разрешаем перенос строк (auth-бар уходит на свою строку) */
  header { flex-wrap: wrap; gap: 8px 12px; }
  #auth-bar { margin-top: 0 !important; }

  @media (max-width: 700px) {
    header { padding: 10px 14px; }
    header h1 {
      font-size: 16px;
      display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    }
    main { padding: 12px 12px 40px; }

    /* auth-бар занимает всю ширину, инпут тянется */
    #auth-bar { flex-basis: 100%; }
    #auth-bar input { flex: 1 1 auto; min-width: 0 !important; }
    #auth-bar > span:last-child { display: none; } /* подпись "(magic-link...)" */

    /* Табы: горизонтальный скролл вместо вылета за экран */
    .tabs {
      flex-wrap: nowrap; overflow-x: auto;
      -webkit-overflow-scrolling: touch;
      scrollbar-width: none;
      margin-left: -12px; margin-right: -12px;
      padding: 0 12px;
    }
    .tabs::-webkit-scrollbar { display: none; }
    .tab { padding: 10px 12px; white-space: nowrap; flex: 0 0 auto; font-size: 14px; }

    .controls { gap: 8px; }
    button { padding: 8px 12px; }
  }

  /* Категория в таблице истории (модалка ASIN) */
  .hist-cat {
    font-size: 12px; color: var(--muted);
    display: inline-block; max-width: 200px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    vertical-align: bottom; cursor: default;
  }
  .hist-cat-changed {
    color: var(--amber); font-weight: 600;
    background: var(--amber-bg); padding: 1px 6px; border-radius: 4px;
  }

  /* Сортируемые заголовки в табах маркетов */
  thead th.th-sort { cursor: pointer; user-select: none; white-space: nowrap; }
  thead th.th-sort:hover { color: var(--text); }
  thead th.th-sort-active { color: var(--text); }
  .th-sort-arrow { margin-left: 4px; color: var(--accent-fg); font-weight: 700; }
  @media (prefers-color-scheme: dark) { .th-sort-arrow { color: var(--accent); } }

  /* BSR: подранг (место в нише) + корневой ранг второй строкой */
  .bsr-subline { white-space: nowrap; }
  .bsr-subline strong { font-variant-numeric: tabular-nums; }
  .bsr-subcat { color: var(--muted); font-size: 11px; }
  .bsr-rootline { color: var(--muted); font-size: 11px; margin-top: 1px; white-space: nowrap; }
  .bsr-rootline .bsr-badge { font-size: 11px; padding: 0 4px; }
  .rank-chip {
    display: inline-block; padding: 0 5px; border-radius: 3px;
    font-size: 10px; font-weight: 700; vertical-align: 1px;
  }
  .rank-top10  { background: var(--amber-bg); color: var(--amber); }
  .rank-top100 { background: var(--green-bg); color: var(--green); }

  /* Пульс email-поля при клике «Войти по email» (v3.12.1) */
  @keyframes pulseField {
    0%   { box-shadow: 0 0 0 0 rgba(212, 240, 106, 0.9); border-color: var(--accent); }
    70%  { box-shadow: 0 0 0 10px rgba(212, 240, 106, 0); border-color: var(--accent); }
    100% { box-shadow: 0 0 0 0 rgba(212, 240, 106, 0); }
  }
  .pulse-field { animation: pulseField 1.2s ease-out 2; }

  /* Группы конкурентов (v3.8.0) */
  .grp-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; padding: 14px 16px; margin-bottom: 14px;
  }
  .grp-card table { border: none; }
  .grp-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
  .grp-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
  .grp-chip {
    font-size: 12px; padding: 3px 10px; border-radius: 10px; white-space: nowrap;
  }
  .grp-chip-green { background: var(--green-bg); color: var(--green); }
  .grp-chip-amber { background: var(--amber-bg); color: var(--amber); }
  .grp-chip-blue  { background: rgba(26,95,165,0.12); color: var(--blue); }
  .grp-chip-red   { background: var(--red-bg); color: var(--red); }
  .grp-row-ours td { background: var(--green-bg); }
  .grp-badge-ours {
    background: var(--green); color: #fff; font-size: 10px; font-weight: 600;
    padding: 1px 6px; border-radius: 8px; vertical-align: 1px;
  }
  .grp-insights {
    margin-top: 10px; font-size: 12px; color: var(--muted);
    display: flex; gap: 16px; flex-wrap: wrap;
  }
