.mobile-app-bar { display: none; }
.mobile-navigation:not([open]) { display: none; }
@media screen and (max-width: 820px) {
    *, *::before, *::after { box-sizing: border-box; }
    html { scroll-padding-top: 68px; }
    body { margin: 0; overflow-wrap: anywhere; }
    body:has(dialog[open]) { overflow: hidden; }
    input:not([type="checkbox"]):not([type="radio"]), select, textarea { font-size: 16px !important; min-width: 0; max-width: 100%; }
    button, .primary-button, .secondary-button, .document-link, .history-button, .history-export-button, .page-button, .upload-button, .mini-button, .link-button { min-height: 44px; touch-action: manipulation; }
    button, a, input, select, textarea { scroll-margin-block: 85px; }
    button, h1, h2, h3, label { letter-spacing: 0 !important; }
    button { white-space: normal; }
    input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; flex-shrink: 0; }
    label:has(input[type="checkbox"]), label:has(input[type="radio"]) { min-height: 44px; }
    .mobile-app-bar { display: flex; position: sticky; top: 0; z-index: 40; align-items: center; justify-content: space-between; gap: 12px; min-height: 58px; padding: 7px max(14px, env(safe-area-inset-left)); padding-top: max(7px, env(safe-area-inset-top)); background: #123825; color: #fff; }
    .mobile-brand { font-size: 22px; font-weight: 900; }
    .mobile-brand span { color: #a7d63d; }
    #mobile-menu-open { display: flex; align-items: center; gap: 8px; padding: 0 12px; color: #fff; border: 1px solid #557564; background: transparent; border-radius: 6px; font-weight: 700; }
    #mobile-menu-open > span { font-size: 22px; }
    dialog.mobile-navigation { position: fixed; inset: 0 auto 0 0; width: min(340px, 92%); max-width: 100%; height: 100dvh; max-height: var(--mobile-view-height, 100dvh); margin: 0; padding: 0; border: 0; border-radius: 0; background: #123825; color: #fff; overflow: auto; }
    .mobile-navigation::backdrop { background: rgb(0 0 0 / 45%); }
    .mobile-menu-close { position: sticky; top: 8px; z-index: 2; display: block; width: 44px; margin: 8px 12px -52px auto; padding: 0; border: 1px solid #557564; border-radius: 6px; color: #fff; background: #123825; font-size: 30px; }
    .mobile-navigation .sidebar { position: static; display: flex; width: 100%; min-height: 100%; height: auto; padding: 24px 14px max(20px, env(safe-area-inset-bottom)); overflow: visible; }
    .mobile-navigation .brand-row { padding-right: 52px; }
    .mobile-navigation .sidebar-label, .mobile-navigation .side-nav { display: block; }
    .mobile-navigation .side-nav { display: grid; gap: 4px; }
    .mobile-navigation .nav-item { min-height: 46px; }
    .mobile-navigation .nav-item span { min-width: 0; white-space: normal; }
    .mobile-navigation .nav-item b { flex-shrink: 0; }
    .mobile-navigation .sidebar-footer { display: flex; align-items: flex-start; flex-direction: column; gap: 4px; margin-top: 22px; }
    .mobile-navigation .sidebar-footer a { display: flex; align-items: center; min-height: 44px; }
    .app-shell { display: block; }
    .content { width: 100%; min-width: 0; padding: 18px 12px 32px; }
    .page-header { gap: 12px; }
    .page-header h1 { font-size: 25px; }
    .summary-chips { flex-wrap: wrap; justify-content: flex-start; max-width: 100%; }
    .summary-chips span { max-width: 100%; white-space: normal; }
    .search-panel { padding: 14px; }
    .search-box { min-width: 0; }
    .search-box input { min-height: 48px; }
    .filters-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .filters-grid label, .filters-grid > div { min-width: 0; }
    .results-section { border-radius: 8px; }
    .results-toolbar { align-items: stretch; padding: 10px 12px; gap: 10px; }
    .tabs { display: flex; width: 100%; max-width: 100%; gap: 16px; overflow-x: auto; overflow-y: hidden; }
    .tab { flex-shrink: 0; min-height: 44px; font-size: 14px; white-space: nowrap; }
    #results, .recipe-results, .returns-results { min-width: 0; width: 100%; }
    .cell-title, .cell-title b, .code, .article-group-identity h2 { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
    .article-group-head { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 16px 12px; }
    .article-group-identity, .article-group-toggle { grid-column: 1 / -1; }
    .article-group-identity h2 { font-size: 18px; }
    .article-group-metric b { font-size: 19px; }
    .article-group-price { grid-column: 1 / -1; }
    .article-group-metric b, .discount-condition span { white-space: normal; max-width: 100%; }
    .price-comparable { min-width: 0; max-width: 100%; grid-template-columns: minmax(0, 1fr); }
    .article-group-detail-summary, .document-overview, .offers-overview, .history-summary, .comparator-overview, .analytics-overview, .audit-overview, .service-overview { min-width: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 12px; }
    .company-group-head, .promotion-title { min-width: 0; flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px 12px; }
    .offers-policy { min-width: 0; }
    .document-overview > *, .history-summary > *, .audit-overview > *, .service-overview > * { min-width: 0; }
    .table-row.header, .article-group-row.header, .comparator-row.header, .strategic-product-row.header, .supplier-audit-row.header, .service-invoice-row.header, .recipe-head, .return-head { display: none; }
    #results .mobile-data-row, .mobile-data-row, .product-rank-table .mobile-data-row { display: grid; min-width: 0; width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 16px 12px; border-top: 1px solid #dbe5dd; align-items: start; }
    .mobile-data-row > *, .recipe-row > .sm-hide, .recipe-row > .md-hide, .return-row > .sm-hide { display: block; min-width: 0; max-width: 100%; text-align: left; white-space: normal; }
    .mobile-data-row > [data-mobile-label]:not([data-mobile-label=""])::before, .mobile-data-table td[data-mobile-label]:not([data-mobile-label=""])::before { content: attr(data-mobile-label); display: block; margin-bottom: 5px; color: #65716b; font-size: 12px; font-weight: 700; letter-spacing: 0; }
    .mobile-data-row > .cell-title, .mobile-data-row > .code-stack, .table-row.article > :nth-child(2), .table-row.article > :nth-child(3), .company-document > :first-child, .promotion-list > :nth-child(2), .promotion-list > :nth-child(3), .article-group-row > :first-child, .article-group-row > :nth-child(2), .comparator-row > :nth-child(2), .comparator-row > :nth-child(3), .strategic-product-row > :nth-child(2), .supplier-audit-row > :first-child, .service-invoice-row > :first-child, .recipe-row > :nth-child(2), .return-row > :nth-child(2), .return-row > :nth-child(3) { grid-column: 1 / -1; }
    .mobile-data-row > .rank-position { width: auto; height: auto; border-radius: 0; background: none; justify-self: start; }
    .mobile-data-row small { display: block; margin-top: 3px; font-size: 12px; }
    .mobile-data-row .document-link, .mobile-data-row .history-button { display: inline-flex; align-items: center; justify-content: center; }
    .mobile-data-row .row-actions { flex-wrap: wrap; }
    .analytics-dashboard, .services-dashboard { min-width: 0; padding: 10px; }
    .analytics-panel { padding: 14px 10px; border-radius: 8px; }
    .analytics-panel > header { gap: 14px; }
    .analytics-panel > header h2 { font-size: 20px; }
    .product-rank-controls { width: 100%; }
    .product-rank-controls label { width: 100%; }
    .product-rank-table { overflow: visible; }
    .provider-rank-row { grid-template-columns: 26px minmax(0, 1fr); gap: 10px; }
    .provider-rank-row > strong { grid-column: 2; }
    .provider-bar { grid-column: 2; }
    .comparison-suppliers, .comparison-supplier, .negotiation-grid, .service-company-grid { grid-template-columns: minmax(0, 1fr); }
    .comparison-supplier dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .price-alert { grid-template-columns: minmax(0, 1fr); gap: 12px; }
    .price-alert > * { min-width: 0; text-align: left; justify-items: start; }
    .price-change-side, .price-change-overview, .comparator-controls { grid-template-columns: minmax(0, 1fr); }
    .comparator-group > header, .service-heading { grid-template-columns: minmax(0, 1fr); }
    .comparator-group > header > *, .comparator-group-meta { min-width: 0; flex-wrap: wrap; }
    .comparator-row > span, .service-supplier-row > span { white-space: normal; }
    .service-supplier-row { grid-template-columns: minmax(0, 1fr); gap: 8px; }
    .service-chart, .history-chart { max-width: 100%; overflow-x: auto; }
    .service-chart svg, .history-chart svg { min-width: 0; width: 100%; height: auto; }
    dialog:not(.mobile-navigation) { position: fixed; inset: var(--mobile-view-top, 0px) 0 auto; width: 100%; max-width: 100%; height: var(--mobile-view-height, 100dvh); max-height: var(--mobile-view-height, 100dvh); margin: 0; padding: 0; border: 0; border-radius: 0; overflow-y: auto; overscroll-behavior: contain; }
    .history-head, .line-editor-head { position: relative; display: flex; align-items: flex-start; flex-direction: column; gap: 12px; padding: 16px 62px 14px 14px; }
    .history-head h2, .line-editor-head h2 { max-width: 100%; font-size: 22px; white-space: normal; }
    .history-head-actions { flex-wrap: wrap; justify-content: flex-start; gap: 8px; }
    .history-head .dialog-close, .line-editor-head .dialog-close { position: absolute; top: 10px; right: 10px; width: 44px; height: 44px; }
    .history-content, .line-editor-body, .editor-body, .recipe-content { padding: 14px; min-width: 0; }
    .line-editor-grid, .editor-grid { grid-template-columns: minmax(0, 1fr); }
    .line-editor-grid > *, .editor-grid > *, .ingredient-grid > *, .line-grid > * { min-width: 0; }
    .ingredient-grid, .line-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ingredient-grid .search-cell, .line-grid .search-cell, .line-grid .wide { grid-column: 1 / -1; }
    .ingredient-card-tools button { width: 44px; height: 44px; }
    .line-editor-actions, .editor-actions { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px max(12px, env(safe-area-inset-bottom)); background: #fff; z-index: 5; }
    .line-editor-actions > button { flex: 1 1 130px; }
    .editor-section-head, .ingredient-card-head, .recipe-fact, .return-fact { flex-wrap: wrap; }
    .recipe-top, .return-top, .file-zone { grid-template-columns: minmax(0, 1fr); }
    .recipe-actions, .returns-filters, .report-row-top, .sales-actions { gap: 10px; flex-wrap: wrap; }
    .recipe-actions > button, .returns-filters > button { flex: 1 1 130px; }
    .recipe-filter, .recipe-filter select, .returns-filters label, .returns-filters select { width: 100%; min-width: 0; }
    .with-button > span { display: flex; flex-wrap: wrap; gap: 8px; }
    .with-button > span > * { width: 100%; }
    .suggest-list { max-height: 220px; }
    .suggest-item { min-height: 52px; grid-template-columns: minmax(0, 1fr); }
    .suggest-item .price { grid-column: auto; grid-row: auto; }
    .mobile-data-table, .mobile-data-table tbody { display: block; min-width: 0; width: 100%; }
    .mobile-data-table thead { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
    .mobile-data-table tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 14px 10px; border-top: 1px solid #dbe5dd; }
    .mobile-data-table td, .mobile-data-table td.num { display: block; min-width: 0; max-width: 100%; padding: 0; border: 0; text-align: left; white-space: normal; overflow-wrap: anywhere; }
    .mobile-data-table td:first-child, .mobile-data-table td[colspan] { grid-column: 1 / -1; }
    .recipe-table-wrap, .history-table-wrap, .return-table-wrap { overflow: visible; }
    .recipe-thumb { width: 44px; height: 44px; }
    .report-grid, .report-totals, .report-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .recipe-toast { width: max-content; max-width: calc(100% - 24px); bottom: max(12px, env(safe-area-inset-bottom)); }
    .login-page { padding: 20px 12px; min-height: 100dvh; }
    .login-card { width: 100%; max-width: 460px; padding: 24px 18px; }
    .login-form button, .login-form a { width: 100%; }
    .users-shell, .users-layout, .users-panel { min-width: 0; width: 100%; }
    .users-layout { grid-template-columns: minmax(0, 1fr); }
    .users-actions, .users-search, .users-permission { flex-wrap: wrap; }
    .users-permission { grid-template-columns: minmax(0, 1fr); }
    .report { width: 100%; min-width: 0; margin: 0; padding: 16px 12px; border: 0; }
    .report-head, .report-grid, .kpi-grid, .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .report-head { display: block; }
    .report-meta { min-width: 0; width: 100%; margin-top: 12px; }
    .toolbar { position: static; flex-wrap: wrap; gap: 8px; padding: 12px; }
    .toolbar a, .toolbar button { min-height: 44px; display: inline-flex; align-items: center; }
    .toolbar > * { max-width: 100%; }
    .report h1 { font-size: 26px; }
    .report svg { max-width: 100%; height: auto; }
}
@media print {
    .mobile-app-bar, .mobile-navigation { display: none !important; }
}
