/* Phone layout. Desktop rules are intentionally left unchanged. */
@media (max-width: 700px) {
  html { -webkit-text-size-adjust: 100%; }
  body { overflow-x: hidden; }
  .app { display: block; min-width: 0; }
  aside {
    position: sticky; top: 0; z-index: 30;
    display: flex; flex-wrap: nowrap; gap: 6px;
    padding: 8px 10px;
    overflow-x: auto; overscroll-behavior-x: contain;
    scrollbar-width: none; box-shadow: 0 2px 12px #0005;
  }
  aside::-webkit-scrollbar { display: none; }
  .brand { flex: 0 0 auto; font-size: 16px; margin: 0 8px 0 0; }
  aside .nav { flex: 0 0 auto; width: auto; min-height: 42px; padding: 8px 11px; margin: 0; font-size: 13px; }
  main { padding: 14px 10px 28px; min-width: 0; }
  .top { display: block; margin-bottom: 12px; }
  .top h1 { font-size: clamp(20px, 5vw, 25px); }
  .top .controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
  .top .controls > * { min-height: 42px; }
  button, select { touch-action: manipulation; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .stat { min-width: 0; padding: 9px 7px; }
  .stat small { display: block; font-size: 11px; line-height: 1.3; overflow-wrap: anywhere; }
  .stat b { font-size: clamp(18px, 5vw, 23px); }
  .layout { display: flex; flex-direction: column; gap: 12px; }
  .layout > .card:first-child { min-height: 0; display: block; }
  .toolbar { padding: 10px; align-items: stretch; }
  .toolbar .controls { width: 100%; display: flex; flex-wrap: wrap; }
  .toolbar .controls > * { min-height: 40px; }
  .map-scroll, .layout > .card:first-child > .map-scroll {
    width: 100%; height: min(58dvh, 600px); min-height: 300px;
    overflow: auto; overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y;
  }
  .map-inner { width: max-content; min-width: 100%; }
  .gridrow { width: max-content; min-width: 100%; grid-template-columns: 42px repeat(15, 42px); height: 42px; }
  .gridrow.header { height: 42px; }
  .gridrow .cell:not(.floor), .gridrow.header .cell:not(.floor) { min-width: 42px; font-size: 12px; }
  .gridrow .cell.floor { position: sticky; left: 0; z-index: 2; min-width: 42px; padding-left: 6px; background: #142a3c; }
  .gridrow.header .cell.floor { z-index: 6; }
  .gridrow .cell.editable { touch-action: manipulation; }
  .right { display: block; margin-top: 0; }
  .right .card { margin-bottom: 12px; }
  .panel { padding: 13px; }
  .auth-overlay { padding: 10px; align-items: center; }
  .auth-dialog { width: min(100%, 520px); max-height: calc(100dvh - 20px); overflow-y: auto; padding: 18px 15px; }
  .auth-dialog input:not([type="checkbox"]), .auth-dialog select { max-width: 100%; min-height: 44px; font-size: 16px; }
  .auth-dialog button { min-height: 44px; }
}

@media (max-width: 380px) {
  main { padding-inline: 7px; }
  .stat small { font-size: 10px; }
  .toolbar { padding: 8px; }
}
