body {
    margin: 0;
    padding: 0;
    background:
        radial-gradient(circle at top left, rgba(59, 130, 246, 0.08), transparent 28%),
        radial-gradient(circle at top right, rgba(16, 185, 129, 0.07), transparent 24%),
        linear-gradient(180deg, #f8fbff 0%, #f3f6fb 100%);
    font-family: Inter, Arial, sans-serif;
    color: #111827;
}

.page {
    max-width: 1320px;
    margin: 0 auto;
    padding: 28px 20px 40px;
}

.header {
    margin-bottom: 24px;
}

.header h1 {
    margin: 0;
    font-size: 32px;
    line-height: 1.2;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #0f172a;
}

.content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.card {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    border-radius: 22px;
    padding: 24px;
    box-shadow:
        0 10px 30px rgba(15, 23, 42, 0.06),
        0 2px 10px rgba(15, 23, 42, 0.04);
    border: 1px solid rgba(226, 232, 240, 0.9);
}

.card h2,
.card h3 {
    margin-top: 0;
    margin-bottom: 18px;
    color: #0f172a;
    letter-spacing: -0.02em;
}

.card h2 {
    font-size: 28px;
    font-weight: 800;
}

.card h3 {
    font-size: 20px;
    font-weight: 700;
}

.info-block {
    margin-top: 16px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 16px 18px;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    overflow-x: auto;
}

pre {
    margin: 0;
    font-family: Consolas, Monaco, monospace;
    font-size: 13px;
    color: #334155;
}

form#profitabilityForm {
    margin-top: 8px !important;
}

form#profitabilityForm > div:first-child {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px !important;
    margin-bottom: 18px !important;
    align-items: end;
}

form#profitabilityForm label {
    display: inline-block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 700;
    color: #334155;
}

input[type="date"],
input[type="text"],
select {
    width: 100%;
    box-sizing: border-box;
    height: 46px;
    padding: 0 14px;
    border-radius: 14px;
    border: 1px solid #dbe3ee;
    background: #ffffff;
    font-size: 14px;
    color: #0f172a;
    outline: none;
    transition: all 0.2s ease;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.03);
}

input[type="date"]:focus,
input[type="text"]:focus,
select:focus {
    border-color: #3b82f6;
    box-shadow:
        0 0 0 4px rgba(59, 130, 246, 0.12),
        inset 0 1px 2px rgba(15, 23, 42, 0.03);
}

input::placeholder {
    color: #94a3b8;
}

button {
    height: 46px;
    border: none;
    border-radius: 14px;
    padding: 0 18px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

button[type="submit"] {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.24);
}

button[type="submit"]:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.28);
}

#managerMatrixBtn {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: white;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18);
}

#managerMatrixBtn:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.24);
}

button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none !important;
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #2563eb;
    cursor: pointer;
}

.report-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 16px;
    font-size: 14px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    overflow: hidden;
}

.report-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
    color: #334155;
    font-weight: 800;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.report-table th,
.report-table td {
    border-bottom: 1px solid #edf2f7;
    padding: 13px 14px;
    text-align: left;
    vertical-align: middle;
}

.report-table tbody tr:last-child td {
    border-bottom: none;
}

.report-table tbody tr:hover {
    background: #f8fbff;
}

.report-table td strong {
    color: #0f172a;
}

.report-table a {
    color: #1d4ed8;
    text-decoration: none;
    font-weight: 600;
}

.report-table a:hover {
    text-decoration: underline;
}

.card p {
    margin: 10px 0;
    color: #334155;
    line-height: 1.5;
}

.status-ok {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #15803d;
    font-weight: 700;
}

.status-error {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #dc2626;
    font-weight: 700;
}

.summary-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.summary-badge {
    padding: 10px 14px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    font-size: 14px;
    color: #334155;
    font-weight: 600;
}

.table-wrap {
    overflow-x: auto;
    border-radius: 18px;
}

::-webkit-scrollbar {
    height: 10px;
    width: 10px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

.hero-card {
    position: relative;
    overflow: visible;
    background:
        radial-gradient(circle at top left, rgba(59, 130, 246, 0.16), transparent 32%),
        radial-gradient(circle at bottom right, rgba(16, 185, 129, 0.10), transparent 28%),
        linear-gradient(135deg, rgba(255,255,255,0.96) 0%, rgba(248,250,252,0.94) 100%);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 28px;
    box-shadow:
        0 16px 40px rgba(15, 23, 42, 0.08),
        0 4px 18px rgba(15, 23, 42, 0.05);
    border: 1px solid rgba(226, 232, 240, 0.9);
    margin-bottom: 20px;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(37, 99, 235, 0.10);
    color: #1d4ed8;
    border: 1px solid rgba(37, 99, 235, 0.16);
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 14px;
}

.hero-title {
    margin: 0 0 8px 0;
    font-size: 32px;
    line-height: 1.1;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: #0f172a;
}

.hero-subtitle {
    margin: 0;
    max-width: 760px;
    font-size: 15px;
    line-height: 1.65;
    color: #475569;
}

.filters-form {
    margin-top: 24px;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    align-items: end;
}

.field {
    display: flex;
    flex-direction: column;
}

.field-wide {
    grid-column: span 2;
}

.field label {
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 700;
    color: #334155;
    letter-spacing: 0.01em;
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    padding: 0 4px;
}

.checkbox-field label {
    font-size: 14px;
    font-weight: 600;
    color: #334155;
    margin: 0;
}

.actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 18px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 18px;
    border: none;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.24);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 30px rgba(37, 99, 235, 0.28);
}

.btn-dark {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: white;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
}

.btn-dark:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.22);
}

.section-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.section-head h3 {
    margin: 0;
}

.section-note {
    font-size: 13px;
    color: #64748b;
    font-weight: 600;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat-box {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    padding: 16px;
}

.stat-label {
    font-size: 12px;
    color: #64748b;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 20px;
    color: #0f172a;
    font-weight: 800;
    line-height: 1.2;
}

.meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.meta-card {
    min-width: 0;
}

.meta-title {
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 700;
    color: #334155;
}

.item-name-cell {
    min-width: 260px;
}

.type-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 6px 10px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1d4ed8;
    font-size: 12px;
    font-weight: 800;
}

.profit-cell {
    font-weight: 700;
    color: #0f766e;
}

.totals-table-row {
    font-weight: 800;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
    border-top: 2px solid #cbd5e1;
}

.totals-panel {
    margin-top: 18px;
    padding: 18px;
    background: linear-gradient(180deg, #f8fbff 0%, #f1f5f9 100%);
    border-radius: 18px;
    border: 1px solid #dbe4ef;
}

.totals-title {
    font-size: 18px;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 14px;
}

.totals-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.totals-badge {
    padding: 10px 14px;
    border-radius: 14px;
    background: white;
    border: 1px solid #e2e8f0;
    color: #334155;
    font-size: 14px;
    font-weight: 600;
}

.totals-badge-winner {
    background: #dcfce7;
    border-color: #22c55e;
    color: #166534;
    font-weight: 800;
}

.totals-badge-total {
    background: #e8f0fe;
    border-color: #b6ccfe;
    color: #1d4ed8;
    font-weight: 800;
}

.error-card {
    border: 1px solid rgba(248, 113, 113, 0.28);
    box-shadow:
        0 16px 40px rgba(239, 68, 68, 0.05),
        0 4px 16px rgba(15, 23, 42, 0.04);
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 24px;
}

.loading-modal {
    width: 100%;
    max-width: 520px;
    background: #ffffff;
    border-radius: 24px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.18);
    padding: 32px 28px;
    text-align: center;
    border: 1px solid rgba(226, 232, 240, 0.9);
    animation: fadeInScale 0.25s ease;
}

.loader-spinner {
    width: 56px;
    height: 56px;
    margin: 0 auto 18px auto;
    border-radius: 50%;
    border: 5px solid #e5e7eb;
    border-top-color: #1d4ed8;
    animation: spin 0.9s linear infinite;
}

.loading-title {
    font-size: 28px;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 10px;
}

.loading-percent {
    font-size: 30px;
    font-weight: 800;
    color: #1d4ed8;
    margin-bottom: 16px;
}

.loading-progress {
    width: 100%;
    height: 14px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 18px;
}

.loading-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #2563eb 0%, #3b82f6 50%, #60a5fa 100%);
    border-radius: 999px;
    transition: width 0.35s ease;
}

.loading-subtitle {
    font-size: 18px;
    font-weight: 700;
    color: #334155;
    margin-bottom: 10px;
}

.loading-item {
    font-size: 15px;
    line-height: 1.45;
    color: #64748b;
    background: #f8fafc;
    border-radius: 14px;
    padding: 12px 14px;
    min-height: 48px;
    word-break: break-word;
}

.matrix-table td,
.matrix-table th {
    white-space: nowrap;
}

.totals-table-row td {
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@media (max-width: 1100px) {
    .meta-grid {
        grid-template-columns: 1fr;
    }

    .field-wide {
        grid-column: span 1;
    }
}

@media (max-width: 900px) {
    .page {
        padding: 16px;
    }

    .card {
        padding: 18px;
        border-radius: 18px;
    }

    .header h1 {
        font-size: 26px;
    }

    .card h2 {
        font-size: 24px;
    }

    .card h3 {
        font-size: 18px;
    }

    form#profitabilityForm > div:first-child {
        grid-template-columns: 1fr;
    }

    button,
    input[type="date"],
    input[type="text"],
    select {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .hero-card {
        padding: 20px;
        border-radius: 20px;
    }

    .hero-title {
        font-size: 26px;
    }

    .hero-subtitle {
        font-size: 14px;
    }

    .filters-grid {
        grid-template-columns: 1fr;
    }

    .actions-row {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .loading-modal {
        min-width: 280px;
        width: calc(100vw - 40px);
        padding: 24px;
    }

    .loading-title {
        font-size: 22px;
    }

    .loading-percent {
        font-size: 26px;
    }

    .loading-subtitle {
        font-size: 16px;
    }

    .loading-item {
        font-size: 14px;
    }
}

.chart-icon-btn {
    min-width: 44px;
    height: 44px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    color: #1d4ed8;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.12);
    transition: all 0.2s ease;
}

.chart-icon-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(37, 99, 235, 0.18);
}

.chart-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 24px;
}

.chart-modal {
    width: 100%;
    max-width: 980px;
    background: #ffffff;
    border-radius: 24px;
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.18);
    padding: 24px;
    animation: fadeInScale 0.25s ease;
}

.chart-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.chart-modal-header h3 {
    margin: 0;
    font-size: 24px;
    font-weight: 800;
    color: #0f172a;
}

.chart-close-btn {
    min-width: 44px;
    height: 44px;
    border: none;
    border-radius: 14px;
    background: #f1f5f9;
    color: #334155;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chart-close-btn:hover {
    background: #e2e8f0;
}

.chart-switchers {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}

.chart-switch-btn {
    min-height: 42px;
    padding: 0 14px;
    border: 1px solid #dbeafe;
    border-radius: 12px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chart-switch-btn.active {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
    border-color: #2563eb;
}

.chart-canvas-wrap {
    position: relative;
    width: 100%;
    height: 460px;
}

@media (max-width: 768px) {
    .chart-modal {
        padding: 18px;
        border-radius: 20px;
    }

    .chart-modal-header h3 {
        font-size: 20px;
    }

    .chart-canvas-wrap {
        height: 320px;
    }
}

.ratio-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(220px, 1fr));
    gap: 16px;
    align-items: end;
}

.ratio-result-card {
    margin-top: 20px;
    border: 1px solid #dbe3f1;
    border-radius: 18px;
    padding: 18px;
    background: #f8fbff;
}

.ratio-result-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    gap: 14px;
}

.ratio-result-box {
    background: #ffffff;
    border: 1px solid #e3eaf5;
    border-radius: 16px;
    padding: 16px;
}

.ratio-result-box-accent {
    background: #eef4ff;
    border-color: #cddcff;
}

.ratio-result-label {
    font-size: 13px;
    color: #667085;
    margin-bottom: 8px;
}

.ratio-result-value {
    font-size: 20px;
    font-weight: 700;
    color: #101828;
}

.ratio-hint-text {
    margin-top: 14px;
    font-size: 14px;
    color: #475467;
}


.multi-dropdown-field {
    position: relative;
}

.multi-dropdown-trigger {
    width: 100%;
    min-height: 44px;
    border: 1px solid #d8deea;
    border-radius: 14px;
    background: #fff;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    font: inherit;
    text-align: left;
}

.multi-dropdown-trigger:hover {
    border-color: #b8c2d6;
}

.multi-dropdown-arrow {
    flex-shrink: 0;
    margin-left: 10px;
}

.multi-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 100%;
    width: 360px;
    max-width: 520px;
    max-height: 500px;
    z-index: 9999;
    background: #fff;
    border: 1px solid #d8deea;
    border-radius: 16px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
    padding: 10px;
}

.multi-dropdown-field.open .multi-dropdown-menu {
    display: block;
}

.multi-check-list {
    max-height: 420px;
    overflow-y: auto;
    padding-top: 6px;
    padding-right: 4px;
}

.multi-check-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 8px;
    border-radius: 10px;
    cursor: pointer;
    line-height: 1.35;
}

.multi-check-row:hover {
    background: #f5f7fb;
}

.multi-check-row input[type="checkbox"] {
    margin: 0;
}

.multi-check-all {
    border-bottom: 1px solid #eef2f7;
    padding-bottom: 10px;
    margin-bottom: 6px;
}