/* Shared screen presentation. Receipts retain their dedicated print styles. */
@media screen {
    :root {
        --control-height: 2.85rem;
        --section-gap: 1.25rem;
    }
    .app-body { background: #f3f5f9; }
    .content { color: var(--ink); }
    .content :is(h2, h3) { text-wrap: balance; }
    .content :is(p, dd, .table-note) { overflow-wrap: anywhere; }
    .header-titles, .form-field, .detail-grid > *, .form-grid > *,
    .standard-form-grid > *, .product-fields-grid > * { min-width: 0; }
    .app-header { align-items: center; }
    .header-titles { flex: 1; }
    .app-header h1 { line-height: 1.25; }
    .user-menu, .user-avatar, .menu-toggle { flex-shrink: 0; }
    .page-actions, .dashboard-heading, .section-title-row, .cash-actions,
    .form-actions, .standard-form-actions { flex-wrap: wrap; }
    .page-actions { gap: .85rem 1.25rem; margin-bottom: var(--section-gap); }
    .page-actions > p { margin: 0; flex: 1 1 18rem; font-size: .9rem; }
    .page-actions > .action-group { justify-content: flex-end; }
    .action-group { align-items: stretch; }
    .panel { box-shadow: 0 2px 8px rgb(16 24 40 / 4%); }
    .panel:hover { box-shadow: 0 2px 8px rgb(16 24 40 / 4%); }
    .panel > h2:first-child { margin-top: 0; font-size: 1.1rem; }
    .panel.standard-form-card, .panel.product-form-section { padding: 0; }
    .standard-form-card-header, .product-section-heading { padding: 1rem 1.25rem; }
    .standard-form-intro p { max-width: 56rem; line-height: 1.6; }
    .standard-form-shell, .settings-form, .product-editor { gap: var(--section-gap); }
    .standard-form-grid, .product-fields-grid, .form-grid { align-items: start; }
    .form-field { align-content: start; }
    .form-field label { line-height: 1.4; }
    .form-field :is(input:not([type="checkbox"]):not([type="file"]):not([type="color"]), select) {
        height: var(--control-height); min-width: 0; max-width: 100%;
    }
    .form-field textarea { line-height: 1.5; }
    .form-field small { line-height: 1.5; }
    .form-field input[type="checkbox"] { min-height: 0; }
    .button { min-height: var(--control-height); line-height: 1.25; text-align: center; }
    .button:hover:not(:disabled) { transform: none; }
    .form-errors:empty { display: none; }
    .form-errors { line-height: 1.5; }
    .filter-bar, .history-filters {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
        align-items: end; gap: 1rem; margin-bottom: var(--section-gap);
    }
    .filter-bar { display: flex; flex-wrap: wrap; }
    .filter-bar > .form-field { flex: 1 1 12rem; }
    .filter-bar > :is(.filter-actions, .sales-filter-actions, .sales-filter-heading, .report-filter-errors) { flex: 1 0 100%; }
    .filter-bar > .button, .history-filters > .button { margin: 0; }
    .filter-bar .form-field { align-self: start; }
    .filter-bar .filter-search { grid-column: auto; }
    .sales-filter-heading, .report-filter-errors { grid-column: 1 / -1; }
    .filter-actions, .sales-filter-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; align-items: center; gap: .65rem; flex-wrap: wrap; padding-top: .75rem; border-top: 1px solid var(--border); }
    .filter-actions .button, .sales-filter-actions .button { min-width: 7rem; }
    .table-panel { padding: 1.25rem; }
    .responsive-table { max-width: 100%; overscroll-behavior-x: contain; }
    .responsive-table table { font-size: .875rem; }
    .responsive-table th { line-height: 1.4; vertical-align: middle; }
    .responsive-table :is(th, td) { padding: .9rem .8rem; }
    .responsive-table th:first-child { border-radius: .5rem 0 0 .5rem; }
    .responsive-table th:last-child { border-radius: 0 .5rem .5rem 0; }
    .responsive-table tbody tr:last-child td { border-bottom: 0; }
    .responsive-table td > a:not(.button) { font-weight: 600; text-decoration: none; }
    .responsive-table td > a:not(.button):hover { text-decoration: underline; }
    .responsive-table :is(th, td).numeric { text-align: right; font-variant-numeric: tabular-nums; }
    .responsive-table td.numeric { white-space: nowrap; }
    .responsive-table td.row-actions { display: table-cell; vertical-align: middle; }
    .table-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem .8rem; }
    .table-actions > form { display: inline-flex; margin: 0; }
    .table-actions :is(a, button) { display: inline-flex; align-items: center; min-height: 2.25rem; font-size: .8rem; font-weight: 650; text-decoration: none; white-space: nowrap; }
    .table-actions :is(a, button):hover { text-decoration: underline; }
    .responsive-table td[colspan] { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }
    .pagination { gap: .5rem 1rem; flex-wrap: wrap; font-size: .85rem; }
    .pagination a { display: inline-flex; align-items: center; min-height: 2.75rem; padding: .45rem .85rem; border: 1px solid var(--border); border-radius: .6rem; background: #fff; text-decoration: none; }
    .summary-card { min-width: 0; gap: .75rem; align-items: flex-start; flex-direction: column; }
    .summary-card strong, .finance-kpis strong, .report-kpis strong,
    .dashboard-kpis strong, .sales-summary strong, .cash-expected strong,
    .sale-totals strong, .sale-detail-totals strong { font-variant-numeric: tabular-nums; }
    .summary-card strong { font-size: clamp(1.25rem, 2vw, 1.6rem); line-height: 1.25; }
    .finance-kpis article, .report-kpis article, .dashboard-kpis article { align-content: start; }
    .finance-kpis article { padding: 1.25rem; border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); }
    .finance-kpis strong, .report-kpis strong { overflow-wrap: anywhere; }
    .detail-list dd { color: var(--ink-strong); font-weight: 550; }
    .detail-list dt { line-height: 1.4; }
    .report-hub > a { align-content: start; min-height: 9rem; transition: border-color 150ms ease, box-shadow 150ms ease; }
    .report-hub > a:hover { box-shadow: var(--shadow-sm); }
    .report-hub h2 { margin: 0; font-size: 1.1rem; }
    .category-layout { display: grid; grid-template-columns: minmax(16rem, .8fr) minmax(0, 1.4fr); align-items: start; gap: var(--section-gap); }
    .pos-errors { margin-bottom: var(--section-gap); }
    .pos-products { display: grid; gap: 1rem; }
    .pos-search-panel .category-chips { margin-bottom: 0; }
    .product-card { align-content: start; }
    .product-card strong { overflow-wrap: anywhere; }
    .current-sale-heading, .customer-selection { flex-wrap: wrap; }
    .payment-fields > .form-field:has(textarea) { grid-column: 1 / -1; }
    .sale-totals { padding: 1rem; border: 1px solid var(--border); border-radius: .75rem; background: var(--surface-soft); }
    .cart-controls { flex-wrap: wrap; }
    .cart-controls button, .cart-controls input { min-height: 2.5rem; }
    .cart-controls .remove-cart-item { width: auto; margin-left: auto; padding-inline: .65rem; color: var(--danger); }
    .cash-heading h2 { margin: .5rem 0 .25rem; }
    .cash-heading p { margin: 0; color: var(--muted); }
    .cash-breakdown, .finance-breakdown { grid-template-columns: minmax(0, 1fr) auto; }
    .cash-breakdown strong, .finance-breakdown strong { font-variant-numeric: tabular-nums; }
    .module-option, .product-toggle, .form-switch-field { min-width: 0; }
    .switch-control { flex-shrink: 0; }
    .switch-control input { min-height: 0; }
}
@media screen and (min-width: 901px) and (max-width: 1200px) {
    .pos-layout { grid-template-columns: minmax(0, 1fr) minmax(19rem, 1fr); }
    .pos-search-row { flex-wrap: wrap; }
    .pos-search-row input { flex: 1 1 100%; }
    .product-results { grid-template-columns: 1fr; }
    .form-section { grid-template-columns: 1fr; gap: 1rem; }
    .dashboard-kpis, .report-kpis, .finance-kpis, .cash-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media screen and (max-width: 900px) {
    .sidebar:not(.open) { box-shadow: none; }
    .category-layout { grid-template-columns: minmax(0, 1fr); }
    .filter-bar, .history-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filter-bar > .form-field { flex-basis: calc(50% - .5rem); }
    .sales-filter-actions { grid-column: 1 / -1; }
    .standard-form-summary, .sale-metadata, .customer-profile, .cash-session-detail,
    .expense-detail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media screen and (max-width: 640px) {
    .content { width: calc(100% - 1.5rem); }
    .app-header { gap: .6rem; }
    .app-header h1 { font-size: 1.15rem; overflow-wrap: anywhere; }
    .page-actions > p { flex: auto; }
    .page-actions > .action-group { width: 100%; justify-content: flex-start; }
    .page-actions .action-group > .button { flex: 1 1 9rem; }
    .filter-bar, .history-filters { grid-template-columns: minmax(0, 1fr); padding: 1rem; }
    .history-filters { padding: 0; }
    .filter-bar > .form-field { flex-basis: 100%; }
    .filter-actions, .sales-filter-actions { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filter-actions .button:only-child { grid-column: 1 / -1; }
    .panel.standard-form-card, .panel.product-form-section { padding: 0; }
    .standard-form-card-header, .product-section-heading { padding: 1rem; }
    .standard-form-actions, .product-form-actions > div { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cash-actions .button { flex: 1 1 8rem; }
    .table-panel { padding: .85rem; }
    .responsive-table :is(th, td) { padding: .5rem .25rem; }
    .responsive-table td[data-label] { display: grid; grid-template-columns: minmax(5rem, 34%) minmax(0, 1fr); gap: .65rem; align-items: start; overflow-wrap: anywhere; }
    .responsive-table td[data-label]::before { text-align: left; }
    .responsive-table td.numeric { white-space: normal; }
    .responsive-table td.row-actions { display: grid; }
    .table-actions { gap: .25rem .65rem; }
    .responsive-table td[colspan] { display: block; }
    .responsive-table td .table-note { grid-column: 2; }
    .responsive-table td :is(.status, .stock-status) { justify-self: start; }
    .summary-card { flex-direction: row; align-items: center; }
    .summary-card span { flex: 1; }
    .standard-form-summary, .sale-metadata, .customer-profile, .cash-session-detail,
    .expense-detail { grid-template-columns: minmax(0, 1fr); }
    .pos-search-row { flex-wrap: wrap; }
    .pos-search-row input { flex: 1 1 100%; }
    .sunmi-scan-button { width: 100%; }
    .discount-fields, .payment-fields { grid-template-columns: minmax(0, 1fr); }
    .payment-fields > .form-field:has(textarea) { grid-column: auto; }
    .current-sale-heading h2 { font-size: 1.1rem; }
    .current-sale-heading { gap: .4rem; }
    .sale-totals { margin-block: .5rem; }
    .settings-save-bar, .product-form-actions { position: static; }
    .module-option { gap: .75rem; padding: .85rem; }
    .module-option-icon { width: 2.25rem; height: 2.25rem; }
    .sales-summary article { align-items: flex-start; }
    .sales-summary strong { overflow-wrap: anywhere; }
    .form-field :is(input, select, textarea) { font-size: 1rem; }
}
@media screen and (max-width: 380px) {
    .standard-form-actions, .product-form-actions > div, .sales-summary,
    .dashboard-quick .action-group { grid-template-columns: minmax(0, 1fr); }
    .module-option { grid-template-columns: minmax(0, 1fr) auto; }
    .module-option-icon { display: none; }
    .summary-card { flex-direction: column; align-items: flex-start; }
}
@media screen and (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { transition: none !important; }
}
