/* ============================================================
   ШОПС — дизайн-система админки (перенос оболочки vpn_bot).
   Светлая тема по умолчанию, тёмная — по системе или вручную.
   Системные шрифты: CSP font-src 'self', внешних шрифтов нет.
   ============================================================ */

:root {
  --bg:            #f7f6f2;
  --surface:       #ffffff;
  --surface-2:     #fbfaf7;
  --surface-hover: #f6f5f1;
  --border:        #e8e6df;
  --border-strong: #ddd9cf;
  --border-faint:  #f0eee8;

  --ink:           #1c1b18;
  --ink-2:         #6c6a62;
  --ink-3:         #9b988d;
  --ink-4:         #b9b6aa;

  --accent:        #4d57a3;
  --accent-press:  #424b8e;
  --accent-soft:   #eef0f7;
  --accent-border: #d9ddee;

  --ok:     #4f8a63;   --ok-soft:   #ecf2ee;
  --warn:   #b08433;   --warn-soft: #f5efe2;
  --bad:    #b1554d;   --bad-soft:  #f5eae8;
  --neutral-soft: #f3f2ec;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --r-card: 12px;
  --r-md:   9px;
  --r-sm:   6px;

  --shadow-card: 0 1px 2px rgba(28,27,24,.04);
  --shadow-pop:  0 10px 34px rgba(28,27,24,.12), 0 2px 8px rgba(28,27,24,.05);

  --sidebar-w: 236px;
  --topbar-h:  56px;
  --maxw: 1380px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p { margin: 0; }
svg { width: 15px; height: 15px; flex: none; }
button { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--accent-soft); }

.mono { font-family: var(--mono); letter-spacing: -0.01em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.muted-2 { color: var(--ink-3); }
.medium { font-weight: 500; }
.break { word-break: break-all; }

/* ============================================================ shell */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: 100vh;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 14px 12px 12px;
  min-width: 0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; }
.brand-mark { width: 22px; height: 22px; color: var(--ink); }
.brand-name { font-weight: 500; font-size: 14.5px; letter-spacing: -0.02em; }
.brand-sub { font-size: 11px; color: var(--ink-3); margin-left: auto; padding-right: 2px; }

.nav { display: flex; flex-direction: column; gap: 1px; margin-top: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 9px; border-radius: var(--r-sm);
  color: var(--ink-2); cursor: pointer; border: none; background: none;
  width: 100%; text-align: left; font-size: 13.5px;
  transition: background .12s, color .12s;
}
.nav-item svg { width: 16px; height: 16px; color: var(--ink-3); }
.nav-item:hover { background: var(--surface-hover); color: var(--ink); }
.nav-item.active { background: var(--surface); color: var(--ink); font-weight: 500; box-shadow: var(--shadow-card); }
.nav-item.active svg { color: var(--accent); }

.sidebar-foot { margin-top: auto; padding-top: 10px; }
.account { display: flex; align-items: center; gap: 8px; padding: 9px 4px 4px 8px; }
.account .ava {
  width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: var(--bg);
  display: grid; place-items: center; font-size: 11px; font-weight: 500; flex: none;
}
.account .meta { min-width: 0; line-height: 1.25; flex: 1; }
.account .nm { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account .rl { font-size: 11px; color: var(--ink-3); }
.gear {
  color: var(--ink-3); background: none; border: none; cursor: pointer; padding: 0;
  border-radius: 6px; display: grid; place-items: center; min-width: 40px; min-height: 40px;
}
.gear:hover { color: var(--ink); background: var(--surface-hover); }
.gear svg { width: 16px; height: 16px; }

.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; background: var(--bg); }
.topbar { flex: none; display: flex; align-items: center; gap: 14px; }
.topbar-title { font-weight: 500; }
.icon-btn {
  width: 32px; height: 32px; border-radius: var(--r-sm); border: 1px solid transparent;
  background: none; color: var(--ink-3); display: grid; place-items: center; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--ink); }
.icon-btn svg { width: 16px; height: 16px; }

.view { flex: 1; overflow-y: auto; overflow-x: hidden; }
.view-inner { max-width: var(--maxw); margin: 0 auto; padding: 26px 30px 60px; }

.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; }
.page-head .titles { min-width: 0; }
.page-title { font-size: 21px; font-weight: 500; letter-spacing: -0.025em; }
.page-sub { color: var(--ink-2); font-size: 13px; margin-top: 3px; }
.page-head .actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: none; }

/* ============================================================ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 33px; padding: 0 13px; border-radius: var(--r-md);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  cursor: pointer; font-size: 13px; white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn svg { width: 15px; height: 15px; color: var(--ink-2); }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: var(--shadow-card); }
.btn-primary svg { color: #fff; }
.btn-primary:hover { background: var(--accent-press); border-color: var(--accent-press); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn-block { width: 100%; }
.btn-ghost { border-color: transparent; background: none; }
.btn-ghost:hover { background: var(--surface-hover); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.fld .btn-row, .modal-body .btn-row, .auth-card .btn-row { margin-top: 8px; }

/* ============================================================ pills + status */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 21px; padding: 0 8px; border-radius: var(--r-sm);
  background: var(--neutral-soft); border: 1px solid var(--border-faint);
  color: var(--ink-2); font-size: 12px; white-space: nowrap;
}
.pill-accent { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent); }
.status { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; font-size: 13px; }
.status .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--ink-4); }
.status.s-ok { color: var(--ok); }     .status.s-ok .dot { background: var(--ok); }
.status.s-warn { color: var(--warn); } .status.s-warn .dot { background: var(--warn); }
.status.s-bad { color: var(--bad); }   .status.s-bad .dot { background: var(--bad); }
.status.s-mute { color: var(--ink-3); } .status.s-mute .dot { background: var(--ink-4); }

/* ============================================================ cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-card); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border-faint); }
.card-head h3 { font-size: 13.5px; font-weight: 500; }
.card-head .sub { color: var(--ink-3); font-size: 12px; }
.card-head .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 16px 18px; }
.card-body p + p { margin-top: 8px; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.metric {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card);
  box-shadow: var(--shadow-card); padding: 15px 16px 14px; min-width: 0;
}
.metric .label { font-size: 12.5px; color: var(--ink-2); }
.metric .value { font-size: 27px; font-weight: 500; letter-spacing: -0.03em; margin-top: 9px; line-height: 1; color: var(--ink-4); }
.metric .foot { margin-top: 9px; font-size: 12px; color: var(--ink-3); }

/* ============================================================ tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-weight: 400; color: var(--ink-3); font-size: 12px;
  padding: 12px 14px 9px; border-bottom: 1px solid var(--border-faint); white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border-faint); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table th:first-child, .table td:first-child { padding-left: 18px; }
.table th:last-child, .table td:last-child { padding-right: 18px; }
.table td.r, .table th.r { text-align: right; }
.table .cell-ua { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pager { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 14px 18px; border-top: 1px solid var(--border-faint); }

.empty { text-align: center; padding: 50px 20px; color: var(--ink-3); }

/* ============================================================ forms */
.fld { margin-bottom: 15px; }
.fld:last-child { margin-bottom: 0; }
.fld > label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; }
.fld .hint { font-size: 11.5px; color: var(--ink-3); margin-top: 5px; }
.fld .hint.bad, .hint.bad { color: var(--bad); }
.check-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; margin-top: 8px; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check-row input[type="checkbox"] { margin: 0; }
.input {
  width: 100%; height: 34px; border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); padding: 0 11px; font: inherit; font-size: 13px; color: var(--ink); outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.input.mono { font-family: var(--mono); font-size: 13px; letter-spacing: .06em; }
.input::placeholder { color: var(--ink-4); }
.input:focus { border-color: var(--accent-border); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { height: auto; padding: 9px 11px; resize: vertical; line-height: 1.5; }
select.input { cursor: pointer; }
select.input.input-sm { height: 28px; width: auto; font-size: 12.5px; padding: 0 8px; }

.form-error { color: var(--bad); font-size: 12.5px; margin-top: 10px; }
.form-note { color: var(--ink-2); font-size: 12.5px; margin-top: 10px; }

/* ============================================================ auth screens */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card);
  box-shadow: var(--shadow-pop); padding: 26px 24px 24px;
}
.auth-card.wide { max-width: 460px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.auth-title { font-size: 18px; font-weight: 500; letter-spacing: -0.02em; margin-bottom: 4px; }
.auth-sub { color: var(--ink-2); font-size: 13px; margin-bottom: 18px; }
.auth-actions { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; padding: 4px 0; font-size: 12.5px; }
.link-btn:hover { text-decoration: underline; }

.qr { display: grid; place-items: center; padding: 12px; background: #fff; border: 1px solid var(--border); border-radius: var(--r-md); margin-bottom: 14px; }
.qr img { width: 196px; height: 196px; image-rendering: pixelated; }
.secret-box {
  font-family: var(--mono); font-size: 13px; letter-spacing: .08em; word-break: break-all;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 9px 11px;
}
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 4px 0 14px; padding: 0; list-style: none; }
.codes li {
  font-family: var(--mono); font-size: 14px; text-align: center; padding: 8px 6px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm);
}
.warn-box { background: var(--warn-soft); color: var(--ink); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 12px; font-size: 12.5px; margin-bottom: 14px; }

/* ============================================================ modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: color-mix(in srgb, var(--bg) 55%, transparent); backdrop-filter: blur(3px);
}
.modal {
  width: 100%; max-width: 440px; max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-pop); padding: 20px 22px;
}
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; flex: none; }
.modal-body { font-size: 13.5px; line-height: 1.5; color: var(--ink-2); overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.modal-body .fld { margin-top: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex: none; }

/* ============================================================ toast */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--ink); color: var(--bg); border-radius: var(--r-md); padding: 10px 14px;
  font-size: 13px; box-shadow: var(--shadow-pop); max-width: 360px;
}
.toast.bad { background: var(--bad); color: #fff; }

/* ============================================================ responsive */
.nav-burger { display: none; width: 40px; height: 40px; flex: none; }
.nav-scrim {
  position: fixed; inset: 0; z-index: 60;
  background: color-mix(in srgb, var(--ink) 28%, transparent);
  opacity: 0; transition: opacity .16s ease;
}

@media (max-width: 1023px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 70;
    width: min(82vw, var(--sidebar-w));
    background: var(--surface);
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: var(--shadow-pop);
    overflow-y: auto;
  }
  body.drawer-open .sidebar { transform: translateX(0); }
  body.drawer-open .nav-scrim { opacity: 1; }
  body.drawer-open { overflow: hidden; }
  .nav-burger { display: grid; }
  .topbar { height: var(--topbar-h); padding: 0 22px; border-bottom: 1px solid var(--border); }
  .metrics { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 759px) {
  .view-inner { padding: 18px 16px 48px; }
  .page-head { flex-wrap: wrap; }
  .page-head .actions { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .topbar { padding: 0 14px; gap: 10px; }

  .table { display: block; width: 100%; }
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .table tbody { display: block; width: 100%; }
  .table tbody tr {
    display: block; width: 100%;
    border: 1px solid var(--border); border-radius: var(--r-md);
    background: var(--surface); padding: 4px 12px; margin: 10px 0;
  }
  .table tbody tr td {
    display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
    width: 100%; padding: 7px 0; border-bottom: 1px solid var(--border-faint); text-align: right;
  }
  .table tbody tr td:last-child { border-bottom: none; }
  .table tbody tr td:first-child, .table tbody tr td:last-child { padding-left: 0; padding-right: 0; }
  .table tbody tr td[data-label]::before {
    content: attr(data-label); flex: none; text-align: left;
    color: var(--ink-3); font-size: 12px; white-space: nowrap;
  }
  .table .cell-ua { max-width: 60vw; }
  .table-wrap { overflow-x: hidden; padding: 0 12px; }
}

@media (max-width: 519px) {
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { max-width: none; max-height: 88vh; border-radius: var(--r-card) var(--r-card) 0 0; border-bottom: none; }
  .metrics { grid-template-columns: 1fr; }
}

/* ============================================================ dark theme */
:root[data-theme="dark"], :root[data-theme="dark"] * { color-scheme: dark; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #16161a;
    --surface:       #1d1d22;
    --surface-2:     #232329;
    --surface-hover: #26262d;
    --border:        #32323a;
    --border-strong: #3d3d46;
    --border-faint:  #27272d;
    --ink:           #ecebe6;
    --ink-2:         #a6a49c;
    --ink-3:         #76746c;
    --ink-4:         #5a5953;
    --accent:        #8a92d8;
    --accent-press:  #9aa1e0;
    --accent-soft:   #25273a;
    --accent-border: #3a3d57;
    --ok:     #6fb487;   --ok-soft:   #1d2a22;
    --warn:   #cfa257;   --warn-soft: #2c2718;
    --bad:    #d07a72;   --bad-soft:  #2c1d1b;
    --neutral-soft: #25252b;
    --shadow-card: 0 1px 2px rgba(0,0,0,.4);
    --shadow-pop:  0 10px 34px rgba(0,0,0,.55), 0 2px 8px rgba(0,0,0,.4);
  }
}

[data-theme="dark"] {
  --bg:            #16161a;
  --surface:       #1d1d22;
  --surface-2:     #232329;
  --surface-hover: #26262d;
  --border:        #32323a;
  --border-strong: #3d3d46;
  --border-faint:  #27272d;
  --ink:           #ecebe6;
  --ink-2:         #a6a49c;
  --ink-3:         #76746c;
  --ink-4:         #5a5953;
  --accent:        #8a92d8;
  --accent-press:  #9aa1e0;
  --accent-soft:   #25273a;
  --accent-border: #3a3d57;
  --ok:     #6fb487;   --ok-soft:   #1d2a22;
  --warn:   #cfa257;   --warn-soft: #2c2718;
  --bad:    #d07a72;   --bad-soft:  #2c1d1b;
  --neutral-soft: #25252b;
  --shadow-card: 0 1px 2px rgba(0,0,0,.4);
  --shadow-pop:  0 10px 34px rgba(0,0,0,.55), 0 2px 8px rgba(0,0,0,.4);
}

.theme-toggle .theme-icon-dark { display: block; }
.theme-toggle .theme-icon-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .theme-icon-dark { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .theme-icon-light { display: block; }
}
[data-theme="dark"] .theme-toggle .theme-icon-dark { display: none; }
[data-theme="dark"] .theme-toggle .theme-icon-light { display: block; }
[data-theme="light"] .theme-toggle .theme-icon-dark { display: block; }
[data-theme="light"] .theme-toggle .theme-icon-light { display: none; }

/* ============================================================ этап 1: общие элементы экранов (T45) */
.btn-row.start { justify-content: flex-start; }
.modal.modal-wide { max-width: 640px; }
.fld-label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.inline-fld { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-3); }
.radio-group { display: flex; flex-direction: column; gap: 6px; }
.radio { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); }

.kv { display: grid; grid-template-columns: minmax(140px, 38%) 1fr; gap: 8px 16px; margin: 0; font-size: 13px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.grid-2 > * + .card, .grid-2 .card + .card { margin-top: 16px; }
.grid-2 > .card { margin-top: 0; }

.filters { display: flex; flex-direction: column; gap: 10px; }
.filters-main { display: flex; gap: 8px; }
.filters-main .input { flex: 1 1 auto; }
.filters-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters-row .input { width: auto; min-width: 140px; }
.cell-user { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pager-label { color: var(--ink-3); font-size: 12.5px; }

.tabs { display: flex; gap: 4px; overflow-x: auto; margin: 16px 0 12px; border-bottom: 1px solid var(--border); }
.tab {
  background: none; border: none; border-bottom: 2px solid transparent; padding: 9px 12px; margin-bottom: -1px;
  color: var(--ink-3); font-size: 13px; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-body > .card + .card { margin-top: 16px; }

.actions-card { margin-top: 12px; }
.action-groups { display: flex; flex-wrap: wrap; gap: 14px 28px; }
.action-group { display: flex; flex-direction: column; gap: 6px; }
.action-group-title { font-size: 12px; color: var(--ink-3); }

.notes { list-style: none; margin: 0; padding: 0; }
.notes li { padding: 12px 18px; border-bottom: 1px solid var(--border-faint); }
.notes li:last-child { border-bottom: none; }
.note-meta { font-size: 12px; margin-bottom: 4px; }
.note-text { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); font-size: 13.5px; }

@media (max-width: 1023px) {
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 759px) {
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
  .filters-row .input { flex: 1 1 140px; }
  .action-groups { flex-direction: column; }
}

/* ============================================================ этап 1: платежи, чаты, источники, тарифы (T46) */
.card-body p > .status { white-space: normal; align-items: baseline; }
.pause-control { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.code-box {
  margin: 0; padding: 10px 12px; max-height: 320px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
  background: var(--neutral-soft); border: 1px solid var(--border-faint); border-radius: var(--r-sm);
  font-family: var(--mono); font-size: 12px; color: var(--ink);
}
.pre-wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.plain-list { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.plain-list li + li { margin-top: 2px; }
.upload { display: flex; flex-direction: column; gap: 8px; }
.upload .input[type="file"] { width: auto; max-width: 100%; }
.import-result { font-size: 13px; }
.plan-chats { padding: 10px 0; border-top: 1px solid var(--border-faint); display: flex; flex-direction: column; gap: 8px; }
.plan-chats:first-of-type { border-top: none; }
.tree-cell { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tree-cell.depth-1 { padding-left: 18px; }
.tree-cell.depth-2 { padding-left: 36px; }
.tree-cell.depth-3 { padding-left: 54px; }
.tree-cell.depth-4 { padding-left: 72px; }
.qr-img { width: 220px; height: 220px; image-rendering: pixelated; }
.cost-form { margin-top: 12px; }
details summary { cursor: pointer; color: var(--accent); font-size: 12.5px; }

@media (max-width: 759px) {
  .tree-cell.depth-1, .tree-cell.depth-2, .tree-cell.depth-3, .tree-cell.depth-4 { padding-left: 0; }
  .qr-img { width: 180px; height: 180px; }
}

/* ============================================================ этап 1: тексты, документы, настройки, главная (T47) */
.metric .value.has-value { color: var(--ink); }
.metric-parts { margin-top: 10px; display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; }
.metric-part { display: flex; justify-content: space-between; gap: 10px; }
.tg-preview {
  white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.45; color: var(--ink);
  background: var(--neutral-soft); border: 1px solid var(--border-faint); border-radius: var(--r-md); padding: 12px 14px;
}
.tg-preview blockquote { margin: 4px 0; padding-left: 10px; border-left: 3px solid var(--accent-border); }
.tg-preview pre, .tg-preview code { font-family: var(--mono); font-size: 12.5px; }
.tg-preview .spoiler { background: var(--border-strong); color: transparent; border-radius: 3px; }
.tg-preview .spoiler:hover { color: inherit; background: none; }
.preview-box { min-height: 48px; }
.var-chips { gap: 6px; }
.var-chip { cursor: pointer; font-family: var(--mono); }
.var-chip:disabled { cursor: default; opacity: .6; }
.doc-preview { max-height: 52vh; overflow-y: auto; border: 1px solid var(--border-faint); border-radius: var(--r-md); padding: 4px 16px; margin-top: 10px; }
.md-preview { color: var(--ink); font-size: 13.5px; line-height: 1.55; }
.md-preview h2, .md-preview h3, .md-preview h4, .md-preview h5 { margin: 14px 0 6px; font-weight: 500; }
.md-preview p, .md-preview ul, .md-preview ol { margin: 8px 0; }
.md-preview ul, .md-preview ol { padding-left: 20px; }
.settings-list { display: flex; flex-direction: column; }
.setting-row {
  display: grid; grid-template-columns: minmax(200px, 1.2fr) minmax(0, 1fr) auto; gap: 8px 16px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border-faint);
}
.setting-row:last-child { border-bottom: none; }
.setting-label { font-size: 13.5px; color: var(--ink); }
.setting-key { font-size: 11.5px; }
.setting-value { font-size: 12.5px; color: var(--ink-2); }
.setting-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.alert-text { display: flex; flex-direction: column; gap: 2px; max-width: 520px; }

@media (max-width: 759px) {
  .setting-row { grid-template-columns: 1fr; }
  .setting-actions { justify-content: flex-start; }
}

/* ---- этап 2: сегменты, рассылки, кнопки шаблонов ---- */
.seg-group { border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px; margin-top: 8px; }
.seg-group.seg-root { border-color: var(--border-strong); }
.seg-children { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.seg-child { display: flex; align-items: flex-start; gap: 8px; }
.seg-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; flex: 1; }
.seg-value { display: inline-flex; }
.seg-params { display: flex; flex-direction: column; gap: 8px; }
.btn-grid-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.media-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.media-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 999px; font-size: 12px; }

/* ---- этап 4: графики (ECharts) — светлая подложка, тема SPA на них не распространяется (§C9) ---- */
.chart-surface {
  background: #ffffff; border: 1px solid #e8e6df; border-radius: var(--r-md);
  min-height: 240px; width: 100%;
}
.chart-panel .card-body { padding: 10px 10px 14px; }
.chart-note { font-size: 11.5px; color: var(--ink-3); padding: 8px 18px 0; }
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
@media (max-width: 1023px) {
  .charts-row { grid-template-columns: 1fr; }
}

/* ---- плитки со спарклайном и Δ (§8.6, T6b/T7a) ---- */
.metric .spark { margin-top: 8px; height: 28px; }
.sparkline { width: 100%; height: 28px; display: block; overflow: visible; }
.sparkline-line { fill: none; stroke: var(--accent); stroke-width: 1.6; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.sparkline-dot { fill: var(--accent); }
.delta { font-size: 12px; margin-top: 6px; display: inline-flex; align-items: center; gap: 3px; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--ink-3); }

/* ---- панель периода и сравнения главной ---- */
.compare-toggle { display: flex; align-items: center; gap: 6px; }
