:root {
  /* === Цвета поверхностей === */
  --bg: #f4f5fa;
  --bg-grad: linear-gradient(180deg, #f6f7fc 0%, #eef0f7 100%);
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --surface-elevated: #ffffff;
  --line: #e8ecf3;
  --line-strong: #d6dde7;
  /* === Текст === */
  --text: #0f172a;
  --text-soft: #334155;
  --muted: #64748b;
  /* === Палитра === */
  --blue: #4f46e5;
  --blue-dark: #4338ca;
  --blue-soft: #eef2ff;
  --indigo: #6366f1;
  --green: #059669;
  --green-soft: #ecfdf5;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --violet: #7c3aed;
  --violet-soft: #f5f3ff;
  --teal: #0d9488;
  --pink: #db2777;
  --orange: #ea580c;
  /* === Тени === */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 28px -8px rgba(15, 23, 42, 0.10), 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow: var(--shadow-sm);
  /* === Радиусы === */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  /* === Алиасы (для совместимости со старым кодом) === */
  --card: var(--surface);
  --border: var(--line);
  --primary: var(--blue);
  --primary-strong: var(--blue-dark);
  --primary-soft: var(--blue-soft);
  --success: var(--green);
  --danger: var(--red);
  --warning: var(--amber);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 12px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 34px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border-radius: 8px;
  background: transparent;
  color: #536176;
  cursor: pointer;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: #edf4ff;
  color: var(--blue-dark);
}

.nav-item:focus-visible,
.primary-button:focus-visible,
.ghost-button:focus-visible,
.icon-button:focus-visible {
  outline: 3px solid rgba(35, 104, 209, 0.24);
  outline-offset: 2px;
}

.nav-item svg,
button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.sidebar-note {
  position: absolute;
  right: 14px;
  bottom: 20px;
  left: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 12px;
}

.sidebar-note span,
.sidebar-note strong {
  display: block;
}

.sidebar-note strong {
  margin-top: 8px;
  color: var(--text);
}

.workspace {
  padding: 18px 24px 30px;
  overflow: hidden;
}

.topbar,
.filters-panel,
.panel-header,
.expense-layout,
.finance-layout {
  display: flex;
}

.topbar {
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.mode-note {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.status-pill.error .dot {
  background: var(--red);
}

.filters-panel,
.chart-panel,
.view-panel,
.expense-form,
.expenses-list-panel,
.finance-report-panel,
.finance-form,
.finance-table-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.filters-panel {
  display: grid;
  grid-template-columns: minmax(260px, 310px) minmax(300px, 370px) minmax(160px, 1fr) minmax(136px, auto) minmax(128px, auto);
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.035);
  flex-wrap: wrap;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 9px 11px;
  background: #ffffff;
  color: var(--text);
  outline: none;
  text-transform: none;
}

input[type="date"] {
  position: relative;
  min-height: 34px;
  padding: 4px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-weight: 800;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  cursor: pointer;
  opacity: 0.58;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(35, 104, 209, 0.12);
}

.pin-field {
  width: 130px;
  display: none;
}

.quick-ranges {
  display: inline-flex;
  width: 100%;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f7fa;
}

.range-button {
  min-height: 34px;
  padding: 7px 12px;
  flex: 1;
  border-radius: 6px;
  background: transparent;
  color: #536176;
  cursor: pointer;
  font-weight: 800;
  white-space: nowrap;
}

.range-button:hover,
.range-button.active {
  background: #ffffff;
  color: var(--blue-dark);
  box-shadow: 0 1px 3px rgba(23, 32, 42, 0.1);
}

.filter-row {
  display: contents;
}

.date-range-control {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 40px;
  padding: 5px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
}

.date-range-control > svg {
  width: 18px;
  height: 18px;
  color: var(--blue);
}

.date-range-control > span {
  height: 1px;
  background: var(--line-strong);
}

.date-range-control label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 128px;
  font-size: 10px;
}

.date-range-control input:focus {
  box-shadow: none;
}

.offer-field {
  width: 100%;
  min-width: 0;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 230px;
  min-height: 28px;
  color: var(--text);
  text-transform: none;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.data-status {
  grid-column: 2 / -1;
  min-height: 28px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.primary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  padding: 10px 16px;
  background: var(--blue);
  color: white;
  box-shadow: 0 8px 16px rgba(35, 104, 209, 0.18);
}

.primary-button:hover {
  background: var(--blue-dark);
}

.primary-button:disabled {
  cursor: progress;
  opacity: 0.62;
  box-shadow: none;
}

.ghost-button {
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: var(--text);
}

.ghost-button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.metric-card {
  position: relative;
  min-height: 82px;
  overflow: hidden;
  padding: 12px 15px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.035);
}

.metric-card::after {
  content: "";
  position: absolute;
  right: 14px;
  bottom: 0;
  left: 14px;
  height: 4px;
  border-radius: 999px 999px 0 0;
  background: var(--blue);
  opacity: 0.92;
}

.metric-card:nth-child(1)::after {
  background: var(--green);
}

.metric-card:nth-child(3)::after {
  background: var(--amber);
}

.metric-card:nth-child(4)::after {
  background: var(--blue-dark);
}

.expense-metric::after {
  background: #94a3b8;
}

.metric-card span,
.panel-header span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin-top: 6px;
  font-size: 25px;
  line-height: 1;
}

.expense-metric {
  min-height: 76px;
  background: #ffffff;
}

.expense-metric strong {
  font-size: 22px;
}

.metric-card small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

.muted {
  color: var(--muted);
}

.charts-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 12px;
  align-items: start;
}

.chart-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  min-width: 0;
  padding: 16px;
  align-self: start;
}

.chart-panel > canvas {
  width: 100% !important;
}

#sizeChart {
  height: 190px !important;
}

#regionChart {
  height: 240px !important;
}

.chart-panel-wide {
  grid-column: span 1;
}



.chart-legend {
  display: grid;
  gap: 6px;
  max-height: 248px;
  overflow: auto;
}

.legend-pill {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 4px 8px;
  align-items: center;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.legend-pill strong {
  color: var(--text);
  font-size: 12px;
}

.legend-pill em {
  grid-column: 2;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.empty-mini {
  padding: 14px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}


.trend-row {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.trend-row > div:first-child {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.trend-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.trend-row strong {
  font-size: 18px;
}

.trend-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9eef5;
}

.trend-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.trend-track .blue {
  background: var(--blue);
}

.trend-track .green {
  background: var(--green);
}

.trend-track .red {
  background: var(--red);
}

.trend-track .amber {
  background: var(--amber);
}

.panel-header {
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-header.compact {
  margin-bottom: 10px;
}

.view-panel {
  display: none;
  padding: 14px;
  margin-top: 0;
}

.view-panel.active {
  display: block;
}

.view-panel.layout-view {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.quick-expense-panel {
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.quick-expense-panel summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  padding: 8px 10px;
  cursor: pointer;
  list-style: none;
}

.quick-expense-panel summary::-webkit-details-marker {
  display: none;
}

.quick-expense-panel summary:focus-visible {
  outline: 3px solid rgba(35, 104, 209, 0.24);
  outline-offset: 2px;
}

.quick-expense-panel summary::before {
  content: "+";
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--blue);
  color: #ffffff;
  font-weight: 800;
}

.quick-expense-panel[open] summary::before {
  content: "-";
}

.quick-expense-panel summary span {
  font-weight: 800;
}

.quick-expense-panel summary small {
  color: var(--muted);
}


.section-hint {
  margin: -4px 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.stat-tile {
  min-height: 82px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.stat-tile span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.stat-tile strong {
  display: block;
  margin-top: 7px;
  font-size: 24px;
}

.stat-tile small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.quick-expense {
  display: grid;
  grid-template-columns: minmax(250px, 1.2fr) minmax(170px, 1fr) 140px auto;
  gap: 10px;
  align-items: end;
  padding: 0 12px 12px;
}

.quick-expense label {
  min-width: 0;
}

.expense-range-presets {
  grid-column: 1 / -1;
  display: inline-flex;
  width: fit-content;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.expense-range-button {
  min-height: 32px;
  padding: 7px 10px;
  border-radius: 6px;
  background: transparent;
  color: #536176;
  cursor: pointer;
  font-weight: 800;
}

.expense-range-button:hover,
.expense-range-button.active {
  background: var(--blue-soft);
  color: var(--blue-dark);
}

.expense-distribution-note {
  grid-column: 1 / -1;
  padding: 9px 10px;
  border: 1px solid #cfe0f8;
  border-radius: 8px;
  background: #f1f6ff;
  color: #536176;
  font-size: 12px;
  line-height: 1.4;
}

.expense-date-range {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 16px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 42px;
  padding: 5px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
}

.expense-date-range > span {
  height: 1px;
  background: var(--line-strong);
}

.expense-date-range label {
  gap: 0;
  font-size: 10px;
}

.expense-date-range input:focus {
  box-shadow: none;
}

.expense-offer-field {
  min-width: 0;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

table {
  width: 100%;
  min-width: max(1480px, 100%);
  border-collapse: collapse;
  background: #ffffff;
  table-layout: auto;
}

.report-table {
  min-width: max(1680px, 100%);
  table-layout: fixed;
}

th,
td {
  min-width: 88px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
  font-size: 13px;
}

.report-table th,
.report-table td {
  min-width: 0;
  padding-right: 10px;
  padding-left: 10px;
  text-align: center;
}

.report-table th {
  white-space: normal;
  line-height: 1.15;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f6f8fb;
  color: #5f6978;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

th[data-sort-key] {
  cursor: pointer;
  user-select: none;
}

th[data-sort-key]::after {
  content: "";
  display: inline-block;
  width: 12px;
  margin-left: 4px;
  color: var(--blue);
}

th[data-sort-key].sorted::after {
  content: "↓";
}

th[data-sort-key].sorted[data-direction="asc"]::after {
  content: "↑";
}

th:first-child,
td:first-child {
  text-align: left;
  min-width: 130px;
}

.report-table th:first-child,
.report-table td:first-child {
  width: 124px;
  min-width: 124px;
  max-width: 124px;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}

.report-table[data-sort-table="offers"] th:nth-child(2),
.report-table[data-sort-table="offers"] td:nth-child(2),
.report-table[data-sort-table="days"] th:nth-child(2),
.report-table[data-sort-table="days"] td:nth-child(2) {
  width: 92px;
}

.report-table[data-sort-table="offers"] th:nth-child(4),
.report-table[data-sort-table="offers"] td:nth-child(4),
.report-table[data-sort-table="days"] th:nth-child(4),
.report-table[data-sort-table="days"] td:nth-child(4) {
  width: 92px;
}

th:first-child,
td:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  background: #ffffff;
  box-shadow: 1px 0 0 var(--line);
}

thead th:first-child {
  z-index: 4;
  background: #f3f6fa;
}

tbody td:first-child {
  background: #ffffff;
}

tbody tr:hover td:first-child {
  background: #f8fafc;
}

tfoot td:first-child {
  background: #f2f6fd;
}

tbody tr:hover {
  background: #f8fafc;
}

tfoot td {
  border-top: 2px solid var(--blue);
  background: #f2f6fd;
  font-weight: 800;
}

.empty-state {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.expense-layout {
  align-items: start;
  gap: 14px;
}

.finance-layout {
  display: block;
}

.expense-form,
.expenses-list-panel,
.finance-report-panel,
.finance-form,
.finance-table-panel {
  padding: 14px;
}

.expense-form,
.finance-form {
  display: grid;
  width: 430px;
  gap: 12px;
}

.finance-form-inline {
  width: 100%;
  position: static;
  display: grid;
  grid-template-columns: 140px 130px minmax(170px, 1fr) minmax(170px, 1fr) minmax(170px, 1fr) 130px minmax(220px, 1.2fr) auto;
  align-items: end;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  background: var(--surface-muted);
}

.finance-form-inline .panel-header {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.finance-form-inline .panel-header.compact {
  align-items: center;
}

.finance-comment-field {
  min-width: 0;
}

.expense-form .expense-date-range,
.expense-form .expense-offer-field,
.expense-form .expense-range-presets {
  width: 100%;
}

.expenses-list-panel {
  flex: 1;
  min-width: 0;
}

.finance-report-panel {
  flex: 1;
  min-width: 0;
}

.finance-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.finance-kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.finance-filters {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.finance-filters {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}



.source-badge {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}



.source-badge {
  align-self: center;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
}

.finance-card {
  min-height: 86px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.finance-card.total {
  background: #f2f6fd;
  border-color: #c8d7ed;
}

.finance-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.finance-card strong {
  display: block;
  margin-top: 7px;
  font-size: 21px;
  line-height: 1;
}

.finance-card small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}


.finance-table-wrap {
  max-height: 380px;
}

.finance-table {
  min-width: 520px;
}

.expenses-list {
  display: grid;
  gap: 8px;
}

.expense-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.expense-item strong,
.expense-item span {
  display: block;
}

.expense-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
  color: var(--red);
  cursor: pointer;
}

.icon-button.neutral {
  color: var(--blue);
}

.entry-actions {
  display: flex;
  gap: 6px;
}

.small-button {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 12px;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 420px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111827;
  color: #ffffff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    align-items: center;
    padding: 14px;
  }

  .sidebar-note {
    position: static;
    grid-column: 1 / -1;
    display: flex;
    gap: 14px;
    align-items: center;
    margin-top: 0;
    padding: 10px 12px;
  }

  .sidebar-note strong {
    margin-top: 0;
  }

  .brand {
    margin-bottom: 0;
  }

  .nav {
    display: flex;
    justify-content: flex-start;
    gap: 8px;
    overflow-x: auto;
  }

  .nav-item {
    width: auto;
    white-space: nowrap;
  }

  .quick-expense {
    grid-template-columns: 1fr 1fr;
  }

  .filters-panel {
    grid-template-columns: minmax(0, 1fr);
  }

  .data-status,
  .check-row {
    grid-column: auto;
    max-width: none;
  }

  .offer-field {
    width: 100%;
  }

  .primary-button {
    width: 100%;
  }

  .filter-row {
    display: contents;
  }

  .pin-field {
    display: none;
  }

  .kpi-grid {
    display: flex;
    overflow-x: auto;
    gap: 0;
  }

  .metric-card {
    flex: 0 0 210px;
    min-height: 78px;
    padding: 12px 14px 11px;
  }

  .metric-card strong {
    margin-top: 7px;
    font-size: 22px;
  }

  .metric-card small {
    margin-top: 8px;
    font-size: 12px;
  }

  .expense-layout,
  .finance-report-grid,
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }

  .expense-layout {
    display: grid;
  }

  .expense-form,
  .finance-form {
    width: auto;
    position: static;
    flex: initial;
  }

  .finance-kpi-grid {
    grid-template-columns: repeat(3, minmax(170px, 1fr));
  }

  .finance-form-inline,
  .finance-filters,
  .finance-flow-grid {
    grid-template-columns: 1fr 1fr;
  }

  .finance-form-inline .primary-button {
    grid-column: 1 / -1;
  }

  .donut-card {
    grid-template-columns: minmax(150px, 0.9fr) minmax(150px, 1fr);
  }
}

@media (max-width: 760px) {
  .workspace {
    padding: 18px;
  }

  .sidebar {
    grid-template-columns: 1fr;
  }

  .nav {
    justify-content: flex-start;
  }

  .sidebar-note {
    display: none;
  }

  .topbar {
    display: grid;
  }

  h1 {
    font-size: 26px;
  }

  .charts-grid,
  .expense-layout,
  .finance-report-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .donut-card {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: repeat(4, minmax(220px, 1fr));
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .filters-panel {
    display: grid;
  }

  .finance-form-inline,
  .finance-filters,
  .finance-flow-grid {
    grid-template-columns: 1fr;
  }

  .quick-ranges {
    width: 100%;
    overflow-x: auto;
  }

  .range-button {
    flex: 1 0 auto;
  }

  .filter-row {
    grid-template-columns: 1fr;
  }

  .date-range-control {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) 12px minmax(0, 1fr);
    gap: 6px;
    align-items: center;
  }

  .date-range-control label {
    min-width: 0;
    gap: 4px;
  }

  .date-range-control input[type="date"] {
    min-width: 0;
    padding-left: 3px;
    padding-right: 3px;
  }

  .quick-expense {
    grid-template-columns: 1fr;
  }

  .finance-kpi-grid {
    display: flex;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .finance-card {
    flex: 0 0 210px;
  }

  .donut-card {
    min-height: 0;
  }
}

/* 2026 compact workspace refresh */
.app-shell {
  display: block;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  height: auto;
  padding: 10px 18px;
  border-right: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(248, 251, 255, 0.94);
}

.brand {
  margin: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 13px;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  overflow-x: auto;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.nav-item {
  width: auto;
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 8px;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 800;
}

.nav-item svg {
  width: 15px;
  height: 15px;
}

.sidebar-note {
  display: none;
}

.workspace {
  padding: 16px 18px 28px;
}

.topbar {
  align-items: center;
  margin-bottom: 10px;
}

h1 {
  font-size: 26px;
}

.filters-panel {
  grid-template-columns: minmax(230px, 280px) minmax(290px, 1fr) minmax(180px, 260px) minmax(130px, auto) minmax(130px, auto);
  gap: 9px;
  margin-bottom: 10px;
  padding: 9px;
  border-radius: 10px;
}

.quick-ranges,
.date-range-control,
input,
select,
.primary-button,
.ghost-button {
  border-radius: 8px;
}

.kpi-grid {
  grid-template-columns: repeat(8, minmax(160px, 1fr));
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.metric-card {
  min-height: 72px;
  padding: 10px 12px;
}

.metric-card::after {
  display: none;
}

.metric-card {
  border-left: 4px solid #d7e2f0;
}

.metric-card:nth-child(1) {
  border-left-color: var(--green);
}

.metric-card:nth-child(2),
.metric-card:nth-child(4) {
  border-left-color: var(--blue);
}

.metric-card:nth-child(3) {
  border-left-color: var(--green);
}

.metric-card span,
.panel-header span {
  font-size: 11px;
  letter-spacing: 0.06em;
}

.metric-card strong {
  margin-top: 5px;
  font-size: 23px;
}

.metric-card small {
  margin-top: 6px;
  font-size: 12px;
}

.view-panel,
.chart-panel,
.finance-report-panel,
.finance-form,
.finance-table-panel,
.expense-form,
.expenses-list-panel {
  border-radius: 10px;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(290px, 1fr));
  gap: 12px;
}

.chart-panel {
  min-height: 278px;
  padding: 14px;
}

.chart-panel > canvas {
  height: 210px !important;
}

.chart-panel-wide {
  grid-column: span 2;
}




.legend-pill, .insight-row, .expense-item, .week-card, .plan-card, .finance-card {
  border-radius: 8px;
}

.week-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.week-card {
  padding: 11px 12px;
  border: 1px solid var(--line);
  background: var(--surface-muted);
}

.week-card span,
.plan-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.week-card strong,
.plan-card strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
}

.week-card small,
.plan-card small,
.plan-card em {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-style: normal;
}

.cohort-grid,
.funnel-grid,
.manager-grid,
.plan-grid,
.settings-grid {
  display: grid;
  gap: 12px;
}

.cohort-grid {
  grid-template-columns: minmax(420px, 1.35fr) repeat(3, minmax(240px, 0.75fr));
}

.funnel-grid,
.manager-grid,
.plan-grid,
.settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.insight-list,
.funnel-bars,
.settings-list,
.finance-structure-list {
  display: grid;
  gap: 8px;
}

.insight-row,
.structure-row,
.settings-list > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--surface-muted);
}

.insight-row span,
.structure-row span {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
  font-weight: 800;
}

.insight-row i,
.structure-row i {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 3px;
}

.insight-row em,
.structure-row em {
  color: var(--muted);
  font-style: normal;
}

.funnel-row {
  display: grid;
  grid-template-columns: 220px minmax(260px, 1fr) 90px;
  gap: 14px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}

.funnel-row strong,
.funnel-row span {
  display: block;
}

.funnel-row span {
  margin-top: 3px;
  color: var(--muted);
}

.funnel-track {
  height: 30px;
  overflow: hidden;
  border-radius: 8px;
  background: #f0f3f8;
}

.funnel-track i {
  display: flex;
  align-items: center;
  height: 100%;
  min-width: 42px;
  padding-left: 12px;
  border-radius: inherit;
  color: #ffffff;
  font-style: normal;
  font-weight: 800;
}

.funnel-track .blue {
  background: linear-gradient(90deg, #93c5fd, #3b82f6);
}

.funnel-track .indigo {
  background: linear-gradient(90deg, #a5b4fc, #6366f1);
}

.funnel-track .cyan {
  background: linear-gradient(90deg, #67e8f9, #0891b2);
}

.funnel-track .green {
  background: linear-gradient(90deg, #6ee7b7, #059669);
}

.funnel-track .orange {
  background: linear-gradient(90deg, #fdba74, #ea580c);
}

.funnel-track .red {
  background: linear-gradient(90deg, #fca5a5, #ef4444);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  margin-right: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #4f46e5;
  font-size: 11px;
  font-weight: 800;
}

.finance-kpi-wide {
  grid-template-columns: repeat(6, minmax(150px, 1fr));
}

.finance-main-grid {
  display: grid;
  grid-template-columns: minmax(440px, 1fr) minmax(420px, 1fr);
  gap: 12px;
}

.finance-form-inline {
  grid-column: 1 / -1;
  grid-template-columns: 130px 130px minmax(160px, 1fr) minmax(160px, 1fr) minmax(160px, 1fr) 130px minmax(200px, 1fr) auto;
}

.pnl-list {
  display: grid;
  gap: 0;
}

.pnl-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px 80px;
  gap: 10px;
  align-items: center;
  min-height: 38px;
  border-bottom: 1px solid var(--line);
}

.pnl-row span {
  color: var(--text);
}

.pnl-row em {
  color: var(--muted);
  font-style: normal;
  text-align: right;
}

.pnl-row.total,
.pnl-row.grand {
  min-height: 46px;
  font-weight: 800;
}

.pnl-row.grand {
  border-top: 2px solid var(--text);
  border-bottom: 0;
  font-size: 17px;
}

.finance-structure {
  display: grid;
  grid-template-columns: minmax(210px, 0.8fr) minmax(240px, 1fr);
  gap: 12px;
  align-items: center;
}

.finance-structure canvas {
  width: 240px !important;
  height: 240px !important;
  justify-self: center;
}


.plan-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 10px;
}

.plan-card {
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--surface-muted);
}



.settings-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

.settings-list > div {
  grid-template-columns: minmax(180px, 0.8fr) minmax(0, 1.2fr);
}

.settings-list strong,
.settings-list span {
  display: block;
}

.settings-list span {
  color: var(--muted);
}

.report-table th:first-child,
.report-table td:first-child {
  width: 108px;
  min-width: 108px;
  max-width: 108px;
}

.report-table th,
.report-table td {
  vertical-align: middle;
}

.report-table td {
  text-align: center;
}

.report-table td:first-child {
  text-align: left;
}

.report-table[data-sort-table="stats"] {
  min-width: max(1460px, 100%);
  table-layout: fixed;
}

.report-table[data-sort-table="stats"] th:first-child,
.report-table[data-sort-table="stats"] td:first-child {
  width: 150px;
  min-width: 150px;
  max-width: 150px;
}

.report-table[data-sort-table="stats"] th:not(:first-child),
.report-table[data-sort-table="stats"] td:not(:first-child) {
  width: 104px;
  padding-right: 8px;
  padding-left: 8px;
}

.stat-pair {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  white-space: nowrap;
}

.stat-pair strong {
  font-size: 14px;
  font-weight: 850;
}

.stat-pair small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.stat-pair.count-only strong {
  font-size: 15px;
}










.structure-row.income {
  background: rgba(15, 159, 110, 0.07);
}

.structure-row.expense {
  background: rgba(239, 68, 68, 0.04);
}

@media (max-width: 1280px) {
  .charts-grid,
  .cohort-grid {
    grid-template-columns: repeat(2, minmax(280px, 1fr));
  }

  .chart-panel-wide {
    grid-column: span 1;
  }

  .finance-kpi-wide {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
  }

  .finance-main-grid,
  .funnel-grid,
  .manager-grid,
  .plan-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .sidebar {
    grid-template-columns: 1fr;
  }

  .filters-panel {
    grid-template-columns: 1fr;
  }

  .filter-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: repeat(8, 190px);
  }

  .charts-grid,
  .cohort-grid {
    grid-template-columns: 1fr;
  }

  .finance-form-inline,
  .settings-form,
  .finance-filters,
  .finance-structure,
  .plan-cards {
    grid-template-columns: 1fr;
  }

  .funnel-row {
    grid-template-columns: 1fr;
  }

  .date-range-control {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) 12px minmax(0, 1fr);
  }
}

/* 2026 dashboard redesign pass */
body {
  background: #f7faff;
}

.app-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100vh;
  padding: 18px 14px;
  border-right: 1px solid #dfe7f1;
  border-bottom: 0;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 12px 0 28px rgba(15, 23, 42, 0.035);
}

.brand {
  margin: 0 0 8px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0f67ff, #0b54d8);
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(35, 104, 209, 0.22);
}

.nav {
  display: grid;
  gap: 5px;
  overflow: visible;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.nav-item {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border-radius: 10px;
  font-size: 14px;
  white-space: normal;
}

.nav-item.active {
  background: linear-gradient(135deg, #eaf2ff, #f5f9ff);
  color: #0b54d8;
  box-shadow: inset 3px 0 0 #2368d1;
}

.sidebar-note {
  position: static;
  display: grid;
  gap: 7px;
  margin-top: auto;
  border-radius: 12px;
  background: #fbfdff;
  box-shadow: none;
}

.workspace {
  padding: 22px 24px 34px;
  overflow: hidden;
}

.topbar {
  align-items: center;
  margin-bottom: 16px;
}

.topbar h1 {
  font-size: clamp(28px, 2.3vw, 40px);
  line-height: 1.03;
}

.status-pill {
  min-height: 38px;
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.045);
}

.filters-panel {
  display: grid;
  grid-template-areas:
    "ranges controls"
    "status status";
  grid-template-columns: minmax(330px, 0.9fr) minmax(640px, 1.7fr);
  gap: 8px 12px;
  align-items: center;
  margin-bottom: 14px;
  padding: 13px 14px;
  border-radius: 16px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.055);
}

/* Чекбокс «Закупку возвратов» — компактная пилюля, прижата справа к кнопке Обновить, без своей строки */
.filters-panel .check-row {
  grid-area: unset !important;
  align-self: center;
  padding: 6px 10px !important;
  font-size: 12.5px !important;
  gap: 6px;
  display: inline-flex;
  align-items: center;
}

/* Status row — статус данных и PIN на одной компактной полосе */
.filters-status-row {
  grid-area: status;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 28px;
}
.filters-status-row .data-status {
  flex: 1 1 auto;
  min-height: 0 !important;
  padding: 4px 0 !important;
  font-size: 12px;
  color: var(--muted);
}
.filters-status-row .pin-field {
  flex: 0 0 auto;
}

.quick-ranges {
  grid-area: ranges;
  min-height: 48px;
  padding: 5px;
  border-radius: 13px;
}

.range-button {
  min-height: 38px;
  border-radius: 10px;
  font-size: 14px;
}

.range-button.active {
  background: #0f67ff;
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(35, 104, 209, 0.22);
}

.filter-row {
  grid-area: controls;
  display: grid;
  grid-template-columns: minmax(350px, 1.25fr) minmax(210px, 0.8fr) 150px 150px;
  gap: 10px;
  align-items: end;
}

.date-range-control {
  min-height: 52px;
  padding: 7px 10px;
  border-radius: 13px;
}

.date-range-control label {
  min-width: 128px;
}

.offer-field select,
.finance-filters select,
input,
select {
  border-radius: 11px;
}

.check-row {
  grid-area: check;
  max-width: none;
  min-height: 34px;
  font-size: 13px;
  line-height: 1.2;
}

.check-row input {
  width: 20px;
  min-height: 20px;
  accent-color: #0f67ff;
}

.data-status {
  grid-area: status;
  grid-column: auto;
  min-height: 34px;
  border-radius: 11px;
  font-size: 13px;
}

.primary-button,
.ghost-button {
  min-height: 52px;
  border-radius: 13px;
  font-size: 14px;
}

.primary-button {
  background: #0f67ff;
  box-shadow: 0 14px 28px rgba(35, 104, 209, 0.22);
}

.kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
  overflow: visible;
}

.metric-card {
  min-height: 112px;
  padding: 14px 15px;
  border: 1px solid #dfe7f1;
  border-left-width: 4px;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.055);
}

.metric-card strong {
  margin-top: 8px;
  font-size: clamp(23px, 1.7vw, 30px);
  letter-spacing: 0;
}

.expense-metric strong {
  font-size: clamp(22px, 1.55vw, 28px);
}

.metric-card small {
  font-size: 13px;
  line-height: 1.2;
  white-space: normal;
}

.view-panel,
.chart-panel,
.finance-report-panel,
.finance-form,
.finance-table-panel,
.expense-form,
.expenses-list-panel {
  border-radius: 16px;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.055);
}

.view-panel {
  padding: 16px;
}

.panel-header {
  margin-bottom: 12px;
}

.quick-expense-panel {
  border-radius: 13px;
  background: #f8fbff;
}

.quick-expense-panel summary {
  min-height: 50px;
  padding: 10px 14px;
}

.table-wrap {
  border-radius: 13px;
}

.report-table {
  min-width: max(1560px, 100%);
}

.report-table th,
.report-table td {
  padding: 10px 9px;
  font-size: 13px;
}

.report-table th {
  background: #f4f7fb;
  font-size: 11px;
  line-height: 1.18;
}

.report-table th:first-child,
.report-table td:first-child {
  width: 118px;
  min-width: 118px;
  max-width: 118px;
}

.report-table[data-sort-table="offers"] th:nth-child(2),
.report-table[data-sort-table="offers"] td:nth-child(2),
.report-table[data-sort-table="days"] th:nth-child(2),
.report-table[data-sort-table="days"] td:nth-child(2) {
  width: 76px;
}

.report-table[data-sort-table="offers"] th:nth-child(3),
.report-table[data-sort-table="offers"] td:nth-child(3),
.report-table[data-sort-table="offers"] th:nth-child(5),
.report-table[data-sort-table="offers"] td:nth-child(5),
.report-table[data-sort-table="days"] th:nth-child(3),
.report-table[data-sort-table="days"] td:nth-child(3),
.report-table[data-sort-table="days"] th:nth-child(5),
.report-table[data-sort-table="days"] td:nth-child(5) {
  width: 104px;
}


.stat-tile {
  border-radius: 14px;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.045);
}

















.finance-structure canvas {
  width: 260px !important;
  height: 260px !important;
}

.legend-pill {
  grid-template-columns: auto minmax(0, 1fr);
  padding: 9px 10px;
  background: #f8fbff;
}

.legend-pill em {
  grid-column: 2;
}

.finance-kpi-wide {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.finance-card {
  border-radius: 14px;
  background: #ffffff;
}

.finance-main-grid {
  grid-template-columns: minmax(430px, 1fr) minmax(430px, 1fr);
  gap: 14px;
}

.finance-form-inline {
  grid-template-columns: minmax(230px, 1.2fr) 120px minmax(150px, 0.85fr) minmax(150px, 0.85fr) minmax(150px, 0.85fr) 130px minmax(180px, 1fr) 170px;
  border-radius: 14px;
  background: #f8fbff;
}

.finance-period-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 14px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  min-height: 40px;
  padding: 4px 6px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: #ffffff;
}

.finance-period-field > span {
  height: 1px;
  background: var(--line-strong);
}

.finance-period-field input {
  min-width: 0;
  padding-right: 2px;
  padding-left: 2px;
}

.finance-structure {
  grid-template-columns: minmax(240px, 0.8fr) minmax(250px, 1fr);
}

.pnl-row {
  min-height: 41px;
}

.expense-item {
  border-radius: 12px;
  background: #ffffff;
}

@media (max-width: 1420px) {
  .filters-panel {
    grid-template-areas:
      "ranges"
      "controls"
      "check"
      "status";
    grid-template-columns: 1fr;
  }

  .filter-row {
    grid-template-columns: minmax(330px, 1fr) minmax(220px, 0.7fr) 150px 150px;
  }
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: 1fr;
    height: auto;
    padding: 14px;
    border-right: 0;
    border-bottom: 1px solid #dfe7f1;
  }

  .nav {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 4px;
    border: 1px solid #dfe7f1;
    border-radius: 13px;
    background: #ffffff;
  }

  .nav-item {
    width: auto;
    white-space: nowrap;
  }

  .sidebar-note {
    display: none;
  }

  .workspace {
    padding: 18px;
  }

  .filter-row,
  .finance-form-inline {
    grid-template-columns: 1fr 1fr;
  }

  .filter-row .primary-button,
  .filter-row .ghost-button,
  .finance-form-inline .primary-button {
    width: 100%;
  }

  .finance-main-grid,
  .focused-charts,
  .finance-structure {
    grid-template-columns: 1fr;
  }

  .daily-flow-panel,
  .profit-donut-panel {
    grid-column: auto !important;
  }
}

@media (max-width: 760px) {
  .topbar {
    display: grid;
  }

  .filter-row,
  .finance-form-inline,
  .quick-expense,
  .finance-filters,
  .finance-period-field {
    grid-template-columns: 1fr;
  }

  .date-range-control,
  .expense-date-range {
    grid-template-columns: 1fr;
  }

  .date-range-control > span,
  .expense-date-range > span,
  .finance-period-field > span {
    display: none;
  }

  .kpi-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .metric-card {
    min-height: 96px;
  }

.offer-profit-card {
  grid-template-columns: 1fr;
}
}

/* Финансовые KPI — Чистая прибыль/Приход/Маржа/Выкуп/Расходы/Реклама — только на офферах.
 * На Статистике, Графиках, Воронке, Менеджерах и других — скрываем (там свой контент). */
body:not([data-view="offers"]) .kpi-grid-hero,
body:not([data-view="offers"]) .kpi-grid-secondary {
  display: none !important;
}

/* Offers overview: main working screen */
body[data-view="offers"] .kpi-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 10px;
}

body[data-view="offers"] .expense-metric {
  display: none;
}

body[data-view="offers"] .metric-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto auto;
  column-gap: 8px;
  align-items: start;
  min-height: 0;
  padding: 12px 14px 11px;
  border: 1px solid #dfe7f1;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #fcfdff 100%);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.045);
}

body[data-view="offers"] .metric-card::after {
  display: none;
}

body[data-view="offers"] .metric-card span {
  grid-column: 1;
  color: #1b2738;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
}

body[data-view="offers"] .metric-card strong {
  grid-column: 1 / -1;
  margin-top: 5px;
  font-size: clamp(24px, 1.8vw, 34px);
  line-height: 1.02;
}

body[data-view="offers"] .metric-card small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 500;
  color: #5b6473;
  letter-spacing: 0;
  text-transform: none;
}

body[data-view="offers"] .primary-profit-card strong {
  color: #0f9f6e;
}

body[data-view="offers"] .revenue-card strong {
  color: #0b4ea2;
}

body[data-view="offers"] .metric-split {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}

body[data-view="offers"] .metric-split small {
  display: inline-flex;
  align-items: center;
  margin-top: 0;
}

body[data-view="offers"] .metric-split small + small {
  padding-left: 10px;
  border-left: 1px solid #dfe7f1;
}

body[data-view="offers"] .kpi-delta {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #eef8f3;
  color: #0f9f6e;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1;
  white-space: nowrap;
}

body[data-view="offers"] .kpi-delta.negative {
  background: #fff0f1;
  color: #e2474f;
}

body[data-view="offers"] .kpi-delta.is-empty {
  display: none;
}

.kpi-spark {
  grid-column: 1 / -1;
  align-self: end;
  min-height: 24px;
  margin-top: 5px;
}

.kpi-spark .chart-sparkline {
  display: block;
  height: 27px;
  margin: 0;
}

.offers-overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(340px, 0.9fr);
  gap: 16px;
  margin-bottom: 16px;
}

.offer-dashboard-panel {
  min-width: 0;
  padding: 18px;
  border: 1px solid #dfe7f1;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.055);
}

.offer-trend-panel canvas {
  width: 100% !important;
  height: 260px !important;
}

.offer-expense-list {
  display: grid;
  gap: 10px;
}







@media (max-width: 1180px) {
  body[data-view="offers"] .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .offers-overview-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  body[data-view="offers"] .kpi-grid {
    grid-template-columns: 1fr;
  }

  .offer-expense-row {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .offer-expense-row .chart-sparkline {
    grid-column: 1 / -1;
    width: 100%;
  }
}

/* Finance report layout inspired by the working P&L reference */
body[data-view="finance"] .kpi-grid {
  display: none;
}

body[data-view="finance"] .workspace {
  background:
    radial-gradient(circle at 28% 0%, rgba(35, 104, 209, 0.07), transparent 28%),
    radial-gradient(circle at 78% 12%, rgba(15, 159, 110, 0.045), transparent 28%),
    #f7faff;
}

body[data-view="finance"] .topbar {
  margin-bottom: 12px;
}

body[data-view="finance"] .filters-panel {
  margin-bottom: 14px;
}

.finance-report-panel {
  padding: 18px;
  border-radius: 18px;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.finance-title-row {
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
}

.finance-title-row h2 {
  font-size: 22px;
}

.finance-kpi-wide {
  grid-template-columns: minmax(260px, 1.35fr) repeat(4, minmax(132px, 1fr));
  align-items: stretch;
  gap: 8px;
  margin-bottom: 10px;
}

.finance-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 86px;
  padding: 10px 12px;
  border-color: #dfe7f1;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #fbfdff);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
}

.finance-card strong {
  margin-top: 5px;
  font-size: clamp(19px, 1.12vw, 25px);
  letter-spacing: 0;
}

.finance-card small {
  color: #657189;
  font-size: 11px;
  line-height: 1.2;
}

.expense-total-card strong {
  color: #dc3e4f;
}

.finance-card.finance-profit-hero {
  position: relative;
  overflow: hidden;
  justify-content: flex-start;
  min-height: 96px;
  padding: 12px 14px 34px;
  background:
    radial-gradient(circle at 80% 62%, rgba(15, 103, 255, 0.34), transparent 28%),
    linear-gradient(135deg, #071c3d 0%, #051127 58%, #082d62 100%);
  color: #ffffff;
}

.finance-card.finance-profit-hero::before {
  content: "";
  position: absolute;
  right: -40px;
  bottom: 18px;
  width: 170px;
  height: 72px;
  border-radius: 50%;
  border: 1px solid rgba(94, 169, 255, 0.18);
  box-shadow:
    0 -12px 0 rgba(94, 169, 255, 0.04),
    0 -24px 0 rgba(94, 169, 255, 0.035),
    0 -36px 0 rgba(94, 169, 255, 0.03);
}

.finance-card.finance-profit-hero span,
.finance-card.finance-profit-hero small {
  position: relative;
  z-index: 1;
  color: rgba(255, 255, 255, 0.82);
}

.finance-card.finance-profit-hero strong {
  position: relative;
  z-index: 1;
  margin-top: 7px;
  color: #ffffff !important;
  font-size: clamp(26px, 2vw, 36px);
  text-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
}

.finance-hero-spark {
  position: absolute;
  right: 14px;
  bottom: 8px;
  left: 14px;
  height: 26px;
  z-index: 1;
}

.finance-hero-spark .chart-sparkline {
  display: block;
  grid-column: auto;
  width: 100%;
  height: 100%;
  margin: 0;
  filter: drop-shadow(0 8px 12px rgba(94, 234, 212, 0.16));
}

.finance-hero-spark .chart-sparkline polyline {
  stroke-width: 3.4;
}

.finance-mini-card {
  display: none;
}

.finance-main-grid {
  grid-template-columns: minmax(460px, 1.35fr) minmax(420px, 1fr) minmax(270px, 0.78fr);
  gap: 14px;
}

.finance-trend-panel {
  min-height: 330px;
  grid-column: span 1;
}

.finance-trend-panel canvas {
  width: 100% !important;
  height: 250px !important;
}

.structure-panel {
  min-height: 330px;
}

.finance-structure {
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.finance-structure canvas {
  width: 190px !important;
  height: 190px !important;
}

.finance-structure-list {
  min-width: 0;
  max-height: none;
  overflow: visible;
  padding-right: 2px;
}

.finance-structure .structure-row {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 8px;
  padding: 7px 9px;
  border-radius: 12px;
  background: #ffffff;
}

.finance-structure .structure-row span {
  overflow: hidden;
  font-size: 12px;
  line-height: 1.2;
  text-overflow: clip;
  white-space: normal;
}

.finance-structure .structure-row strong {
  font-size: 12px;
  white-space: nowrap;
}

.finance-structure .structure-row em {
  grid-column: 1 / -1;
  justify-self: end;
  font-size: 11px;
  font-weight: 800;
}

.finance-insights-panel {
  min-height: 330px;
}

.finance-insights {
  display: grid;
  gap: 9px;
}

.finance-insight {
  position: relative;
  display: grid;
  gap: 4px;
  min-height: 60px;
  padding: 11px 12px 11px 42px;
  border: 1px solid #dfe7f1;
  border-radius: 13px;
  background: #ffffff;
}

.finance-insight::before {
  content: "";
  position: absolute;
  top: 15px;
  left: 14px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #2368d1;
  box-shadow: 0 0 0 5px rgba(35, 104, 209, 0.1);
}

.finance-insight.good::before {
  background: #0f9f6e;
  box-shadow: 0 0 0 5px rgba(15, 159, 110, 0.1);
}

.finance-insight.warn::before {
  background: #ff7a1a;
  box-shadow: 0 0 0 5px rgba(255, 122, 26, 0.12);
}

.finance-insight.bad::before {
  background: #ef4444;
  box-shadow: 0 0 0 5px rgba(239, 68, 68, 0.12);
}

.finance-insight strong {
  font-size: 13px;
}

.finance-insight span {
  color: #697386;
  font-size: 12px;
  line-height: 1.35;
}

.pnl-panel {
  grid-column: span 2;
}

.finance-journal-form {
  grid-column: span 3;
  grid-template-columns: minmax(230px, 1.15fr) 120px minmax(155px, 0.85fr) minmax(155px, 0.85fr) minmax(155px, 0.85fr) 135px minmax(190px, 1fr) 170px;
  margin-bottom: 0;
  border-radius: 15px;
  background: #f8fbff;
}

.finance-history-panel {
  grid-column: span 2;
}

.finance-table-panel .table-wrap {
  box-shadow: none;
}

.finance-main-grid .finance-table-panel {
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #fcfdff);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.045);
}

.pnl-row {
  grid-template-columns: minmax(0, 1fr) 142px 76px;
  min-height: 40px;
}

.pnl-row.grand {
  padding: 10px 0;
  border-radius: 10px;
  background: rgba(15, 159, 110, 0.08);
  border-top: 0;
}


@media (max-width: 1500px) {
  .finance-kpi-wide {
    grid-template-columns: minmax(240px, 1.3fr) repeat(4, minmax(124px, 1fr));
  }

  .finance-main-grid {
    grid-template-columns: minmax(430px, 1.25fr) minmax(340px, 0.9fr);
  }

  .finance-insights-panel,
  .finance-history-panel,
  .finance-journal-form {
    grid-column: span 2;
  }

  .pnl-panel {
    grid-column: span 1;
  }
}

@media (max-width: 1120px) {
  .finance-main-grid {
    grid-template-columns: 1fr;
  }

  .finance-kpi-wide {
    grid-template-columns: minmax(230px, 1.2fr) repeat(2, minmax(132px, 1fr));
  }

  .finance-profit-hero,
  .finance-insights-panel,
  .finance-history-panel,
  .finance-journal-form,
  .pnl-panel {
    grid-column: auto;
  }

  .finance-journal-form {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .finance-kpi-wide,
  .finance-journal-form,
  .finance-structure {
    grid-template-columns: 1fr;
  }

  .finance-profit-hero {
    min-height: 108px;
  }
}

/* Charts analytics screen */
body[data-view="charts"] .kpi-grid {
  display: none;
}

body[data-view="charts"] .workspace {
  background:
    radial-gradient(circle at 28% 0%, rgba(35, 104, 209, 0.06), transparent 30%),
    radial-gradient(circle at 88% 14%, rgba(15, 159, 110, 0.04), transparent 28%),
    #f7faff;
}


.chart-metric-card {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px 12px;
  min-height: 142px;
  padding: 17px 18px 13px;
  overflow: hidden;
  border: 1px solid #dfe7f1;
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #fbfdff);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.048);
}

.chart-metric-card::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 42px;
  background: linear-gradient(180deg, transparent, rgba(35, 104, 209, 0.045));
  pointer-events: none;
}

.chart-metric-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  color: #ffffff;
  background: #2368d1;
  box-shadow: 0 10px 22px rgba(35, 104, 209, 0.2);
}

.chart-metric-icon svg {
  width: 18px;
  height: 18px;
}

.chart-metric-card.green .chart-metric-icon { background: #0f9f6e; }
.chart-metric-card.violet .chart-metric-icon { background: #7c4dff; }
.chart-metric-card.teal .chart-metric-icon { background: #00a6b2; }
.chart-metric-card.orange .chart-metric-icon { background: #ff9f3f; }

.chart-metric-card span {
  display: block;
  color: #1a2433;
  font-size: 13px;
  font-weight: 850;
}

.chart-metric-card strong {
  display: block;
  margin-top: 7px;
  font-size: clamp(24px, 2.1vw, 30px);
  line-height: 1;
}

.chart-metric-card small {
  display: block;
  margin-top: 7px;
  color: #0f9f6e;
  font-size: 12px;
  font-weight: 800;
}

.chart-metric-card.red small,
.chart-metric-card.orange small {
  color: #ff7a1a;
}

.chart-sparkline {
  position: relative;
  z-index: 1;
  grid-column: 1 / -1;
  width: 100%;
  height: 38px;
  margin-top: 2px;
}








body[data-view="charts"] .chart-legend {
  max-height: 128px;
}

body[data-view="charts"] .legend-pill {
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 5px 8px;
  border-radius: 12px;
}

body[data-view="charts"] .legend-pill em {
  grid-column: 2 / -1;
  font-weight: 800;
}

.chart-funnel {
  display: grid;
  gap: 13px;
}

.funnel-visual {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 4px 0;
}

.chart-funnel-stage {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  min-height: 50px;
  padding: 9px 18px;
  border: 2px solid currentColor;
  color: #2368d1;
  background: linear-gradient(180deg, rgba(35, 104, 209, 0.16), rgba(35, 104, 209, 0.06));
  clip-path: polygon(0 0, 100% 0, 90% 100%, 10% 100%);
}

.chart-funnel-stage.green {
  color: #0f9f6e;
  background: linear-gradient(180deg, rgba(15, 159, 110, 0.16), rgba(15, 159, 110, 0.06));
}

.chart-funnel-stage.red {
  color: #ef4444;
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.14), rgba(239, 68, 68, 0.05));
}

.chart-funnel-stage strong,
.chart-funnel-stage span {
  font-size: 15px;
  font-weight: 900;
}

.funnel-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid #dfe7f1;
}

.funnel-metrics div {
  display: grid;
  gap: 2px;
  padding: 10px;
  border-right: 1px solid #dfe7f1;
  text-align: center;
}

.funnel-metrics div:last-child {
  border-right: 0;
}

.funnel-metrics strong {
  font-size: 22px;
}

.funnel-metrics span,
.chart-funnel p {
  color: #697386;
  font-size: 12px;
  font-weight: 750;
}

.chart-funnel p {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f8fbff;
}






.chart-key-card {
  display: grid;
  gap: 6px;
  min-height: 74px;
  padding: 16px 18px 16px 56px;
  border-right: 1px solid #dfe7f1;
  position: relative;
}

.chart-key-card:last-child {
  border-right: 0;
}

.chart-key-card::before {
  content: "";
  position: absolute;
  left: 20px;
  top: 22px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #2368d1;
  box-shadow: 0 0 0 7px rgba(35, 104, 209, 0.1);
}

.chart-key-card.green::before { background: #0f9f6e; box-shadow: 0 0 0 7px rgba(15, 159, 110, 0.1); }
.chart-key-card.violet::before { background: #7c4dff; box-shadow: 0 0 0 7px rgba(124, 77, 255, 0.1); }
.chart-key-card.orange::before { background: #ff7a1a; box-shadow: 0 0 0 7px rgba(255, 122, 26, 0.12); }

.chart-key-card strong {
  font-size: 13px;
}

.chart-key-card span {
  color: #697386;
  font-size: 12px;
  line-height: 1.35;
}

@media (max-width: 1320px) {
  body[data-view="charts"] .chart-insight-strip {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
  }

  body[data-view="charts"] .focused-charts.chart-dashboard-grid,
  .chart-key-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body[data-view="charts"] .daily-flow-panel {
    grid-column: 1 / -1 !important;
  }
}

@media (max-width: 760px) {
  body[data-view="charts"] .chart-insight-strip,
  body[data-view="charts"] .focused-charts.chart-dashboard-grid,
  .chart-key-strip {
    grid-template-columns: 1fr;
  }

  .chart-key-card {
    border-right: 0;
    border-bottom: 1px solid #dfe7f1;
  }

  .chart-key-card:last-child {
    border-bottom: 0;
  }
}

/* Charts 2 reference dashboard */
body[data-view="charts2"] .kpi-grid {
  display: none;
}

body[data-view="charts2"] .workspace {
  background:
    radial-gradient(circle at 28% 0%, rgba(35, 104, 209, 0.055), transparent 31%),
    radial-gradient(circle at 86% 12%, rgba(124, 77, 255, 0.04), transparent 28%),
    #f7faff;
}

.charts2-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.charts2-kpi-card {
  position: relative;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px 14px;
  min-height: 116px;
  padding: 16px 18px 12px;
  overflow: hidden;
  border: 1px solid #dfe7f1;
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #fcfdff);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.048);
}

.charts2-kpi-card .chart-metric-icon {
  width: 48px;
  height: 48px;
  align-self: start;
}

.charts2-kpi-card .chart-metric-icon svg {
  width: 22px;
  height: 22px;
}

.charts2-kpi-card span {
  display: block;
  color: #536176;
  font-size: 12px;
  font-weight: 850;
}

.charts2-kpi-card strong {
  display: block;
  margin-top: 6px;
  color: #132033;
  font-size: clamp(24px, 2.1vw, 30px);
  line-height: 1;
}

.charts2-kpi-card small {
  display: block;
  margin-top: 7px;
  color: #0f9f6e;
  font-size: 12px;
  font-weight: 800;
}

.charts2-kpi-card.red small {
  color: #ef4444;
}

.charts2-kpi-card .chart-sparkline {
  grid-column: 2;
  height: 26px;
  margin-top: 1px;
}

.charts2-kpi-card.blue .chart-metric-icon { background: #2368d1; }
.charts2-kpi-card.green .chart-metric-icon { background: #0f9f6e; }
.charts2-kpi-card.violet .chart-metric-icon { background: #7c4dff; }
.charts2-kpi-card.teal .chart-metric-icon { background: #00a6b2; }
.charts2-kpi-card.red .chart-metric-icon { background: #ef4444; }

.charts2-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
}

.charts2-panel {
  min-height: 300px;
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #fcfdff);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.048);
}

.charts2-panel .panel-header {
  margin-bottom: 10px;
}

.charts2-panel .panel-header h2 {
  font-size: 17px;
}

.chart-small-select {
  min-width: 98px;
  height: 34px;
  padding: 0 28px 0 12px;
  border: 1px solid #d7e1ee;
  border-radius: 10px;
  background: #ffffff;
  color: #132033;
  font-size: 12px;
  font-weight: 800;
}

.panel-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid #d7e1ee;
  border-radius: 10px;
  background: #ffffff;
  color: #536176;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.panel-check input {
  width: 15px;
  min-height: 15px;
  accent-color: #2368d1;
}

.panel-check span {
  color: #536176;
  font-size: 12px;
  font-weight: 850;
  text-transform: none;
}

.charts2-trend-panel,
.charts2-waterfall-panel,
.charts2-compare-panel,
.charts2-heatmap-panel {
  grid-column: span 3;
}

.charts2-loss-panel {
  grid-column: span 2;
}

.charts2-conversion-panel {
  grid-column: span 2;
}

.charts2-insights-panel {
  grid-column: span 2;
}

.charts2-trend-panel canvas,
.charts2-compare-panel canvas {
  width: 100% !important;
  height: 248px !important;
}

.charts2-stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid #dfe7f1;
  border-radius: 12px;
  background: #fbfdff;
}

.charts2-stat-row div {
  display: grid;
  gap: 4px;
  min-height: 56px;
  padding: 10px 14px;
  border-right: 1px solid #dfe7f1;
}

.charts2-stat-row div:last-child {
  border-right: 0;
}

.charts2-stat-row span {
  color: #697386;
  font-size: 11px;
  font-weight: 800;
}

.charts2-stat-row strong {
  color: #132033;
  font-size: 15px;
  line-height: 1.15;
}

.charts2-stat-row strong.green {
  color: #0f9f6e;
}

.charts2-stat-row strong.orange {
  color: #ff7a1a;
}

.charts2-waterfall {
  display: grid;
  grid-template-columns: repeat(7, minmax(70px, 1fr));
  gap: 8px;
  min-height: 230px;
  align-items: end;
  padding: 8px 8px 0;
}

.waterfall-step {
  display: grid;
  gap: 8px;
  min-width: 0;
  text-align: center;
}

.waterfall-bar-wrap {
  position: relative;
  display: flex;
  height: 170px;
  align-items: end;
  justify-content: center;
  padding-top: 30px;
  border-bottom: 1px solid #cfd9e8;
}

.waterfall-bar-wrap b {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 2;
  transform: translateX(-50%);
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  white-space: nowrap;
  font-size: 11px;
  line-height: 1.15;
  box-shadow: 0 1px 5px rgba(15, 23, 42, 0.06);
}

.waterfall-bar {
  display: block;
  width: min(58px, 78%);
  max-height: calc(100% - 34px);
  min-height: 6px;
  border-radius: 7px 7px 0 0;
  background: #2368d1;
  box-shadow: 0 10px 18px rgba(35, 104, 209, 0.16);
}

.waterfall-step.red .waterfall-bar {
  background: #ef5b5b;
  box-shadow: 0 10px 18px rgba(239, 68, 68, 0.12);
}

.waterfall-step.green .waterfall-bar {
  background: #0f9f6e;
  box-shadow: 0 10px 18px rgba(15, 159, 110, 0.12);
}

.waterfall-step.gray .waterfall-bar {
  background: #94a3b8;
  box-shadow: none;
}

.waterfall-step strong {
  min-height: 30px;
  color: #132033;
  font-size: 11px;
  line-height: 1.2;
}

.waterfall-guide {
  position: absolute;
  top: 32px;
  left: -50%;
  width: 100%;
  border-top: 1px dashed rgba(100, 116, 139, 0.45);
}

.heatmap-scale {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #697386;
  font-size: 11px;
  font-weight: 800;
}

.heatmap-scale i {
  width: 16px;
  height: 10px;
  border-radius: 2px;
  background: rgba(15, 159, 110, 0.18);
}

.heatmap-scale i:nth-of-type(2) { background: rgba(15, 159, 110, 0.3); }
.heatmap-scale i:nth-of-type(3) { background: rgba(15, 159, 110, 0.44); }
.heatmap-scale i:nth-of-type(4) { background: rgba(15, 159, 110, 0.62); }
.heatmap-scale i:nth-of-type(5) { background: rgba(15, 159, 110, 0.82); }

.charts2-heatmap {
  overflow: auto;
}

.heatmap-table {
  display: grid;
  grid-template-columns: 88px repeat(var(--heatmap-cols), minmax(72px, 1fr));
  min-width: 620px;
  overflow: hidden;
  border: 1px solid #dfe7f1;
  border-radius: 13px;
}

.heatmap-table > * {
  min-height: 34px;
  padding: 9px 10px;
  border-right: 1px solid #ffffff;
  border-bottom: 1px solid #ffffff;
  color: #132033;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.heatmap-table > b {
  text-align: left;
  background: #f8fbff;
}

.heatmap-table > strong,
.heatmap-corner {
  background: #f8fbff;
  color: #536176;
}

.charts2-loss-layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.charts2-loss-layout canvas {
  width: 210px !important;
  height: 210px !important;
}

.charts2-loss-layout .chart-legend {
  max-height: none;
}

.charts2-loss-layout .legend-pill {
  gap: 3px 8px;
  padding: 7px 9px;
}

.charts2-loss-layout .legend-pill strong {
  font-size: 11.5px;
  line-height: 1.15;
}

.charts2-loss-layout .legend-pill em {
  font-size: 10.5px;
  line-height: 1.15;
}

.charts2-conversion {
  display: grid;
  gap: 18px;
}

.conversion-counts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
}

.conversion-counts div {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid #dfe7f1;
  border-radius: 12px;
  background: #f8fbff;
}

.conversion-counts span {
  color: #536176;
  font-size: 12px;
  font-weight: 800;
}

.conversion-counts strong {
  font-size: 22px;
}

.conversion-flow {
  display: grid;
  gap: 10px;
  justify-items: start;
}

.conversion-flow i {
  display: block;
  min-width: 48px;
  height: 36px;
  border-radius: 0 18px 18px 0;
}

.conversion-flow .blue {
  background: linear-gradient(90deg, #2368d1, rgba(35, 104, 209, 0.55));
}

.conversion-flow .green {
  background: linear-gradient(90deg, #0f9f6e, rgba(15, 159, 110, 0.55));
}

.conversion-flow .red {
  background: linear-gradient(90deg, #ef4444, rgba(239, 68, 68, 0.55));
}

.conversion-note {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr;
  gap: 6px;
  align-items: baseline;
  justify-content: center;
  color: #697386;
}

.conversion-note strong {
  color: #132033;
  font-size: 18px;
}

.charts2-conversion p {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f8fbff;
  color: #536176;
  font-size: 12px;
  font-weight: 800;
}

.charts2-insights {
  display: grid;
  gap: 9px;
}

.charts2-insight {
  position: relative;
  display: grid;
  gap: 4px;
  min-height: 52px;
  padding: 10px 12px 10px 42px;
  border: 1px solid #dfe7f1;
  border-radius: 12px;
  background: #ffffff;
}

.charts2-insight::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 15px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #2368d1;
  box-shadow: 0 0 0 5px rgba(35, 104, 209, 0.1);
}

.charts2-insight.green::before { background: #0f9f6e; box-shadow: 0 0 0 5px rgba(15, 159, 110, 0.1); }
.charts2-insight.orange::before { background: #ff7a1a; box-shadow: 0 0 0 5px rgba(255, 122, 26, 0.12); }
.charts2-insight.red::before { background: #ef4444; box-shadow: 0 0 0 5px rgba(239, 68, 68, 0.12); }
.charts2-insight.violet::before { background: #7c4dff; box-shadow: 0 0 0 5px rgba(124, 77, 255, 0.1); }

.charts2-insight strong {
  font-size: 13px;
}

.charts2-insight span {
  color: #697386;
  font-size: 12px;
  line-height: 1.35;
}

@media (max-width: 1420px) {
  .charts2-kpis {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
  }

  .charts2-trend-panel,
  .charts2-waterfall-panel,
  .charts2-compare-panel,
  .charts2-heatmap-panel,
  .charts2-loss-panel,
  .charts2-conversion-panel,
  .charts2-insights-panel {
    grid-column: span 6;
  }
}

@media (max-width: 760px) {
  .charts2-kpis,
  .charts2-stat-row,
  .conversion-counts {
    grid-template-columns: 1fr;
  }

  .charts2-loss-layout {
    grid-template-columns: 1fr;
  }

  .charts2-waterfall {
    grid-template-columns: repeat(7, 82px);
    overflow: auto;
  }
}

/* ============================================================ */
/* ===     MODERN THEME OVERRIDE — v2026-05-11               === */
/* ===     Полная переработка визуала                        === */
/* ============================================================ */

body {
  background: var(--bg-grad);
  font-feature-settings: 'cv11', 'ss03';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Sidebar ===== */
.sidebar {
  padding: 22px 14px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #fbfcfe 0%, #f6f8fc 100%);
  backdrop-filter: blur(20px);
}

.brand {
  margin-bottom: 28px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--blue) 0%, var(--violet) 100%);
  color: #ffffff;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.02em;
  box-shadow: 0 4px 12px -2px rgba(79, 70, 229, 0.4);
}

.brand strong {
  font-size: 15px;
  letter-spacing: -0.01em;
  font-weight: 700;
}

.brand span {
  font-size: 11.5px;
  font-weight: 500;
}

.nav-item {
  position: relative;
  min-height: 38px;
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  color: #475569;
  transition: all 0.15s ease;
}

.nav-item:hover {
  background: rgba(79, 70, 229, 0.06);
  color: var(--blue-dark);
}

.nav-item.active {
  background: linear-gradient(135deg, #eef2ff 0%, #ede9fe 100%);
  color: var(--blue-dark);
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.08);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--blue), var(--violet));
}

.nav-item svg {
  width: 17px;
  height: 17px;
  opacity: 0.88;
}

.sidebar-note {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(135deg, #ffffff, #f8fafc);
  box-shadow: var(--shadow-xs);
}

/* ===== Topbar ===== */
.workspace {
  padding: 24px 28px 32px;
}

.topbar {
  margin-bottom: 18px;
}

h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.eyebrow {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--blue);
  letter-spacing: 0.08em;
}

.status-pill {
  border-radius: 999px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-xs);
  font-size: 12.5px;
  font-weight: 600;
}

.status-pill .dot {
  width: 7px;
  height: 7px;
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
  animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ===== Filters Panel ===== */
.filters-panel {
  border-radius: var(--radius-md);
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.quick-ranges {
  background: #f1f5f9;
  border: 0;
  padding: 4px;
  border-radius: 10px;
}

.range-button {
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  transition: all 0.15s ease;
}

.range-button.active {
  background: #ffffff;
  color: var(--blue);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
}

.range-button:hover {
  color: var(--text);
}

.date-range-control {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  transition: all 0.15s;
}

.date-range-control:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.date-range-control > svg {
  color: var(--blue);
}

input,
select {
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

label {
  font-size: 11px;
  letter-spacing: 0.06em;
}

/* ===== Buttons ===== */
.primary-button {
  background: linear-gradient(135deg, var(--blue) 0%, var(--indigo) 100%);
  border-radius: 10px;
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: -0.005em;
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.25), 0 4px 12px -2px rgba(79, 70, 229, 0.25);
  transition: all 0.18s ease;
}

.primary-button:hover {
  background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue) 100%);
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3), 0 6px 16px -2px rgba(79, 70, 229, 0.35);
  transform: translateY(-1px);
}

.primary-button:active {
  transform: translateY(0);
}

.ghost-button {
  border-radius: 10px;
  font-weight: 600;
  font-size: 13.5px;
  transition: all 0.15s ease;
}

.ghost-button:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-soft);
}

/* ===== KPI Grid ===== */
.kpi-grid {
  gap: 14px;
  margin-bottom: 16px;
}

.metric-card {
  position: relative;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  overflow: hidden;
}

.metric-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.metric-card::after {
  display: none; /* убираем старую нижнюю полоску */
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 4px;
  background: var(--blue);
  opacity: 0.85;
}

.metric-card:nth-child(1)::before { background: linear-gradient(180deg, var(--green) 0%, #10b981 100%); }
.metric-card:nth-child(2)::before { background: linear-gradient(180deg, var(--blue) 0%, var(--indigo) 100%); }
.metric-card:nth-child(3)::before { background: linear-gradient(180deg, var(--amber) 0%, #f59e0b 100%); }
.metric-card:nth-child(4)::before { background: linear-gradient(180deg, var(--violet) 0%, var(--pink) 100%); }
.metric-card.expense-metric::before {
  background: linear-gradient(180deg, #94a3b8 0%, #cbd5e1 100%);
  width: 3px;
}

.metric-card span {
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}

.metric-card strong {
  font-size: 27px;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  margin-top: 8px;
}

.metric-card small {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin-top: 6px;
}

.primary-profit-card {
  background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
  border-color: #bbf7d0;
}

.primary-profit-card strong {
  background: linear-gradient(135deg, var(--green) 0%, #059669 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.revenue-card {
  background: linear-gradient(135deg, #ffffff 0%, #eff6ff 100%);
  border-color: #bfdbfe;
}

.buyout-card {
  background: linear-gradient(135deg, #ffffff 0%, #fffbeb 100%);
  border-color: #fde68a;
}

.margin-card {
  background: linear-gradient(135deg, #ffffff 0%, #faf5ff 100%);
  border-color: #ddd6fe;
}

.kpi-delta {
  position: absolute;
  top: 14px;
  right: 18px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  font-style: normal;
  background: var(--surface-muted);
  color: var(--muted);
}

.kpi-delta.positive {
  background: #d1fae5;
  color: #047857;
}

.kpi-delta.negative {
  background: #fee2e2;
  color: #b91c1c;
}

/* ===== Panels (Charts/Tables) ===== */
.chart-panel,
.view-panel,
.expense-form,
.expenses-list-panel,
.finance-report-panel,
.finance-form,
.finance-table-panel {
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
}

.chart-panel:hover,
.finance-table-panel:hover {
  box-shadow: var(--shadow-md);
}

.chart-panel {
  padding: 18px 20px;
}

.panel-header {
  margin-bottom: 14px;
}

.panel-header span {
  font-size: 11px;
  letter-spacing: 0.07em;
  color: var(--blue);
  font-weight: 700;
}

.panel-header h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text);
  margin-top: 4px;
}


/* ===== Tables ===== */
.report-table,
.finance-table {
  border-collapse: separate;
  border-spacing: 0;
}

.report-table thead th,
.finance-table thead th {
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1;
}

.report-table tbody td,
.finance-table tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
  color: var(--text);
}

.report-table tbody tr,
.finance-table tbody tr {
  transition: background 0.12s;
}

.report-table tbody tr:hover,
.finance-table tbody tr:hover {
  background: var(--blue-soft);
}

.report-table tfoot td {
  padding: 14px 12px;
  background: linear-gradient(135deg, #eef2ff 0%, #f8fafc 100%);
  font-weight: 700;
  font-size: 13.5px;
  border-top: 2px solid var(--blue);
}

/* ===== Stats tiles ===== */
.stat-tile {
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  padding: 16px 18px;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.stat-tile:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.stat-tile::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--blue), var(--indigo));
  opacity: 0.8;
}

.stat-tile:nth-child(2)::before { background: linear-gradient(90deg, var(--green), #10b981); }
.stat-tile:nth-child(3)::before { background: linear-gradient(90deg, var(--amber), #f59e0b); }
.stat-tile:nth-child(4)::before { background: linear-gradient(90deg, var(--violet), var(--pink)); }
.stat-tile:nth-child(5)::before { background: linear-gradient(90deg, var(--teal), #14b8a6); }
.stat-tile:nth-child(6)::before { background: linear-gradient(90deg, var(--orange), var(--red)); }

.stat-tile span {
  font-size: 11px;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--muted);
}

.stat-tile strong {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}


/* ===== Section hint / data status ===== */
.section-hint,
.data-status {
  border-radius: 10px;
  font-size: 12.5px;
  border: 1px solid #dbeafe;
  background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%);
  color: #4338ca;
  font-weight: 500;
}

/* ===== Toast ===== */
.toast {
  border-radius: var(--radius-md);
  background: var(--text);
  color: #ffffff;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  padding: 12px 18px;
}

/* ===== Quick expense / forms ===== */
.quick-expense-panel,
.expense-distribution-note {
  border-radius: var(--radius-md);
}

.expense-range-presets {
  background: #f1f5f9;
  border: 0;
  padding: 4px;
  border-radius: 10px;
}

.expense-range-button {
  font-weight: 600;
  font-size: 12.5px;
}

.expense-range-button.active {
  background: #ffffff;
  color: var(--blue);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

/* ===== Finance — Hero / KPIs ===== */
.finance-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.finance-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.finance-card.total,
.finance-profit-hero {
  background: linear-gradient(135deg, #4338ca 0%, #6d28d9 50%, #db2777 100%);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 8px 24px -4px rgba(67, 56, 202, 0.4), 0 4px 12px rgba(67, 56, 202, 0.25);
}

.finance-profit-hero span,
.finance-profit-hero small {
  color: rgba(255, 255, 255, 0.85);
}

.finance-profit-hero strong {
  color: #ffffff;
  font-size: 30px;
}

.finance-profit-hero::before {
  display: none;
}

.expense-total-card {
  background: linear-gradient(135deg, #ffffff 0%, #fef2f2 100%);
  border-color: #fecaca;
}

/* ===== Funnel bars ===== */
.funnel-bars > div {
  transition: all 0.2s ease;
}

/* ===== Insight lists ===== */
.insight-list {
  display: grid;
  gap: 10px;
}

/* ===== Legend pills (Charts) ===== */
.legend-pill {
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  transition: all 0.15s;
}

.legend-pill:hover {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 4px;
}

/* ===== Trend rows ===== */
.trend-row {
  border-radius: 10px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
}

.trend-track {
  height: 7px;
  background: #e2e8f0;
  border-radius: 999px;
}

.trend-track .blue { background: linear-gradient(90deg, var(--blue), var(--indigo)); }
.trend-track .green { background: linear-gradient(90deg, var(--green), #10b981); }
.trend-track .red { background: linear-gradient(90deg, var(--red), #f87171); }
.trend-track .amber { background: linear-gradient(90deg, var(--amber), #f59e0b); }

/* ===== Smooth scroll on tabs ===== */
.view-panel {
  animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Subtle scrollbars ===== */
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ===== Chart insight strip ===== */



/* ===== Charts2 enhancement ===== */
.charts2-panel {
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
}

.charts2-panel:hover {
  box-shadow: var(--shadow-md);
}

.charts2-insight {
  border-radius: 10px;
  background: var(--surface-muted);
  padding: 10px 12px;
  border: 1px solid var(--line);
}



/* ===== Settings list ===== */
.settings-list > div {
  padding: 12px;
  border-radius: 10px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
}

.settings-list strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
}

.settings-list span {
  color: var(--muted);
  font-size: 12.5px;
}

/* ===== Mobile / responsive tweaks ===== */
@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  
  .sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  
  .workspace {
    padding: 16px;
  }
  
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ===== Loading states ===== */
.primary-button:disabled {
  cursor: progress;
  opacity: 0.65;
  background: linear-gradient(135deg, #94a3b8, #64748b);
  box-shadow: none;
}

/* ===== Tabs / nav active subtle indicator ===== */
.nav-item.active::after {
  content: '';
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blue);
  opacity: 0;
}

/* ===== Empty state ===== */
.empty-mini {
  border-radius: 10px;
  background: var(--surface-muted);
  color: var(--muted);
  padding: 18px;
  font-size: 13px;
}

/* ===== Sparkline polish ===== */
.kpi-spark {
  margin-top: 10px;
  opacity: 0.7;
}

/* ===== Improve table sort cursor ===== */
.report-table thead th[data-sort-key] {
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.report-table thead th[data-sort-key]:hover {
  background: #eef2ff;
  color: var(--blue);
}

/* ===== Pin field hide for clean look ===== */
.pin-field {
  display: none;
}

/* ===== Quick visual fix for too-tight kpi-grid on smaller widths ===== */
@media (max-width: 1280px) {
  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 1100px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ============================================================ */
/* === OFFERS SECTION — match design v2026-05-11             === */
/* ============================================================ */

/* --- Sidebar: показываем только 6 пунктов как в эталоне --- */
.nav-item[data-view="charts2"],
.nav-item[data-view="cohorts"],
.nav-item[data-view="funnel"],
.nav-item[data-view="managers"],
.nav-item[data-view="plan"],
.nav-item[data-view="settings"] {
  display: none;
}

/* Sidebar note — статусы с цветными точками */
.sidebar-note {
  padding: 16px;
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-xs);
}

.sidebar-note > span {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.sidebar-note > strong {
  position: relative;
  padding-left: 18px;
  margin-top: 8px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
}

.sidebar-note > strong::before {
  content: '';
  position: absolute;
  left: 0;
  top: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.sidebar-note > strong:last-child::before {
  background: var(--red);
}

/* --- Status pill «Данные загружены» зелёная c галочкой --- */
.status-pill {
  background: #d1fae5;
  border-color: #6ee7b7;
  color: #047857;
}

.status-pill .dot {
  background: #059669;
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.18);
  width: 8px;
  height: 8px;
}

.status-pill::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23047857' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><path d='M20 6L9 17l-5-5'/></svg>");
  background-size: contain;
  background-repeat: no-repeat;
}

.status-pill.error {
  background: var(--red-soft);
  border-color: #fecaca;
  color: var(--red);
}

.status-pill.error::before {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23dc2626' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><line x1='18' y1='6' x2='6' y2='18'/><line x1='6' y1='6' x2='18' y2='18'/></svg>");
}

/* --- KPI карточки: delta-пилюля + «к пред. периоду» --- */
.metric-card {
  position: relative;
  min-height: 0;
  padding: 16px 18px 14px;
  overflow: hidden;
}

.kpi-delta {
  position: absolute;
  top: 18px;
  right: 20px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  font-style: normal;
  background: #f1f5f9;
  color: var(--muted);
  line-height: 1.4;
}

.kpi-delta.positive {
  background: #d1fae5;
  color: #047857;
}

.kpi-delta.negative {
  background: #fee2e2;
  color: #b91c1c;
}

.kpi-delta.neutral {
  background: #f1f5f9;
  color: var(--muted);
}

/* Подпись «к пред. периоду» */
.kpi-delta::after {
  content: 'к пред. периоду';
  position: absolute;
  top: 26px;
  right: 0;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}

.kpi-delta.is-empty {
  display: none;
}

.kpi-delta.is-empty::after {
  display: none;
}

/* Цвет цифры в карточках */
.primary-profit-card #kpiProfit {
  color: var(--green);
  background: none;
  -webkit-text-fill-color: var(--green);
  font-size: 30px;
}

.revenue-card #kpiRevenue {
  color: #2563eb;
  font-size: 30px;
}

.buyout-card #kpiBuyout {
  color: var(--text);
  font-size: 30px;
}

.margin-card #kpiMargin {
  color: var(--text);
  font-size: 30px;
}

.metric-card > small,
.metric-card .metric-split {
  margin-top: 8px;
}

.metric-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.metric-split small {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.metric-split small::before {
  content: attr(data-value);
}

.metric-card .kpi-spark {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 60px;
  margin: 0;
  opacity: 1;
}

.metric-card .kpi-spark svg {
  width: 100%;
  height: 100%;
}

.primary-profit-card .kpi-spark { filter: drop-shadow(0 -2px 8px rgba(16, 185, 129, 0.15)); }
.revenue-card .kpi-spark { filter: drop-shadow(0 -2px 8px rgba(37, 99, 235, 0.15)); }
.buyout-card .kpi-spark { filter: drop-shadow(0 -2px 8px rgba(139, 92, 246, 0.15)); }
.margin-card .kpi-spark { filter: drop-shadow(0 -2px 8px rgba(249, 115, 22, 0.15)); }

/* --- Кастомные цвета линий KPI sparkline --- */
.buyout-card .kpi-spark path[fill],
.buyout-card .kpi-spark path[stroke="#7c4dff"] {
  /* JS уже задаёт цвета, лишь корректируем */
}

/* --- Расходы и затраты — список с иконками --- */
.offer-expense-list {
  display: grid;
  gap: 8px;
  padding: 4px 0;
}



.expense-icon-box {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
}

.expense-icon-box svg {
  width: 22px;
  height: 22px;
}






/* Спрятать старый кружок-color marker */

/* --- Динамика прибыли по дням — заголовок + dropdown --- */
.offer-trend-panel {
  padding: 18px 20px;
}

.offer-trend-panel .panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Таблица «Офферы за период» — все колонки видны: Товар, Выкупы, Допродажи,
   Отказы, Возвраты, %выкупа, Ср.чек, Приход, Расход товара, Доставка возвратов,
   Закупка возвратов, Реклама, Реклама на отправку, Прибыль на отправку,
   Чистая прибыль, Чистая маржа. */

/* % выкупа цветовое кодирование */
.report-table td.buyout-good { color: var(--green); font-weight: 700; }
.report-table td.buyout-mid { color: var(--amber); font-weight: 700; }
.report-table td.buyout-bad { color: var(--red); font-weight: 700; }

.report-table tbody td strong {
  font-variant-numeric: tabular-nums;
}

/* --- Pagination footer --- */

/* --- Panel-header span — eyebrow color --- */
.offers-overview-grid .panel-header span {
  color: var(--blue);
}

/* Filters panel — учитывать закупку справа */
.filters-panel .check-row {
  margin-left: auto;
  white-space: nowrap;
}

@media (max-width: 1320px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .metric-card {
    min-height: 140px;
  }
}

@media (max-width: 760px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .offer-expense-row {
    grid-template-columns: 40px 1fr;
  }
  .expense-row-spark {
    display: none;
  }
}

/* ============================================================ */
/* === OFFERS — компактные расходы + цветовое кодирование    === */
/* ============================================================ */

/* --- Расходы и затраты: более компактно --- */
.offer-expense-list {
  gap: 6px;
  padding: 0;
}


.expense-icon-box {
  width: 36px;
  height: 36px;
  border-radius: 9px;
}

.expense-icon-box svg {
  width: 18px;
  height: 18px;
}





.offer-expenses-panel .panel-header {
  margin-bottom: 8px;
}

/* --- Усиление зелёного для прибыли и прибыли/отпр --- */
.report-table td.positive,
.report-table td.positive strong,
.finance-table td.positive,
.finance-table td.positive strong {
  color: #059669 !important;
  font-weight: 700;
}

.report-table td.negative,
.report-table td.negative strong {
  color: #dc2626 !important;
  font-weight: 700;
}

/* --- Маржа: оранжевый ниже 30%, зелёный выше --- */
.report-table td.margin-mid,
.report-table td.margin-mid strong {
  color: #ea580c !important;
  font-weight: 700;
}

/* --- % выкупа оттенки --- */
.report-table td.buyout-good,
.report-table td.buyout-good strong {
  color: #059669 !important;
  font-weight: 700;
}

.report-table td.buyout-mid,
.report-table td.buyout-mid strong {
  color: #ea580c !important;
  font-weight: 700;
}

.report-table td.buyout-bad,
.report-table td.buyout-bad strong {
  color: #dc2626 !important;
  font-weight: 700;
}

/* ============================================================ */
/* === FIX: sparkline не должен налазить на цифры в KPI      === */
/* ============================================================ */

.metric-card {
  min-height: 175px;
  padding: 18px 20px 60px; /* увеличенный нижний padding под sparkline */
  display: flex;
  flex-direction: column;
}

.metric-card .kpi-spark {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 50px;
  opacity: 0.55;
  margin: 0;
  pointer-events: none;
  z-index: 0;
}

.metric-card > * {
  position: relative;
  z-index: 1;
}

.metric-card strong {
  margin-top: 4px;
}

.metric-card .metric-split,
.metric-card > small {
  margin-top: auto; /* прижимаем мини-текст вверх sparkline */
  margin-bottom: 4px;
}

/* Скрыть «Отказы» в таблице офферов (4-я колонка) */
.report-table[data-sort-table="offers"] thead th:nth-child(4),
.report-table[data-sort-table="offers"] tbody td:nth-child(4),
.report-table[data-sort-table="offers"] tfoot td:nth-child(4) {
  display: none;
}

/* ============================================================ */
/* === LAYOUT FIX: filters-panel + Обновить не уплывает      === */
/* ============================================================ */

.filters-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
}

.quick-ranges {
  flex: 1 1 auto;
  width: auto;
  min-width: 320px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  flex: 1 1 100%;
}

.date-range-control {
  flex: 1 1 320px;
  min-width: 280px;
}

.offer-field {
  flex: 1 1 200px;
  min-width: 180px;
}

.primary-button,
.ghost-button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.filters-panel .check-row {
  flex: 0 0 auto;
  margin-right: auto;
}

.data-status {
  flex: 1 1 100%;
  min-height: 28px;
}

/* Show button near offers expense form ('quick' refresh from cache) */
.quick-expense {
  position: relative;
}



/* Убираем sparkline в KPI-карточках — они дублируют динамику с графика */
.metric-card .kpi-spark {
  display: none;
}

.metric-card {
  min-height: 120px;
  padding: 18px 20px;
}

/* Чекбоксы в фильтрах — нейтральный вид, не как кнопка */
.filters-panel .check-row {
  margin: 0;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
  white-space: nowrap;
}

.filters-panel .check-row:hover {
  background: var(--surface-muted);
  border-color: var(--line);
}

.filters-panel .check-row input[type="checkbox"] {
  width: 15px;
  height: 15px;
  min-height: 15px;
  accent-color: var(--blue);
  cursor: pointer;
}

.data-status {
  order: 100;
  flex: 1 1 100%;
}

/* Убираем delta-индикаторы из KPI-карточек (стрелки и «к пред. периоду») */
.metric-card .kpi-delta,
.metric-card .kpi-delta::after {
  display: none !important;
}

/* ============================================================ */
/* === EXPENSES PANEL — donut chart + список (без полосок)   === */
/* ============================================================ */

.offer-expense-list {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  padding: 0;
}














/* ============================================================ */
/* === Расходы и затраты — компактная раскладка             === */
/* === donut слева, список справа в 1 колонку               === */
/* ============================================================ */

.offer-expense-list {
  display: grid;
  grid-template-columns: minmax(180px, 220px) 1fr;
  gap: 16px;
  align-items: center;
  padding: 0;
}







.expense-icon-box {
  width: 28px;
  height: 28px;
  border-radius: 7px;
}

.expense-icon-box svg {
  width: 14px;
  height: 14px;
}




@media (max-width: 1100px) {
  .offer-expense-list {
    grid-template-columns: 1fr;
  }
  .expense-donut-canvas {
    max-width: 180px;
  }
}

/* ============================================================ */
/* === Расходы и затраты — waterfall breakdown               === */
/* ============================================================ */

.offer-expense-list {
  display: block;
  padding: 0;
}



















/* ============================================================ */
/* === EXPENSES PANEL — компактный stacked bar              === */
/* ============================================================ */

/* Сбрасываем предыдущую раскладку */
.offer-expense-list {
  display: block;
  padding: 0;
}

.expenses-compact {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px 0;
}

.expenses-compact-head {
  display: grid;
  grid-template-columns: 1fr 24px 1fr 24px 1fr;
  gap: 8px;
  align-items: center;
  padding: 12px 14px;
  background: linear-gradient(135deg, #eff6ff 0%, #faf5ff 100%);
  border-radius: 12px;
  border: 1px solid var(--line);
}

.expenses-compact-head > div small {
  display: block;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.expenses-compact-head > div strong {
  display: block;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.expenses-compact-head .income { color: var(--blue); }
.expenses-compact-head .expense { color: #f59e0b; }
.expenses-compact-head .profit { color: var(--green); }
.expenses-compact-head .loss { color: var(--red); }

.expenses-compact-divider {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--muted);
}

.expenses-stacked-bar {
  display: flex;
  width: 100%;
  height: 18px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-muted);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.05);
}

.expenses-stacked-bar > span {
  display: block;
  height: 100%;
  min-width: 2px;
  transition: width 0.5s ease;
  cursor: help;
}

.expenses-stacked-bar > span:hover {
  opacity: 0.85;
}

.expenses-stacked-bar > span:first-child {
  border-radius: 10px 0 0 10px;
}

.expenses-stacked-bar > span:last-child {
  border-radius: 0 10px 10px 0;
}









@media (max-width: 720px) {
  .expenses-compact-head {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .expenses-compact-divider {
    display: none;
  }
}

/* ============================================================ */
/* === FIX: chips — % не налазит на сумму                    === */
/* ============================================================ */







/* ============================================================ */
/* === EXPENSES PANEL — финальная компактная раскладка       === */
/* ============================================================ */

.expenses-compact-head.two-col {
  grid-template-columns: 1fr 24px 1fr;
  padding: 10px 12px;
}

.expenses-compact-head.two-col > div small {
  font-size: 10.5px;
}

.expenses-compact-head.two-col > div strong {
  font-size: 17px;
}

.expense-items-tight {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.expense-tight-row {
  display: grid;
  grid-template-columns: 28px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  border-left: 3px solid var(--c, var(--blue));
  transition: all 0.15s ease;
}

.expense-tight-row:hover {
  background: var(--surface-muted);
  transform: translateX(2px);
}

.expense-tight-row .expense-icon-box {
  width: 28px;
  height: 28px;
  border-radius: 7px;
}

.expense-tight-row .expense-icon-box svg {
  width: 14px;
  height: 14px;
}

.expense-tight-row .tight-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.expense-tight-row .tight-pct {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--c);
  background: var(--surface-muted);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.expense-tight-row .tight-value {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 80px;
}

/* Скрываем старые expensive chips если ещё есть в DOM */

/* Week cards — компактнее в 2 раза */
.week-summary-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)) !important;
  gap: 6px !important;
}

.week-card {
  padding: 7px 10px !important;
  border-radius: 9px;
}

.week-card span {
  font-size: 10px !important;
}

.week-card strong {
  font-size: 14px !important;
  margin-top: 2px !important;
  letter-spacing: -0.01em;
}

.week-card small {
  font-size: 11px !important;
  margin-top: 2px !important;
}

/* ============================================================ */
/* === CHARTS V2 — новый раздел Графики                       === */
/* ============================================================ */

.charts-v2-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px;
}

.charts-v2-trend, .charts-v2-compare { grid-column: span 7; }
.charts-v2-waterfall, .charts-v2-heatmap { grid-column: span 5; }
.charts-v2-loss { grid-column: span 5; }
.charts-v2-conversion { grid-column: span 4; }
.charts-v2-insights { grid-column: span 3; }

@media (max-width: 1280px) {
  .charts-v2-trend, .charts-v2-compare,
  .charts-v2-waterfall, .charts-v2-heatmap,
  .charts-v2-loss, .charts-v2-conversion, .charts-v2-insights,
  .charts-v2-variant {
    grid-column: span 12;
  }
}

.charts-v2-grid .chart-panel {
  padding: 18px 20px;
}

.charts-v2-grid canvas {
  width: 100% !important;
  max-height: 280px;
}

/* Тренд / Сравнение — статистика снизу */
.charts-v2-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.charts-v2-stats > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.charts-v2-stats small {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

.charts-v2-stats strong {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
}

.charts-v2-stats .positive { color: var(--green); }
.charts-v2-stats .negative { color: var(--red); }

/* Waterfall */
.wf-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  align-items: end;
  height: 260px;
  padding-top: 30px;
}

.wf-col {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
}

.wf-track {
  flex: 1;
  position: relative;
  background: linear-gradient(180deg, transparent 0%, rgba(100,116,139,0.04) 100%);
}

.wf-bar {
  position: absolute;
  left: 15%;
  right: 15%;
  border-radius: 4px;
  transition: height 0.5s, bottom 0.5s;
}

.wf-value {
  position: absolute;
  left: 50%;
  transform: translateX(-50%) translateY(-100%);
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.wf-label {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  font-weight: 600;
  line-height: 1.2;
}

/* Compare — offer strip */
.charts-v2-offer-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.offer-strip-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-muted);
}

.offer-strip-col strong {
  font-size: 13px;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}

.offer-strip-col div {
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.offer-strip-col .muted { font-weight: 500; }
.offer-strip-col .positive { color: var(--green); }
.offer-strip-col .negative { color: var(--red); }
.offer-strip-col .mid { color: var(--amber); }

/* Heatmap */
.charts-heatmap {
  overflow-x: auto;
}

.hm-grid {
  display: grid;
  gap: 2px;
  min-width: 100%;
}

.hm-corner {
  background: transparent;
}

.hm-date {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  font-weight: 600;
  padding: 4px 0;
}

.hm-row {
  display: contents;
}

.hm-offer {
  font-size: 12.5px;
  font-weight: 700;
  padding: 8px 6px;
  display: flex;
  align-items: center;
}

.hm-cell {
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 700;
  padding: 8px 4px;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
  transition: transform 0.15s;
}

.hm-cell:hover {
  transform: scale(1.08);
  box-shadow: var(--shadow-sm);
  z-index: 2;
  position: relative;
}

/* Loss donut */
.charts-loss-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 14px;
  align-items: center;
}

.charts-loss-donut {
  position: relative;
  width: 200px;
  height: 200px;
}

.charts-loss-donut canvas {
  width: 100% !important;
  height: 100% !important;
}

.charts-loss-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  pointer-events: none;
  text-align: center;
}

.charts-loss-center small {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.charts-loss-center strong {
  font-size: 18px;
  font-weight: 800;
  margin: 4px 0 2px;
  letter-spacing: -0.02em;
}

.charts-loss-center em {
  font-size: 11px;
  color: var(--muted);
  font-style: normal;
}

@media (max-width: 720px) {
  .charts-loss-layout {
    grid-template-columns: 1fr;
  }
  .charts-loss-donut {
    width: 160px;
    height: 160px;
    margin: 0 auto;
  }
}

/* Funnel V2 */
.charts-funnel-v2 {
  padding: 8px 0;
}

.funnel-v2-stages {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.funnel-v2-stage {
  text-align: center;
  padding: 14px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--c);
  background: var(--surface);
}

.funnel-v2-stage small {
  display: block;
  font-size: 11px;
  color: var(--c);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.funnel-v2-stage strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
  font-weight: 800;
  color: var(--c);
}

.funnel-v2-rates {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.funnel-v2-rates > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: center;
}

.funnel-v2-rates strong {
  font-size: 18px;
  font-weight: 800;
}

.funnel-v2-rates small {
  font-size: 11px;
  color: var(--muted);
}

.charts-funnel-note {
  margin-top: 10px;
  padding: 8px 10px;
  background: var(--surface-muted);
  border-radius: 8px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.charts-funnel-note strong {
  color: var(--text);
}

/* Insights V2 */
.charts-v2-insights-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.charts-v2-insight {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  transition: all 0.15s;
}

.charts-v2-insight:hover {
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.charts-v2-insight .insight-icon-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 17px;
  background: #ffffff;
  border: 1px solid var(--line);
}

.charts-v2-insight strong {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  margin-bottom: 2px;
}

.charts-v2-insight span {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.charts-v2-insight.good { border-left: 3px solid var(--green); }
.charts-v2-insight.warn { border-left: 3px solid var(--amber); }
.charts-v2-insight.bad  { border-left: 3px solid var(--red); }
.charts-v2-insight.info { border-left: 3px solid var(--blue); }


/* ============================================================ */
/* === НЕДЕЛИ: все блоки в одну строку, компактно            === */
/* ============================================================ */

.week-summary-grid {
  display: flex !important;
  gap: 4px !important;
  overflow-x: auto;
  padding-bottom: 2px;
}

.week-summary-grid::-webkit-scrollbar {
  height: 3px;
}

.week-card {
  flex: 1 1 0;
  min-width: 70px !important;
  padding: 4px 6px !important;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.week-card span {
  font-size: 9px !important;
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  line-height: 1.1;
}

.week-card strong {
  font-size: 11.5px !important;
  margin-top: 1px !important;
  letter-spacing: -0.01em;
  display: block;
  white-space: nowrap;
  line-height: 1.15;
}

.week-card small {
  font-size: 9.5px !important;
  margin-top: 1px !important;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.15;
}

/* CPL/CPO/CAC tiles */

/* Stats funnel */
.stats-funnel-panel {
  margin-bottom: 16px;
  padding: 14px 16px;
}
.muted-small { color: var(--muted); font-size: 12px; font-weight: 500; }
.stats-funnel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.funnel-row {
  display: grid;
  grid-template-columns: 110px 1fr 130px;
  gap: 12px;
  align-items: center;
}
.funnel-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}
.funnel-bar-wrap {
  height: 28px;
  background: rgba(148,163,184,0.10);
  border-radius: 8px;
  overflow: hidden;
}
.funnel-bar {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #6366f1);
  display: flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 8px;
  min-width: 36px;
  transition: width 280ms ease;
}
.funnel-bar-count {
  color: white;
  font-weight: 700;
  font-size: 12.5px;
}
.funnel-rate {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0;
}
.funnel-rate strong {
  font-size: 14px;
  font-weight: 700;
}
.funnel-rate small {
  font-size: 11px;
  color: var(--muted);
}

/* Offer row expansion */
.offer-row { transition: background-color 120ms ease; }
.offer-row:hover { background: rgba(99,102,241,0.06); }
.offer-row.is-expanded { background: rgba(99,102,241,0.10); }
.expand-caret {
  display: inline-block;
  width: 12px;
  font-size: 10px;
  color: var(--muted);
  transition: transform 160ms ease;
  margin-right: 2px;
}
.offer-row.is-expanded .expand-caret { transform: rotate(90deg); color: var(--primary, #3b82f6); }
.offer-details-row.hidden { display: none; }
.offer-details-row td {
  background: var(--card);
  border-top: 0 !important;
  padding: 10px 14px 16px !important;
  /* Прижимаем разворот к левому краю скролл-контейнера, иначе при горизонтальном скролле таблицы половина уезжает */
  position: sticky;
  left: 0;
}
.offer-details-content {
  display: block;
  /* Не даём контенту растягиваться с широкой таблицей */
  width: calc(100vw - 260px);
  max-width: 100%;
  box-sizing: border-box;
}
@media (max-width: 900px) {
  .offer-details-content { width: 100%; }
}
.offer-details-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.offer-details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 900px) {
  .offer-details-grid { grid-template-columns: 1fr; }
}
.offer-details-stack .variant-block:first-child h4 {
  color: var(--primary, #3b82f6);
}
.variant-block h4 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text);
}
.variant-block h4 small {
  font-weight: 500;
  color: var(--muted);
  font-size: 11px;
  margin-left: 6px;
  text-transform: none;
  letter-spacing: 0;
}
.variant-table-wrap {
  overflow-x: auto;
  background: rgba(148,163,184,0.04);
  border-radius: 10px;
  padding: 4px;
}
.variant-table { font-size: 12.5px; width: 100%; }
.variant-table th, .variant-table td { padding: 6px 8px !important; }
.variant-table tfoot td {
  border-top: 1px solid var(--border);
  background: rgba(148,163,184,0.06);
}

/* Charts → variant panel */
.charts-v2-variant { grid-column: span 12; }
.charts-variant-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 6px 2px;
}
.charts-variant-primary .charts-variant-block h4 { color: var(--primary, #3b82f6); }
.charts-variant-secondary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) {
  .charts-variant-secondary { grid-template-columns: 1fr; }
}
.charts-variant-block h4 {
  margin: 0 0 8px;
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.charts-variant-block h4 small {
  font-weight: 500;
  color: var(--muted);
  margin-left: 6px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 11px;
}
.charts-variant-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.charts-variant-row {
  display: grid;
  grid-template-columns: 90px 1fr 200px;
  gap: 10px;
  align-items: center;
  font-size: 12px;
}
.charts-variant-label {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.charts-variant-bars {
  height: 14px;
  display: flex;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(148,163,184,0.08);
  min-width: 24px;
}
.charts-variant-seg { display: block; height: 100%; }
.seg-completed { background: #10b981; }
.seg-returned  { background: #ef4444; }
.charts-variant-stats {
  display: flex;
  gap: 8px;
  font-size: 11.5px;
  white-space: nowrap;
  justify-content: flex-end;
}
.charts-variant-stats .positive { color: var(--green); }
.charts-variant-stats .negative { color: var(--red); }
.charts-variant-stats .buyout-good { color: var(--green); }
.charts-variant-stats .buyout-mid { color: var(--amber); }
.charts-variant-stats .buyout-bad { color: var(--red); }
.empty-state { padding: 12px 14px; color: var(--muted); font-size: 12.5px; }

/* Finance: monthly goal */
.finance-goal-panel {
  margin: 14px 0;
  padding: 14px 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(16,185,129,0.06), rgba(59,130,246,0.06));
  border: 1px solid rgba(16,185,129,0.18);
}
.finance-goal-header {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.finance-goal-header > div:first-child { flex: 1; min-width: 200px; }
.finance-goal-eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  font-weight: 600;
}
.finance-goal-header h3 {
  margin: 4px 0 0;
  font-size: 16px;
  font-weight: 700;
}
.finance-goal-input {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}
.finance-goal-input input {
  width: 140px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-weight: 600;
}
.finance-goal-bar-wrap {
  height: 12px;
  background: rgba(148,163,184,0.15);
  border-radius: 8px;
  overflow: hidden;
  margin: 6px 0 10px;
}
.finance-goal-bar {
  height: 100%;
  width: 0%;
  border-radius: 8px;
  transition: width 320ms ease;
  background: var(--muted);
}
.finance-goal-bar.low  { background: linear-gradient(90deg, #ef4444, #f97316); }
.finance-goal-bar.mid  { background: linear-gradient(90deg, #f97316, #f59e0b); }
.finance-goal-bar.good { background: linear-gradient(90deg, #f59e0b, #10b981); }
.finance-goal-bar.done { background: linear-gradient(90deg, #10b981, #14b8a6); }
.finance-goal-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}
.finance-goal-stats > div {
  background: var(--card);
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
}
.finance-goal-stats span {
  display: block;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  font-weight: 600;
}
.finance-goal-stats strong {
  display: block;
  margin-top: 2px;
  font-size: 14px;
  font-weight: 700;
}

/* Finance: recurring expenses */
.finance-recurring-panel {
  margin: 14px 0;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--border);
}
.finance-recurring-form {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  margin: 10px 0;
}
.finance-recurring-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}
.finance-recurring-form input,
.finance-recurring-form select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 13px;
}
@media (max-width: 720px) {
  .finance-recurring-form { grid-template-columns: 1fr 1fr; }
  .finance-recurring-form button { grid-column: span 2; }
}
.finance-recurring-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.recurring-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 9px;
  background: rgba(148,163,184,0.06);
  border: 1px solid var(--border);
}
.recurring-info { display: flex; flex-direction: column; gap: 2px; }
.recurring-info strong { font-size: 13px; }
.recurring-cat {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}
.recurring-amount { font-weight: 700; font-size: 14px; }
.recurring-amount small { font-weight: 500; color: var(--muted); font-size: 10.5px; }
.recurring-remove { padding: 4px 8px !important; }
.finance-recurring-total {
  font-size: 12.5px;
  color: var(--muted);
  text-align: right;
}
.finance-recurring-total strong { color: var(--text); font-weight: 700; }

/* === STATISTICS: lead funnel rebuild === */
.stats-funnel-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 12px 0 16px;
}
.stats-funnel-kpis .stat-tile {
  padding: 10px 12px !important;
  border-radius: 11px;
}
.stats-funnel-kpis .stat-tile span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  font-weight: 600;
}
.stats-funnel-kpis .stat-tile strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.stats-funnel-kpis .stat-tile small {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.25;
}
.stat-tile-good { border-left: 3px solid #10b981; }
.stat-tile-good strong { color: #10b981; }
.stat-tile-bad { border-left: 3px solid #ef4444; }
.stat-tile-bad strong { color: #ef4444; }
.stat-tile-warn { border-left: 3px solid #f59e0b; }
.stat-tile-warn strong { color: #f59e0b; }

.funnel-row-v2 .funnel-bar { background: #6366f1; }
.funnel-loss {
  display: block;
  font-size: 10.5px;
  color: var(--red);
  font-weight: 600;
  margin-top: 2px;
}

/* Pending statuses list */
.stats-pending-panel { margin-top: 14px; padding: 14px 16px; }
.stats-pending-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pending-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 2fr 80px;
  gap: 12px;
  align-items: center;
  font-size: 12.5px;
}
.pending-status-label {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pending-bar-wrap {
  height: 18px;
  background: rgba(148,163,184,0.10);
  border-radius: 6px;
  overflow: hidden;
}
.pending-bar {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, #f59e0b, #ef4444);
  min-width: 4px;
  transition: width 260ms ease;
}
.pending-count {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.pending-count strong { font-size: 14px; font-weight: 700; }
.pending-count small { font-size: 10.5px; color: var(--muted); }

/* Managers table */
.stats-managers-panel { margin-top: 14px; padding: 14px 16px; }
.stats-managers-table { width: 100%; font-size: 13px; }
.stats-managers-table th { padding: 8px 10px !important; }
.stats-managers-table td { padding: 6px 10px !important; }
.stats-managers-table td.positive { color: var(--green); }
.stats-managers-table td.negative { color: var(--red); }
.stats-managers-table td.margin-mid { color: var(--amber); }

.stats-offers-panel { margin-top: 14px; padding: 14px 16px; }
.stats-offers-table { width: 100%; font-size: 13px; }
.stats-offers-table th { padding: 8px 10px !important; }
.stats-offers-table td { padding: 6px 10px !important; }
.stats-offers-table td.positive { color: var(--green); }
.stats-offers-table td.negative { color: var(--red); }
.stats-offers-table td.margin-mid { color: var(--amber); }

/* ============================================================ */
/* ===  v2026-05-13  — fixes + dark mode + new components   === */
/* ============================================================ */

/* ===== Sidebar overflow fix + grouping ===== */
.sidebar {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar .brand { flex: 0 0 auto; }
.sidebar .nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  margin-right: -4px;
  scrollbar-width: thin;
}
.sidebar .nav::-webkit-scrollbar { width: 4px; }
.sidebar .nav::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }
.sidebar-note {
  position: static !important;
  right: auto !important;
  bottom: auto !important;
  left: auto !important;
  flex: 0 0 auto;
  margin: 12px 0 0;
}
.nav-group { display: grid; gap: 4px; padding-bottom: 8px; }
.nav-group + .nav-group { margin-top: 6px; padding-top: 8px; border-top: 1px dashed var(--line); }
.nav-group-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  padding: 4px 12px 2px;
}
.nav-group-bottom { margin-top: auto; border-top: 1px solid var(--line); padding-top: 10px; }
/* ===== Topbar actions ===== */
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.icon-button:hover { background: var(--primary-soft); color: var(--primary-strong); border-color: var(--primary); }
.icon-button svg { width: 18px; height: 18px; }
.mode-note:empty { display: none; }

/* Status pill states */
.status-pill {
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  color: var(--muted);
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status-pill.idle { background: var(--surface-muted); color: var(--muted); }
.status-pill.idle .dot { background: #94a3b8; }
.status-pill.loading { background: var(--blue-soft); color: var(--blue-dark); border-color: rgba(99,102,241,0.25); }
.status-pill.loading .dot { background: var(--blue); animation: sd-pulse 1.2s ease-in-out infinite; }
.status-pill.success { background: var(--green-soft); color: var(--green); border-color: rgba(16,185,129,0.25); }
.status-pill.success .dot { background: var(--green); }
.status-pill.warning { background: var(--amber-soft); color: var(--amber); border-color: rgba(245,158,11,0.25); }
.status-pill.warning .dot { background: var(--amber); }
.status-pill.error { background: var(--red-soft); color: var(--red); border-color: rgba(239,68,68,0.25); }
.status-pill.error .dot { background: var(--red); }
@keyframes sd-pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }

/* ===== Rate-limit banner + Alerts banner ===== */
.rate-banner, .alert-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid;
  margin: 0 0 14px;
  font-size: 13.5px;
  background: var(--amber-soft);
  border-color: rgba(245,158,11,0.30);
  color: var(--amber);
}
.rate-banner.hidden, .alert-banner.hidden { display: none; }
.rate-banner svg { width: 18px; height: 18px; flex: 0 0 auto; }
.rate-banner-body { flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; }
.rate-banner-body strong { color: var(--text); font-weight: 700; }
.rate-banner-body small { color: var(--muted); font-size: 12px; }
.rate-banner-close {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
}
.rate-banner-close:hover { background: rgba(0,0,0,0.05); color: var(--text); }
.alert-banner {
  background: var(--red-soft);
  border-color: rgba(239,68,68,0.30);
  color: var(--red);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
}
.alert-banner ul { margin: 0; padding-left: 18px; color: var(--text); }
.alert-banner li { font-size: 13px; line-height: 1.4; }
.alert-banner-close {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  align-self: start;
}

/* ===== Quick ranges + saved views row ===== */
.quick-ranges-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.saved-views { display: flex; gap: 6px; flex-wrap: wrap; flex: 1 1 auto; }
.saved-view-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  border: 1px solid rgba(99,102,241,0.30);
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.saved-view-chip:hover { background: var(--primary); color: #fff; }
.saved-view-chip .x {
  display: inline-grid;
  place-items: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: rgba(255,255,255,0.40);
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
}
.save-view-btn { white-space: nowrap; }

/* ===== KPI 2-tier ===== */
.kpi-grid-hero {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 10px;
}
.kpi-grid-secondary {
  display: grid;
  /* 5 одинаковых колонок на десктопе, без auto-fit чтобы не возникала «сирота» */
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.metric-card-hero strong { font-size: 28px; line-height: 1.1; }
.metric-card-mini { padding: 12px 14px !important; min-height: auto !important; }
.metric-card-mini strong { font-size: 18px; line-height: 1.15; }
.metric-card-mini small { font-size: 11px; }
.kpi-spark-mini { height: 24px; }
@media (max-width: 1280px) {
  .kpi-grid-secondary { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (max-width: 1080px) {
  .kpi-grid-secondary { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 860px) {
  .kpi-grid-hero { grid-template-columns: 1fr; }
  .kpi-grid-secondary { grid-template-columns: repeat(2, 1fr); }
}

/* Skeleton state — before first data load */
[data-skeleton="true"]:not(.loaded) {
  background: linear-gradient(90deg, rgba(148,163,184,0.18) 0%, rgba(148,163,184,0.32) 50%, rgba(148,163,184,0.18) 100%);
  background-size: 200% 100%;
  color: transparent !important;
  border-radius: 6px;
  animation: sd-shimmer 1.4s linear infinite;
  display: inline-block;
  min-width: 60px;
}
@keyframes sd-shimmer { 0% { background-position: 100% 0 } 100% { background-position: -100% 0 } }

/* ===== Tables: sticky head/first col + zebra + toolbar ===== */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 10px 0;
  font-size: 12.5px;
}
.table-search {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  min-width: 180px;
}
.table-search svg { width: 14px; height: 14px; color: var(--muted); }
.table-search input { border: 0; background: transparent; outline: none; min-width: 0; flex: 1 1 auto; }
.check-row-inline { font-size: 12.5px; gap: 6px; }
.table-meta { color: var(--muted); margin-left: auto; }
.sticky-table { max-height: 70vh; overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.report-table-sticky { width: 100%; border-collapse: separate; border-spacing: 0; }
.report-table-sticky thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface);
  cursor: pointer;
  user-select: none;
}
.report-table-sticky thead th:hover { background: var(--primary-soft); }
.report-table-sticky tbody tr:nth-child(2n) { background: var(--surface-muted); }
.report-table-sticky tbody tr:hover { background: rgba(99,102,241,0.06); }
.report-table-sticky tbody td:first-child,
.report-table-sticky thead th:first-child,
.report-table-sticky tfoot td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
}
.report-table-sticky thead th:first-child { z-index: 4; }
.report-table-sticky tbody tr:nth-child(2n) td:first-child { background: var(--surface-muted); }
.report-table-sticky tbody tr:hover td:first-child { background: rgba(99,102,241,0.10); }
.row-hidden { display: none !important; }

/* ===== Manager charts grid ===== */
.managers-charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 10px 0 14px;
}
.manager-chart-block {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  position: relative;
}
.manager-chart-block h4 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
}
.manager-chart-block canvas { max-height: 220px; }
.manager-chart-block .empty-state { padding: 24px 12px; text-align: center; }
@media (max-width: 900px) {
  .managers-charts-grid { grid-template-columns: 1fr; }
}

/* ===== Plan/Fact progress rings ===== */
.plan-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.plan-card-ring {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.plan-card-ring .ring { position: relative; width: 96px; height: 96px; }
.plan-card-ring .ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.plan-card-ring .ring-track { fill: none; stroke: rgba(148,163,184,0.20); stroke-width: 9; }
.plan-card-ring .ring-fill {
  fill: none;
  stroke: var(--success);
  stroke-width: 9;
  stroke-linecap: round;
  transition: stroke-dashoffset 600ms ease, stroke 200ms;
}
.plan-card-ring.warn .ring-fill { stroke: var(--warning); }
.plan-card-ring.bad  .ring-fill { stroke: var(--danger); }
.plan-card-ring.done .ring-fill { stroke: var(--success); }
.plan-card-ring .ring-pct {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 16px;
  color: var(--text);
}
.plan-card-ring .plan-body span { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); font-weight: 700; }
.plan-card-ring .plan-body strong { display: block; margin-top: 4px; font-size: 20px; font-weight: 800; color: var(--text); }
.plan-card-ring .plan-body small { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); }
.plan-card-ring .plan-body em { display: block; margin-top: 6px; font-size: 12px; font-style: normal; color: var(--muted); }
.plan-card-ring .plan-body em.good { color: var(--success); font-weight: 700; }
.plan-card-ring .plan-body em.warn { color: var(--warning); font-weight: 700; }
.plan-card-ring .plan-body em.bad  { color: var(--danger); font-weight: 700; }

/* ===== Alerts form ===== */
.alerts-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.alerts-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.alerts-form input {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}
.alerts-form button { grid-column: span 2; }
@media (max-width: 540px) { .alerts-form { grid-template-columns: 1fr; } .alerts-form button { grid-column: auto; } }

/* ===== Sticky header for default report-table when no class ===== */
.table-wrap { position: relative; }

/* ===== Stat pair (number + percent under it) used in stats tables ===== */
.stat-pair { display: inline-flex; flex-direction: column; align-items: flex-start; line-height: 1.1; }
.stat-pair strong { font-size: 13px; font-weight: 700; }
.stat-pair small { font-size: 10.5px; color: var(--muted); }

/* ===== Print stylesheet ===== */
@media print {
  body { background: #fff !important; }
  .sidebar, .topbar-actions, .filters-panel, .saved-views,
  .rate-banner, .alert-banner, .quick-expense-panel,
  .nav-item, .icon-button, .table-toolbar, .status-pill,
  .save-view-btn { display: none !important; }
  .app-shell { grid-template-columns: 1fr !important; }
  .workspace { padding: 12px !important; }
  .view-panel { display: block !important; page-break-after: always; break-after: page; }
  .chart-panel, .metric-card, .stat-tile, .plan-card-ring {
    break-inside: avoid;
    page-break-inside: avoid;
    box-shadow: none !important;
    border: 1px solid #d1d5db !important;
  }
  .kpi-grid-hero, .kpi-grid-secondary { display: grid !important; }
  h1, h2 { color: #111 !important; }
}

/* ===== final small fixes ===== */
.status-pill.idle {
  background: var(--surface-muted) !important;
  border-color: var(--line) !important;
  color: var(--muted) !important;
}
.status-pill.idle .dot { background: #94a3b8 !important; box-shadow: none !important; }
.status-pill.idle::before { display: none !important; }
.status-pill.loading {
  background: var(--blue-soft) !important;
  border-color: rgba(99,102,241,0.25) !important;
  color: var(--blue-dark) !important;
}
.status-pill.loading .dot { background: var(--blue) !important; animation: sd-pulse 1.2s ease-in-out infinite; }
.status-pill.loading::before { display: none !important; }
.status-pill.warning {
  background: #fef3c7 !important;
  border-color: #fcd34d !important;
  color: #92400e !important;
}
.status-pill.warning .dot { background: #d97706 !important; box-shadow: none !important; }
.status-pill.warning::before { display: none !important; }
@keyframes sd-pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }

/* Сравнить с прошлым периодом — выровнять как обычный фильтр-чекбокс */
.filters-panel .filter-row .check-row {
  order: 1 !important;
  margin-left: 0 !important;
}

/* KPI hero (3) и secondary (5) — даём специфичность выше body[data-view] правил */
body[data-view] .kpi-grid.kpi-grid-hero {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 14px;
}
body[data-view] .kpi-grid.kpi-grid-secondary {
  grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  gap: 10px;
}
@media (max-width: 1080px) {
  body[data-view] .kpi-grid.kpi-grid-secondary {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}
@media (max-width: 860px) {
  body[data-view] .kpi-grid.kpi-grid-hero {
    grid-template-columns: 1fr !important;
  }
  body[data-view] .kpi-grid.kpi-grid-secondary {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ===== KPI sub-lines (% от выручки, ROI, юнит-экономика) ===== */
body[data-view="offers"] .metric-card .kpi-share {
  display: block;
  margin-top: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: #6b7280;
  letter-spacing: 0;
  text-transform: none;
}
body[data-view="offers"] .metric-card-mini .kpi-share { font-size: 11px; margin-top: 4px; }
body[data-view="offers"] .metric-split small.positive { color: #047857; font-weight: 700; }
body[data-view="offers"] .metric-split small.negative { color: #b91c1c; font-weight: 700; }

/* Сжимаем карточки до контента */
body[data-view="offers"] .metric-card { min-height: 0; padding: 12px 16px 9px; }
body[data-view="offers"] .metric-card-mini { padding: 11px 14px 8px !important; }
body[data-view="offers"] .metric-card .kpi-spark { display: none; } /* убираем пустой слот спарклайна */
body[data-view="offers"] .metric-card::after { height: 2px; }

/* ===== Calls view ===== */
.secondary-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.secondary-button:hover { background: var(--blue-soft); border-color: var(--blue); }
.secondary-button:disabled { opacity: 0.4; cursor: not-allowed; }
.calls-table td { font-size: 13px; }
.calls-table td:first-child { white-space: nowrap; color: var(--muted); }

/* ===== Returns breakdown в ячейке таблицы ===== */
.returns-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  line-height: 1.2;
}
.returns-cell .return-breakdown {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  letter-spacing: -0.01em;
}

/* ===== Calls verdict cells ===== */
.verdict-cell {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.verdict-cell.yes { background: var(--green-soft); color: var(--green); }
.verdict-cell.no { background: var(--red-soft); color: var(--red); }
.verdict-cell.mid { background: var(--amber-soft); color: var(--amber); }
.verdict-cell.na { background: transparent; color: var(--muted); font-weight: 400; }
.verdict-cell.pending { background: transparent; color: #94a3b8; font-style: italic; font-weight: 400; font-size: 11px; }

/* ===== Returns breakdown panel ===== */
.returns-breakdown-panel {
  margin-top: 12px;
  padding: 12px 16px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.returns-breakdown-title {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.returns-breakdown-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.returns-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--text);
}
.returns-chip.total { background: var(--blue-soft); border-color: var(--blue); font-weight: 600; }
.returns-chip b { font-weight: 700; color: var(--text); }

/* ===== Calls filter tiles + drill-down ===== */
.calls-filter-tile { cursor: pointer; transition: transform 0.08s, box-shadow 0.12s; }
.calls-filter-tile:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.calls-filter-tile.active {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
  background: var(--blue-soft);
}
.calls-filter-tile[data-calls-filter="all"] { cursor: default; }
.calls-filter-tile[data-calls-filter="all"]:hover { transform: none; }

.calls-filter-active {
  display: flex; align-items: center; gap: 8px;
  margin: 10px 0;
  padding: 8px 14px;
  background: var(--blue-soft);
  border: 1px solid var(--blue);
  border-radius: 8px;
  font-size: 13px;
}
.calls-filter-active strong { color: var(--blue-dark); }
.calls-filter-active .ghost-button { padding: 4px 10px; font-size: 12px; margin-left: auto; }

/* ===== Call detail panel ===== */
.call-detail-content {
  padding: 14px;
  background: #f8fafc;
  border-radius: 8px;
  max-height: 70vh;
  overflow: auto;
  font-size: 13px;
}
.call-audio-block {
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 14px;
}
.call-audio-block.muted { color: var(--muted); }
.call-audio-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.audio-download {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--blue);
  text-decoration: none;
}
.audio-download:hover { text-decoration: underline; }

.call-verdict-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px 16px;
  padding: 12px;
  background: var(--surface);
  border-radius: 8px;
  margin-bottom: 12px;
}
.call-verdict-grid > div { font-size: 13px; }
.call-summary {
  padding: 10px 12px;
  background: var(--blue-soft);
  border-left: 3px solid var(--blue);
  border-radius: 4px;
  margin-bottom: 12px;
  line-height: 1.4;
}
.call-section { margin-bottom: 12px; }
.call-flags {
  margin: 6px 0 0 0;
  padding-left: 18px;
  color: var(--red);
}
.call-flags li { margin-bottom: 4px; }
.call-transcript {
  white-space: pre-wrap;
  background: var(--surface);
  padding: 10px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.5;
  margin: 6px 0 0 0;
  max-height: 320px;
  overflow: auto;
}
.dialog-list {
  margin-top: 6px;
  max-height: 360px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dialog-turn {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.4;
}
.dialog-operator { background: #eef4ff; }
.dialog-client { background: #fff7ed; }
.dialog-unknown { background: #f4f4f5; }
.dialog-role {
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.dialog-operator .dialog-role { color: #1d4ed8; }
.dialog-client .dialog-role { color: #c2410c; }
.dialog-unknown .dialog-role { color: var(--muted); }
.dialog-text { color: var(--text); }
.call-products-list { margin: 0; padding-left: 18px; }
.call-products-list li { padding: 1px 0; }
.sd-open-link {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  background: var(--accent-soft, #eef2ff);
  color: var(--accent, #3b82f6);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--accent, #3b82f6);
}
.sd-open-link:hover { background: var(--accent, #3b82f6); color: #fff; }

/* ===== CRM cross-check block ===== */
.call-crm-block {
  padding: 12px;
  background: var(--blue-soft);
  border-left: 3px solid var(--blue);
  border-radius: 4px;
}
.call-crm-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 12px;
  margin-top: 6px;
  font-size: 13px;
}
.call-crm-grid > div:nth-child(odd) {
  font-weight: 600;
  color: var(--muted);
}
.call-flags-block { margin-top: 10px; }

.analyze-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
}
.analyze-filter input[type="checkbox"] { margin: 0; cursor: pointer; }

/* ===== AI calls view ===== */
.ai-call-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 14px;
  align-items: end;
  padding: 10px 0;
}
.ai-call-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.ai-call-form input, .ai-call-form select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
}
.ai-call-result {
  grid-column: 1 / -1;
  margin-top: 8px;
  padding: 12px;
  background: #f8fafc;
  border-radius: 6px;
  font-size: 12px;
  white-space: pre-wrap;
  max-height: 240px;
  overflow: auto;
}
.ai-provider-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
}
.ai-provider-card.ready { border-color: var(--green); background: var(--green-soft); }
.ai-provider-card.missing { background: #fff7ed; border-color: var(--amber); }
.ai-provider-card ul { margin: 6px 0; padding-left: 16px; font-size: 13px; }
.ai-provider-card a { font-size: 13px; color: var(--blue); }
.ai-setup-checklist code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
}

/* ===== CRM-errors panel ===== */
.crm-errors-panel {
  border-left: 4px solid var(--amber);
  background: var(--amber-soft);
}
.crm-errors-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 8px;
}
.crm-error-tile {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.12s;
}
.crm-error-tile:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.crm-error-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.crm-error-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.crm-error-row .verdict-cell strong { font-size: 16px; margin-right: 2px; }
@media (max-width: 800px) { .crm-errors-grid { grid-template-columns: 1fr; } }

/* ===== Calls admin panel (cache management) ===== */
.calls-admin-panel {
  margin: 12px 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.calls-admin-panel summary {
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  user-select: none;
}
.calls-admin-panel[open] summary {
  border-bottom: 1px solid var(--line);
  color: var(--text);
}
.calls-admin-body {
  padding: 14px;
}
.calls-admin-stats {
  padding: 10px 12px;
  background: var(--surface-muted);
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 13px;
}
.calls-admin-stats code {
  background: rgba(0,0,0,0.04);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}
.calls-admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
