:root {
  color-scheme: light;
  --bg: #f6f5f2;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --line: #e1e0d9;
  --axis: #c3c2b7;
  --accent: #2a78d6;
  --accent-ink: #fff;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --good: #006300;
  --bad: #d03b3b;
  --star: #f2a900;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0d0d; --surface: #1a1a19; --surface-2: #232321; --ink: #f0efec; --ink-2: #c3c2b7;
    --muted: #898781; --line: #2c2c2a; --axis: #383835; --accent: #3987e5;
    --series-1: #3987e5; --series-2: #d95926; --good: #0ca30c; --bad: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0d; --surface: #1a1a19; --surface-2: #232321; --ink: #f0efec; --ink-2: #c3c2b7;
  --muted: #898781; --line: #2c2c2a; --axis: #383835; --accent: #3987e5;
  --series-1: #3987e5; --series-2: #d95926; --good: #0ca30c; --bad: #e66767;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 12px; }
h1 { font-size: 26px; } h2 { font-size: 20px; } h3 { font-size: 16px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); } .ink2 { color: var(--ink-2); }
.small { font-size: 13px; }
.boot { padding: 40px; text-align: center; color: var(--muted); }
.hidden { display: none !important; }

/* ---------- кнопки и поля ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: 600 14px var(--font); cursor: pointer;
  text-decoration: none !important; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 5px; font-weight: 500; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: 15px var(--font);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 80px; resize: vertical; }
.check { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.check input { width: auto; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 600px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- каркас кабинета ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 4px 10px 18px; color: var(--ink); }
.brand img { width: 28px; height: 28px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--ink-2); font-weight: 500; text-decoration: none; }
.nav a:hover { background: var(--surface-2); }
.nav a.on { background: var(--surface-2); color: var(--ink); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .badge { margin-left: auto; }
.side .foot { margin-top: auto; padding: 10px; font-size: 13px; }
.main { padding: 28px 32px 60px; max-width: 1180px; width: 100%; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.topbar h1 { margin: 0; }
.tabbar { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 16px 16px 96px; }
  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); text-decoration: none; padding: 4px 0; position: relative; }
  .tabbar a.on { color: var(--accent); }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar .badge { position: absolute; top: 0; left: 55%; }
  h1 { font-size: 22px; }
}

/* ---------- карточки ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card > h3 { margin-bottom: 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.cards .card { margin: 0; }
.badge { display: inline-block; min-width: 18px; padding: 1px 6px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; text-align: center; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); font-size: 12px; font-weight: 600; }
.pill.ok { color: var(--good); } .pill.bad { color: var(--bad); }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.notice { border-radius: 12px; padding: 12px 14px; background: var(--surface-2); margin-bottom: 16px; font-size: 14px; }
.notice.warn { border-left: 3px solid #fab219; }

/* ---------- статистика ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filters select { width: auto; min-width: 150px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 7px 12px; border-radius: 8px; font: 600 13px var(--font); color: var(--ink-2); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 960px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .k { font-size: 13px; color: var(--ink-2); }
.tile .v { font-size: 28px; font-weight: 700; margin: 2px 0; }
.tile .s { font-size: 12px; color: var(--muted); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 960px) { .two { grid-template-columns: 1fr; } }
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .base { stroke: var(--axis); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); margin-bottom: 8px; }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.12); white-space: nowrap; z-index: 5; }
.tip b { display: block; margin-bottom: 2px; }
.tip i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.bars .bar { display: grid; grid-template-columns: 92px 1fr 48px; gap: 10px; align-items: center; margin-bottom: 9px; font-size: 13px; }
.bars .track { height: 12px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bars .fill { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }
.bars .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.stars { color: var(--star); letter-spacing: 1px; }

/* ---------- таблицы ---------- */
.tablewrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
td input.num-input { width: 96px; text-align: right; padding: 7px 9px; }
td input { padding: 7px 9px; }
code { font: 13px ui-monospace, Consolas, monospace; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }

/* ---------- отзывы ---------- */
.fb { border-bottom: 1px solid var(--line); padding: 14px 0; }
.fb:last-child { border-bottom: 0; }
.fb.unread { position: relative; }
.fb.unread::before { content: ""; position: absolute; left: -12px; top: 22px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.fb .meta { font-size: 12px; color: var(--muted); }
.fb .text { margin: 6px 0; white-space: pre-wrap; }

/* ---------- тарифы ---------- */
.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
@media (max-width: 860px) { .plans { grid-template-columns: 1fr; } }
.plan { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; }
.plan.cur { border-color: var(--accent); }
.plan .price { font-size: 30px; font-weight: 700; margin: 6px 0 2px; }
.plan ul { padding-left: 18px; margin: 12px 0 18px; color: var(--ink-2); }
.plan .btn { margin-top: auto; }

/* ---------- лендинг и авторизация ---------- */
.land { max-width: 1080px; margin: 0 auto; padding: 0 16px 60px; }
.land header { display: flex; justify-content: space-between; align-items: center; padding: 18px 0; }
.hero { padding: 48px 0 40px; display: grid; grid-template-columns: 1.1fr .9fr; gap: 40px; align-items: center; }
.hero h1 { font-size: 44px; letter-spacing: -.02em; margin-bottom: 16px; }
.hero p.lead { font-size: 18px; color: var(--ink-2); margin-bottom: 24px; }
.phone { background: var(--surface); border: 1px solid var(--line); border-radius: 28px; padding: 26px 22px; max-width: 320px; margin: 0 auto; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.08); }
.phone .bigstars { font-size: 36px; color: var(--star); letter-spacing: 4px; margin: 12px 0; }
.phone .fake { padding: 11px; border-radius: 10px; border: 1px solid var(--line); margin-top: 8px; font-weight: 600; font-size: 14px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 24px 0 48px; }
.steps .card { margin: 0; }
.steps .n { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; margin-bottom: 10px; }
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; padding-top: 20px; }
  .hero h1 { font-size: 32px; }
  .steps { grid-template-columns: 1fr; }
}
.authbox { max-width: 420px; margin: 6vh auto; padding: 0 16px; }
.authbox .card { padding: 26px; }

/* ---------- модалка и тост ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--surface); border-radius: 18px; padding: 22px; width: 100%; max-width: 440px; max-height: 90vh; overflow: auto; }
.qr { background: #fff; padding: 14px; border-radius: 12px; display: inline-block; margin: 8px 0 12px; }
#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; }

/* В Telegram скрываем то, что дублирует интерфейс Telegram */
.in-tg .side .foot .logout { display: none; }
