/* Финансы продавца — стили. Цвета — из значка: фиолетово-индиговый акцент, бирюза для долей.
   Светлая и тёмная темы — по настройке системы (или data-theme на <html>). */
:root {
  color-scheme: light;
  --page: #f4f5f9;
  --side: #fbfbfd;
  --surface: #ffffff;
  --surface-2: #f6f7fb;
  --input: #ffffff;
  --ink: #12142a;
  --ink-2: #4a4f68;
  --muted: #868ba3;
  --grid: #eceef4;
  --axis: #d3d6e2;
  --border: #e3e5ee;
  --accent: #4f46e5;
  --accent-wash: rgba(79, 70, 229, 0.08);
  --accent-ring: rgba(79, 70, 229, 0.22);
  --btn: linear-gradient(135deg, #6d5df6 0%, #4f46e5 100%);
  --brand: linear-gradient(135deg, #8b5cf6 0%, #2563eb 100%);
  --teal: #0d9488;
  --good: #0b8a50;
  --good-wash: rgba(11, 138, 80, 0.09);
  --bad: #d4343f;
  --bad-wash: rgba(212, 52, 63, 0.08);
  --amber: #a15c07;
  --amber-wash: rgba(245, 158, 11, 0.13);
  --shadow-xs: 0 1px 2px rgba(18, 20, 42, 0.05);
  --shadow-sm: 0 1px 2px rgba(18, 20, 42, 0.04), 0 2px 6px rgba(18, 20, 42, 0.04);
  --shadow-md: 0 8px 24px rgba(18, 20, 42, 0.08), 0 2px 6px rgba(18, 20, 42, 0.05);
  --radius: 14px;
  --radius-sm: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14.5px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0b0d15;
    --side: #0f121c;
    --surface: #141826;
    --surface-2: #1a1f2f;
    --input: #10131e;
    --ink: #eceef7;
    --ink-2: #aab0c6;
    --muted: #747a94;
    --grid: #20253a;
    --axis: #2e3450;
    --border: rgba(255, 255, 255, 0.08);
    --accent: #9b94ff;
    --accent-wash: rgba(139, 132, 255, 0.12);
    --accent-ring: rgba(139, 132, 255, 0.30);
    --btn: linear-gradient(135deg, #6d5df6 0%, #4f5bea 100%);
    --teal: #2dd4bf;
    --good: #34d399;
    --good-wash: rgba(52, 211, 153, 0.11);
    --bad: #f87171;
    --bad-wash: rgba(248, 113, 113, 0.10);
    --amber: #fbbf24;
    --amber-wash: rgba(251, 191, 36, 0.10);
    --shadow-xs: none;
    --shadow-sm: none;
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.45);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0b0d15;
  --side: #0f121c;
  --surface: #141826;
  --surface-2: #1a1f2f;
  --input: #10131e;
  --ink: #eceef7;
  --ink-2: #aab0c6;
  --muted: #747a94;
  --grid: #20253a;
  --axis: #2e3450;
  --border: rgba(255, 255, 255, 0.08);
  --accent: #9b94ff;
  --accent-wash: rgba(139, 132, 255, 0.12);
  --accent-ring: rgba(139, 132, 255, 0.30);
  --btn: linear-gradient(135deg, #6d5df6 0%, #4f5bea 100%);
  --teal: #2dd4bf;
  --good: #34d399;
  --good-wash: rgba(52, 211, 153, 0.11);
  --bad: #f87171;
  --bad-wash: rgba(248, 113, 113, 0.10);
  --amber: #fbbf24;
  --amber-wash: rgba(251, 191, 36, 0.10);
  --shadow-xs: none;
  --shadow-sm: none;
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.45);
}

/* ---------- основа ---------- */
* { box-sizing: border-box; }
/* hidden прячет всегда: иначе display у .btn и других классов перебивает его и «спрятанное» видно */
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--page); color: var(--ink); line-height: 1.5;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 6px; font-weight: 720; letter-spacing: -0.022em; }
h2 { font-size: 16px; margin: 0 0 14px; font-weight: 680; letter-spacing: -0.01em; }
h3 { font-size: 13px; margin: 0 0 8px; font-weight: 650; color: var(--ink-2); }
p { margin: 0 0 8px; }
a { color: var(--accent); text-underline-offset: 2px; }
button, input, select { font: inherit; color: inherit; }
strong { font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.neg { color: var(--bad); }
.pos { color: var(--good); }
.clickable { cursor: pointer; }
::selection { background: var(--accent-ring); }

/* ---------- каркас: боковое меню и содержимое ---------- */
body { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
  padding: 20px 14px 16px; background: var(--side); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 10px 20px; text-decoration: none; color: inherit; }
.brand-mark { width: 34px; height: 34px; display: block; flex: none; border-radius: 9px; box-shadow: 0 4px 12px rgba(91, 76, 240, 0.28); }
.brand-text { display: grid; gap: 3px; min-width: 0; }
.brand-name { font-weight: 720; font-size: 15px; letter-spacing: -0.01em; line-height: 1.15; }
.tag {
  justify-self: start; font-size: 11px; font-weight: 600; color: var(--ink-2); line-height: 1.6;
  border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; background: var(--surface);
}
#nav { display: grid; gap: 14px; }
.nav-group { display: grid; gap: 2px; }
.nav-title { padding: 0 12px 4px; font-size: 11.5px; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
#nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px;
  color: var(--ink-2); font-weight: 560; text-decoration: none; transition: background .15s, color .15s;
}
#nav a svg { flex: none; color: var(--muted); transition: color .15s; }
#nav a:hover { background: var(--surface-2); color: var(--ink); }
#nav a:hover svg { color: var(--ink-2); }
#nav a[aria-current="page"] { background: var(--accent-wash); color: var(--accent); }
#nav a[aria-current="page"] svg { color: var(--accent); }
.nav-dot { width: 8px; height: 8px; margin-left: auto; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 3px var(--side); }

/* кто вошёл — внизу меню */
.account { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); display: grid; gap: 10px; }
.account:empty { display: none; }
.me { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 0 4px; }
.avatar {
  width: 36px; height: 36px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand); color: #fff; font-weight: 700; font-size: 13px; letter-spacing: 0.02em;
}
.me-text { display: grid; min-width: 0; line-height: 1.3; }
.me-name { font-weight: 650; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-ws { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me .theme-btn { flex: none; width: 30px; padding: 0; margin-left: auto; }
.me-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.me-actions .btn { width: 100%; }
/* «Обновить данные» — над именем; пока WB не пустит, на кнопке обратный отсчёт */
.refresh { display: grid; gap: 5px; }
.refresh:empty { display: none; }
.refresh-btn { width: 100%; font-variant-numeric: tabular-nums; }
.refresh-btn:disabled { cursor: default; }
.refresh-note { font-size: 12px; line-height: 1.35; text-align: center; }

.content { display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }
main { flex: 1 0 auto; width: 100%; max-width: 1280px; margin: 0 auto; padding: 34px 40px 24px; outline: none; }
.site-foot { padding: 24px 24px 28px; text-align: center; font-size: 12.5px; color: var(--muted); letter-spacing: 0.02em; }
.site-foot a { color: var(--ink-2); font-weight: 650; text-decoration: none; }
.site-foot a:hover { color: var(--accent); }

/* вход: без меню, по центру, на фоне цветов значка */
body.is-auth { grid-template-columns: minmax(0, 1fr); }
body.is-auth .side { display: none; }
body.is-auth .content {
  background:
    radial-gradient(900px 520px at 12% -8%, rgba(124, 92, 246, 0.16), transparent 62%),
    radial-gradient(760px 480px at 100% 105%, rgba(37, 99, 235, 0.13), transparent 60%);
}

@media (max-width: 1023px) {
  body { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: sticky; top: 0; z-index: 20; height: auto; overflow: visible;
    flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 12px;
    padding: 10px 16px 8px; border-right: 0; border-bottom: 1px solid var(--border);
  }
  .brand { padding: 0; }
  .brand-mark { width: 30px; height: 30px; }
  #nav { order: 3; width: 100%; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; margin: 0 -6px; }
  #nav a { padding: 7px 10px; white-space: nowrap; }
  /* на узком экране меню — лента: группы без подписей, между ними — черта */
  .nav-group { display: flex; gap: 2px; flex: none; }
  .nav-group + .nav-group { border-left: 1px solid var(--border); padding-left: 6px; margin-left: 4px; }
  .nav-title { display: none; }
  .account { margin: 0 0 0 auto; padding: 0; border: 0; display: flex; align-items: center; gap: 10px; min-width: 0; }
  .me-text { display: none; }
  .me { padding: 0; }
  .avatar { width: 32px; height: 32px; }
  .me-actions { display: flex; }
  .refresh { display: flex; }
  .refresh-note { display: none; }
  main { padding: 22px 16px 16px; }
}
@media (max-width: 560px) {
  .me-actions .btn span { display: none; }
  .refresh-label { display: none; }
  .brand-text .tag { display: none; }
}

/* ---------- заголовок страницы ---------- */
.page-head { margin-bottom: 24px; }
.lead { color: var(--ink-2); max-width: 760px; }

/* ---------- карточки ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 16px; box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* раскрывающиеся карточки: шеврон вместо треугольника */
details.card > summary, details.product > summary { list-style: none; cursor: pointer; }
details.card > summary::-webkit-details-marker, details.product > summary::-webkit-details-marker { display: none; }
details.card > summary { display: flex; gap: 12px; align-items: center; }
details.card > summary::before, details.product > summary::before {
  content: ""; flex: none; width: 7px; height: 7px; margin: 0 4px 0 2px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform .18s ease;
}
details[open].card > summary::before, details[open].product > summary::before { transform: rotate(45deg); }
details.card[open] > summary { margin-bottom: 8px; }
details.card > summary:hover::before { border-color: var(--ink-2); }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 15px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 14px; line-height: 1; cursor: pointer; text-decoration: none; white-space: nowrap;
  box-shadow: var(--shadow-xs); transition: background .15s, border-color .15s, box-shadow .15s, filter .15s, transform .05s;
}
.btn svg { flex: none; }
.btn:hover { background: var(--surface-2); border-color: var(--axis); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--btn); border-color: transparent; color: #fff;
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
.btn.primary:hover { filter: brightness(1.07) saturate(1.05); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-wash); border-color: transparent; }
.btn.small { height: 30px; padding: 0 11px; font-size: 13px; border-radius: 8px; gap: 6px; }
.btn:disabled { opacity: 0.5; cursor: progress; transform: none; }

/* ---------- поля ---------- */
input[type="number"], input[type="text"], input[type="search"], input[type="date"], input[type="month"], input[type="password"], input[type="email"], select {
  height: 36px; background: var(--input); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0 11px; min-width: 0; transition: border-color .15s, box-shadow .15s;
}
select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%23868ba3' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
input:hover, select:hover { border-color: var(--axis); }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
input[readonly] { background: var(--surface-2); }
input[type="number"] { text-align: right; font-variant-numeric: tabular-nums; }
input::placeholder { color: var(--muted); }
button:focus-visible, a:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px;
}
.field { display: grid; gap: 5px; font-size: 13px; font-weight: 550; color: var(--ink-2); }
.field input { width: 100%; }
.filters {
  display: flex; gap: 12px 16px; align-items: end; flex-wrap: wrap; margin-bottom: 18px;
  padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.filters label, .tax-grid label { display: grid; gap: 5px; font-size: 12.5px; font-weight: 550; color: var(--ink-2); }
.tax-grid { display: flex; gap: 14px; flex-wrap: wrap; align-items: end; }
/* в строке отборов: поле, которое тянется (поиск), галочка и счётчик — по нижнему краю полей */
.filters label.grow { flex: 1 1 260px; max-width: 460px; }
.filters label.grow input { width: 100%; }
.filters label.grow .gp { display: block; width: 100%; min-width: 0; }
.filters label.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 500; color: var(--ink); min-height: 36px; }
.filters .found { min-height: 36px; display: flex; align-items: center; }
/* выбор товара с поиском: поле и список под ним (список — в body, его не режет прокрутка таблицы) */
.gp { display: inline-block; min-width: 280px; }
.gp-input { width: 100%; }
.ad-form .gp, .ads-table tr.editing .gp { display: block; width: 100%; min-width: 180px; }
.gp-list {
  position: fixed; z-index: 40; margin: 0; padding: 4px; list-style: none; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); font-size: 13.5px;
}
.gp-list li { display: grid; gap: 1px; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.gp-list li.on { background: var(--accent-wash); }
.gp-list li[aria-selected="true"] > span:first-child { font-weight: 650; color: var(--accent); }
.gp-list li.gp-note { cursor: default; color: var(--muted); font-size: 13px; }
@media (max-width: 560px) { .gp { min-width: 0; width: 100%; } }
/* юнит-экономика: «Что если» и выгрузка товара в одну строку */
.unit-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.unit-tools h3 { margin: 0; }

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13.5px; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--grid); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th {
  font-size: 12px; font-weight: 650; color: var(--muted); background: var(--surface-2);
  border-bottom: 1px solid var(--border); vertical-align: bottom; padding-top: 9px; padding-bottom: 9px;
}
thead th:first-child { border-top-left-radius: 10px; }
thead th:last-child { border-top-right-radius: 10px; }
tbody tr { transition: background .1s; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td.wrap, th.wrap { white-space: normal; }
th.left, td.left { text-align: left; }
tr.section th {
  text-align: left; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); padding-top: 20px; padding-bottom: 6px; border-bottom: none; background: transparent;
}
tr.section:first-child th { padding-top: 10px; }
tr.strong td { font-weight: 650; color: var(--ink); }
tr.result td { font-weight: 720; font-size: 14.5px; background: var(--accent-wash); border-bottom: 0; }
tr.result td:first-child { border-radius: 10px 0 0 10px; }
tr.result td:last-child { border-radius: 0 10px 10px 0; }
tbody tr.result:hover td { background: var(--accent-wash); }
.sticky th:first-child, .sticky td:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.sticky thead th:first-child { background: var(--surface-2); }
.sticky tbody tr:hover td:first-child { background: var(--surface-2); }
.sticky tr.result td:first-child { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
tr.missing td { background: var(--bad-wash); }
/* ОПИУ: таблица прокручивается внутри себя — шапка с периодами прилипает сверху,
   статьи и названия разделов — слева, «Итого» — справа; при любой прокрутке видно, что где */
.pnl-wrap { max-height: calc(100dvh - 110px); overflow: auto; overscroll-behavior-x: contain; }
.pnl-wrap thead th { position: sticky; top: 0; z-index: 2; }
.pnl-wrap thead th:first-child { left: 0; z-index: 4; }
.pnl-wrap td:first-child, .pnl-wrap thead th:first-child { box-shadow: inset -1px 0 0 var(--border); }
.pnl-wrap th:last-child, .pnl-wrap td:last-child {
  position: sticky; right: 0; z-index: 1; background: var(--surface); box-shadow: inset 1px 0 0 var(--border); font-weight: 650;
}
.pnl-wrap thead th:last-child { z-index: 3; background: var(--surface-2); }
.pnl-wrap tbody tr:hover td:last-child { background: var(--surface-2); }
.pnl-wrap tr.result td:last-child { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.pnl-wrap tr.section th { position: static; box-shadow: none; }
.section-label { position: sticky; left: 10px; }
@media (max-width: 1023px) { .pnl-wrap { max-height: calc(100dvh - 140px); } }
.pnl-label { min-width: 240px; }
@media (max-width: 700px) { .pnl-label { min-width: 150px; } }
/* телефон: два закреплённых столбца съели бы весь экран — «Итого» уезжает вместе с периодами */
@media (max-width: 560px) {
  .pnl-wrap td:last-child { position: static; }
  .pnl-wrap thead th:last-child { right: auto; }
  .pnl-label { min-width: 120px; }
}

/* ---------- PnL: отчёт от выручки к прибыли ---------- */
/* «почему изменилась прибыль»: полоса слева — зелёная при росте, красная при падении */
.why { position: relative; overflow: hidden; padding: 16px 20px 16px 24px; }
.why::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--good); }
.why.down::before { background: var(--bad); }
.why h2 { margin: 0 0 2px; font-size: 15.5px; }
.why-sub { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.why ul { margin: 0; padding-left: 18px; display: grid; gap: 5px; font-size: 14px; }
.why li strong { font-variant-numeric: tabular-nums; white-space: nowrap; }
.why-items { margin: 10px 0 0; font-size: 13px; color: var(--ink-2); }
.pl-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .pl-grid { grid-template-columns: minmax(0, 1fr); gap: 0; } }
.pl-table td.pl-label { min-width: 200px; }
/* уровни: итоги жирно и с чертой сверху, статьи групп — с отступом и мельче */
.pl-table td.pl-label { padding-left: 30px; }
.pl-table tr.pl-group td.pl-label { padding-left: 10px; }
.pl-table tr.pl-child td.pl-label { padding-left: 50px; color: var(--ink-2); }
.pl-table tr.pl-info td.pl-label { padding-left: 62px; }
.pl-table tr.pl-child td, .pl-table tr.pl-info td { font-size: 13px; }
.pl-table tr.pl-info td { color: var(--muted); }
.pl-table tr.pl-subtotal td { font-weight: 680; color: var(--ink); border-top: 1px solid var(--axis); }
.pl-table tr.pl-group td { font-weight: 600; }
.pl-table tr.pl-metric td { color: var(--ink-2); border-top: 1px solid var(--axis); }
.pl-toggle {
  display: inline-flex; align-items: center; gap: 6px; padding: 0; margin: 0; border: 0; background: none;
  font: inherit; font-weight: 600; color: inherit; text-align: left; cursor: pointer;
}
.pl-toggle svg { flex: none; color: var(--muted); transform: rotate(-90deg); transition: transform .15s; }
.pl-toggle[aria-expanded="true"] svg { transform: none; }
.pl-toggle:hover { color: var(--accent); }
.pl-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 16px; }
.pl-stat { display: grid; gap: 2px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.pl-stat strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.pl-recon { display: grid; gap: 6px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--grid); font-size: 13.5px; }
.pl-recon h3 { margin: 0 0 2px; }
.pl-recon-row { display: flex; justify-content: space-between; gap: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
/* водопад: полоса — доля выручки, расходы отнимаются по очереди */
.wf { display: grid; gap: 9px; }
.wf-row { display: grid; grid-template-columns: minmax(110px, 160px) minmax(0, 1fr) auto 48px; gap: 10px; align-items: center; font-size: 13px; }
.wf-label { color: var(--ink-2); }
.wf-row.start .wf-label, .wf-row.end .wf-label { color: var(--ink); font-weight: 650; }
.wf-row.end { padding-top: 9px; border-top: 1px solid var(--grid); }
.wf-track { position: relative; height: 18px; border-radius: 5px; background: var(--surface-2); }
.wf-bar { position: absolute; top: 0; bottom: 0; border-radius: 5px; }
.wf-bar.rev { background: var(--btn); }
.wf-bar.cost { background: color-mix(in srgb, var(--bad) 55%, transparent); }
.wf-bar.gain { background: var(--good); }
.wf-bar.loss { background: var(--bad); }
.wf-zero { position: absolute; top: -3px; bottom: -3px; width: 1px; background: var(--axis); }
.wf-val { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.wf-pct { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 560px) {
  .pl-table .pl-unit { display: none; }
  .pl-table th, .pl-table td { padding-left: 6px; padding-right: 6px; }
  .pl-card { padding: 16px 12px; }
  .pl-table td.pl-label { min-width: 120px; padding-left: 22px; }
  .pl-table tr.pl-group td.pl-label { padding-left: 2px; }
  .pl-table tr.pl-child td.pl-label { padding-left: 30px; }
  .pl-table tr.pl-info td.pl-label { padding-left: 38px; }
  .wf-row { grid-template-columns: 100px minmax(0, 1fr) auto; }
  .wf-pct { display: none; }
}

/* ---------- плитки с главными цифрами ---------- */
/* прибыль — шире остальных: в ней ещё мини-график */
.kpis { display: grid; grid-template-columns: minmax(0, 1.9fr) repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
@media (max-width: 1180px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } .kpi-tile.hero { grid-column: 1 / -1; } }
@media (max-width: 700px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi-value { font-size: 21px; }
  .kpi-tile { padding: 14px; min-height: 0; }
  .kpi-tile:last-child { grid-column: 1 / -1; }
  /* четыре плитки — две строки по две: последняя на всю ширину оставляла третью одну */
  .kpis.kpis-even .kpi-tile:last-child:nth-child(even) { grid-column: auto; }
}
.kpi-tile {
  position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); min-height: 112px;
}
.kpi-label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.kpi-value { font-size: 25px; font-weight: 740; letter-spacing: -0.025em; margin-top: 6px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi-sub { font-size: 12.5px; color: var(--ink-2); margin-top: 4px; }
.kpi-tile.hero { background: var(--brand); color: #fff; border-color: transparent; box-shadow: 0 10px 28px rgba(79, 70, 229, 0.28); }
.kpi-tile.hero .kpi-label, .kpi-tile.hero .kpi-sub { color: rgba(255, 255, 255, 0.82); }
.kpi-tile.hero.negative { background: linear-gradient(135deg, #e0475a 0%, #b42343 100%); box-shadow: 0 10px 28px rgba(212, 52, 63, 0.25); }
.spark { position: absolute; right: 18px; top: 50%; transform: translateY(-50%); width: 44%; height: 58px; opacity: 0.95; }
.spark path.line { fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark path.area { fill: rgba(255, 255, 255, 0.16); }
.spark circle { fill: #fff; }
/* плитка прибыли открывает график на весь экран */
/* курсор — рука, как у кнопок: лупа (zoom-in) в Windows похожа на значок загрузки */
.kpi-tile.zoomable { cursor: pointer; transition: transform .15s, box-shadow .15s; }
.kpi-tile.zoomable:hover { transform: translateY(-1px); box-shadow: 0 14px 34px rgba(79, 70, 229, 0.36); }
.kpi-tile.hero.negative.zoomable:hover { box-shadow: 0 14px 34px rgba(212, 52, 63, 0.32); }
.kpi-zoom { position: absolute; top: 10px; right: 12px; display: flex; color: rgba(255, 255, 255, 0.7); transition: color .15s; }
.kpi-tile.zoomable:hover .kpi-zoom, .kpi-tile.zoomable:focus-visible .kpi-zoom { color: #fff; }
dialog.chart-full {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 22px 28px 20px;
  border: 0; background: var(--page); color: var(--ink);
}
dialog.chart-full[open] { display: grid; grid-template-rows: auto auto minmax(0, 1fr); gap: 20px; }
dialog.chart-full::backdrop { background: var(--page); }
html:has(dialog.chart-full[open]) { overflow: hidden; }
.cf-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.cf-head h2 { margin: 0; font-size: 20px; }
.cf-head p { margin: 4px 0 0; }
.cf-stats { display: flex; flex-wrap: wrap; gap: 12px 36px; }
.cf-value { font-size: 19px; font-weight: 720; margin-top: 3px; font-variant-numeric: tabular-nums; }
/* без overflow: hidden — подпись последнего периода выходит за край графика в поле окна */
.cf-box { min-height: 0; touch-action: none; } /* палец над графиком выделяет, а не листает */
.cf-stats .cf-reset { align-self: center; }
/* линия прибыли: выше нуля — акцент, ниже — красный; красная полоса — период под указателем */
.chart .lc-line { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart .lc-line.neg { stroke: var(--bad); }
.chart .lc-area.neg { fill: color-mix(in srgb, var(--bad) 16%, transparent); }
.chart .lc-dot { fill: var(--page); stroke: var(--accent); stroke-width: 1.6; }
.chart .lc-dot.neg { stroke: var(--bad); }
.chart .lc-sel { fill: color-mix(in srgb, var(--accent) 13%, transparent); stroke: var(--accent-ring); stroke-width: 1; }
.chart .lc-cross { stroke: var(--bad); stroke-width: 1.6; pointer-events: none; }
.chart .lc-focus { fill: var(--accent); stroke: var(--page); stroke-width: 2.5; pointer-events: none; }
.chart .lc-focus.neg { fill: var(--bad); }
.chart .lc-hit { fill: transparent; cursor: crosshair; touch-action: none; outline: none; }
.chart .lc-hit:focus-visible { stroke: var(--accent-ring); stroke-width: 2; }
@media (max-width: 700px) {
  dialog.chart-full { padding: 14px 14px 12px; gap: 14px; }
  .cf-head .btn span { display: none; }
  .cf-stats { gap: 10px 22px; }
}

/* ---------- юнит-экономика и прикидки ---------- */
details.product { padding: 0; }
details.product > summary { padding: 16px 20px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
details.product[open] > summary { border-bottom: 1px solid var(--grid); }
.p-title { font-weight: 680; font-size: 15.5px; letter-spacing: -0.01em; }
.p-sub { color: var(--muted); font-size: 13px; }
.p-profit {
  margin-left: auto; font-weight: 680; font-size: 13.5px; padding: 5px 12px; border-radius: 999px;
  background: var(--good-wash); color: var(--good); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.p-profit:empty { display: none; }
.p-profit.neg { background: var(--bad-wash); color: var(--bad); }
.p-body { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: 28px; padding: 18px 20px 22px; }
@media (max-width: 960px) { .p-body { grid-template-columns: 1fr; } }
.p-ident { display: grid; grid-template-columns: 2fr 1fr auto; gap: 12px; align-items: end; margin-bottom: 16px; }
.p-ident > span { display: none; }
@media (max-width: 700px) { .p-ident { grid-template-columns: 1fr 1fr; } }
.groups { columns: 3 230px; column-gap: 24px; }
.group { padding-top: 2px; margin-bottom: 18px; break-inside: avoid; }
.group h3 { margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.05em; font-size: 11.5px; color: var(--muted); }
.inp { display: grid; grid-template-columns: 1fr 96px 22px; gap: 8px; align-items: center; margin-bottom: 6px; font-size: 13.5px; }
.inp input { height: 32px; }
.inp label { color: var(--ink-2); }
.inp label.has-hint { text-decoration: underline dotted var(--muted); text-underline-offset: 3px; cursor: pointer; }
.inp label.has-hint[aria-expanded="true"] { color: var(--accent); text-decoration-color: var(--accent); }
.inp-hint { grid-column: 1 / -1; margin: 0 0 4px; line-height: 1.4; }
/* посчитано сервисом или подставлено из тарифов склада WB — не правится */
.inp input[readonly] { background: transparent; border-style: dashed; color: var(--ink-2); }
.inp .unit { color: var(--muted); font-size: 12px; }
.breakdown { border-left: 1px solid var(--grid); padding-left: 26px; }
@media (max-width: 960px) { .breakdown { border-left: none; padding-left: 0; } }
.bd-row { display: grid; grid-template-columns: 1fr auto 58px; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--grid); font-variant-numeric: tabular-nums; }
.bd-row .pct { color: var(--muted); text-align: right; font-size: 13px; }
.bd-row.sub { color: var(--ink-2); }
.bd-row.eq { font-weight: 650; border-bottom-style: solid; }
.bd-row.result { font-weight: 740; border-bottom: none; margin-top: 6px; padding: 10px 12px; border-radius: 10px; background: var(--accent-wash); }
.bd-note { margin-top: 12px; font-size: 13px; color: var(--ink-2); }
/* черновик нового товара: обведён, внизу «Отмена» и «Сохранить» */
details.product.draft { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
details.product .tag { margin-left: 2px; }
.p-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; padding: 14px 20px 18px; border-top: 1px solid var(--grid); }
.p-actions .muted { margin-right: auto; }
.levers { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: end; margin-bottom: 16px; padding: 14px 16px; border-radius: 12px; background: var(--surface-2); }
.levers .field { min-width: 150px; }
.levers .field input { width: 140px; }

/* ---------- отчёты и загрузка ---------- */
.drop {
  display: grid; justify-items: center; gap: 6px;
  border: 1.5px dashed var(--axis); border-radius: var(--radius); padding: 30px 24px; text-align: center; color: var(--ink-2);
  background: var(--surface-2); cursor: pointer; transition: background .15s, border-color .15s;
}
.drop svg { color: var(--accent); margin-bottom: 4px; }
.drop.over, .drop:hover { background: var(--accent-wash); border-color: var(--accent); }
.drop strong { color: var(--ink); font-size: 15px; }
.week-head { display: flex; flex-wrap: wrap; gap: 8px 28px; align-items: center; flex: 1; }
.week-head h2 { font-size: 15.5px; min-width: 210px; }
.week-head .kpi { display: grid; gap: 1px; }
.week-head .kpi span:first-child { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.week-head .kpi span:last-child { font-weight: 680; font-variant-numeric: tabular-nums; }
.files { margin: 12px 0 8px; display: grid; gap: 8px; }
.file { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; font-size: 13px; color: var(--ink-2); }
.file input[type="date"] { height: 30px; }
.ads-input { width: 110px; height: 32px; }
.warn {
  border: 1px solid color-mix(in srgb, var(--bad) 25%, transparent); padding: 11px 14px; background: var(--bad-wash);
  border-radius: 12px; margin-bottom: 16px; font-size: 14px;
}

/* ход загрузки из WB API */
.progress:empty { display: none; }
.progress { margin-top: 14px; border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; display: grid; gap: 12px; background: var(--surface-2); }
.progress-status { font-weight: 650; }
.progress-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px 16px; }
.progress-grid div { display: grid; gap: 2px; font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: var(--grid); border-radius: 999px; overflow: hidden; position: relative; }
.bar span { display: block; height: 100%; background: var(--btn); border-radius: 999px; transition: width .9s linear; }
.bar.busy span { width: 30%; position: absolute; animation: busy 1.4s ease-in-out infinite; }
@keyframes busy { 0% { left: -30%; } 100% { left: 100%; } }

/* ---------- график ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .tick { fill: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.chart .label { fill: var(--ink); font-size: 12px; font-weight: 700; }
.chart .grid { stroke: var(--grid); stroke-width: 1; stroke-dasharray: 3 4; }
.chart .base { stroke: var(--axis); stroke-width: 1; }
/* столбик и подпись лежат поверх .hit — без pointer-events: none на самом столбике подсказки не было */
.chart .bar, .chart .label { pointer-events: none; }
.chart .bar { fill: url(#bar-fill); }
.chart .bar.neg { fill: var(--bad); opacity: 0.85; }
.chart .hit { fill: transparent; cursor: default; outline: none; }
.chart .hit:hover + .bar, .chart .hit:focus + .bar { filter: brightness(1.15) saturate(1.1); }
.tip {
  position: fixed; z-index: 50; pointer-events: none; background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; font-size: 13px;
  box-shadow: var(--shadow-md); min-width: 150px;
}
.tip .v { font-weight: 740; font-size: 16px; font-variant-numeric: tabular-nums; }
.tip .k { color: var(--ink-2); }

/* ---------- уведомления ---------- */
#toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 10px; z-index: 60; max-width: 400px; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px 12px 16px;
  box-shadow: var(--shadow-md); font-size: 14px; position: relative; overflow: hidden; animation: toast-in .22s ease-out;
}
.toast::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--btn); }
.toast.err::before { background: var(--bad); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
  .bar.busy span { animation: none; width: 100%; opacity: .5; }
}

/* ---------- вход, админ в чужом кабинете ---------- */
.imp-banner {
  display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap;
  padding: 9px 24px; background: var(--amber-wash); color: var(--ink); border-bottom: 1px solid color-mix(in srgb, var(--amber) 35%, transparent); font-size: 14px;
}
/* участник в чужом кабинете — спокойнее, чем админ в кабинете продавца */
.imp-banner.member-banner { background: var(--accent-wash); border-bottom-color: var(--accent-ring); }

/* ---------- кабинеты: переключатель, участники ---------- */
.ws-switch { width: 100%; height: 32px; font-size: 13px; }
/* выбор магазина — под названием сервиса */
.shop { padding: 0 4px 16px; }
.shop:empty { display: none; }
@media (max-width: 1023px) { .ws-switch { width: auto; max-width: 180px; } .shop { padding: 0; } }
.member-form input[type="email"] { flex: 1 1 240px; }
.invites ul { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 6px; font-size: 13.5px; }
.members-card h3 { margin: 18px 0 8px; font-size: 14.5px; }
.auth { min-height: calc(100vh - 140px); display: grid; place-items: center; padding: 20px 0; }
.auth-card { width: 100%; max-width: 410px; padding: 30px 30px 26px; box-shadow: var(--shadow-md); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand img { width: 44px; height: 44px; border-radius: 12px; box-shadow: 0 6px 16px rgba(91, 76, 240, 0.3); }
.auth-brand b { font-size: 16px; font-weight: 720; letter-spacing: -0.01em; }
.auth-card h1 { font-size: 22px; margin-bottom: 6px; }
.auth-card form { display: grid; gap: 14px; margin-top: 18px; }
.auth-card form .btn { height: 42px; font-size: 15px; }
.auth-field input { width: 100%; height: 42px; font-size: 15px; }
.auth-msg { color: var(--bad); margin: 0; min-height: 1.2em; font-size: 14px; }
.link-box { margin-top: 14px; padding: 14px 16px; border: 1px solid var(--accent-ring); border-radius: 12px; background: var(--accent-wash); }

/* ---------- профиль ---------- */
.profile > div > .card { max-width: 680px; }
.profile form { display: grid; gap: 14px; margin-top: 4px; max-width: 420px; }
.profile .token-row input { flex: 1; min-width: 240px; }
.profile .token-row + p { margin-top: 10px; }

/* ---------- что нового ---------- */
.news-day { max-width: 840px; }
.news-day h2 { display: flex; align-items: center; gap: 10px; }
.news-day ul { margin: 6px 0 0; padding-left: 20px; display: grid; gap: 10px; line-height: 1.55; }
.news-day li::marker { color: var(--accent); }
.news-new { color: var(--teal); border-color: color-mix(in srgb, var(--teal) 45%, transparent); background: transparent; }

/* ---------- прочее ---------- */
.notes { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-bottom: 16px; }
.note { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; font-size: 13.5px; color: var(--ink-2); }
.note b { color: var(--ink); }
.hint { color: var(--ink-2); font-size: 13px; text-align: left; white-space: normal; min-width: 280px; max-width: 460px; }
.empty { display: grid; justify-items: center; gap: 8px; text-align: center; padding: 40px 20px; color: var(--ink-2); }
.empty svg { color: var(--muted); }

/* ---------- тема: переключатель ---------- */
.auth-theme { display: flex; justify-content: flex-end; margin-bottom: -8px; }
.seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.seg .btn { border-color: transparent; background: transparent; box-shadow: none; color: var(--ink-2); }
.seg .btn:hover { background: var(--surface); }
.seg .btn[aria-pressed="true"] { background: var(--surface); color: var(--accent); border-color: var(--border); box-shadow: var(--shadow-xs); }

/* ---------- окно подтверждения ---------- */
dialog.modal {
  border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--ink);
  padding: 22px 24px 20px; width: min(480px, calc(100% - 32px)); box-shadow: var(--shadow-md);
}
dialog.modal::backdrop { background: rgba(8, 10, 18, 0.55); backdrop-filter: blur(2px); }
dialog.modal h2 { font-size: 18px; margin-bottom: 10px; }
dialog.modal p { color: var(--ink-2); }
.modal-list { margin: 4px 0 12px; padding-left: 20px; display: grid; gap: 4px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.btn.danger-solid { background: var(--bad); border-color: transparent; color: #fff; }
.btn.danger-solid:hover { filter: brightness(1.08); background: var(--bad); }

/* ---------- уведомление: токену WB не хватает разделов ---------- */
.notice {
  margin-bottom: 16px; padding: 12px 16px; border-radius: 12px; font-size: 13.5px;
  background: var(--amber-wash); border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent);
}
.notice strong { display: block; margin-bottom: 6px; color: var(--ink); }
.notice ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; color: var(--ink-2); }
.notice-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.notice-actions .btn { margin-left: auto; }
/* что-то сломалось (истёк токен, загрузка не удалась) — красным, а не жёлтым */
.notice.bad { background: var(--bad-wash); border-color: color-mix(in srgb, var(--bad) 28%, transparent); }
.as-of { margin: -6px 0 14px; }

/* ---------- настройки: права токена, загрузка, данные ---------- */
.scopes { margin-top: 16px; padding: 14px 16px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.scopes-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.scopes-head h3 { margin: 0; color: var(--ink); font-size: 14px; }
.scopes-head .btn { margin-left: auto; }
.scopes ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.scope { display: grid; grid-template-columns: 24px 1fr; gap: 10px; align-items: start; }
.scope-mark {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
}
.scope.ok .scope-mark { background: var(--good-wash); border-color: transparent; color: var(--good); }
.scope.no .scope-mark { background: var(--bad-wash); border-color: transparent; color: var(--bad); }
.scope-text { color: var(--ink-2); margin-top: 2px; }
.scope.ok .scope-text { color: var(--muted); }
.scopes-fix { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--amber-wash); color: var(--ink); }
.range { display: grid; gap: 10px; margin: 6px 0 14px; }
/* автоподгрузка: галочка, объяснение и чем кончилась последняя */
.auto-import { display: grid; gap: 6px; margin-bottom: 16px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.auto-import p { margin: 0; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.auto-last { color: var(--ink-2); }
.radio { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; cursor: pointer; }
.radio input[type="radio"] { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.parts { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13.5px; }
.part { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.part-mark { width: 16px; text-align: center; font-weight: 700; color: var(--muted); }
.part.done .part-mark { color: var(--good); }
.part.error .part-mark, .part.error strong { color: var(--bad); }
.part.run .part-mark::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
.data-summary p { margin-bottom: 4px; }
.delete-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--grid); }

/* ---------- выбор периода: поле и окно с быстрыми периодами и календарём ---------- */
.dr-field {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 11px; max-width: 100%;
  background: var(--input); border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; white-space: nowrap; font-weight: 500; font-variant-numeric: tabular-nums;
  transition: border-color .15s, box-shadow .15s;
}
.dr-field svg { flex: none; color: var(--muted); }
.dr-field:hover { border-color: var(--axis); }
.dr-field:focus-visible, .dr-field[aria-expanded="true"] { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); border-radius: var(--radius-sm); }
dialog.dr-pop {
  position: fixed; inset: auto; margin: 0; padding: 0; max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); overflow: auto;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-md);
}
dialog.dr-pop::backdrop { background: transparent; }
.dr-body { display: flex; }
.dr-presets { display: grid; align-content: start; gap: 2px; min-width: 176px; padding: 12px 8px; border-right: 1px solid var(--grid); }
.dr-presets button {
  text-align: left; border: 0; background: transparent; padding: 7px 10px; border-radius: 8px;
  font-size: 13.5px; color: var(--ink-2); cursor: pointer; white-space: nowrap;
}
.dr-presets button:hover { background: var(--surface-2); color: var(--ink); }
.dr-presets button[aria-pressed="true"] { background: var(--accent-wash); color: var(--accent); font-weight: 600; }
.dr-presets button:disabled { opacity: 0.4; cursor: default; background: transparent; color: var(--ink-2); }
.dr-cal { padding: 14px 16px 12px; }
.dr-months { display: flex; gap: 24px; }
.dr-mhead { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 8px; }
.dr-nav { width: 30px; height: 30px; padding: 0; flex: none; }
.dr-mhead select { height: 30px; border-color: transparent; background-color: transparent; font-weight: 650; padding-left: 8px; }
.dr-mhead select:hover { border-color: var(--border); }
.dr-grid { display: grid; grid-template-columns: repeat(7, 36px); row-gap: 2px; }
.dr-wd { height: 24px; line-height: 24px; text-align: center; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.dr-day {
  position: relative; height: 34px; padding: 0; border: 0; border-radius: 8px; background: transparent;
  font-size: 13.5px; color: var(--ink); font-variant-numeric: tabular-nums; cursor: pointer;
}
.dr-day:hover { background: var(--surface-2); }
.dr-day.nodata { color: var(--muted); }
.dr-day:disabled { opacity: 0.35; cursor: default; background: transparent; color: var(--muted); }
.dr-day.today::after { content: ""; position: absolute; left: 50%; bottom: 4px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--accent); }
/* период — сплошной полосой; скругление на краях строки и месяца */
.dr-day.in { background: var(--accent-wash); border-radius: 0; }
.dr-day.in.rl, .dr-day.start { border-top-left-radius: 8px; border-bottom-left-radius: 8px; }
.dr-day.in.rr, .dr-day.end { border-top-right-radius: 8px; border-bottom-right-radius: 8px; }
.dr-day.start, .dr-day.end { background: var(--btn); color: #fff; font-weight: 650; }
.dr-day.start.today::after, .dr-day.end.today::after { background: #fff; }
.dr-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--grid); }
.dr-sum { font-size: 13.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.dr-spacer { flex: 1; }
.dr-foot .btn:disabled { cursor: default; }
/* телефон: окно снизу во всю ширину, один месяц, быстрые периоды — кнопками в ряд */
@media (max-width: 640px) {
  dialog.dr-pop { left: 8px; right: 8px; bottom: 8px; width: auto; }
  dialog.dr-pop::backdrop { background: rgba(8, 10, 18, 0.55); }
  .dr-body { flex-direction: column; }
  .dr-presets { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; padding: 12px; border-right: 0; border-bottom: 1px solid var(--grid); }
  .dr-presets button { border: 1px solid var(--border); border-radius: 999px; padding: 5px 11px; font-size: 13px; }
  .dr-presets button[aria-pressed="true"] { border-color: transparent; }
  .dr-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .dr-months { display: block; }
  .dr-sum { flex-basis: 100%; }
  .dr-spacer { display: none; }
  .dr-foot .btn { flex: 1; height: 38px; }
}

/* ---------- себестоимость по датам ---------- */
.cost-cell { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.cost-now { display: grid; justify-items: end; line-height: 1.25; }
.costs-table td[data-cogs] { transition: opacity .15s; }
.costs-table td.pending { opacity: 0.45; }
.costs-table tr.cost-panel-row td { background: var(--surface-2); white-space: normal; text-align: left; }
.costs-table tbody tr.cost-panel-row:hover td { background: var(--surface-2); }
.cost-panel { display: grid; gap: 12px; justify-items: end; padding: 4px 0; }
/* цены по датам — одной сеткой: даты, суммы и кнопки друг под другом */
.cost-hist { display: grid; grid-template-columns: auto 120px auto; gap: 6px 10px; align-items: center; justify-items: end; }
.cost-hist-row { display: contents; }
.cost-hist-row span { color: var(--ink-2); font-size: 13.5px; }
.cost-add { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; font-size: 13.5px; color: var(--ink-2); }
.cost-panel p { margin: 0; max-width: 560px; text-align: right; }
/* телефон: таблица шире экрана — список цен держится у левого края видимой части */
@media (max-width: 700px) {
  .cost-panel { position: sticky; left: 0; width: calc(100vw - 96px); justify-items: start; }
  .cost-hist { justify-items: start; }
  .cost-add { justify-content: flex-start; }
  .cost-panel p { text-align: left; }
}

/* ---------- реклама ---------- */
.ad-form { display: grid; grid-template-columns: minmax(170px, 1fr) minmax(220px, 1.6fr) minmax(170px, 1fr) minmax(120px, 0.7fr); gap: 12px 14px; align-items: end; }
.ad-form .field.wide:last-of-type { grid-column: span 3; }
.ad-form select, .ad-form input { width: 100%; }
.ad-form .btn { height: 36px; }
@media (max-width: 860px) { .ad-form { grid-template-columns: 1fr 1fr; } .ad-form .field.wide { grid-column: 1 / -1; } }
.ads-total { font-size: 14px; }

/* ---------- расходы бизнеса ---------- */
.exp-form { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px 14px; align-items: end; }
.exp-form select, .exp-form input { width: 100%; }
.exp-form .gp { display: block; width: 100%; min-width: 0; }
.exp-form .btn { height: 36px; }
@media (max-width: 860px) { .exp-form { grid-template-columns: 1fr 1fr; } }
.ads-table tr.editing td > input + input, .ads-table tr.editing td > select + span { display: block; margin-top: 6px; }

/* ---------- себестоимость из Excel ---------- */
.paste-area {
  width: 100%; min-height: 140px; resize: vertical; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--input); color: var(--ink); border: 1px solid var(--border);
  font: 13px/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace;
}
.paste-area:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.paste-result:not(:empty) { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.paste-result p { margin: 0 0 8px; }
.paste-unknown { margin: 6px 0 0; padding-left: 18px; font: 12.5px/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace; overflow-wrap: anywhere; }

/* ---------- прикидка: тарифы WB ---------- */
.p-tariffs { display: grid; gap: 10px; margin: 6px 0 18px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.p-tariffs h3 { margin: 0; }
.p-tariffs .seg { justify-self: start; flex-wrap: wrap; }
.pt-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.pt-grid input, .pt-grid select { width: 100%; }
@media (max-width: 700px) { .pt-grid { grid-template-columns: minmax(0, 1fr); } }
.pt-found { display: grid; gap: 2px; max-height: 260px; overflow-y: auto; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.pt-cat { display: grid; gap: 2px; text-align: left; padding: 7px 10px; border: 0; border-radius: 8px; background: transparent; color: inherit; font: inherit; cursor: pointer; }
.pt-cat:hover, .pt-cat:focus-visible { background: var(--accent-wash); }
.pt-chosen { margin: 0; font-weight: 600; }
.pt-chosen:empty, .pt-status:empty, .pt-whnote:empty { display: none; }
.pt-whnote { margin: 0; }
.pt-fact { display: grid; gap: 6px; }
.pt-fact .row { gap: 8px; }
.pt-fact .gp { min-width: 220px; }
.pt-fact p { margin: 0; }
.pt-hint { margin: 4px 10px 2px; }
.pt-parent { grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; }
.pt-back { color: var(--accent); font-weight: 600; }
.pt-status { margin: 0; }

/* ---------- вкладки настроек ---------- */
.settings-tabs { display: flex; flex-wrap: wrap; width: fit-content; max-width: 100%; margin: -8px 0 18px; }
.settings-tabs .btn { text-decoration: none; }

/* ---------- написать нам ---------- */
.seg.seg-wrap { flex-wrap: wrap; justify-self: start; }
.fb-form { display: grid; gap: 16px; max-width: 760px; }
.fb-hint { margin: 2px 0 0; font-weight: 400; }
.fb-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.fb-row select, .fb-row input { width: 100%; }
@media (max-width: 700px) { .fb-row { grid-template-columns: minmax(0, 1fr); } }
.text-area {
  width: 100%; min-height: 140px; resize: vertical; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--input); color: var(--ink); border: 1px solid var(--border); font: inherit; line-height: 1.5;
}
.text-area:hover { border-color: var(--axis); }
.text-area:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.fb-send { gap: 14px; }
.fb-send .muted { flex: 1 1 260px; }
.fb-list { display: grid; gap: 10px; margin-top: 14px; }
.fb-item { display: grid; gap: 8px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.fb-item.fb-new { border-color: var(--accent-ring); }
.fb-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fb-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.fb-actions { gap: 8px; }
.fb-actions input { flex: 1 1 220px; }
.tag.tag-good { color: var(--good); border-color: color-mix(in srgb, var(--good) 35%, transparent); background: var(--good-wash); }

/* ---------- по дням и остатки ---------- */
.kpis.kpis-even { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1180px) { .kpis.kpis-even { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi-tile.warn-tile { border-color: color-mix(in srgb, var(--amber) 40%, transparent); background: var(--amber-wash); }
.tag.tag-bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); background: var(--bad-wash); }
.tag.tag-warn { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 40%, transparent); background: var(--amber-wash); }
.tag.fresh-tag { margin-left: 8px; color: var(--accent); border-color: var(--accent-ring); background: var(--accent-wash); }

/* остатки по складам: раскрытая строка товара и выбор складов WB */
.wh-toggle { display: inline; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.wh-toggle svg { vertical-align: -2px; margin-right: 6px; color: var(--muted); transform: rotate(-90deg); transition: transform .15s; }
.wh-toggle[aria-expanded="true"] svg { transform: none; }
.wh-toggle:hover .wh-good { color: var(--accent); }
tr.wh-open td { border-bottom-color: transparent; }
tr.wh-row td { background: var(--surface-2); padding-top: 8px; padding-bottom: 12px; }
/* склады товара — компактно слева: таблица шире экрана, во всю её ширину список уехал бы за край */
.wh-list { list-style: none; margin: 0; padding: 0 0 0 20px; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 250px)); gap: 4px 28px; max-width: 860px; }
.wh-list li { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 3px 0; border-bottom: 1px dashed var(--grid); }
.wh-name { display: inline-flex; align-items: baseline; gap: 6px; }
.tag.stock-tag { display: inline-block; margin-left: 8px; vertical-align: 1px; white-space: nowrap; }
.wh-name .tag { font-size: 10.5px; }
.wh-pick { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 6px 4px; font-size: 13.5px; cursor: pointer; }
.wh-pick:hover { background: var(--surface-2); border-radius: 8px; }
.wh-pick[hidden] { display: none; }
.wh-pop-body { display: grid; gap: 8px; padding: 12px 12px 10px; width: 340px; max-width: 100%; }
.wh-pop-body input[type="search"] { width: 100%; }
.wh-items { max-height: 320px; overflow-y: auto; display: grid; }
.fbs-list { display: grid; max-width: 520px; }
.dr-field:disabled { opacity: 0.5; cursor: default; }

/* ---------- акции WB: выбранная акция в списке, её описание ---------- */
tr.promo-on td { background: var(--accent-wash); }
.promo-pick[aria-pressed="true"] .wh-good { color: var(--accent); font-weight: 650; }
.promo-about { margin: 0 0 10px; max-width: 860px; white-space: pre-line; }
.promo-adv { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.promo-table td:first-child { min-width: 230px; }
/* заголовки длиннее цифр под ними — переносятся, иначе таблица шире карточки */
.promo-table thead th { white-space: normal; vertical-align: bottom; min-width: 90px; }
@media (max-width: 560px) { .promo-table td:first-child { min-width: 170px; } }

/* ---------- кто тянет прибыль вниз ---------- */
.drags-sum { margin: 0 0 10px; }
.drags h3 { margin: 18px 0 6px; font-size: 14.5px; }
.tag.from-wb { margin-left: 8px; color: var(--accent); border-color: var(--accent-ring); background: var(--accent-wash); }
.ads-table tr.editing td { background: var(--accent-wash); vertical-align: middle; }
.ads-table tr.editing select, .ads-table tr.editing input { height: 32px; min-width: 110px; width: 100%; }
.empty { text-align: center; padding: 34px 24px; color: var(--ink-2); display: grid; justify-items: center; gap: 12px; }
.empty p { margin: 0; max-width: 520px; }
@media (prefers-reduced-motion: reduce) { .part.run .part-mark::before { animation: none; } }
