@media (max-width: 760px) {
  #authRoot {
    inset: 0;
    width: 100%;
    max-width: 100vw;
    padding: 0;
    overflow-x: hidden;
  }

  #authRoot > *,
  .auth-shell,
  .auth-panel,
  .auth-form-wrap,
  .wizard-wrap,
  .auth-form,
  .auth-form label,
  .auth-form input,
  .auth-form select,
  .auth-form textarea,
  .auth-form button {
    min-width: 0;
    max-width: 100%;
  }

  .auth-top-nav {
    left: 10px;
    right: 10px;
    width: auto;
    max-width: none;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

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

  .auth-panel {
    box-sizing: border-box;
    width: 100%;
    padding-right: 20px;
    padding-left: 20px;
  }

  .auth-form-wrap,
  .wizard-wrap {
    width: min(520px, calc(100vw - 40px));
    max-width: 100%;
  }

  :root {
    --radius: 14px;
    --radius-md: 11px;
    --radius-lg: 16px;
  }

  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
  }

  body.mobile-menu-open {
    overflow: hidden;
    touch-action: none;
  }

  .app-shell,
  .main,
  #content,
  .content,
  .page,
  .page-body {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .app-shell,
  .main,
  #content {
    overflow-x: clip;
  }

  #content > *,
  .metric-grid > *,
  .grid-2 > *,
  .card,
  .page-head,
  .toolbar {
    min-width: 0;
    max-width: 100%;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 40px;
    grid-template-rows: 48px 46px;
    align-items: center;
    gap: 5px 9px;
    width: 100%;
    height: auto;
    min-height: 104px;
    padding: max(8px, env(safe-area-inset-top)) 14px 9px;
    background: var(--surface, #0f172a);
    border-bottom: 1px solid var(--line, #263449);
    box-shadow: 0 8px 22px rgba(2, 6, 23, .16);
    backdrop-filter: blur(16px);
  }

  .topbar > .header-back,
  .topbar > .header-app-logo,
  .topbar > .header-app-name {
    display: none !important;
  }

  #menuToggle {
    grid-column: 1;
    grid-row: 1;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid var(--line, #263449);
    border-radius: 12px;
    background: var(--surface-2, #172033);
    color: var(--ink, #f1f5f9);
    font-size: 21px;
  }

  .topbar > div:first-of-type {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    margin: 0 !important;
  }

  .topbar .eyebrow {
    overflow: hidden;
    margin: 0 0 2px;
    color: var(--muted, #94a3b8);
    font-size: 10px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar h1 {
    overflow: hidden;
    margin: 0;
    color: var(--ink, #f1f5f9);
    font-size: 16px;
    font-weight: 750;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .top-actions {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
    margin: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .top-actions::-webkit-scrollbar {
    display: none;
  }

  .global-search-wrap {
    display: flex;
    flex: 1 1 180px;
    min-width: 150px;
    max-width: none;
    gap: 6px;
  }

  .topbar .global-search {
    display: flex;
    flex: 1;
    width: auto;
    min-width: 0;
    height: 40px;
    padding: 0 11px;
    border: 1px solid var(--line, #263449);
    border-radius: 11px;
    background: var(--bg, #0b1220);
  }

  .topbar .global-search input {
    min-width: 0;
    color: var(--ink, #f1f5f9);
    font-size: 13px;
  }

  .topbar .global-search input::placeholder {
    color: var(--muted, #94a3b8);
    opacity: .9;
  }

  .top-actions > .topbar-tool,
  .top-actions > .icon-btn,
  .top-actions > #headerThemePicker,
  .top-actions .global-search-voice {
    display: inline-grid;
    flex: 0 0 40px;
    place-items: center;
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--line, #263449);
    border-radius: 11px;
    background: var(--surface-2, #172033);
    color: var(--ink, #f1f5f9);
  }

  .top-actions > .topbar-tool b {
    display: none;
  }

  .top-actions > #headerThemePicker {
    flex-basis: 104px;
    width: 104px;
    padding: 0 8px;
    font-size: 12px;
  }

  #assistantHeaderBtn {
    grid-column: 3;
    grid-row: 1;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 12px;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 80;
    display: flex;
    width: min(88vw, 340px);
    height: 100dvh;
    max-height: 100dvh;
    padding: max(16px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
    overflow: hidden;
    border-right: 1px solid rgba(148, 163, 184, .18);
    box-shadow: 24px 0 60px rgba(2, 6, 23, .32);
    overscroll-behavior: contain;
    transition: transform .24s ease, visibility .24s ease;
  }

  .sidebar.open {
    transform: translate3d(0, 0, 0) !important;
    visibility: visible !important;
  }

  .sidebar .brand {
    flex: 0 0 auto;
    padding: 7px 8px 17px;
    border-bottom: 1px solid rgba(148, 163, 184, .14);
  }

  .sidebar #nav {
    flex: 1 1 auto;
    min-height: 0;
    padding: 10px 2px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #475569 transparent;
  }

  .sidebar .nav-group-title {
    padding: 15px 11px 7px;
    color: #93a4bd;
    font-size: 10px;
    letter-spacing: .1em;
  }

  .sidebar .nav-button {
    min-height: 44px;
    padding: 10px 11px;
    gap: 11px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.3;
  }

  .sidebar .nav-button.active {
    background: color-mix(in srgb, var(--brand, #2563eb) 22%, #111827);
    box-shadow: inset 3px 0 var(--brand-2, #38bdf8);
  }

  .sidebar .submenu {
    margin: 3px 0 6px 14px;
    padding: 3px 0 3px 9px;
    border-left: 1px solid rgba(148, 163, 184, .24);
  }

  .sidebar .submenu .nav-button {
    min-height: 40px;
    padding: 8px 10px;
    font-size: 12px;
  }

  .sidebar .sidebar-bottom {
    flex: 0 0 auto;
    padding-top: 9px;
    background: #0c1020;
  }

  .mobile-overlay.open {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: block;
    background: rgba(2, 6, 23, .58);
    backdrop-filter: blur(2px);
  }

  .content {
    padding: 18px 14px calc(32px + env(safe-area-inset-bottom));
  }

  .page-head {
    align-items: stretch;
    gap: 12px;
    margin-bottom: 16px;
  }

  .page-head h2 {
    font-size: clamp(20px, 5.5vw, 25px);
    line-height: 1.2;
    letter-spacing: -.025em;
  }

  .page-head p {
    font-size: 13px;
    line-height: 1.5;
  }

  .page-head .actions,
  .actions,
  .toolbar,
  .tabs,
  .appointment-nav {
    width: 100%;
    min-width: 0;
    gap: 8px;
  }

  .actions > button,
  .page-head .actions > button {
    min-height: 40px;
    max-width: 100%;
  }

  .metric-grid,
  .grid-2,
  .settings-layout,
  .import-lanes,
  .messaging-settings-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .metric,
  .card,
  .settings-sidebar,
  .messaging-settings-card {
    min-width: 0;
    padding: 14px;
    border-radius: 14px;
  }

  .card + .card {
    margin-top: 12px;
  }

  .card-head {
    align-items: flex-start;
    gap: 9px;
    flex-wrap: wrap;
  }

  .table-wrap {
    max-width: 100%;
    overflow-x: auto !important;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }

  table {
    max-width: none;
  }

  th,
  td {
    padding: 10px 9px;
    font-size: 12px;
  }

  .toolbar,
  .group-toolbar,
  .quick-notes-toolbar,
  .loan-toolbar {
    align-items: stretch;
    flex-wrap: wrap;
    margin-block: 12px;
  }

  .toolbar > input,
  .toolbar > select,
  .toolbar > .control,
  .toolbar > .search,
  .group-toolbar > .search,
  .quick-notes-toolbar > label,
  .control.search {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  input,
  select,
  textarea {
    max-width: 100%;
    min-height: 42px;
    font-size: 16px;
  }

  input[type="checkbox"],
  input[type="radio"] {
    min-height: 0;
  }

  textarea {
    min-height: 96px;
  }

  .form-grid,
  .settings-grid,
  .product-picker,
  .appointment-board,
  .dialog-catalog {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .field,
  .field.full,
  .form-grid > *,
  .settings-grid > * {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .tabs {
    display: flex;
    max-width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .tabs > * {
    flex: 0 0 auto;
    min-height: 40px;
  }

  .dialog-module {
    min-height: 88px;
  }

  dialog {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    max-height: calc(100dvh - 24px);
    border-radius: 16px;
  }

  dialog > form,
  dialog > .dialog-shell {
    max-height: calc(100dvh - 24px);
  }

  dialog header,
  dialog footer {
    gap: 8px;
    padding: 12px 14px;
  }

  dialog footer {
    flex-wrap: wrap;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  dialog footer button {
    min-height: 42px;
  }

  .chart {
    gap: 6px;
    overflow: hidden;
  }

  .customer-banners {
    height: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 9px;
  }

  .customer-banners button {
    min-height: 40px;
  }

  .group-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .group-metrics article {
    min-width: 0;
    padding: 12px;
  }

  .group-cards {
    grid-template-columns: minmax(0, 1fr);
    padding: 10px;
  }

  .group-card {
    min-width: 0;
  }

  .appointment-board {
    display: grid;
  }

  .cart-line {
    grid-template-columns: minmax(0, 1fr) 58px 78px 34px;
    gap: 6px;
  }

  .metric-grid .metric strong {
    overflow-wrap: anywhere;
    font-size: 20px;
  }

  * {
    scroll-margin-top: 116px;
  }
}

@media (max-width: 380px) {
  .topbar {
    padding-right: 10px;
    padding-left: 10px;
  }

  .top-actions {
    gap: 6px;
  }

  .top-actions > .topbar-tool,
  .top-actions > .icon-btn,
  .top-actions .global-search-voice {
    flex-basis: 38px;
    width: 38px;
    min-width: 38px;
    height: 38px;
  }

  .content {
    padding-right: 10px;
    padding-left: 10px;
  }

  .metric-grid,
  .group-metrics {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) and (max-width: 760px) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
