:root {
  --color-bg: #f4f5f7;
  --color-surface: #ffffff;
  --color-text: #1c2024;
  --color-muted: #6b7280;
  --color-border: #e2e4e9;
  --color-accent: #2563eb;
  --color-accent-contrast: #ffffff;
  --color-error: #dc2626;
  --color-error-bg: #fef2f2;
  --color-ok: #16a34a;
  --color-ok-bg: #f0fdf4;
  --color-warning: #f59e0b;
  --radius: 10px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

[x-cloak] {
  display: none !important;
}

/* ---------- Навигация ---------- */

.topnav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  height: 56px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.topnav__brand {
  font-weight: 600;
  white-space: nowrap;
}

.topnav__tabs {
  display: flex;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
}

.topnav__tab {
  padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--color-muted);
  white-space: nowrap;
  font-size: 14px;
}

.topnav__tab:hover {
  background: var(--color-bg);
}

.topnav__tab--active {
  color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 10%, transparent);
  font-weight: 600;
}

.topnav__right {
  display: flex;
  align-items: center;
  gap: 16px;
  white-space: nowrap;
}

.topnav__settings {
  font-size: 14px;
  color: var(--color-muted);
}

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

.usermenu {
  position: relative;
}

.usermenu__toggle {
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
  color: var(--color-text);
  padding: 6px 8px;
  border-radius: var(--radius);
}

.usermenu__toggle:hover {
  background: var(--color-bg);
}

.usermenu__dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  min-width: 160px;
  padding: 6px;
  display: flex;
  flex-direction: column;
}

.usermenu__dropdown a,
.usermenu__logout {
  padding: 8px 10px;
  border-radius: calc(var(--radius) - 4px);
  font-size: 14px;
  text-align: left;
}

.usermenu__dropdown a:hover,
.usermenu__logout:hover {
  background: var(--color-bg);
}

.usermenu__logout {
  width: 100%;
  background: none;
  border: none;
  font: inherit;
  color: var(--color-error);
  cursor: pointer;
}

.usermenu__dropdown form {
  margin: 0;
}

/* ---------- Контент ---------- */

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

h1 {
  font-size: 22px;
  margin: 0 0 16px;
}

h2 {
  font-size: 16px;
  margin: 0 0 12px;
}

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

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.stub {
  padding: 48px 0;
  text-align: center;
}

/* ---------- Формы ---------- */

.form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 360px;
}

.form--inline {
  max-width: none;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
}

.form__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.catalog-status,
.ozon-check-result {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--color-muted);
}

.form input,
.form select {
  font: inherit;
  padding: 9px 10px;
  border: 1px solid var(--color-border);
  border-radius: calc(var(--radius) - 4px);
  background: var(--color-surface);
  color: var(--color-text);
}

.form input:focus,
.form select:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

.btn {
  font: inherit;
  padding: 9px 16px;
  border-radius: calc(var(--radius) - 4px);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
}

.btn:hover {
  background: var(--color-bg);
}

.btn--primary {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-accent-contrast);
}

.btn--primary:hover {
  filter: brightness(1.05);
}

.btn--small {
  padding: 5px 10px;
  font-size: 13px;
}

.form-error {
  background: var(--color-error-bg);
  color: var(--color-error);
  padding: 10px 12px;
  border-radius: calc(var(--radius) - 4px);
  font-size: 14px;
}

.form-success {
  background: var(--color-ok-bg);
  color: var(--color-ok);
  padding: 10px 12px;
  border-radius: calc(var(--radius) - 4px);
  font-size: 14px;
}

/* ---------- Таблицы ---------- */

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.table__actions {
  display: flex;
  gap: 6px;
}

.inline-form {
  display: inline;
  margin: 0;
}

.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  margin: 0;
}

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

.kv dd {
  margin: 0;
}

/* ---------- Вход ---------- */

.auth-card {
  max-width: 360px;
  margin: 10vh auto 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 32px;
}

/* ---------- Тосты ---------- */

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text);
  color: var(--color-surface);
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  max-width: 90vw;
  display: none;
  z-index: 50;
}

/* ---------- Мобильная адаптация ---------- */

/* ---------- Плитки статистики (себестоимость) ---------- */

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat-tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: block;
}

.stat-tile__value {
  font-size: 22px;
  font-weight: 600;
}

.stat-tile__label {
  font-size: 13px;
  color: var(--color-muted);
  margin-top: 2px;
}

.stat-tile--link {
  cursor: pointer;
}

.stat-tile--link:hover {
  border-color: var(--color-accent);
}

.stat-tile--active {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 1px var(--color-accent) inset;
}

/* ---------- Панель фильтров ---------- */

.cost-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.cost-filters__search {
  flex: 1;
  min-width: 200px;
}

.cost-filters input,
.cost-filters select {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: calc(var(--radius) - 4px);
  background: var(--color-surface);
  color: var(--color-text);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--color-muted);
  white-space: nowrap;
}

.checkbox input {
  width: auto;
}

/* ---------- Таблица себестоимости ---------- */

.thumb {
  width: 56px;
  height: 56px;
  border-radius: calc(var(--radius) - 4px);
  object-fit: cover;
  display: block;
  background: var(--color-bg);
}

.thumb--placeholder {
  border: 1px dashed var(--color-border);
}

.cost-row--missing {
  box-shadow: inset 3px 0 0 var(--color-warning);
}

.chevron-btn {
  background: none;
  border: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: var(--color-text);
  padding: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chevron {
  display: inline-block;
  color: var(--color-muted);
  transition: transform 0.15s;
}

.cost-row.is-open .chevron {
  transform: rotate(90deg);
}

.history-row {
  display: none;
}

.history-row.is-open {
  display: table-row;
}

.history-row td {
  background: var(--color-bg);
}

.history-entry {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 6px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--color-border);
}

.history-entry:last-child {
  border-bottom: none;
}

.history-entry__date {
  color: var(--color-muted);
  min-width: 90px;
}

.history-entry__price {
  font-weight: 600;
  min-width: 110px;
}

.history-entry__note {
  color: var(--color-muted);
  font-style: italic;
}

.badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--color-ok-bg);
  color: var(--color-ok);
}

.cost-cell {
  position: relative;
}

.cost-value {
  cursor: pointer;
  border-bottom: 1px dashed var(--color-muted);
}

.cost-edit-form {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.cost-edit-form input[type="text"] {
  width: 100px;
  font: inherit;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: calc(var(--radius) - 4px);
}

.cost-edit-form input[type="date"] {
  font: inherit;
  padding: 5px 6px;
  border: 1px solid var(--color-border);
  border-radius: calc(var(--radius) - 4px);
}

/* ---------- Импорт CSV ---------- */

.import-summary {
  margin-top: 12px;
}

.import-errors {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: 13px;
}

code {
  background: var(--color-bg);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
}

.more-actions {
  margin-bottom: 16px;
}

/* ---------- Склад ---------- */

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

.stock-header h1 {
  margin: 0;
}

.stock-header__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stock-reconcile-status {
  font-size: 13px;
}

.stock-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 8px;
}

.stock-tab {
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--color-muted);
}

.stock-tab:hover {
  background: var(--color-bg);
}

.stock-tab--active {
  color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 10%, transparent);
  font-weight: 600;
}

.stock-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stock-grid--wide {
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

.stock-card {
  position: relative;
  display: flex;
  gap: 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
}

.stock-card__delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  background: var(--color-bg);
  color: var(--color-muted);
  font-size: 12px;
  cursor: pointer;
  z-index: 1;
}

.stock-card__delete:hover {
  background: var(--color-error-bg);
  color: var(--color-error);
}

.stock-card:hover {
  border-color: var(--color-accent);
}

.stock-card--wide {
  cursor: default;
}

.stock-card--muted {
  opacity: 0.7;
}

.stock-card__thumb {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.stock-card__body {
  min-width: 0;
  flex: 1;
}

.stock-card__title {
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stock-card__sub {
  font-size: 12px;
  margin-top: 2px;
}

.stock-card__metrics {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
  font-size: 13px;
}

.stock-card__buildable {
  font-size: 20px;
  font-weight: 600;
}

.stock-card__buildable--negative {
  color: var(--color-error);
}

.stock-card__actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.stock-collapsible {
  margin-bottom: 16px;
}

.stock-collapsible summary {
  cursor: pointer;
  color: var(--color-muted);
  font-size: 14px;
  padding: 6px 0;
}

.badge--warning {
  background: color-mix(in srgb, var(--color-warning) 15%, transparent);
  color: #92400e;
}

.badge--muted {
  background: var(--color-bg);
  color: var(--color-muted);
}

.badge--ok {
  background: var(--color-ok-bg);
  color: var(--color-ok);
}

/* ---------- Модалка склада ---------- */

.stock-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 5vh 16px;
  z-index: 40;
  overflow-y: auto;
}

.stock-modal {
  position: relative;
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 640px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.stock-modal--wide {
  max-width: 880px;
}

.stock-modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--color-muted);
  padding: 4px 8px;
}

.stock-modal__header {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 12px;
}

.stock-modal__header-main {
  flex: 1;
  min-width: 0;
}

.stock-modal__delete {
  flex-shrink: 0;
  align-self: flex-start;
  color: var(--color-error);
  border-color: var(--color-error-bg);
}

.stock-modal__delete:hover {
  background: var(--color-error-bg);
}

.stock-modal__header h2 {
  margin: 0 0 2px;
}

.stock-modal__thumb {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.stock-modal__stats {
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: 20px;
}

/* ---------- Состав позиции (§9 — подсветка узкого места) ---------- */

.stock-composition {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.stock-composition__row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: calc(var(--radius) - 4px);
  border-left: 3px solid transparent;
}

.stock-composition__row--bottleneck {
  border-left-color: var(--color-warning);
  background: color-mix(in srgb, var(--color-warning) 8%, transparent);
  font-weight: 600;
}

.stock-composition__stock--negative {
  color: var(--color-error);
  font-weight: 600;
}

.stock-composition__add {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
}

/* ---------- Формы движений и партии ---------- */

.stock-move-form {
  max-width: none;
  margin-bottom: 16px;
  align-items: flex-end;
}

.stock-move-form__cost {
  display: flex;
  gap: 8px;
}

.stock-move-form__note {
  flex: 1;
  min-width: 160px;
}

.stock-batch {
  border: 1px solid var(--color-border);
  border-radius: calc(var(--radius) - 2px);
  padding: 10px 12px;
  margin-bottom: 8px;
}

.stock-batch__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 14px;
}

.stock-batch__actions {
  display: flex;
  gap: 6px;
}

.stock-batch__note {
  margin: 4px 0 0;
  font-size: 13px;
}

.stock-batch__consumptions {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.stock-batch__consumption {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- Карточка расходника: действия/инлайн-редактирование/упаковка ---------- */

.stock-action-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.stock-action-row__hint {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
}

.stock-inline-edit {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.stock-inline-edit__row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.stock-inline-edit__row label {
  flex: 1;
}

.stock-pack-fields {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  align-items: end;
  gap: 10px 12px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--color-bg);
  border-radius: calc(var(--radius) - 4px);
}

.stock-pack-fields__hint {
  grid-column: 1 / -1;
  font-size: 12px;
  margin: 0;
}

.stock-badge--pending {
  background: color-mix(in srgb, #7c3aed 15%, transparent);
  color: #6d28d9;
}

/* ---------- Форма «Новый расходный материал» ---------- */

.stock-create-form {
  max-width: none;
  gap: 16px;
}

.stock-create-form__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px 16px;
  align-items: start;
}

.stock-create-form__wide {
  grid-column: 1 / -1;
}

.stock-create-form__flags {
  grid-row: span 2;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
}

.stock-create-form__flags .checkbox {
  align-items: flex-start;
  white-space: normal;
}

.stock-create-form__flags .checkbox input {
  margin-top: 3px;
  flex-shrink: 0;
}

.stock-create-form__photo {
  grid-column: span 3;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stock-create-form__photo-label {
  font-size: 13px;
  color: var(--color-muted);
}

.stock-create-form__photo-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stock-photo-picker {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: calc(var(--radius) - 2px);
  border: 1px dashed var(--color-border);
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
}

.stock-photo-picker--filled {
  border-style: solid;
}

.stock-photo-picker__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.stock-photo-picker__placeholder {
  font-size: 24px;
}

.stock-photo-picker__input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* ---------- Разбивка себестоимости ---------- */

.stock-breakdown-box {
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 14px;
}

.stock-breakdown-box__title {
  font-size: 13px;
  color: var(--color-muted);
  margin-bottom: 10px;
}

.stock-breakdown {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stock-breakdown__row {
  display: grid;
  grid-template-columns: 120px 1fr auto auto;
  align-items: center;
  gap: 10px;
}

.stock-breakdown__label {
  font-size: 13px;
  color: var(--color-muted);
}

.stock-breakdown__amount {
  font: inherit;
  padding: 7px 9px;
  border: 1px solid var(--color-border);
  border-radius: calc(var(--radius) - 4px);
  background: var(--color-surface);
  color: var(--color-text);
}

.radio {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--color-muted);
  white-space: nowrap;
}

.radio input {
  width: auto;
}

@media (max-width: 640px) {
  .stock-create-form__grid {
    grid-template-columns: 1fr;
  }

  .stock-create-form__flags,
  .stock-create-form__photo {
    grid-column: auto;
    grid-row: auto;
  }

  .stock-pack-fields {
    grid-template-columns: 1fr;
  }

  .stock-inline-edit__row {
    flex-direction: column;
    align-items: stretch;
  }

  .stock-breakdown__row {
    grid-template-columns: 1fr;
  }

  .topnav {
    gap: 12px;
    padding: 0 12px;
  }

  .topnav__brand {
    display: none;
  }

  .page {
    padding: 16px 12px 48px;
  }

  .form--inline {
    flex-direction: column;
    align-items: stretch;
  }

  .table__actions {
    flex-direction: column;
  }

  .stat-tiles {
    grid-template-columns: repeat(2, 1fr);
  }

  .cost-table thead,
  .map-table thead {
    display: none;
  }

  .cost-table,
  .cost-table tbody,
  .cost-table tr,
  .cost-table td,
  .map-table,
  .map-table tbody,
  .map-table tr,
  .map-table td {
    display: block;
    width: 100%;
  }

  .cost-table tr.cost-row,
  .map-table tbody tr {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    padding: 10px;
    background: var(--color-surface);
  }

  .cost-table tr.history-row {
    margin-top: -10px;
    margin-bottom: 10px;
  }

  .cost-table tr.history-row.is-open {
    display: block;
  }

  .cost-table td,
  .map-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    border: none;
    white-space: normal;
  }

  .cost-table td[data-label]::before,
  .map-table td[data-label]::before {
    content: attr(data-label);
    color: var(--color-muted);
    font-size: 12px;
    flex-shrink: 0;
  }
}

/* ---------- Финансы ---------- */

.finance-disclaimer {
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 16px;
}

.finance-amount--income {
  color: var(--color-ok);
}

.finance-amount--expense {
  color: var(--color-error);
}

.finance-pagination {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.finance-placeholder {
  padding: 40px 20px;
  text-align: center;
  color: var(--color-muted);
}

/* ---------- Дашборд «Аналитика» (Выкупы/Капитал/Карта) ---------- */

.dash-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.dash-toolbar h1 {
  margin: 0;
}

.btn-toggle-group {
  display: flex;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.btn-toggle {
  padding: 6px 14px;
  font-size: 13px;
  color: var(--color-muted);
  background: var(--color-surface);
}

.btn-toggle:hover {
  background: var(--color-bg);
}

.btn-toggle--active {
  background: var(--color-accent);
  color: var(--color-accent-contrast);
  font-weight: 600;
}

.dash-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 8px;
}

.dash-tab {
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--color-muted);
}

.dash-tab:hover {
  background: var(--color-bg);
}

.dash-tab--active {
  color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 10%, transparent);
  font-weight: 600;
}

.dash-header {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 4px;
}

.dash-header__item {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.dash-header__value {
  font-size: 22px;
  font-weight: 700;
}

.dash-header__label {
  font-size: 13px;
  color: var(--color-muted);
  margin-top: 2px;
}

.dash-header__note {
  font-size: 12px;
  margin: 4px 0 16px;
}

.metric-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.metric-switcher__btn {
  padding: 6px 12px;
  font-size: 13px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-muted);
}

.metric-switcher__btn:hover {
  border-color: var(--color-accent);
}

.metric-switcher__btn--active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-accent-contrast);
  font-weight: 600;
}

.buyouts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.buyouts-tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.buyouts-tile--all {
  background: color-mix(in srgb, var(--color-accent) 6%, var(--color-surface));
  border-color: var(--color-accent);
}

.buyouts-tile__thumb {
  width: 40px;
  height: 40px;
  border-radius: calc(var(--radius) - 4px);
  object-fit: cover;
  background: var(--color-bg);
}

.buyouts-tile__thumb--placeholder {
  display: block;
}

.buyouts-tile__name {
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.buyouts-tile__offer {
  font-size: 12px;
  color: var(--color-muted);
}

.buyouts-tile__value {
  font-size: 20px;
  font-weight: 700;
  margin-top: 4px;
}

.buyouts-tile__trend {
  font-size: 12px;
  font-weight: 400;
  color: var(--color-muted);
  margin-top: 2px;
}

.buyouts-tile__link {
  font-size: 12px;
  color: var(--color-accent);
  margin-top: auto;
  padding-top: 6px;
}

.buyouts-tile--clickable {
  cursor: pointer;
}

.buyouts-tile--clickable:hover {
  border-color: var(--color-accent);
}

.profit-dashboard-summary {
  margin-bottom: 24px;
  padding: 22px;
  background: #fffaf3;
  border: 1px solid var(--color-border);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(104, 75, 48, .08);
}

.profit-dashboard-summary__intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.profit-dashboard-summary__intro h2,
.dash-section-heading h2 { margin: 0 0 5px; font-size: 19px; }
.profit-dashboard-summary__intro p,
.dash-section-heading p { margin: 0; font-size: 13px; }

.profit-dashboard-summary__period {
  display: grid;
  grid-template-columns: auto auto;
  gap: 3px 12px;
  min-width: 165px;
  font-size: 12px;
  color: var(--color-muted);
}
.profit-dashboard-summary__period strong { color: var(--color-text); font-size: 14px; text-align: right; }

.profit-dashboard-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.profit-dashboard-card {
  min-height: 108px;
  padding: 16px;
  background: #fffdf9;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.profit-dashboard-card span { color: var(--color-muted); font-size: 13px; }
.profit-dashboard-card em { float: right; color: var(--color-text); font-style: normal; font-size: 16px; font-weight: 700; }
.profit-dashboard-card strong { font-size: 24px; color: var(--color-text); }
.profit-dashboard-card small { color: var(--color-muted); font-size: 11px; line-height: 1.35; }
.profit-dashboard-card small.is-good { color: #4bbd16; }
.profit-dashboard-card small.is-bad { color: #ff4d4d; }
.dashboard-deductions__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 28px; }
.dashboard-deduction-row { display: grid; grid-template-columns: minmax(180px,1fr) auto auto; align-items: center; gap: 12px; padding: 12px 14px; background: #f8f8fb; border-radius: 10px; }
.dashboard-deduction-row span { color: var(--color-muted); }
.dashboard-deduction-row strong { color: var(--color-text); }
.dashboard-deduction-row em { color: var(--color-muted); font-style: normal; font-size: 12px; }
.dashboard-deduction-row small { color: var(--color-muted); grid-column: 2 / -1; }
@media (max-width: 760px) { .dashboard-deductions__grid { grid-template-columns: 1fr; } }
.profit-dashboard-card--accent { background: #edf6e9; border-color: #c9dfbd; }
.profit-dashboard-card--accent strong { color: #477a43; }
.profit-dashboard-card--margin { background: #e9f7fb; border-color: #b8e3ed; }
.profit-dashboard-card--margin strong { color: #247b8a; }

.dash-section-heading { margin: 22px 0 12px; }

.dash-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding: 20px 22px; margin-bottom: 18px; background: #fffaf3; border: 1px solid var(--color-border); border-radius: 16px; box-shadow: 0 8px 24px rgba(104, 75, 48, .08); }
.dash-toolbar h1 { margin: 0 0 4px; }
.dash-toolbar__subtitle { margin: 0; color: var(--color-muted); font-size: 13px; }
.dashboard-period-form { display: flex; align-items: end; gap: 12px; }
.dashboard-period-form label { display: flex; flex-direction: column; gap: 5px; color: var(--color-muted); font-size: 12px; }
.dashboard-period-form input, .dashboard-period-form select { min-width: 145px; padding: 10px 12px; border: 1px solid var(--color-border); border-radius: 9px; background: #fffdf9; color: var(--color-text); font: inherit; }
.dashboard-period-form__submit { height: 41px; }
.dashboard-period-form__compare { padding-bottom: 10px; color: var(--color-muted); font-size: 12px; white-space: nowrap; }

.dashboard-chart { padding: 20px 22px; margin-bottom: 20px; }
.dashboard-chart__heading { margin-bottom: 8px; }
.dashboard-chart__heading h2 { margin: 0 0 4px; }
.dashboard-chart__heading p { margin: 0; font-size: 13px; }

.dashboard-breakdown { padding: 20px 22px; margin-bottom: 20px; }
.dashboard-breakdown__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 28px; }
.dashboard-breakdown__row { display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; padding: 12px 0; border-bottom: 1px solid #eee4d8; }
.dashboard-breakdown__row span { color: var(--color-muted); font-size: 13px; }
.dashboard-breakdown__row strong { font-size: 16px; text-align: right; }
.dashboard-breakdown__row small { grid-column: 1 / -1; font-size: 11px; color: var(--color-muted); }
.dashboard-breakdown__row small.is-good { color: var(--color-ok); }
.dashboard-breakdown__row small.is-bad { color: var(--color-error); }
.dashboard-breakdown__row--profit { background: #edf6e9; border: 1px solid #c9dfbd; border-radius: 10px; padding: 12px; }
.dashboard-breakdown__row--profit strong { color: #477a43; }
@media (max-width: 700px) { .dashboard-breakdown__grid { grid-template-columns: 1fr; } }

.dashboard-attention { padding: 20px 22px; margin-bottom: 20px; }
.dashboard-attention__list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 22px; }
.dashboard-attention__item { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 10px; background: #fff8f3; border: 1px solid #ead7ca; }
.dashboard-attention__item--stock { background: #fff8e9; border-color: #edd9ab; }
.dashboard-attention__item--return, .dashboard-attention__item--refusal { background: #fff3f0; border-color: #edcec8; }
.dashboard-attention__dot { width: 9px; height: 9px; border-radius: 50%; background: #c45143; }
.dashboard-attention__item--stock .dashboard-attention__dot { background: #c78a3d; }
.dashboard-attention__item strong, .dashboard-attention__item small { display: block; }
.dashboard-attention__item strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dashboard-attention__item small { color: var(--color-muted); font-size: 11px; margin-top: 2px; }
.dashboard-attention__item b { font-size: 13px; color: var(--color-text); }
.dashboard-attention__empty { margin: 0; padding: 12px; color: var(--color-ok); background: var(--color-ok-bg); border-radius: 8px; }
@media (max-width: 700px) { .dashboard-attention__list { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .dash-toolbar, .dashboard-period-form { align-items: stretch; flex-direction: column; } .dashboard-period-form select { width: 100%; } .dashboard-period-form__compare { padding: 0; } }

/* Рабочая область как в MProfit: постоянная боковая навигация и свободный
   тёплый холст для показателей. */
@media (min-width: 901px) {
  .topnav {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 224px;
    height: 100vh;
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
    padding: 22px 14px;
    border-right: 1px solid var(--color-border);
    border-bottom: 0;
  }
  .topnav__brand { padding: 0 10px 14px; font-size: 18px; }
  .topnav__tabs { flex-direction: column; gap: 4px; overflow: visible; }
  .topnav__tab { padding: 11px 13px; }
  .topnav__right { margin-top: auto; padding: 12px 6px 0; border-top: 1px solid var(--color-border); flex-direction: column; align-items: stretch; gap: 8px; }
  .topnav__settings { padding: 8px; }
  .usermenu__toggle { width: 100%; text-align: left; }
  .page { margin-left: 224px; max-width: none; padding: 30px 36px 70px; }
}

@media (max-width: 900px) {
  .topnav__tabs { overflow-x: auto; }
}

@media (max-width: 800px) {
  .profit-dashboard-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .profit-dashboard-summary__intro { flex-direction: column; }
  .profit-dashboard-cards { grid-template-columns: 1fr; }
}

.tile-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.tile-modal-header__thumb {
  width: 56px;
  height: 56px;
  border-radius: calc(var(--radius) - 4px);
  object-fit: cover;
  background: var(--color-bg);
  flex-shrink: 0;
}

.tile-modal-header__name {
  margin: 0 0 2px;
  font-size: 18px;
}

.tile-modal-metrics {
  margin: 0 0 16px;
}

.tile-modal-metrics__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
}

.tile-modal-metrics__row dt {
  color: var(--color-muted);
  font-size: 14px;
}

.tile-modal-metrics__row dd {
  margin: 0;
  font-weight: 600;
  font-size: 15px;
  text-align: right;
}

.tile-modal-metrics__trend {
  font-weight: 400;
  font-size: 12px;
  color: var(--color-muted);
}

.tile-modal-metrics__value-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tile-modal-metrics__spark {
  color: var(--color-accent);
  line-height: 0;
}

.tile-modal-sparkline {
  width: 70px;
  height: 20px;
  display: block;
}

.dash-mode-toggle {
  margin-bottom: 8px;
}

.capital-tile {
  border-left: 4px solid var(--color-border);
}

.capital-tile--ok {
  border-left-color: var(--color-ok);
}

.capital-tile--trap {
  border-left-color: var(--color-error);
  background: color-mix(in srgb, var(--color-error) 4%, var(--color-surface));
}

.capital-tile--no_stock {
  border-left-color: var(--color-accent);
}

.capital-tile--no_data {
  border-left-color: var(--color-border);
  opacity: 0.7;
}

.capital-tile__state {
  font-size: 14px;
  color: var(--color-muted);
  margin-top: 4px;
}

.capital-tile__secondary {
  font-size: 13px;
  color: var(--color-muted);
}

.capital-tile__detail {
  font-size: 12px;
  color: var(--color-muted);
  margin-top: 4px;
}

.map-disclaimer {
  margin-bottom: 16px;
}

.map-disclaimer p {
  margin: 0;
}

.map-table__highlight {
  font-weight: 700;
  color: var(--color-text);
}

.map-svg-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.map-svg {
  width: 100%;
  height: auto;
  display: block;
}

.map-svg__silhouette {
  fill: var(--color-bg);
  stroke: var(--color-border);
  stroke-width: 2;
}

.map-svg__point circle {
  stroke: var(--color-surface);
  stroke-width: 1;
}

.map-svg__label {
  font-size: 11px;
  fill: var(--color-muted);
}

.map-svg__legend {
  margin: 0;
  font-size: 13px;
}

/* Тёплая тема кабинета Bellka: молочный фон, песочные границы и терракотовый
   акцент. Смысловые цвета прибыли/ошибок остаются зелёным и красным. */
:root {
  --color-bg: #f6f0e7;
  --color-surface: #fffdf9;
  --color-text: #3f382f;
  --color-muted: #81766b;
  --color-border: #e7ddd0;
  --color-accent: #b56b45;
  --color-accent-contrast: #fffaf5;
  --color-error: #c45143;
  --color-error-bg: #fff1ed;
  --color-ok: #5d8b55;
  --color-ok-bg: #edf6e9;
  --color-warning: #c78a3d;
  --radius: 12px;
}

.topnav {
  background: #fffaf3;
  box-shadow: 0 2px 10px rgba(104, 75, 48, .05);
}

.page {
  max-width: 1240px;
}

.card,
.buyouts-tile,
.capital-tile,
.dash-header__item {
  box-shadow: 0 5px 18px rgba(104, 75, 48, .08);
}

.dash-toolbar,
.dash-tabs,
.metric-switcher {
  background: #fffaf3;
  border-color: var(--color-border);
}

.dash-tab--active,
.metric-switcher__btn--active {
  background: #f2dfd1;
  color: #8d4e32;
}

.buyouts-tile--all,
.capital-tile--ok {
  border-color: #c8ddbc;
  background: #f1f8eb;
}

.btn--primary {
  background: var(--color-accent);
  border-color: var(--color-accent);
}

@media (max-width: 700px) {
  .page { padding: 16px 12px 48px; }
  .topnav { gap: 8px; padding: 0 12px; }
  .topnav__tabs { gap: 0; }
}

@media (max-width: 640px) {
  .dash-header {
    grid-template-columns: 1fr;
  }

  .buyouts-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .dash-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}
