/* Responsive layout: one workflow on compact screens, two panes where they fit. */
:root { --screen-height: 100vh; }
@supports (height: 100dvh) { :root { --screen-height: 100dvh; } }
html { min-width: 0; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { min-width: 280px; }
body.modal-open { overflow: hidden; }
#app { min-height: 100vh; min-height: 100dvh; }
button, a, input, select { touch-action: manipulation; }
input, select, textarea, .search-field input, .field input, .field select { font-size: 16px; }
button, .button, .button.small, .icon-button, .filter-tab, .actions-button, .table-label { min-height: 44px; }
.icon-button { width: 44px; min-width: 44px; height: 44px; }
.text-button { min-height: 44px; padding: 8px 4px; }
.product-name, .product-en, .cart-item-name, .table-product, .page-heading, .held-card, .receipt { overflow-wrap: anywhere; }
.product-meta { flex-wrap: wrap; gap: 6px 10px; }
.product-meta .price { margin-inline-start: auto; }
.product-en, .sku { font-size: 12px; }
.product-name { padding-inline-end: 18px; }
.line-total { display: flex; align-items: flex-end; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.remove-item { min-width: 44px; width: 44px; min-height: 44px; padding: 10px; margin: 0; border: 1px solid #e1e4ec; border-radius: 7px; }
.remove-item svg { width: 16px; height: 16px; }
.quantity-control { width: 128px; height: 44px; flex-shrink: 0; }
.quantity-control button { width: 44px; min-width: 44px; min-height: 44px; }
.quantity-control span { font-size: 14px; min-width: 30px; text-align: center; }
.quantity-control button svg { width: 16px; height: 16px; }
.app-header { height: calc(68px + env(safe-area-inset-top, 0px)); padding-top: env(safe-area-inset-top, 0px); padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); }
.brand { gap: 8px; white-space: nowrap; }
.brand-title { font-size: 17px; }
.brand-mark { width: 34px; height: 38px; }
.brand-subtitle { font-size: 12px; }
.register-close { padding: 8px; font-size: 14px; }
.user-button { padding: 5px; gap: 7px; }
.app-nav { min-height: 54px; padding-inline: max(12px, env(safe-area-inset-left, 0px)); gap: 10px; }
.nav-tab { padding: 13px 12px; font-size: 14px; }
.branch-label { font-size: 12px; flex-wrap: wrap; justify-content: flex-end; }
.workspace { display: block; width: 100%; height: auto; min-height: 0; max-width: 2400px; margin-inline: auto; padding: 18px max(14px, env(safe-area-inset-right, 0px)) 20px max(14px, env(safe-area-inset-left, 0px)); overflow: visible; }
.menu-panel { min-height: 0; }
.menu-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding-bottom: 16px; min-height: 0; }
.section-heading { min-width: 0; }
.section-heading h1 { font-size: clamp(20px, 2.2vw, 25px); }
.section-heading p { font-size: 13px; }
.menu-select { max-width: 160px; min-width: 108px; min-height: 46px; }
.menu-toolbar .search-field { grid-column: 1 / -1; width: 100%; min-height: 46px; }
.search-field { height: 46px; }
.menu-body { display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.category-rail { width: 100%; min-width: 0; max-width: 100%; flex-direction: row; flex-shrink: 0; gap: 5px; overflow-x: auto; overflow-y: hidden; padding: 5px; -webkit-overflow-scrolling: touch; overscroll-behavior-inline: contain; }
.category-button { flex: 0 0 86px; min-height: 76px; gap: 6px; padding: 10px 6px; font-size: 14px; }
.category-button svg { width: 24px; height: 24px; }
.catalog { min-width: 0; overflow: visible; }
.catalog-meta { gap: 10px; font-size: 13px; align-items: center; }
.catalog-meta > span:last-child { text-align: left; }
.product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.product-tile { min-height: 145px; padding: 15px 12px 12px; }
.product-name { font-size: 16px; }
.price { font-size: 16px; }
.price small { font-size: 12px; }
.suggestions-heading { margin-top: 20px; }
.order-panel { display: none; height: auto; min-height: 0; width: 100%; max-width: 760px; margin-inline: auto; container: order / inline-size; overflow: hidden; }
#app[data-mobile-view="cart"] .menu-panel { display: none; }
#app[data-mobile-view="cart"] .order-panel { display: flex; }
.order-heading { padding: 14px; flex-shrink: 0; }
.table-heading { min-width: 0; gap: 8px; }
.table-label { font-size: 17px; }
.order-tools { gap: 6px; }
.actions-button { padding: 8px 10px; font-size: 14px; }
.dropdown-menu { width: min(220px, calc(100vw - 56px)); }
.dropdown-menu button { min-height: 46px; font-size: 14px; }
.customer-button { flex-shrink: 0; margin: 12px 14px 6px; min-height: 46px; font-size: 14px; }
.cart-header { display: grid; grid-template-columns: minmax(0, 1fr) auto; padding: 12px 14px; gap: 12px; font-size: 13px; flex-shrink: 0; }
.cart-header > :first-child { display: none; }
.cart-list { flex: 1 0 auto; min-height: 100px; padding-inline: 14px; overflow: visible; }
.cart-item { grid-template-columns: minmax(0, 1fr) auto; gap: 10px 12px; padding: 14px 0; }
.cart-item > .quantity-control { grid-column: 1; grid-row: 2; justify-self: start; }
.cart-item > .quantity-control + div { grid-column: 1; grid-row: 1; }
.cart-item > .line-total { grid-column: 2; grid-row: 1 / span 2; flex-direction: column; justify-content: center; }
.cart-item-name { font-size: 16px; }
.cart-item-price { font-size: 13px; }
.tax-inline { font-size: 12px; padding: 12px 0; }
.order-bottom { padding: 0 14px 14px; flex-shrink: 0; }
.order-bottom .order-summary { margin-inline: -14px; padding: 14px; }
.summary-row { font-size: 14px; margin-bottom: 7px; }
.order-bottom .summary-row.grand-total { padding-top: 10px; margin: 8px 0 0; }
.grand-total > strong:first-child { font-size: 17px; }
.grand-total > strong:last-child { font-size: clamp(24px, 3vw, 30px); }
.order-time { font-size: 12px; gap: 6px; margin: 10px 0; flex-wrap: wrap; }
.payment-methods { margin: 10px 0; }
.payment-method { min-height: 48px; font-size: 14px; gap: 6px; }
.quick-cash { gap: 7px; margin-bottom: 10px; }
.quick-cash button { height: auto; min-height: 52px; font-size: 14px; overflow-wrap: anywhere; }
.quick-cash small { font-size: 11px; }
.checkout-button { min-height: 52px; padding: 12px 14px; font-size: 16px; }
.checkout-button > span:last-child { flex-wrap: wrap; justify-content: flex-end; }
.local-note { font-size: 12px; margin-top: 10px; line-height: 1.7; }
.compact-nav { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 8px; position: fixed; z-index: 20; bottom: 0; left: 0; right: 0; padding: 10px max(12px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px)); background: #ffffff; border-top: 1px solid #e1e4ec; box-shadow: 0 -8px 24px #22243a12; }
.compact-nav button { display: flex; align-items: center; justify-content: center; min-width: 0; gap: 7px; min-height: 50px; padding: 10px 12px; background: #ffffff; border: 1px solid #e1e4ec; border-radius: 9px; font-size: 14px; }
.compact-nav button[aria-pressed="true"] { background: #3b82f6; border-color: #7350df; color: #ffffff; }
.compact-nav button strong { margin-inline-start: auto; font-size: 15px; white-space: nowrap; }
.compact-nav button small { font-size: 11px; }
.compact-count { display: inline-block; min-width: 20px; padding-inline: 4px; border-radius: 5px; background: #ffffff; font-size: 12px; }
.compact-nav ~ .status-bar { padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px)); }
.status-bar { min-height: 40px; padding: 10px 16px; gap: 10px; flex-wrap: wrap; font-size: 12px; }
.status-bar .desktop-hint { display: none; }
.toast-container { bottom: calc(90px + env(safe-area-inset-bottom, 0px)); }
.modal-open .compact-nav { visibility: hidden; }

/* Order rows use the available panel width, independent of the device model. */
@container order (min-width: 440px) {
 .cart-header, .cart-item { grid-template-columns: 128px minmax(0, 1fr) 98px; }
 .cart-header > :first-child { display: block; }
 .cart-item > .quantity-control { grid-column: 1; grid-row: 1; }
 .cart-item > .quantity-control + div { grid-column: 2; grid-row: 1; }
 .cart-item > .line-total { grid-column: 3; grid-row: 1; flex-direction: row; align-items: center; gap: 4px; }
 .cart-item-name { font-size: 14px; }
 .cart-item { padding-block: 12px; }
}

/* Administration and dialogs work with touch, narrow widths and keyboards. */
.admin-layout { display: block; min-height: 0; }
.admin-sidebar { display: flex; gap: 6px; padding: 10px 14px; overflow-x: auto; border: 0; border-bottom: 1px solid #e1e4ec; }
.sidebar-label, .sidebar-note { display: none; }
.admin-nav-item { width: auto; flex: 0 0 auto; margin: 0; min-height: 46px; padding: 10px 13px; white-space: nowrap; font-size: 14px; }
.admin-content { padding: 22px 16px; }
.page-heading { flex-wrap: wrap; gap: 16px; }
.page-heading > div { min-width: 0; flex: 1 1 220px; }
.page-heading h1 { font-size: clamp(21px, 3vw, 28px); }
.page-heading .button { flex-shrink: 0; }
.stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stat-card { padding: 18px 14px; }
.stat-label { font-size: 14px; line-height: 1.7; }
.stat-value { font-size: clamp(23px, 3vw, 32px); overflow-wrap: anywhere; }
.stat-foot { font-size: 12px; }
.dashboard-grid { grid-template-columns: 1fr; }
.category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.table-wrapper { max-width: 100%; overscroll-behavior-inline: contain; -webkit-overflow-scrolling: touch; }
.data-table th { font-size: 13px; }
.filter-row .search-field { flex: 1 1 220px; width: auto; }
.filter-tabs { flex-wrap: wrap; }
.filter-tab { min-height: 44px; font-size: 14px; }
.modal { position: fixed; inset: auto 0; top: calc(var(--visual-top, 0px) + var(--visual-height, 100vh) / 2); transform: translateY(-50%); margin: 0 auto; width: calc(100% - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)); max-width: 490px; max-height: calc(var(--visual-height, 100vh) - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); overflow: hidden; padding: 0; }
.modal[open] { display: flex; flex-direction: column; }
.modal-header { padding: 12px 18px; gap: 12px; flex-shrink: 0; }
.modal-header h2 { font-size: 18px; overflow-wrap: anywhere; }
.modal-body { min-height: 0; overflow-y: auto; padding: 20px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.modal-footer { flex-shrink: 0; flex-wrap: wrap; gap: 10px; padding: 12px 18px; }
.modal-footer .button { flex: 1 1 130px; min-width: 0; min-height: 48px; }
.form-grid { gap: 16px; }
.field { font-size: 14px; }
.field input, .field select { min-height: 48px; }
.color-options { flex-wrap: wrap; gap: 10px; }
.color-dot { width: 44px; height: 44px; }
.payment-total > strong { font-size: clamp(28px, 8vw, 42px); overflow-wrap: anywhere; }
.cash-options { gap: 6px; }
.cash-options button { font-size: 14px; min-height: 46px; padding: 8px 3px; overflow-wrap: anywhere; }
.held-card { flex-wrap: wrap; }
.receipt-table { table-layout: fixed; }
.receipt-table th:first-child { width: 52%; }
.receipt-table th:nth-child(2) { width: 16%; }
.receipt-table th:last-child { width: 32%; }
.receipt-table td, .receipt-table th { overflow-wrap: anywhere; }
.receipt-meta { gap: 10px; }
.register-closed { min-height: calc(var(--screen-height) - 160px); }

@media screen and (min-width: 520px) {
 .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media screen and (min-width: 700px) {
 .product-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
 .menu-toolbar { grid-template-columns: minmax(0, 1fr) auto minmax(210px, 1fr); align-items: center; }
 .menu-toolbar .search-field { grid-column: auto; }
}

/* Two panes only when both the width and height can accommodate them. */
@media screen and (min-width: 960px) and (min-height: 641px) {
 #app { display: flex; flex-direction: column; }
 .app-header { height: calc(72px + env(safe-area-inset-top, 0px)); padding-inline: 24px; flex-shrink: 0; }
 .app-nav { height: 54px; min-height: 54px; padding-inline: 24px; flex-shrink: 0; }
 .workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(370px, 35%); height: calc(var(--screen-height) - 166px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); min-height: 0; padding: 18px 20px; gap: 18px; overflow: hidden; flex: none; }
 #app[data-mobile-view] .menu-panel { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
 #app[data-mobile-view] .order-panel { display: flex; height: 100%; min-height: 0; max-width: none; overflow-y: auto; overscroll-behavior: contain; }
 .menu-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; flex-shrink: 0; }
 .menu-toolbar .search-field { grid-column: 1 / -1; }
 .menu-body { min-height: 0; flex: 1; }
 .catalog { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-inline-end: 5px; padding-bottom: 5px; }
 .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
 .category-rail { max-height: 100%; }
 .order-bottom { margin-top: auto; }
 .order-panel .cart-list { flex: 1 0 auto; min-height: 140px; }
 .order-panel .cart-header, .order-panel .order-heading { flex-shrink: 0; }
 .compact-nav { display: none; }
 .compact-nav ~ .status-bar, .status-bar { height: 40px; min-height: 40px; padding: 8px 20px; flex-shrink: 0; }
 .status-bar .desktop-hint { display: flex; }
 .toast-container { bottom: 24px; }
 .admin-layout { display: grid; grid-template-columns: 205px minmax(0, 1fr); flex: 1; }
 .admin-sidebar { display: block; overflow: visible; border-inline-end: 1px solid #e1e4ec; border-bottom: 0; padding: 24px 12px; }
 .admin-nav-item { width: 100%; margin-bottom: 5px; white-space: normal; }
 .sidebar-label, .sidebar-note { display: block; }
 .sidebar-note { display: flex; }
 .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media screen and (min-width: 1200px) and (min-height: 641px) {
 .product-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
 .menu-toolbar { grid-template-columns: minmax(0, 1fr) auto minmax(210px, 1fr); }
 .menu-toolbar .search-field { grid-column: auto; }
 .menu-body { flex-direction: row; gap: 14px; }
 .category-rail { width: 86px; min-width: 86px; flex-direction: column; overflow-y: auto; overflow-x: hidden; }
 .category-button { flex: 0 0 auto; min-height: 78px; }
 .admin-content { padding: 28px; }
 .stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
 .dashboard-grid { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
 .category-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media screen and (min-width: 1350px) and (min-height: 641px) {
 .product-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
 .product-tile { min-height: 145px; }
}
@media screen and (min-width: 1800px) and (min-height: 641px) {
 .workspace { padding-inline: 28px; gap: 24px; }
 .product-tile { min-height: 160px; padding: 18px 15px 14px; }
 .product-name { font-size: 18px; }
}
@media screen and (max-width: 959px), screen and (max-height: 640px) {
 .user-button strong, .user-button small { display: none; }
 .admin-content { padding-bottom: 30px; }
}
@media screen and (max-width: 599px) {
 .brand-subtitle { display: none; }
 .brand-title { font-size: 16px; }
 .branch-label .badge, .branch-label > svg { display: none; }
 .category-grid { grid-template-columns: 1fr; }
 .form-grid { grid-template-columns: 1fr; }
 .field.full { grid-column: auto; }
 .modal-body { padding: 16px; }
 .page-heading { gap: 12px; }
 .page-heading > .button { width: 100%; }
 .filter-tabs { width: 100%; }
 .filter-tab { flex: 1; padding-inline: 8px; }
 .data-table, .data-table tbody { display: block; width: 100%; white-space: normal; }
 .data-table thead { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
 .data-table tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; padding: 16px; border-bottom: 1px solid #e1e4ec; }
 .data-table td { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; border: 0; padding: 0; overflow-wrap: anywhere; font-size: 14px; }
 .data-table td::before { content: attr(data-label); font-size: 12px; font-weight: 400; color: #596176; }
 .data-table td:first-child, .data-table td:last-child { grid-column: 1 / -1; }
 .data-table td:last-child { flex-direction: row; align-items: center; justify-content: space-between; }
 .table-product { min-width: 0; }
 .table-product .product-dot { flex-shrink: 0; }
 .data-table td > .badge { min-height: 40px; }
 .surface > .filter-row { padding: 14px; }
 .receipt-meta { font-size: 12px; }
}
@media screen and (max-width: 359px) {
 .app-header { padding-inline: 8px; }
 .brand { gap: 5px; }
 .brand-title { font-size: 14px; }
 .brand-mark { width: 28px; height: 32px; }
 .user-button > svg { display: none; }
 .register-close { font-size: 12px; gap: 4px; }
 .branch-label { display: none; }
 .workspace { padding-inline: 10px; }
 .catalog-meta > span:last-child { display: none; }
 .product-tile { padding: 12px 9px; }
 .product-name { font-size: 15px; }
 .product-meta .price { width: 100%; justify-content: flex-end; margin: 0; }
 .compact-nav { gap: 6px; padding-inline: 8px; grid-template-columns: minmax(0, 1fr) minmax(0, 2.1fr); }
 .compact-nav button { gap: 5px; padding-inline: 8px; font-size: 13px; }
 .compact-nav button strong { font-size: 14px; }
 .compact-nav svg { width: 17px; height: 17px; }
 .compact-count { display: none; }
 .stats-grid { grid-template-columns: 1fr; }
 .order-heading { padding: 12px; }
 .table-heading > svg { display: none; }
 .payment-method { gap: 4px; font-size: 13px; }
 .quick-cash button { font-size: 13px; }
}
@media screen and (max-height: 500px) {
 .app-header { height: calc(58px + env(safe-area-inset-top, 0px)); }
 .brand-subtitle { display: none; }
 .app-nav { min-height: 48px; }
 .nav-tab { padding-block: 10px; }
 .compact-nav { padding-top: 6px; padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)); }
 .compact-nav button { min-height: 44px; padding-block: 7px; }
 .modal-header { padding-block: 6px; }
 .modal-footer { padding-block: 8px; }
 .modal-body { padding-block: 14px; }
}
@media (hover: none) {
 .product-tile:hover { transform: none; filter: none; }
}
@media (prefers-reduced-motion: reduce) {
 *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media print {
 :root { color-scheme: light; color: #697286; background: #f6f7fb; }
 body { min-width: 0; background: #ffffff; color: #000 !important; font-size: 11pt; overflow: visible !important; }
 #app, dialog, .modal, .toast-container, .compact-nav { display: none !important; }
 #receipt-print { display: block !important; width: 72mm; margin: 0 auto; color: #000 !important; background: #ffffff; direction: inherit; }
 #receipt-print * { color: #000 !important; background: #ffffff; box-shadow: none !important; }
 #receipt-print .receipt-meta { margin: 14px 0; border-color: #e1e4ec; }
 #receipt-print .receipt-table th, #receipt-print .receipt-table td { padding: 8px 0; border-color: #e1e4ec; }
 @page { size: auto; margin: 4mm; }
}
/* Clamp immediately during rotation, before the visualViewport event arrives. */
.modal {
 --modal-viewport: min(var(--visual-height, 100vh), var(--screen-height));
 top: calc(var(--visual-top, 0px) + var(--modal-viewport) / 2);
 max-height: calc(var(--modal-viewport) - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
}
/* Preserve the physical safe edges when the device has an asymmetric notch. */
@media screen {
 .app-header, .app-nav { padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: max(14px, env(safe-area-inset-right, 0px)); }
 .admin-sidebar { padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); }
 .admin-content, .status-bar { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
 .modal { left: env(safe-area-inset-left, 0px); right: env(safe-area-inset-right, 0px); top: calc(var(--visual-top, 0px) + env(safe-area-inset-top, 0px) + (var(--modal-viewport) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)) / 2); }
}
@media screen and (min-width: 1200px) and (min-height: 641px) {
 .app-header, .app-nav { padding-inline: 24px; }
 .admin-content { padding-inline: 28px; }
}

/* Light controls stay readable in the mobile checkout bar. */
.compact-nav{background:#fffffff5;border-top-color:#e1e4ec;box-shadow:0 -6px 24px #26263e0a}
.compact-nav button{background:#f5f3fa;border-color:#e0d9ed;color:#4f4766}
.compact-nav button[aria-pressed="true"]{background:#7150d8;border-color:#7150d8;color:#fff}
.compact-count{background:#7150d812;color:#6342bd}
.compact-nav button[aria-pressed="true"] .compact-count{background:#ffffff26;color:#fff}
.app-nav>.language-switcher{margin-inline-start:auto}
@media screen and (max-width:599px){
 .app-nav{flex-wrap:wrap;padding-block:6px;gap:4px 8px}
 .app-nav>.language-switcher{margin-inline-start:auto}
 .app-nav>.language-switcher button{font-size:14px;padding-inline:9px;min-height:34px}
 .app-nav .branch-label{flex:1 1 auto}
 .nav-tab{padding-inline:10px}
}
@media print{
 #receipt-print{direction:inherit}
 .language-switcher{display:none!important}
}
