/* Shared mobile layout. Loaded after each page's local desktop styles. */
html { -webkit-text-size-adjust:100%; }
.card,.panel,.topbar > *,main > *,section > * { min-width:0; }
@media (max-width:1024px) {
  .topbar { height:auto; min-height:56px; flex-wrap:wrap; gap:8px 16px; padding:10px 12px; }
  .topbar .user { flex-wrap:wrap; gap:8px; min-width:0; }
  .topbar .brand,.topbar .user > span { overflow-wrap:anywhere; }
  .mission-page,.cockpit { height:auto; grid-template-columns:minmax(0,1fr); padding:10px; }
  .mission-page > section { grid-template-rows:minmax(360px,60vh) auto !important; }
  .cockpit > section { grid-template-rows:minmax(360px,60vh) auto !important; }
  .mission-page > aside,.cockpit > aside { overflow:visible; }
  .cockpit > section > .panel { grid-template-columns:repeat(2,minmax(0,1fr)) !important; }
  .cockpit > section > .panel > :first-child { grid-column:1/-1; }
  .control-pad-v2 { grid-template-columns:repeat(2,minmax(0,1fr)); }
  #motion-panel,#video-float { max-width:calc(100vw - 24px) !important; max-height:calc(100dvh - 24px) !important; overflow-y:auto; }
}
@media (max-width:600px) {
  body { padding-left:env(safe-area-inset-left); padding-right:env(safe-area-inset-right); }
  button,select,input,textarea { font-size:16px !important; }
  button,select,input:not([type=checkbox]):not([type=radio]):not([type=range]) { min-height:44px; }
  button { white-space:normal; }
  input,select,textarea { max-width:100%; min-width:0; }
  input[type=checkbox],input[type=radio] { width:20px; height:20px; vertical-align:middle; flex-shrink:0; }
  input[type=range] { min-height:32px; }
  .topbar { align-items:flex-start; }
  .topbar .user { width:100%; font-size:13px; }
  .topbar .brand { font-size:16px; }
  .dev-info-inline { white-space:normal; overflow-wrap:anywhere; }
  .login-bg { height:auto; min-height:100vh; min-height:100dvh; padding:16px; }
  .login-box { width:100%; max-width:360px; padding:24px; margin:auto; }
  .dashboard { padding:12px; }
  .table-wrap { max-width:100%; overflow:auto; -webkit-overflow-scrolling:touch; }
  .vehicle-table { min-width:900px; }
  .vehicle-table button { margin:3px 0; }
  .more-dd > summary { min-height:44px; display:inline-flex; align-items:center; }
  #cockpit-wl-modal { padding:12px; }
  #cockpit-wl-modal > div { max-width:100%; max-height:calc(100dvh - 24px); overflow:auto; overflow-wrap:anywhere; }
  .control-page { padding:8px; }
  .status-grid,.control-pad,.control-pad-v2,.control-pad-v3,.bottom-row { grid-template-columns:minmax(0,1fr); }
  .row,.tool-row,.work-status-bar,.radar-status-row { flex-wrap:wrap; }
  .row > *, .tool-row > * { min-width:0; }
  .card-body { padding:10px; overflow-wrap:anywhere; }
  .card-title { font-size:15px; }
  .dp,.mc-btn { touch-action:none; -webkit-user-select:none; }
  .cam-video,.video-card-stacked .cam-video { height:auto !important; aspect-ratio:16/9; object-fit:contain; }
  .video-grid,.cockpit > section > .panel { grid-template-columns:minmax(0,1fr) !important; }
  .cockpit video { width:100%; height:auto !important; aspect-ratio:16/9; object-fit:contain; }
  .mission-page,.cockpit { padding:8px; gap:8px; }
  .mission-page > section,.cockpit > section { grid-template-rows:minmax(320px,55vh) auto !important; }
  .mini-table { table-layout:fixed; }
  .mini-table td { overflow-wrap:anywhere; }
  .status-box { overflow:auto; }
  .mission-page .status-box .mini-table { min-width:520px; }
  .panel .row > * { flex:1 1 100px; }
  #video-float { width:240px !important; }
  #motion-panel .mc-btn { min-height:42px; }
  .water-card { width:calc(100vw - 16px); max-width:calc(100vw - 16px); height:calc(100dvh - 24px); max-height:calc(100dvh - 24px); right:8px; bottom:12px; }
  .water-title { padding:6px 10px; }
  .water-close { min-width:44px; flex-shrink:0; }
  .water-card > .card-body { padding:10px; }
  /* Fixed-height status slots avoid layout jumps during live telemetry updates. */
  .water-info-row { grid-template-columns:1fr; grid-template-rows:1.6em 3.2em; height:5.2em; }
  .water-info-label { font-weight:600; color:#1d3d71; }
  .water-info-value { height:3.2em; white-space:normal; line-height:1.5; overflow:auto; overflow-wrap:anywhere; }
  .water-card [data-notice] { height:3.2em; white-space:normal; overflow:auto; }
  .water-settings-grid { grid-template-columns:minmax(0,1fr); }
  .water-settings { padding:8px; }
  .water-settings > summary { min-height:44px; padding:8px 0; }
  .water-actions button { flex:1 1 90px; }
  .water-test button { max-width:100%; margin:4px 0; }
}
@media (max-height:500px) and (max-width:1024px) {
  .water-card { max-height:calc(100dvh - 16px); bottom:8px; }
  .login-bg { align-items:flex-start; }
}

/* Vehicle rows become cards; no horizontal swipe needed to reach actions. */
@media (max-width:1024px) {
  .dashboard .table-wrap { overflow:visible; }
  .vehicle-table { display:block; width:100%; min-width:0; overflow:visible; background:none; box-shadow:none; }
  .vehicle-table thead { display:none; }
  .vehicle-table tbody { display:grid; gap:12px; }
  .vehicle-table tbody tr { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); background:#fff; border:1px solid #e0e6f0; border-radius:10px; box-shadow:0 2px 8px rgba(0,0,0,.05); overflow:visible; }
  .vehicle-table td { display:block; min-width:0; padding:9px 12px; overflow-wrap:anywhere; border-bottom:1px solid #eef1f7; }
  .vehicle-table td::before { content:attr(data-label); display:block; color:#68758a; font-size:12px; margin-bottom:4px; }
  .vehicle-cell-value { min-width:0; overflow-wrap:anywhere; line-height:1.6; }
  .vehicle-table .vehicle-cell-0,.vehicle-table .vehicle-cell-1,.vehicle-table .vehicle-cell-6,.vehicle-table .vehicle-cell-7,.vehicle-table .vehicle-cell-10 { grid-column:1/-1; }
  .vehicle-table .vehicle-cell-0 { background:#eaf1fc; border-radius:10px 10px 0 0; font-size:16px; color:#1a3d8f; }
  .vehicle-table .vehicle-cell-0::before,.vehicle-table .vehicle-cell-1::before,.vehicle-table .vehicle-cell-10::before { display:none; }
  .vehicle-table .vehicle-cell-10 { border-bottom:0; }
  .vehicle-cell-10 .vehicle-cell-value { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
  .vehicle-cell-10 a,.vehicle-cell-10 details { margin:0 !important; min-width:0; }
  .vehicle-cell-10 a { display:block; }
  .vehicle-cell-10 button,.vehicle-cell-10 summary { width:100%; min-height:44px; margin:0; font-size:14px; }
  .vehicle-cell-10 summary { display:flex; justify-content:center; align-items:center; }
  .vehicle-table .more-menu { max-width:calc(100vw - 16px); max-height:calc(100dvh - 16px); overflow:auto; }
  .vehicle-table .vehicle-empty { display:block; text-align:center; color:#68758a; }
  .vehicle-empty td::before { display:none; }
}
