*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:      #f0f2f7;
  --card:    #ffffff;
  --navy:    #0f1629;
  --navy2:   #1a2f5e;
  --wb:      #cb11ab;
  --ozon:    #005bff;
  --green:   #16a34a;
  --amber:   #d97706;
  --purple:  #6366f1;
  --red:     #dc2626;
  --muted:   #6b7280;
  --border:  #e5e7eb;
  --shadow:  0 2px 16px rgba(0,0,0,.07);
  --radius:  16px;
  --text:    #111827;
}

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

/* ── Шапка ───────────────────────────────── */
.header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy2) 100%);
  color: #fff;
  padding: 18px 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 4px 24px rgba(0,0,0,.3);
}
.header-left { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, var(--purple), var(--ozon));
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800; color: #fff; flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(99,102,241,.4);
}
.header h1   { font-size: 19px; font-weight: 700; letter-spacing: -.2px; }
.header-sub  { font-size: 12px; color: rgba(255,255,255,.45); margin-top: 2px; }
.header-right { display: flex; align-items: center; gap: 14px; }
.period-badge {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.22);
  padding: 7px 20px; border-radius: 24px;
  font-size: 13px; font-weight: 700; letter-spacing: .4px;
}
.updated { font-size: 11px; color: rgba(255,255,255,.38); }

/* ── Контент ─────────────────────────────── */
.wrap { max-width: 1440px; margin: 0 auto; padding: 28px 28px 56px; }

/* ── Загрузка ────────────────────────────── */
.loading-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 60vh; gap: 16px; color: var(--muted);
}
.spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--purple);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Заголовок секции ────────────────────── */
.section-title {
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted);
  margin: 24px 0 12px;
}

/* ── KPI карты ───────────────────────────── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px; margin-bottom: 16px;
}
.kpi {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px 24px 18px;
  box-shadow: var(--shadow);
  border-top: 4px solid transparent;
  transition: transform .18s, box-shadow .18s;
  position: relative; overflow: hidden;
}
.kpi::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 4px;
}
.kpi:hover { transform: translateY(-3px); box-shadow: 0 8px 32px rgba(0,0,0,.12); }
.kpi-1 { border-color: var(--purple); }
.kpi-2 { border-color: var(--green);  }
.kpi-3 { border-color: var(--amber);  }
.kpi-4 { border-color: #f87171;       }

.kpi-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .9px;
  color: var(--muted); margin-bottom: 10px;
}
.kpi-val { font-size: 26px; font-weight: 800; color: var(--text); line-height: 1.1; }
.kpi-sub { font-size: 11px; color: var(--muted); margin-top: 8px; }
.badge {
  display: inline-block; padding: 3px 10px;
  border-radius: 8px; font-size: 12px; font-weight: 700; margin-top: 6px;
  letter-spacing: .3px;
}
.badge-g { background: #dcfce7; color: #15803d; }
.badge-b { background: #dbeafe; color: #1d4ed8; }
.badge-a { background: #fef3c7; color: #92400e; }
.badge-r { background: #fee2e2; color: #b91c1c; }

.channel-tags { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.ch-tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.ch-tag-wb { background: #fdf4ff; }
.ch-tag-oz { background: #eff6ff; }
.ch-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

/* ── P&L по каналам ──────────────────────── */
.channel-pl-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; margin-bottom: 12px;
}
.ch-pl {
  border-radius: var(--radius); padding: 18px 22px;
  box-shadow: var(--shadow);
}
.ch-pl-wb { background: linear-gradient(135deg, #fdf0fb 0%, #fce7f3 100%); border: 1px solid #fbbde8; }
.ch-pl-oz { background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%); border: 1px solid #bfdbfe; }

.ch-pl-name {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; color: var(--text);
  margin-bottom: 14px;
}
.ch-pl-flow {
  display: flex; align-items: flex-start; gap: 6px; flex-wrap: wrap;
}
.ch-pl-item { flex: 1; min-width: 80px; }
.ch-pl-result {
  background: rgba(255,255,255,.6); border-radius: 10px;
  padding: 8px 12px; margin: -8px -12px -8px -6px;
}
.ch-pl-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-bottom: 4px; }
.ch-pl-val   { font-size: 16px; font-weight: 800; color: var(--text); line-height: 1.2; }
.ch-pl-pct   { font-size: 11px; color: var(--muted); margin-top: 2px; font-weight: 600; }
.ch-pl-pct-g { color: #15803d; }
.ch-pl-sep {
  font-size: 20px; font-weight: 300; color: var(--muted);
  padding-top: 14px; flex-shrink: 0; line-height: 1;
}

/* ── Итоговая полоса МП − Косвенные ─────── */
.summary-bar {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy2) 100%);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 20px 40px;
  color: #fff; display: flex; align-items: center;
  justify-content: center; gap: 0;
  margin-bottom: 0;
  box-shadow: 0 2px 0 rgba(255,255,255,.06);
  flex-wrap: wrap;
}
.sum-item { text-align: center; padding: 6px 32px; }
.sum-label { font-size: 10px; opacity: .5; text-transform: uppercase; letter-spacing: .7px; margin-bottom: 5px; }
.sum-val   { font-size: 22px; font-weight: 800; }
.sum-pct   { font-size: 11px; opacity: .55; margin-top: 3px; }
.sum-sep-op {
  font-size: 28px; font-weight: 300; opacity: .35;
  padding: 0 4px; flex-shrink: 0; align-self: center;
}

/* ── Чистая прибыль — отдельная строка ──── */
.net-profit-bar {
  display: flex; align-items: center; justify-content: center; gap: 32px;
  background: linear-gradient(135deg, #14532d 0%, #166534 100%);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 22px 40px;
  margin-bottom: 16px;
  box-shadow: 0 6px 24px rgba(22,101,52,.35);
  flex-wrap: wrap;
}
.net-profit-eq {
  font-size: 32px; font-weight: 300; color: rgba(255,255,255,.35);
  flex-shrink: 0; line-height: 1;
}
.net-profit-body { text-align: center; }
.net-profit-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: rgba(255,255,255,.5); margin-bottom: 4px;
}
.net-profit-val {
  font-size: 38px; font-weight: 900; color: #86efac;
  letter-spacing: -.5px; line-height: 1.1;
}
.net-profit-pct-box {
  text-align: center; flex-shrink: 0;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 12px; padding: 12px 28px;
}
.net-profit-pct-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .8px; color: rgba(255,255,255,.5); margin-bottom: 4px;
}
.net-profit-pct-val {
  font-size: 30px; font-weight: 900; color: #4ade80;
  letter-spacing: -.3px;
}

/* ── Канальные карточки ──────────────────── */
.cc-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.cc-header {
  padding: 18px 22px;
  display: flex; align-items: center; justify-content: space-between;
}
.cc-header-wb { background: linear-gradient(135deg, #fdf0fb, #fce7f3); border-bottom: 1px solid #fbbde8; }
.cc-header-oz { background: linear-gradient(135deg, #eff6ff, #dbeafe); border-bottom: 1px solid #bfdbfe; }
.cc-channel { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; color: var(--text); }
.cc-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.cc-rev { font-size: 22px; font-weight: 800; color: var(--text); }

.cc-struct-wrap { padding: 16px 22px 12px; }
.cc-struct-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin-bottom: 8px; }
.cc-struct {
  display: flex; height: 12px; border-radius: 6px; overflow: hidden;
  background: #f3f4f6; gap: 2px;
}
.cc-seg { height: 100%; transition: width .6s ease; border-radius: 3px; }
.cc-seg-cogs { background: #f87171; }
.cc-seg-var  { background: #fb923c; }
.cc-seg-mar  { background: #4ade80; }
.cc-struct-legend {
  margin-top: 6px; font-size: 11px; color: var(--muted);
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
}
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; }

.cc-metrics {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 0; padding: 0 0 4px;
}
.cc-metric {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.cc-metric:last-child { border-right: none; }
.cc-metric-highlight { background: #f9fafb; }
.cc-m-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin-bottom: 5px; }
.cc-m-val   { font-size: 15px; font-weight: 700; color: var(--text); }
.cc-m-pct   { font-size: 11px; color: var(--muted); margin-top: 3px; font-weight: 600; }
.cc-m-pct-green { color: #15803d; }

/* ── Сетка ───────────────────────────────── */
.grid-2  { display: grid; grid-template-columns: 1fr 1fr;  gap: 16px; margin-bottom: 16px; }
.grid-31 { display: grid; grid-template-columns: 3fr 2fr;  gap: 16px; margin-bottom: 16px; }
.grid-1  { display: grid; grid-template-columns: 1fr;       gap: 16px; margin-bottom: 16px; }

.card {
  background: var(--card); border-radius: var(--radius);
  padding: 22px 24px; box-shadow: var(--shadow);
}
.card-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 3px; }
.card-sub   { font-size: 12px; color: var(--muted); margin-bottom: 16px; }
.chart-wrap { position: relative; }

/* ── Таблица расходов ────────────────────── */
.cost-table { width: 100%; border-collapse: collapse; }
.cost-table th {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .7px; color: var(--muted);
  text-align: left; padding: 0 0 10px;
  border-bottom: 2px solid var(--border);
}
.cost-table th:last-child { text-align: right; }
.cost-table td { padding: 10px 0 8px; font-size: 13px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
.cost-table td:last-child { text-align: right; font-weight: 700; white-space: nowrap; padding-left: 16px; vertical-align: middle; }
.cost-table tr:last-child td { border-bottom: none; }
.ct-val { display: inline; }
.ct-pct { display: inline; font-size: 11px; font-weight: 500; color: var(--muted); margin-left: 8px; }
.ct-total-row td { border-top: 2px solid var(--border) !important; border-bottom: none !important; font-weight: 700; color: var(--text); }

.ct-label-row {
  display: flex; align-items: center; gap: 8px;
  font-weight: 500; margin-bottom: 5px;
}
.ct-color-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.ct-bar-bg {
  width: 100%; height: 5px; background: #f3f4f6;
  border-radius: 4px; overflow: hidden;
}
.ct-bar-fill {
  height: 100%; border-radius: 4px;
  transition: width .6s ease;
  opacity: 0.6;
}

/* ── Стат-строка тренда ─────────────────── */
.trend-stat { padding: 4px 0 10px; font-size: 13px; }
.ts-label { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.ts-val { font-weight: 700; }
.ts-up { color: #16a34a; font-weight: 600; font-size: 12px; }
.ts-dn { color: #dc2626; font-weight: 600; font-size: 12px; }

/* ── Косвенные: шапка с итогом ──────────── */
.indirect-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 16px; flex-wrap: wrap; gap: 12px;
}
.indirect-total-box {
  text-align: right;
  background: linear-gradient(135deg, #eef2ff, #e0e7ff);
  border: 1px solid #c7d2fe;
  border-radius: 12px; padding: 10px 20px;
}
.indirect-total-val { font-size: 24px; font-weight: 800; color: var(--purple); }
.indirect-total-pct { font-size: 11px; color: #6366f1; margin-top: 2px; font-weight: 600; }

/* ── Пустое состояние ────────────────────── */
.no-data {
  display: flex; align-items: center; justify-content: center;
  height: 100%; min-height: 160px;
  color: var(--muted); font-size: 13px;
}

/* ── Футер ───────────────────────────────── */
.footer {
  text-align: center; padding: 16px;
  font-size: 11px; color: var(--muted);
  border-top: 1px solid var(--border);
}
.footer-admin-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 10px;
  color: var(--muted);
  opacity: .35;
  text-decoration: none;
  transition: opacity .15s;
}
.footer-admin-link:hover { opacity: .7; }

/* ── Навигация страниц ───────────────────── */
.page-nav {
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 0;
  padding: 0 32px;
}
.pnav-link {
  padding: 11px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 3px solid transparent;
  transition: color .15s, border-color .15s;
}
.pnav-link:hover { color: var(--text); }
.pnav-active { color: var(--accent) !important; border-bottom-color: var(--accent) !important; }

/* ── Юнит-экономика: Kanban ──────────────── */
.uc-kanban {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  align-items: start;
}
.uc-col {
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 14px;
}
.uc-col-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.uc-col-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.uc-col-title { font-weight: 700; font-size: 13px; flex: 1; }
.uc-col-badge { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 20px; }
.uc-card {
  background: #f9fafb;
  border-radius: 8px;
  padding: 11px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
}
.uc-card:last-child { margin-bottom: 0; }
.uc-art-id { font-size: 10px; color: var(--muted); margin-bottom: 2px; }
.uc-art-name { font-size: 12px; font-weight: 600; margin-bottom: 9px; line-height: 1.35; word-break: break-word; }
.uc-mrow { display: flex; gap: 5px; margin-bottom: 6px; }
.uc-metric {
  display: flex; flex-direction: column; align-items: center;
  flex: 1; background: #fff; border-radius: 6px;
  padding: 5px 3px; border: 1px solid var(--border);
}
.uc-mval { font-size: 12px; font-weight: 700; }
.uc-mlbl { font-size: 10px; color: var(--muted); }
.uc-ppu { font-size: 12px; font-weight: 700; margin: 5px 0 2px; }
.uc-ppu-lbl { font-size: 10px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.uc-rev { font-size: 11px; font-weight: 600; color: var(--text); text-align: right; }
.uc-flags { margin-top: 7px; }
.uc-flag {
  font-size: 11px; color: #92400e;
  background: #fffbeb; border: 1px solid #fde68a;
  border-radius: 4px; padding: 3px 7px;
  margin-top: 4px; line-height: 1.4;
}
.uc-empty { font-size: 12px; color: var(--muted); text-align: center; padding: 20px 0; }

/* ── Responsive ──────────────────────────── */
@media (max-width: 1100px) {
  .grid-31 { grid-template-columns: 1fr; }
  .cc-metrics { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .grid-2  { grid-template-columns: 1fr; }
  .channel-pl-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .kpi-row { grid-template-columns: 1fr; }
  .cc-metrics { grid-template-columns: 1fr; }
  .cc-metric { border-right: none; }
  .header { padding: 14px 16px; }
  .wrap   { padding: 16px 14px 32px; }
  .summary-bar { padding: 16px 20px; }
  .sum-divider { display: none; }
}

/* ── ДДС ─────────────────────────────────────── */
.dds-filters {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 24px;
  margin-bottom: 16px;
}
.dds-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.dds-filter-group { display: flex; flex-direction: column; gap: 5px; }
.dds-label {
  font-size: 11px; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
}
.dds-input, .dds-select {
  height: 36px; border: 1px solid var(--border); border-radius: 8px;
  padding: 0 10px; font-size: 13px; color: var(--text);
  background: var(--bg); outline: none; cursor: pointer;
}
.dds-input:focus, .dds-select:focus { border-color: var(--navy2); }
.dds-filter-wide .dds-select { min-width: 180px; }
.dds-filter-xl   .dds-select { min-width: 260px; }
.dds-reset-btn {
  height: 36px; padding: 0 16px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); color: var(--muted);
  font-size: 13px; cursor: pointer; transition: background .15s;
}
.dds-reset-btn:hover { background: var(--bg); color: var(--text); }

.dds-summary-bar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 24px; margin-bottom: 16px;
}
.dds-count { font-size: 13px; color: var(--muted); }
.dds-total-box { display: flex; align-items: center; gap: 10px; }
.dds-total-label { font-size: 13px; color: var(--muted); }
.dds-total-val { font-size: 24px; font-weight: 700; color: var(--text); }

.dds-table-wrap {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.dds-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dds-table thead th {
  background: var(--bg); padding: 10px 14px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.dds-table tbody tr { border-bottom: 1px solid var(--border); }
.dds-table tbody tr:last-child { border-bottom: none; }
.dds-table tbody tr:hover { background: var(--bg); }
.dds-table td { padding: 10px 14px; vertical-align: top; }
.dds-td-date    { white-space: nowrap; }
.dds-td-account { white-space: nowrap; }
.dds-td-contr   { max-width: 220px; }
.dds-td-desc    { max-width: 320px; font-size: 12px; color: var(--muted); }
.dds-td-sum     { text-align: right; font-weight: 600; white-space: nowrap; }

@media (max-width: 900px) {
  .dds-td-desc  { display: none; }
  .dds-td-contr { max-width: 160px; }
}
@media (max-width: 640px) {
  .dds-filters  { padding: 14px 16px; }
  .dds-filter-row { gap: 8px; }
  .dds-filter-group { width: 100%; }
  .dds-filter-wide .dds-select,
  .dds-filter-xl   .dds-select { min-width: 0; width: 100%; }
  .dds-input  { width: 100%; }
  .dds-reset-btn { width: 100%; justify-content: center; }
  .dds-summary-bar { flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px 16px; }
  .dds-total-val { font-size: 20px; }
  .dds-table thead th:nth-child(3),
  .dds-table tbody td:nth-child(3) { display: none; }
}
