/* Mobile-only PWA layout. Desktop rendering is intentionally untouched. */
@media (max-width: 768px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  body {
    -webkit-text-size-adjust: 100%;
    background: #f3f6f3;
  }

  button,
  input,
  select,
  textarea {
    font-size: 16px;
  }

  .app-shell {
    display: block;
    min-height: 100vh;
    padding-bottom: calc(70px + env(safe-area-inset-bottom));
  }

  .workspace {
    width: 100%;
    min-width: 0;
  }

  .sidebar {
    position: fixed;
    z-index: 950;
    inset: auto 0 0 0;
    width: 100%;
    height: calc(64px + env(safe-area-inset-bottom));
    padding: 6px 8px env(safe-area-inset-bottom);
    display: block;
    background: rgba(13, 30, 21, .97);
    box-shadow: 0 -8px 28px rgba(20, 48, 33, .18);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  .brand,
  .offline {
    display: none;
  }

  .sidebar nav {
    display: flex;
    gap: 5px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

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

  .nav-item {
    flex: 0 0 64px;
    min-width: 64px;
    height: 52px;
    padding: 5px 3px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 2px;
    text-align: center;
    scroll-snap-align: center;
    font-size: 18px;
  }

  .nav-item span {
    display: block;
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 9px;
    line-height: 1.1;
  }

  .dashboard-view {
    min-height: auto;
    padding: calc(14px + env(safe-area-inset-top)) 14px 24px;
    display: flex;
    flex-direction: column;
    background: linear-gradient(155deg, #f8faf8 0%, #edf4ef 100%);
  }

  .dashboard-hero {
    order: 1;
    width: 100%;
    max-width: none;
    margin: 0 0 14px;
  }

  .dashboard-hero #accountBar {
    position: static;
    margin: 0 0 16px;
  }

  .account-chip {
    width: 100%;
    padding: 10px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px;
    border-radius: 14px;
    background: rgba(255, 255, 255, .92);
    box-shadow: 0 7px 22px rgba(30, 77, 52, .07);
  }

  .account-chip span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .account-chip b {
    justify-self: end;
  }

  .account-chip select {
    width: 100%;
    min-width: 0;
    grid-column: 1;
  }

  .account-chip button {
    grid-column: 2;
  }

  .dashboard-hero > span {
    font-size: 9px;
    letter-spacing: 1.5px;
  }

  .dashboard-hero h1 {
    margin: 8px 0 5px;
    font-size: 28px;
    line-height: 1.16;
  }

  .dashboard-hero p {
    margin: 0;
    font-size: 13px;
    line-height: 1.55;
  }

  #importantDashboard {
    order: 2;
  }

  .followup-dashboard {
    order: 3;
    width: 100%;
    margin: 0 0 14px;
    overflow: hidden;
    border-radius: 17px;
    box-shadow: 0 8px 26px rgba(27, 67, 46, .06);
  }

  .action-grid {
    order: 4;
    width: 100%;
    max-width: none;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .important-dashboard {
    width: 100%;
    margin: 0 0 14px;
    padding: 16px;
    border-radius: 18px;
    align-items: stretch;
    box-shadow: 0 10px 30px rgba(29, 69, 49, .07);
  }

  .important-preview {
    width: 100%;
    align-items: center;
  }

  .important-preview > div {
    min-width: 0;
  }

  .important-preview strong,
  .important-preview small {
    overflow-wrap: anywhere;
  }

  .important-dashboard-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .important-dashboard-actions button {
    width: 100%;
    min-width: 0;
    justify-content: center;
  }

  .followup-dashboard header {
    padding: 15px;
    align-items: flex-start;
    gap: 10px;
  }

  .followup-dashboard h2 {
    font-size: 19px;
    line-height: 1.3;
  }

  .followup-dashboard header button {
    flex: 0 0 auto;
    height: 38px;
    padding: 0 12px;
    font-size: 13px;
  }

  .followup-summary button {
    min-width: 0;
    padding: 12px 9px;
  }

  .followup-summary b {
    font-size: 23px;
  }

  .followup-summary small {
    display: block;
    font-size: 10px;
  }

  .reminder-list > button {
    padding: 12px 14px;
    align-items: flex-start;
    gap: 8px;
  }

  .reminder-list > button em {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .action-card {
    min-height: 0;
    padding: 17px;
    gap: 13px;
    border-radius: 16px;
  }

  .action-card i {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
  }

  .action-card h2 {
    margin: 1px 0 6px;
    font-size: 18px;
  }

  .action-card p {
    min-height: 0;
    margin: 0 0 9px;
    font-size: 13px;
  }

  .library-view,
  .customs-view,
  .finance-view {
    min-height: auto;
    padding: calc(16px + env(safe-area-inset-top)) 12px 24px;
  }

  .library-head,
  .ops-head {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .library-head h2 {
    font-size: 25px;
  }

  .library-head > div:last-child {
    width: 100%;
    flex-wrap: wrap;
  }

  .library-head > button,
  .library-head > div:last-child > button {
    flex: 1;
    min-width: 130px;
  }

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

  .library-toolbar input,
  .library-toolbar select {
    width: 100%;
    min-width: 0;
  }

  .customer-layout,
  .settings-grid,
  .form-grid,
  .customer-form,
  .training-grid,
  .product-library-grid {
    grid-template-columns: 1fr;
  }

  .customer-form .wide,
  .form-grid label.wide,
  .settings-grid .panel:last-child {
    grid-column: auto;
  }

  .list-card {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .library-table {
    min-width: 680px;
  }

  .detail-card {
    max-height: none;
    padding: 16px;
  }

  .detail-top,
  .detail-actions,
  .form-actions {
    flex-wrap: wrap;
  }

  .topbar {
    height: auto;
    padding: calc(12px + env(safe-area-inset-top)) 12px 12px;
    flex-direction: column;
    align-items: stretch;
  }

  .title-row {
    align-items: flex-start;
    gap: 10px;
  }

  .title-row h1 {
    font-size: 20px;
  }

  .top-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .top-actions button {
    min-width: 0;
    padding: 0 9px;
  }

  .project-grid {
    display: block;
    min-height: auto;
  }

  .form-pane {
    padding: 12px;
  }

  .preview-pane,
  .document-rail {
    position: static;
    height: auto;
  }

  .preview-pane {
    min-height: 0;
  }

  .paper-stage {
    height: auto;
    max-height: 72vh;
    padding: 10px;
    justify-content: flex-start;
  }

  .placeholder {
    margin: 12px;
    padding: 38px 18px;
  }

  .feedback-bar {
    margin: 16px 12px 24px;
    align-items: stretch;
  }

  .ops-overlay,
  .product-picker-overlay {
    padding: 8px;
  }

  .ops-modal,
  .important-compose,
  .product-picker {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
    border-radius: 16px;
  }

  .ops-modal-head,
  .ops-modal-body {
    padding: 16px;
  }

  .important-drawer {
    width: 100%;
    max-width: none;
  }

  .important-drawer > header {
    padding: calc(16px + env(safe-area-inset-top)) 16px 14px;
  }

  .important-toolbar,
  .important-list {
    padding-left: 14px;
    padding-right: 14px;
  }

  .important-account {
    margin-left: 14px;
    margin-right: 14px;
  }

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

  .undo-toast {
    right: 12px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    left: 12px;
  }
}
