/* KoreLab UI — единый визуальный слой для основного и аналитического контуров. */

html { color: var(--text-primary); background: var(--surface-canvas); }
body {
  color: var(--text-primary);
  background: var(--surface-canvas);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,input,select,textarea { font-family: Onest,sans-serif; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,summary:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}
button:disabled { cursor: default; opacity: .48; }

/* Верхняя панель */
.topbar,.access-topbar {
  border-color: var(--border-subtle);
  color: var(--text-primary);
  background: var(--surface-raised);
  box-shadow: var(--shadow-card);
  backdrop-filter: none;
}
.topbar .rail-brand__mark,.access-brand i,.login-brand i {
  background: linear-gradient(145deg,color-mix(in srgb,var(--action-primary) 16%,#fff),var(--action-primary));
  box-shadow: none;
}
.topbar__context p,.eyebrow,.page-head .eyebrow,.panel__head p,.access-head p { color: var(--action-primary); }
.topbar-account { border-color: var(--border-subtle); }
.topbar-account a,.topbar-account button,.refresh,.nav-toggle {
  border-color: var(--border-subtle);
  color: var(--text-secondary);
  background: var(--surface-raised);
  box-shadow: 0 1px 2px rgba(24,38,31,.025);
  transition: color .16s ease,border-color .16s ease,background .16s ease,transform .16s ease;
}
.topbar-account a:hover,.topbar-account button:hover,.refresh:hover,.nav-toggle:hover {
  border-color: color-mix(in srgb,var(--action-primary) 46%,var(--border-subtle));
  color: var(--action-primary);
  background: var(--action-soft);
}
.refresh svg,.topbar-account svg,.nav-settings svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.refresh.is-loading svg { animation: spin .8s linear infinite; }

/* Навигация */
.nav-settings > svg { flex: 0 0 auto; }
.nav-settings-panel,.app-nav__group-panel { border-color: var(--border-subtle); box-shadow: var(--shadow-float); }
.nav-settings__row button { display: grid; place-items: center; }
.ui-move,.ui-chevron { position: relative; display: inline-block; width: 12px; height: 12px; }
.ui-move::before {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 6px;
  height: 6px;
  border-top: 1.5px solid currentColor;
  border-left: 1.5px solid currentColor;
  content: "";
  transform: rotate(45deg);
}
.ui-move.is-down::before { top: 1px; transform: rotate(225deg); }
.ui-visibility { width: 14px; height: 9px; border: 1.5px solid currentColor; border-radius: 50%; }
.ui-visibility::after { display: block; width: 4px; height: 4px; margin: 1px auto 0; border-radius: 50%; background: currentColor; content: ""; }
.ui-chevron::before {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  content: "";
  transform: rotate(-45deg);
  transition: transform .16s ease;
}
[aria-expanded="true"] > .ui-chevron::before,.ui-chevron.is-open::before { transform: rotate(45deg); }

@media (min-width:821px) {
  .app-rail { box-shadow: none; }
  .app-nav button {
    min-height: var(--control-height);
    grid-template-columns: 17px minmax(0,1fr);
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-control);
    transition: color .12s ease,background .12s ease;
  }
  .app-nav button:hover { transform: none; }
  .app-nav button.is-active {
    border-color: transparent;
    color: var(--text-on-action);
    background: var(--action-primary);
    box-shadow: none;
  }
}

.app-rail {
  border-right: 1px solid var(--border-subtle);
  color: var(--text-primary);
}
.app-rail::before { display: none; }
.app-rail .rail-brand { color: var(--text-primary); }
.app-rail .rail-brand__mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(145deg,#6da3ff,var(--action-primary));
  box-shadow: none;
}
.app-rail .rail-brand small { color: var(--text-faint); }
.app-nav { scrollbar-color: var(--border-strong) transparent; }
.app-nav__group > summary { color: var(--text-faint); }
.app-nav__group > summary:hover { color: var(--text-secondary); background: var(--surface-hover); }
.app-nav__group:has(button.is-active) > summary { color: var(--text-secondary); background: transparent; }
.app-nav__group-panel { padding-left: 0; border: 0; background: transparent !important; box-shadow: none; }
.app-nav button { color: var(--text-secondary); }
.app-nav button > b { font-size: 11px; font-weight: 500; }
.app-nav__icon {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.45;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.app-nav button:hover { color: var(--text-primary); background: var(--surface-hover); }
.app-nav button.is-active { color: var(--text-on-action); background: var(--action-primary); box-shadow: none; }
.app-nav button.is-active > b { font-weight: 600; }
.app-rail__toggle,.nav-settings {
  border-color: var(--border-subtle);
  color: var(--text-secondary);
  background: var(--surface-raised);
}
.app-rail__toggle:hover,.nav-settings:hover,.nav-settings[aria-expanded="true"] {
  border-color: var(--border-strong);
  color: var(--text-primary);
  background: var(--surface-hover);
}
.nav-settings-panel { color: var(--text-primary); background: var(--surface-raised) !important; }
.nav-settings-panel > strong,.nav-settings__row--group { color: var(--text-primary); }
.nav-settings__row,.nav-settings__row--item { color: var(--text-secondary); }
.nav-settings__row button { border-color: var(--border-subtle); color: var(--text-secondary); background: var(--surface-soft); }
.app-rail__foot { border-color: var(--border-subtle); color: var(--text-faint); }
.app-rail__foot strong { color: var(--text-secondary); }
.app-rail__foot i { background: var(--status-positive); box-shadow: none; }

.rail {
  border-right: 1px solid var(--border-subtle);
  color: var(--text-primary);
  box-shadow: none;
}
.rail::before { display: none; }
.rail .brand { margin-bottom: 24px; }
.rail .brand__mark { border-radius: 9px; box-shadow: none; }
.rail .brand small { color: var(--text-faint); }
.rail-nav { gap: 2px; }
.rail-nav button {
  min-height: var(--control-height);
  padding: 7px 10px;
  border-radius: var(--radius-control);
  color: var(--text-secondary);
  transition: color .12s ease,background .12s ease;
}
.rail-nav button:hover { color: var(--text-primary); background: var(--surface-hover); }
.rail-nav button.is-active { color: var(--action-primary); background: var(--surface-selected); box-shadow: none; }
.rail-foot { border-color: var(--border-subtle); color: var(--text-faint); }
.rail-foot strong { color: var(--text-secondary); }
.rail-foot i { background: var(--status-positive); box-shadow: none; }

/* Фильтры и элементы управления */
.filters,.filter-dock {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  color: var(--text-primary);
  background: var(--surface-raised);
  box-shadow: var(--shadow-card);
  backdrop-filter: none;
}
.filter-group label,.filter-field label,.form-field label,.params label,.password-dialog label {
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .04em;
}
select {
  appearance: none;
  padding-right: 34px !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%23758391' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat !important;
  background-position: right 11px center !important;
  background-size: 14px !important;
}
.chip,.filter-field select,.params input,.params select,.search,.compare-switch,.icon-btn,
.primary-btn,.secondary-btn,.chart-segmented,.segmented,.password-dialog input,
.form-field input,.form-field select,.form-field textarea,.pnl-toolbar__period {
  border-color: var(--border-subtle);
  color: var(--text-primary);
  background-color: var(--surface-raised);
}
.chip,.filter-field select,.params input,.params select,.search,.compare-switch,.icon-btn,
.primary-btn,.secondary-btn,.password-dialog input,.form-field input,.form-field select {
  min-height: var(--control-height);
  border-radius: var(--radius-control);
  font-size: 11px;
}
.chip:hover,.icon-btn:hover,.secondary-btn:hover { border-color: color-mix(in srgb,var(--action-primary) 45%,var(--border-subtle)); background-color: var(--surface-hover); }
.chip.is-active,.segmented button.is-active,.chart-segmented button.is-active,.primary-btn {
  border-color: var(--action-primary);
  color: var(--text-on-action);
  background: var(--action-primary);
  box-shadow: none;
}
.segmented,.chart-segmented { padding: 2px; border: 1px solid var(--border-subtle); border-radius: var(--radius-control); background: var(--surface-soft); }
.segmented button,.chart-segmented button { min-height: 30px; padding: 6px 10px; border-radius: 7px; color: var(--text-secondary); font-size: 10px; font-weight: 500; }
.segmented button:hover,.chart-segmented button:hover { color: var(--action-primary); }

/* Карточки и панели */
.kpi,.kpi-grid .kpi:first-child,.kpi.is-dark {
  --kpi-accent: var(--action-primary);
  position: relative;
  min-height: 118px;
  padding: 16px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  color: var(--text-primary);
  background: var(--surface-raised);
  box-shadow: var(--shadow-card);
  transition: border-color .12s ease,background .12s ease;
}
.kpi:hover { border-color: var(--border-strong); box-shadow: var(--shadow-card); transform: none; }
.kpi::before { display: none; }
.kpi::after,.kpi.is-dark::after { display: none; }
.kpi.is-green { --kpi-accent: var(--status-positive); }
.kpi.is-red,.kpi.is-danger { --kpi-accent: var(--status-negative); }
.kpi.is-amber { --kpi-accent: var(--status-warning); }
.kpi__label,.kpi-grid .kpi:first-child .kpi__label,.kpi.is-dark .kpi__label {
  min-height: 0;
  margin: 0;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
}
.kpi__value { margin: 12px 0 7px; color: var(--text-primary); font-size: clamp(22px,2vw,29px); font-weight: 600; letter-spacing: -.04em; line-height: 1.08; }
.kpi.is-green .kpi__value { color: var(--status-positive); }
.kpi.is-red .kpi__value,.kpi.is-danger .kpi__value { color: var(--status-negative); }
.kpi.is-amber .kpi__value { color: var(--status-warning); }
.kpi__sub,.kpi-grid .kpi:first-child .kpi__sub,.kpi__foot,.kpi.is-dark .kpi__foot { margin-top: 0; color: var(--text-secondary); font-size: 10px; line-height: 1.35; }
.kpi__foot { margin-top: 10px; }
.kpi__delta { padding: 3px 6px; color: var(--status-positive); background: var(--status-positive-soft); }
.kpi__delta.is-bad { color: var(--status-negative); background: var(--status-negative-soft); }

.panel,.users-card,.inventory-notice,.price-method-note,.password-dialog,.access-modal,.login-card {
  border-color: var(--border-subtle);
  border-radius: var(--radius-card);
  color: var(--text-primary);
  background: var(--surface-raised);
  box-shadow: var(--shadow-card);
}
.panel__head { padding: 18px 20px 15px; border-color: var(--border-subtle); }
.panel__head p { margin-bottom: 4px; font-size: 10px; letter-spacing: .085em; }
.panel__head h2 { color: var(--text-primary); font-size: 16px; font-weight: 600; letter-spacing: -.025em; }
.panel__head small,.panel__note,.table-note { color: var(--text-secondary); font-size: 10px; }
.signal-list { padding: 5px 18px 14px; }
.signal { border-color: var(--border-subtle); }
.signal strong { color: var(--text-primary); font-size: 12px; }
.signal p,.signal em { font-size: 10px; }
.insight,.formula-note { color: var(--text-secondary); background: var(--status-warning-soft); }
.empty,.loading,.access-empty { color: var(--text-secondary); }

/* Таблицы: единый канон ПиУ */
table,.data-table,.pnl-table,.weekly-fact-table { color: var(--text-primary); font-size: var(--table-text-size); font-variant-numeric: tabular-nums; }
table th,.data-table th,.pnl-table th,.weekly-fact-table th {
  height: 40px;
  padding: 8px 11px;
  border-color: var(--border-subtle);
  color: var(--text-secondary);
  background: var(--surface-soft);
  font-size: var(--table-head-size);
  font-weight: 500;
}
table td,.data-table td,.pnl-table td,.weekly-fact-table td {
  height: 44px;
  padding: 7px 11px;
  border-color: color-mix(in srgb,var(--border-subtle) 68%,transparent);
  color: var(--text-primary);
  background: var(--surface-raised);
  font-size: var(--table-text-size);
}
.data-table td:first-child,.pnl-table td:first-child,.heat-table th:first-child,.heat-table td:first-child { background: var(--surface-raised); }
.data-table tr:hover td,.data-table tr:hover td:first-child,
.pnl-table tbody tr:hover,.pnl-table tbody tr:hover td:first-child,
.users-table tbody tr:hover td { background: var(--surface-hover); }
.data-table .row-summary td,.data-table .row-summary td:first-child,.pnl-row-top.pnl-income > td { background: var(--status-positive-soft); }
.data-table .row-expense td,.data-table .row-expense td:first-child,.pnl-row-top.pnl-expense > td { background: var(--status-negative-soft); }
.data-table .row-primary td,.data-table .row-primary td:first-child { background: var(--surface-selected); border-color: color-mix(in srgb,var(--action-primary) 18%,var(--border-subtle)); }
.data-table .row-section td,.data-table .row-section td:first-child {
  height: 32px;
  color: var(--text-secondary);
  background: color-mix(in srgb,var(--surface-soft) 78%,var(--surface-canvas));
  font-size: 9px;
}
/* Все рабочие таблицы используют непрерывные строки. */
.workspace .data-table:not(.weekly-fact-table) {
  border-collapse: collapse;
  border-spacing: 0;
  padding: 0;
}
.workspace .data-table:not(.weekly-fact-table) thead th {
  height: 38px;
  border-right: 0;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-soft);
}
.workspace .data-table:not(.weekly-fact-table) tbody td {
  height: 44px;
  padding: 8px 11px;
  border: 0;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-raised);
  transition: background .12s ease;
}
.workspace .data-table:not(.weekly-fact-table) tbody td:first-child {
  border-left: 0;
  border-radius: 0;
  background: var(--surface-raised);
}
.workspace .data-table:not(.weekly-fact-table) tbody td:last-child {
  border-right: 0;
  border-radius: 0;
}
.workspace .data-table:not(.weekly-fact-table) tbody tr:hover td,
.workspace .data-table:not(.weekly-fact-table) tbody tr:hover td:first-child {
  background: var(--surface-hover);
  box-shadow: none;
}
.workspace .data-table:not(.weekly-fact-table) tbody tr.row-summary td,
.workspace .data-table:not(.weekly-fact-table) tbody tr.row-summary td:first-child { background: var(--status-positive-soft); }
.workspace .data-table:not(.weekly-fact-table) tbody tr.row-expense td,
.workspace .data-table:not(.weekly-fact-table) tbody tr.row-expense td:first-child { background: var(--status-negative-soft); }
.workspace .data-table:not(.weekly-fact-table) tbody tr.row-primary td,
.workspace .data-table:not(.weekly-fact-table) tbody tr.row-primary td:first-child { background: var(--surface-selected); }
.workspace .data-table:not(.weekly-fact-table) tbody tr.has-uncertain-stock td,
.workspace .data-table:not(.weekly-fact-table) tbody tr.has-uncertain-stock td:first-child,
.inventory-table tr.is-uncertain td { background: var(--status-warning-soft); }
.workspace .data-table:not(.weekly-fact-table) tbody tr.has-destroyed-stock td,
.workspace .data-table:not(.weekly-fact-table) tbody tr.has-destroyed-stock td:first-child,
.inventory-table tr.is-destroyed td,.inventory-table tr.is-affected td { background: var(--status-negative-soft); }
.workspace .data-table:not(.weekly-fact-table) tbody tr.row-section td,
.workspace .data-table:not(.weekly-fact-table) tbody tr.row-section td:first-child {
  height: 34px;
  border-radius: 0;
  background: color-mix(in srgb,var(--surface-soft) 82%,var(--surface-canvas));
}
.cell-main { color: var(--text-primary); font-size: var(--table-text-size); font-weight: 500; }
.cell-sub,.weekly-fact-table .cell-sub,.pnl-value-wrap[data-share]::after {
  margin-top: 3px;
  color: var(--text-secondary);
  font-size: 9px;
  font-weight: 500;
  line-height: 1.1;
}
.expand-btn,.pnl-toggle {
  position: relative;
  border-color: var(--border-subtle);
  color: var(--text-secondary);
  background: var(--surface-soft);
}
.expand-btn:hover,.pnl-toggle:hover { border-color: var(--action-primary); color: var(--action-primary); background: var(--action-soft); }
.change.good { color: var(--status-positive); background: var(--status-positive-soft); }
.change.bad { color: var(--status-negative); background: var(--status-negative-soft); }

.heat-table th,.heat-table td { font-size: var(--table-text-size); }
.heat-table th { font-size: var(--table-head-size); }
.heat-table td:first-child strong,.product-cell strong { font-size: var(--table-text-size); }
.heat-table td:first-child small,.product-cell small,.picker-row small { font-size: var(--table-meta-size); }
.heat-table .h1 { background: color-mix(in srgb,var(--status-positive) 10%,var(--surface-raised)); }
.heat-table .h2 { background: color-mix(in srgb,var(--status-positive) 23%,var(--surface-raised)); }
.heat-table .h3 { background: color-mix(in srgb,var(--status-positive) 41%,var(--surface-raised)); }
.heat-table .h4 { color: color-mix(in srgb,var(--text-primary) 82%,#063b2b); background: color-mix(in srgb,var(--status-positive) 67%,var(--surface-raised)); }
.heat-table .h5 { color: #fff; background: var(--status-positive); }
.heat-table td[data-heat-cell] {
  isolation: isolate;
  cursor: crosshair;
  transition: color .16s ease,background .16s ease,box-shadow .16s ease,transform .16s cubic-bezier(.2,.8,.2,1);
}
.heat-table td[data-heat-cell]:hover,.heat-table td[data-heat-cell]:focus-visible,.heat-table td[data-heat-cell].is-heat-active {
  z-index: 4;
  outline: 2px solid var(--action-primary);
  outline-offset: 1px;
  box-shadow: 0 0 0 4px color-mix(in srgb,var(--action-primary) 13%,transparent),0 12px 28px color-mix(in srgb,var(--blue-black) 22%,transparent);
  transform: translateY(-2px) scale(1.045);
}
.heat-table td.has-ad::after {
  width: 7px;
  height: 7px;
  background: var(--action-primary);
  box-shadow: 0 0 0 2px color-mix(in srgb,var(--surface-raised) 82%,transparent),0 0 9px color-mix(in srgb,var(--action-primary) 74%,transparent);
}
.heat-tooltip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 240;
  width: min(270px,calc(100vw - 24px));
  padding: 13px 14px;
  border: 1px solid color-mix(in srgb,var(--action-primary) 28%,var(--border-subtle));
  border-radius: 14px;
  color: var(--text-primary);
  background: color-mix(in srgb,var(--surface-raised) 96%,transparent);
  box-shadow: 0 18px 48px color-mix(in srgb,var(--blue-black) 26%,transparent),inset 0 1px 0 color-mix(in srgb,#fff 78%,transparent);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate3d(attr(data-x type(<length>),0px),attr(data-y type(<length>),0px),0) scale(.96);
  transform-origin: top left;
  transition: opacity .12s ease,transform .12s ease,visibility .12s ease;
  backdrop-filter: blur(18px) saturate(1.2);
}
.heat-tooltip.is-visible { opacity: 1; visibility: visible; transform: translate3d(attr(data-x type(<length>),0px),attr(data-y type(<length>),0px),0) scale(1); }
.heat-tooltip strong,.heat-tooltip > span { display: block; }
.heat-tooltip strong { overflow: hidden; font-size: 11px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.heat-tooltip > span { margin-top: 2px; color: var(--text-secondary); font-size: 9px; }
.heat-tooltip dl { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 6px 12px; margin: 11px 0 0; padding-top: 10px; border-top: 1px solid var(--border-subtle); font-size: 10px; }
.heat-tooltip dt { color: var(--text-secondary); }
.heat-tooltip dd { margin: 0; font-weight: 600; text-align: right; }
.heat-tooltip dd.is-ad { color: var(--action-primary); }
.product-preview__large { border-color: var(--border-subtle); color: var(--text-primary); background: var(--surface-raised); box-shadow: var(--shadow-float); }

/* Аналитический контур */
.workspace { color: var(--text-primary); }
.workspace .kpi-grid { gap: 12px; margin-bottom: 16px; }
.workspace .dashboard-grid { gap: 16px; margin-bottom: 16px; }
.page-head h1,.intro h1,.access-head h1 { color: var(--text-primary); font-weight: 600; letter-spacing: -.03em; }
.page-head h1,.access-head h1 { font-size: clamp(26px,3vw,32px); line-height: 1.08; }
.intro h1 { font-size: clamp(26px,3vw,32px); line-height: 1.08; }
.page-head p:last-child,.intro > div > p:last-child,.access-head span { color: var(--text-secondary); }
.meta-chip { border-color: var(--border-subtle); color: var(--text-secondary); background: color-mix(in srgb,var(--surface-raised) 88%,transparent); }
.chart-grid { stroke: var(--chart-grid); }
.chart-axis-label,.chart-value,.chart-legend { fill: var(--text-secondary); }
.chart-funnel-track { fill: var(--surface-soft); }
.chart-funnel-bar { fill: var(--action-primary); }
.chart-point { stroke: var(--surface-raised); }
.mode-banner { background: var(--action-primary); }
.mode-banner p { color: color-mix(in srgb,#fff 76%,transparent); }
.tree-item:hover,.picker-row:hover { background: var(--surface-hover); }
.tree-item.is-active,.assign-box { color: var(--text-on-action); background: var(--action-primary); }
.picker-row,.tag,.fact,.calendar-day { border-color: var(--border-subtle); background: var(--surface-raised); }
.dialog-close,.secondary-btn { color: var(--text-primary); background: var(--surface-raised); }
dialog { color: var(--text-primary); background: var(--surface-raised); box-shadow: var(--shadow-float); }
dialog::backdrop,.access-modal-backdrop { background: var(--surface-overlay); }

/* Вход и управление пользователями */
.login-page { background: var(--surface-canvas); }
.login-card { background: var(--surface-raised); }
.login-card input,.login-card select,.form-field input,.form-field select,.permission,.row-actions button {
  border-color: var(--border-subtle);
  color: var(--text-primary);
  background-color: var(--surface-soft);
}
.login-card button,.access-button.is-primary { color: var(--text-on-action); background: var(--action-primary); }
.users-table th { color: var(--text-secondary); background: var(--surface-soft); }
.role-badge { color: var(--action-primary); background: var(--action-soft); }
.permission { background: var(--surface-soft); }

/* План/Факт — рабочая композиция из утверждённого макета. */
.sales-plan { overflow: visible; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.plan-view-tabs {
  min-height: 48px;
  margin: 0 20px 20px;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--border-subtle);
  border-radius: 0;
  background: transparent;
}
.plan-view-tabs > div { align-self: stretch; gap: 24px; }
.plan-view-tabs button {
  min-height: 48px;
  padding: 4px 2px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  color: var(--text-secondary);
  background: transparent;
  font-size: 12px;
}
.plan-view-tabs button.is-active {
  border-color: var(--action-primary);
  color: var(--text-primary);
  background: transparent;
}
.fact-comparison-toolbar {
  margin: 0 20px 16px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  background: var(--surface-raised);
}
.plan-dashboard {
  display: grid;
  grid-template-columns: minmax(0,2.1fr) minmax(310px,.9fr);
  align-items: start;
  gap: 16px;
  margin: 0 20px 20px;
}
.plan-dashboard__main,.plan-dashboard__side { display: grid; min-width: 0; gap: 16px; }
.plan-dashboard__primary { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.plan-dashboard__secondary { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; }
.plan-metric {
  --metric-accent: var(--action-primary);
  --metric-soft: var(--action-soft);
  min-width: 0;
  min-height: 170px;
  padding: 16px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  background: var(--surface-raised);
  box-shadow: var(--shadow-card);
}
.plan-metric--primary { min-height: 218px; padding: 19px; }
.plan-metric[data-plan-metric="op-margin"] { --metric-accent: var(--status-positive); --metric-soft: var(--status-positive-soft); }
.plan-metric[data-plan-metric="orders"] { --metric-accent: #7757d9; --metric-soft: #f0ebff; }
.plan-metric[data-plan-metric="opex"] { --metric-accent: #ef792a; --metric-soft: #fff0e7; }
.plan-metric[data-plan-metric="net-result"] { --metric-accent: #3575e8; --metric-soft: #eaf2ff; }
.plan-metric header { display: flex; align-items: center; gap: 10px; }
.plan-metric h2 { margin: 0; font-size: 14px; font-weight: 650; letter-spacing: -.02em; }
.plan-metric--primary h2 { font-size: 16px; }
.plan-metric__icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--metric-accent);
  background: var(--metric-soft);
}
.plan-metric__icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.plan-metric__values,.plan-metric__comparison { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.plan-metric__values { margin-top: 16px; }
.plan-metric__values > div,.plan-metric__comparison > div { min-width: 0; }
.plan-metric__values span,.plan-metric__comparison span {
  display: block;
  margin-bottom: 5px;
  overflow: hidden;
  color: var(--text-faint);
  font-size: 9px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.plan-metric__values strong,.plan-metric__comparison strong {
  display: block;
  overflow: hidden;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.plan-metric--primary .plan-metric__values strong { font-size: clamp(18px,1.55vw,23px); }
.plan-metric__comparison { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-subtle); }
.plan-metric__comparison strong { color: var(--text-primary); }
.plan-metric__comparison strong.positive { color: var(--status-positive); }
.plan-metric__comparison strong.negative { color: var(--status-negative); }
.plan-metric__bar { height: 3px; margin-top: 17px; overflow: hidden; border-radius: 999px; background: var(--surface-soft); }
.plan-metric__bar i { display: block; height: 100%; border-radius: inherit; background: var(--metric-accent); }
.plan-progress { overflow: hidden; }
.plan-progress .panel__head,.plan-goals .panel__head { padding: 17px 18px; }
.plan-progress__row { padding: 0 18px 18px; }
.plan-progress__row + .plan-progress__row { padding-top: 17px; border-top: 1px solid var(--border-subtle); }
.plan-progress__row > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.plan-progress__row strong,.plan-progress__row b { font-size: 11px; font-weight: 600; }
.plan-progress__row > span,.plan-marketplace__progress {
  display: block;
  height: 6px;
  margin: 8px 0;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}
.plan-progress__row > span i,.plan-marketplace__progress i { display: block; height: 100%; border-radius: inherit; background: var(--action-primary); }
.plan-progress__row small { color: var(--text-faint); font-size: 9px; font-variant-numeric: tabular-nums; }
.plan-marketplace { min-width: 0; overflow: hidden; }
.plan-marketplace__head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 18px; border-bottom: 1px solid var(--border-subtle); }
.plan-marketplace__head p { margin: 0 0 4px; color: var(--action-primary); font-size: 8px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; }
.plan-marketplace__head h2 { margin: 0; font-size: 13px; }
.plan-scenario-switch { display: flex; flex: 0 0 auto; padding: 2px; border: 1px solid var(--border-subtle); border-radius: 9px; background: var(--surface-soft); }
.plan-scenario-switch button { min-height: 30px; padding: 5px 10px; border: 0; border-radius: 7px; color: var(--text-secondary); background: transparent; cursor: pointer; font-size: 9px; font-weight: 550; }
.plan-scenario-switch button.is-active { color: var(--text-on-action); background: var(--action-primary); }
.plan-marketplace table { min-width: 760px; font-size: 9px; }
.plan-marketplace th,.plan-marketplace td { padding: 8px 9px; text-align: right; white-space: nowrap; }
.plan-marketplace thead th { color: var(--text-secondary); background: var(--surface-soft); font-size: 8px; }
.plan-marketplace thead th:first-child,.plan-marketplace tbody th { text-align: left; }
.plan-marketplace tbody th { font-weight: 550; }
.plan-marketplace__badge { display: inline-grid; place-items: center; width: 23px; height: 23px; margin-right: 7px; border-radius: 6px; color: #fff; font-size: 7px; font-weight: 700; }
.plan-marketplace__badge.is-wb { background: #9c199d; }
.plan-marketplace__badge.is-ozon { background: #1263e8; }
.plan-marketplace__progress { width: 86px; height: 5px; margin: 5px 0 0; }
.plan-marketplace__total th,.plan-marketplace__total td { font-weight: 700; background: var(--surface-soft); }
.plan-goals { min-width: 0; overflow: hidden; }
.plan-goals__status { padding: 4px 7px; border-radius: 999px; color: var(--action-primary); background: var(--action-soft); font-size: 8px; font-weight: 600; }
.plan-goals__section { padding: 15px 16px; border-top: 1px solid var(--border-subtle); }
.plan-goals__section h3 { margin: 0 0 10px; font-size: 11px; }
.plan-goals__section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.plan-goals__section-head strong { font-size: 12px; font-variant-numeric: tabular-nums; }
.plan-goals table { min-width: 100%; font-size: 9px; }
.plan-goals th,.plan-goals td { padding: 7px 6px; }
.plan-goals th { color: var(--text-secondary); background: var(--surface-soft); font-size: 8px; }
.plan-goals .financial-edit-cell input { min-width: 78px; min-height: 31px; padding: 5px 7px; font-size: 9px; }
.plan-goals__orders th:first-child,.plan-goals__orders td:first-child { width: 36%; }
.plan-goals__expenses th:first-child,.plan-goals__expenses td:first-child { width: 48%; }
.plan-goals .financial-row-remove { width: 27px; height: 27px; padding: 0; border: 0; color: var(--text-faint); background: transparent; font-size: 16px; }
.plan-goals__actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; padding: 0 16px 15px; }
.plan-goals__actions details { min-width: 0; }
.plan-goals__actions details[open] { grid-column: 1 / -1; }
.plan-goals__actions summary {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 8px;
  border: 1px solid color-mix(in srgb,var(--action-primary) 42%,var(--border-subtle));
  border-radius: 8px;
  color: var(--action-primary);
  cursor: pointer;
  font-size: 9px;
  font-weight: 600;
  list-style: none;
}
.plan-goals__actions summary::-webkit-details-marker { display: none; }
.plan-goals__actions form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; padding: 10px; border: 1px solid var(--border-subtle); border-radius: 9px; background: var(--surface-soft); }
.plan-goals__actions label { display: grid; gap: 4px; color: var(--text-secondary); font-size: 8px; }
.plan-goals__actions input { width: 100%; min-width: 0; min-height: 32px; padding: 6px 8px; border: 1px solid var(--border-subtle); border-radius: 7px; background: var(--surface-raised); font: inherit; }
.plan-goals__actions form button { min-height: 32px; border: 0; border-radius: 7px; color: var(--text-on-action); background: var(--action-primary); font-size: 9px; font-weight: 600; }
.plan-goals__actions form a { align-self: center; color: var(--action-primary); font-size: 8px; }
.plan-goals__accept { display: grid; grid-template-columns: 1fr; align-items: stretch; padding: 14px 16px; }
.plan-goals__accept label { flex: none; }
.plan-goals__accept > div { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px; }
.plan-goals__accept button { width: 100%; }
.plan-goals__accept > button.is-primary { min-height: 39px; font-size: 10px; }
.plan-goals--readonly > p { margin: 0; padding: 0 18px 18px; color: var(--text-secondary); font-size: 10px; line-height: 1.5; }
.plan-dashboard__details { margin: 0 20px 20px; }
.plan-dashboard__details .sales-plan__pnl { margin: 0; }
.sales-plan__method {
  margin: 0 20px 20px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  background: var(--surface-raised);
}
.plan-fact-primary { border-color: var(--border-subtle); background: var(--surface-raised); }
.plan-fact-primary__scenario { border-left-width: 1px; }
.plan-fact-primary__scenario.is-on-track { background: var(--status-positive-soft); }
.plan-fact-primary__scenario.is-behind { background: var(--status-negative-soft); }
.ai-launch { background: var(--surface-raised); }
.tax-card__intro { background: var(--action-primary); }

.app-stage { background: var(--surface-canvas); }
.app-stage > main { width: min(100%,1480px); margin-inline: auto; padding: 22px 26px 64px; }

@media (max-width:1250px) {
  .plan-dashboard { grid-template-columns: 1fr; }
  .plan-dashboard__side { grid-template-columns: minmax(260px,.7fr) minmax(0,1.3fr); align-items: start; }
}

@media (prefers-reduced-motion:reduce) {
  *,*::before,*::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

@media (max-width:820px) {
  .panel__head { gap: 10px; }
  .filter-dock,.filters { box-shadow: none; }
  .app-stage > main { padding: 18px 14px 48px; }
  .sales-plan__body { padding: 0 14px 14px; }
  .plan-view-tabs,.fact-comparison-toolbar,.sales-plan__method,.plan-dashboard,.plan-dashboard__details { margin-right: 14px; margin-left: 14px; }
  .plan-dashboard__side,.plan-dashboard__primary { grid-template-columns: 1fr; }
  .plan-dashboard__secondary { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .plan-marketplace__head { align-items: flex-start; flex-direction: column; }
}

@media (max-width:480px) {
  .kpi { min-height: 105px; padding: 14px; }
  .kpi__value { font-size: 22px; }
  .panel__head h2 { font-size: 15px; }
  .plan-view-tabs { align-items: flex-end; flex-direction: row; }
  .plan-view-tabs > span { display: none; }
  .plan-dashboard__secondary { grid-template-columns: 1fr; }
  .plan-metric--primary { min-height: 190px; }
  .plan-goals__actions { grid-template-columns: 1fr; }
  .plan-goals__actions form { grid-template-columns: 1fr; }
}
