.is-hidden {
    display: none !important;
}

#cpmDocModal.cpm-modal.is-open {
    display: grid;
    grid-template-columns: 20% 40% 40%;
    align-items: stretch;
    justify-items: center;
    gap: 0;
    padding: 0;
    border: 1px solid #2FBED2;

    background: var(--bg-log-reg);
    background-position: center center, center center;
    background-repeat: no-repeat, no-repeat;
    background-size: cover;
    overflow-y: hidden;
    animation: none;

}

#cpmDocsDock {
    grid-column: 1;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    border-right: 1px solid var(--accent-primary);
}

#cpmDocsDock section:not(.hero)::before {
    content: none;
}

#cpmDocsDock .cpm-card-title {
    border-bottom: none;
    padding-left: 0.75rem;
}

#cpmDocsDock .cpm-card {
    background: var(--bg-quindecennary);
    border-radius: 0;
    border: 0;
    box-shadow: none;
}

#cpmDocPreview {
    display: flex;
    justify-content: center;
    padding-bottom: var(--space-md);
}

#cpmDocsDock .cpm-docs-list {
    padding: 0.2rem 0.75rem var(--space-md);
}

#cpmDocsDock .cpm-docs-list li {
    box-shadow: 0 2px 4px 0 #FFFFFF40;
    flex-direction: column;
}

#cpmDocsDock .cpm-docs-list li .cpm-doc-name,
#cpmDocsDock .cpm-docs-list li .cpm-doc-meta {
    align-self: flex-start;

    width: 100%;
    flex: 0 0 auto;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    direction: rtl;
    text-align: left;
}

#cpmDocsDock .cpm-doc-actions-inline {
    justify-content: space-between;
    width: 100%;
}

#cpmDocModal .cpm-modal__dialog {
    grid-column: 2;
    width: 100%;
}

#cpmDocModal .cpm-modal__body {
    min-height: 0;
    display: flex;
    justify-content: center;
}


.cpm-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    z-index: 1;
    background: rgba(0, 0, 0, .5);
}

.cpm-modal.is-open {
    display: flex;
    z-index: 1100;
}

.cpm-modal__dialog {
    background: var(--bg-denecennary);
    border-radius: 0;
    box-shadow: var(--shadow-lg, 0 8px 30px rgba(0, 0, 0, .12));
    width: min(90vw, 900px);
    overflow: hidden;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    height: auto;
}

.cpm-modal__header,
.cpm-modal__footer {
    padding: var(--space-md, 16px) var(--space-lg, 20px);
    background: transparent;
    display: flex;
    max-height: 10vh;
    align-self: end;
}

.cpm-modal__body {
    overflow: hidden;
    min-height: 0;
}

.cpm-modal__title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}

.cpm-close-btn {
    background: transparent;
    border: 0;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    margin-left: auto;
}

#cpmDocModal.is-open .cpm-close-btn {
    margin: 0;

    z-index: 1300;

    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border-radius: 999px;

    background: transparent;
    color: var(--text-primary);
}

.cpm-doc-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 10px 3px #FFFFFF40;
    border: 3px solid var(--bg-nonenennary);
    border-radius: 20px;
    overflow: hidden;
    margin-top: var(--space-sm);
    position: relative;
    width: 95%;
    height: auto;
    max-height: 85vh;
}

.cpm-doc-scroll {
    scrollbar-width: thin;
    scrollbar-color: var(--bg-duodecennary) transparent;
    height: 100%;
    max-height: none;
}

.cpm-doc-scroll.has-overlay {
    scrollbar-width: none;
}

.cpm-doc-scroll.has-overlay::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.cpm-overlay-scrollbar {
    position: absolute;
    top: 8px;
    bottom: 8px;
    right: 5px;
    width: 5px;
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s ease;
    z-index: 5;
}

.cpm-doc-preview:hover .cpm-overlay-scrollbar,
.cpm-doc-preview.show-overlay .cpm-overlay-scrollbar {
    opacity: 1;
}

.cpm-overlay-scrollbar__thumb {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 40px;
    border-radius: 999px;
    background: var(--bg-duodecennary);
    box-shadow: var(--shadow-my-chats);
    pointer-events: auto;
    touch-action: none;
}

.cpm-doc-preview canvas {
    width: 100% !important;
    height: auto !important;
    display: block;
    border-radius: 0 !important;
}

.cpm-doc-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.cpm-doc-actions .cpm-btn {
    padding: 0.3rem 1rem 0.4rem;
    font-size: var(--font-size-md);
}

.cpm-doc-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.cpm-doc-name, .cpm-doc-meta {
    pointer-events: none;
    display: block;
    flex: 1;
    min-width: 0;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    direction: rtl;
    text-align: left;

    align-self: center;
}

.cpm-doc-actions-inline {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
}

.cpm-doc-analyze-btn {
    padding: 6px var(--space-lg);
    border-radius: 8px;
    border: 0;
    background: var(--accent-primary);
    color: #FFFFFF;
    font-weight: 600;
    cursor: pointer;
}

.cpm-doc-analyze-btn:hover {
    background: var(--accent-primary-hover);
}

.cpm-doc-analyze-btn[disabled] {
    opacity: .6;
    cursor: default;
}

.cpm-doc-delete-btn {
    display: inline-flex;
    align-items: center;
    justify-content: start;
    width: 32px;
    height: 32px;
    border: 0;
    background: transparent;
    cursor: pointer;
    border-radius: 6px;
    transition: transform .12s ease, background .12s ease, opacity .12s ease, stroke .12s ease;
}

.cpm-doc-delete-btn svg {
    fill: transparent;
}

.cpm-doc-delete-btn:hover svg path {
    stroke: var(--error-color, #ff6b6b);;
}

.cpm-doc-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    height: 100%;
    min-height: 0;
}

#cpmAnalysisDock {
    width: 100%;
    z-index: 1;
    pointer-events: none;
    display: none;
    grid-column: 3;
    overflow-y: auto;
    border-left: 1px solid #2FBED2;
}


#cpmAnalysisDock .cpm-ana {
    height: 100%;
    max-height: none;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    overflow-y: hidden;
}

@media (max-width: 900px) {
    .cpm-doc-layout {
        grid-template-columns: 1fr;
    }
}

.cpm-ana {
    background: transparent;
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    box-shadow: var(--shadow-sm, 0 2px 8px rgba(0, 0, 0, .15));
    display: flex;
    flex-direction: column;
    max-height: 70vh;
    overflow: hidden;
}

.cpm-ana.is-hidden {
    display: none;
}

.cpm-ana__head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: var(--space-sm) var(--space-md, 12px);
    border-bottom: 1px solid #2FBED2;
    justify-content: space-between;
    box-shadow: var(--shadow-my-chats);
    background-color: var(--bg-octodecennary);

}

.cpm-ana__title {
    font-weight: 700;
    font-size: 14px;
    letter-spacing: .4px;
}

.cpm-ana__quota {
    margin-left: auto;
    opacity: .7;
    font-size: 12px;
}

#cpmAnaSystem {
    border-bottom: 1px solid var(--text-muted);
    word-break: break-word;
}

.cpm-ana__container {
    overflow-y: auto !important;
}

.cpm-ana__section {
    margin-bottom: 10px;
    padding: var(--space-sm) var(--space-md, 12px);
}

.cpm-ana__type {
    font-size: var(--font-size-md);
    text-transform: uppercase;
    opacity: .8;
    margin: 6px 0 8px;
    color: var(--text-primary);
}

.cpm-ana__sysbtn {
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: 8px;
    background: var(--accent-primary);
    color: #FFFFFF;
    font-weight: 700;
    cursor: pointer;
    transition: opacity .15s ease;
}

.cpm-ana__sysbtn[disabled] {
    opacity: .6;
    cursor: default;
}

.cpm-ana__sysbtn:hover {
    background: var(--accent-primary-hover);
}

.cpm-ana__form {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    position: relative;
    border-radius: 15px;
}

.cpm-ana__form::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: transparent;
    border: 2px solid #2FBED2;
    filter: blur(2px);
    pointer-events: none;
    z-index: 0;
    mix-blend-mode: normal;
}

.cpm-ana__input {
    flex: 1 1 auto;
    border: 1px solid rgba(255, 255, 255, .1);
    background: var(--bg-primary);
    color: inherit;
    /*padding:8px 10px;*/
    display: flex;
    flex-direction: column;
    background-color: var(--bg-nonennary);
    border-radius: 15px;
    padding: var(--space-md);
    width: 100%;
    max-height: 50px;
    font-size: var(--font-size-md);
    padding-right: 75px;
}

.cpm-ana__input[disabled] {
    cursor: not-allowed;
}

.cpm-ana__send {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 7px;
    bottom: auto;
    background-color: var(--bg-tritennary);
    border: none;
    border-radius: 50px;
    width: 61px;
    height: 31px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color var(--transition-normal);
    align-self: flex-end;
    margin-right: 2px;
    box-shadow: 0 1px 4px 0 #FFFFFF40;
}

.cpm-ana__send svg {
    width: 30px;
    height: 30px;
    color: var(--bg-primary);
    margin-top: 1px;
}

#cpm-ana__send svg path {
    fill: var(--bg-primary);
}

.cpm-ana__send:hover {
    opacity: 0.9;
    cursor: pointer;
}

.cpm-ana__send[disabled] {
    opacity: .6;
    cursor: not-allowed;
}

.cpm-ana__list {
    margin-top: 10px;
    overflow: auto;
    padding-right: 6px;
    border-top: 3px dashed var(--text-muted);
    word-break: break-word;
}

.cpm-ana__item {
    padding: 10px 2px;
    border-bottom: 3px dashed var(--text-muted);
}

.cpm-ana__item small {
    opacity: .6;
    font-size: var(--font-size-md);
}

.cpm-ana__q {
    font-weight: 600;
    margin: 2px 0 4px;
    display: flex;
    justify-content: end;
}

.cpm-ana__q .user_message {
    background-color: var(--bg-quattuoretary);
    color: var(--text-primary);
    margin-right: 0.3rem;
    margin-left: auto;
    border-radius: 18px 18px 4px 18px;
    box-shadow: var(--shadow-sm);
    padding: var(--space-md);
    font-size: 18px;
    word-break: break-word;
    min-width: 40px;
    max-width: 100%;
}

.cpm-ana__a {
    white-space: pre-wrap;
    font-size: 18px;
}


.cpm-ana__section h1, .cpm-ana__a h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    padding-bottom: 0.4rem;
    line-height: 1.2;
}

.cpm-ana__section h1:first-of-type, .cpm-ana__a h1:first-of-type {
    margin-top: 0 !important;
}

.cpm-ana__section h2, .cpm-ana__a h2 {
    font-size: 17px;
    font-weight: 650;
    color: var(--text-primary);
    padding-bottom: 0.2rem;
    line-height: 1.3;
}

.cpm-ana__section h2:first-of-type, .cpm-ana__a h2:first-of-type {
    margin-top: 1.2rem !important;
}

.cpm-ana__section h3, .cpm-ana__a h3 {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
}

.cpm-ana__section h3:first-of-type, .cpm-ana__a h3:first-of-type {
    margin-top: 0 !important;
}

.cpm-ana__section h4, .cpm-ana__a h4 {
    font-size: 16px;
    font-weight: 550;
    color: var(--text-primary);
    line-height: 1.4;
    padding-top: 2rem;
}

.cpm-ana__section h4:first-of-type, .cpm-ana__a h4:first-of-type {
    margin-top: 0 !important;
}

.cpm-ana__section h5, .cpm-ana__a h5 {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: 0.04em;
    line-height: 1.4;
}

.cpm-ana__section h5:first-of-type, .cpm-ana__a h5:first-of-type {
    margin-top: 0 !important;
}

.cpm-ana__section hr, .cpm-ana__a hr {
    border: none;
    border-top: 1px solid var(--text-muted);
}

.cpm-ana__section p, .cpm-ana__a p {
    font-size: 16px;
    line-height: 1.7;
}

.cpm-ana__section strong, .cpm-ana__a strong {
    color: var(--text-primary);
    font-weight: 600;
    border-radius: 3px;
}

.cpm-ana__section a, .cpm-ana__a a {
    color: #66D9EF;
    text-decoration: underline;
}

.cpm-ana__section a:hover, .cpm-ana__a a:hover {
    color: #66D9EF;
    text-decoration: none;
}

.cpm-ana__section ol, .cpm-ana__a ol,
.cpm-ana__section ul, .cpm-ana__a ul {
    padding-left: 1.5em;
    font-size: 16px;
    margin-left: 0;
}

.cpm-ana__section ol, .cpm-ana__a ol {
    list-style-type: decimal;
}

.cpm-ana__section ul, .cpm-ana__a ul {
    list-style-type: disc;
}

.cpm-ana__section ol li, .cpm-ana__a ol li,
.cpm-ana__section ul li, .cpm-ana__a ul li {
    font-size: 16px;
}

.cpm-ana__section ol ol, .cpm-ana__a ol ol,
.cpm-ana__section ul ul, .cpm-ana__a ul ul,
.cpm-ana__section ol ul, .cpm-ana__a ol ul,
.cpm-ana__section ul ol, .cpm-ana__a ul ol {
    margin-top: 0.5em;
    margin-bottom: 0.5em;
}

.cpm-ana__section ol ol, .cpm-ana__a ol ol {
    list-style-type: lower-alpha;
}

.cpm-ana__section ul ul, .cpm-ana__a ul ul {
    list-style-type: circle;
}

.cpm-ana__section ol ol ol, .cpm-ana__a ol ol ol {
    list-style-type: lower-roman;
}

.cpm-ana__section ul ul ul, .cpm-ana__a ul ul ul {
    list-style-type: square;
}

.cpm-ana__section table, .cpm-ana__a table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
    font-size: 16px;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.cpm-ana__section th,
.cpm-ana__section td, .cpm-ana__a th, .cpm-ana__a td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--bg-secondary, #e0e0e0);
    vertical-align: top;
}

.cpm-ana__section th, .cpm-ana__a th {
    background-color: var(--accent-primary);
    color: var(--bg-primary);
    font-weight: 600;
    font-size: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cpm-ana__section td,
.cpm-ana__a td {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 16px;
}

.cpm-ana__section tbody tr:nth-child(even) td, .cpm-ana__a tbody tr:nth-child(even) td {
    background-color: var(--bg-tertiary);
}

.cpm-ana__section tbody tr:hover td, .cpm-ana__a tbody tr:hover td {
    background-color: rgba(102, 217, 239, 0.1);
    transition: background-color 0.2s ease;
}

.cpm-ana__section td:first-child, .cpm-ana__a td:first-child {
    font-weight: 500;
}

.cpm-ana__section td:last-child, .cpm-ana__a td:last-child {
    text-align: right;
    font-family: 'Courier New', monospace;
}

.cpm-ana__section tbody tr:last-child td, .cpm-ana__a tbody tr:last-child td {
    border-bottom: none;
}

.cpm-ana__section table.tax-calc, .cpm-ana__a table.tax-calc {
    border: 2px solid var(--accent-primary);
}

.cpm-ana__section table.tax-calc th, .cpm-ana__a table.tax-calc th {
    background-color: var(--accent-primary);
}

.cpm-ana__section table.tax-calc .total-row td, .cpm-ana__a table.tax-calc .total-row td {
    font-weight: bold;
    border-top: 2px solid var(--accent-primary);
    background-color: rgba(102, 217, 239, 0.1);
}

.cpm-docs-card {
    position: relative;
}

.cpm-docs-drop-overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 20;

    background: rgba(0, 0, 0, 0.35);
    border: 2px dashed var(--accent-primary);
    border-radius: var(--radius-lg, 12px);
    backdrop-filter: blur(2px);
}

.cpm-docs-drop-overlay.active {
    display: flex;
}

.cpm-docs-drop-overlay__inner {
    text-align: center;
    padding: 16px 24px;
}

.cpm-docs-drop-overlay__title {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 16px;
    line-height: 1.2;
}

.cpm-docs-drop-overlay__hint {
    color: var(--text-secondary);
    margin-top: 4px;
    font-size: 12px;
    opacity: 0.9;
}

@media (max-width: 1025px) {

    #cpmDocModal #cpmDocsDock {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: min(86vw, 420px);
        max-width: 100%;
        transform: translateX(-100%);
        transition: transform .25s ease;
        z-index: 1255;
        background: var(--bg-denecennary);
        box-shadow: 2px 0 16px rgba(0, 0, 0, .25);
        overflow: hidden;
    }

    #cpmDocModal.docs-dock-open #cpmDocsDock {
        transform: translateX(0);
    }

    #cpmDocModal .cpm-docs-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .35);
        z-index: 1200;
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s ease;
    }

    #cpmDocModal.docs-dock-open .cpm-docs-overlay {
        opacity: 1;
        pointer-events: auto;
    }

    #cpmDocModal.cpm-modal.is-open {
        position: fixed;
        inset: 0;
        display: grid;
        justify-items: center;
        align-items: start;
        gap: 0;
        height: 100dvh;
        overflow-y: auto;
        grid-template-columns: repeat(1, minmax(0, 1fr));
        z-index: 1200;
    }

    .cpm-modal__footer {
        justify-content: center;
    }

    #cpmDocModal .cpm-modal__dialog {
        display: grid;
        grid-template-rows: auto 1fr auto;
        min-height: 100vh;
        grid-column: 1 / -1;
        width: 100%;
        border-radius: 0;
        margin-bottom: 0;
    }

    #cpmAnalysisDock {
        grid-column: 1 / -1;
        border-top: 1px solid var(--accent-primary);
        border-left: 0;
        padding: 0 0 var(--space-md) 0;
    }

    #cpmAnalysisDock .cpm-ana {
        border-radius: 0;
    }

    .cpm-modal__dialog {
        padding-right: 0;
    }

    #cpmDocModal.is-open .cpm-close-btn {
        position: fixed;
        top: calc(env(safe-area-inset-top, 0px) + 8px);
        right: calc(env(safe-area-inset-right, 0px) + 25px);
    }

    #cpmDocModal.is-open .cpm-close-btn:focus-visible {
        outline: 2px solid var(--accent-primary);
        outline-offset: 2px;
    }
}

@media (max-width: 768px) {
    .cpm-ana__section table, .cpm-ana__a table {
        font-size: 14px;
    }

    .cpm-ana__section th, .cpm-ana__a th,
    .cpm-ana__section td, .cpm-ana__a td {
        padding: 8px 12px;
    }

    .cpm-ana__section th, .cpm-ana__a th {
        font-size: 14px;
    }

    .cpm-ana__section td, .cpm-ana__a td {
        font-size: 14px;
    }
}