/* pos.css фиксирует вьюпорт для кассы — здесь документ скроллится целиком (как orders) */
body[data-page="contract-invoices"].pos-app {
    height: auto;
    min-height: 100vh;
    overflow: auto;
}

.ci-page {
    padding: 12px 16px 40px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ci-columns {
    display: grid;
    /* форма покупателя фиксированной ширины, таблица товаров занимает остальное */
    grid-template-columns: minmax(340px, 440px) minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}

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

.ci-card {
    background: var(--pos-surface, #fff);
    border: 1px solid var(--pos-line, #d7dee8);
    border-radius: var(--pos-radius, 12px);
    box-shadow: var(--pos-shadow, 0 1px 3px rgba(21, 32, 51, 0.06));
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ci-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.ci-card__head h2 {
    margin: 0;
    font-size: 17px;
    color: var(--pos-ink, #152033);
}

.ci-head-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex: 1;
    justify-content: flex-end;
    min-width: 200px;
}

.ci-label {
    color: var(--pos-muted, #64748b);
    font-size: 12.5px;
}

.ci-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 10px;
}

.ci-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 12px;
    color: var(--pos-muted, #64748b);
}

.ci-field--wide {
    grid-column: 1 / -1;
}

.ci-field input {
    font-size: 13px;
}

.ci-unp-row {
    display: flex;
    gap: 6px;
    align-items: stretch;
}

.ci-unp-row .ci-input {
    flex: 1;
    min-width: 0;
}

.ci-unp-row .pos-btn {
    white-space: nowrap;
    flex-shrink: 0;
}

.ci-egr-status {
    font-size: 11.5px;
    padding: 3px 8px;
    border-radius: 999px;
    display: inline-block;
}

.ci-egr-status--ok {
    background: #dcfce7;
    color: #15803d;
}

.ci-egr-status--warn {
    background: #fef3c7;
    color: #92400e;
}

.ci-egr-status--err {
    background: #fee2e2;
    color: #b91c1c;
}

.ci-input {
    background: #fff;
    border: 1px solid var(--pos-line, #d7dee8);
    border-radius: 8px;
    padding: 7px 10px;
    font: inherit;
    font-size: 13px;
    color: var(--pos-ink, #152033);
    width: 100%;
    box-sizing: border-box;
}

.ci-input:focus {
    outline: none;
    border-color: var(--pos-accent, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.ci-mono {
    font-family: "Consolas", "Courier New", monospace;
}

.ci-check {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 13px;
    color: var(--pos-ink, #152033);
}

.ci-meta-fields {
    display: flex;
    gap: 8px;
}

.ci-meta-fields .ci-field {
    min-width: 130px;
}

.ci-search {
    display: flex;
    gap: 8px;
}

.ci-search-results {
    border: 1px solid var(--pos-line, #d7dee8);
    border-radius: 8px;
    max-height: 220px;
    overflow-y: auto;
}

.ci-search-results__row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 7px 10px;
    border-bottom: 1px solid var(--pos-line, #d7dee8);
    cursor: pointer;
    font-size: 13px;
}

.ci-search-results__row:last-child {
    border-bottom: none;
}

.ci-search-results__row:hover {
    background: #f1f5f9;
}

.ci-search-results__name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ci-search-results__price {
    font-variant-numeric: tabular-nums;
    color: var(--pos-stock, #15803d);
    white-space: nowrap;
}

.ci-items-wrap {
    max-height: 320px;
    overflow-y: auto;
}

.ci-items-wrap input {
    width: 100%;
    min-width: 40px;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 4px 6px;
    font: inherit;
    font-size: 12.5px;
    background: transparent;
    box-sizing: border-box;
}

.ci-items-wrap input:hover,
.ci-items-wrap input:focus {
    border-color: var(--pos-line, #d7dee8);
    background: #fff;
    outline: none;
}

.ci-items-wrap .item-name {
    min-width: 220px;
}

.ci-mono-cell {
    font-family: "Consolas", "Courier New", monospace;
    font-variant-numeric: tabular-nums;
}

.ci-num-cell {
    font-variant-numeric: tabular-nums;
    text-align: right;
    width: 76px;
}

.ci-totals {
    display: flex;
    gap: 16px;
    justify-content: flex-end;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--pos-muted, #64748b);
    font-variant-numeric: tabular-nums;
}

.ci-totals__gross {
    color: var(--pos-ink, #152033);
    font-size: 14px;
}

.ci-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.ci-edit-banner {
    margin: 0;
    padding: 8px 12px;
    border: 1px solid #f59e0b;
    background: #fffbeb;
    color: #92400e;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.ci-edit-banner.hidden {
    display: none;
}

.ci-kind-tabs {
    font-size: 13px;
}

.ci-kind-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
}

.ci-kind-badge--contract {
    background: #dbeafe;
    color: #1d4ed8;
}

.ci-kind-badge--invoice {
    background: #dcfce7;
    color: #15803d;
}

/* ---- Реестр: признак оплаты ---- */

.ci-paid-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    background: #dcfce7;
    color: #15803d;
}

.ci-paid-badge--open {
    background: transparent;
    color: var(--pos-muted, #64748b);
}

/* ---- Диалог «Оплата по банковской выписке» ---- */

.pos-dialog--wide {
    width: min(720px, 92vw);
    max-height: 84vh;
    overflow: auto;
}

.ci-bank-file-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--pos-muted, #64748b);
}

.ci-bank-api-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
}

.ci-bank-api-row .ci-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    color: var(--pos-muted, #64748b);
}

.ci-bank-api-row input[type="date"] {
    max-width: 160px;
}

.ci-bank-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 0 10px;
    font-size: 12px;
    color: var(--pos-muted, #64748b);
}

.ci-bank-divider::before,
.ci-bank-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--pos-line, #d7dee8);
}

.ci-bank-summary {
    margin: 0;
    font-size: 13px;
    color: var(--pos-muted, #64748b);
}

.ci-bank-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 46vh;
    overflow: auto;
}

.ci-bank-record {
    border: 1px solid var(--pos-line, #d7dee8);
    border-radius: var(--pos-radius, 12px);
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ci-bank-record--nomatch {
    border-color: var(--pos-danger, #dc2626);
    background: #fef2f2;
}

.ci-bank-record__main {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    font-size: 13px;
    align-items: baseline;
}

.ci-bank-record__purpose {
    font-size: 12px;
    color: var(--pos-muted, #64748b);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ci-bank-corr {
    font-weight: 600;
}

.ci-bank-unp {
    color: var(--pos-accent, #2563eb);
    text-decoration: none;
    font-variant-numeric: tabular-nums;
}

.ci-bank-unp:hover {
    text-decoration: underline;
}

.ci-bank-select {
    max-width: 100%;
}


/* ---- Реестр: раскрытие состава документа ---- */

.ci-registry-toggle {
    width: 26px;
    height: 26px;
    border: 1px solid var(--pos-line, #d7dee8);
    border-radius: 8px;
    background: #fff;
    color: var(--pos-muted, #64748b);
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.ci-registry-toggle:hover {
    border-color: var(--pos-accent, #2563eb);
    color: var(--pos-accent, #2563eb);
}

.ci-registry-toggle.is-open {
    background: #eff6ff;
    border-color: var(--pos-accent, #2563eb);
    color: var(--pos-accent, #2563eb);
}

.ci-registry-toggle-cell {
    width: 40px;
    text-align: center;
}

.ci-registry-main {
    cursor: pointer;
}

.ci-registry-main td {
    vertical-align: middle;
}

.ci-registry-expand > td {
    background: #f8fafc;
    padding: 10px 12px 12px 44px;
    border-top: 1px dashed var(--pos-line, #d7dee8);
}

.ci-expand-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.ci-expand-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

.ci-expand-table th {
    text-align: left;
    font-weight: 600;
    color: var(--pos-muted, #64748b);
    padding: 4px 10px 6px 0;
    border-bottom: 1px solid var(--pos-line, #d7dee8);
}

.ci-expand-table td {
    padding: 4px 10px 4px 0;
    border-bottom: 1px solid #eef2f7;
    color: var(--pos-ink, #152033);
}

.ci-expand-table tr:last-child td {
    border-bottom: none;
}

.ci-expand-no {
    width: 28px;
    color: var(--pos-muted, #64748b);
}

.ci-expand-num {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.ci-registry {
    width: 100%;
}

.ci-file-links {
    display: flex;
    gap: 8px;
}

.ci-registry .pos-muted {
    text-align: center;
}

.ci-pdf-hint {
    margin: 0;
    font-size: 12.5px;
}
