/* Mobile presentation layer for the canonical workbench. Desktop remains unchanged. */
.mobile-shell { display: none; }

@media (max-width: 640px) {
  :root { --mobile-blue: #1769e0; --mobile-line: #e3eaf2; --mobile-bg: #f5f8fc; }
  body { background: var(--mobile-bg); padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  body.reference-dark { --mobile-bg: #0b1216; --mobile-line: #2a414a; }
  .app { min-height: 100vh; }
  .topbar { display: none; }
  .content { padding: calc(56px + env(safe-area-inset-top) + 16px) 14px calc(88px + env(safe-area-inset-bottom)); }
  .page-head { margin-bottom: 16px; align-items: center; }
  .page-head h1 { font-size: 19px; margin-bottom: 3px; }
  .page-head p { font-size: 12px; line-height: 1.45; }
  .content .kpis { gap: 10px; }
  .kpi { min-height: 112px; padding: 13px; border-radius: 6px; }
  .kpi .value { margin: 14px 0 6px; font-size: 20px; overflow: hidden; text-overflow: ellipsis; }
  .kpi-top { font-size: 12px; }
  .kpi-top i { width: 17px; }
  .delta { font-size: 11px; line-height: 1.35; display: block; }
  .grid { gap: 12px; margin-top: 12px; }
  .panel, .table-panel { border-radius: 6px; }
  .panel-head { padding: 14px; }
  .panel h2 { font-size: 15px; }
  .chart-area { height: 190px; padding: 0 12px 20px; }
  .table-panel { margin-top: 12px; }
  .table-tools { padding: 0 14px 12px; display: grid; grid-template-columns: 1fr; gap: 8px; }
  .filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .filter { min-width: 0; width: 100%; padding: 0 6px; font-size: 11px; }
  .search { width: 100%; height: 38px; }
  .table-wrap { overflow: visible; }
  .table-wrap table { min-width: 0; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; }
  .table-wrap tr { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; padding: 13px 14px; border-top: 1px solid var(--mobile-line); min-height: 112px; }
  .table-wrap td { height: auto; min-width: 0; padding: 0; border: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
  .table-wrap td:nth-child(1) { grid-column: 1; grid-row: 3; color: var(--muted); font-size: 12px; margin-top: 7px; }
  .table-wrap td:nth-child(2) { grid-column: 1; grid-row: 1; font-weight: 650; }
  .table-wrap td:nth-child(3) { grid-column: 1; grid-row: 2; color: var(--muted); margin-top: 5px; }
  .table-wrap td:nth-child(4), .table-wrap td:nth-child(5), .table-wrap td:nth-child(6) { grid-column: 1; grid-row: 4; color: var(--muted); font-size: 12px; margin-top: 5px; }
  .table-wrap td:nth-child(5), .table-wrap td:nth-child(6) { display: none; }
  .table-wrap td:nth-child(7) { grid-column: 2; grid-row: 1; font-weight: 700; text-align: right; overflow: visible; }
  .table-wrap td:nth-child(8) { grid-column: 2; grid-row: 3; font-size: 11px; color: var(--muted); text-align: right; margin-top: 7px; }
  .table-wrap td:nth-child(9) { grid-column: 2; grid-row: 2; text-align: right; margin-top: 5px; }
  .table-wrap td:nth-child(10) { position: absolute; inset: auto 8px 8px auto; opacity: .55; }
  #businessOrders tr { min-height: 138px; }
  #businessOrders td:nth-child(5) { display: block; grid-column: 2; grid-row: 3; color: var(--muted); font-size: 11px; text-align: right; margin-top: 5px; }
  #businessOrders td:nth-child(6) { display: block; grid-column: 1 / -1; grid-row: 5; color: var(--muted); font-size: 11px; margin-top: 7px; }
  #businessOrders td:nth-child(8) { grid-column: 2; grid-row: 2; margin-top: 5px; }
  #businessOrders .order-caliber.test-order { color: #a36518; }
  .drawer, .report-drawer { z-index: 80; transition: none; }
  .drawer:not(.show), .report-drawer:not(.show) { pointer-events: none; }
  .drawer:not(.show) .drawer-foot, .report-drawer:not(.show) .drawer-foot { display: none; }
  .drawer.show, .report-drawer.show { width: 100%; }
  .drawer-inner, .report-drawer .drawer-inner { width: 100%; padding: calc(16px + env(safe-area-inset-top)) 16px calc(84px + env(safe-area-inset-bottom)); }
  .drawer-head { position: sticky; top: calc(-16px - env(safe-area-inset-top)); z-index: 2; background: var(--panel); padding: 16px 0 14px; }
  .drawer h2 { font-size: 18px; }
  .form-grid { gap: 14px; }
  .field input, .field select { min-height: 44px; }
  .drawer-foot { position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; padding: 11px 16px calc(11px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--mobile-line); }
  .drawer-foot button { min-height: 44px; }
  .settings-tabs, .report-tabs { overflow-x: auto; padding-bottom: 2px; }
  .settings-tab, .report-tab { flex: 0 0 auto; min-height: 38px; }
  .report-toolbar { display: grid; grid-template-columns: 1fr 1fr; }
  .report-toolbar .category-hint { grid-column: 1 / -1; }
  .report-filter, .report-period { width: 100%; min-width: 0; min-height: 40px; }
  .report-overview { grid-template-columns: 1fr 1fr; }
  .report-table-wrap { overflow-x: auto; }
  .mobile-shell { display: block; }
  .mobile-topbar { position: fixed; z-index: 70; top: 0; left: 0; right: 0; height: calc(56px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 14px 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; background: color-mix(in srgb, var(--panel) 94%, transparent); border-bottom: 1px solid var(--mobile-line); backdrop-filter: blur(10px); }
  .mobile-topbar strong { font-size: 16px; color: var(--ink); }
  .mobile-topbar .mobile-month { justify-self: center; border: 0; background: transparent; color: var(--muted); font-size: 12px; min-height: 44px; }
  .mobile-avatar { justify-self: end; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--mobile-line); background: #e8f0ff; color: var(--mobile-blue); font-weight: 700; }
  .mobile-bottom-nav { position: fixed; z-index: 70; bottom: 0; left: 0; right: 0; min-height: calc(64px + env(safe-area-inset-bottom)); padding: 5px 6px env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(var(--mobile-nav-count, 5), minmax(0, 1fr)); background: color-mix(in srgb, var(--panel) 96%, transparent); border-top: 1px solid var(--mobile-line); backdrop-filter: blur(10px); }
  .mobile-nav-button { position: relative; min-height: 54px; display: grid; place-items: center; align-content: center; gap: 3px; border: 0; background: transparent; color: var(--muted); font-size: 11px; }
  .mobile-nav-button svg { width: 20px; height: 20px; }
  .mobile-nav-button.active { color: var(--mobile-blue); font-weight: 700; }
  .mobile-nav-button.active::before { content: ''; position: absolute; top: 2px; width: 36px; height: 28px; border-radius: 6px; background: #eaf2ff; z-index: -1; }
  .mobile-nav-badge { position: absolute; top: 3px; left: calc(50% + 5px); min-width: 16px; height: 16px; padding: 0 4px; display: grid; place-items: center; border-radius: 999px; background: #d85d5d; color: #fff; font-size: 10px; line-height: 1; }
  .mobile-more-mask { position: fixed; z-index: 89; inset: 0; display: none; background: rgba(11, 25, 36, .36); }
  .mobile-more-mask.show { display: block; }
  .mobile-more-sheet { position: fixed; z-index: 90; left: 0; right: 0; bottom: 0; visibility: hidden; pointer-events: none; transform: translateY(105%); transition: transform .2s ease, visibility .2s ease; max-height: 80vh; overflow-y: auto; padding: 10px 14px calc(20px + env(safe-area-inset-bottom)); background: var(--panel); border-radius: 10px 10px 0 0; box-shadow: 0 -10px 30px rgba(16, 34, 55, .16); }
  .mobile-more-sheet.show { visibility: visible; pointer-events: auto; transform: translateY(0); }
  .mobile-sheet-handle { width: 34px; height: 4px; margin: 0 auto 12px; border-radius: 2px; background: #c6d2df; }
  .mobile-account-row { display: flex; align-items: center; gap: 10px; padding: 10px 4px 16px; border-bottom: 1px solid var(--mobile-line); }
  .mobile-account-row .mobile-avatar { justify-self: auto; flex: 0 0 auto; display: grid; place-items: center; }
  .mobile-account-row small { display: block; color: var(--muted); margin-top: 3px; font-size: 12px; }
  .mobile-menu-label { margin: 17px 4px 6px; color: var(--muted); font-size: 12px; }
  .mobile-menu-item { width: 100%; min-height: 48px; display: flex; align-items: center; gap: 11px; padding: 0 7px; border: 0; border-bottom: 1px solid var(--mobile-line); background: transparent; color: var(--ink); text-align: left; }
  .mobile-menu-item svg { width: 18px; height: 18px; color: var(--muted); }
  .mobile-menu-item .chevron { margin-left: auto; }
  .mobile-menu-item.danger { color: #d45b5b; }
  .mobile-menu-item.danger svg { color: #d45b5b; }
  .mobile-entry-result { position: fixed; z-index: 110; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: minmax(0, 1fr) auto 34px; align-items: center; gap: 10px; padding: 12px; border: 1px solid #a8d8c5; border-radius: 7px; background: #f3fbf7; box-shadow: 0 10px 28px rgba(16, 45, 38, .16); color: #176847; opacity: 0; pointer-events: none; transform: translateY(12px); transition: opacity .18s ease, transform .18s ease; }
  .mobile-entry-result.show { opacity: 1; pointer-events: auto; transform: translateY(0); }
  .mobile-entry-result.error { border-color: #e5adad; background: #fff7f7; color: #a43f3f; }
  .mobile-entry-result strong, .mobile-entry-result span { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-entry-result strong { font-size: 13px; }
  .mobile-entry-result span { margin-top: 3px; color: var(--muted); font-size: 11px; }
  .mobile-entry-result [data-mobile-recent] { min-height: 36px; padding: 0 9px; border: 1px solid currentColor; border-radius: 5px; background: transparent; color: inherit; font-size: 12px; white-space: nowrap; }
  .mobile-entry-result-close { width: 34px; height: 34px; display: grid; place-items: center; border: 0; background: transparent; color: inherit; }
  .mobile-entry-result-close svg { width: 18px; height: 18px; }
}
