@media (max-width: 760px) {
  body {
    display: block;
  }

  .sidebar {
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: var(--spacing-16);
  }

  .brand {
    margin-bottom: var(--spacing-16);
  }

  .nav {
    display: flex;
    gap: var(--spacing-8);
    overflow-x: auto;
    padding-bottom: var(--spacing-4);
  }

  .nav-item {
    width: auto;
    flex: 0 0 auto;
    white-space: nowrap;
  }

.sidebar-footer {
    padding-top: var(--spacing-12);
  }

  .main {
    padding: var(--spacing-20) var(--spacing-16);
  }

  .view > .topbar {
    margin-right: calc(var(--spacing-16) * -1);
    margin-left: calc(var(--spacing-16) * -1);
    padding-right: var(--spacing-16);
    padding-left: var(--spacing-16);
  }

  .topbar {
    display: grid;
    align-items: start;
  }

  .topbar-actions,
  .vehicle-toolbar {
    justify-content: start;
  }

  .secondary-action {
    width: 100%;
  }

  .filters {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  body {
    min-height: 100dvh;
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
    overflow-x: hidden;
  }

  .sidebar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    min-height: 0;
    height: auto;
    max-height: none;
    border-top: 1px solid var(--line);
    border-right: 0;
    border-bottom: 0;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    overflow: hidden;
    background: color-mix(in srgb, var(--panel) 94%, transparent);
    box-shadow: 0 -10px 26px rgba(15, 23, 42, .08);
    backdrop-filter: blur(16px);
  }

  .brand,
  .sidebar-footer,
  .nav-divider {
    display: none;
  }

  .nav {
    display: flex;
    gap: 6px;
    padding: 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    flex: 0 0 auto;
    width: 92px;
    min-height: 58px;
    scroll-snap-align: center;
    justify-content: center;
    align-items: center;
    gap: 4px;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 7px 8px;
    text-align: center;
    flex-direction: column;
    font-size: 11px;
    line-height: 1.15;
    white-space: normal;
  }

  .nav-item svg {
    width: 20px;
    height: 20px;
  }

  .nav-item [data-nav-label] {
    max-width: 100%;
    white-space: nowrap;
  }

  .nav-item.active {
    border-color: var(--line);
    background: var(--soft-surface);
  }

  .main {
    min-height: calc(100dvh - 76px);
    height: auto;
    padding: 18px 14px 0;
    overflow: visible;
  }

  .view.active {
    height: auto;
    min-height: calc(100dvh - 94px - env(safe-area-inset-bottom));
    overflow: visible;
  }

  .view > .topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    margin-right: -14px;
    margin-left: -14px;
    padding: 12px 14px;
    background: color-mix(in srgb, var(--bg) 96%, transparent);
    backdrop-filter: blur(14px);
  }

  h1 {
    font-size: 24px;
  }

  .topbar {
    gap: 12px;
  }

  .topbar-actions,
  .vehicle-toolbar {
    display: flex;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
    justify-content: start;
    scrollbar-width: none;
  }

  .topbar-actions::-webkit-scrollbar,
  .vehicle-toolbar::-webkit-scrollbar {
    display: none;
  }

  .topbar-actions button,
  .vehicle-toolbar button {
    flex: 0 0 auto;
  }

  .filters {
    position: static;
    display: grid;
    gap: 8px;
    margin-bottom: 12px;
  }

  .table-shell,
  .simple-table-shell {
    max-width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
  }

  .vehicle-workspace,
  .driver-workspace {
    display: block;
    min-height: 0;
  }

  .vehicle-board {
    min-height: calc(100dvh - 190px - env(safe-area-inset-bottom));
    padding-top: 12px;
  }

  .vehicle-list {
    overflow: visible;
    padding-bottom: 14px;
  }

  .vehicle-card {
    min-height: 74px;
    border-radius: 10px;
  }

  .vehicle-edit-button {
    opacity: 1;
    pointer-events: auto;
  }

  .vehicle-inspector {
    display: none;
    min-height: 0;
    height: auto;
    overflow: visible;
    padding: 12px 0 16px;
  }

  .vehicle-workspace.is-mobile-detail-open .vehicle-board,
  .driver-workspace.is-mobile-detail-open .vehicle-board,
  .customer-workspace.is-mobile-detail-open .vehicle-board {
    display: none;
  }

  .vehicle-workspace.is-mobile-detail-open .vehicle-inspector,
  .driver-workspace.is-mobile-detail-open .vehicle-inspector,
  .customer-workspace.is-mobile-detail-open .vehicle-inspector {
    display: block;
  }

  .mobile-detail-back {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    margin-bottom: 12px;
    border: 1px solid var(--field-border);
    border-radius: var(--radius-buttons);
    padding: 9px 12px;
    color: var(--ink);
    background: var(--field-bg);
    font-size: 14px;
    font-weight: var(--font-weight-medium);
  }

  .mobile-detail-back::before {
    content: "‹";
    margin-right: 7px;
    font-size: 22px;
    line-height: 0;
  }

  .vehicle-profile {
    display: grid;
    gap: 14px;
  }

  .vehicle-profile-stats {
    grid-template-columns: 1fr;
  }

  .vehicle-detail-map {
    height: 280px;
  }

  .vehicle-profile-map {
    height: 300px;
  }

  .vehicle-inspector-head {
    align-items: center;
  }

  .driver-card .vehicle-card-facts {
    grid-template-columns: 1fr 1fr;
  }

  .customers-table,
  .customers-table thead,
  .customers-table tbody,
  .customers-table tr,
  .customers-table th,
  .customers-table td {
    display: block;
  }

  .customers-table {
    min-width: 0;
  }

  .customers-table thead {
    display: none;
  }

  .customers-table tr {
    border-bottom: 1px solid var(--line);
    padding: 12px;
    background: var(--panel);
  }

  .customers-table td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    width: auto;
    border: 0;
    padding: 6px 0;
  }

  .customers-table td::before {
    color: var(--muted);
    font-size: 12px;
    font-weight: var(--font-weight-medium);
  }

  .customers-table td:nth-child(1)::before { content: "№"; }
  .customers-table td:nth-child(2)::before { content: "Название"; }
  .customers-table td:nth-child(3)::before { content: "Контакт"; }
  .customers-table td:nth-child(4)::before { content: "Телефон"; }
  .customers-table td:nth-child(5)::before { content: "Email"; }
  .customers-table td:nth-child(6)::before { content: "Статус"; }
  .customers-table td:nth-child(7)::before { content: "Комментарий"; }
  .customers-table td:nth-child(8)::before { content: "Действия"; }

  .customers-table .cell-input,
  .customers-table .cell-select {
    width: 100%;
  }

  dialog {
    width: min(100vw - 18px, 720px);
    max-height: calc(100dvh - 18px);
  }

  #route-form,
  #driver-form,
  #vehicle-form,
  .status-dialog-content {
    padding: 18px;
  }
}

@media (min-width: 761px) {
  .mobile-detail-back {
    display: none;
  }
}
