/* Shared mobile refinements. Keep scrolling inside wide lists, not the page. */
.bf-site img, .np-panel img { max-width: 100%; }
.bf-site :where(main, section, article, form, fieldset),
.np-panel :where(main, section, article, form, fieldset, .table-wrap, .dataTables_wrapper, .dt-container) { min-width: 0; }
.bf-site :where(p, h1, h2, h3, label), .np-panel :where(p, h1, h2, h3, label, strong) { overflow-wrap: anywhere; }
.bf-site .form-field input:not([type=checkbox]):not([type=radio]),
.bf-site .form-field select, .bf-site .form-field textarea { max-width: 100%; }
.np-panel .table-wrap, .np-panel .document-preview-table-wrap { max-width: 100%; overscroll-behavior-x: contain; }
.np-panel .np-dropdown-menu { max-width: calc(100vw - 28px); }
.np-panel .document-items-table input, .np-panel .document-items-table select, .np-panel .document-items-table textarea { border: 1px solid #cedbc5; border-radius: 8px; background: #fffefb; color: #193d33; padding: 10px; min-height: 44px; }
.bf-install-entry { padding: 12px 24px; text-align: center; }
.bf-install-entry:has([hidden]) { display: none; }
.np-sidebar-bottom .bf-install-entry { padding: 12px 0 0; text-align: left; }
.np-sidebar-bottom [data-pwa-open] { color: #f7f5ef; border-color: #789887; font-size: 12px; width: 100%; }
.bf-footer .bf-install-entry { text-align: left; padding: 0 0 20px; }
.bf-footer [data-pwa-open] { color: #f7f5ef; border-color: #789887; }
#pwa-install-modal { display: none; padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); overflow-y: auto; z-index: 1055; }
#pwa-install-modal.show { display: block; }
#pwa-install-modal .modal-dialog { margin: 0 auto; min-height: calc(100% - 24px); }
#pwa-install-modal .modal-content { color: #193d33; background: #fffefb; }
#pwa-install-modal .btn-primary { background: #245a48; border-color: #245a48; color: white; }
.bf-standalone .panel-topbar, .bf-standalone .bf-header { padding-top: env(safe-area-inset-top); }
.bf-standalone .panel-sidebar { padding-top: env(safe-area-inset-top); }
.bf-standalone .panel-main { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
.bf-site .checkbox-field { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.bf-site .checkbox-field input { flex: 0 0 20px; width: 20px; height: 20px; margin-top: 3px; }

@media (max-width: 991px) {
    .np-panel .panel-sidebar { height: 100dvh; max-width: calc(100vw - 32px); }
    .np-panel .panel-main { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
    .np-panel .document-builder-grid { grid-template-columns: minmax(0, 1fr); }
    .bf-site .bf-navigation { max-height: calc(100dvh - 85px); overflow-y: auto; overscroll-behavior: contain; }
}
@media (max-width: 767px) {
    .bf-site input:not([type=checkbox]):not([type=radio]), .bf-site select, .bf-site textarea,
    .np-panel input:not([type=checkbox]):not([type=radio]), .np-panel select, .np-panel textarea { font-size: 16px; }
    .bf-site :where(.bf-button, .btn, .bf-menu-toggle), .np-panel :where(.btn, .np-icon-button, .sidebar-nav a) { min-height: 44px; }
    .np-panel .np-workspace { max-width: 28vw; line-height: 1.4; }
    .np-panel .section-header { flex-wrap: wrap; gap: 14px; }
    .np-panel .section-actions { flex-wrap: wrap; gap: 8px; }
    .np-panel .form-grid, .np-panel .filters-grid, .np-panel .filters-form, .np-panel .document-preview-parties,
    .np-panel .document-preview-header, .np-panel .document-preview-meta { grid-template-columns: minmax(0, 1fr); }
    .np-panel .dataTables_wrapper .dt-buttons, .np-panel .dt-buttons { display: flex; flex-wrap: wrap; gap: 6px; float: none; }
    .np-panel .dataTables_filter, .np-panel .dataTables_length { float: none; text-align: left; margin-block: 12px; }
    .np-panel .dataTables_filter input { width: 100%; max-width: 100%; margin-left: 0; }
    .np-panel .pagination { flex-wrap: wrap; }
    .np-panel .document-items-table.has-item-labels { display: block; min-width: 0; width: 100%; }
    .np-panel .document-items-table.has-item-labels thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .np-panel .document-items-table.has-item-labels tbody { display: grid; gap: 16px; }
    .np-panel .document-items-table.has-item-labels tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid #dce3d5; border-radius: 12px; padding: 12px; gap: 12px; }
    .np-panel .document-items-table.has-item-labels td { display: block; min-width: 0; padding: 0; border: 0; }
    .np-panel .document-items-table.has-item-labels td:nth-child(-n+3), .np-panel .document-items-table.has-item-labels td:last-child { grid-column: 1 / -1; }
    .np-panel .document-items-table.has-item-labels td::before { content: attr(data-label); display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; }
    .np-panel .document-items-table.has-item-labels input, .np-panel .document-items-table.has-item-labels select, .np-panel .document-items-table.has-item-labels textarea { width: 100%; min-width: 0; }
    .np-panel .document-total-row { flex-wrap: wrap; }
    .np-panel .document-summary-card, .np-panel .document-preview-sheet { padding: 16px; }
    .bf-site .bf-footer-top { align-items: flex-start; }
    .bf-site .bf-footer-top .bf-button { max-width: 100%; white-space: normal; text-align: left; }
    .bf-site .bf-inner .form-actions { flex-wrap: wrap; }
    .bf-site .bf-inner .form-actions .btn { flex: 1 1 180px; }
}
@media (max-width: 380px) {
    .bf-site .bf-hero h1 { font-size: clamp(44px, 15vw, 58px); letter-spacing: -2px; }
    .bf-site .bf-hero-actions { align-items: flex-start; flex-direction: column; }
    .bf-site .bf-hero-actions .bf-text-link { font-size: 12px; }
    .bf-site .bf-footer h2 { font-size: 36px; }
}
@media (max-height: 500px) and (orientation: landscape) {
    .bf-site .bf-header, .np-panel .panel-topbar { position: relative; }
}
