/* Mobile SaaS polish for UmzugsBüro.
   Scope: small touch devices only. Desktop shell and workflow JS stay untouched. */
@media (max-width: 700px){
  html,
  body{
    width:100%;
    max-width:100%;
    overflow-x:hidden;
    background:#f6f7f9;
  }

  body{
    font-size:16px;
    line-height:1.42;
  }

  body:not(.jg-desktop-shell) .app{
    width:100%;
    max-width:none;
    padding:calc(10px + var(--safe-top)) 12px calc(104px + var(--safe-bottom));
  }

  body:not(.jg-desktop-shell) .topbar{
    margin:calc(-10px - var(--safe-top)) -12px 12px;
    padding:calc(10px + var(--safe-top)) 12px 10px;
    background:rgba(246,247,249,.94);
    border-bottom:1px solid rgba(226,232,240,.9);
    box-shadow:0 10px 26px rgba(15,23,42,.06);
  }

  .brand{
    min-width:0;
    align-items:center;
  }

  .brand .row{
    min-width:0;
    flex:1 1 auto;
    gap:9px;
  }

  .brand .row > div:last-child{
    min-width:0;
  }

  .brand h1{
    font-size:17px;
    line-height:1.05;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }

  .brand .sub{
    display:none;
  }

  .logo{
    width:36px;
    height:36px;
    border-radius:12px;
    flex:0 0 36px;
  }

  .main-tabs{
    margin-top:8px;
  }

  .mobile-nav-row{
    display:grid!important;
    grid-template-columns:minmax(0,1fr) minmax(82px,auto);
    gap:8px;
    align-items:center;
  }

  .mobile-main-select,
  .mobile-new-btn{
    min-height:46px;
    border-radius:16px;
    font-size:15px;
  }

  .mobile-main-select{
    border:1px solid rgba(203,213,225,.95);
    padding:0 12px;
    box-shadow:0 1px 2px rgba(15,23,42,.04);
  }

  .mobile-new-btn{
    padding-left:12px;
    padding-right:12px;
    white-space:nowrap;
  }

  .tabs{
    gap:7px;
    margin-top:8px;
    padding:0 2px 4px;
    scroll-snap-type:x proximity;
  }

  .tab{
    flex:0 0 auto;
    min-width:max-content;
    min-height:38px;
    padding:9px 12px;
    border-radius:999px;
    border:1px solid rgba(226,232,240,.95);
    font-size:12px;
    font-weight:850;
    scroll-snap-align:start;
  }

  #view,
  .card,
  .item,
  .overview-box,
  .settings-page,
  .settings-accordion,
  .settings-mini-card,
  .dash-card,
  .dashboard-calendar-card{
    min-width:0;
    max-width:100%;
  }

  .card,
  .dash-card,
  .item,
  .overview-box,
  .settings-accordion,
  .settings-mini-card,
  .upcoming-panel{
    border-radius:20px;
    box-shadow:0 1px 2px rgba(15,23,42,.04),0 12px 28px rgba(15,23,42,.06);
  }

  .card,
  .dash-card{
    padding:14px;
    margin-bottom:12px;
  }

  .section-title,
  .item-head,
  .compact-title,
  .tpl-row-head{
    display:grid;
    grid-template-columns:minmax(0,1fr);
    gap:8px;
    align-items:start;
  }

  .section-title h2{
    font-size:18px;
    line-height:1.18;
  }

  .section-title p,
  .hint,
  .muted{
    font-size:13px;
    line-height:1.42;
  }

  label{
    font-size:11px;
    margin-bottom:5px;
  }

  input,
  textarea,
  select{
    min-height:48px;
    border-radius:16px;
    padding:12px 13px;
    font-size:16px!important;
  }

  textarea{
    min-height:104px;
  }

  .grid,
  .grid.two,
  .grid.three,
  .settings-split,
  .settings-compact-grid,
  .settings-export-grid,
  .employee-row,
  .search-row{
    grid-template-columns:minmax(0,1fr)!important;
    gap:11px;
  }

  .actions,
  .doc-context-actions,
  .settings-hero-actions{
    display:grid!important;
    grid-template-columns:minmax(0,1fr);
    gap:8px;
  }

  .actions .btn,
  .doc-context-actions .btn,
  .section-title .btn,
  .compact-title .btn,
  .tpl-row-head .btn{
    width:100%;
    min-width:0;
  }

  .btn{
    min-height:48px;
    border-radius:16px;
    padding:12px 14px;
    text-align:center;
  }

  .btn.small{
    min-height:42px;
    border-radius:14px;
  }

  .bottom{
    padding:10px 12px calc(12px + var(--safe-bottom));
    background:rgba(255,255,255,.96);
    box-shadow:0 -12px 30px rgba(15,23,42,.10);
  }

  .bottom-inner{
    gap:8px;
  }

  .bottom .btn{
    min-height:50px;
    border-radius:18px;
  }

  .toast{
    left:12px;
    right:12px;
    bottom:calc(88px + var(--safe-bottom));
    transform:none;
    width:auto;
    border-radius:18px;
    text-align:center;
  }

  .dash-grid,
  .dashboard-grid{
    gap:11px;
  }

  .dash-metrics,
  .metric-grid{
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:9px;
  }

  .dash-metric,
  .metric{
    min-height:84px;
    border-radius:18px;
  }

  .dash-metric strong,
  .metric b{
    font-size:26px;
  }

  .dashboard-actions{
    grid-template-columns:minmax(0,1fr);
    gap:8px;
  }

  .calendar-head,
  .calendar-wrap:not(.calendar-compact) .calendar-head{
    display:grid;
    grid-template-columns:minmax(0,1fr);
    gap:8px;
  }

  .calendar-wrap:not(.calendar-compact) .calendar-controls{
    display:grid;
    grid-template-columns:minmax(0,1fr);
    gap:8px;
    margin-top:0;
  }

  .calendar-nav{
    width:100%;
    min-width:0;
    border-radius:16px;
  }

  .calendar-current{
    min-width:0;
    flex:1;
  }

  .calendar-grid{
    gap:4px;
  }

  .calendar-weekday{
    font-size:10px;
    padding:3px 0;
  }

  .calendar-day{
    min-height:52px;
    border-radius:12px;
    padding:5px;
  }

  .staff-badge{
    min-width:18px;
    height:18px;
    font-size:9px;
    padding:0 4px;
  }

  .overview-grid,
  .template-grid,
  .placeholder-grid,
  .info-grid{
    grid-template-columns:minmax(0,1fr)!important;
  }

  .overview-kv{
    grid-template-columns:minmax(0,1fr);
    gap:3px 0;
  }

  .price{
    white-space:normal;
  }

  .item{
    padding:13px;
  }

  .item-title{
    font-size:15px;
    line-height:1.25;
  }

  .item-desc{
    font-size:13.5px;
  }

  .photo-grid{
    gap:8px;
  }

  .photo-thumb{
    border-radius:16px;
  }

  .modal-backdrop.show{
    align-items:flex-end;
  }

  .modal{
    width:100vw;
    max-height:min(92dvh, 92vh);
    border-radius:26px 26px 0 0;
    padding:14px 12px calc(18px + var(--safe-bottom));
  }

  .modal h3{
    font-size:20px;
    line-height:1.18;
  }

  .settings-hero{
    padding:14px;
  }

  .settings-hero h2{
    font-size:20px;
  }

  .settings-quicknav{
    top:86px;
    margin-left:0;
    margin-right:0;
    padding:7px;
    border-radius:18px;
    width:100%;
    max-width:100%;
    min-width:0;
    overflow-x:auto;
    overflow-y:hidden;
    -webkit-overflow-scrolling:touch;
    touch-action:pan-x;
    position:sticky;
  }

  .settings-quicknav a{
    min-height:38px;
    padding:9px 12px;
    flex:0 0 auto;
    cursor:pointer;
    pointer-events:auto;
    user-select:none;
    -webkit-user-select:none;
    touch-action:manipulation;
    text-decoration:none;
  }

  .settings-accordion{
    scroll-margin-top:132px;
  }

  .settings-accordion>summary{
    padding:14px;
  }

  .settings-panel-body{
    padding:13px;
  }

  .jg-saas-login-brand{
    margin-bottom:14px;
  }

  .jg-saas-login-brand h2{
    font-size:25px;
  }

  .jg-saas-login-brand p{
    font-size:14px;
  }

  .jg-saas-login-logo{
    width:70px;
    height:70px;
    margin:0 auto 12px;
    border-radius:22px;
    display:grid;
    place-items:center;
  }

  .jg-saas-login-actions{
    display:grid!important;
    grid-template-columns:minmax(0,1fr);
    gap:9px;
  }

  .jg-forgot-password{
    justify-self:center;
    min-height:40px;
    padding:8px 12px;
  }

  .jg-saas-login-note{
    margin-top:14px!important;
    line-height:1.45;
  }

  .jg-data-table,
  .jg-settings-table-list{
    display:grid!important;
    gap:10px!important;
    border:0!important;
    background:transparent!important;
    overflow:visible!important;
  }

  .jg-table-head{
    display:none!important;
  }

  .jg-table-row{
    display:grid!important;
    grid-template-columns:minmax(0,1fr)!important;
    gap:9px!important;
    padding:13px!important;
    min-height:0!important;
    border:1px solid var(--line)!important;
    border-radius:18px!important;
    background:#fff!important;
    box-shadow:0 1px 2px rgba(15,23,42,.04)!important;
  }

  .jg-table-cell{
    min-width:0!important;
    display:grid!important;
    gap:4px!important;
    align-items:start!important;
  }

  .jg-table-cell[data-label]::before{
    content:attr(data-label);
    color:#64748b;
    font-size:11px;
    font-weight:900;
    letter-spacing:.055em;
    text-transform:uppercase;
  }

  .jg-table-cell > span,
  .jg-table-cell small,
  .jg-table-cell .hint{
    white-space:normal!important;
    overflow:visible!important;
    text-overflow:clip!important;
    line-height:1.35!important;
  }

  .jg-table-actions{
    display:grid!important;
    grid-template-columns:minmax(0,1fr)!important;
    gap:8px!important;
    width:100%!important;
    margin-top:2px!important;
  }

  .jg-table-actions .btn{
    width:100%!important;
    min-width:0!important;
  }

  /* Mobile settings overflow guard: no settings content may widen the viewport. */
  .settings-page,
  .settings-page *,
  .settings-accordion,
  .settings-panel-body,
  .settings-mini-card,
  .settings-list-compact,
  .settings-list-compact .item,
  .settings-export-grid,
  .settings-split,
  .settings-compact-grid,
  .overview-kv,
  .employee-row,
  .jg-data-table,
  .jg-table-row,
  .jg-table-cell{
    max-width:100%!important;
    min-width:0!important;
    box-sizing:border-box!important;
  }

  .settings-page{
    width:100%;
    overflow-x:hidden!important;
  }

  .settings-page .section-title,
  .settings-page .item-head,
  .settings-page .tpl-row-head,
  .settings-page .compact-title{
    width:100%;
    min-width:0!important;
  }

  .settings-page input,
  .settings-page textarea,
  .settings-page select,
  .settings-page button,
  .settings-page .btn{
    max-width:100%!important;
  }

  .settings-page p,
  .settings-page .hint,
  .settings-page .muted,
  .settings-page small,
  .settings-page span,
  .settings-page strong,
  .settings-page div{
    overflow-wrap:anywhere;
    word-break:normal;
  }

  .settings-page .status-chip-row,
  .settings-page .inspection-badges,
  .settings-page .mini-meta{
    min-width:0;
    max-width:100%;
    overflow:hidden;
  }

  .settings-page .status-chip{
    max-width:100%;
    white-space:normal;
    text-align:center;
  }
}

@media (max-width: 380px){
  body:not(.jg-desktop-shell) .app{
    padding-left:10px;
    padding-right:10px;
  }

  body:not(.jg-desktop-shell) .topbar{
    margin-left:-10px;
    margin-right:-10px;
    padding-left:10px;
    padding-right:10px;
  }

  .mobile-nav-row{
    grid-template-columns:minmax(0,1fr);
  }

  .mobile-new-btn{
    width:100%;
  }

  .dash-metrics,
  .metric-grid{
    grid-template-columns:minmax(0,1fr);
  }

  .bottom-inner{
    grid-template-columns:minmax(0,1fr);
  }
}
