/* Локальная аналитика — общие стили */
:root {
  --bg: #f2f6fb;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #dbe5f2;
  --accent: #2563eb;
  --accent-soft: #eaf2ff;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  --success-text: #065f46;
  --warning-bg: #fff7ed;
  --warning-border: #fed7aa;
  --warning-text: #9a3412;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.07);
  --shadow-soft: 0 4px 14px rgba(15, 23, 42, 0.05);
  --focus: 0 0 0 3px rgba(37, 99, 235, 0.18);
  --layout-max-width: 1366px;
  font-family: system-ui, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #111a2c;
  --surface-soft: #0f172a;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: #23324a;
  --accent: #60a5fa;
  --accent-soft: rgba(96, 165, 250, 0.16);
  --success-bg: rgba(16, 185, 129, 0.14);
  --success-border: rgba(16, 185, 129, 0.35);
  --success-text: #6ee7b7;
  --warning-bg: rgba(245, 158, 11, 0.16);
  --warning-border: rgba(245, 158, 11, 0.35);
  --warning-text: #fcd34d;
  --shadow: 0 12px 28px rgba(2, 6, 23, 0.45);
  --shadow-soft: 0 6px 18px rgba(2, 6, 23, 0.35);
  --focus: 0 0 0 3px rgba(96, 165, 250, 0.25);
}

* { box-sizing: border-box; }

html {
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: scroll;
  background: radial-gradient(1200px 600px at 10% -15%, rgba(37, 99, 235, 0.07), transparent 60%), var(--bg);
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Шапка */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.site-header__inner {
  max-width: var(--layout-max-width);
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.site-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}
.site-brand img {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}
.site-brand__text h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.2px;
}
.site-brand__text .sub {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}
.site-freshness {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: right;
  max-width: 280px;
}
.site-freshness strong {
  color: var(--text);
  font-weight: 600;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}
.theme-toggle:hover {
  border-color: var(--accent);
}
.theme-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
.theme-toggle__icon {
  line-height: 1;
  font-size: 0.95rem;
}
.theme-toggle__text {
  font-weight: 600;
}

/* Меню */
.site-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.site-nav__inner {
  max-width: var(--layout-max-width);
  margin: 0 auto;
  padding: 0 1rem 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  align-items: center;
}
.site-nav a {
  display: inline-block;
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  font-size: 0.9rem;
  color: var(--text);
  text-decoration: none;
}
.site-nav a:hover {
  background: var(--surface-soft);
  text-decoration: none;
}
.site-nav a.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* Мега-меню (разделы) */
.nav-mega {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.15rem 0.35rem;
  width: 100%;
}
.nav-mega__single {
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  font-size: 0.9rem;
  color: var(--text);
  text-decoration: none;
  align-self: center;
}
.nav-mega__single:hover {
  background: var(--bg);
  text-decoration: none;
}
.nav-mega__single.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.nav-mega__item {
  position: relative;
  align-self: stretch;
}
.nav-mega__btn {
  display: inline-block;
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  font-size: 0.9rem;
  color: var(--text);
  text-decoration: none;
  cursor: default;
}
a.nav-mega__btn {
  cursor: pointer;
}
.nav-mega__btn:hover,
.nav-mega__item:hover > .nav-mega__btn {
  background: var(--bg);
  text-decoration: none;
}
.nav-mega__btn.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.nav-mega__panel {
  display: none;
  position: absolute;
  left: 0;
  top: 100%;
  min-width: 240px;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 0.35rem 0;
  margin-top: 0;
}
.nav-mega__item:hover .nav-mega__panel,
.nav-mega__item:focus-within .nav-mega__panel {
  display: block;
}
.nav-mega__panel a {
  display: block;
  padding: 0.4rem 0.85rem;
  font-size: 0.88rem;
  color: var(--text);
  border-radius: 0;
}
.nav-mega__panel a:hover {
  background: var(--surface-soft);
}
.nav-mega__panel a.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.stub-links {
  margin: 0 1rem 1rem;
  padding-left: 1.25rem;
  font-size: 0.92rem;
}
.stub-links li { margin-bottom: 0.35rem; }

/* Google-блок на импорте */
.google-exports {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}
.google-exports__note {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
  line-height: 1.45;
}
.google-exports .table-card h3 { margin-top: 0; }

/* Контент */
.site-main {
  flex: 1;
  max-width: var(--layout-max-width);
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 2rem;
}

.page-head {
  margin-bottom: 1.25rem;
}
.page-head h2 {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 700;
}
.page-head .lead {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.alert {
  padding: 0.9rem 1rem;
  border-radius: var(--radius);
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: var(--warning-text);
  margin-bottom: 1rem;
  line-height: 1.45;
}

/* Общие формы */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem 1rem;
}

.form-row {
  margin-bottom: 1rem;
}

.form-row label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.form-row input[type="text"],
.form-row input[type="number"],
.form-row input[type="date"],
.form-row input[type="email"],
.form-row input[type="password"],
.form-row select,
.form-row textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
}

.form-row textarea {
  min-height: 120px;
  resize: vertical;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.form-actions button,
.form-actions .btn {
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  box-shadow: var(--shadow-soft);
}

.form-actions button:hover,
.form-actions .btn:hover {
  filter: brightness(1.05);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.5rem 1rem;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text);
}

/* KPI */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.kpi-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.kpi-card .label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.kpi-card .value {
  font-size: 1.35rem;
  font-weight: 700;
}

/* Таблицы */
.table-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border);
  overflow-x: auto;
  margin-bottom: 1.25rem;
}
.table-card h3 {
  margin: 0;
  padding: 0.65rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}
.table-card table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.table-card th,
.table-card td {
  padding: 0.65rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.45;
}
.table-card th {
  background: var(--surface-soft);
  font-weight: 600;
  color: var(--muted);
  white-space: normal;
}
.table-card tbody tr:hover {
  background: rgba(37, 99, 235, 0.04);
}
[data-theme="dark"] .table-card tbody tr:hover {
  background: rgba(96, 165, 250, 0.08);
}
.table-card tr:last-child td { border-bottom: none; }
.table-card .num { text-align: right; }
.table-card td {
  word-break: break-word;
}
.table-card .num {
  white-space: nowrap;
}
.table-card .empty {
  padding: 0.75rem 1rem;
  color: var(--muted);
}
.table-card__body {
  padding: 0.9rem 1rem 1rem;
}
.table-card__body .lead {
  margin: 0 0 0.8rem;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
}
.table-card__meta {
  margin-top: 0.65rem;
  color: var(--muted);
  font-size: 0.86rem;
}
.table-card__list {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
}
.table-card__list li {
  margin-bottom: 0.25rem;
}
.th-col-70 { width: 70px; }
.th-col-140 { width: 140px; }
.th-col-240 { width: 240px; }
.th-col-320 { width: 320px; }
.stacked-table-panels {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.site-main > div[style*="repeat(auto-fit,minmax(360px,1fr))"] {
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: 1rem !important;
}

.kaspi-progress {
  margin: 0.5rem 0 1rem;
}
.kaspi-progress__head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}
.kaspi-progress__bar {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  overflow: hidden;
}
.kaspi-progress__bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
}
.kaspi-progress__meta {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
}
.inline-form {
  display: inline;
}
.link-danger-btn {
  display: inline-block;
  padding: 0;
  border: 0;
  background: none;
  color: #b91c1c;
  cursor: pointer;
  font-size: 0.9rem;
}
[data-theme="dark"] .link-danger-btn {
  color: #f87171;
}

/* Фильтр периода */
.period-filter {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
}
.period-filter label {
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.period-filter input[type="date"],
.period-filter input[type="text"],
.period-filter select {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  min-width: 10rem;
}
.period-filter button {
  padding: 0.45rem 0.9rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
}
.period-filter button:hover { filter: brightness(1.05); }
.period-filter .reset {
  font-size: 0.9rem;
  color: var(--muted);
}

/* Карта */
#sales-map {
  height: 460px;
  width: 100%;
  border-radius: var(--radius);
  background: #e2e8f0;
  border: 1px solid var(--border);
}
.map-note {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

.map-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  margin-bottom: 0.75rem;
  align-items: center;
}
.map-presets > span {
  font-size: 0.75rem;
  color: var(--muted);
  margin-right: 0.25rem;
}
.map-presets a {
  font-size: 0.8rem;
  padding: 0.25rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.map-presets a:hover { background: #f8fafc; text-decoration: none; }
[data-theme="dark"] .map-presets a:hover { background: var(--surface-soft); }
.map-presets a.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.map-filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow-soft);
}
.map-filters__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem 0.75rem;
  align-items: end;
}
.map-filters label {
  font-size: 0.72rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.map-filters input,
.map-filters select {
  padding: 0.35rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  width: 100%;
}
.map-filters__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.65rem;
  align-items: center;
}
.map-filters__actions button {
  padding: 0.4rem 0.75rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
}
.map-filters__actions a {
  font-size: 0.85rem;
  color: var(--muted);
}

.map-status {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 0.5rem;
  line-height: 1.45;
}
.map-status strong { color: var(--text); font-weight: 600; }
.map-status .warn { color: #b45309; }

/* Подвал */
.site-footer {
  margin-top: auto;
  padding: 1rem 1.25rem;
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
  text-align: center;
}

.leaflet-container { font-family: inherit; }

/* Отчёты: фильтры, режимы, графики */
.report-filters {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border);
}
.report-filters__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.5rem 0.75rem;
  align-items: end;
}
.report-filters label {
  font-size: 0.72rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.report-filters input,
.report-filters select {
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  width: 100%;
}
.report-filters__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.65rem;
  align-items: center;
}
.report-filters__actions button {
  padding: 0.4rem 0.75rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
}
.report-filters__actions .reset {
  font-size: 0.85rem;
  color: var(--muted);
}
.strategy-kpi-settings-panel {
  margin-top: 0.5rem;
}
.strategy-kpi-settings-grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.35rem 0.55rem;
}
.strategy-kpi-setting-field {
  font-size: 0.68rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.strategy-kpi-setting-field input {
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  width: 100%;
  box-sizing: border-box;
}
.strategy-kpi-settings-form .empty {
  grid-column: 1 / -1;
  padding: 0.5rem 0;
  color: var(--muted);
}

.view-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}
.view-tabs a {
  font-size: 0.85rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.view-tabs a:hover { background: #f8fafc; text-decoration: none; }
[data-theme="dark"] .view-tabs a:hover { background: var(--surface-soft); }
.view-tabs a.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.report-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  align-items: center;
}
.report-toolbar__export {
  font-size: 0.85rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  text-decoration: none;
}
.report-toolbar__export:hover { background: #f8fafc; text-decoration: none; }
[data-theme="dark"] .report-toolbar__export:hover { background: var(--surface-soft); }

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.chart-card h3 {
  margin: 0;
  padding: 0.65rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}
.chart-wrap {
  padding: 0.75rem 1rem 1rem;
  height: 240px;
  position: relative;
}
.chart-wrap--tall { height: 360px; }

.product-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}
.dashboard-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}
.dashboard-card--wide {
  grid-column: 1 / -1;
}
.dashboard-card h4 {
  margin: 0;
  padding: 0.8rem 1rem 0.65rem;
  font-size: 0.98rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}
.dashboard-card__body {
  padding: 0.9rem 1rem 1rem;
}
.product-scatter__hint {
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}
.product-scatter-board {
  position: relative;
  min-height: 640px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(to top, rgba(148, 163, 184, 0.1) 1px, transparent 1px) 0 0 / 100% 25%,
    linear-gradient(to right, rgba(148, 163, 184, 0.1) 1px, transparent 1px) 0 0 / 25% 100%,
    linear-gradient(180deg, rgba(248, 250, 252, 0.95), rgba(241, 245, 249, 0.88));
  overflow: hidden;
}
.product-scatter-board__divider {
  position: absolute;
  background: rgba(100, 116, 139, 0.42);
  z-index: 1;
}
.product-scatter-board__divider--v {
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
}
.product-scatter-board__divider--h {
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
}
.product-scatter-board__corner {
  display: none;
}
.product-scatter-board__label {
  position: absolute;
  z-index: 3;
  font-size: 0.74rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  padding: 0.15rem 0.35rem;
  border-radius: 999px;
}
[data-theme="dark"] .product-scatter-board__label {
  background: rgba(15, 23, 42, 0.55);
}
.product-scatter-board__label--x-left { left: 0.9rem; bottom: 0.35rem; }
.product-scatter-board__label--x-right { right: 0.9rem; bottom: 0.35rem; }
.product-scatter-board__label--y-bottom { left: 0.85rem; bottom: 2.65rem; transform: rotate(-90deg); transform-origin: left bottom; }
.product-scatter-board__label--y-top { left: 0.85rem; top: 2.4rem; transform: rotate(-90deg); transform-origin: left top; }
.dashboard-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  margin-bottom: 0.8rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.dashboard-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.dashboard-legend__dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 999px;
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.45);
}
.product-scatter {
  position: relative;
  min-height: 420px;
  padding: 1rem 1rem 2.2rem 2.4rem;
  border-radius: var(--radius-sm);
  background:
    linear-gradient(to top, rgba(148, 163, 184, 0.12) 1px, transparent 1px) 0 0 / 100% 25%,
    linear-gradient(to right, rgba(148, 163, 184, 0.12) 1px, transparent 1px) 0 0 / 25% 100%,
    linear-gradient(180deg, rgba(248, 250, 252, 0.9), rgba(241, 245, 249, 0.85));
  border: 1px solid rgba(148, 163, 184, 0.25);
  overflow: hidden;
}
[data-theme="dark"] .product-scatter {
  background:
    linear-gradient(to top, rgba(148, 163, 184, 0.1) 1px, transparent 1px) 0 0 / 100% 25%,
    linear-gradient(to right, rgba(148, 163, 184, 0.1) 1px, transparent 1px) 0 0 / 25% 100%,
    linear-gradient(180deg, rgba(15, 23, 42, 0.94), rgba(30, 41, 59, 0.9));
}
.product-scatter__axis {
  position: absolute;
  background: rgba(100, 116, 139, 0.45);
}
.product-scatter__axis--x {
  left: 2.4rem;
  right: 1rem;
  bottom: 2.2rem;
  height: 1px;
}
.product-scatter__axis--y {
  left: 2.4rem;
  top: 1rem;
  bottom: 2.2rem;
  width: 1px;
}
.product-scatter__median-x,
.product-scatter__median-y {
  position: absolute;
  background: rgba(30, 41, 59, 0.28);
  z-index: 1;
}
.product-scatter__median-x {
  top: 1rem;
  bottom: 2.2rem;
  width: 1px;
}
.product-scatter__median-y {
  left: 2.4rem;
  right: 1rem;
  height: 1px;
}
[data-theme="dark"] .product-scatter__median-x,
[data-theme="dark"] .product-scatter__median-y {
  background: rgba(226, 232, 240, 0.24);
}
.product-scatter__point {
  position: absolute;
  transform: translate(-50%, 50%);
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.82);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.16);
  opacity: 0.88;
  z-index: 2;
}
.product-scatter__point:hover {
  opacity: 1;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.24);
  transform: translate(-50%, 50%) scale(1.08);
}
.product-scatter__labels {
  position: absolute;
  left: 2.4rem;
  right: 1rem;
  bottom: 0.45rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.product-scatter__labels--y {
  left: 0.4rem;
  top: 1rem;
  bottom: 2.2rem;
  right: auto;
  width: 1.6rem;
  display: flex;
  flex-direction: column-reverse;
  justify-content: space-between;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}
.abc-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}
.abc-grid__cell {
  min-height: 82px;
  padding: 0.75rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.7), rgba(248,250,252,0.95));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.35rem;
}
[data-theme="dark"] .abc-grid__cell {
  background: linear-gradient(180deg, rgba(30,41,59,0.88), rgba(15,23,42,0.96));
}
.abc-grid__cell strong {
  font-size: 0.95rem;
}
.abc-grid__cell span {
  font-size: 0.82rem;
  color: var(--muted);
}
.mini-bars {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.mini-bars__row {
  display: grid;
  grid-template-columns: minmax(0, 130px) minmax(0, 1fr) auto;
  gap: 0.7rem;
  align-items: center;
}
.mini-bars__label {
  font-size: 0.82rem;
  line-height: 1.35;
  word-break: break-word;
}
.mini-bars__bar {
  height: 0.7rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
  overflow: hidden;
}
.mini-bars__bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #16a34a);
}
.mini-bars__value {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}
@media (max-width: 900px) {
  .product-scatter {
    min-height: 320px;
    padding: 0.85rem 0.75rem 2rem 2rem;
  }
  .product-scatter__axis--x,
  .product-scatter__labels {
    left: 2rem;
  }
  .product-scatter__axis--y,
  .product-scatter__labels--y,
  .product-scatter__median-y {
    left: 2rem;
  }
}
@media (max-width: 640px) {
  .mini-bars__row {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }
  .mini-bars__value {
    white-space: normal;
  }
}

/* Маркетинг — сводка CSV */
.marketing-source-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.85rem 1rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.88rem;
  line-height: 1.5;
}
.marketing-source-banner h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  font-weight: 600;
}
.marketing-source-banner dl {
  margin: 0.5rem 0 0;
  display: grid;
  grid-template-columns: minmax(0, 220px) 1fr;
  gap: 0.35rem 1rem;
  align-items: baseline;
}
.marketing-source-banner dt {
  color: var(--muted);
  font-size: 0.82rem;
}
.marketing-source-banner dd {
  margin: 0;
  font-size: 0.86rem;
}
.marketing-source-banner__filter {
  margin: 0.65rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.marketing-block {
  margin-bottom: 2rem;
}
.marketing-block__title {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  font-weight: 600;
}
.marketing-block__range {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  color: var(--muted);
}
.table-card--scroll {
  max-height: 480px;
  overflow: auto;
}
.table-card--scroll thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}
.strategy-status-card {
  max-height: none;
  overflow: visible;
}
.strategy-status-table {
  min-width: 1100px;
}
.strategy-status-table th {
  white-space: nowrap;
}
.strategy-status-table td {
  vertical-align: middle;
}
.strategy-status-table input[type="text"],
.strategy-status-table select {
  width: 100%;
  min-width: 140px;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.88rem;
}
.strategy-status-table select {
  min-width: 120px;
}
.strategy-status-table input[type="text"]:focus,
.strategy-status-table select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus);
}
.status-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
}
.status-toggle label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.88rem;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.status-toggle input[type="radio"] {
  accent-color: var(--accent);
}
.channel-split-card {
  /* table-card--scroll keeps the scrolling container */
}
.channel-split-table {
  min-width: 1420px;
  font-size: 0.82rem;
}
.channel-split-table th {
  white-space: nowrap;
}
.channel-split-table td {
  vertical-align: top;
}
.channel-split-table__name {
  min-width: 240px;
  white-space: normal;
  line-height: 1.35;
}
.sku-base-card {
  min-height: 0;
}
.sku-base-table {
  min-width: 980px;
  font-size: 0.88rem;
}
.sku-base-table th {
  white-space: nowrap;
}
.sku-base-table td {
  vertical-align: top;
}
.sku-base-table__name {
  min-width: 260px;
  white-space: normal;
  line-height: 1.35;
}
.profit-analysis-card {
  min-height: 0;
}
.profit-analysis-table {
  min-width: 2200px;
  font-size: 0.8rem;
  table-layout: fixed;
}
.profit-analysis-table th {
  white-space: nowrap;
}
.profit-analysis-table td {
  vertical-align: top;
}
.profit-analysis-table__name {
  width: 250px;
  white-space: normal;
  line-height: 1.35;
}
.profitability-products-page .profit-analysis-table th:nth-child(1),
.profitability-products-page .profit-analysis-table td:nth-child(1) {
  width: 250px;
}
.profitability-products-page .profit-analysis-table th:nth-child(2),
.profitability-products-page .profit-analysis-table td:nth-child(2) {
  width: 150px;
}
.profitability-products-page .profit-analysis-table th:nth-child(3),
.profitability-products-page .profit-analysis-table td:nth-child(3),
.profitability-products-page .profit-analysis-table th:nth-child(4),
.profitability-products-page .profit-analysis-table td:nth-child(4),
.profitability-products-page .profit-analysis-table th:nth-child(5),
.profitability-products-page .profit-analysis-table td:nth-child(5),
.profitability-products-page .profit-analysis-table th:nth-child(6),
.profitability-products-page .profit-analysis-table td:nth-child(6) {
  width: 110px;
}
.profitability-products-page .profit-analysis-table th:nth-child(7),
.profitability-products-page .profit-analysis-table td:nth-child(7),
.profitability-products-page .profit-analysis-table th:nth-child(8),
.profitability-products-page .profit-analysis-table td:nth-child(8),
.profitability-products-page .profit-analysis-table th:nth-child(9),
.profitability-products-page .profit-analysis-table td:nth-child(9),
.profitability-products-page .profit-analysis-table th:nth-child(10),
.profitability-products-page .profit-analysis-table td:nth-child(10) {
  width: 90px;
}
.profitability-products-page .profit-analysis-table th:nth-child(11),
.profitability-products-page .profit-analysis-table td:nth-child(11),
.profitability-products-page .profit-analysis-table th:nth-child(12),
.profitability-products-page .profit-analysis-table td:nth-child(12),
.profitability-products-page .profit-analysis-table th:nth-child(13),
.profitability-products-page .profit-analysis-table td:nth-child(13),
.profitability-products-page .profit-analysis-table th:nth-child(14),
.profitability-products-page .profit-analysis-table td:nth-child(14) {
  width: 85px;
}
.profitability-products-page .profit-analysis-table th:nth-child(15),
.profitability-products-page .profit-analysis-table td:nth-child(15) {
  width: 120px;
}
.profitability-products-page .profit-analysis-table th:nth-child(16),
.profitability-products-page .profit-analysis-table td:nth-child(16) {
  width: 150px;
}
.profitability-products-page .profit-analysis-table th:nth-child(17),
.profitability-products-page .profit-analysis-table td:nth-child(17) {
  width: 100px;
}
.profitability-products-page .profit-analysis-table th:nth-child(18),
.profitability-products-page .profit-analysis-table td:nth-child(18) {
  width: 110px;
}
.profitability-products-page .profit-analysis-table th:nth-child(19),
.profitability-products-page .profit-analysis-table td:nth-child(19) {
  width: 130px;
}
.profitability-products-page .profit-analysis-table th:nth-child(20),
.profitability-products-page .profit-analysis-table td:nth-child(20) {
  width: 280px;
}
.profitability-products-page .profitability-traffic-table {
  min-width: 1800px;
  font-size: 0.84rem;
  table-layout: fixed;
}
.profitability-products-page .profitability-traffic-table th,
.profitability-products-page .profitability-traffic-table td {
  white-space: nowrap;
}
.profitability-products-page .profitability-traffic-table td {
  overflow: hidden;
  text-overflow: ellipsis;
}
.profitability-products-page .profitability-traffic-table th:nth-child(1),
.profitability-products-page .profitability-traffic-table td:nth-child(1) {
  width: 220px;
  white-space: normal;
  line-height: 1.35;
}
.profitability-products-page .profitability-traffic-table th:nth-child(2),
.profitability-products-page .profitability-traffic-table td:nth-child(2) {
  width: 150px;
}
.profitability-products-page .profitability-traffic-table th:nth-child(3),
.profitability-products-page .profitability-traffic-table td:nth-child(3),
.profitability-products-page .profitability-traffic-table th:nth-child(4),
.profitability-products-page .profitability-traffic-table td:nth-child(4),
.profitability-products-page .profitability-traffic-table th:nth-child(5),
.profitability-products-page .profitability-traffic-table td:nth-child(5),
.profitability-products-page .profitability-traffic-table th:nth-child(6),
.profitability-products-page .profitability-traffic-table td:nth-child(6),
.profitability-products-page .profitability-traffic-table th:nth-child(7),
.profitability-products-page .profitability-traffic-table td:nth-child(7),
.profitability-products-page .profitability-traffic-table th:nth-child(8),
.profitability-products-page .profitability-traffic-table td:nth-child(8),
.profitability-products-page .profitability-traffic-table th:nth-child(9),
.profitability-products-page .profitability-traffic-table td:nth-child(9),
.profitability-products-page .profitability-traffic-table th:nth-child(10),
.profitability-products-page .profitability-traffic-table td:nth-child(10) {
  width: 95px;
}
.profitability-products-page .profitability-traffic-table th:nth-child(11),
.profitability-products-page .profitability-traffic-table td:nth-child(11),
.profitability-products-page .profitability-traffic-table th:nth-child(12),
.profitability-products-page .profitability-traffic-table td:nth-child(12),
.profitability-products-page .profitability-traffic-table th:nth-child(13),
.profitability-products-page .profitability-traffic-table td:nth-child(13),
.profitability-products-page .profitability-traffic-table th:nth-child(14),
.profitability-products-page .profitability-traffic-table td:nth-child(14),
.profitability-products-page .profitability-traffic-table th:nth-child(15),
.profitability-products-page .profitability-traffic-table td:nth-child(15) {
  width: 105px;
}
.profitability-products-page .profitability-traffic-table th:nth-child(16),
.profitability-products-page .profitability-traffic-table td:nth-child(16) {
  width: 260px;
  white-space: normal;
  line-height: 1.35;
}
.marketing-month-card {
  min-height: 0;
}
.marketing-month-table {
  min-width: 860px;
  font-size: 0.88rem;
}
.marketing-month-table th {
  white-space: nowrap;
}
.marketing-month-table td:first-child,
.marketing-month-table th:first-child {
  min-width: 110px;
}
.marketing-month-table td:nth-child(2),
.marketing-month-table th:nth-child(2) {
  min-width: 120px;
}
.marketing-channel-kpi-table {
  min-width: 2200px;
  font-size: 0.82rem;
}
.marketing-channel-kpi-table th {
  white-space: nowrap;
}
.marketing-channel-kpi-table td:first-child,
.marketing-channel-kpi-table th:first-child {
  min-width: 110px;
}
.marketing-channel-kpi-table td:nth-child(2),
.marketing-channel-kpi-table th:nth-child(2) {
  min-width: 110px;
}
.marketing-month-total-table {
  min-width: 920px;
  font-size: 0.88rem;
}
.marketing-month-total-table th {
  white-space: nowrap;
}
.marketing-month-total-table td:first-child,
.marketing-month-total-table th:first-child {
  min-width: 110px;
}
.marketing-dashboard-page .marketing-dashboard-table {
  min-width: 1380px;
  font-size: 0.86rem;
  table-layout: fixed;
}
.marketing-dashboard-page .marketing-dashboard-table th {
  white-space: nowrap;
}
.marketing-dashboard-page .marketing-dashboard-table td {
  vertical-align: top;
  overflow: hidden;
  text-overflow: ellipsis;
}
.marketing-dashboard-page .marketing-dashboard-table th:nth-child(1),
.marketing-dashboard-page .marketing-dashboard-table td:nth-child(1) {
  width: 110px;
}
.marketing-dashboard-page .marketing-dashboard-table--daily th:nth-child(2),
.marketing-dashboard-page .marketing-dashboard-table--daily td:nth-child(2),
.marketing-dashboard-page .marketing-dashboard-table--site th:nth-child(1),
.marketing-dashboard-page .marketing-dashboard-table--site td:nth-child(1),
.marketing-dashboard-page .marketing-dashboard-table--channel th:nth-child(1),
.marketing-dashboard-page .marketing-dashboard-table--channel td:nth-child(1) {
  width: 140px;
}
.marketing-dashboard-page .marketing-dashboard-table--daily th:nth-child(2),
.marketing-dashboard-page .marketing-dashboard-table--daily td:nth-child(2) {
  width: 120px;
}
.marketing-dashboard-page .marketing-dashboard-table--channel th:nth-child(2),
.marketing-dashboard-page .marketing-dashboard-table--channel td:nth-child(2) {
  width: 100px;
}
.marketing-dashboard-page .marketing-dashboard-table--channel th:nth-child(3),
.marketing-dashboard-page .marketing-dashboard-table--channel td:nth-child(3),
.marketing-dashboard-page .marketing-dashboard-table--channel th:nth-child(4),
.marketing-dashboard-page .marketing-dashboard-table--channel td:nth-child(4),
.marketing-dashboard-page .marketing-dashboard-table--channel th:nth-child(5),
.marketing-dashboard-page .marketing-dashboard-table--channel td:nth-child(5),
.marketing-dashboard-page .marketing-dashboard-table--channel th:nth-child(6),
.marketing-dashboard-page .marketing-dashboard-table--channel td:nth-child(6) {
  width: 120px;
}
.empty-note {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0 0 1rem;
}

/* Insight (map.php) */
.insight-panel { margin-top: 0.5rem; }
.insight-kpi { margin-bottom: 1rem; }
.insight-cols {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.insight-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  box-shadow: var(--shadow);
}
.insight-col__title {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
}
.insight-list { list-style: none; margin: 0; padding: 0; }
.insight-list__item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(80px, 1fr) auto;
  gap: 0.35rem 0.5rem;
  align-items: center;
  font-size: 0.82rem;
  margin-bottom: 0.35rem;
}
.insight-list__name {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.insight-list__bar {
  height: 6px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}
.insight-list__bar > span {
  display: block;
  height: 100%;
  background: #1d4ed8;
  border-radius: 4px;
}
.insight-list__val {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: right;
}

.insight-bubbles { margin-bottom: 1rem; }
.insight-bubbles__row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
}
.insight-bubble {
  flex: 0 0 auto;
  transform: scale(var(--s, 0.85));
  transform-origin: bottom center;
}
.insight-bubble__inner {
  min-width: 72px;
  max-width: 140px;
  padding: 0.5rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid #bfdbfe;
  text-align: center;
}
.insight-bubble__val {
  font-weight: 700;
  font-size: 0.85rem;
  color: #1e3a8a;
}
.insight-bubble__lbl {
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 0.2rem;
  line-height: 1.25;
  word-break: break-word;
}

.insight-zones__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: flex-end;
  min-height: 120px;
}
.insight-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-width: 52px;
}
.insight-zone__year { font-size: 0.75rem; color: var(--muted); }
.insight-zone__track {
  width: 18px;
  height: 88px;
  background: #e2e8f0;
  border-radius: 6px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}
.insight-zone__track > span {
  display: block;
  width: 100%;
  background: #1d4ed8;
  border-radius: 6px 6px 0 0;
  min-height: 6px;
}
.insight-zone__rev {
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Импорт */
.imports-section {
  margin-bottom: 2rem;
}
.imports-section__title {
  font-size: 1.15rem;
  margin: 0 0 0.35rem;
  font-weight: 700;
}
.imports-section__lead {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: var(--muted);
  max-width: 52rem;
}
.alert--ok {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-text);
}
.import-instruction-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.import-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 0.85rem 1rem 1rem;
}
.import-card--inactive {
  opacity: 0.75;
}
.import-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}
.import-card__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}
.import-card__code code {
  font-size: 0.8rem;
  background: var(--surface-soft);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}
.import-card__badge {
  font-size: 0.72rem;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}
.import-card__dl {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(140px, 200px) 1fr;
  gap: 0.35rem 1rem;
  font-size: 0.88rem;
}
.import-card__dl dt {
  margin: 0;
  color: var(--muted);
  font-weight: 500;
}
.import-card__dl dd {
  margin: 0;
}
.import-card__mono {
  font-family: ui-monospace, monospace;
  font-size: 0.82rem;
  line-height: 1.45;
}
.import-upload-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  max-width: 36rem;
  box-shadow: var(--shadow-soft);
}
.import-upload-form__row {
  margin-bottom: 0.75rem;
}
.import-upload-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.import-upload-form input[type="file"],
.import-upload-form select {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}
.import-upload-form__hint {
  font-size: 0.82rem;
  color: var(--text);
  background: var(--surface-soft);
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  margin-bottom: 0.75rem;
  line-height: 1.45;
}
.import-upload-form__btn {
  padding: 0.45rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
}
.import-upload-form__btn:hover {
  filter: brightness(1.05);
}
.table-scroll {
  overflow-x: auto;
}
.import-cell-path {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
}

/* Общие утилиты (логин, админка) */
.muted {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.field {
  margin-bottom: 0.85rem;
}
.field:last-child {
  margin-bottom: 0;
}
.label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.input,
input.input,
select.input,
textarea.input {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  font-family: inherit;
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  box-shadow: var(--shadow-soft);
}
.btn:hover {
  text-decoration: none;
  filter: brightness(1.04);
}
.btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: rgba(15, 23, 42, 0.14);
}
[data-theme="dark"] .btn--primary {
  border-color: rgba(226, 232, 240, 0.18);
}
.btn--ghost {
  background: var(--surface-soft);
  color: var(--text);
  border-color: var(--border);
  box-shadow: none;
}
.btn--ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}
.card__hd {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}
.card__hd h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}
.card__bd {
  padding: 1rem;
}

.alert--success {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success-text);
}
.alert--danger {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #dc2626;
}
[data-theme="dark"] .alert--danger {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.35);
  color: #fca5a5;
}

/* Администрирование */
.admin-page {
  --admin-bar: linear-gradient(90deg, #4f46e5, var(--accent));
}
.admin-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1rem 1.25rem;
  margin-bottom: 1.35rem;
  padding: 1.1rem 1.15rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  position: relative;
  overflow: hidden;
}
.admin-hero::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--admin-bar);
  border-radius: 4px 0 0 4px;
}
.admin-hero__mark {
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 800;
  flex-shrink: 0;
}
.admin-hero__body {
  flex: 1;
  min-width: 200px;
}
.admin-hero__eyebrow {
  margin: 0 0 0.2rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}
.admin-hero__title {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.admin-hero__lead {
  margin: 0;
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.45;
  max-width: 40rem;
}
.admin-hero__meta {
  margin-left: auto;
  align-self: center;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}
.admin-hero__meta strong {
  display: block;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}
.admin-hero__meta span {
  display: block;
  font-size: 0.78rem;
  margin-top: 0.15rem;
  line-height: 1.3;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 960px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }
}

.admin-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}
.admin-panel__hd {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}
.admin-panel__hd h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}
.admin-panel__hd p {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.4;
}
.admin-panel__bd {
  padding: 1rem;
}

.admin-form-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 1rem;
  padding: 0.55rem 0.65rem;
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  line-height: 1.45;
}

.admin-form-actions {
  margin-top: 1.1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.admin-table-wrap {
  overflow-x: auto;
  margin: 0 -1rem -1rem;
  border-top: 1px solid var(--border);
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.admin-table th,
.admin-table td {
  padding: 0.55rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table th {
  background: var(--surface-soft);
  font-weight: 600;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.admin-table tbody tr:hover {
  background: var(--accent-soft);
}
.admin-table tbody tr:last-child td {
  border-bottom: none;
}
.admin-table td.mono {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.8rem;
  color: var(--muted);
}

.admin-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid var(--border);
  background: var(--surface-soft);
}
.admin-badge--admin {
  background: rgba(79, 70, 229, 0.14);
  border-color: rgba(79, 70, 229, 0.32);
  color: #4338ca;
}
[data-theme="dark"] .admin-badge--admin {
  color: #a5b4fc;
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(129, 140, 248, 0.35);
}
.admin-badge--user {
  color: var(--muted);
}
.admin-badge--on {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-text);
}
.admin-badge--off {
  background: var(--warning-bg);
  border-color: var(--warning-border);
  color: var(--warning-text);
}

.admin-edit {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}
.admin-edit > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.45rem 0.6rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
}
.admin-edit > summary::-webkit-details-marker {
  display: none;
}
.admin-edit > summary::after {
  content: "▸";
  float: right;
  opacity: 0.55;
  transition: transform 0.15s ease;
}
.admin-edit[open] > summary::after {
  transform: rotate(90deg);
}
.admin-edit > summary:hover {
  background: var(--surface);
}
.admin-edit__form {
  padding: 0.75rem 0.85rem 0.85rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.admin-edit__form .field:last-of-type {
  margin-bottom: 0.75rem;
}

.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.checkbox-inline input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}
.checkbox-inline .label {
  margin: 0;
  font-weight: 500;
  color: var(--text);
}


/* Sales dashboard */
.sales-dashboard { padding-top: 1rem; }
.sales-title-row { display:flex; align-items:center; justify-content:space-between; gap:1rem; margin-bottom:1rem; }
.sales-title-row h2 { margin:0; font-size:1.45rem; }
.sales-data-status { display:flex; gap:.75rem; align-items:center; color:var(--muted); font-size:.84rem; flex-wrap:wrap; justify-content:flex-end; }
.sales-data-status__ok { color:var(--success-text); font-weight:700; }
.sales-filter-panel { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow-soft); padding:.9rem 1rem; margin-bottom:1rem; }
.sales-filter-grid { display:grid; grid-template-columns:repeat(6,minmax(130px,1fr)); gap:.6rem .75rem; align-items:end; }
.sales-filter-grid--period { grid-template-columns:1.25fr 1fr 1fr 1fr 1.15fr; padding-bottom:.75rem; margin-bottom:.75rem; border-bottom:1px solid var(--border); }
.sales-filter-grid label { display:flex; flex-direction:column; gap:.22rem; font-size:.74rem; color:var(--muted); min-width:0; }
.sales-filter-grid input,.sales-filter-grid select { width:100%; min-width:0; border:1px solid var(--border); border-radius:var(--radius-sm); background:var(--surface); color:var(--text); padding:.48rem .55rem; font-size:.86rem; }
.sales-filter-grid input:focus,.sales-filter-grid select:focus { outline:none; border-color:var(--accent); box-shadow:var(--focus); }
.sales-filter-actions { display:flex; gap:.65rem; align-items:center; margin-top:.8rem; }
.sales-filter-actions button { border:0; border-radius:var(--radius-sm); background:var(--accent); color:#fff; padding:.5rem 1rem; font-size:.87rem; cursor:pointer; }
.sales-filter-actions a { color:var(--muted); font-size:.85rem; }
.sales-compare-panel { display:none; margin-top:.85rem; padding:.75rem; border:1px dashed var(--border); border-radius:var(--radius-sm); background:var(--surface-soft); }
.sales-compare-panel.is-open { display:block; }
.sales-compare-panel__title { font-size:.82rem; font-weight:700; margin-bottom:.55rem; }
.sales-kpi-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:.75rem; margin-bottom:1rem; }
.sales-kpi { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow-soft); padding:.85rem 1rem; min-width:0; }
.sales-kpi span { display:block; color:var(--muted); font-size:.74rem; margin-bottom:.25rem; }
.sales-kpi strong { display:block; font-size:1.18rem; line-height:1.2; overflow-wrap:anywhere; }
.sales-comparison-summary { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:.75rem; margin-bottom:1rem; }
.sales-comparison-summary > div { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-sm); padding:.7rem .85rem; }
.sales-comparison-summary span { display:block; color:var(--muted); font-size:.72rem; margin-bottom:.2rem; }
.sales-comparison-summary strong { font-size:1rem; }
.sales-comparison-summary .is-positive strong { color:var(--success-text); }
.sales-comparison-summary .is-negative strong { color:#b91c1c; }
.sales-chart-card { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow-soft); margin-bottom:1rem; overflow:hidden; }
.sales-section-head { display:flex; align-items:center; justify-content:space-between; gap:1rem; padding:.7rem 1rem; border-bottom:1px solid var(--border); background:var(--surface-soft); }
.sales-section-head h3 { margin:0; font-size:1rem; }
.sales-section-head label { display:flex; align-items:center; gap:.5rem; color:var(--muted); font-size:.75rem; }
.sales-section-head select { border:1px solid var(--border); border-radius:var(--radius-sm); background:var(--surface); color:var(--text); padding:.38rem .5rem; }
.sales-chart-wrap { padding:.85rem 1rem .65rem; }
#sales-trend-chart { width:100%; height:320px; display:block; overflow:visible; }
.chart-grid { stroke:var(--border); stroke-width:1; vector-effect:non-scaling-stroke; }
.chart-axis-label { fill:var(--muted); font-size:11px; }
.chart-series-a,.chart-series-b { fill:none; stroke-width:3; vector-effect:non-scaling-stroke; }
.chart-series-a { stroke:var(--accent); }
.chart-series-b { stroke:#8b5cf6; stroke-dasharray:7 6; }
.chart-series-a-point { fill:var(--surface); stroke:var(--accent); stroke-width:2; vector-effect:non-scaling-stroke; }
.chart-series-b-point { fill:var(--surface); stroke:#8b5cf6; stroke-width:2; vector-effect:non-scaling-stroke; }
.sales-chart-legend { display:flex; gap:1rem; justify-content:flex-end; color:var(--muted); font-size:.78rem; padding:.2rem .2rem 0; }
.sales-chart-legend span { display:inline-flex; align-items:center; gap:.35rem; }
.sales-chart-legend i { width:18px; height:3px; border-radius:99px; display:inline-block; }
.sales-chart-legend .series-a { background:var(--accent); }
.sales-chart-legend .series-b { background:#8b5cf6; }
.sales-two-column { display:grid; grid-template-columns:1fr 1fr; gap:1rem; }
.sales-two-column .table-card { min-width:0; }
.sales-dashboard .table-card h3 { font-size:.93rem; }
.sales-dashboard .table-card th { cursor:default; }
.sales-dashboard .js-sortable th { cursor:pointer; user-select:none; }
.sales-dashboard .js-sortable th:hover { color:var(--accent); }
.sales-control-details { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow-soft); margin-top:1rem; overflow:hidden; }
.sales-control-details summary { display:flex; gap:1rem; align-items:center; padding:.8rem 1rem; cursor:pointer; list-style:none; }
.sales-control-details summary::-webkit-details-marker { display:none; }
.sales-control-details summary span { font-weight:700; color:var(--success-text); }
.sales-control-details summary strong { margin-left:auto; }
.sales-control-details summary small { color:var(--muted); }
.sales-control-details__body { border-top:1px solid var(--border); overflow:auto; }
.sales-control-details table { width:100%; border-collapse:collapse; font-size:.86rem; }
.sales-control-details th,.sales-control-details td { padding:.55rem .7rem; border-bottom:1px solid var(--border); }
.sales-control-details .num { text-align:right; white-space:nowrap; }

@media (max-width: 1100px) {
  .sales-filter-grid { grid-template-columns:repeat(3,minmax(140px,1fr)); }
  .sales-filter-grid--period { grid-template-columns:repeat(3,minmax(140px,1fr)); }
  .sales-kpi-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .sales-two-column { grid-template-columns:1fr; }
}
@media (max-width: 700px) {
  .sales-title-row { align-items:flex-start; flex-direction:column; }
  .sales-data-status { justify-content:flex-start; }
  .sales-filter-grid,.sales-filter-grid--period { grid-template-columns:1fr 1fr; }
  .sales-kpi-grid { grid-template-columns:1fr 1fr; }
  .sales-comparison-summary { grid-template-columns:1fr; }
  .sales-section-head { align-items:flex-start; flex-direction:column; }
  #sales-trend-chart { height:260px; }
  .sales-control-details summary { align-items:flex-start; flex-wrap:wrap; }
  .sales-control-details summary strong { margin-left:0; }
}
