:root {
  --bg: #f7f8f3;
  --panel: #ffffff;
  --panel-soft: #fafbf5;
  --ink: #171b14;
  --muted: #686f61;
  --line: #e4e7dc;
  --soft: #f1f3e8;
  --primary: #9ba600;
  --primary-dark: #7d8700;
  --primary-soft: #eef2c6;
  --accent: #bd6b35;
  --danger: #b94343;
  --ok: #1d7a4a;
  --shadow: none;
  --shadow-soft: none;
}

/* WeChat/iOS zoom guard: inputs below 16px trigger browser auto-zoom on focus. */
@media (max-width: 640px) {
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    touch-action: manipulation;
  }

  input,
  select,
  textarea,
  .login-input-wrap input,
  .data-table input,
  .data-table select,
  .product-edit-table input,
  .product-edit-table select,
  .paste-table input,
  .toolbar-search,
  .search,
  .qty-stepper input,
  .picker-row .qty-stepper input,
  .order-edit-modal input,
  .order-edit-modal select {
    font-size: 16px !important;
  }

  input::placeholder,
  textarea::placeholder {
    font-size: 16px !important;
  }
}

* { box-sizing: border-box; }

html { scrollbar-gutter: stable; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 44px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(155, 166, 0, 0.14);
}

.readonly-field {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.readonly-field span {
  display: block;
  margin-bottom: 4px;
  color: #596154;
  font-size: 12px;
  font-weight: 700;
}

.readonly-field strong {
  display: block;
  font-size: 16px;
  line-height: 1.25;
}

h1, h2, h3, p { margin: 0; }
h2 { font-size: 24px; line-height: 1.18; letter-spacing: 0; }
h3 { font-size: 15px; line-height: 1.25; }
label span { display: block; margin-bottom: 6px; color: #596154; font-size: 12px; font-weight: 700; }

.hidden { display: none !important; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
  background: var(--primary);
}

.login-panel {
  width: min(420px, 100%);
  padding: 28px;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: none;
  text-align: center;
}

.login-logo {
  display: block;
  width: min(178px, 62%);
  height: auto;
  object-fit: contain;
  margin: 4px auto 18px;
  border-radius: 0;
}

.login-panel h1 { font-size: 24px; line-height: 1.22; }
.login-panel p { margin: 8px auto 20px; color: var(--muted); line-height: 1.55; }
.login-panel input::placeholder { color: #a2aaa5; }

.login-field {
  display: block;
}

.login-input-wrap {
  min-height: 44px;
  display: flex;
  align-items: center;
  border: 1px solid #dfe3d5;
  border-radius: 8px;
  background: #fff;
  text-align: left;
  overflow: hidden;
}

.login-input-wrap span {
  flex: 0 0 auto;
  display: inline;
  margin: 0;
  padding-left: 14px;
  color: #2c3328;
  font-size: 14px;
  font-weight: 750;
}

.login-input-wrap input {
  min-height: 42px;
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding-left: 0;
  box-shadow: none;
}
.stack { display: grid; gap: 12px; }
.error { min-height: 20px; color: var(--danger); font-size: 13px; }

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.app-brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
}

.app-brand img {
  width: 30px;
  height: 30px;
  object-fit: cover;
  border-radius: 8px;
}

.topbar strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  letter-spacing: 0;
}

.topbar small { display: block; color: var(--muted); font-size: 12px; }
.content { width: min(1180px, 100%); margin: 0 auto; padding: 18px 12px 30px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.page-title {
  display: grid;
  gap: 4px;
  margin: 8px 2px 16px;
}

.page-title.row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
}

.page-title p {
  max-width: 720px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
}

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

.section-head p, .hint { color: var(--muted); font-size: 13px; }
.section-head.slim { margin-bottom: 8px; }

.sheet-card {
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.primary, .ghost, .icon-btn {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  white-space: nowrap;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.primary {
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  box-shadow: none;
}

.primary:hover { background: var(--primary-dark); }
.primary:active, .ghost:active { transform: translateY(1px); }

.ghost {
  display: inline-grid;
  place-items: center;
  border: 1px solid #d8dccd;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
}
.ghost:hover { border-color: #c7ccb9; background: #fff; }
.icon-btn { min-width: 44px; background: var(--accent); color: #fff; font-size: 20px; }
.icon-close {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  margin-top: -2px;
  margin-right: -2px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #2c3328;
  font-size: 28px;
  line-height: 1;
}

.icon-close:hover {
  background: #f4f6ef;
}

.danger { color: var(--danger); }
.ok { color: var(--ok); }
.danger-text { color: var(--danger); }

.segmented, .subtabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 6px;
  overflow: hidden;
  margin-bottom: 12px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

.segmented button, .subtabs button {
  min-height: 34px;
  min-width: 0;
  padding: 0 12px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.segmented button.active, .subtabs button.active {
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.sheet-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  overflow-x: auto;
}

.table-section { padding-top: 0; }

.sticky-controls {
  position: sticky;
  top: calc(58px + env(safe-area-inset-top));
  z-index: 4;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: -14px -14px 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
}

.sticky-controls h3 { margin-bottom: 3px; }

.compact-controls {
  align-items: center;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.toolbar-search {
  max-width: none;
  flex: 1;
  margin-bottom: 0;
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.line { height: 1px; background: var(--line); }
.search { margin-bottom: 10px; }
.search-inline { max-width: 260px; }
.input-action {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.input-action .ghost { min-width: 116px; }

.scan-button {
  min-width: 128px;
  height: 42px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  border: 1px solid var(--primary);
  border-radius: 8px;
  background: var(--primary);
  color: #fff !important;
  font-size: 17px;
  font-weight: 850;
  line-height: 1;
  vertical-align: middle;
}

.scan-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}
.full { width: 100%; }

.picker-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: inset 3px 0 0 var(--primary-soft);
}

.picker-card strong { font-size: 15px; }
.picker-card .muted { margin-top: 3px; }
.picker-card .primary {
  min-height: 42px;
  color: #fff !important;
  font-size: 17px;
  font-weight: 850;
  line-height: 1;
}

.scan-button span {
  display: inline-flex;
  align-items: center;
  height: auto;
  color: inherit !important;
  font-size: inherit !important;
  font-weight: inherit !important;
  line-height: 1;
  transform: translateY(3px);
}

.cost-preview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.cost-preview div {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #e4e8d9;
  background: #fbfcf3;
}

.cost-preview span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.cost-preview strong {
  display: block;
  margin-top: 2px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.data-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th, .data-table td {
  border-bottom: 1px solid var(--line);
  padding: 9px 8px;
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f4f6e8;
  color: #555d4c;
  font-weight: 700;
}

.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table input, .data-table select { min-width: 130px; padding: 8px; border-radius: 7px; }
.data-table .narrow { min-width: 72px; max-width: 86px; }
.data-table .order-input { min-width: 170px; }
.data-table .date-input { min-width: 145px; }
.data-table .product-select { min-width: 220px; }
.paste-table input { min-width: 170px; }
.product-edit-table { min-width: 980px; }
.product-edit-table input { min-width: 120px; }

.image-edit {
  position: relative;
  width: 58px;
  height: 58px;
}

.image-edit button {
  width: 58px;
  height: 58px;
  padding: 0;
  border-radius: 8px;
  background: #eef1ef;
}

.product-thumb {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f1f3f1;
}

.product-thumb.empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.image-plus {
  font-size: 22px;
  color: var(--muted);
}

.image-pencil {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  border: 2px solid #fff;
}

.orders-list, .product-table { display: grid; gap: 10px; }

.order-card, .product-row, .multi-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 13px;
  box-shadow: var(--shadow-soft);
}

.order-card header, .product-row, .multi-row header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.order-no { font-weight: 800; word-break: break-all; }
.muted { color: var(--muted); font-size: 13px; }
.summary-text { margin: 9px 0; line-height: 1.45; }

.mini-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.mini-grid div {
  padding: 9px;
  border-radius: 8px;
  border: 1px solid #e5e9d8;
  background: #fbfcf3;
}

.mini-grid div {
  min-width: 0;
}

.mini-grid span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: clamp(9px, 2.4vw, 11px);
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-grid strong {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  font-size: clamp(13px, 3.7vw, 15px);
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.summary-cards article {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.summary-cards span, .session-profit span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.summary-cards strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  font-size: clamp(15px, 4.8vw, 18px);
  line-height: 1.15;
  white-space: nowrap;
}

.session-profit {
  min-width: 108px;
  text-align: right;
}

.session-profit strong {
  display: block;
  margin-top: 2px;
  font-size: 18px;
}

.multi-card-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.product-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: #e8f2ed;
  color: var(--primary-dark);
  font-size: 12px;
}

.badge.warn { background: #fff0e4; color: #9b4e16; }

.bottom-nav {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: 8px;
  z-index: 6;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  width: min(760px, calc(100% - 16px));
  max-width: calc(100% - 16px);
  transform: translateX(-50%);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  border: 1px solid rgba(225, 228, 216, 0.9);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  box-shadow: none;
}

.bottom-nav button {
  min-width: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  min-height: 46px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.bottom-nav button > span:last-child {
  max-width: 100%;
  overflow: hidden;
  font-size: clamp(10px, 2.55vw, 12px);
  line-height: 1;
  white-space: nowrap;
}

.bottom-nav button.active {
  background: var(--primary);
  font-weight: 800;
  color: #fff;
}

.nav-icon {
  position: relative;
  width: 23px;
  height: 23px;
  color: currentColor;
}

.nav-icon::before, .nav-icon::after {
  content: "";
  position: absolute;
  box-sizing: border-box;
}

.icon-entry::before {
  left: 5px;
  top: 5px;
  width: 13px;
  height: 15px;
  border: 1.8px solid currentColor;
  border-radius: 4px;
}

.icon-entry::after {
  left: 8px;
  top: 2px;
  width: 7px;
  height: 5px;
  border: 1.8px solid currentColor;
  border-radius: 3px;
  background: rgba(255, 255, 250, 0.92);
}

.bottom-nav button.active .icon-entry::after {
  background: var(--primary);
}

.icon-details::before {
  left: 4px;
  top: 4px;
  width: 15px;
  height: 15px;
  border: 1.8px solid currentColor;
  border-radius: 4px;
}

.icon-details::after {
  left: 8px;
  top: 8px;
  width: 8px;
  height: 1.8px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 4px 0 currentColor, 0 8px 0 currentColor;
}

.icon-ship::before {
  left: 3px;
  top: 8px;
  width: 13px;
  height: 8px;
  border: 1.8px solid currentColor;
  border-radius: 3px;
}

.icon-ship::after {
  left: 5px;
  top: 17px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 10px 0 0 currentColor, 11px -8px 0 -1px currentColor;
}

.icon-products::before {
  left: 4px;
  top: 5px;
  width: 14px;
  height: 14px;
  border: 1.8px solid currentColor;
  border-radius: 4px;
  transform: rotate(45deg);
}

.icon-products::after {
  left: 7px;
  top: 7px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
}

.icon-sessions::before {
  left: 4px;
  right: 4px;
  bottom: 5px;
  height: 12px;
  border-left: 1.8px solid currentColor;
  border-bottom: 1.8px solid currentColor;
  border-radius: 0 0 0 3px;
}

.icon-sessions::after {
  left: 8px;
  bottom: 6px;
  width: 2.5px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 5px -3px 0 currentColor, 10px -7px 0 currentColor;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(0, 0, 0, 0.62);
}

.modal-card {
  width: min(560px, 100%);
  padding: 10px;
  border-radius: 14px;
  background: #fff;
}

.modal-card .section-head h2 {
  font-size: 18px;
  line-height: 1.2;
}

.modal-card .section-head p {
  font-size: 12px;
  line-height: 1.45;
}

.picker-modal {
  width: min(520px, 100%);
  max-height: calc(100vh - 24px);
  display: grid;
  grid-template-rows: auto auto 1fr auto;
}

.order-edit-modal {
  width: min(500px, 100%);
}

.picker-list {
  display: grid;
  gap: 6px;
  overflow: auto;
  padding-right: 2px;
}

.picker-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.picker-row strong {
  display: block;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-row .muted {
  margin-top: 2px;
  overflow: hidden;
  font-size: 10px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-row .product-thumb,
.picker-row .product-thumb.empty,
.picker-row .image-edit,
.picker-row .image-edit button {
  width: 44px;
  height: 44px;
}

.qty-stepper {
  display: grid;
  grid-template-columns: 28px 36px 28px;
  gap: 3px;
  align-items: center;
}

.qty-stepper button {
  height: 28px;
  border-radius: 7px;
  background: var(--primary-soft);
  color: var(--ink);
  font-weight: 800;
}

.qty-stepper input {
  min-height: 28px;
  height: 28px;
  padding: 4px;
  font-size: 12px;
  text-align: center;
}

#scannerVideo {
  width: 100%;
  min-height: 280px;
  border-radius: 10px;
  background: #111;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(86px + env(safe-area-inset-bottom));
  z-index: 30;
  transform: translateX(-50%);
  max-width: min(520px, calc(100% - 28px));
  padding: 11px 14px;
  border-radius: 999px;
  background: #101820;
  color: #fff;
  box-shadow: var(--shadow);
}

@media (max-width: 640px) {
  body { background: var(--bg); }
  h2 { font-size: 22px; }
  .app-shell { padding-bottom: calc(82px + env(safe-area-inset-bottom)); }
  .topbar { padding-left: 10px; padding-right: 10px; }
  .app-brand img { width: 28px; height: 28px; }
  .topbar strong { font-size: 14px; }
  #logoutBtn { min-height: 34px; padding: 0 10px; font-size: 12px; }
  .content { padding: 12px 8px 26px; }
  .page-title { margin-top: 4px; margin-bottom: 12px; }
  .page-title p { font-size: 13px; }
  .sheet-card { padding: 12px; }
  .sticky-controls { margin: -12px -12px 10px; padding: 10px 12px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .mini-grid, .cost-preview, .summary-cards { grid-template-columns: 1fr 1fr; }
  .input-action { grid-template-columns: 1fr !important; }
  .input-action .ghost { width: 100%; min-width: 0; }
  .input-action .scan-button { width: 100%; min-width: 0; }
  .picker-card { grid-template-columns: 1fr; }
  .picker-card .primary { width: 100%; }
  .form-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .content { padding-left: 8px; padding-right: 8px; }
  .sticky-controls { padding: 10px; gap: 8px; }
  .sticky-controls .hint { font-size: 12px; }
  .toolbar-actions { gap: 6px; }
  .toolbar-actions button { min-width: 64px; padding-left: 10px; padding-right: 10px; }
  .multi-card-list { grid-template-columns: 1fr; }
  .page-title.row { align-items: stretch; flex-direction: column; }
  .bottom-nav { bottom: 8px; width: calc(100% - 16px); }
  .bottom-nav button { min-height: 48px; font-size: 11px; }
  .nav-icon { width: 20px; height: 20px; }
  .modal { padding: 10px; }
  .modal-card { max-height: calc(100vh - 20px); overflow: auto; }
  .order-edit-modal .inline-edit-grid,
  .order-edit-modal .inline-product-edit {
    grid-template-columns: 1fr;
  }
  .picker-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }
  .picker-row .qty-stepper {
    grid-column: auto;
    justify-self: end;
    grid-template-columns: 28px 34px 28px;
  }
}

/* Senior UI polish pass */
html {
  overflow-y: scroll;
  scrollbar-gutter: stable both-edges;
}

body {
  font-size: 14px;
  line-height: 1.5;
}

h2 {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.18;
}

h3 {
  font-size: 15px;
  font-weight: 800;
}

.content {
  padding-top: 20px;
}

.page-title {
  gap: 6px;
  margin: 6px 4px 18px;
}

.page-title p,
.hint,
.section-head p {
  font-size: 13px;
  line-height: 1.65;
}

.sheet-card,
.order-card,
.product-row,
.multi-row,
.summary-cards article {
  border-color: #dfe3d5;
  background: #fff;
}

.primary,
.ghost,
.icon-btn {
  min-height: 42px;
  border-radius: 8px;
  font-size: 14px;
}

.primary {
  letter-spacing: 0;
}

.ghost {
  color: #2c3328;
}

input,
select,
textarea {
  min-height: 44px;
  border-color: #dfe3d5;
  font-size: 14px;
}

.subtabs {
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
}

.subtabs button {
  min-height: 38px;
  padding: 0 16px;
  font-size: 14px;
}

.sticky-controls {
  top: calc(56px + env(safe-area-inset-top));
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
}

.compact-controls {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
}

.toolbar-actions {
  justify-content: flex-end;
  align-items: center;
}

.toolbar-actions .primary,
.toolbar-actions .ghost {
  min-width: 84px;
}

.product-panel > .hint {
  max-width: none;
  margin: 12px 10px 14px;
  padding-right: 8px;
  color: #687061;
}

.table-wrap {
  border-color: #dfe3d5;
}

.data-table {
  font-size: 14px;
}

.data-table th,
.data-table td {
  padding: 10px 10px;
}

.data-table th {
  height: 44px;
  background: #f2f5e7;
  color: #525b49;
}

.data-table input,
.data-table select {
  min-height: 40px;
  border-radius: 8px;
}

.image-edit,
.image-edit button {
  width: 56px;
  height: 56px;
}

.product-thumb {
  width: 52px;
  height: 52px;
}

.orders-list {
  gap: 12px;
}

.order-card,
.multi-row {
  padding: 14px;
}

.order-card-editing {
  border-color: rgba(160, 176, 0, 0.45);
  background: #fffef7;
}

.inline-edit-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(120px, 0.8fr) minmax(150px, 0.8fr);
  gap: 8px;
}

.inline-product-edit {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
  margin-bottom: 4px;
}

.inline-product-edit > div {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid #e3e7d7;
  border-radius: 8px;
  background: #fff;
}

.inline-product-edit strong {
  font-size: 13px;
}

.inline-product-edit p {
  min-height: 30px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  word-break: break-word;
}

.inline-product-edit .primary {
  min-height: 34px;
  font-size: 13px;
  font-weight: 800;
}

.order-card .form-actions {
  display: grid;
  grid-template-columns: 1fr;
}

.edit-order-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  font-size: 15px;
  font-weight: 750;
}

.edit-pencil {
  display: inline-block;
  color: var(--primary);
  font-size: 16px;
  line-height: 1;
  transform: translateY(1px);
}

.order-card-head {
  align-items: flex-start;
}

.order-title-block {
  min-width: 0;
}

.order-no {
  color: var(--ink);
  font-size: 18px;
  line-height: 1.28;
  letter-spacing: 0;
}

.profit-pill {
  min-width: 96px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: right;
  background: #fafbf5;
}

.profit-pill span {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.profit-pill strong {
  display: block;
  font-size: 17px;
  line-height: 1.2;
}

.profit-pill.negative {
  border-color: #efd0cf;
  background: #fff7f6;
  color: var(--danger);
}

.profit-pill.positive {
  border-color: #d8e5d3;
  background: #f6fbf2;
  color: var(--ok);
}

.summary-text {
  margin: 12px 0;
  padding: 11px 12px;
  border: 1px solid #e3e7d7;
  border-radius: 8px;
  background: #fbfcf5;
  color: #22271f;
  font-size: 14px;
  line-height: 1.65;
}

.order-date-edit {
  max-width: 220px;
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
}

.order-date-edit span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.order-date-edit input {
  min-height: 38px;
  border-radius: 8px;
  font-size: 14px;
}

.summary-line {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
}

.summary-line + .summary-line {
  margin-top: 6px;
}

.summary-line span {
  color: #596154;
  font-weight: 800;
}

.summary-line p {
  min-width: 0;
  word-break: break-word;
}

.mini-grid {
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 8px;
}

.mini-grid div {
  min-height: 64px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 10px 12px;
}

.mini-grid span {
  font-size: 12px;
  line-height: 1.3;
}

.mini-grid strong {
  margin-top: 5px;
  font-size: 15px;
  line-height: 1.25;
  word-break: break-word;
}

.order-card .form-actions,
.multi-row .form-actions {
  margin-top: 12px;
}

.form-actions .ghost,
.form-actions .primary {
  min-height: 42px;
}

.multi-card-list {
  align-items: start;
}

.multi-row .grid2 {
  margin-top: 10px;
}

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

@media (min-width: 761px) {
  .summary-cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.bottom-nav {
  left: calc((100vw - var(--page-width, 100vw)) / 2 + 8px);
  right: calc((100vw - var(--page-width, 100vw)) / 2 + 8px);
  width: auto;
  max-width: 760px;
  margin: 0 auto;
  transform: none;
  gap: 4px;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  border-radius: 18px;
}

.compact-controls .toolbar-search,
.sticky-controls .search {
  margin-bottom: 0;
}

.bottom-nav button {
  min-width: 0;
  min-height: 50px;
  gap: 4px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 650;
}

.bottom-nav button.active {
  font-weight: 800;
}

.nav-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
}

.nav-icon::before,
.nav-icon::after {
  display: none;
}

.nav-icon svg {
  width: 22px;
  height: 22px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 760px) {
  h2 {
    font-size: 24px;
  }

  .content {
    padding: 14px 10px 28px;
  }

  .page-title {
    margin-bottom: 14px;
  }

  .compact-controls {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .toolbar-actions {
    gap: 6px;
  }

  .toolbar-actions .primary,
  .toolbar-actions .ghost {
    min-width: 64px;
    padding-left: 12px;
    padding-right: 12px;
  }

  .product-panel > .hint {
    margin: 10px 4px 12px;
  }

  .order-card,
  .multi-row {
    padding: 12px;
  }

  .order-no {
    font-size: 16px;
  }

  .profit-pill {
    min-width: 88px;
    padding: 6px 8px;
  }

  .profit-pill strong {
    font-size: 16px;
  }

  .summary-text {
    font-size: 14px;
  }

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

  .bottom-nav {
    width: auto;
  }
}

@media (max-width: 420px) {
  .toolbar-actions .primary,
  .toolbar-actions .ghost {
    min-width: 56px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .data-table {
    font-size: 13px;
  }

  .summary-line {
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 8px;
  }

  .bottom-nav button {
    font-size: 11px;
  }
}

/* Tightened UI QA pass from annotated screenshots */
html {
  scrollbar-gutter: stable;
}

body {
  background: #f8f9f4;
}

.topbar {
  padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-left)) 10px max(16px, env(safe-area-inset-left));
}

#logoutBtn {
  min-width: 118px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  line-height: 1;
  text-align: center;
}

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 46px;
  background-image: url("data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23171B14' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 18px center;
  background-size: 18px 18px;
}

input[type="date"] {
  padding-right: 46px;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  width: 46px;
  height: 100%;
  margin: 0 -12px 0 0;
  padding: 0;
  cursor: pointer;
}

.page-title.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  column-gap: 14px;
}

.page-title.row > div {
  min-width: 0;
}

.page-title.row h2,
.page-title.row p {
  max-width: 100%;
  overflow-wrap: break-word;
}

.page-title.row > .ghost {
  grid-column: 2;
  grid-row: 1;
  align-self: start;
  min-width: 76px;
  width: auto;
  border-color: #d8dccd;
  background: #fff;
}

.order-card-head {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
}

.profit-pill,
.profit-pill.negative,
.profit-pill.positive {
  min-width: 82px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  display: grid;
  justify-items: end;
  align-content: start;
  gap: 1px;
  transform: translateY(-2px);
}

.profit-pill span {
  color: #70776a;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.2;
}

.profit-pill strong {
  font-size: 20px;
  font-weight: 820;
  line-height: 1.05;
}

.profit-pill.negative strong {
  color: var(--danger);
}

.profit-pill.positive strong {
  color: var(--ok);
}

.ship-panel.sheet-card,
.product-panel.sheet-card {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.ship-panel .sticky-controls,
.product-panel .sticky-controls {
  position: sticky;
  margin: 0 0 10px;
  padding: 0;
  border: 0;
  background: transparent;
  backdrop-filter: none;
  align-items: center;
}

.ship-panel .sticky-controls > div:first-child {
  display: grid;
  align-content: center;
  min-height: 54px;
}

.ship-panel .sticky-controls .hint {
  margin: 0;
  line-height: 1.55;
}

.ship-panel .table-wrap,
.product-panel .table-wrap {
  border-radius: 10px;
  background: #fff;
  border-color: #dde2d2;
}

.product-panel > .hint {
  margin: 8px 4px 12px;
  padding: 0;
}

.subtabs {
  margin-bottom: 14px;
  background: #fff;
}

.table-section .data-table {
  background: #fff;
}

.multi-card-list {
  padding-top: 2px;
}

.multi-row {
  border-radius: 10px;
}

@media (max-width: 760px) {
  .topbar {
    padding-left: 16px;
    padding-right: 16px;
  }

  .content {
    padding-left: 16px;
    padding-right: 16px;
  }

  #logoutBtn {
    min-width: 116px;
    min-height: 48px;
    font-size: 14px;
  }

  .page-title.row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }

  .page-title.row > .ghost {
    grid-column: 2;
    grid-row: 1;
  }

  .profit-pill {
    min-width: 82px;
  }

  .profit-pill strong {
    font-size: 20px;
  }

  .ship-panel .sticky-controls,
  .product-panel .sticky-controls {
    gap: 10px;
  }

  .session-toolbar,
  .session-edit-grid {
    grid-template-columns: 1fr;
  }

  .session-toolbar .primary {
    width: 100%;
  }
}

/* Brand and surface refresh */
.topbar {
  min-height: 64px;
}

.app-brand {
  gap: 10px;
}

.app-brand .brand-wordmark {
  width: 82px;
  height: auto;
  max-height: 28px;
  object-fit: contain;
  border-radius: 0;
}

.topbar strong {
  font-size: 17px;
  font-weight: 850;
  letter-spacing: 0;
}

#logoutBtn {
  min-width: 88px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
}

.subtabs {
  --seg-radius: 18px;
  --seg-pad: 6px;
  gap: 5px;
  padding: var(--seg-pad);
  border: 0;
  border-radius: var(--seg-radius);
  background: #edf0e9;
}

.subtabs button {
  min-width: 0;
  min-height: 42px;
  padding: 0 16px;
  border-radius: calc(var(--seg-radius) - var(--seg-pad));
  color: #73796d;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subtabs button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 14px rgba(32, 38, 28, 0.07);
}

.nav-icon {
  width: 24px;
  height: 24px;
}

.nav-icon svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.05;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-icon .nav-cut {
  display: none;
}

.bottom-nav button {
  color: #646d5f;
}

.bottom-nav button.active .nav-icon svg {
  stroke: #fff;
}

.bottom-nav button:not(.active) .nav-icon svg {
  stroke: #646d5f;
}

.nav-glyph-entry {
  transform: scale(1.02);
}

.nav-glyph-details {
  transform: scale(0.97);
}

.nav-glyph-products {
  transform: scale(0.96);
}

/* Dense operator mode */
.picker-modal {
  width: min(480px, 100%);
}

.order-edit-modal {
  width: min(460px, 100%);
}

.picker-row {
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 5px;
  padding: 5px 6px;
}

.picker-row .product-thumb,
.picker-row .product-thumb.empty,
.picker-row .image-edit,
.picker-row .image-edit button {
  width: 36px;
  height: 36px;
}

.picker-row strong {
  font-size: 12px;
  line-height: 1.15;
}

.picker-row .muted {
  font-size: 10px;
  line-height: 1.1;
}

.picker-row .qty-stepper {
  grid-column: auto;
  grid-template-columns: 26px 32px 26px;
  gap: 3px;
  justify-self: end;
}

.picker-row .qty-stepper button,
.picker-row .qty-stepper input {
  min-height: 26px;
  height: 26px;
  border-radius: 6px;
  font-size: 12px;
}

.inline-edit-grid {
  gap: 6px;
}

.inline-product-edit {
  gap: 6px;
  margin-top: 6px;
  margin-bottom: 2px;
}

.inline-product-edit > div {
  gap: 5px;
  padding: 7px;
}

.inline-product-edit strong {
  font-size: 12px;
}

.inline-product-edit p {
  min-height: 24px;
  font-size: 10px;
  line-height: 1.25;
}

.inline-product-edit .primary {
  min-height: 30px;
  font-size: 12px;
}

.mini-grid div {
  min-width: 0;
}

.mini-grid span {
  overflow: hidden;
  font-size: clamp(9px, 2.4vw, 11px) !important;
  line-height: 1.15 !important;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-grid strong {
  overflow: hidden;
  font-size: clamp(13px, 3.7vw, 15px) !important;
  line-height: 1.15 !important;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.session-toolbar .hint {
  margin: 0;
  line-height: 1.55;
}

.session-toolbar .primary {
  min-width: 108px;
}

.session-edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}

.session-card {
  border-radius: 10px;
}

.session-card header {
  align-items: start;
}

@media (max-width: 760px) {
  .topbar {
    min-height: 60px;
  }

  .app-brand {
    gap: 8px;
  }

  .app-brand .brand-wordmark {
    width: 68px;
    max-height: 24px;
  }

  .topbar strong {
    font-size: 16px;
  }

  #logoutBtn {
    min-width: 78px;
    min-height: 34px;
    font-size: 12px;
    padding: 0 10px;
  }

  .subtabs {
    --seg-radius: 16px;
    --seg-pad: 5px;
  }

  .subtabs button {
    min-height: 40px;
    padding: 0 13px;
  }
}

@media (max-width: 430px) {
  .app-brand .brand-wordmark {
    width: 58px;
  }

  .topbar strong {
    font-size: 15px;
  }
}

/* Operator density pass */
.picker-row {
  min-height: 48px;
}

.picker-row.picker-lf {
  grid-template-columns: minmax(0, 1fr) auto;
}

.picker-row.picker-lf strong {
  display: -webkit-box;
  overflow: hidden;
  font-size: 12.5px;
  line-height: 1.25;
  white-space: normal;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.picker-row.picker-lf .muted {
  margin-top: 1px;
}

.order-no {
  overflow: hidden;
  font-size: clamp(15px, 4vw, 18px);
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: normal;
}

.summary-text {
  margin: 9px 0;
  padding: 9px 10px;
  font-size: 13.25px;
  line-height: 1.5;
}

.summary-line {
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 8px;
}

.summary-line + .summary-line {
  margin-top: 4px;
}

.summary-line span {
  font-size: 13px;
}

.mini-grid {
  gap: 7px;
}

.mini-grid div {
  min-height: 52px;
  padding: 7px 9px;
}

.mini-grid span {
  font-size: clamp(11px, 3vw, 12px) !important;
  line-height: 1.12 !important;
}

.mini-grid strong {
  margin-top: 4px;
  font-size: clamp(15px, 4.2vw, 16px) !important;
  line-height: 1.12 !important;
}

.order-card {
  padding: 11px;
}

.orders-list,
.product-table {
  gap: 8px;
}

.table-wrap {
  border-radius: 8px;
}

.data-table th,
.data-table td {
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.28;
}

.data-table input,
.data-table select {
  min-height: 34px;
  padding: 6px 8px;
  font-size: 13px;
}

.product-panel > .hint,
.ship-panel .sticky-controls .hint {
  font-size: 13px;
  line-height: 1.45;
}

.product-row,
.multi-row {
  padding: 11px;
}

@media (max-width: 640px) {
  .summary-text {
    font-size: 12.75px;
  }

  .summary-line {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .summary-line span {
    font-size: 12.5px;
  }

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

  .mini-grid div {
    min-height: 50px;
    padding: 7px 8px;
  }
}

/* Fine density and affordance fixes */
.file-input-proxy {
  position: fixed;
  left: -100vw;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.image-edit button {
  cursor: pointer;
}

.image-pencil {
  transform: scaleX(-1);
}

.edit-pencil {
  transform: scaleX(-1) translateY(1px);
}

.order-card .mini-grid span,
.session-card .mini-grid span {
  font-weight: 500;
}

.order-card .mini-grid strong,
.session-card .mini-grid strong,
.session-profit strong,
.profit-pill strong {
  font-weight: 650;
}

.box-spec-value {
  font-size: clamp(12px, 3.4vw, 14px) !important;
  letter-spacing: 0;
}

.summary-line span {
  font-weight: 650;
}

.summary-line p {
  font-size: 13px;
  line-height: 1.42;
}

.product-edit-table {
  border-collapse: separate;
  border-spacing: 0 4px;
}

.product-edit-table th,
.product-edit-table td {
  border-bottom: 0;
  padding: 5px 8px;
}

.product-edit-table tbody tr {
  background: #fff;
}

.product-edit-table tbody tr:nth-child(even) {
  background: #f7f8f1;
}

.product-edit-table tbody td:first-child {
  border-radius: 8px 0 0 8px;
}

.product-edit-table tbody td:last-child {
  border-radius: 0 8px 8px 0;
}

.product-edit-table input,
.product-edit-table select {
  min-height: 30px;
  padding: 5px 7px;
  font-size: 12.5px;
}

.product-edit-table .ghost {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12.5px;
}

.product-edit-table .image-edit,
.product-edit-table .image-edit button {
  width: 44px;
  height: 44px;
}

.product-edit-table .product-thumb {
  width: 40px;
  height: 40px;
}

.product-edit-table .image-pencil {
  right: -3px;
  bottom: -3px;
  width: 20px;
  height: 20px;
  font-size: 11px;
}

@media (max-width: 640px) {
  .summary-line p {
    font-size: 12.5px;
  }

  .product-edit-table th,
  .product-edit-table td {
    padding: 4px 7px;
  }
}

/* Product table and box-spec polish */
.box-spec-value {
  display: -webkit-box !important;
  overflow: visible !important;
  font-size: clamp(11px, 3vw, 13px) !important;
  line-height: 1.2 !important;
  text-overflow: clip !important;
  white-space: normal !important;
  word-break: break-all;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.mini-grid div:has(.box-spec-value) {
  justify-content: flex-start;
  min-height: 58px;
}

.product-panel .table-wrap {
  padding-top: 0;
  border-radius: 8px;
  background: #fff;
}

.product-edit-table {
  border-collapse: collapse;
  border-spacing: 0;
  table-layout: fixed;
}

.gd-product-edit-table {
  min-width: 760px;
}

.lf-product-edit-table {
  min-width: 560px;
}

.gd-product-edit-table th:nth-child(1),
.gd-product-edit-table td:nth-child(1) {
  width: 86px;
}

.gd-product-edit-table th:nth-child(2),
.gd-product-edit-table td:nth-child(2) {
  width: 260px;
}

.gd-product-edit-table th:nth-child(3),
.gd-product-edit-table td:nth-child(3),
.gd-product-edit-table th:nth-child(4),
.gd-product-edit-table td:nth-child(4),
.gd-product-edit-table th:nth-child(5),
.gd-product-edit-table td:nth-child(5),
.gd-product-edit-table th:nth-child(6),
.gd-product-edit-table td:nth-child(6) {
  width: 98px;
}

.gd-product-edit-table th:nth-child(7),
.gd-product-edit-table td:nth-child(7) {
  width: 72px;
}

.lf-product-edit-table th:nth-child(1),
.lf-product-edit-table td:nth-child(1) {
  width: 280px;
}

.lf-product-edit-table th:nth-child(2),
.lf-product-edit-table td:nth-child(2) {
  width: 150px;
}

.lf-product-edit-table th:nth-child(3),
.lf-product-edit-table td:nth-child(3) {
  width: 90px;
}

.lf-product-edit-table th:nth-child(4),
.lf-product-edit-table td:nth-child(4) {
  width: 72px;
}

.product-edit-table th,
.product-edit-table td {
  padding: 4px 7px;
  border-bottom: 0;
  border-radius: 0 !important;
}

.product-edit-table th {
  background: #f4f6e8;
}

.product-edit-table tbody tr {
  background: #fff;
}

.product-edit-table tbody tr:nth-child(even) {
  background: #fbfcf8;
}

.product-edit-table input,
.product-edit-table select {
  width: 100%;
  min-width: 0;
  min-height: 29px;
  padding: 4px 7px;
}

.product-edit-table .image-edit,
.product-edit-table .image-edit button {
  width: 40px;
  height: 40px;
}

.product-edit-table .product-thumb {
  width: 36px;
  height: 36px;
}

/* Final alignment pass */
.box-spec-value {
  display: block !important;
  overflow: visible !important;
  font-size: clamp(8px, 2.05vw, 10px) !important;
  line-height: 1.15 !important;
  text-overflow: clip !important;
  white-space: nowrap !important;
  word-break: normal !important;
  -webkit-line-clamp: unset;
}

.mini-grid div:has(.box-spec-value) {
  justify-content: center;
  min-height: 50px;
}

.gd-product-edit-table {
  min-width: 720px;
}

.gd-product-edit-table th:nth-child(1),
.gd-product-edit-table td:nth-child(1) {
  width: 64px;
  padding-right: 3px;
}

.gd-product-edit-table th:nth-child(2),
.gd-product-edit-table td:nth-child(2) {
  width: 220px;
  padding-left: 4px;
}

.gd-product-edit-table th:nth-child(3),
.gd-product-edit-table td:nth-child(3),
.gd-product-edit-table th:nth-child(4),
.gd-product-edit-table td:nth-child(4),
.gd-product-edit-table th:nth-child(5),
.gd-product-edit-table td:nth-child(5),
.gd-product-edit-table th:nth-child(6),
.gd-product-edit-table td:nth-child(6) {
  width: 91px;
}

.gd-product-edit-table th:nth-child(7),
.gd-product-edit-table td:nth-child(7) {
  width: 72px;
}

.lf-product-edit-table {
  min-width: 520px;
}

.lf-product-edit-table th:nth-child(1),
.lf-product-edit-table td:nth-child(1) {
  width: 250px;
}

.product-edit-table th,
.product-edit-table td {
  padding-top: 6px;
  padding-bottom: 6px;
}

.product-edit-table input,
.product-edit-table select {
  min-height: 33px;
}

.product-edit-table .image-edit,
.product-edit-table .image-edit button {
  width: 48px;
  height: 48px;
}

.product-edit-table .product-thumb {
  width: 44px;
  height: 44px;
}

.product-edit-table .image-pencil {
  right: -2px;
  bottom: -2px;
  width: 19px;
  height: 19px;
}

.session-card header {
  align-items: flex-start;
}

.session-card header > div:first-child {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.session-profit {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

/* Final fixes from mobile review */
.box-spec-value {
  display: block !important;
  max-width: 100%;
  overflow: hidden !important;
  font-size: 6px !important;
  font-weight: 600 !important;
  letter-spacing: -0.3px;
  line-height: 1.05 !important;
  text-overflow: clip !important;
  white-space: nowrap !important;
}

.picker-row.picker-lf {
  grid-template-columns: minmax(0, 1fr) 104px !important;
  align-items: center;
  min-height: 58px;
  gap: 8px;
  padding: 7px 8px;
}

.picker-row.picker-lf > div:first-child {
  min-width: 0;
}

.picker-row.picker-lf strong {
  -webkit-line-clamp: 2;
  font-size: 12.5px;
  line-height: 1.15;
}

.picker-row.picker-lf .muted {
  font-size: 11px;
}

.picker-row.picker-lf .qty-stepper {
  width: 104px;
  grid-template-columns: 30px 38px 30px;
  align-self: center;
}

.picker-row.picker-lf .qty-stepper button,
.picker-row.picker-lf .qty-stepper input {
  height: 30px;
  min-height: 30px;
}

#ship-multi .sticky-controls h3 {
  display: none;
}

#ship-multi .sticky-controls .hint {
  margin-top: 0;
}

.session-toolbar {
  margin-bottom: 6px;
}

#sessionsList {
  gap: 8px;
}

.session-card {
  margin-top: 0;
  padding-top: 9px;
}

.gd-product-edit-table [data-draft-product="gd"] .product-thumb.empty {
  position: relative;
  cursor: pointer;
}

.gd-product-edit-table [data-draft-product="gd"] .product-thumb.empty::after {
  content: none;
}

.readonly-field {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6f7f1;
  color: var(--ink);
  font-size: 15px;
  font-weight: 650;
}

.session-card {
  padding-top: 10px;
}

.session-card header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  margin-bottom: 8px;
}

.session-card header > div:first-child,
.session-profit {
  min-height: 0;
  justify-content: flex-start;
}

.session-profit {
  align-items: flex-end;
  padding-top: 1px;
  text-align: right;
}

.session-card .order-no {
  line-height: 1.12;
}

.session-card header .muted {
  margin-top: 3px;
  line-height: 1.2;
}

.session-profit span {
  margin-bottom: 4px;
  line-height: 1.1;
}

.session-profit strong {
  line-height: 1.1;
}

/* Multi-warehouse search and session header alignment */
#ship-multi .sticky-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

#ship-multi .toolbar-actions {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto;
  gap: 8px;
  width: min(430px, 48vw);
  align-items: center;
}

#multiWarehouseFilter {
  min-height: 40px;
  height: 40px;
  margin: 0;
  padding: 0 12px;
  font-size: 13px;
}

.readonly-field {
  min-height: 42px;
  height: 42px;
  justify-content: flex-start;
  font-size: 15px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.readonly-field.is-empty {
  color: #8a9080;
  font-weight: 500;
}

.session-card header {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(96px, auto);
  align-items: stretch !important;
  gap: 10px;
  min-height: 44px;
  margin-bottom: 8px;
}

.session-card header > div:first-child {
  display: grid !important;
  grid-template-rows: 23px 18px;
  align-content: start;
  min-height: 44px;
}

.session-card .order-no {
  font-size: clamp(17px, 4.4vw, 21px);
  line-height: 1;
  white-space: nowrap;
}

.session-card header .muted {
  margin-top: 2px;
  font-size: clamp(11.5px, 3.2vw, 14px);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-profit {
  display: grid !important;
  grid-template-rows: 16px 24px;
  justify-items: end;
  align-content: start;
  min-height: 44px;
  padding-top: 0;
}

.session-profit span {
  margin: 0;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.session-profit strong {
  align-self: end;
  font-size: clamp(19px, 5vw, 24px);
  line-height: 1;
  white-space: nowrap;
  letter-spacing: 0;
}

@media (max-width: 640px) {
  #ship-multi .sticky-controls {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  #ship-multi .toolbar-actions {
    grid-template-columns: minmax(108px, 1fr) auto;
    width: min(100%, 320px);
  }

  #multiWarehouseFilter {
    font-size: 12px;
    padding: 0 9px;
  }

  #saveMultiWarehouseBtn {
    min-width: 76px;
    padding-left: 12px;
    padding-right: 12px;
  }
}

/* Fixed app header, Langfang express tools, and session-card header polish */
.app-shell {
  padding-top: calc(62px + env(safe-area-inset-top));
}

.topbar {
  position: fixed !important;
  top: 0;
  left: 50%;
  z-index: 30;
  width: min(1180px, 100%);
  transform: translateX(-50%);
}

.sticky-controls {
  top: calc(62px + env(safe-area-inset-top));
}

#ship-multi .sticky-controls {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  min-height: 42px;
  margin-top: 0;
  padding-top: 0;
}

#ship-multi .sticky-controls > div:first-child {
  display: none;
}

#ship-multi .toolbar-actions {
  width: 100%;
  max-width: none;
  grid-template-columns: minmax(0, 1fr) auto;
}

#multiWarehouseFilter {
  height: 42px;
  min-height: 42px;
  font-size: 14px;
}

.session-card header {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start !important;
  min-height: 38px;
  gap: 12px;
  margin-bottom: 10px;
}

.session-card header > div:first-child {
  display: grid !important;
  grid-template-rows: auto auto;
  gap: 3px;
  min-height: 38px;
  align-content: start;
}

.session-card .order-no {
  font-size: 17px;
  font-weight: 760;
  line-height: 1.08;
  white-space: nowrap;
}

.session-card header .muted {
  margin: 0;
  font-size: 13px;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-profit {
  display: grid !important;
  grid-template-rows: auto auto;
  gap: 3px;
  min-height: 38px;
  align-content: start;
  justify-items: end;
  padding-top: 0;
}

.session-profit span {
  margin: 0;
  font-size: 13px;
  font-weight: 620;
  line-height: 1.08;
}

.session-profit strong {
  font-size: 20px;
  font-weight: 760;
  line-height: 1.08;
}

@media (max-width: 640px) {
  .app-shell {
    padding-top: calc(58px + env(safe-area-inset-top));
  }

  .sticky-controls {
    top: calc(58px + env(safe-area-inset-top));
  }

  #ship-multi .toolbar-actions {
    width: 100%;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  #multiWarehouseFilter {
    font-size: 13px;
  }

  .session-card .order-no {
    font-size: 16px;
  }

  .session-card header .muted,
  .session-profit span {
    font-size: 12.5px;
  }

  .session-profit strong {
    font-size: 19px;
  }
}

/* Session profit header final size correction */
.session-card header {
  align-items: start !important;
  min-height: 34px;
}

.session-card header > div:first-child,
.session-profit {
  min-height: 34px;
}

.session-card .order-no {
  font-size: 16px !important;
  font-weight: 720 !important;
  line-height: 1.05 !important;
}

.session-card header .muted {
  font-size: 12.5px !important;
  line-height: 1.12 !important;
}

.session-profit {
  gap: 2px;
  align-content: start !important;
  justify-self: end !important;
  grid-template-columns: 1fr !important;
  padding-top: 0 !important;
  transform: translateY(-1px);
  width: 108px;
}

.session-profit span {
  font-size: 11.5px !important;
  font-weight: 500 !important;
  line-height: 1.05 !important;
  color: var(--muted);
  justify-self: end !important;
  text-align: right;
}

.session-profit strong {
  font-size: 17px !important;
  font-weight: 700 !important;
  line-height: 1.05 !important;
  justify-self: end !important;
  text-align: right;
}

/* Modal layer must sit above the fixed app chrome */
.modal {
  z-index: 1000 !important;
}

.modal-card {
  position: relative;
  z-index: 1001;
}

.modal .icon-close,
.modal [id^="close"],
.modal .section-head button {
  position: relative;
  z-index: 1002;
}

/* Session card layout: revenue/order count align with cost grid; other costs span full width */
.session-card .session-edit-grid {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 10px 12px !important;
  margin: 10px 0 12px !important;
}

.session-card .session-stat-field,
.session-card .session-other-cost-field {
  min-width: 0;
}

.session-card .session-stat-field {
  display: block !important;
  height: auto !important;
  min-height: 70px !important;
  padding: 10px 12px !important;
  border: 1px solid #e5e9d8 !important;
  border-radius: 8px !important;
  background: #fbfcf3 !important;
}

.session-card .session-stat-field span {
  display: block !important;
  margin: 0 0 6px !important;
  overflow: hidden;
  color: var(--muted) !important;
  font-size: clamp(9px, 2.4vw, 11px) !important;
  font-weight: 500 !important;
  line-height: 1.15 !important;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-card .session-stat-field strong {
  display: block !important;
  overflow: hidden;
  margin: 0 !important;
  color: var(--ink);
  font-size: clamp(13px, 3.7vw, 15px) !important;
  font-weight: 700 !important;
  line-height: 1.15 !important;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-card .session-other-cost-field {
  grid-column: 1 / -1;
}

.session-card .session-other-cost-field input {
  min-height: 44px;
  height: 44px;
}

@media (max-width: 640px) {
  .session-card .session-edit-grid {
    gap: 8px 10px !important;
    margin: 8px 0 10px !important;
  }

  .session-card .session-stat-field {
    min-height: 60px !important;
    padding: 9px 10px !important;
  }
}

.session-card .session-mini-grid {
  margin-top: 10px;
}

.session-card .session-cost-edit {
  display: block !important;
  margin: 10px 0 0 !important;
}

.session-card .session-cost-edit .session-other-cost-field {
  display: block !important;
  grid-column: auto !important;
  margin: 0 !important;
}

.session-card .session-cost-edit .session-other-cost-field input {
  width: 100%;
  min-height: 44px;
  height: 44px;
}

@media (max-width: 640px) {
  .session-card .session-mini-grid {
    margin-top: 8px;
  }

  .session-card .session-cost-edit {
    margin-top: 8px !important;
  }
}

/* Reliability pass: full-width app chrome, safer dates, delete affordance, and save animation */
html,
body {
  background: #fff;
}

.app-shell {
  background: #f8f9f4;
}

.topbar {
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  transform: none !important;
  padding-left: max(14px, calc((100vw - 1180px) / 2 + 14px), env(safe-area-inset-left)) !important;
  padding-right: max(14px, calc((100vw - 1180px) / 2 + 14px), env(safe-area-inset-right)) !important;
}

input,
select,
button {
  min-width: 0;
}

.scan-button span {
  transform: none !important;
}

#orderEntryForm > .form-actions {
  grid-template-columns: 1fr !important;
}

#saveOrderBtn {
  width: 100%;
}

.danger-ghost {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid rgba(187, 64, 68, 0.26);
  border-radius: 8px;
  background: #fff;
  color: var(--danger);
  font-weight: 760;
}

.danger-ghost:active {
  transform: translateY(1px);
}

.order-edit-modal {
  overflow-x: hidden;
}

.order-edit-modal label,
.order-edit-modal input,
.order-edit-modal select {
  width: 100%;
  max-width: 100%;
}

.order-edit-modal .inline-edit-grid {
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.72fr) minmax(0, 0.95fr);
}

.order-edit-modal input[type="date"] {
  box-sizing: border-box;
  min-width: 0;
  padding-right: 38px;
  font-size: 13px;
}

.order-edit-modal input[type="date"]::-webkit-calendar-picker-indicator {
  width: 34px;
  margin-right: -8px;
}

.order-flyer {
  position: fixed;
  z-index: 1400;
  width: 54px;
  height: 36px;
  margin: -18px 0 0 -27px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 780;
  pointer-events: none;
  box-shadow: 0 12px 30px rgba(90, 105, 0, 0.24);
  transition: transform 680ms cubic-bezier(0.2, 0.9, 0.22, 1), opacity 680ms ease;
}

@media (max-width: 640px) {
  .topbar {
    padding-left: max(12px, env(safe-area-inset-left)) !important;
    padding-right: max(12px, env(safe-area-inset-right)) !important;
  }

  .app-shell {
    padding-top: calc(64px + env(safe-area-inset-top));
  }

  .order-edit-modal .inline-edit-grid {
    grid-template-columns: 1fr !important;
  }

  .order-edit-modal input[type="date"] {
    font-size: 16px;
  }

  .order-edit-modal .form-actions {
    grid-template-columns: 1fr 1fr;
  }
}

/* Mobile repair pass: scanner button centering, iOS date containment, shorter pickers */
.scan-button,
.scan-button * {
  box-sizing: border-box;
}

.scan-button {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 1 !important;
  overflow: hidden;
}

.scan-button svg {
  flex: 0 0 auto;
  transform: none !important;
}

.scan-button span {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  height: 100% !important;
  line-height: 1 !important;
  transform: none !important;
  position: static !important;
  margin: 0 !important;
  padding: 0 !important;
}

input[type="date"] {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

label:has(input[type="date"]) {
  min-width: 0;
  overflow: hidden;
}

.picker-modal {
  overflow: hidden;
}

@media (max-width: 640px) {
  .input-action .scan-button {
    height: 48px !important;
    min-height: 48px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    font-size: 18px !important;
  }

  .input-action .scan-button span {
    height: 48px !important;
  }

  #entryOrderDate,
  #modalOrderDate {
    height: 52px;
    min-height: 52px;
    padding: 0 40px 0 14px !important;
    font-size: 16px;
    text-align: center;
  }

  input[type="date"]::-webkit-date-and-time-value {
    text-align: center;
  }

  .picker-modal {
    width: min(430px, calc(100vw - 28px)) !important;
    max-height: min(72vh, 560px) !important;
    padding: 8px !important;
    grid-template-rows: auto auto minmax(0, 1fr) auto !important;
    border-radius: 18px !important;
  }

  .picker-modal .section-head {
    margin-bottom: 6px;
  }

  .picker-modal .section-head h2 {
    font-size: 20px;
  }

  .picker-modal .section-head p {
    font-size: 12px;
  }

  #pickerSearch {
    min-height: 40px;
    height: 40px;
    padding: 0 12px;
    font-size: 14px;
  }

  .picker-list {
    gap: 5px;
    min-height: 0;
    padding: 2px 2px 6px 0;
    overflow: auto;
  }

  .picker-row {
    min-height: 50px;
    grid-template-columns: 38px minmax(0, 1fr) auto !important;
    gap: 7px !important;
    padding: 5px 6px !important;
    border-radius: 9px;
  }

  .picker-row .product-thumb,
  .picker-row .product-thumb.empty,
  .picker-row .image-edit,
  .picker-row .image-edit button {
    width: 36px !important;
    height: 36px !important;
  }

  .picker-row strong {
    font-size: 13px !important;
    line-height: 1.12 !important;
  }

  .picker-row .muted {
    font-size: 11px !important;
    line-height: 1.1 !important;
  }

  .picker-row .qty-stepper {
    grid-template-columns: 28px 34px 28px !important;
    gap: 4px !important;
  }

  .picker-row .qty-stepper button,
  .picker-row .qty-stepper input {
    height: 30px !important;
    min-height: 30px !important;
  }

  #confirmPickerBtn {
    height: 46px;
    min-height: 46px;
    margin-top: 4px;
  }

  .order-edit-modal {
    width: min(430px, calc(100vw - 28px)) !important;
    max-height: min(76vh, 570px) !important;
    padding: 10px !important;
  }

  .order-edit-modal .inline-edit-grid,
  .order-edit-modal .inline-product-edit {
    gap: 7px !important;
  }
}

/* Mobile final fix: keep core controls inside the card and keep pickers usable in phone browsers */
@media (max-width: 640px) {
  #orderEntryForm,
  #orderEntryForm * {
    max-width: 100%;
  }

  #orderEntryForm .grid2,
  .order-edit-modal .inline-edit-grid {
    overflow: hidden;
  }

  #orderEntryForm label,
  .order-edit-modal label {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
  }

  #entryOrderDate,
  #modalOrderDate {
    inline-size: 100% !important;
    max-inline-size: 100% !important;
    min-inline-size: 0 !important;
    border-inline-end-width: 1px;
    -webkit-text-size-adjust: 100%;
  }

  #entryOrderDate::-webkit-date-and-time-value,
  #modalOrderDate::-webkit-date-and-time-value {
    display: block;
    width: 100%;
    min-width: 0;
    margin: 0;
    text-align: center;
  }

  #entryOrderDate::-webkit-calendar-picker-indicator,
  #modalOrderDate::-webkit-calendar-picker-indicator {
    position: absolute;
    right: 12px;
    width: 22px;
    height: 22px;
    margin: 0;
  }

  .input-action .scan-button {
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 14px !important;
    gap: 10px !important;
    line-height: 44px !important;
  }

  .input-action .scan-button svg {
    width: 18px !important;
    height: 18px !important;
  }

  .input-action .scan-button span {
    height: auto !important;
    min-height: 0 !important;
    line-height: 1 !important;
    transform: translateY(1px) !important;
  }

  .modal {
    align-items: center !important;
    justify-items: center !important;
    padding: max(8px, env(safe-area-inset-top)) 8px max(72px, env(safe-area-inset-bottom)) !important;
  }

  .picker-modal {
    width: min(420px, calc(100vw - 18px)) !important;
    max-height: min(66svh, 500px) !important;
    max-height: min(66vh, 500px) !important;
    padding: 8px !important;
    grid-template-rows: auto auto minmax(0, 1fr) auto !important;
    overflow: hidden !important;
  }

  .picker-modal .section-head {
    align-items: start;
    margin-bottom: 4px !important;
  }

  .picker-modal .section-head h2 {
    font-size: 18px !important;
    line-height: 1.1 !important;
  }

  .picker-modal .section-head p {
    margin-top: 2px !important;
    font-size: 11px !important;
    line-height: 1.2 !important;
  }

  .picker-modal .icon-close {
    width: 28px !important;
    height: 28px !important;
    min-height: 28px !important;
  }

  #pickerSearch {
    height: 38px !important;
    min-height: 38px !important;
    margin-bottom: 6px !important;
  }

  .picker-list {
    align-content: start;
    gap: 4px !important;
    min-height: 0 !important;
    padding-bottom: 4px !important;
    overflow-y: auto !important;
  }

  .picker-row {
    min-height: 44px !important;
    grid-template-columns: 34px minmax(0, 1fr) auto !important;
    gap: 6px !important;
    padding: 4px 5px !important;
  }

  .picker-row .product-thumb,
  .picker-row .product-thumb.empty,
  .picker-row .image-edit,
  .picker-row .image-edit button {
    width: 32px !important;
    height: 32px !important;
  }

  .picker-row strong {
    font-size: 12px !important;
    line-height: 1.14 !important;
  }

  .picker-row .muted {
    margin-top: 1px !important;
    font-size: 10px !important;
    line-height: 1.05 !important;
  }

  .picker-row .qty-stepper {
    grid-template-columns: 26px 32px 26px !important;
    gap: 3px !important;
  }

  .picker-row .qty-stepper button,
  .picker-row .qty-stepper input {
    height: 28px !important;
    min-height: 28px !important;
    border-radius: 7px !important;
    font-size: 13px !important;
  }

  #confirmPickerBtn {
    position: sticky;
    bottom: 0;
    height: 42px !important;
    min-height: 42px !important;
    margin-top: 6px !important;
    font-size: 16px !important;
  }

  .order-edit-modal {
    width: min(420px, calc(100vw - 18px)) !important;
    max-height: min(70svh, 520px) !important;
    max-height: min(70vh, 520px) !important;
    padding: 9px !important;
    overflow-y: auto !important;
  }

  .order-edit-modal .section-head h2 {
    font-size: 18px !important;
  }

  .order-edit-modal .section-head p {
    font-size: 11px !important;
  }

  .order-edit-modal .inline-product-edit {
    grid-template-columns: 1fr !important;
  }

  .order-edit-modal .form-actions {
    position: sticky;
    bottom: -9px;
    margin: 8px -2px 0;
    padding-top: 7px;
    background: #fff;
  }
}

/* Mobile modal balance pass: readable rows, aligned controls, no cramped edit sheet */
@media (max-width: 640px) {
  #saveOrderBtn,
  #confirmPickerBtn,
  .picker-card .primary,
  .order-edit-modal .primary,
  .order-edit-modal .danger-ghost {
    font-size: 17px !important;
    font-weight: 850 !important;
    line-height: 1 !important;
  }

  #saveOrderBtn {
    min-height: 44px !important;
  }

  #entryOrderDate,
  #modalOrderDate {
    height: 44px !important;
    min-height: 44px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    line-height: 44px !important;
  }

  .picker-modal {
    max-height: min(66vh, 500px) !important;
    max-height: min(66svh, 500px) !important;
  }

  .picker-row {
    min-height: 54px !important;
    grid-template-columns: 42px minmax(0, 1fr) auto !important;
    gap: 8px !important;
    padding: 6px 7px !important;
  }

  .picker-row .product-thumb,
  .picker-row .product-thumb.empty,
  .picker-row .image-edit,
  .picker-row .image-edit button {
    width: 40px !important;
    height: 40px !important;
  }

  .picker-row strong {
    font-size: 14px !important;
    font-weight: 760 !important;
    line-height: 1.18 !important;
  }

  .picker-row .muted {
    font-size: 12px !important;
    line-height: 1.15 !important;
  }

  .picker-row .qty-stepper {
    grid-template-columns: 31px 36px 31px !important;
    gap: 4px !important;
  }

  .picker-row .qty-stepper button,
  .picker-row .qty-stepper input {
    height: 32px !important;
    min-height: 32px !important;
    font-size: 14px !important;
  }

  .order-edit-modal {
    display: grid !important;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    width: min(430px, calc(100vw - 18px)) !important;
    max-height: min(80vh, 650px) !important;
    max-height: min(80svh, 650px) !important;
    padding: 12px !important;
    overflow: hidden !important;
  }

  .order-edit-modal .section-head {
    margin-bottom: 8px !important;
  }

  .order-edit-modal .inline-edit-grid {
    gap: 8px !important;
  }

  .order-edit-modal .inline-edit-grid label span {
    margin-bottom: 4px;
  }

  .order-edit-modal .inline-product-edit {
    min-height: 0;
    overflow-y: auto;
    gap: 8px !important;
    padding-right: 2px;
  }

  .order-edit-modal .inline-product-edit > div {
    padding: 9px !important;
  }

  .order-edit-modal .inline-product-edit p {
    margin: 4px 0 8px !important;
    font-size: 12px !important;
    line-height: 1.35 !important;
  }

  .order-edit-modal .inline-product-edit .primary {
    min-height: 40px !important;
  }

  .order-edit-modal .form-actions {
    position: static !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
    margin: 10px 0 0 !important;
    padding: 0 !important;
    background: #fff;
  }

  .order-edit-modal .form-actions button {
    min-height: 44px !important;
  }
}
