/* ══════════════════════════════════════════════════
   Proposal v2 (КП) — Modern Dashboard Stylesheet
   Based on Stitch design, accent: #d3182e
   ══════════════════════════════════════════════════ */

@import url('/fonts/inter/index.css');

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

:root {
  /* ── Colors ─────────────────────────────── */
  --primary: #d3182e;
  --primary-light: rgba(211, 24, 46, 0.08);
  --primary-ring: rgba(211, 24, 46, 0.20);
  --primary-shadow: rgba(211, 24, 46, 0.30);
  --primary-dark: #a81224;
  --warning: #d2054f;

  --bg: #f6f6f8;
  --surface: #ffffff;
  --surface-hover: #fafafa;
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  --success-bg: #dcfce7;
  --success-text: #166534;
  --warning-bg: #fef3c7;
  --warning-text: #92400e;
  --danger-bg: #fee2e2;
  --danger-text: #991b1b;
  --draft-bg: #f1f5f9;
  --draft-text: #475569;

  /* ── Shadows ────────────────────────────── */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-footer: 0 -10px 30px rgba(0, 0, 0, 0.05);

  /* ── Misc ───────────────────────────────── */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --transition: 0.18s ease;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Base ─────────────────────────────────── */
body {
  font-family: var(--font);
  font-size: 14px;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Material Icons ──────────────────────── */
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
  line-height: 1;
}

/* ── Scrollbar ───────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }

/* ══════════════════════════════════════════════════
   HEADER
   ══════════════════════════════════════════════════ */
.v2-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.80);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
}

.v2-header__inner {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.v2-header__left {
  display: flex;
  align-items: center;
  gap: 24px;
}

.v2-header__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--primary);
  text-decoration: none;
}

.v2-header__logo .material-symbols-outlined {
  font-size: 28px;
  font-weight: 700;
}

.v2-header__logo-text {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.v2-header__search {
  position: relative;
}

.v2-header__search .material-symbols-outlined {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 20px;
}

.v2-header__search input {
  padding: 8px 16px 8px 40px;
  width: 320px;
  background: var(--border-light);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.88rem;
  color: var(--ink);
  outline: none;
  transition: box-shadow var(--transition);
}

.v2-header__search input:focus {
  box-shadow: 0 0 0 2px var(--primary-ring);
}

.v2-header__search input::placeholder {
  color: var(--muted);
}

.v2-header__right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.v2-header__notify {
  position: relative;
  padding: 8px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background var(--transition);
}

.v2-header__notify:hover {
  background: var(--border-light);
}

.v2-header__notify-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 7px;
  height: 7px;
  background: var(--primary);
  border-radius: 50%;
  border: 2px solid white;
}

.v2-header__divider {
  width: 1px;
  height: 28px;
  background: var(--border);
}

.v2-header__user {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.v2-header__user-info {
  text-align: right;
}

.v2-header__user-name {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1;
  color: var(--ink);
}

.v2-header__user-role {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1;
}

.v2-header__avatar {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  transition: background var(--transition), color var(--transition);
  overflow: hidden;
}

.v2-header__user:hover .v2-header__avatar {
  background: var(--primary);
  color: #fff;
}

/* Notification badge on avatar */
.v2-avatar-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  background: #d2054f;
  border-radius: 50%;
  border: 2px solid var(--surface);
  pointer-events: none;
  animation: v2-badge-pulse 2s ease-in-out infinite;
}
.v2-avatar-badge.is-hidden {
  display: none !important;
}
@keyframes v2-badge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(210, 5, 79, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(210, 5, 79, 0); }
}

.v2-header__logout-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  font-family: var(--font);
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.v2-header__logout-btn:hover {
  background: var(--danger-bg);
  border-color: #fca5a5;
  color: var(--danger-text);
}

/* ══════════════════════════════════════════════════
   MAIN LAYOUT
   ══════════════════════════════════════════════════ */
.v2-main {
  display: flex;
  align-items: start;
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px;
  gap: 24px;
  min-height: calc(100vh - 60px - 68px);
}

.v2-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
  padding-bottom: 80px;
  min-width: 0;
}

/* ── Card (shared section) ────────────────── */
.v2-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}

.v2-card__title {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.v2-card__title .material-symbols-outlined {
  color: var(--primary);
  font-size: 22px;
}

.v2-card__badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 4px;
  background: var(--primary-light);
  color: var(--primary);
  margin-left: auto;
}

/* ── Form fields ──────────────────────────── */
.v2-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.v2-form-grid--full {
  grid-column: 1 / -1;
}

.v2-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.v2-field__label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink-soft);
}

.v2-field__input,
.v2-field__textarea,
.v2-field__select {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--surface);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

.v2-field__input:focus,
.v2-field__textarea:focus,
.v2-field__select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.v2-field__input::placeholder,
.v2-field__textarea::placeholder {
  color: var(--muted);
}

.v2-field__textarea {
  resize: vertical;
  min-height: 64px;
}

/* ══════════════════════════════════════════════════
   CATALOG SECTION
   ══════════════════════════════════════════════════ */
.v2-catalog-search {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.v2-catalog-search__input-wrap {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.v2-catalog-search__input-wrap .material-symbols-outlined {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 20px;
}

.v2-catalog-search__input-wrap input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  background: var(--border-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.88rem;
  color: var(--ink);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.v2-catalog-search__input-wrap input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.v2-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--border-light);
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform 0.12s ease;
  white-space: nowrap;
}

.v2-btn:hover {
  background: var(--border);
}

.v2-btn:active {
  transform: scale(0.97);
}

.v2-btn .material-symbols-outlined {
  font-size: 18px;
}

/* ── Category chips ──────────────────────── */
.v2-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.v2-chips__label {
  font-size: 0.70rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.v2-chip {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  border: none;
  font-family: var(--font);
  background: var(--border-light);
  color: var(--ink-soft);
}

.v2-chip:hover {
  background: var(--border);
}

.v2-chip.active {
  background: var(--primary);
  color: #fff;
}

/* ── Catalog filters ──────────────────────── */
.v2-catalog-filters {
  margin-top: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--border-light);
  display: none;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  align-items: end;
}

.v2-catalog-filters.is-open {
  display: grid;
}

.v2-catalog-filters .v2-field__label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Product grid ────────────────────────── */
.v2-products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.v2-product-card {
  padding: 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.v2-product-card:hover {
  border-color: var(--primary-ring);
  box-shadow: var(--shadow-md);
}

.v2-product-card__img {
  width: 100%;
  aspect-ratio: 4/3;
  background: var(--border-light);
  border-radius: var(--radius-xs);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.v2-product-card__img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.v2-product-card__img .material-symbols-outlined {
  font-size: 36px;
  color: #d1d5db;
}

.v2-product-card__img-overlay {
  position: absolute;
  inset: 0;
  background: transparent;
  transition: background var(--transition);
}

.v2-product-card:hover .v2-product-card__img-overlay {
  background: rgba(211, 24, 46, 0.04);
}

.v2-product-card__name {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v2-product-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 3px;
}

.v2-product-card__sku {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.v2-product-card__stock {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

.v2-product-card__stock .material-symbols-outlined {
  font-size: 13px;
}

.v2-product-card__stock--in-stock {
  background: rgba(34, 197, 94, 0.12);
  color: #16a34a;
}

.v2-product-card__stock--on-order {
  background: rgba(234, 179, 8, 0.14);
  color: #a16207;
}

.v2-product-card__stock--out-of-stock {
  background: rgba(239, 68, 68, 0.10);
  color: #dc2626;
}

.v2-product-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}

.v2-product-card__price {
  font-weight: 700;
  color: var(--primary);
}

.v2-product-card__add {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--border-light);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.v2-product-card__add:hover {
  background: var(--primary);
  color: #fff;
}

.v2-product-card__add .material-symbols-outlined {
  font-size: 18px;
}

/* search states */
.v2-catalog-loading,
.v2-catalog-empty {
  grid-column: 1 / -1;
  padding: 32px;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
}

/* ══════════════════════════════════════════════════
   ITEMS TABLE (Состав КП)
   ══════════════════════════════════════════════════ */
.v2-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 16px;
  text-align: center;
}

.v2-empty-state__icon {
  width: 80px;
  height: 80px;
  background: var(--border-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.v2-empty-state__icon .material-symbols-outlined {
  font-size: 36px;
  color: #d1d5db;
}

.v2-empty-state__title {
  font-weight: 600;
  color: var(--ink-soft);
}

.v2-empty-state__text {
  font-size: 0.88rem;
  color: var(--muted);
  margin-top: 4px;
  max-width: 280px;
}

.v2-items-table {
  width: 100%;
  border-collapse: collapse;
}

.v2-items-table thead {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-light);
}

.v2-items-table th {
  padding: 0 0 14px;
  text-align: left;
  font-weight: 700;
}

.v2-items-table th:last-child {
  text-align: right;
}

/* dividers between rows */

.v2-items-table tbody tr {
  border-bottom: 1px solid var(--border-light);
}

.v2-items-table td {
  padding: 14px 0;
  vertical-align: middle;
}

.v2-items-table td:last-child {
  text-align: right;
}

.v2-item-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.v2-item-info__thumb {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-xs);
  background: var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.v2-item-info__thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.v2-item-info__thumb .material-symbols-outlined {
  font-size: 18px;
  color: var(--muted);
}

.v2-item-info__name {
  font-size: 0.88rem;
  font-weight: 600;
}

.v2-item-info__meta {
  font-size: 0.70rem;
  color: var(--muted);
  margin-top: 2px;
}

.v2-item-price {
  font-size: 0.88rem;
  font-weight: 500;
}

.v2-item-total {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--primary);
}

.v2-final-price-input {
  width: 80px;
  text-align: right;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.v2-final-price-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
  outline: none;
}

/* Ручной ввод базовой цены, когда в каталоге price = 0 */
.v2-base-price-input {
  width: 72px;
  text-align: right;
  padding: 6px;
  border: 1px solid var(--warning, #d2054f);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 600;
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.v2-base-price-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
  outline: none;
}

/* Пульс-подсветка позиций без цены при попытке экспорта */
@keyframes v2-price-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(210, 5, 79, 0); }
  30%      { box-shadow: 0 0 0 4px rgba(210, 5, 79, 0.45); }
}
.v2-price-flash {
  animation: v2-price-pulse 0.8s ease-in-out 2;
  border-radius: var(--radius-sm);
}

/* Quantity stepper */
.v2-qty {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.v2-qty__btn {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font);
  font-weight: 600;
  transition: color var(--transition), border-color var(--transition);
  padding: 0;
}

.v2-qty__btn:hover {
  color: var(--primary);
  border-color: var(--primary-ring);
}

.v2-qty__value {
  font-size: 0.88rem;
  font-weight: 700;
  min-width: 16px;
  text-align: center;
}

.v2-qty__input {
  width: 48px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 700;
  padding: 5px 4px;
  text-align: center;
}

.v2-qty__input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
  outline: none;
}

.v2-item-total__line {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  margin-top: 4px;
  white-space: nowrap;
}

.v2-item-delete {
  background: none;
  border: none;
  color: #d1d5db;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color var(--transition);
}

.v2-item-delete:hover {
  color: var(--primary);
}

/* Discount input in table */
.v2-disc-wrap {
  display: flex;
  gap: 4px;
  align-items: center;
}

.v2-disc-select {
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.76rem;
  font-family: var(--font);
  background: #fff;
  width: 46px;
}

.v2-disc-input {
  width: 56px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.82rem;
  font-family: var(--font);
  text-align: right;
}

.v2-disc-select:focus,
.v2-disc-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Summary bar */
.v2-summary-bar {
  margin-top: 20px;
  padding: 16px 20px;
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  border: 1px solid var(--primary-ring);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.v2-summary-bar__info {
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.v2-summary-bar__info strong {
  color: var(--ink);
}

.v2-summary-bar__total-label {
  font-size: 0.88rem;
  color: var(--ink-soft);
  margin-right: 8px;
}

.v2-summary-bar__total-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
}

.v2-summary-bar__savings {
  font-size: 0.82rem;
  color: var(--success-text);
  margin-left: 12px;
}

/* ══════════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════════ */
.v2-sidebar {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.v2-sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.v2-sidebar__title {
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.v2-sidebar__title .material-symbols-outlined {
  color: var(--primary);
}

.v2-sidebar__see-all {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  padding: 0;
}

.v2-sidebar__see-all:hover {
  text-decoration: underline;
}

.v2-sidebar__list {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── History card ─────────────────────────── */
.v2-history-card {
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: box-shadow var(--transition), border-color var(--transition);
  cursor: pointer;
}

.v2-history-card:hover {
  box-shadow: 0 0 0 2px var(--primary-ring);
}

.v2-history-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-ring);
}

.v2-history-card__top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
}

.v2-history-card__status {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.v2-history-card__status--sent {
  background: var(--success-bg);
  color: var(--success-text);
}

.v2-history-card__status--draft {
  background: var(--draft-bg);
  color: var(--draft-text);
}

.v2-history-card__status--rejected {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.v2-history-card__date {
  font-size: 0.65rem;
  color: var(--muted);
  font-weight: 500;
}

.v2-history-card__client {
  font-weight: 700;
  font-size: 0.88rem;
  line-height: 1.3;
  color: var(--ink);
}

.v2-history-card__seller {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 3px;
}

.v2-history-card__stats {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  font-size: 0.70rem;
  color: var(--muted);
  font-weight: 600;
}

.v2-history-card__stats span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.v2-history-card__stats .material-symbols-outlined {
  font-size: 14px;
}

.v2-history-card__actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
}

.v2-history-card__action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color var(--transition), background var(--transition);
  font-family: var(--font);
}

.v2-history-card__action-btn:hover {
  color: var(--primary);
  background: var(--primary-light);
}

.v2-history-card__action-btn--pdf:hover { color: #dc2626; background: #fee2e2; }
.v2-history-card__action-btn--xlsx:hover { color: #16a34a; background: #dcfce7; }
.v2-history-card__action-btn--delete:hover { color: #dc2626; background: #fee2e2; }

.v2-history-card__action-btn .material-symbols-outlined {
  font-size: 20px;
}

.v2-history-card__action-btn span:last-child {
  font-size: 0.60rem;
  font-weight: 700;
  text-transform: uppercase;
}

.v2-history-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 2px 8px;
}

.v2-history-pagination__btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.v2-history-pagination__btn:hover:not(:disabled) {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
  color: var(--primary);
}

.v2-history-pagination__btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.v2-history-pagination__btn .material-symbols-outlined {
  font-size: 20px;
}

.v2-history-pagination__meta {
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: center;
}

.v2-history-pagination__meta small {
  color: var(--muted);
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  margin-top: 2px;
}

/* ══════════════════════════════════════════════════
   STICKY FOOTER
   ══════════════════════════════════════════════════ */
.v2-footer {
  position: sticky;
  bottom: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  padding: 14px 24px;
  box-shadow: var(--shadow-footer);
}

.v2-footer__inner {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.v2-footer__left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.v2-footer__right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ── Button styles ────────────────────────── */
.v2-btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  background: var(--primary);
  color: #fff;
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: 0 4px 14px var(--primary-shadow);
  transition: box-shadow var(--transition), transform 0.12s ease;
}

.v2-btn-primary:hover {
  box-shadow: 0 6px 20px var(--primary-shadow);
  transform: translateY(-1px);
}

.v2-btn-primary:active {
  transform: scale(0.97);
}

.v2-btn-primary .material-symbols-outlined {
  font-size: 20px;
}

.v2-btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--border-light);
  color: var(--ink-soft);
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.v2-btn-secondary:hover {
  background: var(--border);
}

.v2-btn-secondary:active {
  transform: scale(0.97);
}

.v2-btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}

.v2-btn-outline:hover {
  border-color: var(--primary-ring);
  color: var(--primary);
}

.v2-btn-outline:active {
  transform: scale(0.97);
}

.v2-btn-icon {
  padding: 10px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition);
}

.v2-btn-icon:hover {
  color: var(--primary);
}

/* ── Status message ──────────────────────── */
.v2-status {
  font-size: 0.82rem;
  color: var(--muted);
  margin-left: auto;
}

.v2-status.ok { color: var(--success-text); }
.v2-status.err { color: var(--primary); }

/* ── Profile Panel ───────────────────────── */
.v2-profile-panel {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  max-height: 400px;
  transition: max-height 0.3s ease, padding 0.3s ease;
  padding: 20px 24px;
}

.v2-profile-panel.is-hidden {
  max-height: 0;
  padding: 0 24px;
}

.v2-profile-panel .panel-inner {
  max-width: 600px;
  margin: 0 auto;
}

/* ── USER MENU DROPDOWN ── */
.v2-user-menu-wrap {
  position: relative;
}
.v2-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 8px 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
}
.v2-dropdown.is-hidden {
  display: none !important;
}
.v2-dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: var(--font);
  font-size: 0.88rem;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition);
}
.v2-dropdown-item:hover {
  background: var(--surface-hover);
}
.v2-dropdown-item .material-symbols-outlined {
  font-size: 20px;
  color: var(--ink-soft);
}
.v2-dropdown-item--danger {
  color: var(--danger-text);
}
.v2-dropdown-item--danger .material-symbols-outlined {
  color: inherit;
}
.v2-dropdown-item--danger:hover {
  background: var(--danger-bg);
}
.v2-dropdown-divider {
  height: 1px;
  background: var(--border-light);
  margin: 6px 0;
}

/* ── PROFILE MODAL ── */
.v2-modal {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.v2-modal.is-hidden {
  display: none !important;
}
.v2-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.v2-modal__content {
  position: relative;
  width: 100%;
  max-width: 600px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
  overflow: hidden;
}
.v2-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
}
.v2-modal__header h2 {
  font-size: 1.15rem;
  margin: 0;
}
.v2-modal__close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  margin: -4px;
  border-radius: 4px;
  display: flex;
  transition: background var(--transition), color var(--transition);
}
.v2-modal__close:hover {
  background: var(--border-light);
  color: var(--ink);
}
.v2-modal__body {
  padding: 24px;
  overflow-y: auto;
}
.v2-profile-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}
.v2-profile-form .v2-field {
  min-width: 0;
}
.v2-profile-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  grid-column: span 2;
  margin-top: 8px;
}

.v2-photo-row {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
}
.v2-photo-preview {
  margin-top: 8px;
  min-height: 48px;
}
.v2-photo-preview img {
  max-width: 120px;
  max-height: 120px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
}
.v2-profile-btn-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.v2-profile-tooltip {
  position: absolute;
  top: calc(100% + 14px);
  right: 0;
  width: 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.12);
  z-index: 1000;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.v2-profile-tooltip.is-hidden {
  display: none !important;
}
.v2-profile-tooltip__text {
  font-size: 0.85rem;
  color: var(--ink);
  line-height: 1.4;
  margin: 0;
  flex: 1;
}
.v2-profile-tooltip__close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  margin: -4px -4px 0 0;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
}
.v2-profile-tooltip__close:hover {
  background: var(--border-light);
  color: var(--ink);
}
.v2-profile-tooltip::before {
  content: "";
  position: absolute;
  top: -6px;
  right: 22px;
  width: 10px;
  height: 10px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
  transform: rotate(45deg);
}

/* ── Hidden utility ──────────────────────── */
.is-hidden {
  display: none !important;
}

/* ══════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════ */
@media screen and (max-width: 1200px) {
  .v2-header__search input {
    width: 220px;
  }
}

@media screen and (max-width: 1024px) {
  .v2-main {
    flex-direction: column;
  }

  .v2-sidebar {
    width: 100%;
  }

  .v2-sidebar__list {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 12px;
    padding-bottom: 4px;
  }

  .v2-history-card {
    min-width: 280px;
    flex-shrink: 0;
  }
}

@media screen and (max-width: 768px) {
  .v2-header {
    padding: 0 16px;
  }

  .v2-header__search {
    display: none;
  }

  .v2-header__user-info {
    display: none;
  }

  .v2-main {
    padding: 16px;
    gap: 16px;
  }

  .v2-card {
    padding: 16px;
  }

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

  .v2-products-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
  }

  .v2-footer__inner {
    flex-direction: column;
    gap: 8px;
  }

  .v2-footer__left,
  .v2-footer__right {
    width: 100%;
    justify-content: center;
  }

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

  .v2-profile-form {
    grid-template-columns: 1fr;
  }

  .v2-profile-actions {
    grid-column: span 1;
  }
}

/* ── Animation ───────────────────────────── */
@keyframes v2-fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.v2-animate {
  animation: v2-fadeIn 0.4s ease forwards;
}

.v2-animate--delay-1 { animation-delay: 0.05s; opacity: 0; }
.v2-animate--delay-2 { animation-delay: 0.12s; opacity: 0; }
.v2-animate--delay-3 { animation-delay: 0.20s; opacity: 0; }

/* ── Папки-комплекты (группы КП) ─────────────── */
.v2-seg { margin-bottom: 14px; }

.v2-group-select {
  margin-top: 6px;
  max-width: 200px;
  font-size: 12px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
}
.v2-group-select:focus { outline: none; border-color: #d2054f; box-shadow: 0 0 0 2px rgba(210,5,79,0.15); }

.v2-seg-footer {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 10px;
  padding: 10px 0;
  flex-wrap: wrap;
}
.v2-seg-footer__label { font-size: 13px; color: var(--muted); }
.v2-seg-footer__total { font-size: 16px; color: #d2054f; }
.v2-seg-footer__eco { font-size: 12px; color: #d2054f; }

/* Папка-комплект: рамку выносим наружу на 14px, контент возвращаем внутренним
   padding 14px — колонки совпадают с блоком «без папки», а рамка шире. */
.v2-group-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  margin: 0 -14px 14px;
  overflow: hidden;
  background: var(--surface);
}
.v2-group-card__table { padding: 4px 14px 0; }
.v2-group-card .v2-seg-footer { padding-left: 14px; padding-right: 14px; }
.v2-group-card__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(210,5,79,0.06);
  border-bottom: 1px solid var(--border-light);
}
.v2-group-card__header .material-symbols-outlined { color: #d2054f; font-size: 20px; }
.v2-group-name {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
}
.v2-group-name:hover { border-color: var(--border); background: var(--surface); }
.v2-group-name:focus { outline: none; border-color: #d2054f; background: var(--surface); box-shadow: 0 0 0 2px rgba(210,5,79,0.12); }
.v2-group-delete {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  padding: 4px;
  border-radius: 6px;
}
.v2-group-delete:hover { color: #d2054f; background: rgba(210,5,79,0.08); }
.v2-group-card__empty {
  padding: 18px 14px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.v2-add-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0 8px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #d2054f;
  background: rgba(210,5,79,0.05);
  border: 1px dashed rgba(210,5,79,0.4);
  border-radius: 10px;
  cursor: pointer;
}
.v2-add-group:hover { background: rgba(210,5,79,0.1); }
.v2-add-group .material-symbols-outlined { font-size: 18px; }

/* ── Характеристики товаров ─────────────────── */
.v2-specs-details {
  margin-top: 10px;
  max-width: 480px;
}

.v2-specs-details summary {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
}
.v2-specs-details summary:hover {
  color: #d2054f;
}

.v2-specs-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  margin-top: 6px;
  background: var(--border-light);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.v2-spec-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-soft);
  padding: 2px 4px;
  border-radius: 4px;
}
.v2-spec-row:hover {
  background: rgba(0, 0, 0, 0.02);
}

.v2-spec-row input[type="checkbox"] {
  width: 14px;
  height: 14px;
  cursor: pointer;
  accent-color: #d2054f;
}

.v2-spec-label {
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.v2-spec-value {
  font-weight: 400;
  color: var(--ink-soft);
}

.v2-spec-input-label,
.v2-spec-input-value {
  font-size: 12px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink-soft);
}
.v2-spec-input-label {
  flex: 1;
  min-width: 80px;
}
.v2-spec-input-value {
  flex: 1.5;
  min-width: 120px;
}
.v2-spec-input-label:focus,
.v2-spec-input-value:focus {
  outline: none;
  border-color: #d2054f;
}

.v2-spec-delete {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  padding: 0 4px;
}
.v2-spec-delete:hover {
  color: #d2054f;
}

.v2-spec-add {
  align-self: flex-start;
  font-size: 11px;
  font-weight: 600;
  color: #d2054f;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  margin-top: 2px;
}
.v2-spec-add:hover {
  background: rgba(210, 5, 79, 0.08);
}

/* ── Сравнительная таблица товаров ──────────── */
.v2-compare-area {
  margin-top: 24px;
  animation: v2-fadeIn 0.3s ease forwards;
}

.v2-compare-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 12px;
}

.v2-compare-placeholder {
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  background: var(--surface);
}

.v2-compare-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.v2-compare-table th,
.v2-compare-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.v2-compare-table th {
  background: var(--border-light);
  font-weight: 600;
  color: var(--ink-soft);
  vertical-align: top;
}

.v2-compare-table td:first-child {
  background: var(--border-light);
  font-weight: 500;
  color: var(--ink-soft);
  width: 150px;
  border-right: 1px solid var(--border);
}

.v2-compare-table th + th,
.v2-compare-table td + td {
  border-left: 1px solid var(--border);
}

.v2-item-name-link {
  color: inherit;
  text-decoration: none;
}

.v2-item-name-link:hover {
  text-decoration: underline;
}

.v2-compare-row-clickable {
  cursor: pointer;
  transition: background-color var(--transition);
}

.v2-compare-row-clickable:hover {
  background-color: var(--surface-hover);
}

.v2-compare-row-clickable.is-highlight {
  background-color: rgba(210, 5, 79, 0.08) !important;
}

.v2-compare-row-clickable.is-highlight:hover {
  background-color: rgba(210, 5, 79, 0.08) !important;
}
