/* ============================================================================
   YouCanTravel · сквозная аналитика — «Дизайн BoevLab в стиле Apple».
   Один акцент (синий), карточки с тонкой рамкой без теней, тень только у
   «парящего» (меню-остров, окна), радиусы по ролям: pill · 11 · 18 · 24 · 28.
   Движение — только как ответ на действие. Светлая и тёмная тема.
   ============================================================================ */

:root {
  color-scheme: light;
  --font: "SF Pro Text", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;

  --ground: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f5f5f7;
  --ink: #1d1d1f;
  --ink-soft: #515154;
  --ink-faint: #6e6e73;
  --hairline: #e0e0e0;
  --rule: #f0f0f0;
  --rule-strong: #e0e0e0;
  --fill: rgba(0, 0, 0, .05);
  --fill-hover: rgba(0, 0, 0, .09);
  --seg-on: #ffffff;
  --brand: #0066cc;
  --brand-strong: #0071e3;
  --brand-soft: rgba(0, 102, 204, .09);
  --on-brand: #ffffff;
  --good: #1d7f3a;
  --warn: #9a5b00;
  --bad: #c9231b;
  --good-bg: rgba(52, 199, 89, .13);
  --warn-bg: rgba(255, 159, 10, .15);
  --bad-bg: rgba(255, 59, 48, .11);
  --island: rgba(255, 255, 255, .72);
  --shadow-float: 0 14px 44px rgba(0, 0, 0, .10), 0 1px 3px rgba(0, 0, 0, .06);
  --shadow-pop: 0 30px 80px rgba(0, 0, 0, .28);

  /* палитра данных — цвет канала один на всей странице */
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #4a3aa7; --series-7: #008300; --series-8: #e34948;
  --series-muted: #c7c7cc;

  --r-sm: 8px; --r-md: 11px; --r-card: 18px; --r-island: 24px; --r-sheet: 28px;
  --gap: 12px;
  --nav-w: 244px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #000000; --surface: #1d1d1f; --surface-2: #272729;
    --ink: #f5f5f7; --ink-soft: #c7c7cc; --ink-faint: #98989d;
    --hairline: rgba(255, 255, 255, .14); --rule: rgba(255, 255, 255, .08); --rule-strong: rgba(255, 255, 255, .16);
    --fill: rgba(255, 255, 255, .08); --fill-hover: rgba(255, 255, 255, .14); --seg-on: #48484a;
    --brand: #0071e3; --brand-strong: #2997ff; --brand-soft: rgba(41, 151, 255, .16);
    --good: #30d158; --warn: #ff9f0a; --bad: #ff6961;
    --good-bg: rgba(48, 209, 88, .16); --warn-bg: rgba(255, 159, 10, .16); --bad-bg: rgba(255, 105, 97, .16);
    --island: rgba(29, 29, 31, .72);
    --shadow-float: 0 14px 44px rgba(0, 0, 0, .6);
    --series-1: #3f8ae6; --series-2: #f07a4b; --series-3: #2fc08a; --series-4: #f2b01e;
    --series-5: #ee8db2; --series-6: #8d80f0; --series-7: #37b24d; --series-8: #ef6767;
    --series-muted: #636366;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #000000; --surface: #1d1d1f; --surface-2: #272729;
  --ink: #f5f5f7; --ink-soft: #c7c7cc; --ink-faint: #98989d;
  --hairline: rgba(255, 255, 255, .14); --rule: rgba(255, 255, 255, .08); --rule-strong: rgba(255, 255, 255, .16);
  --fill: rgba(255, 255, 255, .08); --fill-hover: rgba(255, 255, 255, .14); --seg-on: #48484a;
  --brand: #0071e3; --brand-strong: #2997ff; --brand-soft: rgba(41, 151, 255, .16);
  --good: #30d158; --warn: #ff9f0a; --bad: #ff6961;
  --good-bg: rgba(48, 209, 88, .16); --warn-bg: rgba(255, 159, 10, .16); --bad-bg: rgba(255, 105, 97, .16);
  --island: rgba(29, 29, 31, .72);
  --shadow-float: 0 14px 44px rgba(0, 0, 0, .6);
  --series-1: #3f8ae6; --series-2: #f07a4b; --series-3: #2fc08a; --series-4: #f2b01e;
  --series-5: #ee8db2; --series-6: #8d80f0; --series-7: #37b24d; --series-8: #ef6767;
  --series-muted: #636366;
}

/* ---------- основа ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--ground); color: var(--ink);
  font-family: var(--font); font-size: 15px; line-height: 1.45; letter-spacing: -.011em;
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
}
h1, h2, h3 { margin: 0; font-weight: 600; color: var(--ink); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand-strong); outline-offset: 2px; border-radius: 6px; }
.ic { width: 18px; height: 18px; flex: none; }
.muted { color: var(--ink-faint); }
.note { margin: 10px 0 0; font-size: 13px; color: var(--ink-faint); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- каркас: меню-«остров» ---------- */
.app { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); gap: var(--gap); padding: var(--gap); min-height: 100vh; }
.app.nav-collapsed { --nav-w: 72px; }
.sidebar {
  position: sticky; top: var(--gap); height: calc(100vh - 2 * var(--gap));
  display: flex; flex-direction: column; gap: 14px; padding: 16px 12px;
  background: var(--island); -webkit-backdrop-filter: saturate(180%) blur(30px); backdrop-filter: saturate(180%) blur(30px);
  border: 1px solid var(--hairline); border-radius: var(--r-island); box-shadow: var(--shadow-float);
  overflow-y: auto; scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 6px; }
.brand__mark { width: 34px; height: 34px; border-radius: 9px; flex: none; }
.brand__txt { min-width: 0; }
.brand__name { font-size: 15px; font-weight: 600; letter-spacing: -.02em; }
.brand__sub { font-size: 12.5px; color: var(--ink-faint); }
.brand .brand__menu { display: none; margin-left: auto; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__item {
  display: flex; align-items: center; gap: 11px; width: 100%; min-height: 40px; padding: 0 12px;
  border: 0; border-radius: var(--r-md); background: none; cursor: pointer; text-align: left;
  font-size: 14.5px; font-weight: 500; color: var(--ink);
}
.nav__item .ic { color: var(--brand); }
.nav__item:hover { background: var(--fill); }
.nav__item.is-active { background: var(--brand); color: var(--on-brand); }
.nav__item.is-active .ic { color: var(--on-brand); }
.sidebar__foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.icon-btn {
  width: 36px; height: 36px; display: inline-grid; place-items: center; border: 0; border-radius: 50%;
  background: var(--fill); color: var(--ink-soft); cursor: pointer;
}
.icon-btn:hover { background: var(--fill-hover); }
.collapse-btn { align-self: flex-start; margin-left: 4px; }
.nav-collapsed .brand__txt, .nav-collapsed .nav__item span { display: none; }
.nav-collapsed .nav__item { justify-content: center; padding: 0; }
.nav-collapsed .brand { justify-content: center; padding: 2px 0 6px; }
.nav-collapsed .collapse-btn { align-self: center; margin: 0; }

/* ---------- основная область ---------- */
.main { min-width: 0; display: flex; flex-direction: column; gap: var(--gap); padding: 4px 6px 40px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 10px 4px 2px; }
.topbar h1 { font-size: 34px; letter-spacing: -.03em; line-height: 1.1; }
.topbar p { margin: 4px 0 0; color: var(--ink-faint); font-size: 14px; }
.badge {
  display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px; flex: none;
  border: 1px solid var(--hairline); border-radius: 999px; background: var(--surface);
  font-size: 13px; color: var(--ink-soft); cursor: pointer; white-space: nowrap;
}
.badge__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); }
.badge.on .badge__dot { background: var(--good); }
.badge.warn .badge__dot { background: var(--warn); }
.badge.off .badge__dot { background: var(--bad); }

/* ---------- строка периода: одна на весь кабинет ---------- */
.period {
  position: sticky; top: var(--gap); z-index: 20;
  background: var(--island); -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
  border: 1px solid var(--hairline); border-radius: var(--r-card); padding: 8px;
}
.period__row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.period__right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--fill); }
.seg button {
  height: 30px; padding: 0 13px; border: 0; border-radius: 999px; background: none; cursor: pointer;
  font-size: 13px; font-weight: 500; color: var(--ink-soft); white-space: nowrap;
}
.seg button:hover { color: var(--ink); }
.seg button.is-active { background: var(--seg-on); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .04); }
.pop { position: relative; }
.pop__btn {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px 0 14px;
  border: 1px solid var(--hairline); border-radius: 999px; background: var(--surface); cursor: pointer;
  font-size: 13px; font-weight: 500; color: var(--ink); white-space: nowrap;
}
.pop__btn .ic { width: 14px; height: 14px; color: var(--ink-faint); }
.pop__btn:hover { background: var(--surface-2); }
.pop__btn.is-set { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.pop__btn.is-set .ic { color: var(--on-brand); }
.pop__panel {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 40; min-width: 260px; padding: 14px;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-card); box-shadow: var(--shadow-float);
  display: flex; flex-direction: column; gap: 12px;
}
.pop__panel--right { left: auto; right: 0; }
.pop__row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.pop__row label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-soft); }
input[type="date"], input[type="text"], input[type="password"], select {
  height: 36px; padding: 0 10px; border: 1px solid var(--hairline); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 14px;
}
input:focus, select:focus { outline: 2px solid var(--brand-strong); outline-offset: 1px; }
.checklist { display: flex; flex-direction: column; gap: 2px; min-width: 220px; }
.checklist label { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--r-sm); cursor: pointer; font-size: 14px; }
.checklist label:hover { background: var(--fill); }
.checklist input { width: 16px; height: 16px; accent-color: var(--brand); }
.rfilter__badge {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--brand); color: var(--on-brand); font-size: 11px; font-weight: 600;
}
.rfilter__panel { width: min(640px, calc(100vw - 32px)); max-height: 70vh; overflow: auto; }
.custom-filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.custom-filters__field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-soft); }
.custom-filters__field select[multiple] { height: auto; min-height: 120px; padding: 4px; }
.custom-filters__field option { padding: 4px 6px; border-radius: 6px; }
.rfilter__actions { display: flex; gap: 8px; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 16px;
  border: 0; border-radius: 999px; background: var(--brand); color: var(--on-brand); cursor: pointer;
  font-size: 14px; font-weight: 500; white-space: nowrap; transition: transform .1s ease, background .15s ease;
}
.btn:hover { background: var(--brand-strong); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn--ghost { background: var(--surface); color: var(--brand); border: 1px solid var(--hairline); }
.btn--ghost:hover { background: var(--surface-2); }
.btn[disabled] { opacity: .5; cursor: default; }

/* ---------- состояния загрузки ---------- */
.loader { display: flex; align-items: center; gap: 12px; padding: 40px 8px; color: var(--ink-soft); font-size: 15px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--fill-hover); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.errbox { padding: 14px 16px; border-radius: var(--r-md); background: var(--bad-bg); color: var(--bad); font-size: 14px; }
.notes { display: flex; flex-direction: column; gap: 8px; }
.notes:empty { display: none; }
.notes p { margin: 0; padding: 10px 14px; border-radius: var(--r-md); background: var(--warn-bg); color: var(--ink); font-size: 13.5px; }

/* ---------- карточки и сетки ---------- */
.pane { display: flex; flex-direction: column; gap: var(--gap); }
.card { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-card); padding: 20px 22px; min-width: 0; }
.card__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card__head h2 { font-size: 17px; letter-spacing: -.022em; }
.card__head span { font-size: 13px; color: var(--ink-faint); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: var(--gap); }
.grid-2--even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.chart-box { position: relative; height: 300px; }
.chart-box--sm { height: 260px; }
.chart-empty { padding: 40px 0; text-align: center; color: var(--ink-faint); font-size: 14px; }

/* ---------- плитки KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: var(--gap); }
@media (min-width: 1180px) { .kpi-grid:has(> :nth-child(6):last-child) { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.kpi {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-card);
  padding: 16px 16px 12px; display: flex; flex-direction: column; min-width: 0;
}
.kpi--link { cursor: pointer; }
.kpi--link:hover { border-color: var(--brand-strong); }
.kpi__label { font-size: 13px; font-weight: 500; color: var(--ink-soft); min-height: 19px; }
.kpi__value { margin-top: 4px; font-size: 28px; font-weight: 600; letter-spacing: -.03em; line-height: 1.15; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi__delta { margin-top: 6px; font-size: 12.5px; color: var(--ink-faint); min-height: 18px; }
.kpi__delta b { display: inline-block; padding: 1px 7px; border-radius: 999px; font-weight: 600; margin-right: 2px; }
.kpi__delta.up b { background: var(--good-bg); color: var(--good); }
.kpi__delta.down b { background: var(--bad-bg); color: var(--bad); }
.kpi__delta.flat b { background: var(--fill); color: var(--ink-soft); }
.kpi__ch { margin-top: 10px; }
.kpi__ch-svg { display: block; width: 100%; height: 46px; overflow: visible; }
.kpi__ch-a { fill: var(--good-bg); stroke: none; }
.kpi__ch-l { fill: none; stroke: var(--good); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.kpi__ch-d { fill: var(--good); }
.kpi__ch-svg.down .kpi__ch-a { fill: var(--bad-bg); }
.kpi__ch-svg.down .kpi__ch-l { stroke: var(--bad); }
.kpi__ch-svg.down .kpi__ch-d { fill: var(--bad); }
.kpi__ch-prev { fill: none; stroke: var(--ink-faint); stroke-width: 1.2; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; opacity: .8; }
.kpi__ch-ends { display: flex; justify-content: space-between; margin-top: 3px; font-size: 11px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }

/* ---------- воронка ---------- */
.fnl { display: flex; flex-direction: column; }
.fnl-row { display: block; width: 100%; padding: 10px 12px; margin: 0 -12px; border: 0; border-radius: var(--r-md); background: none; text-align: left; width: calc(100% + 24px); }
.fnl-row[data-list-mode] { cursor: pointer; }
.fnl-row[data-list-mode]:hover { background: var(--surface-2); }
.fnl-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.fnl-name { font-size: 14px; font-weight: 500; }
.fnl-count { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.fnl-track { margin-top: 6px; height: 10px; border-radius: 999px; background: var(--fill); overflow: hidden; }
.fnl-fill { display: block; height: 100%; border-radius: 999px; background: var(--series-1); }
.fnl-row.is-sale .fnl-fill { background: var(--good); }
.fnl-row.is-ad .fnl-fill { background: var(--series-muted); }
.fnl-meta { display: flex; justify-content: space-between; margin-top: 4px; font-size: 12px; color: var(--ink-faint); }
.fnl-step { padding: 2px 0 2px 2px; font-size: 12px; color: var(--ink-faint); }
.fnl-step b { color: var(--ink-soft); font-weight: 600; }
.fnl-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--rule); font-size: 13px; color: var(--ink-soft); }
.fnl-foot b { color: var(--ink); }

/* ---------- таблицы ---------- */
.tbl-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 10px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--rule); }
.tbl thead th { font-size: 12.5px; font-weight: 500; color: var(--ink-faint); background: var(--surface); position: sticky; top: 0; }
.tbl th:first-child, .tbl td:first-child { text-align: left; padding-left: 0; }
.tbl td:first-child { max-width: 300px; overflow: hidden; text-overflow: ellipsis; }
.tbl th:last-child, .tbl td:last-child { padding-right: 0; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl tfoot td { font-weight: 600; border-bottom: 0; border-top: 1px solid var(--rule-strong); }
.tbl .l { text-align: left; }
.tbl .dim { color: var(--ink-faint); }
.tbl .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: 0; }
.cell-link { color: var(--brand); cursor: pointer; border-radius: 6px; padding: 2px 4px; margin: -2px -4px; }
.cell-link:hover { background: var(--brand-soft); }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--fill); color: var(--ink-soft); }
.pill--good { background: var(--good-bg); color: var(--good); }
.pill--warn { background: var(--warn-bg); color: var(--warn); }
.pill--bad { background: var(--bad-bg); color: var(--bad); }
.tbl-tools { display: flex; justify-content: flex-end; margin-top: 10px; }

/* ---------- окна-листы ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; }
.modal__bg { position: absolute; inset: 0; background: rgba(0, 0, 0, .32); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.modal__box {
  position: relative; width: min(760px, 100%); max-height: calc(100vh - 48px); overflow: auto;
  background: var(--surface); border-radius: var(--r-sheet); box-shadow: var(--shadow-pop); padding: 28px 28px 24px;
}
.modal__box--wide { width: min(1180px, 100%); }
.modal__box--settings { width: min(860px, 100%); padding: 0; overflow: hidden; display: flex; }
.modal__x {
  position: absolute; top: 16px; right: 16px; z-index: 2; width: 32px; height: 32px; border: 0; border-radius: 50%;
  background: var(--fill); color: var(--ink-soft); font-size: 20px; line-height: 1; cursor: pointer;
}
.modal__x:hover { background: var(--fill-hover); }
.list-head h2 { font-size: 22px; letter-spacing: -.025em; padding-right: 40px; }
.list-head p { margin: 6px 0 16px; color: var(--ink-soft); font-size: 14px; }
.list-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.list-tools input { flex: 1; min-width: 180px; }
.modal .tbl-wrap { margin: 0; padding: 0; }
.modal .tbl td:first-child { max-width: 280px; }
.modal .tbl td.l { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }

.settings { display: flex; width: 100%; min-height: 460px; max-height: calc(100vh - 48px); }
.settings__nav { flex: none; width: 210px; padding: 24px 12px; background: var(--surface-2); display: flex; flex-direction: column; gap: 2px; }
.settings__nav button { height: 38px; padding: 0 12px; border: 0; border-radius: var(--r-md); background: none; text-align: left; cursor: pointer; font-size: 14px; font-weight: 500; }
.settings__nav button:hover { background: var(--fill); }
.settings__nav button.is-active { background: var(--brand); color: var(--on-brand); }
.settings__body { flex: 1; min-width: 0; padding: 28px 28px 24px; overflow: auto; }
.settings__body h3 { font-size: 20px; letter-spacing: -.022em; margin-bottom: 14px; padding-right: 40px; }
.settings__body h4 { margin: 20px 0 8px; font-size: 15px; font-weight: 600; }
.srow { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--rule); font-size: 14px; }
.srow span:first-child { color: var(--ink-soft); }
.srow span:last-child { text-align: right; }
.copy-row { display: flex; gap: 8px; margin: 8px 0; }
.copy-row input { flex: 1; min-width: 0; font-size: 13px; }
.steps { margin: 8px 0 0; padding-left: 20px; font-size: 14px; color: var(--ink-soft); }
.steps li { margin: 4px 0; }
.connect-card h2 { font-size: 17px; margin-bottom: 6px; }
.connect-card p { margin: 0 0 12px; color: var(--ink-soft); font-size: 14px; }

/* ---------- широкие экраны: плотнее строка периода ---------- */
@media (max-width: 1400px) {
  .seg button { padding: 0 10px; }
  .pop__btn { padding: 0 10px 0 12px; }
}
@media (max-width: 1020px) {
  .grid-2, .grid-2--even { grid-template-columns: minmax(0, 1fr); }
  .period__right { margin-left: 0; }
}

/* ---------- телефон ---------- */
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); padding: 8px; padding-top: max(8px, env(safe-area-inset-top)); }
  .sidebar { position: sticky; top: 8px; z-index: 50; height: auto; padding: 10px 12px; gap: 8px; }
  .brand { padding: 0; }
  .brand .brand__menu { display: inline-grid; }
  .nav, .sidebar__foot { display: none; }
  .sidebar.is-open .nav, .sidebar.is-open .sidebar__foot { display: flex; }
  .nav__item { min-height: 44px; }
  .collapse-btn { display: none; }
  .main { padding: 0 2px 32px; }
  .topbar { padding: 6px 2px 0; align-items: flex-start; flex-direction: column; gap: 8px; }
  .topbar h1 { font-size: 28px; }
  .period { position: static; }
  .period__presets { width: 100%; overflow-x: auto; scrollbar-width: none; }
  .period__presets::-webkit-scrollbar { display: none; }
  .period__right { width: 100%; }
  .pop__panel { position: fixed; left: 12px !important; right: 12px !important; top: auto; bottom: 12px; min-width: 0; }
  .card { padding: 16px; }
  .tbl-wrap { margin: 0 -16px; padding: 0 16px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 12px 12px 10px; }
  .kpi__value { font-size: 22px; }
  input[type="date"], input[type="text"], input[type="password"], select { font-size: 16px; }
  .modal { padding: 0; place-items: end stretch; }
  .modal__box { width: 100%; max-height: 92vh; border-radius: var(--r-sheet) var(--r-sheet) 0 0; padding: 22px 16px calc(16px + env(safe-area-inset-bottom)); }
  .modal__box--settings { flex-direction: column; padding: 0; }
  .settings { flex-direction: column; max-height: 92vh; }
  .settings__nav { width: auto; flex-direction: row; overflow-x: auto; padding: 16px 12px 8px; }
  .settings__nav button { white-space: nowrap; }
  .settings__body { padding: 16px; }
  .chart-box { height: 240px; }
}
