/* ============================================================
   MVKVN admin — iOS Settings style. Тёмная тема по умолчанию,
   светлая — через [data-theme="light"]. Никаких градиентов-«control room».
   ============================================================ */
:root {
    --bg:        #000000;   /* фон экрана (iOS dark settings) */
    --bg-2:      #1c1c1e;   /* группа-карточка */
    --bg-3:      #2c2c2e;   /* нажатая строка / вторичная плашка */
    --sep:       rgba(255,255,255,.10);  /* hairline */
    --text:      #ffffff;
    --text-2:    #ebebf5;
    --text-3:    rgba(235,235,245,.6);   /* подписи */
    --text-4:    rgba(235,235,245,.3);
    --accent:    #0a84ff;   /* iOS blue (dark) */
    --green:     #30d158;
    --red:       #ff453a;
    --orange:    #ff9f0a;
    --yellow:    #ffd60a;
    --r:         12px;      /* радиус группы */
    --row-h:     46px;
    --pad:       16px;
    --hdr-h:     52px;
    --safe-t:    env(safe-area-inset-top, 0px);
    --safe-b:    env(safe-area-inset-bottom, 0px);
    --ico-blue:  #0a84ff; --ico-green:#30d158; --ico-red:#ff453a;
    --ico-orange:#ff9f0a; --ico-purple:#bf5af2; --ico-teal:#40c8e0;
    --ico-pink:#ff375f; --ico-gray:#8e8e93; --ico-indigo:#5e5ce6;
}
/* Заглушка «доступа нет» — панель открыли вне Telegram (без initData). */
.noauth {
    min-height: 72vh; display: flex; flex-direction: column;
    align-items: center; justify-content: center; text-align: center;
    gap: 12px; padding: 32px 26px; max-width: 460px; margin: 0 auto;
}
.noauth-ico { font-size: 54px; line-height: 1; }
.noauth-title { font-size: 22px; font-weight: 800; color: var(--text); }
.noauth-sub { font-size: 14px; line-height: 1.55; color: var(--text-3); }
[data-theme="light"] {
    --bg:        #f2f2f7;
    --bg-2:      #ffffff;
    --bg-3:      #e5e5ea;
    --sep:       rgba(60,60,67,.13);
    --text:      #000000;
    --text-2:    #1c1c1e;
    --text-3:    rgba(60,60,67,.6);
    --text-4:    rgba(60,60,67,.3);
    --accent:    #007aff;
    --green:     #34c759; --red:#ff3b30; --orange:#ff9500; --yellow:#ffcc00;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
    margin: 0; padding: 0; background: var(--bg); color: var(--text);
    font: 17px/1.3 -apple-system, BlinkMacSystemFont, "SF Pro Text",
          system-ui, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none;
}
body { padding-bottom: var(--safe-b); }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; }

/* ── Sticky header (iOS large-then-small) ─────────────────── */
.nav {
    position: sticky; top: 0; z-index: 50;
    padding-top: var(--safe-t);
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: .5px solid var(--sep);
}
.nav-bar {
    height: var(--hdr-h); display: flex; align-items: center;
    gap: 6px; padding: 0 8px; position: relative;
}
.nav-back {
    display: inline-flex; align-items: center; gap: 7px;
    color: var(--accent); background: none; border: 0;
    font-size: 17px; padding: 6px 6px; min-width: 44px; min-height: 44px;
}
.nav-back svg { width: 12px; height: 20px; }
/* заголовок центрируем по экрану абсолютно — чтобы кнопка «Назад» слева не
   сдвигала его вбок (иначе он не идеально по центру). */
.nav-title {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    max-width: 56%; text-align: center; font-size: 17px; font-weight: 600;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    pointer-events: none;
}
.nav-right { min-width: 44px; display: flex; justify-content: flex-end; gap: 4px; }
.nav-icon-btn {
    background: none; border: 0; color: var(--accent);
    min-width: 44px; min-height: 44px; font-size: 18px;
}
.nav-large {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 10px; padding: 2px 16px 10px;
}
.nav-large-t { font-size: 32px; font-weight: 800; letter-spacing: -.5px; }
.nav-large-meta { font-size: 13px; font-weight: 400; color: var(--text-3);
    white-space: nowrap; }

/* ── Content scroll area ──────────────────────────────────── */
.page { max-width: 720px; margin: 0 auto; padding: 0 0 40px; }
/* Главная без навбара: отступ сверху под safe-area (вырез/статус-бар). */
.page-top { padding-top: calc(var(--safe-t) + 6px); }
/* iOS push-переход: новый экран въезжает справа (вперёд) / слева (назад). */
body { overflow-x: hidden; }
@keyframes pgFwd { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes pgBack { from { transform: translateX(-100%); } to { transform: translateX(0); } }
.page.pg-fwd { animation: pgFwd .28s cubic-bezier(.32, .72, 0, 1); }
.page.pg-back { animation: pgBack .28s cubic-bezier(.32, .72, 0, 1); }
.intro {
    color: var(--text-3); font-size: 13px; line-height: 1.4;
    padding: 6px 16px 14px;
}

/* ── Group (iOS grouped card) ─────────────────────────────── */
.group { margin: 18px 16px 0; }
.group.tight { margin-top: 8px; }                    /* «Добавить голос» ближе к списку */
.group-note { color: var(--text-3); font-size: 13px; padding: 7px 20px 0; }
.group-hdr {
    color: var(--text-3); font-size: 13px; font-weight: 400;
    text-transform: uppercase; letter-spacing: .3px;
    padding: 0 4px 7px;
}
.group-body {
    background: var(--bg-2); border-radius: var(--r); overflow: hidden;
}
.group-ftr { color: var(--text-3); font-size: 13px; padding: 7px 4px 0; }

/* ── Row ──────────────────────────────────────────────────── */
.row {
    display: flex; align-items: center; gap: 12px;
    min-height: var(--row-h); padding: 8px 16px 8px 14px;
    position: relative; background: var(--bg-2);
}
/* hairline между ЛЮБЫМИ соседними строками группы (row/slider/seg/chk/swipe). */
.group-body > * { position: relative; }
.group-body > * + *::before {
    content: ""; position: absolute; left: 52px; right: 0; top: 0;
    height: .5px; background: var(--sep); pointer-events: none; z-index: 1;
}
.row.tap { transition: background .12s; }
.row.tap:active { background: var(--bg-3); }
.row-ico {
    width: 30px; height: 30px; border-radius: 7px; flex-shrink: 0;
    display: grid; place-items: center; font-size: 17px; color: #fff;
    background: var(--ico-gray);
}
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 16px; color: var(--text); }
.row-sub { font-size: 12px; color: var(--text-3); margin-top: 1px;
    overflow: hidden; text-overflow: ellipsis; }
.row-val { color: var(--text-3); font-size: 15px; max-width: 48%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    text-align: right; }
.row-chev { color: var(--text-4); width: 8px; height: 14px; flex-shrink: 0; }
.row.danger .row-title { color: var(--red); }
.row.center { justify-content: center; }
.row.center .row-title { color: var(--accent); font-weight: 500; }
.row.center.danger .row-title { color: var(--red); }
.row[disabled], .row.is-disabled { opacity: .45; pointer-events: none; }

/* ── Toggle (iOS switch) ──────────────────────────────────── */
.sw {
    width: 51px; height: 31px; border-radius: 999px; flex-shrink: 0;
    background: var(--bg-3); position: relative; transition: background .2s;
    border: 0; padding: 0;
}
.sw::after {
    content: ""; position: absolute; top: 2px; left: 2px;
    width: 27px; height: 27px; border-radius: 50%; background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s;
}
.sw.on { background: var(--green); }
.sw.on::after { transform: translateX(20px); }

/* ── Slider ───────────────────────────────────────────────── */
.slider-row { display: block; padding: 12px 16px 14px 14px; min-height: 44px; }
.slider-top { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.slider-val { color: var(--text); font-variant-numeric: tabular-nums; font-size: 15px; }
input[type=range].slider {
    -webkit-appearance: none; appearance: none; width: 100%; height: 4px;
    border-radius: 2px; background: var(--bg-3); outline: none; margin: 6px 0 2px;
}
input[type=range].slider::-webkit-slider-thumb {
    -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); cursor: pointer;
}
input[type=range].slider::-moz-range-thumb {
    width: 26px; height: 26px; border: 0; border-radius: 50%; background: #fff;
}

/* ── Segmented control ────────────────────────────────────── */
.seg-row { padding: 10px 16px 12px; }
.seg-row .row-title { margin-bottom: 8px; }
.seg {
    display: flex; background: var(--bg-3); border-radius: 9px; padding: 2px;
    gap: 2px;
}
.seg button {
    flex: 1; border: 0; background: none; color: var(--text-2);
    padding: 9px 4px; border-radius: 7px; font-size: 13px; min-height: 40px;
    transition: background .15s;
}
.seg button.on { background: var(--accent); color: #fff; font-weight: 600; }

/* ── Scope badge (Глобально / Беседа) ─────────────────────── */
.scope {
    display: inline-block; font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .4px; padding: 2px 6px;
    border-radius: 5px; margin-left: 6px; vertical-align: middle;
}
.scope.chat { background: rgba(10,132,255,.18); color: #4aa3ff; }
.scope.global { background: rgba(142,142,147,.22); color: #aeaeb2; }

/* ── Status cards (Главная) ───────────────────────────────── */
.stat-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
    margin: 14px 16px 0;
}
.stat-card {
    background: var(--bg-2); border-radius: var(--r); padding: 12px 14px;
    display: flex; flex-direction: column; justify-content: space-between;
    min-height: 84px;            /* метка сверху, значение в левом-нижнем углу */
    min-width: 0;                /* grid-колонка не растягивается под nowrap-текст */
}
.stat-card .lbl { color: var(--text-3); font-size: 12px; }
/* Значения карточек стартуют крупными (как счётчик сообщений); JS ужимает
   длинные строки до одной строки (shrink-to-fit), без переноса посреди слова. */
.stat-card .val { font-size: 40px; font-weight: 700; margin-top: 8px;
    letter-spacing: -.5px; font-variant-numeric: tabular-nums; line-height: 1.05;
    white-space: nowrap; overflow: hidden; }
.stat-card .val.ok { color: var(--green); }
.stat-card .val.warn { color: var(--orange); }
.stat-card .val.bad { color: var(--red); }
.warn-card {
    display: flex; gap: 10px; align-items: center; margin: 12px 16px 0;
    background: rgba(255,159,10,.14); border: .5px solid rgba(255,159,10,.4);
    border-radius: var(--r); padding: 11px 14px; color: var(--orange);
    font-size: 14px;
}

/* ── Chips / role badges ──────────────────────────────────── */
.chip {
    display: inline-flex; align-items: center; gap: 5px; font-size: 13px;
    background: var(--bg-3); color: var(--text-2); border: 0;
    padding: 6px 12px; border-radius: 999px; min-height: 32px;
}
.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.badge.owner { background: rgba(255,214,10,.2); color: var(--yellow); }
.badge.full  { background: rgba(48,209,88,.2); color: var(--green); }
.badge.limited { background: rgba(10,132,255,.2); color: #4aa3ff; }
.badge.view  { background: rgba(142,142,147,.25); color: #aeaeb2; }
.badge.off   { background: rgba(255,69,58,.2); color: var(--red); }

/* ── Search (встроенная строка вверху Главной, iOS Settings) ── */
.search-bar { display: flex; align-items: center; gap: 8px; margin: 4px 16px 6px;
    background: var(--bg-2); border-radius: 10px; padding: 9px 12px; }
.search-ico { opacity: .5; font-size: 15px; line-height: 1; }
.search-input { flex: 1; background: none; border: 0; color: var(--text);
    font-size: 17px; outline: none; min-width: 0; }
.search-input::placeholder { color: var(--text-3); }

/* ── Inputs in rows ───────────────────────────────────────── */
.row input.inp {
    background: var(--bg-3); border: 0; border-radius: 8px; color: var(--text);
    padding: 7px 10px; font-size: 15px; width: 120px; text-align: right;
}
/* числовой инпут авто-ширины (size по содержимому) */
.numf {
    background: var(--bg-3); border: 0; border-radius: 8px; color: var(--text);
    padding: 7px 8px; font-size: 15px; text-align: center; width: auto; min-width: 0;
}
.unit-suf { color: var(--text-3); font-size: 15px; }
.btn {
    background: var(--accent); color: #fff; border: 0; border-radius: 9px;
    padding: 8px 14px; font-size: 15px; font-weight: 600; min-height: 38px;
}
.btn.ghost { background: var(--bg-3); color: var(--accent); }
.btn.red { background: var(--red); }
.btn.sm { padding: 6px 10px; font-size: 13px; min-height: 32px; }
.btn:disabled { opacity: .5; }

/* ── Bottom sheet / confirm ───────────────────────────────── */
.sheet-back {
    position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.5);
    display: flex; align-items: flex-end; justify-content: center;
    opacity: 0; transition: opacity .2s;
}
.sheet-back.show { opacity: 1; }
.sheet {
    background: var(--bg-2); width: 100%; max-width: 520px;
    border-radius: 16px 16px 0 0; padding: 20px 18px;
    padding-bottom: calc(18px + var(--safe-b));
    transform: translateY(100%); transition: transform .25s ease;
}
.sheet-back.show .sheet { transform: translateY(0); }
.sheet-title { font-size: 18px; font-weight: 700; text-align: center; }
.sheet-body { color: var(--text-3); font-size: 14px; text-align: center;
    margin: 8px 0 18px; line-height: 1.4; }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; }
.sheet-actions .btn { width: 100%; min-height: 48px; font-size: 17px; }
.sheet-sub { text-align: center; color: var(--text-3); font-size: 13px; margin-top: 3px; }
/* iOS-поля ввода в шитах (не привязаны к .row). */
.field {
    width: 100%; background: var(--bg-3); border: 0; border-radius: 10px;
    color: var(--text); font-size: 16px; padding: 13px 14px; outline: none;
}
.field::placeholder { color: var(--text-3); }
.field-group { display: flex; flex-direction: column; gap: 10px; margin: 16px 0 20px; }
.sheet-list { max-height: 50vh; overflow-y: auto; margin: 6px -4px 0; }
.sheet-opt {
    display: flex; align-items: center; gap: 10px; padding: 12px 8px;
    border-radius: 8px; border-bottom: .5px solid var(--sep);
}
.sheet-opt:active { background: var(--bg-3); }
.sheet-opt .check { color: var(--accent); width: 22px; }

/* ── Toast ────────────────────────────────────────────────── */
.toast {
    position: fixed; left: 50%; bottom: calc(28px + var(--safe-b));
    transform: translateX(-50%) translateY(20px);
    background: rgba(40,40,42,.96); color: #fff; padding: 11px 18px;
    border-radius: 12px; font-size: 14px; z-index: 200; opacity: 0;
    pointer-events: none; transition: opacity .2s, transform .2s;
    max-width: 84%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── States ───────────────────────────────────────────────── */
.state { text-align: center; color: var(--text-3); padding: 60px 24px; }
.state .em { font-size: 34px; margin-bottom: 10px; }
.spinner {
    width: 26px; height: 26px; border: 3px solid var(--bg-3);
    border-top-color: var(--accent); border-radius: 50%;
    animation: spin .8s linear infinite; margin: 60px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton {
    background: linear-gradient(90deg, var(--bg-2), var(--bg-3), var(--bg-2));
    background-size: 200% 100%; animation: shimmer 1.2s infinite;
    border-radius: var(--r); height: 54px; margin: 12px 16px 0;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── messages chart (iOS) ─────────────────────────────────── */
.chart-card { padding: 14px 14px 12px; position: relative; }
.chart-wrap { position: relative; width: 100%; }
.chart-svg { width: 100%; height: 150px; display: block; touch-action: none; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2.5;
    stroke-linecap: round; stroke-linejoin: round; }
.chart-area { fill: var(--accent); opacity: .12; }
.chart-cursor { stroke: var(--text-4); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; }
.chart-cursor.on { opacity: 1; }
.chart-dot { fill: var(--accent); stroke: var(--bg-2); stroke-width: 2; opacity: 0; }
.chart-dot.on { opacity: 1; }
.chart-tip { position: absolute; background: rgba(40,40,42,.96); color: #fff;
    font-size: 12px; padding: 5px 9px; border-radius: 8px; pointer-events: none;
    opacity: 0; transition: opacity .12s; white-space: nowrap; z-index: 2; }
.chart-tip.on { opacity: 1; }
.chart-total { color: var(--text-3); font-size: 13px; margin: 8px 2px 10px; }
.seg.chart-types { flex-wrap: wrap; }
/* типы тянутся на всю ширину строки и перераспределяются равномерно по мере
   появления новых категорий (flex:1 → равные доли; min-width — чтобы не схлопнулись). */
.seg.chart-types button { flex: 1 1 0; min-width: 64px; padding: 6px 6px; min-height: 32px; }

/* категории внутри списка голосов m mv (тонкий iOS-разделитель) */
.cat-div { font-size: 12px; color: var(--text-3); text-transform: uppercase;
    letter-spacing: .3px; padding: 11px 16px 5px; background: var(--bg-2);
    border-top: .5px solid var(--sep); }
.cat-div:first-child { border-top: 0; }
.mv-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px 12px;
    background: var(--bg-2); }
.mv-chip { font-size: 12px; background: var(--bg-3); color: var(--text-2);
    padding: 4px 9px; border-radius: 999px; }

/* свайп-влево для удаления (iOS swipe action) */
.swipe { position: relative; overflow: hidden; background: var(--bg-2); }
.swipe-content { position: relative; background: var(--bg-2); touch-action: pan-y;
    transition: transform .22s ease; will-change: transform; }
.swipe-del { position: absolute; top: 0; right: 0; height: 100%; width: 96px;
    border: 0; background: var(--red); color: #fff; font-size: 15px; font-weight: 600; }
/* кнопки внутри строки (напр. «Тест») плавно гаснут при свайпе влево */
.swipe-content .btn { opacity: calc(1 - var(--sw, 0)); transition: opacity .18s; }

/* монотекст (топ сцен, логи) */
.log-box { white-space: pre-wrap; word-break: break-word; padding: 12px 14px;
    font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--text-2); max-height: 340px; overflow-y: auto; }

/* checkbox list row */
.chk-row { display: flex; align-items: center; gap: 12px; min-height: 44px;
    padding: 6px 16px; }
.chk { width: 24px; height: 24px; border-radius: 6px; flex-shrink: 0;
    border: 1.5px solid var(--text-4); display: grid; place-items: center;
    color: #fff; }
.chk.on { background: var(--accent); border-color: var(--accent); }

/* desktop: чуть шире, центрируем */
@media (min-width: 760px) {
    .page { padding-top: 8px; }
}
