.plan-section {
    margin-top: 48px;
}

.section-heading--plan {
    align-items: flex-end;
    padding: 0 3px;
}

.section-heading--plan > div:first-child {
    display: grid;
    gap: 5px;
}

.plan-heading-actions {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.plan-year-field {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #4d5963;
    font-size: 12px;
    font-weight: 650;
}

.plan-years-selector {
    position: relative;
    width: 190px;
}

.plan-years-selector .multi-select {
    min-height: 40px;
}

.plan-years-selector .chip {
    padding-block: 3px;
}

.plan-warning {
    margin: 14px 0 0;
    padding: 10px 13px;
    border: 1px solid #ecc8a1;
    border-radius: 9px;
    background: #fff8ee;
    color: #8a5923;
    font-size: 12px;
    font-weight: 650;
}

.plan-warning.is-error {
    border-color: #e5b8bd;
    background: #fff3f4;
    color: var(--danger);
}

.plan-message {
    min-height: 16px;
    margin: 9px 3px 0;
}

.plan-table-wrap {
    margin-top: 10px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 10px 30px rgba(30, 48, 60, .05);
}

.plan-table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 10.5px;
}

.plan-table th,
.plan-table td {
    padding: 10px 6px;
    border-right: 1px solid #edf0f2;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.plan-table th:last-child,
.plan-table td:last-child {
    border-right: 0;
}

.plan-table th {
    background: #f5f8f9;
    color: #52606b;
    font-size: 9.5px;
    font-weight: 760;
    line-height: 1.35;
    text-align: left;
    white-space: normal;
}

.plan-table th:nth-child(1) { width: 14%; }
.plan-table th:nth-child(2) { width: 10%; }
.plan-table th:nth-child(3) { width: 10%; text-align: right; }
.plan-table th:nth-child(4) { width: 11%; text-align: right; }
.plan-table th:nth-child(5) { width: 10%; text-align: right; }
.plan-table th:nth-child(6) { width: 11%; text-align: right; }
.plan-table th:nth-child(7) { width: 12%; text-align: right; }
.plan-table th:nth-child(8) { width: 11%; text-align: right; }
.plan-table th:nth-child(9) { width: 11%; text-align: right; }

.plan-table th small {
    color: #87929b;
    font-size: 9px;
}

.plan-table td {
    color: #35424c;
}

.plan-table tbody tr {
    transition: background .14s;
}

.plan-table tbody tr:hover {
    background: #f8fafb;
}

.plan-table tbody tr.is-unavailable,
.plan-table tbody tr.is-unavailable:hover {
    background: #fff2f3;
}

.plan-table td.plan-number {
    text-align: right;
    white-space: nowrap;
}

.plan-table tfoot td {
    border-top: 2px solid var(--line-strong);
    border-bottom: 0;
    background: #eef4f5;
    color: #26343e;
    font-weight: 800;
}

.plan-table-empty {
    height: 112px;
    color: var(--muted);
    text-align: center;
}

.plan-unavailable-note {
    display: block;
    margin-top: 4px;
    color: var(--danger);
    font-size: 10px;
    font-weight: 700;
}

.plan-percent {
    font-weight: 720;
}

.plan-remaining.is-negative {
    color: var(--success);
    font-weight: 750;
}

.plan-table th.plan-filter-column {
    position: relative;
    padding: 0;
}

.plan-filter-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    width: 100%;
    min-height: 58px;
    padding: 10px 6px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
}

.plan-filter-trigger:hover,
.plan-filter-trigger:focus-visible {
    background: #edf3f4;
}

.plan-filter-trigger.is-active {
    background: rgba(22, 118, 140, .09);
    color: var(--accent-dark);
}

.plan-filter-trigger.is-active::after {
    content: attr(data-count);
    display: grid;
    place-items: center;
    min-width: 18px;
    height: 18px;
    margin-left: auto;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
}

.plan-filter-trigger__icon {
    color: #82909a;
    font-size: 13px;
}

.plan-filter-popover {
    position: fixed;
    z-index: 100;
    display: grid;
    width: min(310px, calc(100vw - 24px));
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 18px 45px rgba(27, 42, 52, .2);
}

.plan-filter-popover[hidden] {
    display: none;
}

.plan-filter-search {
    width: 100%;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    color: #27333d;
}

.plan-filter-options {
    display: grid;
    max-height: 230px;
    overflow-y: auto;
}

.plan-filter-option {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 8px 7px;
    border-radius: 7px;
    color: #34414b;
    font-size: 12px;
    font-weight: 550;
    cursor: pointer;
}

.plan-filter-option:hover {
    background: #eef5f6;
}

.plan-filter-option input {
    margin: 1px 0 0;
    accent-color: var(--accent);
}

.plan-filter-empty {
    margin: 0;
    padding: 14px 8px;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

.plan-filter-actions {
    display: flex;
    justify-content: flex-end;
    gap: 7px;
    padding-top: 9px;
    border-top: 1px solid var(--line);
}

.plan-filter-actions .button {
    min-height: 34px;
    padding: 6px 11px;
    font-size: 11px;
}

.plan-empty-state {
    display: grid;
    justify-items: center;
    gap: 12px;
    padding: 25px 18px;
    color: var(--muted);
}

.plan-empty-add {
    min-height: 34px;
    padding: 6px 12px;
    font-size: 12px;
}

.plan-amount-button {
    padding: 3px 0;
    border: 0;
    border-bottom: 1px solid transparent;
    background: transparent;
    color: var(--accent-dark);
    font-weight: 750;
    font-size: 10.5px;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
    border-bottom-color: transparent;
    text-decoration: none;
    cursor: pointer;
}

.plan-amount-button:hover,
.plan-amount-button:focus-visible,
.plan-amount-button.is-active {
    border-bottom-color: currentColor;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.plan-dialog {
    width: min(1120px, calc(100% - 32px));
    max-height: calc(100vh - 40px);
    padding: 0;
    border: 0;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 28px 80px rgba(19, 33, 43, .28);
}

.plan-dialog::backdrop {
    background: rgba(23, 32, 42, .48);
    backdrop-filter: blur(2px);
}

.plan-dialog__header {
    position: sticky;
    z-index: 2;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 20px 22px;
    border-bottom: 1px solid var(--line);
    background: #fff;
}

.plan-dialog__header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

#plan-save-all-button:disabled {
    cursor: default;
}

.plan-dialog__close {
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 9px;
    background: #f0f3f5;
    color: #66727c;
    font-size: 24px;
    line-height: 1;
}

.plan-dialog__body {
    display: block;
    max-height: calc(100vh - 122px);
    overflow: auto;
    padding: 20px 22px 24px;
}

.plan-dialog__message {
    min-height: 18px;
    margin: 0 0 10px;
}

.plan-discard-confirmation {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin: 0 0 14px;
    padding: 12px 14px;
    border: 1px solid #ecc8a1;
    border-radius: 10px;
    background: #fff8ee;
    color: #74491d;
    font-size: 13px;
    font-weight: 650;
}

.plan-discard-confirmation[hidden] {
    display: none;
}

.plan-discard-confirmation > div {
    display: flex;
    gap: 8px;
}

.plan-editor-table {
    min-width: 940px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

.plan-editor-table__header,
.plan-editor-row {
    display: grid;
    grid-template-columns: minmax(170px, 1fr) minmax(190px, 1.08fr) minmax(220px, 1.25fr) minmax(155px, .82fr) 38px;
    align-items: center;
    gap: 10px;
}

.plan-editor-table__header {
    padding: 9px 12px;
    border-bottom: 1px solid var(--line);
    background: #f5f8f9;
    color: #52606b;
    font-size: 10px;
    font-weight: 760;
}

.plan-editor-list {
    display: grid;
}

.plan-editor-row {
    position: relative;
    padding: 9px 12px;
    border-bottom: 1px solid var(--line);
}

.plan-editor-row:last-child {
    border-bottom: 0;
}

.plan-editor-row.is-unavailable {
    background: #fff9f9;
}

.plan-editor-row.has-error {
    background: #fff5f6;
}

.plan-editor-cell {
    min-width: 0;
}

.plan-editor-cell--select,
.plan-editor-multiselect {
    position: relative;
    display: block;
}

.plan-editor-row .multi-select,
.plan-editor-manager {
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: #fff;
}

.plan-editor-row .multi-select {
    padding-block: 3px;
}

.plan-editor-row .multi-select input {
    min-width: 42px;
    font-size: 12px;
}

.plan-editor-row .chip {
    padding-block: 3px;
}

.plan-editor-manager {
    padding: 7px 30px 7px 9px;
    color: #27343f;
    font: inherit;
    font-size: 12px;
}

.option small {
    margin-left: 6px;
    color: var(--muted);
    font-size: 10px;
}

.option:disabled,
.option.is-disabled {
    cursor: not-allowed;
    opacity: .7;
}

.option:disabled:hover,
.option.is-disabled:hover {
    background: transparent;
    color: #34414b;
}

.plan-editor-amount {
    display: flex;
    justify-content: flex-start;
}

.plan-editor-amount__button {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 7px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #27343f;
    font-weight: 750;
    white-space: nowrap;
}

.plan-editor-amount__button:hover,
.plan-editor-amount__button:focus-visible {
    background: #edf4f6;
    color: var(--accent-dark);
}

.plan-editor-amount__pencil {
    opacity: 0;
    color: var(--accent);
    font-size: 14px;
    transition: opacity .15s;
}

.plan-editor-amount__button:hover .plan-editor-amount__pencil,
.plan-editor-amount__button:focus-visible .plan-editor-amount__pencil {
    opacity: 1;
}

.plan-editor-amount__input {
    width: 100%;
    min-height: 38px;
    padding: 7px 9px;
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: #fff;
    color: #27343f;
    font: inherit;
    font-weight: 700;
    text-align: left;
    outline: 3px solid rgba(22,118,140,.12);
}

.plan-editor-cell--action {
    display: flex;
    justify-content: flex-end;
}

.plan-editor-remove {
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #97a0a7;
    font-size: 21px;
    line-height: 1;
}

.plan-editor-remove:hover,
.plan-editor-remove:focus-visible {
    background: #fff0f1;
    color: var(--danger);
}

.plan-editor-row__error {
    grid-column: 1 / -1;
    margin: -1px 0 0;
    color: var(--danger);
    font-size: 11px;
    font-weight: 700;
}

.plan-editor-row__error[hidden] {
    display: none;
}

.plan-editor-empty {
    grid-column: 1 / -1;
    margin: 0;
    padding: 28px 18px;
    border: 1px dashed var(--line-strong);
    border-radius: 12px;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

.plan-editor-empty--error {
    border-color: #e5b8bd;
    background: #fff5f6;
    color: var(--danger);
}

.analytics-section {
    margin-top: 48px;
}

.analytics-section__heading {
    align-items: flex-end;
    padding: 0 3px;
}

.analytics-selector {
    position: relative;
    width: min(360px, 100%);
}

.analytics-heading-actions {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.analytics-heading-actions .analytics-selector {
    width: 360px;
}

.analytics-selector > label {
    display: block;
    margin-bottom: 6px;
    color: #4d5963;
    font-size: 11px;
    font-weight: 700;
}

.analytics-selector .multi-select {
    min-height: 38px;
}

.analytics-message {
    min-height: 16px;
    margin: 8px 3px 0;
}

.analytics-table-wrap {
    margin-top: 10px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 10px 30px rgba(30, 48, 60, .05);
}

.analytics-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 11px;
    transition: opacity .15s;
}

.analytics-table.is-loading {
    opacity: .5;
}

.analytics-table th,
.analytics-table td {
    min-width: 0;
    padding: 10px 6px;
    border-right: 1px solid #edf0f2;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.analytics-table th:last-child,
.analytics-table td:last-child {
    border-right: 0;
}

.analytics-table th {
    background: #f5f8f9;
    color: #52606b;
    font-size: 9px;
    font-weight: 760;
    line-height: 1.3;
    text-align: left;
    overflow-wrap: anywhere;
}

.analytics-table tbody tr:not(.analytics-group-row):not(.analytics-total-row):hover {
    background: #f8fafb;
}

.pipeline-state-table th:nth-child(1) { width: 18%; }
.pipeline-state-table th:nth-child(2) { width: 22%; }
.pipeline-state-table th:nth-child(3) { width: 8%; }
.pipeline-state-table th:nth-child(4) { width: 16%; }
.pipeline-state-table th:nth-child(5) { width: 18%; }
.pipeline-state-table th:nth-child(6) { width: 18%; }

.section-statistics-table th:nth-child(1) { width: 20%; }
.section-statistics-table th:nth-child(2) { width: 8%; }
.section-statistics-table th:nth-child(3) { width: 8%; }
.section-statistics-table th:nth-child(4) { width: 14%; }
.section-statistics-table th:nth-child(5) { width: 16%; }
.section-statistics-table th:nth-child(6) { width: 8%; }
.section-statistics-table th:nth-child(7) { width: 14%; }
.section-statistics-table th:nth-child(8) { width: 12%; }

.analytics-table th:nth-child(n + 3),
.section-statistics-table th:nth-child(n + 2),
.analytics-number {
    text-align: right;
}

.analytics-label {
    color: #34414b;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.analytics-number {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.analytics-value-button {
    padding: 2px 0;
    border: 0;
    border-bottom: 1px solid transparent;
    background: transparent;
    color: var(--accent-dark);
    font-size: inherit;
    font-weight: 750;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.analytics-value-button:hover,
.analytics-value-button:focus-visible,
.analytics-value-button.is-active {
    border-bottom-color: currentColor;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.analytics-group-row td {
    padding-top: 11px;
    padding-bottom: 8px;
    background: #eef4f5;
    color: #34505a;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .055em;
    text-transform: uppercase;
}

.analytics-total-row td {
    border-top: 2px solid var(--line-strong);
    background: #f2f6f7;
    color: #26343e;
    font-weight: 800;
}

.analytics-empty {
    height: 104px;
    color: var(--muted);
    font-size: 13px;
    text-align: center !important;
}

.deals-section {
    margin-top: 48px;
}

.deals-heading-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.deals-clear {
    width: auto;
    min-height: 34px;
    padding: 6px 10px;
    font-size: 11px;
}

.deals-clear[hidden] {
    display: none;
}

.deal-table-header,
.deal-row,
.deal-row.has-amount {
    display: grid;
    grid-template-columns: 20% 12% 13% 12% 11% 10% 12% 10%;
    gap: 0;
    width: 100%;
}

.deal-table-header {
    align-items: stretch;
    border-bottom: 1px solid var(--line);
    background: #f7fafb;
}

.deal-table-header span {
    min-width: 0;
    padding: 11px 6px;
    border-right: 1px solid var(--line);
    color: #76828b;
    font-size: 9px;
    font-weight: 750;
    letter-spacing: .035em;
    line-height: 1.25;
    overflow-wrap: anywhere;
    text-transform: uppercase;
}

.deal-table-header span:last-child,
.deal-row > span:last-child {
    border-right: 0;
}

.deals-list {
    min-width: 0;
}

.deal-row,
.deal-row.has-amount {
    align-items: stretch;
    min-height: 62px;
    padding: 0;
}

.deal-row > span {
    min-width: 0;
    padding: 11px 6px;
    border-right: 1px solid var(--line);
}

.deal-row__name {
    display: -webkit-box;
    align-self: stretch;
    overflow: hidden;
    font-size: 12px;
    line-height: 1.35;
    overflow-wrap: anywhere;
    text-overflow: ellipsis;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.deal-row__meta {
    display: block;
    min-width: 0;
}

.deal-row__meta small {
    display: none;
}

.deal-row__meta > span {
    display: block;
    overflow: visible;
    color: #59656f;
    font-size: 11px;
    line-height: 1.35;
    overflow-wrap: anywhere;
    text-overflow: clip;
    white-space: normal;
}

.deal-row__money > span {
    color: var(--accent-dark);
    font-weight: 740;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

@media (max-width: 820px) {
    .analytics-section__heading {
        align-items: stretch;
    }

    .analytics-selector {
        width: 100%;
    }

    .analytics-heading-actions {
        width: 100%;
        justify-content: space-between;
    }

    .analytics-heading-actions .analytics-selector {
        width: min(360px, 100%);
    }

    .analytics-table-wrap {
        overflow-x: auto;
    }

    .pipeline-state-table {
        min-width: 760px;
    }

    .section-statistics-table {
        min-width: 980px;
    }

    .plan-table-wrap {
        overflow-x: auto;
    }

    .plan-table {
        min-width: 1000px;
    }

    .section-heading--plan {
        align-items: stretch;
    }

    .plan-heading-actions {
        justify-content: space-between;
    }

    .plan-dialog__header {
        align-items: flex-start;
    }

    .deals-heading-actions {
        width: 100%;
        justify-content: space-between;
    }

    .deal-table-header {
        display: none;
    }

    .deal-row,
    .deal-row.has-amount {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px 18px;
        padding: 14px;
    }

    .deal-row > span {
        padding: 0;
        border-right: 0;
    }

    .deal-row__name {
        grid-column: 1 / -1;
    }

    .deal-row__meta small {
        display: block;
        margin-bottom: 3px;
    }

    .deal-row__money > span {
        text-align: left;
    }

}

@media (max-width: 560px) {
    .plan-section,
    .analytics-section,
    .deals-section {
        margin-top: 38px;
    }

    .plan-heading-actions,
    .plan-dialog__header-actions,
    .analytics-heading-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .analytics-heading-actions .analytics-selector,
    .analytics-heading-actions .button {
        width: 100%;
    }

    .plan-year-field {
        justify-content: space-between;
    }

    .plan-years-selector {
        width: min(100%, 260px);
    }

    .plan-heading-actions .button,
    .plan-dialog__header-actions .button {
        width: 100%;
    }

    .plan-dialog__header {
        gap: 12px;
    }

    .plan-dialog__header-actions {
        width: 100%;
    }

    .plan-dialog__close {
        position: absolute;
        top: 13px;
        right: 13px;
    }

    .deal-row,
    .deal-row.has-amount {
        grid-template-columns: 1fr;
    }

    .deal-row__name {
        grid-column: auto;
    }

    .plan-discard-confirmation {
        align-items: stretch;
        flex-direction: column;
    }

    .plan-discard-confirmation > div {
        flex-direction: column;
    }
}
