/* ==================== Форма «Добавить магазин»: подсказки ==================== */
.addr-hint {
    margin-top: 8px;
    font-size: 0.76rem;
    color: var(--text-secondary);
    background: var(--surface-2);
    border: 1px dashed var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.4;
}
.addr-hint i { color: var(--accent, #990000); flex-shrink: 0; }
.addr-hint.ok { color: #065f46; background: #ecfdf5; border: 1px solid #a7f3d0; }
.addr-hint.ok i { color: #16a34a; }

.addr-detect-btn {
    width: 100%;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.addr-detect-btn:hover:not(:disabled) { border-color: var(--accent, #990000); color: var(--accent, #990000); }
.addr-detect-btn:disabled { opacity: 0.6; cursor: default; }

/* Ориентир по тарифам */
.tariff-hint {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    background: linear-gradient(135deg, rgba(var(--accent-rgb, 153, 0, 0), 0.09), rgba(var(--accent-rgb, 153, 0, 0), 0.02));
    border: 1px solid rgba(var(--accent-rgb, 153, 0, 0), 0.25);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 12px;
}
.tariff-hint.muted { background: var(--surface-2); border: 1px dashed var(--border); }
.tariff-hint-icon {
    width: 34px; height: 34px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    background: var(--accent, #990000);
    color: #fff;
    flex-shrink: 0;
    font-size: 0.9rem;
}
.tariff-hint.muted .tariff-hint-icon { background: var(--text-faint, #94a3b8); }
.tariff-hint-title { font-size: 0.82rem; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.tariff-hint-text { font-size: 0.78rem; color: var(--text-secondary); line-height: 1.4; }
.tariff-hint-text strong { color: var(--accent, #990000); }

/* Рекомендуемые должности */
.reco-block { margin-bottom: 14px; }
.reco-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
}
.reco-title i { color: #f59e0b; }
.reco-title span { font-weight: 500; font-size: 0.72rem; color: var(--text-muted); }
.reco-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.reco-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px 7px 13px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 22px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text);
    transition: all 0.15s;
}
.reco-chip:hover { border-color: var(--accent, #990000); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); }
.reco-chip-name { font-weight: 600; }
.reco-chip-hint { font-size: 0.72rem; color: var(--text-muted); background: var(--surface-2); padding: 2px 8px; border-radius: 12px; }
.reco-chip-cov { font-size: 0.68rem; color: var(--text-faint, #94a3b8); }
.reco-chip-add {
    width: 20px; height: 20px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--accent, #990000); color: #fff; font-size: 0.6rem;
    flex-shrink: 0;
}
.reco-chip.added { border-color: #a7f3d0; background: #ecfdf5; }
.reco-chip.added .reco-chip-add { background: #16a34a; }

/* Подсказка тарифа в строке должности */
.pos-tariff-hint {
    margin-top: 6px;
    font-size: 0.72rem;
    color: #1e40af;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 4px 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.pos-tariff-hint i { color: #2563eb; }
.pos-tariff-hint strong { color: #1e3a8a; }


/* ==================== ТАРИФЫ: inline-правка и массовое изменение ==================== */

/* --- Кнопка режима редактирования --- */
#tariffEditToggleBtn.active {
    background: #ffffff;
    color: var(--primary, #990000);
    border-color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* --- Чекбоксы выбора магазинов --- */
.tariff-th-shop {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.tariff-select-all,
.tariff-row-check {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--primary, #990000);
    flex: 0 0 auto;
}
.tariff-row-check {
    margin-right: 2px;
}

/* --- Кликабельный тариф в чипе (inline-правка) --- */
.tariff-pos-chip.editable {
    transition: border-color 0.15s, box-shadow 0.15s;
}
.tariff-pos-chip.editable:hover {
    border-color: var(--accent, #990000);
}
.tariff-pos-chip .pos-rate-editable {
    cursor: pointer;
    border-bottom: 1px dashed currentColor;
    padding-bottom: 1px;
}
.tariff-pos-chip .pos-rate-editable:hover {
    color: var(--primary, #990000);
    border-bottom-style: solid;
}
.tariff-pos-chip .pos-rate-editable i {
    font-size: 0.56rem;
    opacity: 0.55;
    margin-right: 1px;
}

/* --- Состояние редактирования чипа --- */
.tariff-pos-chip.editing {
    gap: 4px;
    background: var(--surface);
    border-color: var(--accent, #990000);
    box-shadow: 0 0 0 2px rgba(var(--accent-rgb, 153, 0, 0), 0.12);
}
.tariff-pos-chip.saving {
    opacity: 0.6;
    pointer-events: none;
}
.tariff-pos-chip .pos-rate-input {
    width: 68px;
    padding: 2px 6px;
    font-size: 0.72rem;
    line-height: 1.4;
    color: var(--text);
    background: var(--input-bg, var(--surface-2));
    border: 1px solid var(--border);
    border-radius: 6px;
    outline: none;
}
.tariff-pos-chip .pos-rate-input:focus {
    border-color: var(--accent, #990000);
}
.tariff-pos-chip .pos-rate-input::-webkit-outer-spin-button,
.tariff-pos-chip .pos-rate-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.tariff-pos-chip .pos-rate-input {
    -moz-appearance: textfield;
}
.tariff-pos-chip .pos-rate-save,
.tariff-pos-chip .pos-rate-cancel {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    cursor: pointer;
    font-size: 0.62rem;
    line-height: 1;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.tariff-pos-chip .pos-rate-save { color: #16a34a; }
.tariff-pos-chip .pos-rate-save:hover { background: #16a34a; color: #fff; border-color: #16a34a; }
.tariff-pos-chip .pos-rate-cancel { color: #dc2626; }
.tariff-pos-chip .pos-rate-cancel:hover { background: #dc2626; color: #fff; border-color: #dc2626; }

/* --- Панель массового изменения --- */
.tariff-bulk-bar {
    position: fixed;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    z-index: 590;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    max-width: calc(100vw - 32px);
    padding: 10px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 10px 34px rgba(0, 0, 0, 0.18);
    animation: tbbSlideUp 0.18s ease-out;
}
@keyframes tbbSlideUp {
    from { opacity: 0; transform: translate(-50%, 12px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}
.tariff-bulk-bar .tbb-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.tariff-bulk-bar .tbb-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 5px 12px;
}
.tariff-bulk-bar .tbb-badge i { color: var(--accent, #990000); }
.tariff-bulk-bar .tbb-badge strong { color: var(--primary, #990000); }
.tariff-bulk-bar .tbb-link {
    background: none;
    border: none;
    padding: 2px 4px;
    font-size: 0.78rem;
    color: var(--accent, #990000);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.tariff-bulk-bar .tbb-link:hover { color: var(--primary, #990000); }
.tariff-bulk-bar .tbb-right {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}
.tariff-bulk-bar .tbb-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.tariff-bulk-bar .tbb-label {
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    font-weight: 700;
}
.tariff-bulk-bar .tbb-select,
.tariff-bulk-bar .tbb-input {
    height: 36px;
    padding: 0 10px;
    font-size: 0.82rem;
    color: var(--text);
    background: var(--input-bg, var(--surface-2));
    border: 1px solid var(--border);
    border-radius: 9px;
    outline: none;
}
.tariff-bulk-bar .tbb-select { min-width: 170px; }
.tariff-bulk-bar .tbb-input { width: 130px; }
.tariff-bulk-bar .tbb-select:focus,
.tariff-bulk-bar .tbb-input:focus { border-color: var(--accent, #990000); }
.tariff-bulk-bar .tbb-apply {
    height: 36px;
    padding: 0 18px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

/* --- Адаптив --- */
@media (max-width: 768px) {
    .tariff-bulk-bar {
        left: 8px;
        right: 8px;
        bottom: 64px;
        transform: none;
        max-width: none;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    @keyframes tbbSlideUp {
        from { opacity: 0; transform: translateY(12px); }
        to   { opacity: 1; transform: translateY(0); }
    }
    .tariff-bulk-bar .tbb-left,
    .tariff-bulk-bar .tbb-right {
        justify-content: space-between;
    }
    .tariff-bulk-bar .tbb-field { flex: 1; }
    .tariff-bulk-bar .tbb-select,
    .tariff-bulk-bar .tbb-input { width: 100%; min-width: 0; }
    .tariff-bulk-bar .tbb-apply { width: 100%; justify-content: center; }
}

/* ==================== Заголовок таблицы тарифов — как в «Сотрудниках» / «Сменах» ==================== */
.tariff-table thead tr th {
    background: var(--primary);
    color: #ffffff;
    font-weight: 600;
    padding: 12px 10px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    font-size: 0.78rem;
    letter-spacing: 0.3px;
    text-transform: none;
    white-space: normal;
    word-break: keep-all;
    text-align: center;
    vertical-align: middle;
    box-shadow: none;
    border-radius: 0;
    transition: background 0.2s;
}
.tariff-table thead tr th:hover { background: var(--primary-dark); }
.tariff-table thead tr th.sorted-asc,
.tariff-table thead tr th.sorted-desc { background: var(--primary-dark); }
.tariff-table thead tr th.sorted-asc::after,
.tariff-table thead tr th.sorted-desc::after {
    content: '';
    display: inline-block;
    width: auto;
    height: auto;
    margin-left: 6px;
    vertical-align: middle;
    border: none;
}
.tariff-table thead tr th.sorted-asc::after {
    content: "\f0dd";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 0.75rem;
}
.tariff-table thead tr th.sorted-desc::after {
    content: "\f0de";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 0.75rem;
}
.tariff-table thead tr th:first-child,
.tariff-table thead tr th:last-child {
    border-radius: 0;
    padding-left: 10px;
    padding-right: 10px;
    text-align: center;
}

/* ==================== Метрики в таблице тарифов ==================== */
/* Чип вида ТТ рядом с названием магазина */
.tariff-shop-title { font-weight: 700; }
.tariff-tt-chip {
    display: inline-flex;
    align-items: center;
    padding: 1px 9px;
    border-radius: 9999px;
    border: 1px solid;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    line-height: 1.6;
    white-space: nowrap;
}

/* Часы (закрыто в ЛКК / в сменах) с мини-диаграммой */
.tariff-hours-cell { text-align: center; }
.tariff-hours {
    position: relative;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 2px;
    min-height: 24px;
    padding: 0 4px;
    border-radius: 8px;
    overflow: hidden;
}
.tariff-hours .th-bar {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    border-radius: 8px;
    z-index: 0;
    transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}
.tariff-hours .th-bar.req { background: linear-gradient(90deg, rgba(37, 99, 235, 0.22), rgba(37, 99, 235, 0.06)); }
.tariff-hours .th-bar.shift { background: linear-gradient(90deg, rgba(220, 38, 38, 0.20), rgba(220, 38, 38, 0.05)); }
.tariff-hours .th-val { position: relative; z-index: 1; font-size: 0.95rem; font-weight: 700; color: var(--text); }
.tariff-hours .th-unit { position: relative; z-index: 1; font-size: 0.68rem; color: var(--text-muted); }

/* Акцент строки при расхождении */
.tariff-table tbody tr.row-plus td:first-child { box-shadow: inset 3px 0 0 #f59e0b; }
.tariff-table tbody tr.row-minus td:first-child { box-shadow: inset 3px 0 0 #ef4444; }

/* Разница */
.tariff-diff-cell { text-align: center; }
.tariff-diff {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.74rem;
    font-weight: 700;
    white-space: nowrap;
    border: 1px solid transparent;
}
.tariff-diff i { font-size: 0.66rem; }
.tariff-diff.match { color: #047857; background: #ecfdf5; border-color: #a7f3d0; }
.tariff-diff.plus { color: #b45309; background: #fffbeb; border-color: #fde68a; }
.tariff-diff.minus { color: #b91c1c; background: #fef2f2; border-color: #fecaca; }

/* Заявки за месяц (входящие / отклонённые) */
.tariff-claims-cell { text-align: center; }
.tariff-claims { display: inline-flex; align-items: center; gap: 6px; }
.claim-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 0.74rem;
    font-weight: 700;
    border: 1px solid transparent;
    white-space: nowrap;
}
.claim-badge i { font-size: 0.66rem; }
.claim-badge.incoming { color: #1d4ed8; background: #eff6ff; border-color: #bfdbfe; }
.claim-badge.rejected { color: #b91c1c; background: #fef2f2; border-color: #fecaca; }

html[data-theme="dark"] .tariff-diff.match { background: rgba(16,185,129,0.15); border-color: rgba(16,185,129,0.4); color: #6ee7b7; }
html[data-theme="dark"] .tariff-diff.plus { background: rgba(245,158,11,0.15); border-color: rgba(245,158,11,0.4); color: #fcd34d; }
html[data-theme="dark"] .tariff-diff.minus { background: rgba(239,68,68,0.15); border-color: rgba(239,68,68,0.4); color: #fca5a5; }
html[data-theme="dark"] .claim-badge.incoming { background: rgba(59,130,246,0.18); border-color: rgba(59,130,246,0.4); color: #93c5fd; }
html[data-theme="dark"] .claim-badge.rejected { background: rgba(239,68,68,0.18); border-color: rgba(239,68,68,0.4); color: #fca5a5; }

/* ==================== Карточка магазина: удаление / история / дата ==================== */
.sd-btn-danger { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
.sd-btn-danger:hover { background: #dc2626; color: #fff; border-color: #dc2626; }

/* История тарифов */
.sd-hist-head {
    display: flex; align-items: center; gap: 8px;
    font-weight: 700; font-size: 0.95rem; color: var(--text);
    padding: 4px 2px 14px 2px;
}
.sd-hist-head i { color: var(--accent, #990000); }
.sd-hist-head span {
    margin-left: auto; font-size: 0.72rem; font-weight: 700;
    background: var(--surface-2); border: 1px solid var(--border);
    color: var(--text-muted); border-radius: 20px; padding: 2px 10px;
}
.sd-hist-list { display: flex; flex-direction: column; gap: 8px; }
.sd-hist-item {
    display: flex; gap: 12px; align-items: flex-start;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 12px 14px;
    transition: box-shadow 0.15s, transform 0.15s;
}
.sd-hist-item:hover { box-shadow: 0 6px 18px rgba(0, 0, 0, 0.07); transform: translateY(-1px); }
.sd-hist-icon {
    width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 0.85rem;
    background: var(--surface-2); color: var(--text-muted);
}
.sd-hist-icon.up { background: #ecfdf5; color: #047857; }
.sd-hist-icon.down { background: #fef2f2; color: #b91c1c; }
.sd-hist-body { flex: 1; min-width: 0; }
.sd-hist-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.sd-hist-pos { font-weight: 700; color: var(--text); font-size: 0.88rem; }
.sd-hist-rates { font-size: 0.85rem; color: var(--text-secondary); white-space: nowrap; }
.sd-hist-rates i { font-size: 0.66rem; color: var(--text-faint, #cbd5e1); margin: 0 3px; }
.sd-hist-rates b { color: var(--accent, #990000); }
.sd-hist-meta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 5px; font-size: 0.72rem; color: var(--text-muted); }
.sd-hist-meta i { margin-right: 4px; opacity: 0.8; }
.sd-hist-pending { color: #b45309; font-weight: 600; }
.sd-hist-loading, .sd-hist-empty {
    text-align: center; padding: 40px 16px; color: var(--text-muted); font-size: 0.85rem;
}
.sd-hist-empty i { font-size: 2rem; display: block; margin-bottom: 10px; opacity: 0.4; }
.sd-hist-empty p { margin: 0; }

/* Отложенный тариф (действует с даты) */
.pos-pending {
    display: inline-flex; align-items: center; gap: 4px;
    color: #b45309; background: #fffbeb; border: 1px solid #fde68a;
    border-radius: 12px; padding: 1px 7px; font-size: 0.66rem; font-weight: 700;
    white-space: nowrap;
}
.sd-tariff-pending {
    margin-top: 4px; font-size: 0.74rem; color: #b45309;
    background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px;
    padding: 3px 9px; display: inline-flex; align-items: center; gap: 5px;
}

/* Модалка выбора даты действия */
.date-prompt-overlay {
    position: fixed; inset: 0; z-index: 10000;
    background: rgba(0, 0, 0, 0.45);
    display: flex; align-items: center; justify-content: center; padding: 16px;
}
.date-prompt {
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
    padding: 20px; width: 100%; max-width: 360px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    animation: dpIn 0.18s ease-out;
}
@keyframes dpIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
.dp-title { font-weight: 700; font-size: 1rem; color: var(--text); display: flex; align-items: center; gap: 8px; }
.dp-title i { color: var(--accent, #990000); }
.dp-desc { font-size: 0.78rem; color: var(--text-muted); margin: 8px 0 14px; line-height: 1.45; }
.dp-input {
    width: 100%; height: 42px; padding: 0 12px;
    border: 1.5px solid var(--border); border-radius: 10px;
    background: var(--input-bg, var(--surface-2)); color: var(--text);
    font-size: 0.95rem; font-family: inherit; outline: none;
}
.dp-input:focus { border-color: var(--accent, #990000); }
.dp-actions { display: flex; gap: 10px; margin-top: 16px; }
.dp-btn {
    flex: 1; height: 40px; border-radius: 10px; border: 1px solid var(--border);
    font-size: 0.88rem; font-weight: 600; cursor: pointer; font-family: inherit;
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    transition: all 0.15s;
}
.dp-cancel { background: var(--surface-2); color: var(--text-secondary); }
.dp-cancel:hover { background: var(--surface); color: var(--text); }
.dp-ok { background: var(--primary); color: #fff; border-color: var(--primary); }
.dp-ok:hover { filter: brightness(0.92); }

html[data-theme="dark"] .sd-hist-icon.up { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; }
html[data-theme="dark"] .sd-hist-icon.down { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
html[data-theme="dark"] .pos-pending,
html[data-theme="dark"] .sd-tariff-pending { background: rgba(245, 158, 11, 0.15); border-color: rgba(245, 158, 11, 0.4); color: #fcd34d; }
html[data-theme="dark"] .sd-btn-danger { background: rgba(239, 68, 68, 0.15); color: #fca5a5; border-color: rgba(239, 68, 68, 0.4); }

/* «Выделить все» — слева, название столбца — по центру */
.tariff-table thead tr th:first-child { text-align: center; position: relative; }
.tariff-th-shop { justify-content: center; }
.tariff-table thead tr th:first-child .tariff-select-all {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
}

/* ==================== Панель массового изменения: ширина и выравнивание ==================== */
.tariff-bulk-bar {
    width: min(1180px, calc(100vw - 32px));
    justify-content: space-between;
}
.tariff-bulk-bar .tbb-left { justify-content: flex-start; }

/* Кнопка «Редактировать» в карточке (стиль как в «Сотрудниках») в режиме правки */
.ed-btn-icon.editing { background: rgba(239, 68, 68, 0.35); border-color: rgba(239, 68, 68, 0.45); color: #fecaca; }
.ed-btn-icon.editing:hover { background: rgba(239, 68, 68, 0.5); color: #fff; }

/* ==================== Модалка тарифа (час / за смену / дата) ==================== */
.rate-modal { max-width: 430px; }
.rm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rm-field { display: flex; flex-direction: column; gap: 5px; font-size: 0.72rem; color: var(--text-muted); font-weight: 600; }
.rm-field.rm-full { grid-column: 1 / -1; }
.rm-input {
    width: 100%; height: 42px; padding: 0 12px;
    border: 1.5px solid var(--border); border-radius: 10px;
    background: var(--input-bg, var(--surface-2)); color: var(--text);
    font-size: 0.95rem; font-family: inherit; outline: none;
}
.rm-input:focus { border-color: var(--accent, #990000); }
.rm-input::-webkit-outer-spin-button,
.rm-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.rm-input[type=number] { -moz-appearance: textfield; }

/* Удобный блок даты действия тарифа в карточке */
.sd-tariff-date-box {
    background: linear-gradient(135deg, rgba(var(--accent-rgb, 153, 0, 0), 0.08), rgba(var(--accent-rgb, 153, 0, 0), 0.02));
    border: 1px solid rgba(var(--accent-rgb, 153, 0, 0), 0.25);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 12px;
}
.sd-tariff-date-box-head {
    font-size: 0.78rem; font-weight: 700; color: var(--text);
    display: flex; align-items: center; gap: 7px; margin-bottom: 8px;
}
.sd-tariff-date-box-head i { color: var(--accent, #990000); }
.sd-tariff-date-input {
    width: 100%; height: 40px; padding: 0 12px;
    border: 1.5px solid var(--border); border-radius: 10px;
    background: var(--surface); color: var(--text);
    font-size: 0.9rem; font-family: inherit; outline: none;
}
.sd-tariff-date-input:focus { border-color: var(--accent, #990000); }
.sd-tariff-date-box .sd-tariff-date-hint { margin: 8px 0 0 0; }

/* ==================== ВИД ОПЛАТЫ: переключатель над таблицей ==================== */
.tariff-paybar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: 0 0 10px 0;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}
.tpb-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
}
.tpb-label i { color: var(--accent, #990000); }
.tpb-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.tpb-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 9999px;
    background: var(--surface-2);
    color: var(--text-secondary);
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.tpb-btn i { font-size: 0.7rem; opacity: 0.8; }
.tpb-btn:hover { border-color: var(--accent, #990000); color: var(--accent, #990000); }
.tpb-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
}
/* ==================== МЕНЕДЖЕРЫ В ТАБЛИЦЕ ==================== */
.tariff-managers-cell { min-width: 160px; }
.tariff-managers .tm-list { display: flex; flex-wrap: wrap; gap: 4px; }
.tariff-managers .tm-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.5;
    white-space: nowrap;
}

/* ==================== ИСТОРИЯ: ТИП СТАВКИ ==================== */
.sd-hist-type {
    display: inline-block;
    margin-left: 6px;
    padding: 0 6px;
    font-size: 0.62rem;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 9999px;
    vertical-align: middle;
}

/* ==================== МОДАЛКА ТАРИФА: ВИД ОПЛАТЫ И ДРУГИЕ СТАВКИ ==================== */
.rm-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin: 2px 0 8px 0;
    padding: 4px 10px;
    border-radius: 9999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.74rem;
    font-weight: 700;
}
.rm-type-badge i { color: var(--accent, #990000); }
.rm-type-badge.override { background: rgba(var(--accent-rgb, 153, 0, 0), 0.08); border-color: rgba(var(--accent-rgb, 153, 0, 0), 0.28); color: var(--text); }
.rm-other {
    margin-top: 12px;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.rm-other-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}
.rm-other-title i { color: var(--accent, #990000); }
.rm-other-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.72rem;
    color: var(--text-muted);
    padding: 2px 0;
}
.rm-other-row b { color: var(--text); font-weight: 600; }
.rm-other-row.current {
    background: rgba(var(--accent-rgb, 153, 0, 0), 0.09);
    border-radius: 6px;
    padding: 3px 6px;
    margin: 0 -6px;
}
.rm-other-row.current > span:first-child { color: var(--text); font-weight: 700; }
.rm-other-val { display: inline-flex; align-items: center; gap: 6px; }
.rm-mark {
    padding: 0 6px;
    font-size: 0.58rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 9999px;
    line-height: 1.6;
}
.rm-mark.custom {
    color: var(--accent, #990000);
    border-color: rgba(var(--accent-rgb, 153, 0, 0), 0.35);
    background: rgba(var(--accent-rgb, 153, 0, 0), 0.08);
    font-weight: 700;
}
.rm-reset {
    margin-top: 8px;
    width: 100%;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
}
.rm-reset:hover { border-color: #dc2626; color: #dc2626; }

/* ==================== КАРТОЧКА: СТАВКИ ПО ВИДАМ ОПЛАТЫ ==================== */
.sd-tariff-item { flex-wrap: wrap; }
.sd-tariff-rates {
    width: 100%;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
}
.sd-rates-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 7px;
}
.sd-rates-title i { color: var(--accent, #990000); }
.sd-rates-matrix { display: flex; flex-direction: column; gap: 8px; }
.sd-rate-base-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(var(--accent-rgb, 153, 0, 0), 0.10), rgba(var(--accent-rgb, 153, 0, 0), 0.02));
    border: 1px solid rgba(var(--accent-rgb, 153, 0, 0), 0.28);
}
.sd-rate-base-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--text);
}
.sd-rate-base-label i { color: var(--accent, #990000); }
.sd-rate-base-val { font-size: 0.92rem; color: var(--text); }
.sd-rate-base-val span { font-size: 0.64rem; color: var(--text-muted); font-weight: 500; }
.sd-rate-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(115px, 1fr));
    gap: 6px;
}
.sd-rate-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    transition: border-color 0.15s, background 0.15s;
}
.sd-rate-cell.custom {
    border-color: var(--accent, #990000);
    background: rgba(var(--accent-rgb, 153, 0, 0), 0.08);
    box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb, 153, 0, 0), 0.12);
}
.sd-rate-cell .sd-rate-name {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-secondary);
}
.sd-rate-cell.custom .sd-rate-name { color: var(--accent, #990000); }
.sd-rate-cell .sd-rate-val { font-size: 0.82rem; color: var(--text); }
.sd-rate-cell .sd-rate-val span { font-size: 0.6rem; color: var(--text-muted); font-weight: 500; }
.sd-rate-cell .sd-rate-mark { font-size: 0.62rem; color: var(--text-muted); }
.sd-rate-cell.custom .sd-rate-mark { color: var(--accent, #990000); font-weight: 700; }

/* Быстрые действия по видам оплаты в редакторе тарифов */
.sd-te-bulk-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 8px;
}
.sd-te-bulk-actions button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.sd-te-bulk-actions button:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(var(--accent-rgb, 153, 0, 0), 0.06);
}
.sd-tariff-help {
    background: var(--surface-2);
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 8px 12px;
}

/* Периоды тарифов (ставка на конкретные даты) */
.sd-periods-block {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
}
.sd-periods-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}
.sd-periods-hint {
    font-size: 0.74rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 8px;
}
.sd-periods-empty {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px dashed var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.78rem;
}
.sd-period-row {
    display: grid;
    grid-template-columns: minmax(150px, 1.4fr) minmax(140px, 1.2fr) 130px 130px 110px 32px;
    gap: 6px;
    align-items: center;
    margin-top: 6px;
}
.sd-period-row select,
.sd-period-row input {
    width: 100%;
    min-width: 0;
    padding: 6px 8px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.78rem;
    outline: none;
    font-family: inherit;
}
.sd-period-row select:focus,
.sd-period-row input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(var(--accent-rgb, 153, 0, 0), 0.08);
}
.sd-period-remove {
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sd-period-remove:hover {
    color: #dc2626;
    border-color: #dc2626;
    background: rgba(220, 38, 38, 0.06);
}
.sd-periods-table-wrap { overflow-x: auto; }
.sd-periods-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.sd-periods-table th {
    text-align: left;
    padding: 7px 9px;
    background: var(--surface-2);
    color: var(--text-secondary);
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.sd-periods-table td {
    padding: 7px 9px;
    border-bottom: 1px solid var(--surface-2);
    color: var(--text);
}
.dp-period-note {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(8, 145, 178, 0.10);
    border: 1px solid rgba(8, 145, 178, 0.28);
    color: #0e7490;
    font-size: 0.76rem;
    line-height: 1.45;
}
.sd-rate-period {
    font-size: 0.62rem;
    color: var(--text-muted);
    line-height: 1.3;
}
.sd-rate-cell.period,
.sd-rate-base-box.period {
    border-color: #0891b2;
    background: rgba(8, 145, 178, 0.08);
}
.sd-rate-cell.period .sd-rate-name,
.sd-rate-cell.period .sd-rate-mark { color: #0e7490; }
.pos-period {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 5px;
    border-radius: 5px;
    background: rgba(8, 145, 178, 0.12);
    color: #0e7490;
    font-size: 0.62rem;
    font-weight: 600;
    white-space: nowrap;
}
.pos-period.next {
    background: rgba(100, 116, 139, 0.12);
    color: #475569;
}
.sd-rate-period.next { color: #64748b; }
@media (max-width: 900px) {
    .sd-period-row { grid-template-columns: 1fr 1fr; }
    .sd-period-row .sd-period-remove { width: 100%; }
}

/* Редактор тарифов в карточке */
.sd-tariff-edit-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 10px;
    background: var(--surface-2);
}
.sd-te-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.sd-te-pos { flex: 1; min-width: 0; }
.sd-te-pos label, .sd-te-rate label {
    display: block;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 3px;
}
.sd-te-pos select, .sd-te-rate input {
    width: 100%;
    padding: 7px 9px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.8rem;
    background: var(--input-bg, var(--surface));
    color: var(--text);
    outline: none;
}
.sd-te-rate input:focus, .sd-te-pos select:focus { border-color: var(--accent, #990000); }
.sd-tariff-remove {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 0.82rem;
    padding: 5px 8px;
    flex-shrink: 0;
}
.sd-te-rates { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.sd-te-rate {
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.sd-te-rate-base {
    grid-column: 1 / -1;
    border-color: rgba(var(--accent-rgb, 153, 0, 0), 0.35);
    background: linear-gradient(135deg, rgba(var(--accent-rgb, 153, 0, 0), 0.09), rgba(var(--accent-rgb, 153, 0, 0), 0.02));
}
.sd-te-rate.has-custom {
    border-color: var(--accent, #990000);
    background: rgba(var(--accent-rgb, 153, 0, 0), 0.07);
    box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb, 153, 0, 0), 0.10);
}
.sd-te-custom-badge {
    display: none;
    margin-left: 4px;
    padding: 0 5px;
    font-size: 0.56rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #fff;
    background: var(--accent, #990000);
    border-radius: 9999px;
    vertical-align: middle;
}
.sd-te-rate.has-custom .sd-te-custom-badge { display: inline-flex; }
.sd-te-rate.has-custom label { color: var(--accent, #990000); }
.sd-te-shift { margin-top: 4px; font-size: 0.7rem; color: var(--text-muted); }
.sd-te-shift .muted { color: var(--text-faint, #94a3b8); }
.sd-te-pending { margin-top: 3px; font-size: 0.68rem; color: #b45309; }
.sd-te-lunch {
    margin-top: 8px;
    display: inline-block;
    font-size: 0.7rem;
    color: var(--text-secondary);
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 3px 10px;
    border-radius: 20px;
}
@media (max-width: 640px) {
    .sd-te-rates { grid-template-columns: 1fr; }
    .sd-te-rate-base { grid-column: auto; }
}

/* ==================== ТЁМНАЯ ТЕМА ==================== */
html[data-theme="dark"] .tpb-btn.active { background: var(--accent, #990000); border-color: var(--accent, #990000); }
html[data-theme="dark"] .tariff-managers .tm-chip { background: rgba(148, 163, 184, 0.08); }
html[data-theme="dark"] .sd-rate-cell.custom,
html[data-theme="dark"] .sd-te-rate.has-custom { background: rgba(var(--accent-rgb, 153, 0, 0), 0.16); }
html[data-theme="dark"] .sd-te-rate-base { background: rgba(var(--accent-rgb, 153, 0, 0), 0.14); }
html[data-theme="dark"] .sd-te-pending { color: #fcd34d; }

/* Подсказка о дате действия тарифа в карточке */
.sd-tariff-date-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--surface-2);
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 7px 11px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 7px;
    line-height: 1.4;
}
.sd-tariff-date-hint i { color: var(--accent, #990000); flex-shrink: 0; }

/* ==================== КАРТА: КРАТКАЯ КАРТОЧКА МАГАЗИНА ==================== */
.map-shop-panel {
    position: absolute;
    top: 12px;
    right: 12px;
    bottom: 78px;
    width: 350px;
    max-width: calc(100% - 24px);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.22);
    z-index: 25;
    overflow: hidden;
    transform: translateX(calc(100% + 24px));
    opacity: 0;
    pointer-events: none;
    transition: transform 0.22s ease, opacity 0.22s ease;
}
.map-shop-panel.open {
    transform: none;
    opacity: 1;
    pointer-events: auto;
}
.msp-head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.msp-icon {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--accent, #990000);
    overflow: hidden;
    font-size: 1.1rem;
}
.msp-icon img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.msp-title { flex: 1; min-width: 0; }
.msp-title h3 {
    margin: 0 0 2px;
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.25;
    word-break: break-word;
}
.msp-title span { font-size: 0.72rem; color: var(--text-muted); }
.msp-close {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-2);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}
.msp-close:hover { background: #fee2e2; border-color: #fecaca; color: #b91c1c; }
.msp-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.msp-section { display: flex; flex-direction: column; gap: 6px; }
.msp-section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    margin-bottom: 1px;
}
.msp-section-title i { color: var(--accent, #990000); }
.msp-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.78rem;
    line-height: 1.4;
    color: var(--text-secondary);
}
.msp-row i {
    width: 13px;
    margin-top: 3px;
    flex-shrink: 0;
    color: var(--accent, #990000);
    font-size: 0.72rem;
}
.msp-row-ok { color: #047857; font-weight: 600; }
.msp-row-ok i { color: #16a34a; }
.msp-contact {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 7px 9px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 9px;
}
.msp-contact-main { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.msp-contact-name { font-size: 0.78rem; font-weight: 600; color: var(--text); }
.msp-contact-pos { font-size: 0.64rem; color: var(--text-muted); }
.msp-contact-phone {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.74rem;
    color: var(--accent, #990000);
    text-decoration: none;
}
.msp-contact-phone:hover { text-decoration: underline; }
.msp-rates { display: flex; flex-direction: column; gap: 5px; }
.msp-rate {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 9px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 9px;
    font-size: 0.78rem;
}
.msp-rate-name { flex: 1; min-width: 0; color: var(--text); font-weight: 600; }
.msp-rate b { color: var(--text); white-space: nowrap; }
.msp-rate b span { font-size: 0.62rem; color: var(--text-muted); font-weight: 500; }
.msp-rate-custom {
    padding: 0 6px;
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--accent, #990000);
    background: rgba(var(--accent-rgb, 153, 0, 0), 0.09);
    border: 1px solid rgba(var(--accent-rgb, 153, 0, 0), 0.3);
    border-radius: 9999px;
}
.msp-empty { font-size: 0.74rem; color: var(--text-muted); }
.msp-open-detail {
    width: 100%;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--primary);
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.15s;
}
.msp-open-detail:hover { filter: brightness(0.93); }
@media (max-width: 900px) {
    .map-shop-panel {
        left: 8px;
        right: 8px;
        width: auto;
        max-width: none;
        bottom: 76px;
        max-height: 62%;
    }
}
html[data-theme="dark"] .map-shop-panel { box-shadow: 0 16px 44px rgba(0, 0, 0, 0.5); }
html[data-theme="dark"] .msp-close:hover { background: rgba(239, 68, 68, 0.2); border-color: rgba(239, 68, 68, 0.4); color: #fca5a5; }

/* ==================== МАТРИЦА ТАРИФОВ В ТАБЛИЦЕ ==================== */
.tariff-table .tariff-matrix-td {
    padding: 6px 8px !important;
    vertical-align: top;
}
.tm-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
}
.tm-table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
    font-size: 0.72rem;
}
.tariff-table .tm-table thead tr th {
    background: var(--surface-2);
    color: var(--text-secondary);
    padding: 5px 6px;
    font-size: 0.66rem;
    font-weight: 700;
    text-align: center;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: static;
}
.tariff-table .tm-table thead tr th.tm-pos-head {
    text-align: left;
    padding-left: 8px;
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--surface-2);
}
.tariff-table .tm-table thead tr th.tm-col-active {
    background: var(--primary);
    color: #fff;
}
.tariff-table .tm-table tbody tr {
    cursor: default;
}
.tariff-table .tm-table tbody tr:hover td {
    background: transparent;
}
.tariff-table .tm-table td {
    padding: 3px 5px;
    border-bottom: 1px solid var(--surface-2);
    vertical-align: middle;
    text-align: right;
    background: var(--surface);
}
.tariff-table .tm-table tbody tr:last-child td {
    border-bottom: none;
}
.tm-pos-cell {
    text-align: left !important;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--surface) !important;
    border-right: 1px solid var(--border);
    min-width: 150px;
}
.tm-pos-cell i {
    color: var(--text-muted);
    font-size: 0.65rem;
    margin-right: 4px;
}
.tm-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 1px;
    min-height: 32px;
    padding: 3px 5px;
    border-radius: 6px;
    border: 1px dashed transparent;
    transition: background 0.12s, border-color 0.12s;
}
.tm-rate {
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.tm-cell.is-custom {
    background: rgba(37, 99, 235, 0.09);
}
.tm-cell.is-custom .tm-rate {
    color: #1d4ed8;
}
.tm-cell.is-period {
    background: rgba(8, 145, 178, 0.12);
}
.tm-cell.is-period .tm-rate {
    color: #0e7490;
}
.tm-cell.tm-col-active {
    box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb, 153, 0, 0), 0.22);
}
.tm-cell.pos-rate-editable {
    cursor: pointer;
}
.tm-cell.pos-rate-editable:hover {
    border-color: var(--accent);
    background: rgba(var(--accent-rgb, 153, 0, 0), 0.08);
}
.tm-mark {
    font-size: 0.56rem;
    line-height: 1.1;
    color: var(--text-muted);
    white-space: nowrap;
}
.tm-period {
    font-size: 0.56rem;
    line-height: 1.15;
    color: #0e7490;
    font-weight: 600;
    white-space: nowrap;
}
.tm-period.next {
    color: #64748b;
    font-weight: 500;
}
html[data-theme="dark"] .tm-cell.is-custom { background: rgba(59, 130, 246, 0.18); }
html[data-theme="dark"] .tm-cell.is-period { background: rgba(8, 145, 178, 0.22); }

/* Перекрываем стили внешней таблицы внутри матрицы */
.tariff-table .tm-table tbody tr:nth-child(even) td { background: var(--surface); }
.tariff-table .tm-table tbody tr td:first-child { padding-left: 8px; border-left: none; }
.tariff-table .tm-table thead tr th:first-child { border-radius: 0; padding-left: 8px; text-align: left; }
.tariff-table .tm-table thead tr th:last-child { border-radius: 0; padding-right: 6px; }
.tariff-table .tm-table tbody tr:hover td { background: transparent !important; }

.tm-cell.is-base-col { background: rgba(148, 163, 184, 0.08); }
html[data-theme="dark"] .tm-cell.is-base-col { background: rgba(148, 163, 184, 0.14); }

.tariff-table .tm-table thead tr th { cursor: default; }
.tariff-table .tm-table thead tr th:hover { background: var(--surface-2); }
.tariff-table .tm-table thead tr th.tm-col-active:hover { background: var(--primary); }

/* ==================== КАРТОЧКИ ТАРИФОВ ==================== */
.tariff-cards-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 0 2px 8px;
}
.tariff-select-all-wrap {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}
.tariff-sort-controls {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}
.tariff-sort-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--text-muted);
}
.tariff-sort-select {
    padding: 6px 9px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 0.78rem;
    outline: none;
}
.tariff-sort-select:focus { border-color: var(--accent); }
.tariff-sort-dir {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
}
.tariff-sort-dir:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.tariff-sort-dir:disabled { opacity: 0.4; cursor: default; }

.tariff-table-view .tariff-table-wrap {
    padding: 14px;
    background: transparent;
    border: none;
    box-shadow: none;
    overflow-x: hidden;
    overflow-y: auto;
}
.tariff-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(520px, 1fr));
    gap: 14px;
    align-items: start;
}
@media (max-width: 1100px) {
    .tariff-cards { grid-template-columns: 1fr; }
}

.tc-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    gap: 11px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.tc-card:hover {
    border-color: var(--accent);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}
.tc-card.tc-edit-mode { cursor: default; }
.tc-card-plus { border-left: 4px solid #f59e0b; }
.tc-card-minus { border-left: 4px solid #ef4444; }

.tc-head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.tc-check {
    display: inline-flex;
    align-items: center;
    padding-top: 8px;
    flex-shrink: 0;
    cursor: pointer;
}
.tc-check input { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; }
.tc-avatar {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 11px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: var(--text-muted);
    font-size: 1.1rem;
}
.tc-avatar img { width: 100%; height: 100%; object-fit: contain; }
.tc-title { flex: 1; min-width: 0; }
.tc-name {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.25;
    word-break: break-word;
}
.tc-sub {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 3px;
    font-size: 0.74rem;
    color: var(--text-muted);
}
.tc-address { display: inline-flex; align-items: center; gap: 4px; }
.tc-badges {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 5px;
    flex-shrink: 0;
}
.tc-diff {
    display: inline-flex;
    align-items: center;
    padding: 4px 9px;
    border-radius: 7px;
    font-size: 0.72rem;
    font-weight: 800;
    white-space: nowrap;
}
.tc-diff.match { background: rgba(22, 163, 74, 0.12); color: #15803d; }
.tc-diff.plus { background: rgba(245, 158, 11, 0.14); color: #b45309; }
.tc-diff.minus { background: rgba(220, 38, 38, 0.12); color: #b91c1c; }
.tc-diff.muted { background: var(--surface-2); color: var(--text-muted); }

.tc-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 14px;
    font-size: 0.76rem;
    color: var(--text-secondary);
}
.tc-meta > span { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.tc-meta i { color: var(--text-muted); font-size: 0.72rem; }
.tc-managers { flex-wrap: wrap; }
.tc-manager {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 5px;
    background: var(--surface-2);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.tc-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 7px;
}
.tc-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 7px 9px;
    border-radius: 9px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    min-width: 0;
}
.tc-stat-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.65rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.tc-stat b { font-size: 0.86rem; color: var(--text); }
.tc-stat small { font-size: 0.62rem; color: var(--text-muted); font-weight: 500; }

.tc-tariffs { display: flex; flex-direction: column; gap: 10px; }
.tc-pos {
    padding-top: 10px;
    border-top: 1px dashed var(--border);
}
.tc-pos:first-child { border-top: none; padding-top: 0; }
.tc-pos-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.tc-pos-name {
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--text);
}
.tc-pos-name i { color: var(--text-muted); font-size: 0.7rem; margin-right: 4px; }
.tc-pos-hours { font-size: 0.68rem; color: var(--text-muted); }
.tc-rate-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(115px, 1fr));
    gap: 6px;
}
.tc-rate {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    padding: 7px 9px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
}
.tc-rate.custom { background: rgba(37, 99, 235, 0.08); border-color: rgba(37, 99, 235, 0.25); }
.tc-rate.period { background: rgba(8, 145, 178, 0.10); border-color: rgba(8, 145, 178, 0.35); }
.tc-rate.active { box-shadow: inset 0 0 0 2px var(--accent); }
.tc-rate.pos-rate-editable { cursor: pointer; }
.tc-rate.pos-rate-editable:hover { border-color: var(--accent); background: rgba(var(--accent-rgb, 153, 0, 0), 0.07); }
.tc-rate-label {
    font-size: 0.62rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tc-rate-hour {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.tc-rate-hour small, .tc-rate-shift small { font-size: 0.62rem; font-weight: 500; color: var(--text-muted); }
.tc-rate-shift {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.tc-rate.custom .tc-rate-hour { color: #1d4ed8; }
.tc-rate.period .tc-rate-hour { color: #0e7490; }
.tc-rate-mark, .tc-rate-period {
    font-size: 0.57rem;
    line-height: 1.2;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tc-rate-period { color: #0e7490; font-weight: 700; }
.tc-rate-period.next { color: #64748b; font-weight: 500; }
.tc-rate-mark { font-weight: 500; }

.tc-footer {
    padding-top: 9px;
    border-top: 1px solid var(--border);
}
.tc-contacts {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 12px;
    align-items: center;
    font-size: 0.72rem;
    color: var(--text-secondary);
}
.tc-contact { display: inline-flex; align-items: center; gap: 4px; min-width: 0; }
.tc-contact b { font-weight: 600; color: var(--text); }
.tc-contact span { display: inline-flex; align-items: center; gap: 3px; color: var(--text-muted); }
.tc-no-contacts { color: var(--text-muted); }
.tc-empty {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px;
    color: var(--text-muted);
    font-size: 0.8rem;
    background: var(--surface-2);
    border: 1px dashed var(--border);
    border-radius: 9px;
}

@media (max-width: 700px) {
    .tariff-table-view .tariff-table-wrap { padding: 8px; }
    .tc-card { padding: 11px; border-radius: 13px; }
    .tc-head { flex-wrap: wrap; }
    .tc-badges { width: 100%; justify-content: flex-start; }
    .tc-rate-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tc-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tariff-cards-toolbar { align-items: flex-start; }
    .tariff-sort-controls { width: 100%; justify-content: space-between; }
    .tariff-sort-select { flex: 1; }
}

/* ==================== НОРМАЛЬНАЯ ТАБЛИЦА ТАРИФОВ ==================== */
.tariff-table-view .tariff-table-wrap {
    padding: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
    overflow: auto;
}
.tt-table {
    width: 100%;
    min-width: 1150px;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.78rem;
}
.tt-table thead {
    position: static;
}
.tt-table thead th {
    background: linear-gradient(180deg, var(--primary), var(--primary-dark));
    color: #fff;
    padding: 12px 10px;
    text-align: left;
    vertical-align: middle;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.12);
    white-space: nowrap;
}
.tt-table thead th:first-child { border-radius: 15px 0 0 0; padding-left: 14px; }
.tt-table thead th:last-child { border-radius: 0 15px 0 0; padding-right: 14px; }
.tt-col-name { min-width: 170px; }
.tt-col-tariffs { min-width: 400px; }
.tt-col-address { min-width: 130px; }
.tt-col-city { min-width: 90px; }
.tt-col-tt { min-width: 80px; }
.tt-col-manager { min-width: 100px; }
.tt-col-contacts { min-width: 110px; }
.tt-col-claims { min-width: 70px; }

.tt-table tbody td {
    padding: 10px 12px;
    vertical-align: top;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
    background: var(--surface);
    color: var(--text);
}
.tt-table tbody tr:nth-child(even) td { background: var(--surface-2); }
.tt-table tbody tr:hover td { background: rgba(var(--accent-rgb), 0.07) !important; }
.tt-table tbody tr:last-child td { border-bottom: none; }

.tt-name-cell { padding-left: 14px !important; }
.tt-name-row { display: flex; align-items: flex-start; gap: 8px; }
.tt-check { display: inline-flex; padding-top: 5px; flex-shrink: 0; cursor: pointer; }
.tt-check input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.tt-avatar {
    width: 36px; height: 36px; flex-shrink: 0; border-radius: 9px;
    border: 1px solid var(--border); background: var(--surface);
    display: flex; align-items: center; justify-content: center; overflow: hidden;
    color: var(--text-muted); font-size: 0.95rem;
}
.tt-avatar img { width: 100%; height: 100%; object-fit: contain; }
.tt-name-wrap { min-width: 0; }
.tt-name { font-size: 0.86rem; font-weight: 800; line-height: 1.25; word-break: break-word; }
.tt-name-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.tt-name-badges .tariff-tax-badge,
.tt-name-badges .tariff-commission-badge { font-size: 0.58rem; padding: 1px 5px; }

.tt-tariffs-cell { min-width: 460px; }
.tf-pos { padding: 0 0 9px; margin-bottom: 9px; border-bottom: 1px dashed var(--border); }
.tf-pos:last-child { padding-bottom: 0; margin-bottom: 0; border-bottom: none; }
.tf-pos-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 5px; }
.tf-pos-name { font-size: 0.8rem; font-weight: 700; }
.tf-pos-name i { font-size: 0.66rem; color: var(--text-muted); margin-right: 3px; }
.tf-pos-hours { font-size: 0.66rem; color: var(--text-muted); }
.tf-rates { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
.tf-rate {
    display: flex; flex-direction: column; gap: 0;
    padding: 5px 7px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); min-width: 0;
    transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
}
.tf-rate.custom { background: rgba(37, 99, 235, 0.07); border-color: rgba(37, 99, 235, 0.22); }
.tf-rate.period { background: rgba(8, 145, 178, 0.09); border-color: rgba(8, 145, 178, 0.3); }
.tf-rate.active { box-shadow: inset 0 0 0 2px var(--accent); }
.tf-rate.pos-rate-editable { cursor: pointer; }
.tf-rate.pos-rate-editable:hover { border-color: var(--accent); background: rgba(var(--accent-rgb), 0.07); }
.tf-rate-label {
    font-size: 0.58rem; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.2px; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
.tf-rate-main { font-size: 0.8rem; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tf-rate-main small { font-size: 0.56rem; font-weight: 500; color: var(--text-muted); }
.tf-rate-shift { font-size: 0.63rem; color: var(--text-secondary); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tf-rate-shift small { font-size: 0.55rem; color: var(--text-muted); font-weight: 500; }
.tf-rate.custom .tf-rate-main { color: #1d4ed8; }
.tf-rate.period .tf-rate-main { color: #0e7490; }
.tf-rate-extra { font-size: 0.55rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tf-rate-extra.period { color: #0e7490; font-weight: 700; }
.tf-rate-extra.next { color: #64748b; }

.tt-address-cell span { display: inline-flex; align-items: flex-start; gap: 5px; font-size: 0.74rem; line-height: 1.35; }
.tt-address-cell i { color: #ef4444; font-size: 0.64rem; margin-top: 3px; flex-shrink: 0; }
.tt-tt-chip {
    display: inline-flex; align-items: center; padding: 2px 7px;
    border: 1px solid var(--border); border-radius: 6px;
    font-size: 0.68rem; font-weight: 600; white-space: nowrap;
}
.tt-managers { display: flex; flex-wrap: wrap; gap: 3px; }
.tt-manager {
    display: inline-flex; padding: 1px 6px; border-radius: 5px;
    background: var(--surface); border: 1px solid var(--border);
    color: var(--text-secondary); font-size: 0.68rem; white-space: nowrap;
}
.tt-contacts-cell .tt-contact { display: flex; flex-direction: column; gap: 1px; margin-bottom: 3px; font-size: 0.68rem; }
.tt-contacts-cell .tt-contact b { font-weight: 600; color: var(--text); }
.tt-contacts-cell .tt-contact span { display: inline-flex; align-items: center; gap: 3px; color: var(--text-muted); }
.tt-contact-more { font-size: 0.64rem; color: var(--text-muted); }
.tt-claims { display: flex; flex-wrap: wrap; gap: 4px; }
.tt-claim { display: inline-flex; align-items: center; gap: 3px; padding: 2px 6px; border-radius: 5px; font-size: 0.65rem; white-space: nowrap; }
.tt-claim b { font-weight: 800; }
.tt-claim.in { background: rgba(37, 99, 235, 0.1); color: #1d4ed8; }
.tt-claim.out { background: rgba(220, 38, 38, 0.09); color: #b91c1c; }
.tt-empty { display: flex; align-items: center; gap: 6px; padding: 8px; font-size: 0.76rem; color: var(--text-muted); }

@media (max-width: 1250px) {
    .tariff-table-view .tariff-table-wrap {
        padding: 0;
        background: transparent;
        border: none;
        border-radius: 0;
        box-shadow: none;
        overflow: visible;
    }
    .tt-table { display: block; min-width: 0; }
    .tt-table thead { display: none; }
    .tt-table tbody { display: flex; flex-direction: column; gap: 12px; padding: 10px; }
    .tt-table tbody tr {
        display: block;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 14px;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
        overflow: hidden;
    }
    .tt-table tbody td {
        display: block;
        width: auto;
        padding: 8px 12px;
        border-bottom: 1px solid var(--surface-2);
        background: var(--surface) !important;
    }
    .tt-table tbody tr:hover td { background: var(--surface) !important; }
    .tt-table tbody td:last-child { border-bottom: none; }
    .tt-table tbody td[data-label]::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 4px;
        font-size: 0.62rem;
        font-weight: 700;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.2px;
    }
    .tt-name-cell { padding: 11px 12px !important; }
    .tt-name-cell::before { display: none !important; }
    .tt-tariffs-cell { min-width: 0; }
    .tf-rates { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ==================== ТАБЛИЦА: МАГАЗИН + ДОЛЖНОСТЬ ==================== */
.tt-table {
    min-width: 1120px;
}
.tt-table thead th {
    padding: 10px 6px;
    font-size: 0.74rem;
    text-align: center;
    vertical-align: middle;
    white-space: normal;
    line-height: 1.22;
}
.tt-table thead th.tt-c-shop,
.tt-table thead th.tt-c-pos,
.tt-table thead th.tt-c-address { text-align: left; }
.tt-table tbody td {
    padding: 6px 8px;
    font-size: 0.72rem;
    vertical-align: middle;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}
.tt-table tbody tr.tt-shop-end td { border-bottom: 2px solid var(--border); }

.tt-c-shop { min-width: 130px; width: 130px; }
.tt-c-pos { min-width: 105px; width: 105px; }
.tt-c-rate { min-width: 80px; width: 80px; }
.tt-c-address { min-width: 120px; width: 120px; }
.tt-c-city { min-width: 75px; width: 75px; }
.tt-c-tt { min-width: 65px; width: 65px; }
.tt-c-manager { min-width: 85px; width: 85px; }
.tt-c-contacts { min-width: 100px; width: 100px; }
.tt-c-claims { min-width: 55px; width: 55px; }

/* Первые две колонки — закреплены и по вертикали, и по горизонтали */
.tt-table thead th.tt-c-shop { position: sticky; top: 0; left: 0; z-index: 8; background: var(--primary) !important; border-radius: 15px 0 0 0; }
.tt-table thead th.tt-c-pos { position: sticky; top: 0; left: 130px; z-index: 8; background: var(--primary) !important; }
.tt-shop-cell { position: sticky; left: 0; z-index: 3; background: var(--surface) !important; border-right: 1px solid var(--border); }
.tt-pos-cell { position: sticky; left: 130px; z-index: 3; background: var(--surface) !important; border-right: 1px solid var(--border); }
.tt-table tbody tr:nth-child(even) .tt-shop-cell,
.tt-table tbody tr:nth-child(even) .tt-pos-cell { background: var(--surface) !important; }

.tt-shop-cell { min-width: 130px; max-width: 130px; }
.tt-shop-line { display: flex; align-items: flex-start; gap: 7px; }
.tt-avatar {
    width: 30px; height: 30px; flex-shrink: 0; border-radius: 8px;
    border: 1px solid var(--border); background: var(--surface-2);
    display: flex; align-items: center; justify-content: center; overflow: hidden;
    color: var(--text-muted); font-size: 0.8rem;
}
.tt-avatar img { width: 100%; height: 100%; object-fit: contain; }
.tt-shop-name-wrap { min-width: 0; }
.tt-shop-name { font-size: 0.78rem; font-weight: 800; line-height: 1.2; word-break: normal; overflow-wrap: break-word; }
.tt-shop-badges { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.tt-shop-badges .tariff-tax-badge,
.tt-shop-badges .tariff-commission-badge { font-size: 0.52rem; padding: 1px 4px; }
.tt-check { display: inline-flex; padding-top: 4px; flex-shrink: 0; cursor: pointer; }
.tt-check input { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; }

.tt-pos-cell { min-width: 105px; max-width: 105px; }
.tt-pos-name { font-size: 0.73rem; font-weight: 700; line-height: 1.2; color: var(--text); }
.tt-pos-hours { margin-top: 2px; font-size: 0.6rem; color: var(--text-muted); line-height: 1.2; }

.tt-rate-cell { text-align: center; white-space: nowrap; }
.tt-rate-cell .tfc-hour { font-size: 0.78rem; font-weight: 800; line-height: 1.15; color: var(--text); font-variant-numeric: tabular-nums; }
.tt-rate-cell .tfc-hour span { font-size: 0.55rem; font-weight: 500; color: var(--text-muted); }
.tt-rate-cell .tfc-shift { font-size: 0.6rem; line-height: 1.15; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.tt-rate-cell .tfc-shift span { font-size: 0.53rem; color: var(--text-muted); }
.tt-rate-cell .tfc-extra { font-size: 0.53rem; line-height: 1.1; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tt-rate-cell .tfc-extra.custom { color: #1d4ed8; font-weight: 700; }
.tt-rate-cell .tfc-extra.period { color: #0e7490; font-weight: 700; }
.tt-rate-cell .tfc-extra.next { color: #64748b; }
.tt-rate-cell.custom { background: rgba(37, 99, 235, 0.07) !important; }
.tt-rate-cell.custom .tfc-hour { color: #1d4ed8; }
.tt-rate-cell.period { background: rgba(8, 145, 178, 0.09) !important; }
.tt-rate-cell.period .tfc-hour { color: #0e7490; }
.tt-rate-cell.base-fallback .tfc-hour { color: var(--text-secondary); }
.tt-rate-cell.active { box-shadow: inset 0 0 0 2px var(--accent); }
.tt-rate-cell.pos-rate-editable { cursor: pointer; }
.tt-rate-cell.pos-rate-editable:hover { background: rgba(var(--accent-rgb), 0.08) !important; }

.tt-address-cell span { display: inline-flex; align-items: flex-start; gap: 4px; font-size: 0.68rem; line-height: 1.3; }
.tt-address-cell i { color: #ef4444; font-size: 0.58rem; margin-top: 2px; flex-shrink: 0; }
.tt-tt-cell, .tt-managers-cell, .tt-contacts-cell, .tt-claims-cell { vertical-align: middle; }
.tt-c-tt-chip { display: inline-flex; padding: 2px 6px; border: 1px solid var(--border); border-radius: 5px; font-size: 0.62rem; font-weight: 600; white-space: nowrap; }
.tt-managers { display: flex; flex-wrap: wrap; gap: 2px; }
.tt-manager { display: inline-flex; padding: 1px 5px; border-radius: 4px; background: var(--surface); border: 1px solid var(--border); color: var(--text-secondary); font-size: 0.61rem; white-space: nowrap; }
.tt-contacts-cell .tt-contact { display: flex; flex-direction: column; gap: 0; margin-bottom: 2px; font-size: 0.61rem; line-height: 1.25; }
.tt-contacts-cell .tt-contact b { font-weight: 600; color: var(--text); }
.tt-contacts-cell .tt-contact span { color: var(--text-muted); }
.tt-contact-more { font-size: 0.58rem; color: var(--text-muted); }
.tt-claims { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.tt-claim { display: inline-flex; align-items: center; gap: 2px; padding: 1px 4px; border-radius: 4px; font-size: 0.58rem; white-space: nowrap; }
.tt-claim b { font-weight: 800; }
.tt-claim.in { background: rgba(37, 99, 235, 0.1); color: #1d4ed8; }
.tt-claim.out { background: rgba(220, 38, 38, 0.09); color: #b91c1c; }

/* На малых экранах таблица остаётся таблицей, но прокручивается по горизонтали */
@media (max-width: 1250px) {
    .tariff-table-view .tariff-table-wrap {
        overflow-x: auto;
        overflow-y: visible;
        padding: 0;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 12px;
        box-shadow: none;
    }
    .tt-table { display: table; min-width: 1120px; }
    .tt-table thead { display: table-header-group; }
    .tt-table tbody { display: table-row-group; padding: 0; gap: 0; }
    .tt-table tbody tr { display: table-row; border: 0; border-radius: 0; box-shadow: none; overflow: visible; background: transparent; }
    .tt-table tbody td { display: table-cell; width: auto; padding: 6px 8px; border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent); background: var(--surface); }
    .tt-table tbody tr:hover td { background: rgba(var(--accent-rgb), 0.07) !important; }
    .tt-table tbody td[data-label]::before { display: none; }
}

.tt-table { table-layout: fixed; width: 100%; }
.tt-address-cell, .tt-table td, .tt-table th { overflow-wrap: anywhere; }
.tt-rate-cell { overflow: hidden; }
.tt-address-cell span, .tt-contacts-cell, .tt-managers-cell { word-break: break-word; }

/* Полировка таблицы */
.tt-rate-cell .tfc-hour span { margin-left: 2px; }
.tt-rate-cell .tfc-shift span { margin-left: 2px; }
.tt-rate-cell.period { background: rgba(8, 145, 178, 0.08) !important; }
.tt-rate-cell.period .tfc-hour { color: #0e7490; }
.tt-rate-cell.active { background: rgba(var(--accent-rgb), 0.05) !important; }
.tt-address-cell span {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.tt-pos-name { overflow-wrap: anywhere; }

/* Шапка таблицы — как в модулях «Смены» и «Сотрудники» */
.tt-table thead th {
    position: sticky;
    top: 0;
    z-index: 6;
    background: var(--primary) !important;
    background-image: none !important;
    color: #fff;
    font-weight: 600;
    letter-spacing: 0.3px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.14);
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}
.tt-table thead th:hover { background: var(--primary-dark) !important; }
.tt-table thead th.sorted-asc,
.tt-table thead th.sorted-desc { background: var(--primary-dark) !important; }
.tt-table thead th.sorted-asc::after,
.tt-table thead th.sorted-desc::after {
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 0.6rem;
    margin-left: 4px;
    opacity: 0.9;
}
.tt-table thead th.sorted-asc::after { content: "\f0dd"; }
.tt-table thead th.sorted-desc::after { content: "\f0de"; }
.tt-table thead th.tt-c-shop,
.tt-table thead th.tt-c-pos { background: var(--primary) !important; color: #fff; }
.tt-manager { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt-c-tt-chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.tt-contacts-cell .tt-contact { overflow: hidden; }
.tt-contacts-cell .tt-contact b,
.tt-contacts-cell .tt-contact span { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt-c-claims { width: 60px; }

/* Цветовые акценты видов оплаты в шапке */
.tt-table thead th.tt-c-rate::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 4px;
    border-radius: 50%;
    background: var(--tt-color, #94a3b8);
    vertical-align: middle;
}
.tt-table thead th.tt-c-rate.tt-active-type {
    box-shadow: inset 0 -3px 0 var(--tt-color, #fff);
    font-weight: 800;
}
.tt-shop-cell { border-left: 0; }

/* Цветовые акценты тарифов по виду оплаты */
.tt-rate-cell.custom {
    background: color-mix(in srgb, var(--rate-color, #3b82f6) 8%, var(--surface)) !important;
}
.tt-rate-cell.custom .tfc-hour { color: var(--rate-color, #1d4ed8); }
.tt-rate-cell.custom.active {
    background: color-mix(in srgb, var(--rate-color, #3b82f6) 14%, var(--surface)) !important;
}
.tt-manager {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: top;
}
.tt-c-manager { min-width: 100px; width: 100px; }
.tt-c-address { min-width: 110px; width: 110px; }
.tt-c-tt { min-width: 55px; width: 55px; }

.tt-table thead th.tt-rate-last { border-right: 2px solid var(--border); }
.tt-rate-cell.tt-rate-last { border-right: 2px solid var(--border); }

.tt-table thead th.tt-c-rate { font-size: 0.58rem; white-space: nowrap; }
.tt-rate-cell.active {
    background: color-mix(in srgb, var(--rate-color, var(--accent)) 8%, var(--surface)) !important;
}
.tt-rate-cell.custom.active {
    background: color-mix(in srgb, var(--rate-color, #3b82f6) 13%, var(--surface)) !important;
}

.tt-c-rate { min-width: 76px; width: 76px; }
.tt-c-address { min-width: 140px; width: 140px; }
.tt-c-city { min-width: 72px; width: 72px; }
.tt-c-manager { min-width: 96px; width: 96px; }

.tt-shop-cell { box-shadow: inset -1px 0 0 var(--border); }
.tt-pos-cell { box-shadow: 2px 0 6px rgba(0, 0, 0, 0.06); }

/* Строка «на руки» в ячейке ставки */
.tt-rate-cell .tfc-net {
    font-size: 0.53rem;
    line-height: 1.15;
    font-weight: 700;
    color: #15803d;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Закреплённые колонки: шапка выше тела */
.tt-table thead th.tt-c-shop,
.tt-table thead th.tt-c-pos { z-index: 8; }
.tt-shop-cell { z-index: 3; }
.tt-pos-cell { z-index: 3; }

/* Итоговые ширины колонок и читаемая шапка */
.tt-c-rate { min-width: 86px; width: 86px; }
.tt-c-address { min-width: 130px; width: 130px; }
.tt-c-city { min-width: 76px; width: 76px; }
.tt-c-tt { min-width: 50px; width: 50px; }
.tt-c-manager { min-width: 88px; width: 88px; }
.tt-c-contacts { min-width: 96px; width: 96px; }
.tt-c-claims { min-width: 56px; width: 56px; }
.tt-table thead th.tt-c-rate { font-size: 0.74rem; white-space: normal; }
.tt-table thead th.tt-c-rate::before {
    display: block;
    margin: 0 auto 3px;
}

/* Город не рвётся посреди слова */
.tt-table td.tt-c-city,
.tt-table thead th.tt-c-city { overflow-wrap: normal; word-break: normal; }
.tt-c-claims { min-width: 64px; width: 64px; }

/* Подсветка каждого вида оплаты своим цветом */
.tt-rate-cell[data-payment-type]:not([data-payment-type=""]) {
    background: color-mix(in srgb, var(--rate-color, #3b82f6) 7%, var(--surface)) !important;
}
.tt-rate-cell[data-payment-type]:not([data-payment-type=""]) .tfc-hour {
    color: var(--rate-color, #1d4ed8);
}
.tt-rate-cell[data-payment-type]:not([data-payment-type=""]) .tfc-shift {
    color: color-mix(in srgb, var(--rate-color, #1d4ed8) 55%, var(--text-secondary));
}
.tt-rate-cell.custom[data-payment-type] {
    background: color-mix(in srgb, var(--rate-color, #3b82f6) 13%, var(--surface)) !important;
}

/* Без разделителя слева от адреса */
.tt-table thead th.tt-rate-last { border-right: 0; }
.tt-rate-cell.tt-rate-last { border-right: 0; }

/* Колонка «Заявки и часы» */
.tt-c-claims { min-width: 92px; width: 92px; }
.tt-claims { flex-direction: row; flex-wrap: wrap; gap: 2px 4px; }
.tt-claims-cell .tt-hours {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin-top: 3px;
}
.tt-hour {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.56rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.tt-hour i { font-size: 0.5rem; opacity: 0.75; }
.tt-hour.req { color: #1d4ed8; }
.tt-hour.shift { color: #0e7490; }

/* Бейдж вида ТТ в столбце магазина */
.tt-shop-badges .tt-c-tt-chip {
    font-size: 0.52rem;
    padding: 0 4px;
    line-height: 1.5;
}

/* Баланс ширин под 6 видов оплаты */
.tt-c-rate { min-width: 92px; width: 92px; }
.tt-c-address { min-width: 122px; width: 122px; }
.tt-c-city { min-width: 74px; width: 74px; }
.tt-c-manager { min-width: 84px; width: 84px; }
.tt-c-contacts { min-width: 90px; width: 90px; }

/* Чуть заметнее цвет вида оплаты */
.tt-rate-cell[data-payment-type]:not([data-payment-type=""]) {
    background: color-mix(in srgb, var(--rate-color, #3b82f6) 10%, var(--surface)) !important;
}
.tt-rate-cell.custom[data-payment-type] {
    background: color-mix(in srgb, var(--rate-color, #3b82f6) 18%, var(--surface)) !important;
}
.tt-table thead th.tt-c-rate { font-size: 0.72rem; }

/* Часы: подпись + значение */
.tt-hour {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px;
    font-size: 0.55rem;
    line-height: 1.25;
    white-space: nowrap;
}
.tt-hour-lbl { color: var(--text-muted); font-weight: 500; }
.tt-hour b { font-weight: 700; font-variant-numeric: tabular-nums; }
.tt-hour.req b { color: #1d4ed8; }
.tt-hour.shift b { color: #0e7490; }

/* Подписи тарифных колонок шире */
.tt-table thead th.tt-c-rate { padding-left: 4px; padding-right: 4px; }

/* Компактные бейджи магазина */
.tt-shop-badges .tariff-tax-badge,
.tt-shop-badges .tariff-commission-badge { font-size: 0.48rem; padding: 0 3px; }
.tt-hour { justify-content: flex-start; gap: 5px; }

/* Филиал под названием магазина */
.tt-shop-branch {
    margin-top: 1px;
    font-size: 0.58rem;
    line-height: 1.2;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Однотонные строки: убираем «зебру», подсветка только у видов оплаты */
.tt-table tbody tr td,
.tt-table tbody tr:nth-child(even) td {
    background: var(--surface);
}
.tt-table tbody tr:nth-child(even) .tt-shop-cell,
.tt-table tbody tr:nth-child(even) .tt-pos-cell {
    background: var(--surface) !important;
}

/* Ровная подсветка видов оплаты: один цвет и одна интенсивность на колонку */
.tt-rate-cell[data-payment-type]:not([data-payment-type=""]) {
    background: color-mix(in srgb, var(--rate-color, #3b82f6) 11%, var(--surface)) !important;
}
.tt-rate-cell.custom[data-payment-type] {
    background: color-mix(in srgb, var(--rate-color, #3b82f6) 11%, var(--surface)) !important;
}
.tt-rate-cell[data-payment-type]:not([data-payment-type=""]) .tfc-hour,
.tt-rate-cell.base-fallback .tfc-hour {
    color: var(--rate-color, var(--text));
}

/* Чуть шире столбец магазина под филиал */
.tt-c-shop { min-width: 150px; width: 150px; }
.tt-shop-cell { min-width: 150px; max-width: 150px; }
.tt-table thead th.tt-c-pos { left: 150px; }
.tt-pos-cell { left: 150px; }
.tt-shop-branch { font-size: 0.6rem; }
.tt-c-rate { min-width: 90px; width: 90px; }
.tt-c-city { min-width: 72px; width: 72px; }
.tt-c-manager { min-width: 82px; width: 82px; }
.tt-c-contacts { min-width: 88px; width: 88px; }
.tt-c-claims { min-width: 90px; width: 90px; }
.tt-shop-branch {
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.tt-shop-branch { font-size: 0.55rem; }

/* ==================== Прайс заказчика ==================== */
.tt-pos-customer {
    margin-top: 2px;
    font-size: 0.55rem;
    line-height: 1.25;
    font-weight: 700;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.tt-pos-customer span { font-weight: 500; opacity: 0.75; }
.tt-pos-customer.pos { color: #15803d; }
.tt-pos-customer.neg { color: #b91c1c; }

.ct-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}
.ct-modal {
    width: 100%;
    max-width: 760px;
    max-height: calc(100vh - 36px);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
    overflow: hidden;
}
.ct-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--primary) 6%, var(--surface));
}
.ct-title { font-size: 1rem; font-weight: 800; color: var(--text); display: flex; align-items: center; gap: 8px; }
.ct-title i { color: var(--primary); }
.ct-sub { margin-top: 3px; font-size: 0.72rem; color: var(--text-muted); }
.ct-close {
    width: 32px; height: 32px; border-radius: 9px;
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text-secondary); cursor: pointer;
}
.ct-close:hover { background: var(--surface-2); color: var(--text); }
.ct-body { padding: 14px 18px 18px; overflow-y: auto; }
.ct-form {
    display: grid;
    grid-template-columns: 1.4fr 0.9fr 0.9fr;
    gap: 10px;
    align-items: end;
}
.ct-field { display: flex; flex-direction: column; gap: 4px; font-size: 0.68rem; color: var(--text-muted); font-weight: 600; }
.ct-field input {
    height: 38px; padding: 0 10px;
    border: 1.5px solid var(--border); border-radius: 9px;
    background: var(--input-bg, var(--surface-2)); color: var(--text);
    font-size: 0.82rem; font-family: inherit; outline: none;
}
.ct-field input:focus { border-color: var(--primary); }
.ct-upload {
    height: 38px; padding: 0 16px; border-radius: 9px; border: 1px solid var(--primary);
    background: var(--primary); color: #fff; font-weight: 700; font-size: 0.8rem;
    font-family: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
    white-space: nowrap;
}
.ct-upload:hover { filter: brightness(0.94); }
.ct-upload:disabled { opacity: 0.6; cursor: default; }
.ct-status { margin-top: 10px; font-size: 0.76rem; color: var(--text-secondary); min-height: 18px; }
.ct-status.error { color: #b91c1c; }
.ct-status.ok { color: #15803d; font-weight: 600; }
.ct-active {
    margin-top: 10px; padding: 8px 12px; border-radius: 9px;
    background: color-mix(in srgb, var(--primary) 8%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--primary) 25%, var(--border));
    font-size: 0.75rem; color: var(--text-secondary);
}
.ct-active b { color: var(--text); }
.ct-results { margin-top: 12px; display: none; }
.ct-results.show { display: block; }
.ct-stats { display: flex; flex-wrap: wrap; gap: 8px; }
.ct-stat {
    flex: 1 1 110px; padding: 8px 10px; border-radius: 9px;
    border: 1px solid var(--border); background: var(--surface-2);
}
.ct-stat b { display: block; font-size: 1.05rem; color: var(--text); font-variant-numeric: tabular-nums; }
.ct-stat span { font-size: 0.64rem; color: var(--text-muted); }
.ct-stat.green b { color: #15803d; }
.ct-stat.amber b { color: #b45309; }
.ct-stat.red b { color: #b91c1c; }
.ct-section { margin-top: 14px; }
.ct-section-title { font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); margin-bottom: 6px; }
.ct-list { max-height: 180px; overflow-y: auto; border: 1px solid var(--border); border-radius: 9px; }
.ct-list-row {
    display: flex; align-items: center; gap: 8px; justify-content: space-between;
    padding: 6px 10px; font-size: 0.72rem; border-bottom: 1px solid var(--border);
}
.ct-list-row:last-child { border-bottom: 0; }
.ct-list-row:nth-child(even) { background: var(--surface-2); }
.ct-list-main { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.ct-list-sub { color: var(--text-muted); font-size: 0.66rem; white-space: nowrap; }
.ct-empty { padding: 10px; font-size: 0.72rem; color: var(--text-muted); }
@media (max-width: 720px) {
    .ct-form { grid-template-columns: 1fr; }
    .ct-modal { max-height: calc(100vh - 20px); }
}

.ct-upload { grid-column: 1 / -1; justify-self: end; }
.ct-field input[type="file"] { padding: 6px 8px; height: auto; font-size: 0.76rem; }
.ct-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ct-stat { flex: none; }
@media (max-width: 720px) {
    .ct-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ct-upload { justify-self: stretch; }
}

/* Маржа по магазину (цена заказчика − наша ставка) */
.tt-shop-margin {
    display: inline-flex;
    align-items: center;
    padding: 0 4px;
    border-radius: 4px;
    font-size: 0.52rem;
    font-weight: 800;
    line-height: 1.5;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.tt-shop-margin.pos { background: rgba(21, 128, 61, 0.10); color: #15803d; }
.tt-shop-margin.neg { background: rgba(185, 28, 28, 0.10); color: #b91c1c; }

/* На узких широких экранах шапка не переносится из-за кнопок */
@media (max-width: 1420px) {
    .header { padding-left: 24px; padding-right: 24px; gap: 10px; }
    .header h1 { font-size: 20px; white-space: nowrap; flex: 0 0 auto; }
    .header-right { gap: 8px; }
    .header .add-button { padding: 8px 12px; font-size: 0.78rem; }
    .header .stats-badge { padding: 7px 12px; font-size: 0.82rem; }
    .header .org-name { display: none; }
}

/* ==================== Экономика ==================== */
.tariff-economics-view {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0 28px 20px;
    gap: 12px;
}
.eco-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
}
.eco-field { display: flex; flex-direction: column; gap: 4px; font-size: 0.68rem; font-weight: 600; color: var(--text-muted); }
.eco-field input {
    height: 36px; padding: 0 10px; border: 1.5px solid var(--border); border-radius: 9px;
    background: var(--input-bg, var(--surface-2)); color: var(--text); font-family: inherit; font-size: 0.82rem;
}
.eco-field input:focus { outline: none; border-color: var(--primary); }
.eco-basis { display: inline-flex; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.eco-basis button {
    border: 0; background: transparent; color: var(--text-secondary);
    padding: 6px 11px; border-radius: 8px; font-size: 0.76rem; font-weight: 700;
    font-family: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.eco-basis button.active { background: var(--primary); color: #fff; }
.eco-btn {
    height: 36px; padding: 0 13px; border-radius: 9px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text-secondary); font-family: inherit;
    font-size: 0.78rem; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.eco-btn:hover { background: var(--surface-2); color: var(--text); }
.eco-btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.eco-btn.primary:hover { filter: brightness(0.94); }
.eco-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.eco-card {
    padding: 10px 12px; background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; min-width: 0;
}
.eco-card span { display: block; font-size: 0.64rem; color: var(--text-muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eco-card b { display: block; margin-top: 3px; font-size: 1.05rem; color: var(--text); font-variant-numeric: tabular-nums; }
.eco-card.good b { color: #15803d; }
.eco-card.bad b { color: #b91c1c; }
.eco-table-wrap {
    flex: 1; min-height: 0; overflow: auto;
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
}
.eco-table { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; min-width: 1080px; }
.eco-table thead th {
    position: sticky; top: 0; z-index: 3;
    background: var(--primary); color: #fff; font-size: 0.68rem; font-weight: 700;
    padding: 10px 8px; text-align: left; white-space: nowrap;
}
.eco-table thead th.num { text-align: right; }
.eco-table tbody td {
    padding: 7px 8px; font-size: 0.72rem; color: var(--text);
    border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.eco-table tbody tr:nth-child(even) td { background: var(--surface-2); }
.eco-table tbody tr:hover td { background: rgba(var(--accent-rgb), 0.06); }
.eco-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.eco-table .eco-shop { font-weight: 700; }
.eco-table .profit-pos { color: #15803d; font-weight: 700; }
.eco-table .profit-neg { color: #b91c1c; font-weight: 700; }
.eco-table .margin-badge { display: inline-block; padding: 0 5px; border-radius: 5px; font-weight: 700; }
.eco-table .margin-badge.pos { background: rgba(21, 128, 61, 0.10); color: #15803d; }
.eco-table .margin-badge.neg { background: rgba(185, 28, 28, 0.10); color: #b91c1c; }
.eco-empty { padding: 30px; text-align: center; color: var(--text-muted); font-size: 0.85rem; }
@media (max-width: 1250px) {
    .eco-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .tariff-economics-view { padding: 0 12px 16px; }
}
@media (max-width: 720px) {
    .eco-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .eco-toolbar { padding: 10px; }
}

/* Свои затраты */
.cost-form { display: grid; grid-template-columns: 1.4fr 1fr 0.8fr 1fr; gap: 10px; align-items: end; }
.cost-form .ct-upload { grid-column: 1 / -1; justify-self: end; }
.cost-form select {
    height: 38px; padding: 0 8px; border: 1.5px solid var(--border); border-radius: 9px;
    background: var(--input-bg, var(--surface-2)); color: var(--text); font-family: inherit; font-size: 0.8rem;
}
.cost-list { margin-top: 12px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.cost-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 0.75rem; }
.cost-row:last-child { border-bottom: 0; }
.cost-row:nth-child(even) { background: var(--surface-2); }
.cost-row-main { flex: 1; min-width: 0; }
.cost-row-name { font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cost-row-meta { color: var(--text-muted); font-size: 0.66rem; }
.cost-row-value { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cost-row-del { border: 1px solid var(--border); background: var(--surface); color: #b91c1c; width: 28px; height: 28px; border-radius: 7px; cursor: pointer; }
.cost-row-del:hover { background: rgba(185,28,28,0.08); }
.cost-empty { padding: 14px; text-align: center; color: var(--text-muted); font-size: 0.75rem; }
@media (max-width: 720px) { .cost-form { grid-template-columns: 1fr; } }

/* Ширины колонок экономики */
.eco-table { min-width: 1140px; }
.eco-table th:nth-child(1) { width: 200px; }
.eco-table th:nth-child(2) { width: 100px; }
.eco-table th:nth-child(3) { width: 110px; }
.eco-table th:nth-child(4) { width: 65px; }
.eco-table th:nth-child(5),
.eco-table th:nth-child(6),
.eco-table th:nth-child(7),
.eco-table th:nth-child(8),
.eco-table th:nth-child(9) { width: 90px; }
.eco-table th:nth-child(10) { width: 60px; }
.eco-table th:nth-child(11) { width: 85px; }
.eco-table th:nth-child(12) { width: 70px; }

/* Калькулятор рекомендованного тарифа в модалке */
.rm-calc {
    margin: 10px 0 12px;
    padding: 10px 12px;
    border-radius: 11px;
    border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--border));
    background: color-mix(in srgb, var(--primary) 6%, var(--surface));
}
.rm-calc.muted { border-color: var(--border); background: var(--surface-2); color: var(--text-muted); font-size: 0.76rem; }
.rm-calc-title { font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); margin-bottom: 7px; display: flex; align-items: center; gap: 6px; }
.rm-calc-title i { color: var(--primary); }
.rm-calc-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 0.76rem; color: var(--text-secondary); padding: 2px 0; }
.rm-calc-row b { color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rm-calc-row.total { margin-top: 6px; padding-top: 7px; border-top: 1px dashed color-mix(in srgb, var(--primary) 35%, var(--border)); font-weight: 700; }
.rm-calc-row.total b { color: #15803d; font-size: 0.95rem; }
.rm-calc-row.total small { color: var(--text-muted); font-size: 0.66rem; margin-left: 4px; }
.rm-apply-reco {
    margin-top: 8px; width: 100%; height: 32px; border-radius: 8px;
    border: 1px solid var(--primary); background: var(--surface); color: var(--primary);
    font-family: inherit; font-size: 0.74rem; font-weight: 700; cursor: pointer;
}
.rm-apply-reco:hover { background: var(--primary); color: #fff; }

/* Рекомендация по прайсу в форме добавления магазина */
.pos-tariff-hint.reco {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    color: #15803d;
    background: rgba(21, 128, 61, 0.08);
    border: 1px solid rgba(21, 128, 61, 0.22);
    border-radius: 8px;
    padding: 5px 8px;
    margin-top: 6px;
}
.apply-reco-btn {
    margin-left: auto;
    border: 1px solid #15803d;
    background: transparent;
    color: #15803d;
    border-radius: 7px;
    padding: 2px 8px;
    font-family: inherit;
    font-size: 0.68rem;
    font-weight: 700;
    cursor: pointer;
}
.apply-reco-btn:hover { background: #15803d; color: #fff; }
.tt-pos-customer { color: #0e7490; }
.tt-pos-customer span { font-weight: 500; }
.eco-help {
    margin-top: -2px;
    padding: 8px 12px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--primary) 5%, var(--surface));
    border: 1px dashed color-mix(in srgb, var(--primary) 25%, var(--border));
    font-size: 0.7rem;
    line-height: 1.5;
    color: var(--text-secondary);
}
.eco-help b { color: var(--text); }
.eco-help .help-pos { color: #15803d; }
.eco-help .help-neg { color: #b91c1c; }
.tt-pos-cell.pos-base-editable { cursor: pointer; }
.tt-pos-cell.pos-base-editable:hover { background: rgba(var(--accent-rgb), 0.08) !important; }
.tt-pos-edit {
    margin-top: 2px;
    font-size: 0.5rem;
    color: var(--text-muted);
    opacity: 0.7;
    white-space: nowrap;
}
.tt-pos-edit i { margin-right: 3px; }
.ct-field select {
    height: 38px; padding: 0 8px;
    border: 1.5px solid var(--border); border-radius: 9px;
    background: var(--input-bg, var(--surface-2)); color: var(--text);
    font-size: 0.82rem; font-family: inherit; outline: none;
}
.ct-field select:focus { border-color: var(--primary); }
