/* Final mobile product layer. Loaded after every legacy mobile stylesheet. */
@media (max-width: 760px) {
  :root {
    --mobile-v2-dock-height: 72px;
    --mobile-v2-gutter: 12px;
    --mobile-vv-bottom: 0px;
  }

  html {
    background: #f3f0e8;
    scroll-padding-bottom: calc(
      var(--mobile-v2-dock-height) + 28px + env(safe-area-inset-bottom)
    );
  }

  body.mobile-app-v2 {
    min-width: 320px;
    max-width: 100%;
    overflow-x: hidden;
    padding-bottom: calc(
      var(--mobile-v2-dock-height) + 30px + env(safe-area-inset-bottom)
    );
    background: #f3f0e8;
  }

  body.mobile-app-v2 .app-shell {
    display: block;
    min-height: 100svh;
  }

  body.mobile-app-v2 .sidebar {
    position: sticky;
    top: 0;
    z-index: 120;
    width: 100%;
    height: 58px;
    min-height: 58px;
    padding: 8px 14px;
    overflow: visible;
    border: 0;
    border-bottom: 1px solid #d8d2c7;
    background: #ebe6dc;
    box-shadow: 0 6px 18px rgba(23, 26, 24, 0.06);
  }

  body.mobile-app-v2 .brand {
    min-height: 42px;
    padding: 0;
    gap: 9px;
  }

  body.mobile-app-v2 .brand-mark {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border-radius: 12px;
  }

  body.mobile-app-v2 .brand strong {
    font-size: 16px;
    font-weight: 730;
    letter-spacing: -0.02em;
  }

  body.mobile-app-v2 .brand small,
  body.mobile-app-v2 .workspace-card,
  body.mobile-app-v2 .sidebar-footer,
  body.mobile-app-v2 .sidebar::after {
    display: none !important;
  }

  /* The legacy navigation remains as the source of truth, but is not rendered on phones. */
  body.mobile-app-v2 .nav-list {
    display: none !important;
  }

  body.mobile-app-v2 .app-main {
    width: 100%;
    max-width: none;
    padding: 14px var(--mobile-v2-gutter)
      calc(var(--mobile-v2-dock-height) + 36px + env(safe-area-inset-bottom));
  }

  body.mobile-app-v2 .topbar {
    min-height: 0;
    padding: 0 0 12px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 9px 10px;
    border-bottom: 1px solid #d8d2c7;
  }

  body.mobile-app-v2 .topbar-copy {
    min-width: 0;
  }

  body.mobile-app-v2 .topbar .eyebrow {
    margin: 0 0 4px;
    color: #7d837e;
    font-size: 12px;
    letter-spacing: 0.1em;
  }

  body.mobile-app-v2 .topbar h1 {
    margin: 0;
    font-size: 27px;
    line-height: 1.08;
    letter-spacing: -0.045em;
  }

  body.mobile-app-v2 .page-subtitle {
    display: none;
  }

  body.mobile-app-v2 .usynai-topbar-actions {
    width: auto;
    margin: 0;
    display: flex;
    align-items: flex-end;
    flex-direction: column;
    gap: 7px;
  }

  body.mobile-app-v2 .app-main > .topbar .usynai-language-switcher {
    position: static !important;
    min-height: 32px;
    padding: 3px;
    gap: 1px;
    border-radius: 13px;
    box-shadow: none;
  }

  body.mobile-app-v2 .app-main > .topbar .usynai-language-switcher button {
    min-width: 34px;
    height: 34px;
    padding: 0 6px;
    font-size: 12px;
  }

  body.mobile-app-v2 .connection-badge {
    min-height: 32px;
    max-width: 150px;
    padding: 7px 10px;
    border-radius: 12px;
    overflow: hidden;
    font-size: 12px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.mobile-app-v2 .dashboard {
    margin-top: 14px;
  }

  body.mobile-app-v2 .dashboard-head {
    margin: 0 0 10px;
    gap: 0;
  }

  body.mobile-app-v2.seller-overview-v2
    #dashboard
    .dashboard-head
    > div:first-child,
  body.mobile-app-v2.seller-overview-v2 #dashboard #disconnect,
  body.mobile-app-v2.seller-overview-v2 #dashboardPeriodBar {
    display: none !important;
  }

  /* Periods become compact chips instead of a large card. */
  body.mobile-app-v2 .overview-period-control {
    width: 100%;
    padding: 0;
    display: grid;
    gap: 8px;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  body.mobile-app-v2 .overview-period-label {
    display: flex;
    align-items: center;
    gap: 7px;
    color: #667085;
    font-size: 12px;
    font-weight: 700;
  }

  body.mobile-app-v2 .overview-period-label::before {
    width: 24px;
    height: 24px;
    border-radius: 8px;
    font-size: 11px;
  }

  body.mobile-app-v2
    .overview-period-presets[data-usyn-standard-presets="true"],
  body.mobile-app-v2 .overview-period-presets {
    width: 100%;
    display: flex !important;
    align-items: center;
    gap: 7px;
    padding: 1px 0 3px;
    overflow-x: auto !important;
    overflow-y: hidden;
    border: 0;
    background: transparent;
    box-shadow: none;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }

  body.mobile-app-v2 .overview-period-presets::-webkit-scrollbar {
    display: none;
  }

  body.mobile-app-v2
    .overview-period-presets[data-usyn-standard-presets="true"]
    button,
  body.mobile-app-v2 .overview-period-presets button {
    width: auto;
    min-width: max-content;
    min-height: 40px;
    flex: 0 0 auto;
    padding: 0 12px;
    border: 1px solid #d8d2c7;
    border-radius: 999px;
    color: #555c57;
    background: #fffef9;
    box-shadow: none;
    font-size: 12px;
    font-weight: 680;
    line-height: 1;
    white-space: nowrap;
    scroll-snap-align: start;
  }

  body.mobile-app-v2
    .overview-period-presets[data-usyn-standard-presets="true"]
    button.active,
  body.mobile-app-v2
    .overview-period-presets[data-usyn-standard-presets="true"]
    button[aria-pressed="true"],
  body.mobile-app-v2 .overview-period-presets button.active,
  body.mobile-app-v2 .overview-period-presets button[aria-pressed="true"] {
    color: #fff;
    border-color: #171a18;
    background: #171a18;
    box-shadow: none;
  }

  body.mobile-app-v2
    .overview-period-presets[data-usyn-standard-presets="true"]
    [data-period-custom],
  body.mobile-app-v2 .overview-period-presets [data-period-custom] {
    grid-column: auto;
    min-height: 36px;
    border-left: 1px solid #d8d2c7;
  }

  body.mobile-app-v2 .overview-period-custom {
    grid-template-columns: 1fr;
    padding: 12px;
    border: 1px solid #d8d2c7;
    border-radius: 15px;
    background: #fffef9;
  }

  body.mobile-app-v2 .overview-period-custom label,
  body.mobile-app-v2 .overview-period-apply {
    grid-column: 1;
  }

  /* Three useful KPIs only: sales, completed orders and average order. */
  body.mobile-app-v2 .metrics-grid {
    width: 100%;
    margin-top: 10px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  body.mobile-app-v2 .metrics-grid > .metric-card:nth-child(2) {
    display: none !important;
  }

  body.mobile-app-v2 .metrics-grid > .metric-card:first-child {
    grid-column: 1/-1;
    min-height: 112px;
  }

  body.mobile-app-v2 .metric-card,
  body.mobile-app-v2 .metric-primary {
    min-width: 0;
    min-height: 96px;
    padding: 14px;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.045);
  }

  body.mobile-app-v2 .metric-card > span,
  body.mobile-app-v2 .metric-label {
    font-size: 12px;
    line-height: 1.25;
  }

  body.mobile-app-v2 .metric-card strong {
    margin: 10px 0 5px;
    font-size: 24px;
    line-height: 1;
    letter-spacing: -0.045em;
  }

  body.mobile-app-v2 .metric-card small {
    font-size: 12px;
    line-height: 1.35;
  }

  /* These four cards repeat information already surfaced by AI priorities. */
  body.mobile-app-v2 .performance-strip {
    display: none !important;
  }

  body.mobile-app-v2 .dashboard-ai-focus,
  body.mobile-app-v2 .assistant-focus-board {
    margin: 11px 0;
    padding: 14px;
    border-radius: 17px;
    box-shadow: 0 8px 24px rgba(34, 28, 55, 0.045);
  }

  body.mobile-app-v2 .ai-focus-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    margin-bottom: 11px;
  }

  body.mobile-app-v2 .ai-focus-copy h3 {
    font-size: 18px;
  }

  body.mobile-app-v2 .ai-focus-copy p {
    font-size: 12px;
  }

  body.mobile-app-v2 .ai-focus-count {
    min-height: 28px;
    padding: 0 9px;
    font-size: 12px;
  }

  body.mobile-app-v2 .ai-priority-grid {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(238px, 86%);
    grid-template-columns: none;
    gap: 9px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 3px;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  body.mobile-app-v2 .ai-priority-grid::-webkit-scrollbar {
    display: none;
  }

  body.mobile-app-v2 .ai-priority-card {
    min-height: 136px;
    padding: 13px;
    scroll-snap-align: start;
  }

  body.mobile-app-v2 .ai-mini-chat {
    margin-top: 10px;
    padding: 12px;
  }

  body.mobile-app-v2 .ai-mini-chat-top {
    display: grid;
    gap: 9px;
  }

  body.mobile-app-v2 .ai-mini-prompts {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  body.mobile-app-v2 .ai-mini-prompts::-webkit-scrollbar {
    display: none;
  }

  body.mobile-app-v2 .ai-mini-prompt {
    flex: 0 0 auto;
  }

  /* Product-shell v2 keeps decisions as one ledger on phones as well. */
  body.mobile-app-v2.cabinet-experience-v2 .dashboard-ai-focus,
  body.mobile-app-v2.cabinet-experience-v2 .assistant-focus-board {
    margin: 11px 0;
    padding: 0;
    border-radius: 12px;
    box-shadow: 0 8px 22px rgba(23, 26, 24, 0.04);
  }

  body.mobile-app-v2.cabinet-experience-v2 .ai-focus-head {
    display: flex;
    grid-template-columns: none;
    gap: 10px;
    margin: 0;
    padding: 15px 16px 13px;
  }

  body.mobile-app-v2.cabinet-experience-v2 .ai-focus-count {
    display: none;
  }

  body.mobile-app-v2.cabinet-experience-v2 .ai-priority-grid {
    display: grid;
    grid-auto-flow: row;
    grid-auto-columns: auto;
    grid-template-columns: 1fr;
    gap: 0;
    overflow: visible;
    padding: 0;
    scroll-snap-type: none;
  }

  body.mobile-app-v2.cabinet-experience-v2 .ai-priority-card {
    min-height: 0;
    padding: 13px 16px;
    border-radius: 0;
    scroll-snap-align: none;
  }

  body.mobile-app-v2.cabinet-experience-v2 .ai-mini-chat {
    margin: 0;
    padding: 14px 16px;
    border-radius: 0;
  }

  body.mobile-app-v2.cabinet-experience-v2 .ai-mini-chat-top {
    display: block;
  }

  body.mobile-app-v2.cabinet-experience-v2 .ai-mini-prompts {
    justify-content: flex-start;
    margin-top: 9px;
  }

  body.mobile-app-v2 .analytics-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 10px;
  }

  body.mobile-app-v2 :is(.chart-panel, .status-panel, .orders-panel) {
    padding: 14px;
    border-radius: 16px;
  }

  body.mobile-app-v2 .status-panel {
    display: none !important;
  }

  body.mobile-app-v2 .orders-panel {
    margin-top: 10px;
  }

  body.mobile-app-v2 .sales-chart,
  body.mobile-app-v2 .sales-chart svg {
    min-height: 190px;
    height: 190px;
  }

  /* Stable native-style dock rendered independently from the legacy sidebar nav. */
  .mobile-v2-dock {
    position: fixed !important;
    z-index: 980;
    left: 10px;
    right: 10px;
    bottom: calc(
      8px + env(safe-area-inset-bottom) + var(--mobile-vv-bottom, 0px)
    );
    height: var(--mobile-v2-dock-height);
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: stretch;
    gap: 4px;
    padding: 6px;
    border: 1px solid #d3cdc1;
    border-radius: 18px;
    background: #fffef9;
    box-shadow:
      0 14px 36px rgba(23, 26, 24, 0.14),
      inset 0 1px 0 rgba(255, 255, 255, 0.7);
    transform: translate3d(0, 0, 0);
    contain: layout paint;
    isolation: isolate;
  }

  .mobile-v2-dock-item {
    position: relative;
    min-width: 0;
    min-height: 58px;
    padding: 5px 2px 4px;
    display: grid;
    grid-template-rows: 22px 14px;
    place-items: center;
    align-content: center;
    gap: 3px;
    border: 0;
    border-radius: 12px;
    color: #737a74;
    background: transparent;
    font-family:
      Inter,
      -apple-system,
      BlinkMacSystemFont,
      "Segoe UI",
      sans-serif;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-v2-dock-item-icon {
    font-size: 19px;
    line-height: 22px;
  }

  .mobile-v2-dock-item-icon svg,
  .mobile-v2-more-item-icon svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .mobile-v2-dock-item-label {
    max-width: 100%;
    overflow: hidden;
    font-size: 11px;
    font-weight: 720;
    line-height: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-v2-dock-item-badge {
    position: absolute;
    top: 3px;
    right: 5px;
    min-width: 16px;
    max-width: 28px;
    padding: 1px 4px;
    overflow: hidden;
    border-radius: 999px;
    color: #246a53;
    background: #dff4e9;
    font-size: 10px;
    line-height: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-v2-dock-item.active {
    color: #fff;
    background: #171a18;
    box-shadow: none;
  }

  .mobile-v2-dock-item.active .mobile-v2-dock-item-badge {
    color: #fff;
    background: rgba(255, 255, 255, 0.18);
  }

  .mobile-v2-dock-item:active {
    transform: scale(0.97);
  }

  .mobile-v2-backdrop {
    position: fixed;
    z-index: 970;
    inset: 0;
    border: 0;
    background: rgba(15, 23, 42, 0.32);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
  }

  .mobile-v2-more-sheet {
    position: fixed;
    z-index: 975;
    left: 10px;
    right: 10px;
    bottom: calc(
      var(--mobile-v2-dock-height) + 18px + env(safe-area-inset-bottom) +
        var(--mobile-vv-bottom, 0px)
    );
    max-height: min(62svh, 520px);
    padding: 16px;
    overflow: auto;
    border: 1px solid #d8d2c7;
    border-radius: 18px;
    background: #fffef9;
    box-shadow: 0 24px 64px rgba(23, 26, 24, 0.2);
    opacity: 0;
    pointer-events: none;
    transform: translateY(18px) scale(0.985);
    transform-origin: bottom center;
    transition:
      opacity 0.18s ease,
      transform 0.18s ease;
  }

  body.mobile-v2-more-open .mobile-v2-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  body.mobile-v2-more-open .mobile-v2-more-sheet {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
  }

  .mobile-v2-more-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
  }

  .mobile-v2-more-head strong {
    color: #171a18;
    font-size: 16px;
    letter-spacing: -0.025em;
  }

  .mobile-v2-more-close {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 11px;
    color: #656c66;
    background: #efebe2;
    font-size: 18px;
  }

  .mobile-v2-more-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .mobile-v2-more-item {
    min-width: 0;
    min-height: 58px;
    padding: 11px;
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    border: 1px solid #d8d2c7;
    border-radius: 11px;
    color: #474e49;
    background: #f8f5ee;
    text-align: left;
  }

  .mobile-v2-more-item-icon {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 10px;
    color: #29499f;
    background: #e7edff;
  }

  .mobile-v2-more-item-label {
    overflow: hidden;
    font-size: 11px;
    font-weight: 680;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-v2-more-item-badge {
    color: #717872;
    font-size: 10px;
  }

  .mobile-v2-more-item.active {
    border-color: #171a18;
    color: #fff;
    background: #171a18;
  }

  body.mobile-keyboard-open .mobile-v2-dock,
  body.mobile-keyboard-open .mobile-v2-more-sheet,
  body.mobile-keyboard-open .mobile-v2-backdrop {
    opacity: 0 !important;
    pointer-events: none !important;
  }
}

@media (max-width: 380px) {
  .mobile-v2-dock {
    left: 7px;
    right: 7px;
    gap: 2px;
    padding: 5px;
  }

  .mobile-v2-dock-item-label {
    font-size: 8.5px;
  }

  .mobile-v2-more-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mobile-v2-dock-item,
  .mobile-v2-backdrop,
  .mobile-v2-more-sheet {
    transition: none !important;
  }
}
