:root {
  --bg: #f7f3ec;
  --surface: #fffaf3;
  --surface-strong: #ffffff;
  --ink: #252525;
  --muted: #6f6a61;
  --line: #ddd4c7;
  --accent: #c64936;
  --accent-dark: #8f2f25;
  --ok: #1f7a4d;
  --warn: #9b6515;
  --danger: #a9342b;
  --shadow: 0 18px 38px rgba(41, 31, 20, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
  padding: 0 14px;
  cursor: pointer;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

button.ghost {
  background: transparent;
}

button.danger-action {
  border-color: rgba(169, 52, 43, 0.28);
  background: #fff4f1;
  color: var(--danger);
}

button.blue-action {
  border-color: #2f6fa8;
  background: #2f6fa8;
  color: #fff;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
}

input:disabled,
select:disabled,
textarea:disabled {
  border-color: #e4ddd2;
  background: #f1ede6;
  color: #827a70;
  cursor: not-allowed;
}

textarea {
  min-height: 82px;
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.boot {
  display: grid;
  min-height: 100vh;
  place-items: center;
  color: var(--muted);
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: #fff8ee;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
}

.brand-title {
  font-weight: 800;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  justify-content: flex-start;
  text-align: left;
  background: transparent;
}

.nav button.active {
  border-color: #edc7ba;
  background: #fff;
  color: var(--accent-dark);
}

.profile {
  margin-top: auto;
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.content {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 0;
}

.topbar p {
  margin: 3px 0 0;
  color: var(--muted);
}

.mobile-menu {
  display: none;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 17px;
}

.panel-body {
  padding: 14px;
}

.grid {
  display: grid;
  gap: 12px;
}

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

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

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: end;
}

.toolbar label {
  min-width: 180px;
  flex: 1;
}

.table-wrap {
  overflow: auto;
}

.responsive-table {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 9px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.stat-value {
  font-size: 28px;
  font-weight: 850;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
}

.dashboard-shell {
  display: grid;
  gap: 16px;
}

.dashboard-metrics {
  margin-bottom: 0;
}

.metric-sales .stat-value {
  color: var(--ok);
}

.metric-pending .stat-value {
  color: var(--warn);
}

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

.dashboard-grid.wide {
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
}

.dashboard-card {
  box-shadow: none;
}

.chart-layout {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
}

.pie-chart {
  width: 132px;
  aspect-ratio: 1;
  border-radius: 999px;
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 16px rgba(255, 255, 255, 0.58);
}

.pie-chart.empty {
  border: 1px solid var(--line);
  background: #f4f1ec;
}

.pie-chart span {
  display: grid;
  width: 64px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 999px;
  background: #fff;
  font-size: 22px;
  font-weight: 850;
}

.dashboard-legend {
  display: grid;
  gap: 9px;
}

.dashboard-legend div,
.dashboard-table div,
.payment-summary div {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.dashboard-legend i {
  width: 11px;
  height: 11px;
  border-radius: 999px;
}

.dashboard-legend span,
.dashboard-table span,
.payment-summary span,
.mini-summary small {
  color: var(--muted);
}

.mini-summary-grid,
.payment-summary,
.dashboard-table {
  display: grid;
  gap: 10px;
}

.mini-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 4px;
}

.mini-summary span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.mini-summary strong {
  font-size: 28px;
}

.dashboard-table div,
.payment-summary div {
  grid-template-columns: minmax(0, 1fr) auto auto;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}

.dashboard-table div:last-child,
.payment-summary div:last-child {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.badge.ok {
  border-color: #b9dac6;
  color: var(--ok);
}

.badge.warn {
  border-color: #e2c792;
  color: var(--warn);
}

.badge.soft {
  border-color: #d8d3ca;
  background: #f4f1ec;
  color: var(--muted);
}

.badge.danger {
  border-color: #e8b6b2;
  color: var(--danger);
}

.notice {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  color: var(--muted);
}

.notice strong {
  color: var(--ink);
}

.error {
  border-color: #e4aaa5;
  background: #fff4f2;
  color: var(--danger);
}

.success {
  border-color: #afd7c0;
  background: #f2fff7;
  color: var(--ok);
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.login-shell {
  width: min(430px, 100%);
  display: grid;
  gap: 14px;
}

.login h1 {
  margin: 0;
  font-size: 30px;
}

.login p {
  margin: 0;
  color: var(--muted);
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.table-actions,
.record-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.table-actions button,
.record-actions button {
  min-height: 34px;
  padding: 0 10px;
}

.record-actions {
  justify-content: flex-end;
}

.line-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.order-line {
  display: grid;
  grid-template-columns: minmax(210px, 2fr) minmax(86px, 0.75fr) minmax(96px, 0.8fr) minmax(76px, 0.6fr) minmax(88px, auto) minmax(82px, auto);
  gap: 10px;
  align-items: end;
}

.order-detail-line {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
  padding: 8px 10px;
}

.quantity-stepper {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 6px;
}

.stepper-actions {
  display: grid;
  gap: 4px;
}

.stepper-button {
  min-height: 19px;
  padding: 0;
  font-size: 10px;
  line-height: 1;
}

.line-total {
  font-weight: 800;
  align-self: end;
  min-height: 42px;
  display: flex;
  align-items: center;
}

.order-total {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  font-size: 20px;
  font-weight: 850;
}

.add-line-row {
  display: flex;
  justify-content: flex-start;
}

.add-line-row button {
  min-width: 180px;
}

.card-list {
  display: none;
}

.record-card {
  width: 100%;
  min-height: auto;
  display: grid;
  gap: 8px;
  text-align: left;
  padding: 12px;
  background: #fff;
}

.record-main,
.record-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

.record-main {
  align-items: flex-start;
  flex-direction: column;
}

.record-main span {
  color: var(--muted);
  font-size: 13px;
}

.record-main .record-phone {
  color: var(--ink);
  font-weight: 750;
}

.check-row {
  min-height: 42px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.customer-active-check,
.project-open-check {
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.customer-search-field {
  position: relative;
}

.autocomplete-list {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 34px rgba(41, 31, 20, 0.16);
}

.autocomplete-list button {
  width: 100%;
  min-height: auto;
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 0;
  border-radius: 0;
  text-align: left;
}

.autocomplete-list button + button {
  border-top: 1px solid var(--line);
}

.autocomplete-list button:hover {
  background: #fff7ee;
}

.autocomplete-list span,
.autocomplete-empty {
  color: var(--muted);
  font-size: 12px;
}

.autocomplete-empty {
  padding: 10px 12px;
}

.line-heading {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink);
}

.order-detail-line .line-heading {
  font-size: 14px;
}

.order-detail-line .line-total {
  font-weight: 850;
}

.detail-lines {
  display: grid;
  gap: 8px;
}

.order-detail-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.order-detail-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.order-detail-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.order-detail-summary strong {
  display: block;
  margin-top: 3px;
}

.order-update-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: end;
}

.order-state-box {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 7px 10px;
}

.order-state-box span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.final-state-check {
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.order-update-form textarea {
  min-height: 42px;
}

.order-update-form .modal-actions {
  grid-column: auto;
  padding-top: 0;
}

.order-update-form .full-span {
  grid-column: 1 / -1;
}

.order-edit-section,
.detail-edit-section,
.order-detail-editor .detail-lines,
.order-detail-editor .add-line-row,
.order-detail-editor .modal-actions {
  grid-column: 1 / -1;
}

.order-edit-section,
.detail-edit-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf9;
  padding: 12px;
}

.detail-edit-section {
  margin-top: 2px;
  background: #f7f1e8;
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.section-title-row h3 {
  margin: 0;
  font-size: 15px;
}

.section-title-row span {
  color: var(--muted);
  font-weight: 800;
}

.order-edit-fields {
  display: grid;
  gap: 12px;
}

.order-edit-row {
  display: grid;
  gap: 10px;
  align-items: end;
}

.order-edit-main {
  grid-template-columns: minmax(150px, 0.8fr) minmax(170px, 0.9fr) minmax(160px, 0.8fr) minmax(150px, 0.8fr);
}

.order-edit-secondary {
  grid-template-columns: minmax(170px, 0.7fr) minmax(320px, 1.8fr);
}

.order-state-display {
  min-height: 42px;
  padding: 0;
}

.order-state-display .delivered-check {
  min-height: 34px;
  margin-top: 7px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.order-state-display .delivered-check:has(input:disabled) {
  opacity: 0.6;
}

.order-edit-fields label:not(.check-row),
.order-state-display span,
.payment-balance span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.order-edit-fields .check-row {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.order-edit-fields select,
.order-edit-fields textarea,
.order-edit-fields input {
  font-size: 14px;
}

.order-edit-fields .order-notes textarea {
  min-height: 40px;
  max-height: 84px;
}

.payment-balance {
  min-height: 42px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.payment-balance strong {
  font-size: 15px;
}

.order-detail-editor .modal-actions {
  justify-content: flex-end;
}

.order-detail-line .detail-product {
  grid-column: 1 / span 5;
  min-width: 0;
}

.order-detail-line .detail-quantity {
  grid-column: 6 / span 2;
}

.order-detail-line .detail-unit {
  grid-column: 8 / span 3;
}

.order-detail-line .detail-total {
  grid-column: 11 / span 2;
}

.order-detail-line label {
  font-size: 12px;
  font-weight: 750;
}

.order-detail-line input,
.order-detail-line select,
.order-detail-line textarea {
  min-height: 34px;
  padding: 6px 8px;
  font-size: 14px;
}

.order-detail-line .quantity-stepper {
  grid-template-columns: minmax(0, 1fr) 28px;
  gap: 4px;
}

.order-detail-line .stepper-actions {
  gap: 3px;
}

.order-detail-line .stepper-button {
  min-height: 15px;
  font-size: 9px;
}

.order-detail-line .detail-notes {
  grid-column: 4 / -1;
}

.order-detail-line .detail-state {
  grid-column: 1 / span 3;
}

.order-detail-line.detail-complete {
  border-color: rgba(31, 122, 77, 0.38);
  background: #fbfff9;
}

.order-detail-line.detail-pending {
  border-color: rgba(155, 101, 21, 0.36);
  background: #fffaf1;
}

.order-detail-line .state-complete {
  border-color: rgba(31, 122, 77, 0.45);
  background: #e9f7ef;
  color: var(--ok);
}

.order-detail-line .state-pending,
.order-edit-fields .state-pending {
  border-color: rgba(155, 101, 21, 0.45);
  background: #fff4df;
  color: var(--warn);
}

.order-edit-fields .state-complete {
  border-color: rgba(31, 122, 77, 0.45);
  background: #e9f7ef;
  color: var(--ok);
}

.order-edit-fields .state-partial {
  border-color: #d8d3ca;
  background: #f4f1ec;
  color: var(--muted);
}

.order-detail-line .detail-notes textarea {
  min-height: 34px;
}

.line-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  grid-column: 1 / -1;
}

.line-actions button {
  min-height: 34px;
  padding: 0 10px;
}

.modal-backdrop {
  position: fixed;
  z-index: 30;
  inset: 0;
  height: 100dvh;
  max-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 22px;
  overflow: hidden;
  background: rgba(24, 20, 16, 0.58);
  backdrop-filter: blur(4px);
}

.modal-panel {
  width: min(680px, 100%);
  max-height: min(760px, calc(100dvh - 44px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 28px 70px rgba(24, 20, 16, 0.34);
  display: flex;
  flex-direction: column;
}

.modal-panel.modal-wide {
  width: min(980px, 100%);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: #fffaf3;
}

.modal-head h2 {
  margin: 0;
  font-size: 21px;
}

.modal-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

.modal-head-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.modal-body {
  padding: 18px;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

.modal-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 4px;
  background: var(--surface);
}

.full-span {
  grid-column: 1 / -1;
}

.icon-action {
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    z-index: 10;
    inset: 0 auto 0 0;
    width: min(300px, 86vw);
    overflow-y: auto;
    transform: translateX(-105%);
    transition: transform 160ms ease;
  }

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

  .mobile-menu {
    display: inline-flex;
  }

  .content {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
    margin-bottom: 12px;
  }

  .topbar h1 {
    font-size: 22px;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-head .form-actions,
  .form-actions {
    width: 100%;
    justify-content: stretch;
  }

  .panel-head .form-actions button,
  .form-actions button {
    flex: 1;
    min-width: 0;
  }

  .grid.two,
  .grid.three,
  .stat-grid,
  .dashboard-grid,
  .dashboard-grid.wide {
    grid-template-columns: 1fr;
  }

  .chart-layout {
    grid-template-columns: 112px minmax(0, 1fr);
  }

  .pie-chart {
    width: 112px;
  }

  .toolbar label {
    min-width: 100%;
  }

  .responsive-table {
    display: none;
  }

  .card-list {
    display: grid;
    gap: 10px;
  }

  .table-wrap {
    overflow: visible;
  }

  .line-heading {
    flex-direction: column;
  }

  .order-line {
    grid-template-columns: 1fr 1fr;
  }

  .order-detail-line {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
  }

  .order-edit-fields {
    grid-template-columns: 1fr;
  }

  .order-edit-row,
  .order-edit-main,
  .order-edit-secondary {
    grid-template-columns: 1fr;
  }

  .order-detail-line .line-heading {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    line-height: 1.25;
  }

  .order-detail-line .line-heading strong {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .order-detail-line .detail-product,
  .order-detail-line .detail-quantity,
  .order-detail-line .detail-unit,
  .order-detail-line .detail-total,
  .order-detail-line .detail-state,
  .order-detail-line .detail-notes,
  .order-detail-line .line-actions {
    grid-column: auto;
    max-width: 100%;
    min-width: 0;
    width: 100%;
  }

  .order-detail-line .line-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .order-detail-line .line-actions button,
  .order-detail-line label,
  .order-detail-line select,
  .order-detail-line input,
  .order-detail-line textarea {
    max-width: 100%;
    min-width: 0;
    width: 100%;
  }

  .order-detail-line .quantity-stepper {
    grid-template-columns: minmax(0, 1fr) 32px;
    max-width: 100%;
    width: 100%;
  }

  .order-detail-line .stepper-button {
    width: 32px;
  }

  .order-line label:first-child {
    grid-column: 1 / -1;
  }

  .order-line .line-total,
  .order-line .remove-line {
    width: 100%;
  }

  .order-detail-summary,
  .order-update-form {
    grid-template-columns: 1fr;
  }

  .order-update-form .modal-actions {
    grid-column: 1 / -1;
  }

  .modal-backdrop {
    align-items: start;
    height: auto;
    min-height: 100dvh;
    place-items: start center;
    padding: 8px 8px max(104px, calc(env(safe-area-inset-bottom) + 104px));
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal-panel {
    width: 100%;
    max-width: calc(100vw - 20px);
    max-height: none;
    overflow: visible;
    display: block;
  }

  .modal-head {
    align-items: flex-start;
    padding: 14px;
  }

  .modal-head-actions {
    gap: 8px;
  }

  .modal-head-actions button {
    min-height: 38px;
    padding: 0 12px;
  }

  .modal-head h2 {
    font-size: 18px;
  }

  .modal-body {
    padding: 14px;
    padding-bottom: 18px;
    overflow-x: hidden;
    overflow-y: visible;
  }

  .modal-actions {
    flex-direction: column-reverse;
    position: static;
    margin: 8px 0 0;
    padding: 10px 0 4px;
    border-top: 1px solid var(--line);
  }

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

@media (max-width: 430px) {
  .modal-backdrop {
    padding: 6px 6px max(116px, calc(env(safe-area-inset-bottom) + 116px));
  }

  .modal-head {
    flex-direction: column;
  }

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

  .modal-panel {
    max-width: calc(100vw - 12px);
    max-height: none;
  }

  .order-edit-section,
  .detail-edit-section,
  .line-item {
    max-width: 100%;
    overflow: hidden;
  }

  .order-detail-line .line-heading {
    flex-direction: column;
  }

  .order-detail-line .line-actions {
    grid-template-columns: 1fr;
  }

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

  .section-title-row button {
    width: 100%;
  }
}
