@media (max-width: 1120px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar__actions {
    width: 100%;
  }

  .phase {
    margin-left: auto;
  }

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

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

  .batch-flow {
    min-width: 760px;
  }

  .panel--flow {
    overflow-x: auto;
  }
}

@media (max-width: 780px) {
  .board-shell {
    width: min(100% - 24px, 1500px);
    margin-top: 12px;
  }

  .topbar {
    gap: 1.2rem;
    padding: 20px;
    border-radius: 22px;
  }

  .topbar__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .active-user,
  .active-user select {
    width: 100%;
  }

  .phase {
    grid-column: 1 / -1;
    margin: 0;
    padding: 0 0 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    border-left: 0;
  }

  .demo-banner {
    align-items: flex-start;
    flex-direction: column;
    padding: 12px 14px;
  }

  .demo-banner div {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .metrics {
    gap: 10px;
  }

  .metric-card {
    min-height: 142px;
    padding: 16px;
  }

  .panel {
    padding: 17px;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .work-mode-assist {
    align-items: stretch;
    flex-direction: column;
  }

  .work-mode-assist .button {
    width: 100%;
  }

  .filters {
    width: 100%;
    flex-direction: column;
  }

  .filters label {
    width: 100%;
  }

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

  .table-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
  }

  .table-scroll > table {
    min-width: 680px;
  }

  .board-shell,
  main,
  [data-page],
  .panel {
    min-width: 0;
    max-width: 100%;
  }

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

  .materials-tabs button {
    padding: 0 8px;
  }

  .task-title {
    min-width: 0;
  }

  .status-select {
    width: 100%;
  }

  .panel--flow {
    overflow: hidden;
  }

  .batch-flow {
    min-width: 0;
    grid-template-columns: 1fr;
  }

  .flow-step {
    min-height: 68px;
    justify-items: start;
    padding-right: 52px;
    text-align: right;
  }

  .flow-step::before {
    top: -32px;
    right: 18px;
    width: 2px;
    height: 66px;
  }

  .flow-step__marker {
    position: absolute;
    top: 0;
    right: 0;
  }

  .flow-step__copy {
    justify-items: start;
  }

  .flow-step button {
    margin-top: -7px;
  }

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

  .inventory-split > div {
    border-bottom: 1px solid var(--ink-100);
    border-left: 0;
  }

  .inventory-split > div:last-child {
    border-bottom: 0;
  }

  .decision-row {
    align-items: start;
    grid-template-columns: 9px 1fr;
  }

  .decision-row > span:last-child {
    grid-column: 2;
  }

  .system-row {
    grid-template-columns: 1fr;
  }

  .system-row p {
    max-width: none;
    text-align: right;
  }

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

  .supplier-profile-grid,
  .supplier-messenger-grid,
  .supplier-related-records {
    grid-template-columns: 1fr;
  }

  .supplier-related-records > h3,
  .supplier-messenger-grid > span {
    grid-column: auto;
  }

  .supplier-profile-dialog {
    width: min(100vw - 16px, 1040px) !important;
    max-height: calc(100vh - 16px) !important;
  }

  .record-actions button,
  .panel-heading button {
    flex: 1 1 150px;
  }
}

@media (max-width: 460px) {
  .brand-mark {
    flex-basis: 44px;
    width: 44px;
    height: 44px;
    border-radius: 14px;
  }

  .brand h1 {
    font-size: 1.04rem;
  }

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

  .phase {
    grid-column: auto;
  }

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

  .metric-card {
    min-height: 128px;
  }

  .filters {
    flex-direction: column;
  }

  .dialog-actions {
    flex-direction: column-reverse;
  }

  .dialog-actions .button {
    width: 100%;
  }

  .supplier-profile-dialog :is(.supplier-profile-section > button, .supplier-repeat-list > button, .supplier-address-row > button, .supplier-contact-card > button, .supplier-phone-row > button, .dialog-actions > button) {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

@media (max-width: 780px) {
  .sidebar-toggle {
    display: inline-flex;
    margin: .75rem 0;
  }

  .app-navigation {
    display: none;
  }

  .app-navigation.is-open {
    display: grid;
  }

  .board-shell {
    width: min(100% - 1.5rem, 1500px);
    margin-inline: auto;
  }
}
