@media (max-width: 1100px) {
  .stats-grid,
  .info-grid,
  .crm-field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(320px, calc(100vw - 64px));
    height: 100vh;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    padding: 24px 18px;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 20px 0 48px rgba(15, 23, 42, 0.18);
    z-index: 60;
  }

  .app-shell.nav-open .sidebar {
    transform: translateX(0);
  }

  .sidebar nav {
    grid-template-columns: 1fr;
    gap: 8px;
    overflow-y: auto;
  }

  .nav-backdrop {
    position: fixed;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: rgba(15, 23, 42, 0.36);
    cursor: pointer;
    z-index: 50;
  }

  .nav-backdrop[hidden] {
    display: none;
  }
  
  .nav-link {
    justify-content: flex-start;
  }
  
  .nav-link:hover {
    transform: none;
  }

  .mobile-nav-toggle {
    display: inline-flex;
    width: 38px;
    min-width: 38px;
    padding: 0;
  }

  .mobile-nav-toggle span {
    display: none;
  }

  .main {
    padding: 24px 20px;
  }

  .topbar,
  .profile-head,
  .crm-record-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .topbar {
    flex-direction: row;
    align-items: center;
  }

  .topbar-actions {
    flex-shrink: 0;
  }

  .chart-panel .panel-title {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .profile-actions {
    justify-items: start;
    width: 100%;
  }
  
  .profile-actions button,
  .profile-actions a {
    width: 100%;
  }

  .detail-list-row,
  .detail-list-compact .detail-list-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .detail-record-list,
  .detail-list {
    padding-right: 16px;
    padding-left: 16px;
  }

  .detail-record-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .crm-record-amount {
    justify-items: start;
  }

  .echart {
    height: 300px;
    min-height: 300px;
  }

  .echart-tall {
    height: 340px;
    min-height: 340px;
  }

  .crm-followup-item {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .login-card {
    grid-template-columns: 1fr;
  }

  .login-hero {
    min-height: 280px;
    padding: 32px;
  }

  .login-form {
    padding: 28px;
  }
}

@media (max-width: 560px) {
  .stats-grid,
  .info-grid,
  .crm-field-grid {
    grid-template-columns: 1fr;
  }

  .crm-field.wide {
    grid-column: span 1;
  }

  .toolbar,
  .user-form,
  .inline-form,
  .import-card form,
  .dashboard-filters,
  .row-form,
  .mini-link-form {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }
  
  .toolbar label,
  .dashboard-filters label {
    width: 100%;
  }
  
  .toolbar label select,
  .dashboard-filters label select,
  .dashboard-filters label input {
    width: 100%;
  }

  .transaction-tabs {
    grid-template-columns: 1fr;
  }

  .transaction-type-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .employee-form-grid {
    grid-template-columns: 1fr;
  }

  .employee-form-section,
  .employee-toggle-grid {
    grid-column: span 1;
  }

  .wework-page-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .wework-company-head {
    align-items: stretch;
    flex-direction: column;
  }

  .wework-company-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
    gap: 8px;
  }

  .wework-company-metrics span {
    justify-content: space-between;
  }

  .wework-company-card-grid,
  .wework-company-card-metrics {
    grid-template-columns: 1fr;
  }

  .ledger-month-summary {
    align-items: stretch;
    flex-direction: column;
  }

  .ledger-month-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
    gap: 8px;
  }

  .ledger-month-metrics span {
    justify-content: space-between;
  }

  input,
  select,
  button,
  .primary-btn,
  .ghost-btn {
    width: 100%;
  }

  .topbar-actions {
    width: auto;
    flex-wrap: nowrap;
  }

  .topbar-actions .mobile-nav-toggle,
  .topbar-actions .theme-toggle {
    width: 38px;
    min-width: 38px;
    flex: 0 0 38px;
  }

  .topbar-actions a.ghost-btn {
    width: auto;
    white-space: nowrap;
  }

  .echart,
  .echart-tall {
    height: 280px;
    min-height: 280px;
  }
}
