/* Tablet layout */
@media (min-width:651px) and (max-width:1100px){
  .content{padding:18px 16px 36px}.panel{margin:18px 16px;padding:22px}.topbar{padding:16px 18px}
  .top-actions{flex:1;justify-content:flex-end}.search-wrap{flex:1;max-width:430px}.search-wrap input{width:100%;min-width:180px}
  .filters{display:grid;grid-template-columns:repeat(3,minmax(0,1fr))}.filters select{width:100%;min-width:0;max-width:none}.filter-count{grid-column:1/-1;margin-left:0}
  .modal{width:min(700px,calc(100vw - 100px))}.map-filters{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));width:100%}.map-filters select{width:100%;max-width:none}
}

/* Phone layout */
@media (max-width:650px){
  html{-webkit-text-size-adjust:100%}body{padding-bottom:0}.shell{display:block;min-height:100vh;padding-bottom:calc(66px + env(safe-area-inset-bottom))}.main{min-width:0}
  .sidebar{position:fixed;z-index:1000;left:0;right:0;top:auto;bottom:0;height:calc(66px + env(safe-area-inset-bottom));padding:7px 8px env(safe-area-inset-bottom);display:flex;flex-direction:row;align-items:center;gap:4px;border:0;border-top:1px solid #dfe3e8;box-shadow:0 -5px 20px #15223918;background:#fff}
  .sidebar .brand,.side-user{display:none}.sidebar .nav{display:flex;flex:1;gap:2px;overflow-x:auto;overscroll-behavior-x:contain;scrollbar-width:none}.sidebar .nav::-webkit-scrollbar{display:none}.sidebar .nav button,.side-bottom button{min-width:48px;width:48px;height:48px;padding:0;justify-content:center;border-radius:10px}.sidebar .nav button span,.side-bottom button span{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.sidebar .nav svg,.side-bottom svg{width:21px;height:21px}.side-bottom{margin:0;display:flex}.sidebar .nav button.active{background:#e9edf2;color:#182231}
  .topbar{position:sticky;top:0;z-index:8;min-height:auto;padding:13px 14px;gap:10px;align-items:stretch;background:#fffffffa;backdrop-filter:blur(8px)}.topbar h1{font-size:1.35rem}.top-actions{display:grid;grid-template-columns:1fr 1fr;width:100%;gap:8px}.search-wrap{grid-column:1/-1}.search-wrap input{width:100%;height:42px}.top-actions>.button{width:100%;min-width:0;padding:9px 8px;font-size:.8rem;white-space:nowrap}
  .content{padding:12px 10px 26px}.stats{display:flex;gap:8px;overflow-x:auto;overscroll-behavior-x:contain;scroll-snap-type:x proximity;margin:0 -10px 18px;padding:0 10px 4px;scrollbar-width:none}.stats::-webkit-scrollbar{display:none}.stat{flex:0 0 132px;min-height:78px;padding:11px;scroll-snap-align:start}.stat strong{font-size:1.12rem;margin-bottom:5px}.stat span{font-size:.76rem}.reminders-head{padding:0 2px}.reminder-title{min-height:46px}.reminder-list>button{min-height:48px}
  .filters{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.filters select{width:100%;min-width:0;max-width:none;height:42px;padding-left:9px;font-size:.79rem}.filter-count{grid-column:1/-1;width:auto;margin:0;padding:2px;color:#5f6b7b}.bulkbar{align-items:stretch}.bulkbar select,.bulkbar input{max-width:100%;flex:1}.bulkbar .button{flex:1}
  .contacts-table{min-width:0;display:block;background:transparent}.contacts-table thead{display:none}.contacts-table tbody{display:grid;gap:9px}.contacts-table tr{display:grid;background:#fff;border:1px solid #dfe4ea;border-radius:10px;padding:7px 11px;box-shadow:0 1px 2px #20273308}.contacts-table tr.current{border-color:#6e91bd;background:#f7faff}.contacts-table td{display:flex;align-items:center;justify-content:space-between;gap:14px;width:auto!important;padding:7px 0!important;border-bottom:1px solid #edf0f3;text-align:right;overflow-wrap:anywhere}.contacts-table td:last-child{border-bottom:0}.contacts-table td::before{color:#758091;font-size:.7rem;font-weight:600;text-align:left;white-space:nowrap}.contacts-table td:first-child:empty{display:none}.contacts-table td:first-child:not(:empty){justify-content:flex-start}.contacts-table td:nth-child(2)::before{content:'Firma'}.contacts-table td:nth-child(3)::before{content:'Jméno'}.contacts-table td:nth-child(4)::before{content:'E-mail'}.contacts-table td:nth-child(5)::before{content:'Pozice'}.contacts-table td:nth-child(6)::before{content:'Stav'}.contacts-table td:nth-child(7)::before{content:'Vytvořeno'}.contacts-table td:nth-child(8)::before{content:'Poslední kontakt'}.contacts-table td:nth-child(9)::before{content:'Další kontakt'}.contacts-table td:nth-child(10)::before{content:'Obchodník'}.contacts-table-wrap{border:0;background:transparent;overflow:visible}.pagination{justify-content:space-between}.pagination .button{min-width:86px}
  .detail{z-index:1100;width:100%;padding:12px 15px calc(28px + env(safe-area-inset-bottom));box-shadow:none}.detail-head{position:sticky;top:-12px;z-index:2;background:#fff;padding:9px 0}.detail h2{margin-top:4px}.kv{grid-template-columns:105px minmax(0,1fr)}.detail-actions .button{flex:1}
  .panel{margin:0;border:0;border-radius:0;padding:18px 14px 28px;max-width:none}.panel .section-head{align-items:flex-start;flex-direction:column}.panel .section-head>.button{width:100%}.user-row{align-items:flex-start}.permission-grid{padding:0 12px 14px}.table-wrap{max-width:100%;-webkit-overflow-scrolling:touch}.import-table,.audit-table,.backup-table{min-width:690px}
  .profile-identity{align-items:center;gap:15px}.avatar-large{width:86px;height:86px}.avatar-grid{grid-template-columns:repeat(3,76px);gap:12px;justify-content:center}.avatar-choice{width:76px;height:76px;padding:4px}.avatar-option{width:66px;height:66px}.user-identity{align-items:flex-start}.avatar-medium{width:46px;height:46px}
  .modal-backdrop{z-index:1200;align-items:end;padding:0}.modal{width:100%;max-height:92dvh;border-radius:16px 16px 0 0;padding:18px 14px calc(22px + env(safe-area-inset-bottom))}.modal .close-row{position:sticky;top:-18px;z-index:2;background:#fff;padding:8px 0}.form-grid{gap:13px}.field input,.field select,.field textarea{font-size:16px;min-height:44px}.form-actions{position:sticky;bottom:calc(-22px - env(safe-area-inset-bottom));background:#fff;padding:12px 0 calc(8px + env(safe-area-inset-bottom));margin-top:8px}.form-actions .button{flex:1}.file-drop{padding:20px 12px}
  .map-page{padding:10px}.map-toolbar{gap:10px}.map-filters{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));width:100%}.map-filters label{min-width:0}.map-filters select{height:44px;font-size:.8rem}.map-stage{height:calc(100dvh - 250px);min-height:390px;border-radius:10px}.distance-panel{max-height:190px;overflow:auto}.leaflet-control-zoom a{width:36px;height:36px;line-height:36px}#toast{left:10px;right:10px;bottom:calc(76px + env(safe-area-inset-bottom));max-width:none;text-align:center}
  .login-page{min-height:100dvh}.login-brand{min-height:135px;padding:22px}.login-brand p{font-size:1.35rem;margin:18px 0 0}.login-panel{padding:30px 20px}.login-card h1{font-size:1.75rem}.login-card input{font-size:16px;min-height:46px}
}

@media (max-width:380px){.filters{grid-template-columns:1fr}.top-actions{grid-template-columns:1fr}.stat{flex-basis:122px}.map-filters{grid-template-columns:1fr}.detail{padding-left:12px;padding-right:12px}}
