/* Avito watcher mini-app. Colors follow the Telegram theme when opened in
   Telegram (--tg-theme-*), else the light/dark fallbacks below. */
:root {
  color-scheme: light;
  --bg: var(--tg-theme-secondary-bg-color, #f2f2f0);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #fcfcfb));
  --text: var(--tg-theme-text-color, #0b0b0b);
  --hint: var(--tg-theme-hint-color, #6b6a66);
  --accent: var(--tg-theme-button-color, #2a78d6);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --link: var(--tg-theme-link-color, #2a78d6);
  --section: var(--tg-theme-section-header-text-color, #6b6a66);
  --danger: var(--tg-theme-destructive-text-color, #e34948);
  --line: rgba(127, 127, 127, 0.22);
  --soft: rgba(127, 127, 127, 0.12);
  --good: #0f7c55;
  --good-bg: rgba(27, 175, 122, 0.16);
  --bad: #b8322f;
  --bad-bg: rgba(227, 73, 72, 0.13);
  --warn: #8a5d00;
  --warn-bg: rgba(237, 161, 0, 0.18);
  --info-bg: rgba(42, 120, 214, 0.13);
  --shimmer: rgba(127, 127, 127, 0.14);
  --tabbar-h: 58px;
  --safe-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: var(--tg-theme-secondary-bg-color, #1a1a19);
    --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #242423));
    --text: var(--tg-theme-text-color, #f0efec);
    --hint: var(--tg-theme-hint-color, #a3a29b);
    --accent: var(--tg-theme-button-color, #3987e5);
    --link: var(--tg-theme-link-color, #5b9ef0);
    --section: var(--tg-theme-section-header-text-color, #a3a29b);
    --danger: var(--tg-theme-destructive-text-color, #e66767);
    --good: #4fd1a0;
    --good-bg: rgba(25, 158, 112, 0.24);
    --bad: #f08a89;
    --bad-bg: rgba(230, 103, 103, 0.2);
    --warn: #f0b84a;
    --warn-bg: rgba(201, 133, 0, 0.24);
    --info-bg: rgba(57, 135, 229, 0.2);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: var(--tg-theme-secondary-bg-color, #1a1a19);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #242423));
  --text: var(--tg-theme-text-color, #f0efec);
  --hint: var(--tg-theme-hint-color, #a3a29b);
  --accent: var(--tg-theme-button-color, #3987e5);
  --link: var(--tg-theme-link-color, #5b9ef0);
  --section: var(--tg-theme-section-header-text-color, #a3a29b);
  --danger: var(--tg-theme-destructive-text-color, #e66767);
  --good: #4fd1a0;
  --good-bg: rgba(25, 158, 112, 0.24);
  --bad: #f08a89;
  --bad-bg: rgba(230, 103, 103, 0.2);
  --warn: #f0b84a;
  --warn-bg: rgba(201, 133, 0, 0.24);
  --info-bg: rgba(57, 135, 229, 0.2);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
html { overflow-x: hidden; }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  min-height: 100vh; overflow-x: hidden;
  padding-top: var(--safe-top);
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
}
body.subscreen { padding-bottom: calc(var(--safe-bottom) + 24px); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--link); }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* --- header ------------------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 4px;
  padding: calc(6px + var(--safe-top)) 8px 6px 16px; margin-top: calc(-1 * var(--safe-top));
  background: var(--bg);
}
.topbar h1 { flex: 1; min-width: 0; font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -0.2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar.scrolled { box-shadow: 0 1px 0 var(--line); }
.icon-btn {
  width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: var(--accent);
  display: inline-grid; place-items: center; flex: none;
}
.icon-btn:active { background: var(--soft); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.spin svg { animation: spin 0.8s linear infinite; }
#back-btn { margin-left: -12px; }
@keyframes spin { to { transform: rotate(360deg); } }
.mock-flag { font-size: 11px; font-weight: 600; color: var(--warn); background: var(--warn-bg);
  border-radius: 6px; padding: 2px 6px; flex: none; }

/* --- layout ---------------------------------------------------------------------- */
main { max-width: 760px; margin: 0 auto; padding: 4px 16px 0; }
.view { animation: fade 0.18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.section-title {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  margin: 20px 4px 8px; font-size: 13px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.3px; color: var(--section);
}
.section-title button { border: 0; background: none; color: var(--link); font-size: 14px; font-weight: 500;
  text-transform: none; letter-spacing: 0; padding: 8px 0 8px 8px; min-height: 40px; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px; }
.card + .card { margin-top: 10px; }
.card h2 { font-size: 16px; margin: 0 0 2px; }
.sub { color: var(--hint); font-size: 13px; margin: 0 0 10px; }
.stack > * + * { margin-top: 10px; }

/* --- status ---------------------------------------------------------------------- */
.status-head { display: flex; align-items: center; gap: 12px; }
.status-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: #1baf7a;
  box-shadow: 0 0 0 4px var(--good-bg); }
.status-dot.paused { background: #eda100; box-shadow: 0 0 0 4px var(--warn-bg); }
.status-dot.stale { background: #e34948; box-shadow: 0 0 0 4px var(--bad-bg); }
.status-dot.live { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px transparent; } }
.status-head b { font-size: 17px; display: block; }
.status-head span { color: var(--hint); font-size: 13px; }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 8px; margin-top: 14px; }
.kv div { min-width: 0; }
.kv dt { color: var(--hint); font-size: 12px; }
.kv dd { margin: 1px 0 0; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-error { margin-top: 12px; padding: 8px 10px; border-radius: 10px; background: var(--bad-bg);
  color: var(--bad); font-size: 13px; overflow-wrap: anywhere; }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile { background: var(--card); border-radius: var(--radius); padding: 12px 14px; min-width: 0;
  border: 0; text-align: left; display: block; width: 100%; }
button.tile:active { opacity: 0.7; }
.tile b { display: block; font-size: 24px; font-weight: 700; letter-spacing: -0.4px; line-height: 1.15; }
.tile span { color: var(--hint); font-size: 13px; }
.tile.wide { grid-column: span 2; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tile .tile-icon { font-size: 22px; }
@media (min-width: 520px) { .tiles { grid-template-columns: repeat(3, 1fr); } .tile.wide { grid-column: span 3; } }

.big-toggle {
  width: 100%; min-height: 54px; border: 0; border-radius: var(--radius); font-size: 16px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 12px;
  background: var(--warn-bg); color: var(--warn);
}
.big-toggle.resume { background: var(--accent); color: var(--accent-text); }
.big-toggle:active { opacity: 0.8; }
.big-toggle:disabled { opacity: 0.5; }

/* --- buttons and form controls -------------------------------------------------- */
.btn {
  min-height: 44px; border: 0; border-radius: 12px; padding: 10px 16px; font-weight: 600; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
  background: var(--soft); color: var(--text);
}
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.link { background: var(--info-bg); color: var(--link); }
.btn.danger { background: var(--bad-bg); color: var(--danger); }
.btn.block { width: 100%; }
.btn:active { opacity: 0.75; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 140px; }

.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px 16px 2px; margin: 0 -16px 10px;
  scroll-padding: 16px; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; margin: 0 0 10px; padding: 0; }
.chip {
  flex: none; min-height: 40px; padding: 6px 14px; border-radius: 20px; border: 0; font-size: 14px;
  background: var(--card); color: var(--text); white-space: nowrap; box-shadow: inset 0 0 0 1px var(--line);
}
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); box-shadow: none; }
.chip .count { opacity: 0.7; margin-left: 4px; font-size: 12px; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; background: var(--soft);
  border-radius: 10px; padding: 2px; }
.seg button { border: 0; background: transparent; border-radius: 8px; min-height: 40px; padding: 4px 6px;
  font-size: 14px; color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--card); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

.switch { position: relative; display: inline-block; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; inset: -7px -4px; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 16px; background: var(--line); transition: background 0.2s; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25); transition: transform 0.2s; }
.switch input:checked + i { background: #1baf7a; }
.switch input:checked + i::after { transform: translateX(20px); }
.switch input:disabled + i { opacity: 0.4; }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }

.form-row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 0; border-top: 1px solid var(--line); }
.form-row:first-child { border-top: 0; padding-top: 0; }
.form-row > div:first-child { flex: 1; min-width: 0; }
.form-row label, .form-row .label { display: block; font-size: 15px; }
.form-row small { display: block; color: var(--hint); font-size: 12px; line-height: 1.3; margin-top: 1px; }
.form-row.column { flex-direction: column; align-items: stretch; gap: 6px; }
.form-row .seg { min-width: 150px; }
.field { width: 100%; min-height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg);
  padding: 10px 12px; font-size: 16px; color: var(--text); outline: none; }
.field:focus { border-color: var(--accent); }
.field.small { width: 88px; text-align: center; }
.field-label { display: block; font-size: 13px; color: var(--hint); margin: 12px 2px 6px; }
.field-label:first-child { margin-top: 0; }
.search-box { position: relative; margin-bottom: 10px; }
.search-box .field { padding-left: 38px; background: var(--card); border-color: transparent; }
.search-box svg { position: absolute; left: 12px; top: 13px; width: 18px; height: 18px; color: var(--hint); pointer-events: none; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 40px; height: 40px; border-radius: 10px; border: 0; background: var(--soft); font-size: 20px; color: var(--accent); }
.stepper output { min-width: 56px; text-align: center; font-weight: 600; }

/* --- listing cards ----------------------------------------------------------------- */
.items { display: flex; flex-direction: column; gap: 10px; }
.item { background: var(--card); border-radius: var(--radius); padding: 10px; display: grid;
  grid-template-columns: 84px 1fr; gap: 12px; position: relative; cursor: pointer; }
.item:active { opacity: 0.85; }
.thumb { width: 84px; height: 84px; border-radius: 10px; object-fit: cover; background: var(--soft);
  display: grid; place-items: center; font-size: 28px; color: var(--hint); overflow: hidden; }
.item-body { min-width: 0; padding-right: 34px; }
.item-title { font-size: 15px; font-weight: 500; line-height: 1.3; margin: 0; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.price-line { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; margin-top: 4px; }
.price { font-size: 18px; font-weight: 700; letter-spacing: -0.2px; white-space: nowrap; }
.market { color: var(--hint); font-size: 13px; white-space: nowrap; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.badge { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; line-height: 1; padding: 4px 7px;
  border-radius: 7px; background: var(--soft); color: var(--text); white-space: nowrap; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; }
.badge.good { background: var(--good-bg); color: var(--good); font-weight: 600; }
.badge.bad { background: var(--bad-bg); color: var(--bad); font-weight: 600; }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.info { background: var(--info-bg); color: var(--link); }
.item-meta { color: var(--hint); font-size: 12px; margin-top: 6px; overflow-wrap: anywhere; }
.item-meta .mi { white-space: nowrap; display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.item-meta .sep { white-space: nowrap; }
.item-meta .sep::before { content: "·"; margin: 0 5px; }
.notes { margin: 6px 0 0; padding: 0; list-style: none; font-size: 12px; color: var(--hint); }
.notes li { display: inline; }
.notes li + li::before { content: " · "; }
.reasons { margin: 6px 0 0; padding-left: 16px; font-size: 13px; }
.star { position: absolute; right: 4px; top: 4px; width: 44px; height: 44px; border: 0; background: transparent;
  border-radius: 50%; display: grid; place-items: center; color: var(--hint); }
.star svg { width: 24px; height: 24px; }
.star[aria-pressed="true"] { color: #eda100; }
.star[aria-pressed="true"] svg { fill: currentColor; }
.star:active { background: var(--soft); }
.star.pop svg { animation: pop 0.3s ease-out; }
@keyframes pop { 50% { transform: scale(1.35); } }
.item-search { font-size: 12px; color: var(--link); margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item.compact { grid-template-columns: 56px 1fr; padding: 8px 10px; }
.item.compact .thumb { width: 56px; height: 56px; font-size: 22px; }
.item.compact .price { font-size: 16px; }
.more { margin-top: 12px; }

/* --- search cards ----------------------------------------------------------------- */
.scard { background: var(--card); border-radius: var(--radius); padding: 14px; cursor: pointer; }
.scard:active { opacity: 0.85; }
.scard + .scard { margin-top: 10px; }
.scard-head { display: flex; align-items: flex-start; gap: 12px; }
.scard-head > div { flex: 1; min-width: 0; }
.scard h3 { font-size: 16px; margin: 0; line-height: 1.3; overflow-wrap: anywhere; }
.scard .where { color: var(--hint); font-size: 13px; margin-top: 2px; }
.scard .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.scard .stats div { background: var(--bg); border-radius: 10px; padding: 7px 8px; min-width: 0; }
.scard .stats b { display: block; font-size: 16px; }
.scard .stats span { color: var(--hint); font-size: 11px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scard.off h3, .scard.off .stats { opacity: 0.55; }
.switch-label { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--hint); }
.banner { border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-bottom: 10px; background: var(--warn-bg); color: var(--warn); }
.banner.info { background: var(--info-bg); color: var(--link); }

.scard-actions { display: flex; justify-content: flex-end; margin-top: 10px; }
.btn.small { min-height: 36px; padding: 6px 14px; font-size: 14px; border-radius: 10px; }

/* --- «Хочу найти» ------------------------------------------------------------------ */
.wish-card { box-shadow: inset 0 0 0 2px var(--accent); }
.wish-card h2 { font-size: 19px; }
.wish-input { position: relative; }
.wish-input textarea { display: block; resize: none; min-height: 72px; line-height: 1.35; overflow-wrap: anywhere; }
.wish-input .paste { position: absolute; right: 6px; bottom: 6px; min-height: 34px; padding: 4px 12px;
  font-size: 13px; border-radius: 9px; background: var(--info-bg); color: var(--link); }
.wish-input:has(.paste) textarea { padding-bottom: 44px; }
.wish-kind { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; margin-top: 8px; font-size: 12px; color: var(--hint); }
.wish-kind:empty { display: none; }
.wish-card .form-row label { font-size: 15px; }
#wish-error { margin: 4px 0 0; }
#wish-error[hidden] { display: none; }
.wish-card [data-action="wish-submit"] { margin-top: 12px; min-height: 50px; font-size: 16px; }

.job { margin-top: 10px; }
.job-head { display: flex; align-items: center; gap: 8px; }
.job-head b { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.icon-x { width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--soft); color: var(--hint);
  font-size: 20px; line-height: 1; flex: none; }
.job-row { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.job-head + .progress + .job-row, .job-head + .job-row { border-top: 0; }
.job-row[data-name] { cursor: pointer; }
.job-row > div { flex: 1; min-width: 0; }
.job-row b { display: block; font-size: 14px; }
.job-row small { display: block; color: var(--hint); font-size: 12px; overflow-wrap: anywhere; }
.job-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex: none; border: 2px solid var(--line); }
.job-row.queued .job-dot { border-color: var(--hint); }
.job-row.running .job-dot { border-color: var(--accent); animation: pulse 1.2s infinite; }
.job-row.done .job-dot { background: #1baf7a; border-color: #1baf7a; }
.job-row.error .job-dot { background: #e34948; border-color: #e34948; }
.job-row.error small { color: var(--danger); }
.job-state { font-size: 12px; color: var(--hint); white-space: nowrap; margin-top: 2px; }
.job-row.done .job-state { color: var(--good); font-weight: 600; }
.job-row.error .job-state { color: var(--danger); font-weight: 600; }

.wcard { background: var(--card); border-radius: var(--radius); padding: 14px; }
.wcard + .wcard { margin-top: 10px; }
.wcard-head { display: flex; align-items: flex-start; gap: 10px; }
.wcard-head > div { flex: 1; min-width: 0; }
.wcard h3 { font-size: 16px; margin: 0; line-height: 1.3; overflow-wrap: anywhere; }
.wcard .where { color: var(--hint); font-size: 13px; margin-top: 2px; }
.wicon { width: 36px; height: 36px; border-radius: 10px; background: var(--soft); display: grid; place-items: center;
  font-size: 18px; flex: none; }
.wrows { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.wrow { display: flex; align-items: center; gap: 8px; background: var(--bg); border-radius: 12px; padding: 8px 10px 8px 12px;
  min-height: 52px; cursor: pointer; }
.wrow:active { opacity: 0.8; }
.wrow-main { flex: 1; min-width: 0; }
.wrow-main b { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wrow-main small { display: block; color: var(--hint); font-size: 12px; }
.wrow.off .wrow-main { opacity: 0.55; }
.wrow .badge { flex: none; }
.wcard .btn-row { gap: 6px; }
.wcard .btn-row .btn { flex: 1 1 80px; min-height: 40px; font-size: 14px; padding: 8px 6px; white-space: nowrap; }

/* --- detail ---------------------------------------------------------------------- */
.detail-head h2 { font-size: 20px; margin: 0; line-height: 1.25; overflow-wrap: anywhere; }
.detail-head .where { color: var(--hint); font-size: 14px; margin-top: 4px; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.mini-table th, .mini-table td { text-align: right; padding: 7px 4px; border-top: 1px solid var(--line); white-space: nowrap; }
.mini-table th:first-child, .mini-table td:first-child { text-align: left; white-space: normal; }
.mini-table th { color: var(--hint); font-weight: 500; border-top: 0; }

/* --- add / task ------------------------------------------------------------------- */
.progress { height: 6px; border-radius: 3px; background: var(--soft); overflow: hidden; margin: 12px 0 8px; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.6s ease; }
.progress.indeterminate i { width: 35% !important; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
.steps { list-style: none; margin: 10px 0 0; padding: 0; font-size: 14px; }
.steps li { display: flex; align-items: center; gap: 10px; padding: 5px 0; color: var(--hint); }
.steps li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--line); flex: none; }
.steps li.done { color: var(--text); }
.steps li.done::before { background: #1baf7a; border-color: #1baf7a; }
.steps li.now { color: var(--text); font-weight: 600; }
.steps li.now::before { border-color: var(--accent); animation: pulse 1.2s infinite; }
.task-msg { font-size: 14px; overflow-wrap: anywhere; }
.task-msg.error { color: var(--danger); }
.hint-list { color: var(--hint); font-size: 13px; padding-left: 18px; margin: 8px 0 0; }

/* --- charts ---------------------------------------------------------------------- */
.chart { position: relative; width: 100%; }
.note { color: var(--hint); font-size: 13px; margin: 10px 0 0; }
.meta { color: var(--hint); font-size: 12px; margin-top: 12px; text-align: center; }
.chart-card table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 12px; font-variant-numeric: tabular-nums; }
.chart-card th, .chart-card td { text-align: right; padding: 5px 4px; border-top: 1px solid var(--line); white-space: nowrap; }
.chart-card th:first-child, .chart-card td:first-child { text-align: left; white-space: normal; }
.chart-card th { color: var(--hint); font-weight: 500; }
select.field { appearance: none; background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M1 1l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 14px center;
  padding-right: 36px; border-color: transparent; margin-bottom: 10px; }

/* --- states ---------------------------------------------------------------------- */
.empty, .error-box { text-align: center; padding: 36px 16px; color: var(--hint); background: var(--card); border-radius: var(--radius); }
.empty .em, .error-box .em { font-size: 40px; line-height: 1; display: block; margin-bottom: 10px; }
.empty b, .error-box b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }
.empty p, .error-box p { margin: 0 0 4px; font-size: 14px; overflow-wrap: anywhere; }
.empty .btn, .error-box .btn { margin-top: 12px; }
.fullscreen-msg { padding: 64px 16px; text-align: center; color: var(--hint); }
.fullscreen-msg b { display: block; color: var(--text); font-size: 18px; margin-bottom: 8px; }
.sk { background: linear-gradient(90deg, var(--shimmer) 25%, rgba(127, 127, 127, 0.24) 50%, var(--shimmer) 75%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite linear; border-radius: 8px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.sk-line { height: 12px; margin-top: 8px; }
.sk-item { background: var(--card); border-radius: var(--radius); padding: 10px; display: grid; grid-template-columns: 84px 1fr; gap: 12px; }
.sk-item .sk.thumb { width: 84px; height: 84px; border-radius: 10px; }
.sk-block { height: 140px; border-radius: var(--radius); }
.sk-tile { height: 70px; border-radius: var(--radius); }

/* --- tab bar ---------------------------------------------------------------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  background: var(--card); box-shadow: 0 -1px 0 var(--line);
}
.tabbar button { border: 0; background: none; color: var(--hint); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 500; position: relative; min-width: 0; }
.tabbar button svg { width: 26px; height: 26px; }
.tabbar button[aria-selected="true"] { color: var(--accent); }
.tabbar button[aria-selected="true"] svg { stroke-width: 2.2; }
.tabbar .dot { position: absolute; top: 5px; left: calc(50% + 7px); min-width: 18px; height: 18px; border-radius: 9px;
  background: #e34948; color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; padding: 0 5px; }
@media (min-width: 760px) { .tabbar { left: 50%; right: auto; width: 760px; transform: translateX(-50%); border-radius: 16px 16px 0 0; } }

/* --- toast and pull to refresh ---------------------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px); z-index: 50;
  transform: translate(-50%, 20px); opacity: 0; transition: opacity 0.2s, transform 0.2s; pointer-events: none;
  background: rgba(30, 30, 30, 0.92); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px;
  max-width: calc(100vw - 32px); width: max-content; text-align: center;
}
body.subscreen .toast { bottom: calc(var(--safe-bottom) + 20px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: rgba(190, 45, 45, 0.95); }
.ptr { position: fixed; left: 50%; top: calc(var(--safe-top) + 8px); z-index: 40; width: 36px; height: 36px;
  margin-left: -18px; border-radius: 50%; background: var(--card); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  display: grid; place-items: center; color: var(--accent); opacity: 0; transform: translateY(-50px); pointer-events: none; }
.ptr svg { width: 20px; height: 20px; }
.ptr.ready svg { color: #1baf7a; }
.ptr.loading svg { animation: spin 0.8s linear infinite; }
.wrow.task { cursor: default; }
.wrow.task:active { opacity: 1; }
.wrow.task .wrow-main small { overflow-wrap: anywhere; }
.wrow.task.error .wrow-main small, .wrow.task.error .job-state { color: var(--danger); }
.wrow.task.running .job-state { color: var(--link); }

/* --- «Перепродажа» --------------------------------------------------------------- */
.tile b.tile-small { font-size: 17px; letter-spacing: -0.1px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.good-text { color: var(--good); }
.bad-text { color: var(--bad); }
.emoji-ic { font-size: 20px; line-height: 1; }
.niche-card .niche-head { display: flex; align-items: flex-start; gap: 8px; }
.niche-card .niche-head > div { flex: 1; min-width: 0; }
.niche-card h2 { font-size: 18px; overflow-wrap: anywhere; }
.niche-card .where { color: var(--hint); font-size: 13px; margin-top: 2px; }
.niche-card .icon-btn { margin: -8px -8px 0 0; }
.niche-card .btn-row .btn { flex: 1 1 120px; }
.model-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.model-chips.edit { gap: 6px; margin-top: 0; min-height: 34px; align-items: center; }
.mchip { display: inline-flex; align-items: center; gap: 2px; padding: 0 0 0 12px; min-height: 36px; border-radius: 18px;
  background: var(--info-bg); color: var(--link); font-size: 14px; max-width: 100%; }
.mchip button { width: 36px; height: 36px; border: 0; background: none; color: inherit; font-size: 20px; line-height: 1; border-radius: 50%; flex: none; }
.mchip button:active { background: var(--soft); }
.add-model { display: flex; gap: 8px; margin-top: 8px; }
.add-model .field { flex: 1; min-width: 0; }
.add-model .btn { flex: none; }
.cat-line { display: flex; align-items: center; gap: 8px; font-size: 14px; overflow-wrap: anywhere; }
.cat-line span { flex: 1; min-width: 0; color: var(--hint); }
.wrow .chev { color: var(--hint); font-size: 20px; flex: none; }
.how { margin-top: 10px; padding: 0; }
.how summary { cursor: pointer; padding: 12px 14px; min-height: 44px; font-weight: 600; font-size: 15px; list-style: none;
  display: flex; align-items: center; gap: 8px; }
.how summary::-webkit-details-marker { display: none; }
.how summary::before { content: "ℹ️"; }
.how summary::after { content: "›"; margin-left: auto; color: var(--hint); font-size: 20px; transition: transform 0.2s; }
.how[open] summary::after { transform: rotate(90deg); }
.how-body { padding: 0 14px 14px; font-size: 14px; }
.how-body p { margin: 0 0 8px; }
.how-list { list-style: none; padding: 0; margin: 0; }
.how-list li { margin-top: 6px; color: var(--hint); font-size: 13px; }
.how-list .badge { margin-right: 4px; }

.badge.verdict { font-weight: 700; }
.deal { background: var(--card); border-radius: var(--radius); padding: 10px 12px 12px; position: relative; cursor: pointer;
  border-left: 4px solid transparent; }
.deal:active { opacity: 0.9; }
.deal.v-buy { border-left-color: #1baf7a; }
.deal.v-check { border-left-color: #eda100; }
.deal.v-haggle { border-left-color: var(--accent); }
.deal.v-skip { border-left-color: var(--line); }
.deal-top { display: grid; grid-template-columns: 72px 1fr; gap: 12px; }
.deal .thumb { width: 72px; height: 72px; font-size: 26px; }
.deal-main { min-width: 0; padding-right: 34px; }
.deal-tags { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; margin-bottom: 4px; }
.model-key { font-size: 12px; color: var(--link); font-weight: 600; overflow-wrap: anywhere; }
.deal .price-line { margin-top: 2px; }
.deal .price-line .market { white-space: normal; }
.deliv { white-space: nowrap; }
.deal-profit { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 2px 10px; margin-top: 10px;
  padding-top: 8px; border-top: 1px solid var(--line); }
.profit { font-size: 22px; font-weight: 800; letter-spacing: -0.4px; white-space: nowrap; }
.profit.good { color: var(--good); }
.profit.bad { color: var(--bad); }
.kzn { color: var(--hint); font-size: 13px; }
.lvl { display: inline-block; font-size: 11px; line-height: 1; padding: 3px 6px; border-radius: 6px; background: var(--soft); color: var(--hint); white-space: nowrap; vertical-align: 1px; }
.lvl.lvl-1 { background: var(--good-bg); color: var(--good); }
.lvl.lvl-2 { background: var(--info-bg); color: var(--link); }
.lvl.lvl-3 { background: var(--warn-bg); color: var(--warn); }
.deal-calc { color: var(--hint); font-size: 12px; margin-top: 2px; }
.deal .reasons { margin-top: 8px; }
.ai-slot:empty { display: none; }
.ai-slot { margin-top: 10px; }
.ai-btn { width: 100%; min-height: 42px; background: var(--info-bg); color: var(--link); }
.ai-hint { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 6px 0; min-height: 36px;
  color: var(--hint); font-size: 12px; }
.ai-tip { display: block; width: 100%; text-align: left; border: 0; font-size: 13px; line-height: 1.35; }
.ai-box { background: var(--bg); border-radius: 12px; padding: 10px 12px; font-size: 14px; cursor: default; }
.ai-box.err { display: flex; align-items: center; gap: 8px; }
.ai-box.err small { flex: 1; color: var(--danger); }
.ai-box.busy small { display: block; color: var(--hint); margin-top: 4px; }
.ai-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-weight: 600; }
.ai-head small { color: var(--hint); font-weight: 400; font-size: 12px; margin-left: auto; }
.ai-summary { margin: 6px 0 0; }
.ai-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0 0; }
.ai-facts div { min-width: 0; }
.ai-facts dt { color: var(--hint); font-size: 11px; }
.ai-facts dd { margin: 0; font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.ai-line { color: var(--hint); font-size: 12px; margin-top: 6px; }
.ai-risks { margin: 6px 0 0; padding: 0; list-style: none; font-size: 13px; color: var(--warn); }
.ai-risks li::before { content: "⚠️ "; }
.ai-q { margin-top: 6px; }
.ai-q summary { cursor: pointer; color: var(--link); font-size: 13px; min-height: 36px; display: flex; align-items: center; }
.ai-q ol { margin: 2px 0 0; padding-left: 20px; font-size: 13px; }
.ai-q li + li { margin-top: 3px; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite; flex: none; }
.ai-status { font-size: 14px; padding: 8px 10px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); }
.ai-status.on { background: var(--good-bg); color: var(--good); }
.unit-field { display: flex; align-items: center; gap: 6px; flex: none; }
.unit-field span { color: var(--hint); font-size: 13px; min-width: 18px; }
.unit-field .field.small { width: 96px; }

.mrows { display: flex; flex-direction: column; gap: 8px; }
.mrow { display: flex; gap: 10px; background: var(--card); border-radius: 12px; padding: 10px 12px; }
.mrow-main { flex: 1; min-width: 0; }
.mrow-main b { display: block; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.mrow-main .badges { margin-top: 4px; }
.mrow-main small { display: block; color: var(--hint); font-size: 12px; margin-top: 4px; }
.mrow-side { text-align: right; flex: none; }
.mrow-side b { display: block; font-size: 16px; white-space: nowrap; }
.mrow-side small { display: block; color: var(--hint); font-size: 12px; white-space: nowrap; }
