@media (max-width: 768px) {
    .table-responsive {
        font-size: 0.8125rem;
    }

    .form-control,
    .form-select {
        font-size: 16px;
    }

    table {
        font-size: 0.8125rem;
    }

    th, td {
        padding: 0.5rem 0.625rem;
    }

    .product-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

@media (max-width: 576px) {
    h1 { font-size: 1.375rem; }
    h2 { font-size: 1.125rem; }

    .btn-group-vertical {
        width: 100%;
    }

    .btn-group-vertical .btn {
        margin-bottom: 0.25rem;
    }
}

.btn {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-sm {
    min-height: 32px;
}

.form-control,
.form-select {
    min-height: 38px;
}

@media screen and (-webkit-min-device-pixel-ratio: 0) {
    select,
    textarea,
    input {
        font-size: 16px;
    }
}

@media (max-width: 991.98px) {
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }
}

/* Modern document item styling */
.product-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    align-items: center;
    padding: 1rem 1.1rem;
    margin-bottom: 0.85rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}

.product-item:last-child {
    margin-bottom: 0;
}

.product-item strong {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.product-item small,
.product-item .text-muted {
    color: var(--text-muted);
}

.product-item .remove-btn {
    min-width: 42px;
    min-height: 38px;
}

.existing-documents {
    min-height: 120px;
    max-height: 260px;
    overflow-y: auto;
}

.existing-document-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1rem;
    margin-bottom: 0.75rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.existing-document-card:last-child {
    margin-bottom: 0;
}

.existing-document-card .document-meta {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.4;
}

.client-info-panel {
    margin-top: 1.25rem;
    padding: 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
}

.client-summary {
    display: grid;
    gap: 0.55rem;
}

.client-summary .summary-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.client-summary div {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.client-summary strong {
    color: var(--text-primary);
}

    .client-row {
        cursor: pointer;
        transition: background var(--transition), border-color var(--transition);
    }

    .client-row:hover,
    .client-row:focus-visible {
        background: var(--bg-hover);
        outline: none;
    }

    .client-row.active {
        background: rgba(37, 99, 235, 0.12);
        border-color: rgba(37, 99, 235, 0.35);
    }

    .client-row-name {
        font-size: 0.95rem;
    }

    .document-card {
        background: var(--bg-surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        box-shadow: var(--shadow-sm);
    }

    .document-card-title {
        font-size: 0.95rem;
        color: var(--text-primary);
    }

    .document-list p {
        margin: 0;
    }

    .clients-page-row {
        align-items: stretch;
    }

    .clients-panel-card {
        display: flex;
        flex-direction: column;
    }

    .clients-panel-body {
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
    }

    .clients-list-wrapper,
    .tab-content {
        flex: 1;
        min-height: 0;
        overflow: auto;
    }

    .clients-list-wrapper {
        max-height: calc(100vh - 220px);
    }

    #client-details-card .clients-panel-body {
        max-height: calc(100vh - 220px);
    }

    .document-list {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

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