/* Страница «Расчёты» — единый стиль с Dashboard (modern SaaS) */

.page-calculations .container {
    padding: 24px;
    background-color: #f5f5f5;
    min-height: 100vh;
}

/* Заголовок в стиле Dashboard */
.page-calculations .page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #2c3e50;
    margin: 0 0 24px 0;
    letter-spacing: -0.02em;
}

.page-calculations .page-header {
    margin-bottom: 8px;
}

/* Карточка фильтров */
.calculations-filters-card {
    background: #fff;
    border-radius: 20px;
    padding: 20px 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
}

.page-calculations .filters-panel {
    padding: 0;
    background: transparent;
    border: none;
    margin: 0;
    border-radius: 0;
}

.page-calculations .filter-group {
    min-width: 200px;
    flex: 1;
}

.page-calculations .filter-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 17px;
    font-weight: 600;
    color: #374151;
}

.page-calculations .filter-input,
.page-calculations .filter-select {
    height: 44px;
    padding: 0 14px;
    border-radius: 11px;
    border: 1px solid #e5e7eb;
    font-size: 14px;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-width: 160px;
}

.page-calculations .filter-input {
    width: 100%;
    max-width: 280px;
}

.page-calculations .filter-input:focus,
.page-calculations .filter-select:focus {
    outline: none;
    border-color: #108FBA;
    box-shadow: 0 0 0 3px rgba(16, 143, 186, 0.12);
}

.page-calculations .filter-select {
    cursor: pointer;
    appearance: auto;
}

/* Кнопка «Сбросить фильтры» — вторичная */
.page-calculations .filters-panel .btn-secondary {
    height: 44px;
    padding: 0 20px;
    border-radius: 11px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid #d1d5db;
    background: #fff;
    color: #374151;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.page-calculations .filters-panel .btn-secondary:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Карточка-контейнер таблицы — overflow: visible, чтобы dropdown не создавал внутренний скролл */
.calculations-table-card,
.calculations-table-card .table-responsive {
    overflow: visible !important;
}

.calculations-table-card {
    background: #fff;
    border-radius: 20px;
    padding: 0;
    margin-bottom: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.page-calculations .table-responsive {
    margin: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

.page-calculations .calculations-table-card .table {
    margin: 0;
    background: transparent;
}

.page-calculations .calculations-table-card .table thead th {
    background: #f8fafc;
    padding: 16px 20px;
    font-size: 12px;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid #e2e8f0;
}

.page-calculations .calculations-table-card .table tbody td {
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 14px;
    line-height: 1.5;
    vertical-align: middle;
}

.page-calculations .calculations-table-card .table tbody tr:nth-child(even) {
    background: #fafbfc;
}

.page-calculations .calculations-table-card .table tbody tr:hover {
    background: #f1f5f9;
}

.page-calculations .calculations-table-card .table td.actions {
    padding: 12px 20px;
}

/* Статус сделки — pill/badge + dropdown */
.deal-status-widget {
    position: relative;
    display: inline-flex;
    justify-content: center;
    background: transparent !important;
    color: inherit;
}

.page-calculations .calculations-table-card td:nth-child(7) {
    text-align: center;
    vertical-align: middle;
}

.deal-status-pill {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 160px;
    min-width: 160px;
    max-width: 160px;
    padding: 6px 14px;
    border-radius: 999px;

    overflow: hidden;
    background-clip: padding-box;
    -webkit-background-clip: padding-box;

    border: 0;
    outline: 0;
    box-shadow: none;
    filter: none !important;
    -webkit-filter: none !important;
    background-image: none !important;
    -webkit-mask-image: none !important;
    mask-image: none !important;

    white-space: nowrap;
    text-overflow: ellipsis;

    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    isolation: isolate;
    transition: box-shadow 0.2s;
}

.deal-status-pill::before,
.deal-status-pill::after {
    content: none !important;
    display: none !important;
}

.deal-status-pill:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.deal-status-draft .deal-status-pill { background: #e5e7eb; color: #374151; }
.deal-status-sent .deal-status-pill { background: #fef3c7; color: #92400e; }
.deal-status-onagreement .deal-status-pill { background: #ffedd5; color: #9a3412; }
.deal-status-inprogress .deal-status-pill { background: #dbeafe; color: #1e40af; }
.deal-status-realized .deal-status-pill { background: #d1fae5; color: #065f46; }
.deal-status-closed .deal-status-pill { background: #fee2e2; color: #991b1b; }

.deal-status-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 180px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12), 0 4px 6px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb;
    z-index: 100;
    padding: 6px 0;
    display: none;
}

.deal-status-widget.open .deal-status-dropdown {
    display: block;
}

/* Dropdown вверх, если снизу мало места */
.deal-status-widget.drop-up .deal-status-dropdown {
    top: auto;
    bottom: calc(100% + 6px);
}

.deal-status-dropdown-option {
    display: block;
    width: 100%;
    padding: 10px 16px;
    text-align: left;
    font-size: 13px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #374151;
    transition: background 0.15s;
}

.deal-status-dropdown-option:hover {
    background: #f3f4f6;
}

.deal-status-dropdown-option.active {
    background: #eff6ff;
    color: #1e40af;
    font-weight: 500;
}

/* Кнопки действий — единый размер и стиль */
.page-calculations .btn-action-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #4b5563;
    transition: background 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.page-calculations .btn-action-icon:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    color: #111827;
}

.page-calculations .btn-action-icon.btn-primary {
    border-color: #108FBA;
    color: #108FBA;
}

.page-calculations .btn-action-icon.btn-primary:hover {
    background: #108FBA;
    color: #fff;
    border-color: #108FBA;
    box-shadow: 0 2px 8px rgba(16, 143, 186, 0.3);
}

.page-calculations .btn-action-icon.btn-danger {
    border-color: #fecaca;
    color: #b91c1c;
}

.page-calculations .btn-action-icon.btn-danger:hover {
    background: #fef2f2;
    border-color: #f87171;
    color: #b91c1c;
    box-shadow: 0 2px 6px rgba(185, 28, 28, 0.15);
}

.page-calculations .table td.actions {
    gap: 8px;
}

.page-calculations .btn-favorite {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    font-size: 18px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    transition: background 0.2s, box-shadow 0.2s;
}

.page-calculations .btn-favorite:hover,
.page-calculations .btn-favorite.active {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

/* Empty state */
.page-calculations .empty-state {
    margin-top: 24px;
}

@media (max-width: 768px) {
    .page-calculations .container { padding: 16px; }
    .calculations-filters-card { padding: 16px 18px; border-radius: 16px; }
    .calculations-table-card { border-radius: 16px; }
    .page-calculations .filters-panel { flex-direction: column; align-items: stretch; }
    .page-calculations .filter-input { max-width: none; }

    /* Карточный вид: без горизонтального скролла */
    .page-calculations .calculations-table-card .table-responsive {
        overflow: visible;
    }
    .page-calculations .calculations-table-card #calculations-table {
        display: block;
        width: 100%;
    }
    .page-calculations .calculations-table-card #calculations-table thead {
        display: none;
    }
    .page-calculations .calculations-table-card #calculations-table tbody {
        display: block;
    }
    .page-calculations .calculations-table-card #calculations-table tbody tr {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto auto;
        gap: 6px 10px;
        padding: 12px 16px;
        border-bottom: 1px solid #e2e8f0;
        align-items: center;
    }
    .page-calculations .calculations-table-card #calculations-table tbody tr:nth-child(even) {
        background: #fafbfc;
    }
    .page-calculations .calculations-table-card #calculations-table tbody tr:hover {
        background: #f1f5f9;
    }
    .page-calculations .calculations-table-card #calculations-table tbody tr:last-child {
        border-bottom: none;
    }
    .page-calculations .calculations-table-card #calculations-table tbody td {
        padding: 0;
        border: none;
    }
    .page-calculations .calculations-table-card #calculations-table tbody td.mobile-hide {
        display: none !important;
    }
    /* Строка 1: название слева, сумма справа */
    .page-calculations .calculations-table-card #calculations-table tbody td:nth-child(1) {
        grid-row: 1;
        grid-column: 1;
        font-size: 14px;
        font-weight: 600;
        color: #1e293b;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .page-calculations .calculations-table-card #calculations-table tbody td:nth-child(6) {
        grid-row: 1;
        grid-column: 2;
        font-size: 13px;
        font-weight: 600;
        color: #0f172a;
        text-align: right;
        white-space: nowrap;
    }
    /* Строка 2: статус сделки */
    .page-calculations .calculations-table-card #calculations-table tbody td:nth-child(7) {
        grid-row: 2;
        grid-column: 1 / -1;
        padding: 2px 0 0 0;
    }
    .page-calculations .calculations-table-card #calculations-table tbody td:nth-child(7) .deal-status-pill {
        min-width: 0;
        width: auto;
        max-width: 180px;
        padding: 4px 10px;
        font-size: 12px;
    }
    /* Строка 3: кнопки */
    .page-calculations .calculations-table-card #calculations-table tbody td.actions {
        grid-row: 3;
        grid-column: 1 / -1;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
        padding-top: 4px;
    }
    .page-calculations .calculations-table-card #calculations-table tbody td.actions .btn-action-icon,
    .page-calculations .calculations-table-card #calculations-table tbody td.actions .btn-favorite {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
    }
}

@media (max-width: 480px) {
    .page-calculations .calculations-table-card #calculations-table tbody tr {
        padding: 10px 12px;
        gap: 4px 8px;
    }
    .page-calculations .calculations-table-card #calculations-table tbody td:nth-child(1) {
        font-size: 13px;
        white-space: normal;
        line-height: 1.3;
        max-height: 2.6em;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    .page-calculations .calculations-table-card #calculations-table tbody td:nth-child(6) {
        font-size: 12px;
    }
    .page-calculations .calculations-table-card #calculations-table tbody td.actions .btn-action-icon,
    .page-calculations .calculations-table-card #calculations-table tbody td.actions .btn-favorite {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
    }
}
