@media (max-width: 900px) {
  .app {
    display: flex;
    flex-direction: column;
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .global-sidebar {
    height: auto;
    max-height: none;
    position: static;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    overflow-y: visible;
  }

  .sidebar-top {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 12px;
  }

  .sidebar-brand {
    padding: 0;
    border-bottom: 0;
  }

  .sidebar-nav {
    margin: 0;
    flex-direction: row;
    gap: 6px;
  }

  .nav-item {
    padding: 8px 12px;
    font-size: 13px;
    min-height: 44px;
  }

  .sidebar-footer {
    display: none;
  }

  .patient-panel {
    height: auto;
    max-height: 240px;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .panel-header {
    padding: 12px 16px 10px;
  }

  .panel-title-row {
    margin-bottom: 8px;
  }

  .patient-list {
    max-height: 180px;
    padding: 0 8px 10px;
  }

  .patient-row {
    padding: 10px 9px;
    border-radius: 10px;
    min-height: 44px;
  }

  .main {
    height: auto;
    max-height: none;
    overflow: visible;
    padding: 16px 14px 28px;
  }

  .empty {
    min-height: 44vh;
    padding: 16px;
  }

  .empty h2,
  .page h1 {
    font-size: 29px;
    line-height: 1.08;
  }

  .empty p,
  .meta {
    font-size: 15px;
    line-height: 1.35;
  }

  .page-head {
    margin-bottom: 16px;
  }

  .eyebrow {
    font-size: 10px;
  }

  .actions {
    gap: 8px;
  }

  .btn {
    padding: 9px 12px;
    min-height: 40px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.15;
  }

  .tabs {
    margin: 0 -2px 14px;
  }

  .tab {
    padding: 9px 10px;
    font-size: 14px;
  }

  .panel,
  .form-section {
    padding: 14px;
    border-radius: 14px;
  }

  .section-title,
  .form-section h2 {
    margin-bottom: 12px;
    font-size: 22px;
  }

  .grid {
    gap: 11px;
  }

  .field {
    gap: 5px;
  }

  .field label {
    font-size: 12px;
  }

  .field input,
  .field textarea,
  .field select {
    padding: 9px 10px;
    min-height: 39px;
    border-radius: 9px;
    font-size: 15px;
  }

  .field textarea {
    min-height: 68px;
  }

  .savebar {
    position: static;
    display: grid;
    gap: 10px;
    margin-top: 16px;
    padding: 11px;
  }

  .savebar .actions,
  .savebar .btn {
    width: 100%;
  }

  .savebar .actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .event {
    gap: 7px;
    padding: 12px;
  }

  .event time {
    font-size: 12px;
  }

  .form-shell .page-head {
    margin-top: 12px;
  }
}

/* Мобильная адаптация медицинских инструментов (Mobile First 390px, min 44px tap targets) */
@media (max-width: 600px) {
  .tools-search-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .tools-search-bar input[type="search"] {
    width: 100%;
    min-height: 44px;
    font-size: 15px;
  }

  .tools-categories {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
  }

  .tools-categories .btn {
    min-height: 44px;
    padding: 10px 14px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .tool-card {
    min-height: 120px;
    padding: 16px;
  }

  .field input,
  .field select,
  .field textarea,
  .btn.primary {
    min-height: 44px;
    font-size: 15px;
  }

  /* Чекбоксы и списки факторов риска для комфортного тапа */
  .rmi-u-cb,
  .musa-cb,
  .rcog-cb,
  .pe-high-cb,
  .pe-mod-cb,
  .mec4-cb,
  .mec3-cb {
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
    cursor: pointer;
  }

  label:has(input[type="checkbox"]) {
    min-height: 44px;
    padding: 6px 0;
  }

  /* Мобильная адаптация CRM V3 (Сегодня, Контроль, Следующее действие) */
  .metrics-row {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 20px;
  }

  .metric-card {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .metric-title {
    margin-bottom: 0;
    font-size: 14px;
  }

  .metric-num {
    font-size: 26px;
  }

  .action-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px;
  }

  .card-center {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
  }

  .card-right {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }

  .card-right .btn {
    min-height: 44px;
    justify-content: center;
  }

  .chip-group-scroll {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
  }

  .chip-group-scroll .chip {
    flex-shrink: 0;
    min-height: 40px;
  }

  .control-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .control-search-wrap {
    width: 100%;
  }

  .control-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
  }

  .control-tabs .btn {
    flex-shrink: 0;
    min-height: 40px;
    white-space: nowrap;
  }

  .next-action-content {
    flex-direction: column;
    align-items: stretch;
  }

  .next-action-btns {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .next-action-btns .btn {
    min-height: 44px;
    justify-content: center;
  }

  /* CRM V3.1 Mobile Art & Optimization */
  .service-cards-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .service-item-card {
    padding: 14px;
  }

  .finance-metrics-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .fin-metric-card {
    padding: 12px;
  }

  .fin-metric-num {
    font-size: 17px;
  }

  .fin-visit-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px 8px;
  }

  .fin-visit-mid {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .fin-visit-right {
    justify-content: space-between;
    width: 100%;
  }

  .patient-finance-card {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .patient-finance-metrics {
    gap: 14px;
  }

  .p-fin-last {
    border-left: none;
    border-top: 1px solid #e2e8f0;
    padding-left: 0;
    padding-top: 8px;
    width: 100%;
  }

  .exam-service-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .qty-btn {
    min-width: 36px;
    min-height: 36px;
  }

  .qty-input {
    min-height: 36px;
  }

  .exam-srv-price-input {
    min-height: 36px;
  }

  .billing-discount-row {
    flex-direction: column;
    align-items: stretch;
  }

  .billing-payment-row {
    flex-direction: column;
    align-items: stretch;
  }

  .pay-amount-input {
    width: 100%;
    min-height: 44px;
  }

  .nav-item {
    min-height: 44px;
  }
}


