/* Mobile-responsive layout for admin + customer portals */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overflow-x: hidden;
}

.wf-app-shell {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-app);
}

.wf-sidebar {
  width: 248px;
  flex-shrink: 0;
}

.wf-main {
  flex: 1;
  min-width: 0;
}

.wf-mobile-header,
.wf-nav-backdrop {
  display: none;
}

.wf-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.wf-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.wf-grid-split {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 22px;
}

.wf-grid-cards {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 28px;
  align-items: start;
}

.wf-page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.wf-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.wf-table-header,
.wf-table-row {
  display: grid;
}

.wf-banner {
  display: flex;
  align-items: center;
  gap: 14px;
}

.wf-login-split {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

.wf-login-brand {
  flex: 1 1 46%;
}

.wf-login-form-panel {
  flex: 1 1 54%;
}

.wf-modal-panel {
  width: 480px;
  max-width: calc(100vw - 32px);
}

.wf-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.wf-txn-row {
  display: grid;
  grid-template-columns: 1.6fr 1fr 0.7fr auto;
  gap: 10px;
}

@media (max-width: 900px) {
  .wf-grid-cards {
    grid-template-columns: 1fr;
  }

  .wf-grid-split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .wf-app-shell {
    flex-direction: column;
  }

  .wf-nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(7, 10, 18, 0.65);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .wf-nav-backdrop.wf-nav-open {
    opacity: 1;
    pointer-events: auto;
  }

  .wf-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    width: min(280px, 88vw);
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-lg);
  }

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

  .wf-mobile-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: -8px 0 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
  }

  .wf-menu-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--surface-card);
    color: var(--text-body);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .wf-main {
    padding: 16px 16px calc(24px + env(safe-area-inset-bottom, 0px)) !important;
    overflow-x: hidden;
  }

  .wf-topbar {
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px !important;
  }

  .wf-topbar-date {
    font-size: 12px !important;
  }

  .wf-topbar-user-text {
    display: none;
  }

  .wf-grid-2,
  .wf-grid-3,
  .wf-detail-grid {
    grid-template-columns: 1fr !important;
  }

  .wf-page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .wf-page-header > button,
  .wf-page-header .wf-btn-full-mobile {
    width: 100%;
  }

  .wf-search-full {
    max-width: none !important;
    width: 100%;
  }

  .wf-table-header {
    display: none !important;
  }

  .wf-table-row {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
    padding: 16px !important;
    text-align: left !important;
  }

  .wf-table-row > span:last-child {
    align-self: flex-end;
  }

  .wf-table-wide {
    min-width: 0 !important;
  }

  .wf-table-wide .wf-table-header,
  .wf-table-wide .wf-table-row {
    min-width: 640px;
  }

  .wf-banner {
    flex-wrap: wrap;
    border-radius: var(--radius-md) !important;
    padding: 14px !important;
  }

  .wf-banner .wf-banner-action {
    width: 100%;
  }

  .wf-login-split {
    flex-direction: column !important;
  }

  .wf-login-brand {
    flex: none !important;
    padding: 28px 24px !important;
    min-height: auto !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border-subtle);
  }

  .wf-login-brand h1 {
    font-size: 28px !important;
  }

  .wf-login-form-panel {
    flex: 1 !important;
    padding: 32px 20px !important;
  }

  .wf-modal-panel {
    width: calc(100vw - 32px) !important;
    margin: 16px;
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
  }

  .wf-modal-overlay {
    align-items: flex-start !important;
    padding-top: 16px;
    overflow-y: auto;
  }

  h1 {
    font-size: clamp(24px, 6vw, 32px) !important;
    line-height: 1.2 !important;
  }

  .wf-card-row {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .wf-card-row-actions {
    width: 100%;
  }

  .wf-card-row-actions select {
    width: 100%;
    min-height: 44px;
  }

  .wf-detail-header {
    flex-direction: column !important;
    align-items: flex-start !important;
  }

  .wf-detail-header-balance {
    text-align: left !important;
    width: 100%;
  }

  .wf-quick-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 10px !important;
  }

  .wf-quick-actions > * {
    min-width: 0;
  }

  .wf-shipment-steps {
    gap: 6px !important;
  }

  .wf-shipment-steps > div {
    flex: 1 1 calc(50% - 6px) !important;
    min-width: calc(50% - 6px);
  }

  .wf-table-wide .wf-table-header {
    display: grid !important;
  }

  .wf-table-wide .wf-table-row {
    display: grid !important;
    flex-direction: unset !important;
    align-items: center !important;
    text-align: left !important;
  }

  .wf-table-wide .wf-table-row > span:last-child {
    align-self: center;
  }

  .wf-segmented {
    flex-direction: column !important;
  }

  .wf-segmented button {
    min-height: 44px;
  }

  .wf-txn-row {
    grid-template-columns: 1fr !important;
  }
}

@media (min-width: 769px) {
  .wf-sidebar .wf-menu-btn {
    display: none !important;
  }
}

@media (max-width: 480px) {
  .wf-quick-actions {
    grid-template-columns: 1fr !important;
  }

  .wf-login-form-panel form {
    max-width: none !important;
  }
}
