:root {
  --bg: var(--tg-theme-bg-color, #fff);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f3f5);
  --text: var(--tg-theme-text-color, #111);
  --hint: var(--tg-theme-hint-color, #8a8f98);
  --link: var(--tg-theme-link-color, #2481cc);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-text: var(--tg-theme-button-text-color, #fff);
  --sep: color-mix(in srgb, var(--hint) 25%, transparent);
  --good: #1a9a4a;
  --warn: #e08a00;
  --bad: #d64545;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg2); color: var(--text);
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 10px 12px 6px;
  box-shadow: 0 1px 0 var(--sep); }
.search-row { display: flex; gap: 8px; }
#q { flex: 1; min-width: 0; border: 0; border-radius: 10px; background: var(--bg2); padding: 9px 12px; outline: none; }
.icon-btn { position: relative; border: 0; border-radius: 10px; background: var(--bg2); width: 42px;
  display: grid; place-items: center; color: var(--text); }
.badge { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; border-radius: 9px;
  background: var(--accent); color: var(--accent-text); font-size: 11px; display: grid; place-items: center; padding: 0 4px; }
.tabs { display: flex; gap: 4px; margin-top: 8px; overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: 6px 10px; border-radius: 8px; color: var(--hint); white-space: nowrap; }
.tabs button.on { background: var(--bg2); color: var(--text); font-weight: 600; }
.presets { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-top: 6px; }
.presets:empty { display: none; }
.chip { border: 1px solid var(--sep); background: var(--bg); border-radius: 16px; padding: 4px 10px; white-space: nowrap; font-size: 13px; }
.chip.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.bar { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; color: var(--hint); font-size: 13px; }
.bar select { border: 0; background: none; color: var(--link); text-align: right; }

#list { padding: 8px 10px 40px; display: flex; flex-direction: column; gap: 8px; }
.card { background: var(--bg); border-radius: var(--radius); padding: 10px; display: grid;
  grid-template-columns: 76px 1fr; gap: 10px; }
.card .img { width: 76px; height: 76px; border-radius: 10px; background: #fff center/contain no-repeat; }
.card .title { font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .nums { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; margin-top: 4px; }
.pts { font-weight: 700; font-size: 17px; color: var(--good); }
.pct { font-weight: 600; }
.score { color: var(--hint); font-size: 12px; }
.price { margin-top: 2px; font-size: 13px; }
.price s { color: var(--hint); }
.meta { color: var(--hint); font-size: 12px; margin-top: 2px; }
.tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.tag { font-size: 11px; border-radius: 6px; padding: 1px 6px; background: var(--bg2); }
.tag.new { background: #2481cc22; color: var(--link); }
.tag.up { background: #1a9a4a22; color: var(--good); }
.tag.down { background: #e08a0022; color: var(--warn); }
.actions { grid-column: 1 / -1; display: flex; gap: 6px; }
.actions button { flex: 1; border: 0; border-radius: 9px; padding: 6px 8px; background: var(--bg2); font-size: 13px; }
.actions .open { background: var(--accent); color: var(--accent-text); flex: 2; }
.actions .on { color: var(--warn); }

.state { text-align: center; color: var(--hint); padding: 60px 24px; }
.state .btn { margin-top: 16px; }
.btn { border: 0; border-radius: 10px; padding: 10px 16px; background: var(--accent); color: var(--accent-text); }
.link { border: 0; background: none; color: var(--link); padding: 4px; }

.sheet { position: fixed; inset: 0; z-index: 20; background: var(--bg2); display: flex; flex-direction: column; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 12px; background: var(--bg);
  box-shadow: 0 1px 0 var(--sep); }
.sheet-body { overflow-y: auto; padding: 10px 12px 80px; flex: 1; }
.sec { background: var(--bg); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.sec h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: var(--hint); font-weight: 600; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; }
.row + .row { border-top: 1px solid var(--sep); }
.row label { flex: 1; }
.row small { display: block; color: var(--hint); font-size: 12px; }
.pair { display: flex; gap: 6px; }
.pair input, .num { width: 88px; border: 0; border-radius: 8px; background: var(--bg2); padding: 7px 8px; text-align: right; outline: none; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.range-val { min-width: 48px; text-align: right; font-weight: 600; }
.seg { display: flex; background: var(--bg2); border-radius: 8px; padding: 2px; }
.seg button { border: 0; background: none; padding: 5px 10px; border-radius: 6px; font-size: 13px; }
.seg button.on { background: var(--bg); box-shadow: 0 1px 2px #0002; }
.switch { appearance: none; width: 42px; height: 26px; border-radius: 13px; background: var(--sep); position: relative; transition: .2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .2s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { left: 19px; }
textarea { width: 100%; min-height: 70px; border: 0; border-radius: 8px; background: var(--bg2); padding: 8px; outline: none; resize: vertical; }
.hint { color: var(--hint); font-size: 12px; margin-top: 4px; }

.tree { font-size: 14px; }
.tree .node { display: flex; align-items: center; gap: 6px; padding: 5px 0; }
.tree .kids { padding-left: 18px; }
.tree .tog { width: 18px; color: var(--hint); border: 0; background: none; padding: 0; }
.tree .st { width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--sep); display: grid; place-items: center;
  font-size: 13px; flex: none; background: var(--bg); }
.tree .st.inc { background: var(--good); border-color: var(--good); color: #fff; }
.tree .st.exc { background: var(--bad); border-color: var(--bad); color: #fff; }
.tree .cnt { color: var(--hint); font-size: 12px; margin-left: auto; }
.shops { display: flex; flex-wrap: wrap; gap: 6px; max-height: 220px; overflow-y: auto; }
.shops .chip.exc { background: var(--bad); color: #fff; border-color: var(--bad); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #000c; color: #fff;
  padding: 8px 14px; border-radius: 10px; z-index: 30; font-size: 14px; }

.adm .u { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-top: 1px solid var(--sep); gap: 8px; }
.adm .u small { color: var(--hint); display: block; }
.adm .u .btns { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.adm .u button { border: 0; border-radius: 8px; padding: 6px 8px; background: var(--bg2); font-size: 12px; }
#admin { padding: 10px; }
