/* Mobile workspace. Desktop layout and business controls retain their original DOM. */
.grid, .grid > div { min-width: 0; }
.tablewrap { max-width: 100%; }
.table-pager { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-top: 16px; font-size: 12px; color: #718079; }
.table-pager button { border: 1px solid #dce7df; border-radius: 10px; padding: 9px 14px; background: #f3f8f4; color: #397253; font-family: inherit; cursor: pointer; min-height: 40px; }
.table-pager button:disabled { opacity: .4; cursor: default; }
.mobile-nav, .mobile-page-heading, .mobile-form-toggle, .mobile-record-toggle, .mobile-action-icon { display: none; }
.mobile-menu { border: 0; padding: 0; }
@media (min-width: 641px) and (max-width: 1080px) {
  .topbar { flex-wrap: wrap; gap: 10px; }
  .tabs { width: 100%; margin-left: 0; order: 3; overflow-x: auto; }
  .tabs button { flex-shrink: 0; white-space: nowrap; }
  .stats { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media (max-width: 640px) {
  :root { --md-sys-color-background: #f4f6f8; --md-sys-color-surface: #fff; --md-sys-color-primary: #168567; --md-sys-color-outline: #cbd5d1; --md-sys-color-outline-variant: #e6ebe8; --md-sys-color-on-surface-variant: #718079; }
  html { scroll-padding-top: 76px; scroll-padding-bottom: 100px; }
  body { font-size: 14px; line-height: 1.5; color: #20382e; }
  button, input, select, textarea { -webkit-tap-highlight-color: transparent; }
  .topbar { position: sticky; top: 0; z-index: 42; min-height: 60px; padding: calc(12px + env(safe-area-inset-top)) 18px 12px; flex-wrap: nowrap; gap: 8px; background: rgba(255,255,255,.97); border: 0; }
  .topbar .logo { width: 24px; height: 26px; border-radius: 8px; background: #168567; box-shadow: inset 0 0 0 6px #d6ede4; }
  .topbar h1 { font-size: 14px; letter-spacing: -.4px; white-space: nowrap; }
  .mobile-enhanced .topbar .tabs { display: none; }
  .topbar .who { margin-left: auto; max-width: 82px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0; }
  .topbar .who::after { content: attr(data-mobile-account); font-size: 11px; color: #668273; }
  .topbar .spacer { display: none; }
  .topbar .linkbtn { font-size: 11px; padding: 8px 0 8px 4px; white-space: nowrap; }
  .wrap { width: 100%; min-width: 0; padding: 20px 16px calc(104px + env(safe-area-inset-bottom)); }
  .mobile-page-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0 2px 22px; }
  .mobile-page-heading h2 { font-size: 25px; line-height: 1.25; letter-spacing: -.7px; margin: 3px 0 6px; color: #183c2f; }
  .mobile-page-heading p { font-size: 12px; color: #7b8983; margin: 0; }
  .mobile-eyebrow { display: block; color: #168567; font-size: 10px; font-weight: 700; letter-spacing: 1.6px; }
  .mobile-heading-action { border: 1px solid #d8e6df; background: #e8f1ec; color: #26735a; min-height: 40px; padding: 8px 12px; border-radius: 12px; font-family: inherit; font-weight: 600; font-size: 12px; white-space: nowrap; }
  .stats { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; margin-bottom: 18px; }
  .stat { min-width: 0; padding: 14px 10px; border: 0; border-radius: 16px; box-shadow: none; }
  .stat .k { font-size: 10px; margin-bottom: 10px; white-space: normal; }
  .stat .v { font-size: clamp(17px,5vw,23px); color: #204d39; font-weight: 700; overflow-wrap: anywhere; line-height: 1.25; letter-spacing: -.6px; }
  .stat:first-child { background: #1d624b; }
  .stat:first-child .k { color: #bdd8cb; }
  .stat:first-child .v { color: #fff; }
  .quickbar { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 6px; padding: 16px 6px; margin-bottom: 24px; background: #fff; border-radius: 18px; }
  .quickbar .quickbtn { display: flex; flex-direction: column; gap: 8px; padding: 0 2px; min-width: 0; border: 0; background: transparent; color: #4e6057; font-size: 10px; font-weight: 500; box-shadow: none; line-height: 1.4; }
  .mobile-action-icon { display: flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: 14px; background: #e8f4ed; color: #228b65; }
  .quickbtn.ai .mobile-action-icon { background: #eeeafb; color: #7c65b1; }
  #openScanOut .mobile-action-icon { background: #fff2e4; color: #be8748; }
  .mobile-desktop-action { display: none; }
  .grid { display: flex; flex-direction: column; gap: 0; min-width: 0; }
  .grid > div { width: 100%; min-width: 0; }
  #pageStock > .grid > div:first-child, #pageEc > .grid > div:first-child { order: 2; }
  #pageStock > .grid > div:last-child, #pageEc > .grid > div:last-child { order: 1; }
  #pageEc > .grid > div { display: contents; }
  #pageEc .mobile-form { order: 1; width: 100%; }
  #pageEc .grid > div:last-child > .card { order: 2; width: 100%; }
  #pageEc .grid > div:first-child > .card:not(.mobile-form) { order: 3; width: 100%; }
  .card { padding: 18px 16px; margin-bottom: 16px; border: 0; border-radius: 18px; box-shadow: 0 3px 14px rgba(30,62,47,.025); min-width: 0; }
  .card h2 { font-size: 16px; font-weight: 700; margin-bottom: 16px; letter-spacing: -.25px; }
  .secdesc { font-size: 12px; line-height: 1.8; margin: -4px 0 16px; color: #7b8983; overflow-wrap: anywhere; }
  label { font-size: 12px; margin: 14px 0 7px; color: #64766c; }
  input, select, textarea, .query-layout textarea { width: 100%; min-width: 0; min-height: 46px; padding: 12px; font: inherit; font-size: 16px; line-height: 1.4; color: #2c4538; background: #f8faf9; border: 1px solid #e7ece9; border-radius: 12px; outline: none; }
  textarea { display: block; resize: vertical; }
  input:focus, select:focus, textarea:focus { border: 1px solid #168567; padding: 12px; outline: 2px solid #e0f1e8; }
  input[type=checkbox], input[type=radio] { min-height: 0; width: auto; }
  input[type=file] { font-size: 12px; }
  .btn, .btn.sm, .seg button { min-height: 44px; border-radius: 12px; box-shadow: none; padding: 11px 14px; font-size: 13px; }
  .btn.grey { background: #f0f4f1; color: #52685a; }
  .row2 { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
  .row2 > div { min-width: 0; }
  .searchrow { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
  .searchrow input { max-width: none; flex: 1 1 100%; font-size: 13px; background: #f4f7f5; min-height: 42px; }
  .searchrow select { flex: 1 1 auto; max-width: none !important; width: auto; min-height: 38px; font-size: 12px; padding: 9px 12px; }
  .searchrow .btn { min-height: 38px; padding: 8px 14px; font-size: 12px; margin-left: 0 !important; }
  .mobile-form { padding: 0; }
  .mobile-form-toggle { display: flex; width: 100%; align-items: center; gap: 12px; border: 0; background: transparent; padding: 18px 16px; color: #294d3a; font-family: inherit; text-align: left; }
  .mobile-form-toggle strong { font-size: 14px; font-weight: 600; flex: 1; }
  .mobile-form-toggle small { font-size: 11px; color: #839087; }
  .mobile-form-toggle svg { width: 20px; height: 20px; color: #168567; }
  .mobile-form.is-open .mobile-form-toggle svg { transform: rotate(45deg); }
  .mobile-form-body { padding: 0 16px 18px; }
  .mobile-form-body > h2 { display: none; }
  .mobile-form:not(.is-open) .mobile-form-body { display: none; }
  .mobile-records { display: block; white-space: normal; }
  .mobile-records thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .mobile-records tbody { display: grid; gap: 12px; width: 100%; }
  .mobile-records tbody tr { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px 18px; padding: 16px 14px 0; border: 1px solid #e8eeea; border-radius: 14px; background: #fff !important; }
  .mobile-records td { display: none; min-width: 0; min-height: 0; padding: 0; border: 0; text-align: left; overflow-wrap: anywhere; white-space: normal; font-size: 13px; }
  .mobile-records td::before { content: attr(data-mobile-label); display: block; font-size: 10px; font-weight: 400; color: #89968e; margin-bottom: 4px; }
  .mobile-records td[data-mobile-title] { display: block; order: -2; grid-column: 1 / -1; font-size: 15px; font-weight: 650; color: #264637; }
  .mobile-records td[data-mobile-title]::before, .mobile-records td[data-mobile-subtitle]::before { display: none; }
  .mobile-records td[data-mobile-subtitle] { display: block; order: -1; grid-column: 1 / -1; font-size: 10px; color: #92a096; margin-top: -8px; letter-spacing: .3px; }
  .mobile-records td[data-mobile-primary] { display: block; }
  .mobile-records td[data-mobile-emphasis] { font-size: 19px; font-weight: 700; color: #277957; }
  .mobile-records tr.mobile-expanded td { display: block; }
  .mobile-records td.mobile-record-toggle { display: block; grid-column: 1 / -1; border-top: 1px solid #edf1ee; margin-top: 2px; }
  .mobile-record-toggle::before { display: none !important; }
  .mobile-record-toggle button { display: flex; width: 100%; min-height: 40px; align-items: center; justify-content: center; gap: 5px; border: 0; background: transparent; color: #84958a; font-family: inherit; font-size: 11px; cursor: pointer; }
  .mobile-record-toggle svg { width: 12px; height: 12px; }
  .mobile-records .rowbtn { min-height: 38px; padding: 8px 12px; background: #f2f6f3; margin: 2px 4px 2px 0; }
  .mobile-records .pname { align-items: center; }
  .mobile-records .thumb { width: 36px; height: 36px; border-radius: 10px; }
  .mobile-records td[data-edit] { min-height: 38px; padding: 4px; border: 1px dashed #cbd9d0; border-radius: 8px; }
  .mobile-records td input { width: 100%; }
  .tablewrap:has(.mobile-records) { overflow: visible; }
  .tablewrap:not(:has(.mobile-records)) { border-radius: 12px; -webkit-overflow-scrolling: touch; }
  .tablewrap:not(:has(.mobile-records)) th { padding: 10px; background: #f5f8f6; }
  .tablewrap:not(:has(.mobile-records)) td { padding: 12px 10px; }
  .query-title-row { margin-bottom: 12px; gap: 8px; }
  .query-title-row h2 { margin: 0; }
  .query-title-row .btn { min-height: 34px; padding: 7px 10px; font-size: 11px; }
  .query-layout textarea { min-height: 130px; background: #f8faf9; padding: 14px; font-size: 15px; line-height: 1.7; }
  .query-examples { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin: 14px 0; }
  .query-examples .btn { width: 100%; min-height: 46px; padding: 9px 10px; font-size: 11px; line-height: 1.6; border-radius: 10px; text-align: left; }
  .query-actions { gap: 10px; }
  .query-actions .btn { min-height: 48px; font-size: 15px; }
  .query-config-hint, .query-meta { font-size: 11px; line-height: 1.8; }
  .query-answer { padding: 12px; background: #edf6f0; border-radius: 12px; color: #2a6e4c; font-size: 13px; line-height: 1.9; }
  .query-mobile-hint { display: none; }
  .query-table.mobile-records td { max-width: none; min-width: 0; }
  .query-table.mobile-records tbody tr { padding-bottom: 16px; }
  .mobile-nav { position: fixed; z-index: 43; bottom: 0; left: 0; right: 0; display: flex; align-items: stretch; padding: 8px 8px calc(9px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.98); border-top: 1px solid #e9eeeb; box-shadow: 0 -3px 20px rgba(37,64,49,.035); }
  .mobile-nav button { display: flex; flex: 1; min-width: 0; min-height: 48px; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; border-radius: 12px; background: transparent; color: #99a49d; font: inherit; font-size: 10px; }
  .mobile-nav svg { width: 21px; height: 21px; }
  .mobile-nav button[aria-current=page] { color: #167b57; background: #ecf5ef; font-weight: 650; }
  .mobile-nav button[data-mobile-tab=aiQuery] svg { color: #8b78b6; }
  .mobile-nav button[data-mobile-tab=aiQuery][aria-current=page] { color: #78609f; background: #f1edf8; }
  .mobile-menu { position: fixed; inset: auto 0 0; margin: 0; width: 100%; max-width: none; max-height: 85dvh; overflow-y: auto; border-radius: 26px 26px 0 0; background: #f7f9f7; padding: 12px 20px calc(28px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 40px rgba(19,43,30,.12); color: #234432; }
  .mobile-menu::backdrop { background: rgba(20,40,31,.35); }
  body:has(.mobile-menu[open]) { overflow: hidden; }
  .mobile-menu-handle { height: 4px; width: 34px; background: #d5dfd8; border-radius: 5px; margin: 0 auto 20px; }
  .mobile-menu-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
  .mobile-menu-head h2 { margin: 0; font-size: 19px; }
  .mobile-menu-close { border: 0; width: 36px; height: 36px; border-radius: 50%; background: #eaf0eb; color: #647e6c; font-size: 22px; }
  .mobile-menu-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; }
  .mobile-menu-grid button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 88px; border: 1px solid #edf1ee; border-radius: 16px; background: #fff; color: #536f5d; font: inherit; font-size: 12px; }
  .mobile-menu-grid svg { width: 24px; height: 24px; color: #42936c; }
  .mobile-menu-grid button[aria-current=page] { background: #e7f3eb; border-color: #c8dfcf; color: #246c46; }
  .fab { right: 18px; bottom: calc(90px + env(safe-area-inset-bottom)); width: 48px; height: 48px; border-radius: 16px; background: #226f50; color: #fff; box-shadow: 0 6px 18px #226f5033; }
  .mask { padding: 16px; align-items: flex-end; }
  .modal { width: 100% !important; max-width: 100%; max-height: calc(92dvh - env(safe-area-inset-top)); padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); border-radius: 22px !important; overscroll-behavior: contain; }
  .mask:has(.modal) { z-index: 55; }
  .scanmask { z-index: 60; }
  .scanpanel { border-radius: 18px; }
  .scantop { padding-top: calc(12px + env(safe-area-inset-top)); }
  .switchrow { flex: none; }
  .frow { gap: 14px; padding: 14px 0; }
  .frow > div { min-width: 0; flex: 1; }
  .frow .fname { font-size: 13px; }
  .plughead { flex-wrap: wrap; }
  .plughead > div { min-width: 0; }
  .plugitem, .bundlebox { background: #fafcfb; border-color: #e6ede8; border-radius: 14px; overflow-wrap: anywhere; }
  #locListBox, #supListBox { grid-template-columns: minmax(0,1fr) !important; }
  #pageSettings .card, #pagePlugins .card { overflow-wrap: anywhere; }
  #pageSettings .row2 { grid-template-columns: minmax(0,1fr); }
  .authwrap { padding: 24px; min-height: 100dvh; background: #eef4ef; }
  .authwrap > div { width: 100%; max-width: 360px; }
  .authcard, #phoneCard { width: 100% !important; border: 0; border-radius: 24px; box-shadow: 0 10px 40px #254a3320; }
  .authcard .btn { min-height: 48px; margin-top: 24px; }
  #toast { top: calc(68px + env(safe-area-inset-top)); width: max-content; max-width: calc(100% - 32px); font-size: 12px; border-radius: 12px; z-index: 90; }
  .empty { padding: 28px 10px; color: #95a398; line-height: 1.8; }
  .table-pager { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
  .table-pager span { grid-column: 1 / -1; grid-row: 1; text-align: center; font-size: 11px; }
  .table-pager button:first-child { grid-column: 1; grid-row: 2; }
  .table-pager button:last-child { grid-column: 2; grid-row: 2; }
}
@media (max-width: 359px) {
  .topbar { padding-left: 12px; padding-right: 12px; }
  .topbar .who { max-width: 48px; }
  .wrap { padding-left: 12px; padding-right: 12px; }
  .mobile-page-heading h2 { font-size: 23px; }
  .quickbar .quickbtn { font-size: 9px; }
  .mobile-records tbody tr { gap: 12px; padding-left: 12px; padding-right: 12px; }
}
@media (prefers-reduced-motion: reduce) { .mobile-nav *, .mobile-menu *, .mobile-form * { transition: none !important; } }
