/* ============ Sniper CRM — тёмный графит + белый акцент ============ */
:root {
  --bg: #0e1012;
  --panel: #16181c;
  --panel-2: #1b1e23;
  --panel-3: #22262c;
  --border: #262a31;
  --border-2: #31363e;
  --text: #eceef1;
  --muted: #8b919c;
  --dim: #5c626d;
  --accent: #ffffff;
  --green: #41d98c;
  --green-bg: rgba(65, 217, 140, .12);
  --red: #f4647c;
  --red-bg: rgba(244, 100, 124, .12);
  --amber: #f5b54a;
  --amber-bg: rgba(245, 181, 74, .12);
  --blue: #6aa6ff;
  --radius: 14px;
  --font: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;        /* без двойного тапа-зума и дёрганья на мобиле */
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
a { color: var(--text); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--panel-3); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ Логин ============ */
.login {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #1c2027 0%, var(--bg) 60%);
}
.login-card {
  width: 360px; padding: 40px 36px; text-align: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: 20px;
  box-shadow: 0 30px 80px rgba(0,0,0,.5);
}
.login-logo { font-size: 42px; margin-bottom: 10px; }
.login-card h1 { font-size: 24px; font-weight: 800; letter-spacing: 2px; }
.login-card h1 span { color: var(--muted); font-weight: 500; }
.login-sub { color: var(--dim); font-size: 12px; margin: 6px 0 24px; }
.login-card input {
  width: 100%; padding: 12px 14px; margin-bottom: 12px;
  background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 10px;
  color: var(--text); font-size: 14px; outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.login-err { color: var(--red); font-size: 12px; min-height: 18px; margin-top: 10px; }
.login-hint { color: var(--dim); font-size: 11px; text-align: left; margin: -4px 0 12px 2px; }
.login-hint b { color: var(--muted); }
#login-code { font-family: var(--mono); letter-spacing: 4px; }

/* ============ Кнопки/инпуты ============ */
.btn {
  border: 1px solid var(--border-2); border-radius: 10px; padding: 9px 16px;
  font-size: 13px; font-weight: 600; transition: .15s;
}
.btn-accent { background: var(--accent); color: #0b0c0e; border-color: var(--accent); width: 100%; }
.btn-accent:hover { opacity: .88; }
.btn-dark { background: var(--panel-2); color: var(--text); }
.btn-dark:hover { background: var(--panel-3); }
.btn-ghost {
  background: none; border: none; color: var(--dim); font-size: 12px; padding: 6px;
}
.btn-ghost:hover { color: var(--text); }
.input {
  background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 10px;
  color: var(--text); padding: 9px 14px; font-size: 13px; outline: none; min-width: 260px;
}
.input:focus { border-color: var(--accent); }

/* ============ Каркас ============ */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 22px 14px 14px 20px; }
.brand-icon {
  width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
  background: var(--panel-3); border: 1px solid var(--border-2); border-radius: 11px; font-size: 19px;
  flex-shrink: 0;
}
.brand-text { font-weight: 800; font-size: 15px; letter-spacing: 1.5px; white-space: nowrap; }
.brand-text span { color: var(--muted); font-weight: 500; }
.collapse-btn {
  margin-left: auto; width: 26px; height: 26px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--muted); transition: .15s;
}
.collapse-btn:hover { color: #fff; border-color: var(--border-2); }
.collapse-btn svg { width: 15px; height: 15px; fill: currentColor; transition: transform .2s; }

/* ---- профиль в меню ---- */
.profile {
  display: flex; align-items: center; gap: 10px;
  margin: 2px 12px 8px; padding: 10px 12px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px;
}
.profile-ava {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 30% 22%, #4d545f, #1b1e23 75%);
  border: 1px solid var(--border-2);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.14), 0 2px 8px rgba(0,0,0,.35);
}
.profile-ava svg { width: 17px; height: 17px; fill: #e3e6eb; }
.profile-info { flex: 1; min-width: 0; }
.profile-name { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-role { color: var(--dim); font-size: 10.5px; }
.profile-out {
  width: 28px; height: 28px; flex-shrink: 0; background: none; border: none;
  display: flex; align-items: center; justify-content: center;
  color: var(--dim); border-radius: 8px; transition: .12s;
}
.profile-out:hover { color: var(--red); background: var(--panel-3); }
.profile-out svg { width: 15px; height: 15px; fill: currentColor; }

/* ---- свёрнутое меню (десктоп) ---- */
@media (min-width: 641px) {
  .sidebar { transition: width .18s ease; }
  body.nav-min .sidebar { width: 76px; }
  body.nav-min .brand { flex-direction: column; gap: 8px; padding: 16px 0 8px; justify-content: center; }
  body.nav-min .brand-text, body.nav-min .profile-info, body.nav-min .profile-out,
  body.nav-min .nav-label, body.nav-min .foot-stats { display: none; }
  body.nav-min .collapse-btn { margin-left: 0; }
  body.nav-min .collapse-btn svg { transform: rotate(180deg); }
  body.nav-min .profile { justify-content: center; margin: 2px 10px 8px; padding: 9px 0; }
  body.nav-min .nav { padding: 8px 10px; }
  body.nav-min .nav-item { justify-content: center; gap: 0; padding: 12px 0; position: relative; }
  body.nav-min .nav-item svg { width: 20px; height: 20px; }
  body.nav-min .nav-badge { position: absolute; top: 4px; right: 7px; margin: 0; }
}

/* ---- мини-профиль в шапке (мобила) ---- */
.profile-m { position: relative; }
.profile-ava-sm { width: 34px; height: 34px; cursor: pointer; }
.profile-ava-sm svg { width: 15px; height: 15px; }
.profile-menu {
  position: absolute; right: 0; top: 42px; z-index: 60; min-width: 170px;
  background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 12px;
  padding: 12px 14px; box-shadow: 0 18px 50px rgba(0,0,0,.55);
}
.pm-name { font-weight: 700; font-size: 13.5px; }
.pm-role { color: var(--dim); font-size: 11px; margin-bottom: 10px; }
.pm-out {
  width: 100%; background: var(--panel-3); border: 1px solid var(--border-2);
  border-radius: 9px; color: var(--red); padding: 8px; font-size: 13px; font-weight: 600;
}
.nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  background: none; border: none; border-radius: 10px;
  color: var(--muted); font-size: 13.5px; font-weight: 600; text-align: left; transition: .15s;
}
.nav-item svg { width: 17px; height: 17px; fill: currentColor; flex-shrink: 0; }
.nav-item:hover { color: var(--text); background: var(--panel-2); }
.nav-item.active { color: #0b0c0e; background: var(--accent); }
.nav-badge {
  margin-left: auto; background: var(--green); color: #06281a;
  border-radius: 20px; padding: 1px 8px; font-size: 11px; font-weight: 700;
}
.nav-item.active .nav-badge { background: #0b0c0e; color: #fff; }
.sidebar-foot { padding: 14px 20px; border-top: 1px solid var(--border); }
.foot-stats { color: var(--dim); font-size: 11px; line-height: 1.7; margin-bottom: 6px; }
.foot-stats b { color: var(--muted); font-weight: 600; }

.main { flex: 1; padding: 0 28px 60px; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 0 18px; position: sticky; top: 0; z-index: 5;
  background: linear-gradient(var(--bg) 80%, transparent);
}
.topbar h2 { font-size: 21px; font-weight: 800; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.updated { color: var(--dim); font-size: 12px; }

/* ============ KPI ============ */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px; margin-bottom: 18px;
}
.kpi {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; position: relative; overflow: hidden;
}
.kpi::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--kpi-c, var(--border-2));
}
.kpi-label { color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }
.kpi-value { font-size: 24px; font-weight: 800; margin-top: 6px; font-family: var(--mono); }
.kpi-sub { color: var(--dim); font-size: 11.5px; margin-top: 4px; }
.kpi-sub b { color: var(--muted); }

/* ============ Панели/графики ============ */
.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 14px; min-width: 0;
}
.panel h3 {
  font-size: 13px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .8px; margin-bottom: 14px;
}
.dash-row { display: grid; grid-template-columns: 1.7fr 1fr; gap: 14px; }
.dash-row .panel { margin-bottom: 14px; }
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }

/* воронка */
.funnel-row { display: flex; align-items: center; gap: 12px; margin-bottom: 9px; }
.funnel-label { width: 70px; color: var(--muted); font-size: 12px; font-family: var(--mono); font-weight: 700; }
.funnel-track { flex: 1; height: 22px; background: var(--panel-2); border-radius: 6px; overflow: hidden; }
.funnel-bar {
  height: 100%; border-radius: 6px; min-width: 2px;
  background: linear-gradient(90deg, #3a3f47, #e8eaee);
}
.funnel-count { width: 46px; text-align: right; font-family: var(--mono); font-size: 12.5px; font-weight: 700; }

/* таблица последних сделок */
.recent-table { width: 100%; border-collapse: collapse; }
.recent-table td {
  padding: 9px 8px; border-top: 1px solid var(--border); font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.recent-table tr { cursor: pointer; transition: .1s; }
.recent-table tr:hover { background: var(--panel-2); }

/* ============ Карточки токенов ============ */
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px;
}
.tcard {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; cursor: pointer; transition: .15s; display: flex; flex-direction: column; gap: 12px;
}
.tcard:hover { border-color: var(--border-2); transform: translateY(-2px); box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.tcard-top { display: flex; align-items: center; gap: 11px; }
.avatar {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  object-fit: cover; background: var(--panel-3); border: 1px solid var(--border-2);
}
.avatar-fallback {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 17px; color: var(--text);
  background: linear-gradient(135deg, #2a2f37, #1b1e23); border: 1px solid var(--border-2);
}
.avatar-sm, .avatar-sm-fallback { width: 28px; height: 28px; border-radius: 8px; font-size: 12px; }
.tcard-names { min-width: 0; flex: 1; }
.tcard-sym { font-weight: 800; font-size: 15.5px; display: flex; align-items: center; gap: 8px; }
.tcard-name { color: var(--dim); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-status {
  font-size: 10.5px; font-weight: 700; padding: 2.5px 8px; border-radius: 6px;
  text-transform: uppercase; letter-spacing: .4px; flex-shrink: 0;
}
.st-ACTIVE { background: rgba(255,255,255,.13); color: #fff; }
.st-STOP_HIT { background: var(--amber-bg); color: var(--amber); }
.st-TAKE { background: var(--green-bg); color: var(--green); }
.st-FULL_LOSS { background: var(--red-bg); color: var(--red); }
.st-RUG { background: rgba(244,100,124,.2); color: #ff8597; }
.st-WATCHING { background: var(--panel-3); color: var(--muted); }
.st-POSITION { background: rgba(255,255,255,.13); color: #fff; }

.tcard-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 14px; }
.tm { display: flex; justify-content: space-between; font-size: 12.5px; }
.tm span { color: var(--dim); }
.tm b { font-family: var(--mono); font-weight: 700; }
.pnl-pos { color: var(--green); }
.pnl-neg { color: var(--red); }

.progress { height: 6px; background: var(--panel-2); border-radius: 4px; overflow: hidden; position: relative; }
.progress-bar { height: 100%; border-radius: 4px; background: linear-gradient(90deg, #4a505a, #fff); }
.progress-bar.neg { background: linear-gradient(90deg, #5c2731, var(--red)); }
.progress-caption { display: flex; justify-content: space-between; color: var(--dim); font-size: 10.5px; margin-top: 4px; font-family: var(--mono); }

/* прогресс-лайн с метками тройной отработки (500K/750K/1M) на самой линии */
.pl-track {
  position: relative; height: 6px; background: var(--panel-2); border-radius: 4px;
  margin: 18px 6px 6px;                /* сверху место под подписи меток */
}
.pl-fill {
  height: 100%; border-radius: 4px; max-width: 100%;
  background: linear-gradient(90deg, #4a505a, #fff);
}
.pl-fill.neg { background: linear-gradient(90deg, #5c2731, var(--red)); }
.pl-mark { position: absolute; top: 50%; transform: translate(-50%, -50%); z-index: 1; }
.pl-mark i {
  display: block; width: 11px; height: 11px; border-radius: 50%;
  background: var(--panel-3); border: 2px solid var(--dim);
  box-shadow: 0 0 0 2px var(--panel);
}
.pl-mark span {
  position: absolute; bottom: 9px; left: 50%; transform: translateX(-50%);
  font-family: var(--mono); font-size: 9.5px; font-weight: 700; color: var(--dim);
  white-space: nowrap;
}
.pl-mark.on i { background: var(--green); border-color: var(--green); }
.pl-mark.on span { color: var(--green); }
.pl-mark:last-child span { transform: translateX(-80%); }

.tcard-foot { display: flex; align-items: center; justify-content: space-between; }
.links { display: flex; gap: 6px; }
.link-ico {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--muted); text-decoration: none; font-size: 13px; transition: .12s;
}
.link-ico:hover { color: #fff; border-color: var(--border-2); background: var(--panel-3); }
.link-ico svg { width: 14px; height: 14px; fill: currentColor; }
.tcard-age { color: var(--dim); font-size: 11px; }
.fails-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.fail-chip { background: var(--red-bg); color: var(--red); font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 5px; }
.verdict-chip { font-size: 11px; color: var(--muted); }

/* сводка отработки */
.summary-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 16px;
}
.sumi-label { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.sumi-value { font-family: var(--mono); font-weight: 800; font-size: 17px; margin-top: 3px; }

/* подвкладки */
.subtabs, .chiprow { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.subtab, .chip {
  background: var(--panel); border: 1px solid var(--border); border-radius: 9px;
  color: var(--muted); padding: 7px 16px; font-size: 13px; font-weight: 600; transition: .12s;
}
.subtab:hover, .chip:hover { color: var(--text); }
.subtab.active, .chip.active { background: var(--accent); color: #0b0c0e; border-color: var(--accent); }

/* ============ История (строки) ============ */
.history-controls { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.history-controls .chiprow { margin-bottom: 0; }
.hrow {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 14px; margin-bottom: 8px; cursor: pointer; transition: .12s;
}
.hrow:hover { border-color: var(--border-2); background: var(--panel-2); }
.hrow-names { width: 200px; min-width: 0; }
.hrow-sym { font-weight: 700; font-size: 13.5px; }
.hrow-name { color: var(--dim); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hrow-m { width: 110px; font-size: 12px; }
.hrow-m span { display: block; color: var(--dim); font-size: 10.5px; }
.hrow-m b { font-family: var(--mono); }
.hrow-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.empty {
  text-align: center; color: var(--dim); padding: 60px 20px; font-size: 14px;
  background: var(--panel); border: 1px dashed var(--border-2); border-radius: var(--radius);
}

/* ============ Модалка ============ */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5,6,8,.72); backdrop-filter: blur(3px); }
.modal-card {
  position: relative; width: min(960px, calc(100vw - 40px)); max-height: calc(100vh - 60px);
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border-2); border-radius: 18px;
  box-shadow: 0 40px 120px rgba(0,0,0,.6); overflow: hidden;
}
.modal-head { padding: 20px 24px 0; }
.mhead { display: flex; align-items: center; gap: 14px; padding-right: 36px; }  /* не наезжаем на ✕ */
.mhead .avatar, .mhead .avatar-fallback { width: 54px; height: 54px; border-radius: 14px; font-size: 21px; }
.mhead-names { flex: 1; min-width: 0; }
.mhead-sym { font-size: 19px; font-weight: 800; display: flex; align-items: center; gap: 10px; }
.mhead-name { color: var(--muted); font-size: 13px; }
.mhead-ca {
  font-family: var(--mono); font-size: 11px; color: var(--dim); cursor: pointer; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 380px;
}
.mhead-ca:hover { color: var(--text); }
.mhead-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.mhead-cap { font-family: var(--mono); font-weight: 800; font-size: 18px; }
.modal-close {
  position: absolute; top: 14px; right: 14px; width: 32px; height: 32px;
  background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 9px;
  color: var(--muted); font-size: 15px; line-height: 1;
}
.modal-close:hover { color: #fff; }
/* вкладки модалки: сегмент-контрол на всю ширину, активная — белая таблетка */
.modal-tabs {
  display: flex; gap: 4px; margin: 14px 24px 0; padding: 4px; flex-shrink: 0;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px;
}
.mtab {
  flex: 1; min-width: 0; background: none; border: none; color: var(--muted);
  font-size: 13px; font-weight: 600; padding: 9px 8px; border-radius: 9px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: .12s;
}
.mtab:hover { color: var(--text); }
.mtab.active { background: var(--accent); color: #0b0c0e; }
.modal-body { overflow-y: auto; padding: 20px 24px 26px; }

/* обзор в модалке */
.ov-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.ov-item { background: var(--panel-2); border: 1px solid var(--border); border-radius: 11px; padding: 11px 13px; }
.ov-label { color: var(--dim); font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; }
.ov-value { font-family: var(--mono); font-weight: 700; font-size: 14.5px; margin-top: 3px; }
.ov-value small { color: var(--dim); font-weight: 500; }
.ov-section { margin-top: 18px; }
.ov-section h4 {
  font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .7px; margin-bottom: 10px;
}
.filters-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.f-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px;
  font-size: 12.5px;
}
.f-item .f-name { color: var(--muted); }
.f-item .f-val { font-family: var(--mono); font-size: 11.5px; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.f-pass { border-left: 3px solid var(--green); }
.f-fail { border-left: 3px solid var(--red); }
.f-nc { border-left: 3px solid var(--dim); }
.ms-row { display: flex; gap: 8px; flex-wrap: wrap; }
.ms-pill {
  background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 9px;
  padding: 7px 12px; font-size: 12px; font-family: var(--mono);
}
.ms-pill b { color: #fff; }
.ms-pill span { color: var(--dim); font-size: 10.5px; display: block; }

/* таймлайн */
.tl { position: relative; padding-left: 22px; }
.tl::before { content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--border-2); }
.tl-item { position: relative; padding: 0 0 16px; }
.tl-dot {
  position: absolute; left: -21px; top: 4px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--panel-3); border: 2px solid var(--dim);
}
.tl-dot.g { border-color: var(--green); background: var(--green-bg); }
.tl-dot.r { border-color: var(--red); background: var(--red-bg); }
.tl-dot.a { border-color: var(--amber); background: var(--amber-bg); }
.tl-dot.w { border-color: #fff; background: rgba(255,255,255,.15); }
.tl-title { font-weight: 700; font-size: 13.5px; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.tl-time { color: var(--dim); font-size: 11px; font-family: var(--mono); }
.tl-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ИИ-вкладка */
.ai-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.ai-head .btn-accent { width: auto; }
.ai-model { color: var(--dim); font-size: 12px; font-family: var(--mono); }
.ai-card { background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 12px; overflow: hidden; }
.ai-card-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer; user-select: none;
}
.ai-card-head:hover { background: var(--panel-3); }
.ai-card-head .ai-ts { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.ai-card-head .ai-chev { margin-left: auto; color: var(--dim); transition: .15s; }
.ai-card.open .ai-chev { transform: rotate(180deg); }
.ai-card-body { display: none; padding: 4px 18px 18px; }
.ai-card.open .ai-card-body { display: block; }
.ai-md { font-size: 13.5px; line-height: 1.65; }
.ai-md h2 { font-size: 15px; margin: 16px 0 8px; color: #fff; }
.ai-md h3 { font-size: 13.5px; margin: 12px 0 6px; }
.ai-md p { margin: 6px 0; color: #c9cdd4; }
.ai-md ul, .ai-md ol { margin: 6px 0 6px 20px; color: #c9cdd4; }
.ai-md li { margin: 3px 0; }
.ai-md strong { color: #fff; }
.ai-md code { font-family: var(--mono); font-size: 12px; background: var(--panel-3); padding: 1px 5px; border-radius: 5px; }
.spinner {
  width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.25); border-top-color: #fff;
  border-radius: 50%; display: inline-block; vertical-align: -3px; margin-right: 8px;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* график в модалке */
.dexframe { width: 100%; height: 460px; border: 1px solid var(--border); border-radius: 12px; background: #0b0d0f; }

/* тост */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 200;
  background: var(--panel-3); border: 1px solid var(--border-2); border-radius: 12px;
  color: var(--text); padding: 12px 22px; font-size: 13.5px; font-weight: 600;
  box-shadow: 0 16px 50px rgba(0,0,0,.5);
}

.mobile-only { display: none; }

@media (max-width: 1100px) { .dash-row { grid-template-columns: 1fr; } }

/* ============ Планшет: всегда узкая панель (иконки) ============ */
@media (max-width: 980px) and (min-width: 641px) {
  .sidebar { width: 76px !important; }
  .brand { flex-direction: column; gap: 8px; justify-content: center; padding: 16px 0 8px; }
  .brand-text, .foot-stats, .nav-label, .profile-info, .profile-out, .collapse-btn { display: none; }
  .profile { justify-content: center; margin: 2px 10px 8px; padding: 9px 0; }
  .nav { padding: 8px 10px; }
  .nav-item { justify-content: center; gap: 0; padding: 12px 0; position: relative; }
  .nav-item svg { width: 20px; height: 20px; }
  .nav-badge { position: absolute; margin: 0; top: 4px; right: 7px; }
  .sidebar-foot { padding: 10px 4px; }
  .main { padding: 0 18px 40px; }
}

/* ============ Телефон: нижняя панель вкладок, всё в одну колонку ============ */
@media (max-width: 640px) {
  html, body { overflow-x: hidden; }
  .app { display: block; }

  /* сайдбар -> нижний таб-бар */
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    width: 100%; height: auto; flex-direction: row; z-index: 40;
    background: rgba(17, 19, 23, .97); backdrop-filter: blur(12px);
    border-right: none; border-top: 1px solid var(--border-2);
  }
  .brand, .sidebar-foot, .profile { display: none; }
  .nav { flex-direction: row; gap: 2px; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
  .nav-item {
    flex: 1; flex-direction: column; gap: 4px; padding: 7px 2px 6px;
    position: relative; min-width: 0;
  }
  .nav-item svg { width: 21px; height: 21px; }
  .nav-label { font-size: 9.5px; font-weight: 600; letter-spacing: .1px; }
  .nav-badge {
    position: absolute; top: 1px; left: 50%; margin: 0 0 0 8px;
    font-size: 9px; padding: 0 5px; line-height: 14px;
  }
  /* активная вкладка: только цвет, без белого фона */
  .nav-item.active { background: none; color: #fff; }
  .nav-item.active .nav-badge { background: var(--green); color: #06281a; }
  .nav-item.active::before {
    content: ''; position: absolute; top: 0; left: 50%;
    transform: translateX(-50%); width: 22px; height: 2px;
    background: #fff; border-radius: 0 0 3px 3px;
  }

  /* контент */
  .main { padding: 0 12px calc(84px + env(safe-area-inset-bottom)); }
  .topbar { padding: 12px 0 10px; }
  .topbar h2 { font-size: 17px; }
  .topbar-right { gap: 8px; }
  .updated { display: none; }
  .refresh-label { font-size: 0; }
  .refresh-label::before { content: '⟳'; font-size: 15px; }
  #btn-refresh, #btn-logout-m { padding: 8px 12px; line-height: 1; }
  .mobile-only { display: inline-flex; align-items: center; }

  /* KPI и панели */
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 12px; }
  .kpi { padding: 12px 13px; border-radius: 12px; }
  .kpi-value { font-size: 17px; }
  .kpi-label { font-size: 10px; }
  .kpi-sub { font-size: 10.5px; }
  .panel { padding: 14px; border-radius: 12px; margin-bottom: 10px; }
  .dash-row { gap: 10px; }
  .chart-box { height: 190px; }
  .chart-box.tall { height: 230px; }
  .funnel-label { width: 52px; font-size: 11px; }
  .recent-table td { padding: 8px 6px; font-size: 12.5px; }
  .recent-table td:nth-child(4) { display: none; }   /* колонка «вход → выход» */

  /* карточки токенов */
  .grid { grid-template-columns: 1fr; gap: 10px; }
  .summary-strip { grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 12px; }
  .sumi-value { font-size: 14px; }
  /* вкладки-фильтры на всю ширину, активная — таблетка */
  .subtabs, .chiprow { gap: 6px; margin-bottom: 12px; flex-wrap: nowrap; }
  .subtab, .chip {
    flex: 1; min-width: 0; padding: 8px 4px; font-size: 12.5px;
    text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }

  /* история */
  .history-controls { gap: 10px; }
  .history-controls .input { min-width: 0; flex: 1 1 100%; }
  .hrow { flex-wrap: wrap; row-gap: 7px; padding: 10px 12px; }
  .hrow-names { width: auto; flex: 1; }
  .hrow-m { width: auto; flex: 1 1 28%; }
  .hrow-right { margin-left: 0; width: 100%; justify-content: space-between; }

  /* модалка на весь экран */
  .modal { align-items: stretch; justify-content: stretch; }
  .modal-card {
    width: 100vw; height: 100dvh; max-height: 100dvh;
    border-radius: 0; border: none;
  }
  .modal-head { padding: 14px 14px 0; }
  .mhead { gap: 10px; padding-right: 38px; }
  .mhead .avatar, .mhead .avatar-fallback { width: 44px; height: 44px; border-radius: 12px; font-size: 17px; }
  .mhead-sym { font-size: 16px; flex-wrap: wrap; gap: 7px; }
  .mhead-ca { max-width: 50vw; }
  .mhead-cap { font-size: 15px; }
  .mhead-right { gap: 6px; }
  .modal-close { top: 10px; right: 10px; }
  .modal-tabs { margin: 10px 12px 0; gap: 3px; padding: 3px; }
  .mtab { padding: 8px 2px; font-size: 12px; }
  .modal-body { padding: 14px 14px calc(24px + env(safe-area-inset-bottom)); }
  .ov-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .ov-value { font-size: 13px; }
  .filters-grid { grid-template-columns: 1fr; }
  .dexframe { height: 380px; }

  /* ИИ-вкладка и прочее */
  .ai-head { gap: 10px; }
  .ai-head .btn { width: 100%; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); max-width: calc(100vw - 28px); text-align: center; }

  /* логин: 16px в инпутах = iOS не зумит при фокусе */
  .login-card { width: min(360px, calc(100vw - 28px)); padding: 32px 24px; }
  .login-card input, .input { font-size: 16px; }
}
