/*
 * Раздел «Прайс» (cp): редактор таблицы цен по макетам pen.dev
 * «Прайс (таблица)», «… (массовое изменение)», «… (копирование и перетаскивание)», «… (MacBook, новая модель)».
 * Классы с префиксом pe-; цвета через var(--ive-*) (переопределены для тёмной темы в cp.css).
 */
.pe { --pe-head: #FDE7F2; --pe-group: #F9D3E6; --pe-sel: #2F6FEB; --pe-sel-soft: rgba(47, 111, 235, .09); --pe-grip: #C9C9D1; --pe-note: #EEF4FB; --pe-note-ink: #1F4F7A; --pe-note-icon: #2F75B5; }
.dark .pe { --pe-head: #3A1426; --pe-group: #4A1A31; --pe-sel: #6E9BF5; --pe-sel-soft: rgba(110, 155, 245, .14); --pe-grip: #5A5A66; --pe-note: #16223D; --pe-note-ink: #BFD3FB; --pe-note-icon: #9DB7F5; }
.pe-root { display: flex; flex-direction: column; gap: 18px; color: var(--ive-ink); font-size: 13px; }
.pe-root button { font: inherit; cursor: pointer; }
.pe-spacer { flex: 1 1 auto; }
.pe-muted { color: var(--ive-ink-3); }
.pe-root svg, .pe-menu svg { flex: none; }

/* Листы, кто в прайсе, сохранение, поиск */
.pe-sheets { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pe-sheet { padding: 8px 14px; border-radius: 10px; border: 1px solid var(--ive-line); background: var(--ive-bg); font-size: 14px !important; font-weight: 700; color: var(--ive-ink); white-space: nowrap; }
.pe-sheet:hover { border-color: var(--ive-ink-3); }
.pe-sheet.is-on { background: var(--ive-ink); border-color: var(--ive-ink); color: var(--ive-bg); }
.pe-avatars { display: flex; align-items: center; margin-right: 2px; }
.pe-avatar { width: 30px; height: 30px; border-radius: 999px; border: 2px solid var(--ive-bg); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.pe-avatar + .pe-avatar { margin-left: -8px; }
.pe-save { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px; background: var(--ive-green-soft); color: var(--ive-green-dark); max-width: 320px; }
.pe-save > span { display: inline-flex; }
.pe-save svg { width: 16px; height: 16px; }
.pe-save div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.pe-save b { font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pe-save small { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pe-save.is-saving { background: var(--ive-bg); color: var(--ive-ink-2); box-shadow: inset 0 0 0 1px var(--ive-line); }
.pe-save.is-saving svg { animation: pe-spin 1s linear infinite; }
.pe-save.is-offline { background: var(--ive-bad-soft); color: var(--ive-bad-text); }
@keyframes pe-spin { to { transform: rotate(360deg); } }
.pe-search { display: inline-flex; align-items: center; gap: 8px; width: 170px; padding: 0 12px; height: 34px; border-radius: 10px; border: 1px solid var(--ive-line); background: var(--ive-bg); color: var(--ive-ink-3); }
.pe-search:focus-within { border-color: var(--ive-pink); }
.pe-search svg { width: 15px; height: 15px; }
.pe-search input { flex: 1; min-width: 0; border: 0; padding: 0; background: transparent; font-size: 13px; color: var(--ive-ink); outline: none; box-shadow: none; }
.pe-search input::placeholder { color: var(--ive-ink-3); }

/* Белая панель с таблицей и панель справа */
.pe-work { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
.pe-work.has-panel { grid-template-columns: minmax(0, 1fr) 360px; }
.pe-table-panel { background: var(--ive-bg); border-radius: 20px; overflow: hidden; display: flex; flex-direction: column; min-width: 0; }

.pe-tools { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--ive-line); }
.pe-tools__group { display: contents; }
.pe-tools__sep { width: 1px; height: 22px; background: var(--ive-line); margin: 0 2px; }
.pe-selinfo { font-size: 13px; font-weight: 700; color: var(--ive-blue); max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pe-tbtn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border-radius: 9px; border: 1px solid var(--ive-line); background: var(--ive-bg); font-size: 13px !important; font-weight: 600; color: var(--ive-ink); white-space: nowrap; }
.pe-tbtn svg { width: 15px; height: 15px; color: var(--ive-ink-2); }
.pe-tbtn:hover { background: var(--ive-bg-2); }
.pe-tbtn--pink { background: var(--ive-pink-soft); border-color: transparent; color: var(--ive-pink); }
.pe-tbtn--pink svg { color: var(--ive-pink); }
.pe-tbtn--pink:hover { background: var(--ive-pink-soft); filter: brightness(.97); }
.pe-tbtn--icon { padding: 6px 10px; }
.pe-wide { width: 100%; justify-content: center; padding: 9px 12px; }
.pe-hidden-toggle { display: inline-flex; align-items: center; gap: 6px; padding: 0 6px; font-size: 12px; color: var(--ive-ink-2); white-space: nowrap; }

/* Примечания листа */
.pe-notebar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--pe-note); border-bottom: 1px solid var(--ive-line); }
.pe-notebar--site { border-bottom: 0; border-top: 1px solid var(--ive-line); }
.pe-note { flex: 1; min-width: 0; margin: 0; font-size: 12px; color: var(--pe-note-ink); white-space: pre-line; }
.pe-note-empty { font-style: italic; opacity: .7; }
.pe-notebar__edit { border: 0; background: none; padding: 0; font-size: 12px !important; font-weight: 700; color: var(--ive-pink); white-space: nowrap; }
.pe-badge { display: inline-flex; align-items: center; gap: 4px; flex: none; font-size: 11px; font-weight: 700; line-height: 1; padding: 4px 8px; border-radius: 999px; white-space: nowrap; cursor: help; }
.pe-badge svg { width: 12px; height: 12px; }
.pe-badge--site { background: var(--ive-green-soft); color: var(--ive-green-dark); }
.pe-badge--internal { background: var(--ive-bg); color: var(--ive-ink-2); }

/* Сетка */
.pe-scroll { position: relative; overflow: auto; height: calc(100vh - 400px); min-height: 360px; outline: none; background: var(--ive-bg); }
.pe-scroll:focus-visible { box-shadow: inset 0 0 0 2px var(--pe-sel-soft); }
.pe-inner { position: relative; width: max-content; min-width: 100%; }
.pe-table { border-collapse: separate; border-spacing: 0; font-size: 12px; table-layout: fixed; user-select: none; }
.pe-col-service { width: 286px; }
.pe-col-model { width: 68px; }
.pe-table td, .pe-table th { border-right: 1px solid var(--ive-line); border-bottom: 1px solid var(--ive-line); padding: 0 6px; height: 29px; }
.pe-table thead th { position: sticky; z-index: 3; background: var(--pe-head); color: var(--ive-ink); font-size: 11px; font-weight: 700; text-align: center; line-height: 1.15; border-right-color: transparent; }
.pe-table thead th.pe-h0 { top: 0; }
.pe-table thead th.pe-h1 { top: 28px; height: 44px; }
.pe-table thead th.pe-group { height: 28px; background: var(--pe-group); color: var(--ive-pink-dark); font-weight: 800; border-right: 1px solid rgba(230, 0, 126, .33); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pe-table thead th.pe-corner { left: 0; z-index: 5; text-align: left; padding-left: 12px; font-size: 12px; color: var(--ive-ink-2); border-right-color: var(--ive-line); background: var(--pe-head); }
.pe-table thead th.pe-simple { height: 44px; }
.pe-mh { position: relative; cursor: default; }
.pe-mh-label { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pe-mh-label small { display: block; font-size: 10px; font-weight: 500; color: var(--ive-ink-2); }
.pe-mh-tools { position: absolute; right: 1px; top: 1px; display: none; gap: 1px; }
.pe-mh:hover .pe-mh-tools, .pe-sh:hover .pe-sh-tools { display: flex; }
.pe-tool { border-radius: 4px; padding: 0 3px; font-size: 11px; line-height: 15px; background: var(--ive-bg); color: var(--ive-pink); box-shadow: 0 0 0 1px var(--ive-line); cursor: pointer; }
.pe-grab { cursor: grab; }
.pe-drop { box-shadow: inset 3px 0 0 var(--pe-sel); }
.pe-drop-row { box-shadow: inset 0 3px 0 var(--pe-sel); }
.pe-table tbody th { position: sticky; left: 0; z-index: 2; background: var(--ive-bg-2); text-align: left; font-weight: 600; padding: 0 8px 0 6px; }
.pe-sh { position: relative; }
.pe-sh > * { vertical-align: middle; }
.pe-grip { display: inline-flex; color: var(--pe-grip); margin-right: 4px; }
.pe-grip.pe-grab:hover { color: var(--ive-pink); }
.pe-sh-name { display: inline-block; width: calc(100% - 22px); line-height: 1.15; overflow: hidden; display: -webkit-inline-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; color: var(--ive-ink); font-size: 12px; }
.pe-sh-lock { position: absolute; right: 4px; bottom: 3px; opacity: .55; cursor: help; }
.pe-sh-lock svg { width: 11px; height: 11px; }
.pe-sh-tools { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); display: none; }
.pe-cell { text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: cell; font-weight: 600; color: var(--ive-ink); }
.pe-cell--none { color: var(--ive-plan); text-align: center; }
.pe-cell--ask { color: var(--ive-warn-text); text-align: center; font-size: 11px; }
.pe-cell--text { text-align: left; font-size: 11px; font-weight: 500; color: var(--ive-ink-2); }
.pe-cell--pending { font-style: italic; color: var(--ive-late-text); }
.pe-cell--chg::before, .pe-dot { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--ive-pink); margin-right: 5px; vertical-align: 1px; }
.pe-hidden { opacity: .45; }
.pe-sel { position: absolute; pointer-events: none; z-index: 1; background: var(--pe-sel-soft); border: 2px solid var(--pe-sel); }
.pe-act { position: absolute; pointer-events: none; z-index: 1; border: 2px solid var(--pe-sel); }
.pe-fill { position: absolute; z-index: 2; width: 9px; height: 9px; background: var(--pe-sel); border: 1px solid #fff; cursor: crosshair; }
.pe-fillbox { position: absolute; pointer-events: none; z-index: 1; border: 2px dashed var(--pe-sel); background: var(--pe-sel-soft); }
.pe-peer { position: absolute; pointer-events: none; z-index: 1; border: 2px solid; }
.pe-peer span { position: absolute; top: -1rem; left: -2px; font-size: 10px; color: #fff; padding: 0 4px; border-radius: 3px 3px 3px 0; white-space: nowrap; }
.pe-edit { position: absolute; z-index: 4; border: 2px solid var(--pe-sel); padding: 0 6px; font-size: 12px; font-weight: 600; text-align: right; background: var(--ive-bg); color: var(--ive-ink); outline: none; }

/* Строка состояния */
.pe-legend { display: flex; align-items: center; gap: 6px 16px; flex-wrap: wrap; padding: 8px 14px; background: var(--ive-bg-2); border-top: 1px solid var(--ive-line); font-size: 12px; color: var(--ive-ink-3); }
.pe-legend b { font-weight: 700; color: var(--ive-ink); margin-right: 2px; }
.pe-legend b.is-ask { color: var(--ive-warn-text); }
.pe-legend b.is-none { color: var(--ive-plan); }
.pe-legend__hint { cursor: help; }

/* Панель справа (массовое изменение, вставка) */
.pe-side { background: var(--ive-bg); border-radius: 20px; position: sticky; top: 84px; }
.pe-side__body { display: flex; flex-direction: column; gap: 14px; padding: 18px 20px 20px; }
.pe-side__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pe-side__head h3 { margin: 0; font-size: 18px; font-weight: 700; color: var(--ive-ink); }
.pe-x { border: 0; background: none; font-size: 22px !important; line-height: 1; color: var(--ive-ink-3); padding: 0 4px; }
.pe-side__where { margin: 0; font-size: 12px; color: var(--ive-ink-2); }
.pe-side__note { margin: 0; font-size: 12px; color: var(--ive-ink-3); }
.pe-seg { display: flex; gap: 3px; padding: 3px; border-radius: 12px; background: var(--ive-bg-2); }
.pe-seg button { flex: 1; border: 0; background: transparent; padding: 7px 6px; border-radius: 9px; font-size: 13px !important; font-weight: 600; color: var(--ive-ink-2); }
.pe-seg button.is-on { background: var(--ive-ink); color: var(--ive-bg); }
.pe-ops { display: flex; flex-wrap: wrap; gap: 6px; }
.pe-ops button { border: 1px solid var(--ive-line); background: var(--ive-bg); border-radius: 999px; padding: 4px 10px; font-size: 12px !important; font-weight: 600; color: var(--ive-ink-2); }
.pe-ops button.is-on { background: var(--ive-ink); border-color: var(--ive-ink); color: var(--ive-bg); }
.pe-value { display: flex; align-items: center; gap: 10px; }
.pe-value small { font-size: 12px; color: var(--ive-ink-3); }
.pe-field { display: inline-flex; align-items: center; gap: 6px; width: 140px; padding: 0 12px; height: 42px; border-radius: 12px; border: 1.5px solid var(--ive-pink); background: var(--ive-bg); }
.pe-field input { flex: 1; min-width: 0; border: 0; padding: 0; background: transparent; font-size: 17px; font-weight: 700; color: var(--ive-ink); outline: none; box-shadow: none; }
.pe-field span { font-size: 15px; font-weight: 600; color: var(--ive-ink-2); }
.pe-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ive-ink); }
.pe-check input, .pe-hidden-toggle input { accent-color: var(--ive-pink); }
.pe-prev { border: 1px solid var(--ive-line); border-radius: 12px; overflow: hidden; max-height: 360px; overflow-y: auto; }
.pe-prev__head { position: sticky; top: 0; display: flex; justify-content: space-between; padding: 8px 12px; background: var(--ive-bg-2); font-size: 12px; font-weight: 700; color: var(--ive-ink-3); }
.pe-prev__head span:last-child { color: var(--ive-pink); }
.pe-prev__row { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-top: 1px solid var(--ive-line); font-size: 12px; }
.pe-prev__row span { flex: 1; min-width: 0; color: var(--ive-ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pe-prev__row s { color: var(--ive-ink-3); white-space: nowrap; }
.pe-prev__row b { color: var(--ive-green-dark); font-weight: 700; white-space: nowrap; }
.pe-prev__more { padding: 7px 12px; border-top: 1px solid var(--ive-line); font-size: 12px; color: var(--ive-ink-3); }
.pe-chip-count { display: inline-flex; padding: 5px 10px; border-radius: 999px; background: var(--ive-blue-soft); color: var(--ive-blue); font-size: 12px; font-weight: 700; }
.pe-side__btns { display: flex; gap: 8px; }
.pe-btn-pink, .pe-btn-line { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 14px; border-radius: 12px; font-size: 14px !important; font-weight: 700; white-space: nowrap; }
.pe-side__btns .pe-btn-pink { flex: 1; }
.pe-btn-pink { border: 1px solid var(--ive-pink); background: var(--ive-pink); color: #fff; }
.pe-btn-pink:hover { background: var(--ive-pink-dark); }
.pe-btn-pink:disabled { opacity: .45; cursor: default; }
.pe-btn-line { border: 1px solid var(--ive-line); background: var(--ive-bg); color: var(--ive-ink); font-weight: 600; }
.pe-btn-line:hover { background: var(--ive-bg-2); }

/* Меню (правый клик, ⋯, «Пометка») */
.pe-menu { position: fixed; z-index: 60; min-width: 240px; max-width: 340px; background: var(--ive-bg); border: 1px solid var(--ive-line); border-radius: 14px; box-shadow: 0 12px 32px rgba(20, 20, 24, .14); padding: 6px; font-size: 13px; color: var(--ive-ink); }
.pe-menu button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 7px 10px; border: 0; background: none; border-radius: 9px; font-size: 13px !important; font-weight: 500; color: var(--ive-ink); }
.pe-menu button svg { width: 15px; height: 15px; color: var(--ive-ink-2); }
.pe-menu button:hover { background: var(--ive-bg-2); }
.pe-menu button.is-danger, .pe-menu button.is-danger svg { color: var(--ive-bad-text); }
.pe-menu hr { margin: 4px 0; border: 0; border-top: 1px solid var(--ive-line); }
.pe-menu__title { padding: 4px 10px 6px; font-size: 12px; color: var(--ive-ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pe-swatch { display: inline-block; flex: none; width: 15px; height: 15px; border-radius: 4px; border: 1px solid rgba(0, 0, 0, .15); }
.pe-swatch--none { background: repeating-linear-gradient(45deg, transparent 0 3px, var(--ive-line) 3px 5px); }

/* Окна: конфликт правок, история ячейки */
.pe-modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(20, 20, 24, .4); display: grid; place-items: center; padding: 1rem; }
.pe-modal { background: var(--ive-bg); border-radius: 20px; width: min(46rem, 100%); max-height: 85vh; display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); color: var(--ive-ink); }
.pe-modal h3 { font-weight: 700; font-size: 18px; padding: 18px 20px 8px; margin: 0; }
.pe-modal-body { padding: 0 20px; overflow: auto; font-size: 13px; }
.pe-modal-foot { padding: 12px 20px 18px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.pe-list { width: 100%; border-collapse: collapse; }
.pe-list td { padding: 7px 6px; border-bottom: 1px solid var(--ive-line); vertical-align: top; }
.pe-was { color: var(--ive-ink-3); text-decoration: line-through; white-space: nowrap; }
.pe-now { color: var(--ive-green-dark); font-weight: 700; white-space: nowrap; }

@media (max-width: 1280px) { .pe-work.has-panel { grid-template-columns: minmax(0, 1fr); } .pe-side { position: static; } }
/* С открытой панелью справа таблица уже — на кнопках остаются только значки (как в макете «массовое изменение») */
.pe-work.has-panel .pe-tbtn__l { display: none; }

/* Версии прайса: длинные имена файлов в комментарии переносим, чтобы кнопки строки не уезжали вправо. */
.pv-comment { overflow-wrap: anywhere; word-break: break-word; }
.pe-work.has-panel .pe-selinfo { max-width: 150px; }
