/* CS2 Sniper mini app. Цвета берутся из темы Telegram (--tg-theme-*), с тёмными значениями по умолчанию. */
:root {
  --bg: var(--tg-theme-bg-color, #0f1117);
  --bg2: var(--tg-theme-secondary-bg-color, #171a23);
  --card: color-mix(in srgb, var(--bg2) 92%, white 8%);
  --text: var(--tg-theme-text-color, #eef1f7);
  --muted: var(--tg-theme-hint-color, #8b93a7);
  --accent: var(--tg-theme-button-color, #4f8cff);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --link: var(--tg-theme-link-color, #6ea8ff);
  --line: color-mix(in srgb, var(--text) 10%, transparent);
  --great: #22c55e;
  --good: #eab308;
  --edge: #f97316;
  --bad: #ef4444;
  --nodata: #94a3b8;
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; }
button:disabled { opacity: .45; cursor: default; }

.app { min-height: 100vh; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: 14px 16px 12px; background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.logo { width: 38px; height: 38px; display: grid; place-items: center; font-size: 20px; border-radius: 12px;
  background: linear-gradient(135deg, #4f8cff, #a855f7); box-shadow: 0 6px 20px #4f8cff40; }
.brand .title { font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.brand .subtitle { font-size: 12px; color: var(--muted); }
.who { margin-left: auto; font-size: 12px; color: var(--muted); }

.content { flex: 1; padding: 14px 16px 96px; }
.page { display: flex; flex-direction: column; gap: 12px; }
.section-title { font-size: 22px; font-weight: 800; margin-top: 2px; }
.group-title { font-weight: 700; margin: 8px 2px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 11.5px; }
.pos, b.pos { color: var(--great); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.card-title { font-weight: 700; }
.card.cta { border: 1px dashed var(--accent); cursor: pointer; }
.hint { font-size: 13px; color: var(--muted); padding: 2px 4px; }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }
.error { background: #ef444418; border: 1px solid #ef444455; color: #fca5a5; padding: 12px 14px; border-radius: 12px; }
.error.big { margin-top: 40px; text-align: center; }
.warnbox { background: #f9731618; border: 1px solid #f9731650; color: #fdba74; padding: 8px 10px; border-radius: 10px; font-size: 13px; }

.loading { display: flex; gap: 10px; align-items: center; justify-content: center; color: var(--muted); padding: 30px; }
.spinner { width: 20px; height: 20px; border: 2.5px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { flex-direction: row; align-items: center; gap: 12px; }
.bar { height: 6px; background: var(--line); border-radius: 6px; overflow: hidden; margin-top: 8px; }
.bar-fill { height: 100%; width: 40%; background: linear-gradient(90deg, var(--accent), #a855f7); border-radius: 6px; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }

/* обзор */
.hero { position: relative; border-radius: 20px; padding: 16px; overflow: hidden;
  background: radial-gradient(120% 140% at 0% 0%, #4f8cff33, transparent 60%), radial-gradient(120% 140% at 100% 100%, #a855f733, transparent 60%), var(--card);
  border: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.hero-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.hero-row div { display: flex; flex-direction: column; gap: 2px; }
.hero-row span { font-size: 12px; }
.hero-row b { font-size: 18px; }
.mode { align-self: flex-start; font-weight: 800; font-size: 12px; letter-spacing: 1px; padding: 4px 10px; border-radius: 999px; }
.mode-monitor { background: #4f8cff22; color: #93c5fd; }
.mode-paper { background: #eab30822; color: #fde047; }
.mode-live { background: #ef444422; color: #fca5a5; }
.mode-kill { background: #ef4444; color: white; }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--bg2); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stat b { font-size: 22px; }
.stat span { font-size: 11.5px; color: var(--muted); }
b.great { color: var(--great); } b.good { color: var(--good); } b.edge { color: var(--edge); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; }
.tile b { font-size: 20px; }
.tile span { font-size: 12.5px; color: var(--muted); }
.tile.warn { border-color: #f9731680; }

/* чипы и переключатели */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip-btn { white-space: nowrap; background: var(--card); border: 1px solid var(--line); padding: 8px 12px; border-radius: 999px; font-size: 13.5px; }
.chip-btn.active { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg2); border-radius: 12px; padding: 4px; gap: 4px; }
.segmented.four { grid-template-columns: repeat(4, 1fr); }
.segmented button { background: transparent; padding: 9px 4px; border-radius: 9px; font-weight: 600; font-size: 13.5px; color: var(--muted); }
.segmented button.active { background: var(--card); color: var(--text); box-shadow: 0 1px 6px #0003; }
.chip { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--bg2); white-space: nowrap; }
.tier-great { background: #22c55e22; color: #4ade80; }
.tier-good { background: #eab30822; color: #facc15; }
.tier-edge { background: #f9731622; color: #fb923c; }
.tier-bad { background: #ef444422; color: #f87171; }
.tier-nodata { background: #94a3b822; color: #cbd5e1; }
.badge { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: #22c55e1f; color: #4ade80; white-space: nowrap; }

/* лоты */
.coverage { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.coverage div { display: flex; flex-direction: column; }
.coverage b { font-size: 16px; }
.coverage span { font-size: 11px; color: var(--muted); }
.item { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 6px; cursor: pointer; transition: transform .08s; }
.item:active { transform: scale(.985); }
.item.compact { padding: 10px 12px; gap: 3px; }
.item-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.route { font-size: 12px; color: var(--muted); }
.item-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.item-line { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.item-prices { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.buy { font-weight: 800; }
.arrow { color: var(--muted); }
.profit { margin-left: auto; font-weight: 700; }
.profit.pos { color: var(--great); }
.profit.neg { color: var(--bad); }
.tier-dot { font-size: 12px; }

/* списки */
.row { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.card > .row { margin: -2px 0; }
.page > .row { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.chev { color: var(--muted); font-size: 20px; }
.search { width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; outline: none; }
.search:focus { border-color: var(--accent); }
.toolbar { display: flex; justify-content: space-between; align-items: center; }
.back { background: transparent; color: var(--link); padding: 4px 0; font-weight: 600; }
.toggle { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }

/* торговля */
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mode-btn { background: var(--bg2); border: 1.5px solid transparent; border-radius: 12px; padding: 10px 6px; display: flex; flex-direction: column; gap: 2px; align-items: center; }
.mode-btn b { font-size: 13px; }
.mode-btn span { font-size: 11px; color: var(--muted); }
.mode-btn.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--bg2)); }
.mode-btn.live.active { border-color: var(--bad); background: #ef444420; }
.kill { background: #ef444420; color: #fca5a5; border: 1px solid #ef444460; border-radius: 12px; padding: 11px; font-weight: 700; }
.kill.on { background: #22c55e20; color: #86efac; border-color: #22c55e60; }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.kv span { color: var(--muted); }
.op { border-top: 1px solid var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.op.warn .row-title::before { content: "⚠️ "; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row button { background: var(--bg2); padding: 8px 12px; border-radius: 10px; font-size: 13px; font-weight: 600; }
button.ok { background: #22c55e22; color: #4ade80; }
button.no { background: #ef444418; color: #f87171; }
.primary { background: var(--accent); color: var(--accent-text); border-radius: 12px; padding: 12px; font-weight: 700; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.field input, .field select { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; color: var(--text); font-size: 14px; outline: none; }
.field input:focus { border-color: var(--accent); }
.rule.off { opacity: .55; }
.rule-head { display: flex; justify-content: space-between; align-items: center; }
.offer-flow { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.offer-flow div { display: flex; flex-direction: column; }
.offer-flow b { font-size: 18px; }

/* интеграции */
.integ-icon { font-size: 18px; }
.detail { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.caps { display: flex; flex-wrap: wrap; gap: 6px; }
.cap { font-size: 12px; padding: 4px 9px; border-radius: 999px; }
.cap.ready { background: #22c55e22; color: #4ade80; }
.cap.impl { background: #eab30820; color: #facc15; }
.cap.off { background: var(--bg2); color: var(--muted); text-decoration: line-through; opacity: .7; }
.creds code { font-size: 12px; background: var(--bg2); padding: 1px 6px; border-radius: 6px; }
.notes { max-height: 120px; overflow: auto; }

/* нижняя навигация */
.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(6, 1fr);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg2) 90%, transparent);
  backdrop-filter: blur(14px); border-top: 1px solid var(--line);
}
.nav-btn { background: transparent; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 12px; color: var(--muted); }
.nav-icon { font-size: 20px; filter: grayscale(.6); transition: transform .15s; }
.nav-label { font-size: 10px; font-weight: 600; white-space: nowrap; }
.nav-btn.active { color: var(--text); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.nav-btn.active .nav-icon { filter: none; transform: translateY(-1px) scale(1.08); }

/* поля в сетках не должны вылезать за край */
.grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid2 > *, .grid3 > * { min-width: 0; }
.field input, .field select { width: 100%; min-width: 0; }

/* настройки и ключи */
.segmented.five { grid-template-columns: repeat(5, 1fr); }
.primary.ghost { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--text); }
.key { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; border-top: 1px solid var(--line); }
.key-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.key-head code { font-size: 12.5px; background: var(--bg2); padding: 2px 7px; border-radius: 6px; }
.key-group .muted.tiny { margin-top: 6px; }
.key-row { display: flex; gap: 8px; }
.key-row input { flex: 1; min-width: 0; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; color: var(--text); outline: none; font-size: 14px; }
.key-row input:focus { border-color: var(--accent); }
.key-row button { padding: 8px 14px; border-radius: 10px; font-weight: 700; }
.admin { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.admin code { font-size: 13px; }
.small-btn { margin-left: auto; padding: 6px 10px; border-radius: 9px; font-size: 12.5px; }

/* графики */
.chart { display: flex; flex-direction: column; gap: 6px; }
.chart-svg { width: 100%; display: block; overflow: visible; }
.chart-svg .grid { stroke: var(--line); stroke-width: 1; }
.chart-svg .zero { stroke: color-mix(in srgb, var(--text) 35%, transparent); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-svg .axis { fill: var(--muted); font-size: 10px; }
.chart-empty { color: var(--muted); font-size: 13px; padding: 18px 4px; text-align: center; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 11.5px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-item i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: 12.5px; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.bar-track { height: 8px; background: var(--bg2); border-radius: 6px; overflow: hidden; }
.bar-val { height: 100%; background: linear-gradient(90deg, #4f8cff, #a855f7); border-radius: 6px; }
.bar-row.hi .bar-val { background: linear-gradient(90deg, #22c55e, #4ade80); }
.bar-row.hi .bar-label { color: var(--text); font-weight: 600; }
.bar-num { font-weight: 700; font-variant-numeric: tabular-nums; }

/* шторка предмета */
.sheet-bg { position: fixed; inset: 0; background: #0008; z-index: 20; animation: fade .15s; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 88vh; overflow-y: auto;
  background: var(--bg); border-radius: 20px 20px 0 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px; box-shadow: 0 -10px 40px #0006; animation: up .2s ease-out; }
.sheet-handle { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 0; }
.sheet-head { display: flex; align-items: flex-start; gap: 10px; }
.sheet-title { font-weight: 800; font-size: 16px; flex: 1; }
.sheet-close { background: var(--bg2); width: 32px; height: 32px; border-radius: 50%; flex: none; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } }

/* пользователи, excel */
.user { border-top: 1px solid var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.user.pending { background: color-mix(in srgb, var(--good) 8%, transparent); border-radius: 10px; padding: 8px; }
.user-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-head code { font-size: 12px; color: var(--muted); }
.excel { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar { gap: 8px; flex-wrap: wrap; }

/* вход на сайт */
.login { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 20px 8px; }
.login-logo { width: 72px; height: 72px; display: grid; place-items: center; font-size: 36px; border-radius: 22px;
  background: linear-gradient(135deg, #4f8cff, #a855f7); box-shadow: 0 10px 40px #4f8cff55; }
.login-title { font-size: 26px; font-weight: 800; }
.login-btn { width: 100%; max-width: 340px; font-size: 16px; padding: 14px; }
.bottom.hidden { display: none; }

@media (min-width: 720px) {
  .sheet { max-width: 720px; margin: 0 auto; }
  .content { max-width: 720px; margin: 0 auto; width: 100%; }
  .bottom { max-width: 720px; margin: 0 auto; border-radius: 18px 18px 0 0; }
}
