@media (max-width: 760px){
  html{font-size:15px;-webkit-text-size-adjust:100%}
  body{display:block;min-height:100vh;padding-bottom:76px;overflow-x:hidden}
  aside{position:fixed;left:0;right:0;bottom:0;top:auto;height:auto;z-index:1000;padding:6px 8px calc(6px + env(safe-area-inset-bottom));background:var(--side);box-shadow:0 -8px 24px #10162526}
  aside .logo{display:none}
  aside nav{display:grid;grid-template-columns:repeat(6,1fr);gap:3px}
  .navbtn{display:flex;width:100%;min-width:0;height:52px;margin:0;padding:6px 1px;border-radius:10px;align-items:center;justify-content:center;text-align:center;font-size:9px;line-height:1.15;white-space:normal}
  .navbtn.active{background:var(--side2)}

  main{padding:14px 12px 18px;max-width:100%;overflow:hidden}
  header{display:flex;flex-direction:row;align-items:flex-start;justify-content:space-between;gap:10px;margin-bottom:4px}
  header h1{font-size:26px;line-height:1.1;margin-bottom:4px}
  header p{font-size:12px}
  .auth-card{padding:7px 9px;background:#fff;border-radius:999px;box-shadow:0 4px 14px #18274b0d;flex:0 0 auto}
  #authText{font-size:11px}
  .msg{font-size:13px;margin:6px 0 10px;min-height:18px}

  .panel,.card{border-radius:14px;box-shadow:0 5px 18px #18274b0d}
  .panel{padding:14px;margin-bottom:12px;overflow:hidden}
  .card{padding:14px}
  h2{font-size:20px;line-height:1.2}
  h3{font-size:18px}
  p{line-height:1.4}
  button,input,select,.download-link{min-height:44px;border-radius:11px}
  button,.download-link{touch-action:manipulation}

  .stats{grid-template-columns:1fr 1fr;gap:9px;margin:12px 0}
  .stats .card:last-child{grid-column:1/-1}
  .card b{font-size:25px}
  .card span{font-size:12px}
  .monitor-grid{grid-template-columns:1fr;gap:12px}

  .toolbar{align-items:stretch;gap:10px;margin-bottom:12px}
  .toolbar>div:first-child{min-width:0}
  .toolbar-group,.history-filters{width:100%;display:grid;grid-template-columns:1fr auto;gap:8px}
  .toolbar-group .search,.history-filters select{width:100%;min-width:0}
  .toolbar>.secondary{align-self:flex-start}

  /* Desktop tables become readable mobile cards. */
  table{display:block;width:100%;border-collapse:separate}
  table thead{display:none}
  table tbody{display:grid;width:100%;gap:10px}
  table tr{display:block;width:100%;padding:10px 12px;background:#fff;border:1px solid var(--line);border-radius:12px}
  table td{display:flex;width:100%;justify-content:space-between;align-items:flex-start;gap:14px;padding:7px 0;border-bottom:1px solid var(--line);text-align:right;word-break:break-word}
  table td:last-child{border-bottom:0;padding-bottom:0}
  table td:first-child{padding-top:0;font-weight:700}
  table td::before{flex:0 0 38%;color:var(--muted);font-size:11px;font-weight:700;text-align:left}
  table td>*{max-width:62%}
  table .actions{justify-content:flex-end}

  #monitorDevices td:nth-child(1)::before{content:'Компьютер'}
  #monitorDevices td:nth-child(2)::before{content:'ПВЗ'}
  #monitorDevices td:nth-child(3)::before{content:'Последний сигнал'}
  #monitorDevices td:nth-child(4)::before{content:'Версия'}
  #monitorDevices td:nth-child(5)::before{content:'Статус'}

  #locationsBody td:nth-child(1)::before{content:'Название'}
  #locationsBody td:nth-child(2)::before{content:'Адрес'}
  #locationsBody td:nth-child(3)::before{content:'График'}
  #locationsBody td:nth-child(4)::before{content:'Статус'}
  #locationsBody td:nth-child(5)::before{content:'Действия'}

  #computersBody td:nth-child(1)::before{content:'Название'}
  #computersBody td:nth-child(2)::before{content:'Windows'}
  #computersBody td:nth-child(3)::before{content:'ПВЗ'}
  #computersBody td:nth-child(4)::before{content:'Направление'}
  #computersBody td:nth-child(5)::before{content:'IP'}
  #computersBody td:nth-child(6)::before{content:'Последний сигнал'}
  #computersBody td:nth-child(7)::before{content:'Версия'}
  #computersBody td:nth-child(8)::before{content:'Статус'}
  #computersBody td:nth-child(9)::before{content:'Действия'}

  #historyBody td:nth-child(1)::before{content:'Дата'}
  #historyBody td:nth-child(2)::before{content:'ПВЗ'}
  #historyBody td:nth-child(3)::before{content:'Компьютер'}
  #historyBody td:nth-child(4)::before{content:'Открытие'}
  #historyBody td:nth-child(5)::before{content:'Проверка'}
  #historyBody td:nth-child(6)::before{content:'Запуск Windows'}
  #historyBody td:nth-child(7)::before{content:'Результат'}

  .issue-list{gap:8px}
  .issue-item{padding:11px}
  .notice{flex-direction:column;align-items:stretch;padding:13px}
  .notice button{width:100%}

  .settings-grid{grid-template-columns:1fr;gap:12px}
  .settings-wide{grid-column:auto}
  .kv{grid-template-columns:1fr;gap:4px}
  .kv>div:nth-child(odd){margin-top:8px;font-size:12px}
  .token-settings{display:grid;grid-template-columns:1fr 1fr;gap:8px}
  .token-settings input{grid-column:1/-1;min-width:0;width:100%}
  .token-settings .danger{grid-column:1/-1}

  .editgrid,.editgrid.device{grid-template-columns:1fr;gap:8px}
  .editor-actions{display:grid;grid-template-columns:1fr 1fr;gap:8px}
  .editor-actions button{width:100%}
  .editor-actions .danger,.editor-actions .push-right{grid-column:1/-1;margin-left:0}

  .schedule-head{display:none}
  .schedule-row{grid-template-columns:1fr 1fr;gap:8px;margin:8px 0;padding:12px;border:1px solid var(--line);border-radius:12px;background:#fafbfc}
  .schedule-row>b{grid-column:1/-1;font-size:16px}
  .schedule-row>.workcheck{grid-column:1/-1}
  .schedule-row input[type='time']{width:100%;min-width:0}

  form.grid{grid-template-columns:1fr;gap:8px}
  .code-options{display:grid;grid-template-columns:1fr;gap:8px}
  .code-options label{display:grid;grid-template-columns:110px 1fr;gap:8px}
  .code-options select{width:100%}
  .codebox{display:grid;grid-template-columns:1fr 1fr;gap:8px;align-items:stretch}
  .codebox code{grid-column:1/-1;width:100%;font-size:14px}
  .onboarding .download-link{width:100%;text-align:center;margin-top:4px}
  .download-link{display:flex;align-items:center;justify-content:center;text-align:center}
  .empty{padding:20px 8px}
}

@media (max-width: 430px){
  main{padding-left:10px;padding-right:10px}
  header h1{font-size:23px}
  #authText{display:none}
  .auth-card{padding:9px}
  .stats{grid-template-columns:1fr 1fr}
  .card{padding:12px}
  .card b{font-size:23px}
  .toolbar-group,.history-filters{grid-template-columns:1fr}
  .toolbar-group button,.history-filters button{width:100%}
  .editor-actions,.token-settings,.codebox{grid-template-columns:1fr}
  .editor-actions .danger,.token-settings input,.token-settings .danger,.codebox code{grid-column:auto}
  table td{gap:10px}
  table td::before{flex-basis:42%}
  table td>*{max-width:58%}
  .badge{font-size:11px;padding:5px 8px}
}
