/* Экономика: вкладка «Экономика» в модуле «Итоги» */
.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); }
}

/* ==================== Экономика ==================== */
.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 > tr > 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 > tr > th.num { text-align: right; }
.eco-table > tbody > tr > 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 > tbody > tr > 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 > thead > tr > th:nth-child(1) { width: 200px; }
.eco-table > thead > tr > th:nth-child(2) { width: 100px; }
.eco-table > thead > tr > th:nth-child(3) { width: 110px; }
.eco-table > thead > tr > th:nth-child(4) { width: 65px; }
.eco-table > thead > tr > th:nth-child(5),
.eco-table > thead > tr > th:nth-child(6),
.eco-table > thead > tr > th:nth-child(7),
.eco-table > thead > tr > th:nth-child(8),
.eco-table > thead > tr > th:nth-child(9) { width: 90px; }
.eco-table > thead > tr > th:nth-child(10) { width: 60px; }
.eco-table > thead > tr > th:nth-child(11) { width: 85px; }
.eco-table > thead > tr > 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; }

/* Раскрытие магазина по должностям + колонка текущего тарифа */
.eco-table { min-width: 1240px; }
.eco-table > thead > tr > th:nth-child(5),
.eco-table > thead > tr > th:nth-child(6),
.eco-table > thead > tr > th:nth-child(7),
.eco-table > thead > tr > th:nth-child(8),
.eco-table > thead > tr > th:nth-child(9) { width: 90px; }
.eco-table > thead > tr > th:nth-child(10) { width: 60px; }
.eco-table > thead > tr > th:nth-child(11) { width: 85px; }
.eco-table > thead > tr > th:nth-child(12) { width: 90px; }
.eco-table > thead > tr > th:nth-child(13) { width: 70px; }
.eco-row { cursor: pointer; }
.eco-caret {
    font-size: 0.55rem;
    margin-right: 6px;
    color: var(--text-muted);
    transition: transform 0.15s;
}
.eco-row.open .eco-caret { transform: rotate(90deg); color: var(--primary); }
.eco-detail-row td { padding: 0 !important; background: var(--surface-2) !important; white-space: normal; }
.eco-detail-row:hover td { background: var(--surface-2) !important; }
.eco-detail-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 14px;
    font-size: 0.76rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}
.eco-detail-head b { color: var(--text); }
.eco-detail-meta { font-size: 0.7rem; color: var(--text-muted); }
.eco-detail-table { width: 100%; border-collapse: collapse; }
.eco-detail-table th {
    padding: 7px 10px;
    font-size: 0.64rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    text-align: left;
    background: color-mix(in srgb, var(--primary) 5%, var(--surface));
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.eco-detail-table th.num { text-align: right; }
.eco-detail-table td {
    padding: 7px 10px;
    font-size: 0.72rem;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
    white-space: nowrap;
    color: var(--text);
}
.eco-detail-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.eco-detail-table tr:last-child td { border-bottom: 0; }
.eco-detail-pos { font-weight: 700; }
.eco-detail-loading { padding: 14px; font-size: 0.76rem; color: var(--text-muted); text-align: center; }

/* Аккуратная раскрывающаяся таблица по должностям */
.eco-row.open td { background: color-mix(in srgb, var(--primary) 4%, var(--surface)) !important; }
.eco-detail-row td {
    padding: 0 !important;
    background: var(--surface) !important;
    border-bottom: 2px solid var(--border) !important;
}
.eco-detail-row:hover td { background: var(--surface) !important; }
.eco-detail-panel { padding: 12px 16px 14px; }
.eco-detail-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 0 0 10px;
    border-bottom: 0;
}
.eco-detail-name { font-size: 0.9rem; font-weight: 800; color: var(--text); }
.eco-detail-name span { font-size: 0.7rem; font-weight: 600; color: var(--text-muted); margin-left: 6px; }
.eco-detail-meta { font-size: 0.68rem; color: var(--text-muted); }
.eco-detail-meta b { color: var(--text); }
.eco-detail-wrap {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--surface);
}
.eco-detail-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.eco-detail-table th {
    padding: 7px 10px;
    font-size: 0.64rem;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-muted);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}
.eco-detail-table th.num { text-align: right; }
.eco-detail-table td {
    padding: 7px 10px;
    font-size: 0.72rem;
    background: var(--surface);
    border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
    white-space: nowrap;
    color: var(--text);
}
.eco-detail-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 55%, var(--surface)); }
.eco-detail-table tbody tr:hover td { background: rgba(var(--accent-rgb), 0.05); }
.eco-detail-table tbody tr:last-child td { border-bottom: 0; }
.eco-detail-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.eco-detail-pos { font-weight: 700; }
.eco-table { min-width: 1270px; }
.eco-table > thead > tr > th:nth-child(13) { width: 95px; }

/* Раскрытие магазина — в стиле таблиц проекта */
.eco-detail-panel { padding: 0 0 14px; }
.eco-detail-head {
    padding: 10px 16px;
    background: color-mix(in srgb, var(--primary) 6%, var(--surface));
    border-bottom: 1px solid var(--border);
}
.eco-detail-wrap {
    margin: 12px 16px 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
.eco-detail-table th {
    background: var(--primary);
    color: #fff;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.66rem;
    font-weight: 700;
    padding: 8px 10px;
    border-bottom: 0;
}
.eco-detail-table th.num { color: #fff; text-align: right; }
.eco-detail-table td { padding: 7px 10px; font-size: 0.72rem; }
.eco-detail-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 60%, var(--surface)); }
.eco-detail-table tbody tr:hover td { background: rgba(var(--accent-rgb), 0.06); }
.eco-detail-table tbody tr:last-child td { border-bottom: 0; }
