/* AquaAsist mobile interaction preview.
   All visual changes are mobile-only; the original desktop layout is preserved. */
@media (max-width: 700px) {
  :root {
    --aq-mobile-panel: #111d34;
    --aq-mobile-panel-raised: #182741;
    --aq-mobile-divider: #30405e;
    --aq-mobile-text: #f0f5ff;
    --aq-mobile-muted: #a2b3cf;
    --aq-mobile-accent: #a3acf9;
    --aq-mobile-success: #9fe8cf;
    --aq-mobile-panel-shadow: 0 -12px 70px #02081766;
    --aq-mobile-tab-height: 76px;
  }

  html[data-aq-theme="light"] {
    --aq-mobile-panel: #ffffff;
    --aq-mobile-panel-raised: #f1f5fc;
    --aq-mobile-divider: #d9e3ef;
    --aq-mobile-text: #20334c;
    --aq-mobile-muted: #586f89;
    --aq-mobile-accent: #425abd;
    --aq-mobile-success: #25735d;
    --aq-mobile-panel-shadow: 0 -12px 64px #18334b20;
  }

  html.aq-mobile-panel-open,
  html.aq-mobile-panel-open body {
    overscroll-behavior: none;
  }

  /* Native dialog remains responsible for focus, backdrop and accessibility. */
  html #dialog:is(.aq-mobile-sheet, .aq-mobile-fullscreen) {
    position: fixed !important;
    inset: auto 0 var(--aq-keyboard-inset, 0px) 0 !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto;
    max-height: min(78dvh, calc(var(--aq-viewport-height, 100dvh) - var(--safe-top, 0px) - 12px)) !important;
    min-height: 0;
    margin: 0 !important;
    padding: 0 !important;
    border: 1px solid var(--aq-mobile-divider);
    border-bottom: 0;
    border-radius: 28px 28px 0 0;
    background: var(--aq-mobile-panel) !important;
    color: var(--aq-mobile-text);
    box-shadow: var(--aq-mobile-panel-shadow);
    overflow: hidden !important;
    overscroll-behavior: contain;
    transform: translate3d(0, var(--aq-sheet-drag-y, 0px), 0) !important;
    transition: transform 240ms cubic-bezier(.22, .7, .2, 1), max-height 240ms ease, border-radius 180ms ease;
    isolation: isolate;
  }

  html #dialog:is(.aq-mobile-sheet, .aq-mobile-fullscreen)[open] {
    display: flex;
    flex-direction: column;
    animation: aq-mobile-panel-in 280ms cubic-bezier(.22, .7, .2, 1) both;
  }

  html #dialog:is(.aq-mobile-sheet, .aq-mobile-fullscreen)::backdrop {
    background: #0208178f;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    animation: aq-mobile-backdrop-in 220ms ease-out both;
  }

  html #dialog.aq-mobile-sheet[data-aq-snap="expanded"] {
    height: calc(var(--aq-viewport-height, 100dvh) - var(--safe-top, 0px) - 12px);
    max-height: calc(var(--aq-viewport-height, 100dvh) - var(--safe-top, 0px) - 12px) !important;
  }

  html #dialog.aq-mobile-fullscreen {
    top: var(--aq-viewport-top, 0px) !important;
    height: var(--aq-viewport-height, 100dvh) !important;
    max-height: var(--aq-viewport-height, 100dvh) !important;
    border: 0;
    border-radius: 0;
  }

  html #dialog[data-aq-dragging="true"] {
    transition: none !important;
    animation: none !important;
    user-select: none;
    -webkit-user-select: none;
  }

  html #dialog[data-aq-closing="true"] {
    transform: translate3d(0, 105%, 0) !important;
    pointer-events: none;
  }

  html #dialog .aq-mobile-sheet-header {
    position: relative !important;
    top: 0 !important;
    z-index: 5;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    min-width: 0;
    margin: 0 !important;
    padding: 32px max(18px, var(--safe-right, 0px)) 10px max(20px, var(--safe-left, 0px)) !important;
    background: var(--aq-mobile-panel) !important;
    border-bottom: 1px solid var(--aq-mobile-divider);
    touch-action: none;
    cursor: grab;
  }

  html #dialog .aq-mobile-sheet-header h2 {
    min-width: 0;
    margin: 0;
    color: var(--aq-mobile-text);
    font-size: 19px;
    line-height: 1.35;
    font-weight: 650;
    letter-spacing: -.35px;
    overflow-wrap: anywhere;
  }

  html #dialog .aq-mobile-drag-handle {
    position: absolute;
    inset: 0 auto auto 50%;
    display: grid;
    place-items: start center;
    width: 68px;
    height: 44px;
    min-height: 44px;
    margin: 0;
    padding: 13px 0 0;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--aq-mobile-muted);
    transform: translateX(-50%);
    cursor: ns-resize;
    touch-action: none;
  }

  html #dialog .aq-mobile-drag-handle::before {
    content: "";
    width: 36px;
    height: 4px;
    border-radius: 8px;
    background: currentColor;
    opacity: .56;
  }

  html #dialog .aq-mobile-drag-handle:focus-visible {
    outline-offset: -6px;
    background: var(--aq-mobile-panel-raised);
  }

  html #dialog .aq-mobile-sheet-header :is(.icon-button, .aq-mobile-back) {
    position: relative;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--aq-mobile-panel-raised);
    color: var(--aq-mobile-muted);
    font-size: 25px;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
  }

  html #dialog.aq-mobile-fullscreen .aq-mobile-sheet-header {
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    min-height: calc(66px + var(--safe-top, 0px));
    padding: calc(9px + var(--safe-top, 0px)) max(12px, var(--safe-right, 0px)) 9px max(12px, var(--safe-left, 0px)) !important;
    cursor: default;
    touch-action: auto;
  }

  html #dialog.aq-mobile-fullscreen .aq-mobile-drag-handle { display: none; }
  html #dialog.aq-mobile-sheet .aq-mobile-back { display: none; }
  html #dialog.aq-mobile-fullscreen .aq-mobile-back { grid-column: 1; grid-row: 1; }
  html #dialog.aq-mobile-fullscreen .aq-mobile-sheet-header h2 { grid-column: 2; grid-row: 1; font-size: 18px; }
  html #dialog.aq-mobile-fullscreen .aq-mobile-sheet-header > .icon-button { grid-column: 3; grid-row: 1; }

  html #dialog .aq-mobile-sheet-body {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    padding: 18px max(20px, var(--safe-right, 0px)) calc(20px + var(--safe-bottom, 0px)) max(20px, var(--safe-left, 0px));
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scroll-padding-block: 18px 24px;
  }

  html #dialog .aq-mobile-sheet-body > :first-child { margin-top: 0; }
  html #dialog .aq-mobile-sheet-body > :last-child { margin-bottom: 0; }
  html #dialog .aq-mobile-sheet-body :is(p, small, label) { overflow-wrap: anywhere; }
  html #dialog .aq-mobile-sheet-body .dialog-subtitle { margin: 0 0 18px; font-size: 13px; line-height: 1.6; }

  html #dialog .aq-mobile-sheet-body > form.aq-mobile-form {
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: 100%;
    margin: 0;
    gap: 0;
  }

  html #dialog .aq-mobile-sheet-body:has(> form.aq-mobile-form) {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
  }

  html #dialog .aq-mobile-form { flex: 1 1 auto; }
  html #dialog .aq-mobile-form-fields {
    flex: 1 1 auto;
    min-height: 0;
    padding: 18px max(20px, var(--safe-right, 0px)) 24px max(20px, var(--safe-left, 0px));
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scroll-padding-block: 20px 28px;
  }

  html #dialog .aq-mobile-form-fields > :first-child { margin-top: 0; }
  html #dialog .aq-mobile-form-fields > :last-child { margin-bottom: 0; }
  html #dialog .aq-mobile-form-fields .form-grid:not(.tank-dimensions) { grid-template-columns: minmax(0, 1fr); gap: 18px; }

  html #dialog:is(.aq-mobile-sheet, .aq-mobile-fullscreen) :is(input, select, textarea) {
    font-size: 16px;
    line-height: 1.4;
    border-radius: 12px;
    scroll-margin-block: 20px;
  }

  html #dialog:is(.aq-mobile-sheet, .aq-mobile-fullscreen) :is(input, select):not([type="checkbox"]):not([type="radio"]) {
    min-height: 50px;
  }

  html #dialog:is(.aq-mobile-sheet, .aq-mobile-fullscreen) label {
    font-size: 13px;
    line-height: 1.5;
    gap: 8px;
  }

  html #dialog:is(.aq-mobile-sheet, .aq-mobile-fullscreen) .field-hint {
    display: block;
    font-size: 12px;
    line-height: 1.6;
    color: var(--aq-mobile-muted);
  }

  html #dialog .aq-mobile-sheet-actions {
    position: sticky;
    bottom: 0;
    z-index: 4;
    display: flex;
    align-items: stretch;
    gap: 10px;
    flex: 0 0 auto;
    min-width: 0;
    margin: 0;
    padding: 12px max(20px, var(--safe-right, 0px)) calc(12px + var(--safe-bottom, 0px)) max(20px, var(--safe-left, 0px));
    background: var(--aq-mobile-panel);
    border-top: 1px solid var(--aq-mobile-divider);
    box-shadow: 0 -10px 22px color-mix(in srgb, var(--aq-mobile-panel) 80%, transparent);
  }

  html #dialog .aq-mobile-sheet-actions > :is(button, input[type="submit"], input[type="button"]) {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    min-height: 50px;
    margin: 0;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 650;
    line-height: 1.35;
  }

  html:is(.keyboard-open, .aq-mobile-keyboard-open) #dialog .aq-mobile-sheet-actions { padding-bottom: 12px; }
  html:is(.keyboard-open, .aq-mobile-keyboard-open) #dialog.aq-mobile-sheet { max-height: calc(var(--aq-viewport-height, 100dvh) - 8px) !important; }

  /* Mobile tap targets and concise, predictable visual feedback. */
  :is(.bottomnav, .aq-mobile-sheet-body, .aq-mobile-form-fields) :is(button, [role="button"], summary),
  .topbar :is(.bell, .avatar) {
    min-height: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  :is(.aq-mobile-sheet-body, .aq-mobile-form-fields) :is(button, [role="button"]) { min-width: 44px; }
  .task .check { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }

  .topbar :is(.bell, .avatar) { width: 44px; height: 44px; }
  :is(.aq-mobile-sheet-body, .aq-mobile-form-fields) button:active,
  .topbar :is(.bell, .avatar):active {
    filter: brightness(.91);
    transform: scale(.98);
  }

  html #dialog .aq-mobile-sheet-header button:active { filter: brightness(.88); }
  html #dialog .aq-mobile-drag-handle:active { transform: translateX(-50%); }

  /* Compact, anchored tab bar: the active destination is visible by shape and color. */
  .bottomnav {
    max-width: 500px;
    padding: 8px max(8px, var(--safe-right, 0px)) calc(8px + var(--safe-bottom, 0px)) max(8px, var(--safe-left, 0px));
    border-top-color: #2b3854;
    box-shadow: 0 -10px 26px #02081718;
  }

  .bottomnav button {
    position: relative;
    min-width: 0;
    min-height: 52px;
    padding: 5px 2px;
    border-radius: 16px;
    gap: 5px;
    font-size: 10px;
    line-height: 1.25;
    letter-spacing: .1px;
    transition: color 140ms ease, background 140ms ease, transform 140ms ease;
  }

  .bottomnav button::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 50%;
    width: 52px;
    height: 29px;
    border-radius: 14px;
    background: transparent;
    transform: translateX(-50%) scale(.88);
    transition: background 180ms ease, transform 180ms ease;
    pointer-events: none;
  }

  .bottomnav button.active {
    background: transparent;
    color: #b7beff;
    box-shadow: none;
    font-weight: 650;
  }

  .bottomnav button.active::before {
    background: #7a89e72b;
    transform: translateX(-50%) scale(1);
  }

  .bottomnav button .icon { position: relative; width: 22px; height: 22px; z-index: 1; }
  .bottomnav button.active .icon { filter: none; stroke-width: 2; }
  .bottomnav button:active { transform: scale(.94); }
  .bottomnav button:focus-visible { outline-offset: -3px; }
  html.aq-mobile-panel-open .bottomnav { pointer-events: none; }
  html.aq-mobile-keyboard-open .bottomnav { visibility: hidden; pointer-events: none; }

  /* Toast is still a live status region; dismiss is a real accessible button. */
  :is(#toast, .aq-toast-mirror).aq-mobile-toast:not([hidden]) {
    position: fixed;
    top: auto !important;
    right: 16px;
    bottom: calc(var(--aq-mobile-tab-height) + var(--safe-bottom, 0px) + 12px);
    left: 16px;
    z-index: 30;
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr) 44px;
    align-items: center;
    gap: 9px;
    width: auto;
    max-width: min(440px, calc(100% - 32px));
    min-height: 60px;
    height: auto !important;
    max-height: 180px;
    max-height: min(180px, 30dvh);
    overflow-y: auto;
    margin: 0 auto;
    padding: 7px 7px 7px 15px;
    border: 1px solid #3a516d;
    border-radius: 18px;
    background: #172b3e;
    color: #edf7ff;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.5;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
    box-shadow: 0 10px 35px #02081766;
    transform: none;
    animation: aq-mobile-toast-in 210ms ease-out both;
  }

  /* Only the copy inside an existing dialog should be visible or announced. */
  html #toast.aq-toast-shadowed { visibility: hidden; pointer-events: none; }

  :is(#toast, .aq-toast-mirror).aq-mobile-toast::before {
    content: "i";
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border: 1px solid #86a0c6;
    border-radius: 50%;
    color: #c0d6f4;
    font-size: 14px;
    font-weight: 700;
  }

  :is(#toast, .aq-toast-mirror).aq-mobile-toast[data-aq-toast-tone="success"]::before { content: "✓"; color: #a8efd8; border-color: #5caa91; }
  :is(#toast, .aq-toast-mirror).aq-mobile-toast[data-aq-toast-tone="error"]::before { content: "!"; color: #ffbdc8; border-color: #b97085; }
  :is(#toast, .aq-toast-mirror).aq-mobile-toast .aq-toast-dismiss {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #c5d5e8;
    font-size: 22px;
    line-height: 1;
  }

  html:is(.keyboard-open, .aq-mobile-keyboard-open) :is(#toast, .aq-toast-mirror).aq-mobile-toast:not([hidden]) {
    bottom: calc(var(--aq-keyboard-inset, 0px) + 16px);
  }

  html #dialog :is(#toast, .aq-toast-mirror).aq-mobile-toast:not([hidden]) {
    bottom: calc(86px + var(--safe-bottom, 0px));
    max-width: calc(100% - 32px);
  }

  /* Unsaved changes: explicit choice without opening a second native dialog. */
  html #dialog .aq-mobile-discard-confirm {
    position: absolute;
    inset: 0;
    z-index: 12;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    justify-content: safe center;
    gap: 12px;
    padding: 28px;
    background: var(--aq-mobile-panel);
    color: var(--aq-mobile-text);
    overflow-y: auto;
  }

  html #dialog .aq-mobile-discard-confirm h3 { margin: 0; font-size: 21px; line-height: 1.3; letter-spacing: -.35px; }
  html #dialog .aq-mobile-discard-confirm p { margin: 0 0 8px; color: var(--aq-mobile-muted); font-size: 14px; line-height: 1.65; }
  html #dialog .aq-mobile-discard-actions { display: grid; gap: 10px; }
  html #dialog .aq-mobile-discard-confirm :is(button, .primary, .secondary) { width: 100%; min-height: 50px; font-size: 14px; border-radius: 14px; }

  html[data-aq-theme="light"] #dialog:is(.aq-mobile-sheet, .aq-mobile-fullscreen) { background: var(--aq-mobile-panel) !important; border-color: var(--aq-mobile-divider) !important; }
  html[data-aq-theme="light"] #dialog:is(.aq-mobile-sheet, .aq-mobile-fullscreen)::backdrop { background: #1c354b60; }
  html[data-aq-theme="light"] .bottomnav { box-shadow: 0 -8px 22px #173b5d08; }
  html[data-aq-theme="light"] .bottomnav button.active { color: #4055b7 !important; background: transparent !important; box-shadow: none !important; }
  html[data-aq-theme="light"] .bottomnav button.active::before { background: #e6eaff; }
  html[data-aq-theme="light"] :is(#toast, .aq-toast-mirror).aq-mobile-toast:not([hidden]) { background: #183849; border-color: #3f6975; color: #f3fcff; }

  @keyframes aq-mobile-panel-in {
    from { opacity: .96; translate: 0 100%; }
    to { opacity: 1; translate: 0 0; }
  }
  @keyframes aq-mobile-backdrop-in { from { opacity: 0; } to { opacity: 1; } }
  @keyframes aq-mobile-toast-in { from { opacity: 0; translate: 0 10px; } to { opacity: 1; translate: 0 0; } }

  @media (prefers-reduced-motion: reduce) {
    html #dialog:is(.aq-mobile-sheet, .aq-mobile-fullscreen),
    html #dialog:is(.aq-mobile-sheet, .aq-mobile-fullscreen)::backdrop,
    :is(#toast, .aq-toast-mirror).aq-mobile-toast:not([hidden]),
    .bottomnav button,
    .bottomnav button::before {
      animation: none !important;
      transition: none !important;
    }
  }
}
@media(max-width:700px){.aq-mobile-record-detail{padding:4px 0 0}.aq-record-type{display:flex;align-items:center;gap:14px;margin:4px 0 22px}.aq-record-type>span{display:grid;place-items:center;width:54px;height:54px;flex:none;background:color-mix(in srgb,var(--aq-mobile-success) 12%,transparent);border:1px solid color-mix(in srgb,var(--aq-mobile-success) 28%,transparent);border-radius:17px;color:var(--aq-mobile-success)}.aq-record-type .icon{width:29px;height:29px}.aq-record-type small{color:var(--aq-mobile-muted);font-size:10px;letter-spacing:1.2px;font-weight:700}.aq-record-type p{margin:6px 0 0;color:var(--aq-mobile-text);font-size:14px;font-style:italic}.aq-record-facts{display:grid;grid-template-columns:1fr 1fr;border:1px solid var(--aq-mobile-divider);border-radius:17px;overflow:hidden;margin-bottom:18px}.aq-record-facts>div{padding:16px 13px;min-width:0;border-bottom:1px solid var(--aq-mobile-divider)}.aq-record-facts>div:nth-child(odd){border-right:1px solid var(--aq-mobile-divider)}.aq-record-facts>div:nth-last-child(-n+2){border-bottom:0}.aq-record-facts small{display:block;color:var(--aq-mobile-muted);font-size:11px;line-height:1.5;margin-bottom:8px}.aq-record-facts strong{display:block;font-size:14px;line-height:1.5;color:var(--aq-mobile-text);overflow-wrap:anywhere}.aq-record-facts em{font-size:11px;font-style:normal;font-weight:400;color:var(--aq-mobile-muted)}.aq-record-actions{display:grid;gap:10px;margin-top:22px}.aq-record-actions button{min-height:48px}}

/* Mobile livestock: compact catalogue entry and horizontally scrollable filters. */
@media (max-width:700px) {
  html #content .aq-mobile-catalogue { margin: 8px 0 22px; }
  html #content .aq-mobile-catalogue > .v6-catalog-progress { display:none!important; }
  html #content .aq-mobile-catalogue > button {
    width:100%; min-height:64px; display:flex; align-items:center; gap:12px;
    padding:12px 14px; border:1px solid var(--aq-mobile-divider); border-radius:16px;
    background:var(--aq-mobile-panel); color:var(--aq-mobile-text); text-align:left;
  }
  html #content .aq-catalogue-icon { display:grid; place-items:center; width:36px; height:36px; border-radius:11px; background:var(--aq-mobile-panel-raised); color:var(--aq-mobile-success); flex:none; }
  .aq-catalogue-icon svg,.aq-category-menu svg { width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
  html #content .aq-mobile-catalogue strong { display:block; font-size:13px; font-weight:600; line-height:1.5; }
  html #content .aq-mobile-catalogue small { display:block; color:var(--aq-mobile-muted); font-size:11px; line-height:1.5; margin-top:2px; }
  html #content .aq-mobile-catalogue b { margin-left:auto; color:var(--aq-mobile-muted); font-weight:400; font-size:24px; }
  html #content .aq-livestock-filter-block { position:relative; margin:8px 0 18px; }
  html #content .aq-livestock-filter-label { display:flex; align-items:center; min-height:44px; margin:0 0 8px; padding-right:130px; font-size:16px; font-weight:650; color:var(--aq-mobile-text)!important; }
  html #content .aq-category-menu { position:absolute; right:0; top:0; display:flex; align-items:center; gap:7px; min-height:44px; padding:0 4px 0 12px; background:transparent; border:0; color:var(--aq-mobile-muted); font-size:12px; }
  html #content .aq-livestock-filter-chips {
    position:relative; display:flex!important; flex-wrap:nowrap; gap:8px; margin:0; padding:0 0 4px;
    width:100%; overflow-x:auto; overflow-y:hidden; background:transparent!important; border-radius:0;
    scrollbar-width:none; -webkit-overflow-scrolling:touch; overscroll-behavior-x:contain; scroll-padding-inline:2px;
    touch-action:pan-x pan-y pinch-zoom; cursor:grab;
  }
  html #content .aq-livestock-filter-chips[data-aq-scroll-start="true"][data-aq-scroll-end="false"] { mask-image:linear-gradient(to right,#000 0%,#000 calc(100% - 23px),transparent 100%); }
  html #content .aq-livestock-filter-chips[data-aq-scroll-start="false"][data-aq-scroll-end="false"] { mask-image:linear-gradient(to right,transparent,#000 20px,#000 calc(100% - 23px),transparent); }
  html #content .aq-livestock-filter-chips[data-aq-scroll-start="false"][data-aq-scroll-end="true"] { mask-image:linear-gradient(to right,transparent,#000 20px); }
  html #content .aq-livestock-filter-chips.aq-filter-dragging,html #content .aq-livestock-filter-chips.aq-filter-dragging button { cursor:grabbing; user-select:none; }
  html #content .aq-livestock-filter-chips::-webkit-scrollbar { display:none; }
  html #content .aq-livestock-filter-chips button {
    flex:0 0 auto; width:auto; min-height:44px; margin:0; padding:10px 12px;
    border:1px solid var(--aq-mobile-divider); border-radius:12px; background:var(--aq-mobile-panel)!important;
    box-shadow:none!important; color:var(--aq-mobile-muted)!important; white-space:nowrap; font-size:12px; font-weight:500; line-height:1.5; cursor:grab;
  }
  html #content .aq-livestock-filter-chips button[aria-pressed="true"] {
    background:var(--aq-mobile-success)!important; border-color:var(--aq-mobile-success); color:#0c2a25!important; font-weight:650;
  }
  html[data-aq-theme="light"] #content .aq-livestock-filter-chips button[aria-pressed="true"] { color:#fff!important; }
  html #dialog .aq-category-picker > .field-hint,html #dialog .aq-catalogue-sheet > .field-hint { margin:0 0 16px; color:var(--aq-mobile-muted); font-size:13px; line-height:1.6; }
  html #dialog .aq-category-options { display:grid; gap:7px; }
  html #dialog .aq-category-options button { display:flex; align-items:center; justify-content:space-between; gap:12px; min-height:50px; padding:12px 14px; border:1px solid var(--aq-mobile-divider); border-radius:13px; background:var(--aq-mobile-panel-raised); color:var(--aq-mobile-text); font-size:14px; text-align:left; }
  html #dialog .aq-category-options button i { display:grid; place-items:center; width:21px; height:21px; border:1.5px solid var(--aq-mobile-muted); border-radius:50%; font-style:normal; flex:none; }
  html #dialog .aq-category-options button[aria-pressed="true"] { border-color:var(--aq-mobile-success); }
  html #dialog .aq-category-options button[aria-pressed="true"] i { background:var(--aq-mobile-success); border-color:var(--aq-mobile-success); color:#0c2a25; }
  html #dialog .aq-category-options button[aria-pressed="true"] i::after { content:'✓'; font-size:13px; font-weight:700; }
  html #dialog .aq-catalogue-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; margin-bottom:18px; }
  html #dialog .aq-catalogue-grid > div { display:flex; flex-direction:column; justify-content:space-between; min-height:108px; padding:15px; background:var(--aq-mobile-panel-raised); border:1px solid var(--aq-mobile-divider); border-radius:15px; }
  html #dialog .aq-catalogue-grid strong { color:var(--aq-mobile-text); font-size:24px; font-weight:600; line-height:1.3; }
  html #dialog .aq-catalogue-grid small { margin-left:5px; font-size:11px; color:var(--aq-mobile-muted); font-weight:400; }
  html #dialog .aq-catalogue-grid span { margin-top:8px; font-size:12px; line-height:1.5; color:var(--aq-mobile-muted); }
  html #content :is(.aq-category-menu,.aq-mobile-catalogue > button,.aq-livestock-filter-chips button):focus-visible { outline:2px solid var(--aq-mobile-accent); outline-offset:-2px; }
}

/* Shared mobile navigation: labels keep their natural width on every page. */
@media (max-width:700px) {
  html :is(#content,#dialog) .aq-mobile-scroll-row:not([data-aq-scroll-kind="period"]) {
    display:flex!important; flex-wrap:nowrap!important; align-items:stretch; gap:8px;
    width:100%; min-width:0; max-width:100%; margin:8px 0 18px; padding:2px 0 5px;
    overflow-x:auto!important; overflow-y:hidden; background:transparent!important; border-radius:0;
    scrollbar-width:none; touch-action:pan-x pan-y pinch-zoom; -webkit-overflow-scrolling:touch;
    overscroll-behavior-x:contain; cursor:grab;
  }
  html :is(#content,#dialog) .aq-mobile-scroll-row::-webkit-scrollbar { display:none; }
  html :is(#content,#dialog) .aq-mobile-scroll-row:not([data-aq-scroll-kind="period"]) > button {
    flex:0 0 auto!important; width:auto!important; min-width:44px; max-width:none; min-height:44px; height:auto;
    margin:0; padding:11px 14px; border:1px solid var(--aq-mobile-divider); border-radius:12px;
    background:var(--aq-mobile-panel)!important; color:var(--aq-mobile-muted)!important; box-shadow:none!important;
    white-space:nowrap!important; overflow-wrap:normal!important; word-break:normal!important; hyphens:none;
    font-size:12px; line-height:1.5; font-weight:500; cursor:grab;
  }
  html :is(#content,#dialog) .aq-mobile-scroll-row > button:is(.active,[aria-pressed="true"]) {
    background:var(--aq-mobile-success)!important; border-color:var(--aq-mobile-success)!important; color:#0c2a25!important; font-weight:650;
  }
  html[data-aq-theme="light"] :is(#content,#dialog) .aq-mobile-scroll-row > button:is(.active,[aria-pressed="true"]) { color:#fff!important; }
  html :is(#content,#dialog) .aq-mobile-scroll-row[data-aq-scroll-start="true"][data-aq-scroll-end="false"] { mask-image:linear-gradient(to right,#000,#000 calc(100% - 22px),transparent); }
  html :is(#content,#dialog) .aq-mobile-scroll-row[data-aq-scroll-start="false"][data-aq-scroll-end="false"] { mask-image:linear-gradient(to right,transparent,#000 18px,#000 calc(100% - 22px),transparent); }
  html :is(#content,#dialog) .aq-mobile-scroll-row[data-aq-scroll-start="false"][data-aq-scroll-end="true"] { mask-image:linear-gradient(to right,transparent,#000 18px); }
  html :is(#content,#dialog) .aq-mobile-scroll-row.aq-filter-dragging,
  html :is(#content,#dialog) .aq-mobile-scroll-row.aq-filter-dragging > button { cursor:grabbing; user-select:none; }
  html :is(#content,#dialog) .aq-mobile-scroll-row[data-aq-scroll-kind="period"] {
    display:grid!important; grid-template-columns:repeat(4,minmax(0,1fr)); gap:4px; width:100%; min-width:0;
    margin:2px 0 20px; padding:4px; border:1px solid var(--aq-mobile-divider); border-radius:14px;
    background:var(--aq-mobile-panel)!important; overflow:hidden; mask-image:none;
  }
  html :is(#content,#dialog) .aq-mobile-scroll-row[data-aq-scroll-kind="period"] > button {
    width:100%; min-width:0; min-height:44px; padding:10px 3px; margin:0; border:0;
    border-radius:10px; background:transparent!important; color:var(--aq-mobile-muted)!important;
    font-size:12px; font-weight:500; line-height:1.5; white-space:nowrap; word-break:normal; overflow-wrap:normal; box-shadow:none!important;
  }
  html :is(#content,#dialog) .aq-mobile-scroll-row[data-aq-scroll-kind="period"] > button:is(.active,[aria-pressed="true"]) { background:var(--aq-mobile-success)!important; color:#0c2a25!important; }
  html[data-aq-theme="light"] :is(#content,#dialog) .aq-mobile-scroll-row[data-aq-scroll-kind="period"] > button:is(.active,[aria-pressed="true"]) { color:#fff!important; }
  html :is(#content,#dialog) .aq-mobile-scroll-row > button:focus-visible { outline:2px solid var(--aq-mobile-accent); outline-offset:-2px; }
  html #content .aq-livestock-filter-chips.aq-mobile-scroll-row > button { padding-inline:12px; }
}

/* Touch targets and resilient content widths across the five main screens. */
@media (max-width:700px) {
  html #content button { min-height:44px; min-width:44px; }
  html #dialog button { min-height:44px; min-width:44px; }
  html #content :is(.animal-title,.taskname,.settings-row>span:nth-child(2),.carehead>div,.aq-device-chart-head>div) { min-width:0; }
  html #content .animal .fishthumb { width:44px; min-width:44px; }
  html #content .animal .counter { gap:6px; }
  html #content .animal .counter button { width:44px; height:44px; }
  html #content .plug-card-actions { flex-wrap:wrap; }
  html #content .adv-tool-buttons { gap:8px; }
  html #content .adv-tool-buttons button { padding:10px 12px; line-height:1.45; }
  html #content :is(.page-actions,.sectionhead,.charttop,.aq-device-chart-head) { gap:12px; }
  html #content :is(.page-actions,.sectionhead,.charttop,.aq-device-chart-head)>:first-child { min-width:0; }
  html #content :is(.page-actions,.sectionhead)>button { flex-shrink:0; }
  html #content .task .check { width:44px; height:44px; min-width:44px; flex:none; }
  html #content .carehead>.icon-button { width:44px; height:44px; flex:none; }
  html #dialog :is(.form-grid>*,label,.settings-row>span:nth-child(2)) { min-width:0; }
}
@media (max-width:350px) {
  html #content .animal { display:grid; grid-template-columns:44px minmax(0,1fr); gap:10px; }
  html #content .animal .counter { grid-column:2; justify-self:end; margin-left:0; }
  html #content .animal .animal-title { width:100%; }
  html #content .water-history-summary { grid-template-columns:repeat(3,minmax(0,1fr)); gap:6px; }
  html #content .water-history-summary strong { font-size:15px; white-space:nowrap; }
  html #content .water-history-summary small { font-size:9px; letter-spacing:.3px; }
}
@media (max-width:700px) {
  html :is(#content,#dialog) .aq-mobile-scroll-row[data-aq-scroll-kind="period"][data-aq-period-count="5"] { grid-template-columns:repeat(5,minmax(0,1fr)); }
  html :is(#content,#dialog) .aq-mobile-scroll-row[data-aq-scroll-kind="period"][data-aq-period-count="5"] > button { font-size:11px; padding-inline:2px; }
  html #content .aq-tabs-toolbar button { padding:10px 16px; border:1px solid var(--aq-mobile-divider); border-radius:12px; color:var(--aq-mobile-text); background:var(--aq-mobile-panel-raised); font-size:12px; line-height:1.5; }
  html #content .v5-analytics-grid { grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; }
  html #content .v5-analytics-card { display:flex; flex-direction:column; justify-content:space-between; min-width:0; min-height:90px; padding:12px; border-color:var(--aq-mobile-divider); background:var(--aq-mobile-panel); }
  html #content .v5-analytics-card small { font-size:10px; line-height:1.5; color:var(--aq-mobile-muted); }
  html #content .v5-analytics-card strong { margin-top:8px; font-size:22px; color:var(--aq-mobile-text); }
  html #content .v5-quality-row { grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; padding:14px; border:1px solid var(--aq-mobile-divider); border-radius:14px; background:var(--aq-mobile-panel); }
  html #content .v5-quality-row strong { grid-column:1/-1; font-size:13px; line-height:1.5; color:var(--aq-mobile-text); }
  html #content .v5-quality-row span { font-size:11px; line-height:1.6; color:var(--aq-mobile-muted); }
  html #content .v5-quality-row:last-child { border-bottom:1px solid var(--aq-mobile-divider); }
}
@media (max-width:350px) {
  html #content .v5-analytics-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  html #content .v5-analytics-card:last-child { grid-column:1/-1; }
}
@media (max-width:700px) {
  html #content .v6-profile-row > .v6-alpha-note { display:none; }
}
