:root {
  --ui-brand: #ec5728;
  --ui-brand-strong: #cf4219;
  --ui-brand-soft: #fdf0eb;
  --ui-brand-border: #f3b39d;
  --ui-bg: #f7f7f5;
  --ui-surface: #ffffff;
  --ui-text: #172033;
  --ui-muted: #6b7280;
  --ui-border: #e7e8eb;
  --ui-blue: #2563eb;
  --ui-blue-soft: #eff6ff;
  --ui-green: #168447;
  --ui-green-soft: #edf9f1;
  --ui-red: #dc2626;
  --ui-red-soft: #fff1f2;
  --ui-warning: #d97706;
  --ui-warning-soft: #fff8eb;
  --ui-space-1: 4px;
  --ui-space-2: 8px;
  --ui-space-3: 12px;
  --ui-space-4: 16px;
  --ui-space-6: 24px;
  --ui-space-8: 32px;
  --ui-radius-sm: 10px;
  --ui-radius: 16px;
  --ui-radius-lg: 18px;
  --ui-shadow: 0 5px 18px rgba(23, 32, 51, 0.06);
  --ui-font-sm: 12px;
  --ui-font-body: 14px;
  --ui-font-title: 16px;
  --ui-safe-bottom: env(safe-area-inset-bottom, 0px);
  --ui-nav-height: 70px;
}

#appPage,
#appPage button,
#appPage input,
#appPage select {
  font-family: Arial, "Noto Sans Thai", sans-serif;
}

#appPage.wrap {
  position: relative;
  isolation: isolate;
  display: block;
  width: min(100%, 1180px);
  max-width: 1180px;
  min-height: 100vh;
  padding: var(--ui-space-3) var(--ui-space-3) calc(var(--ui-nav-height) + var(--ui-safe-bottom) + var(--ui-space-6));
  color: var(--ui-text);
}

#appPage.wrap::before {
  content: "";
  position: fixed;
  z-index: -1;
  inset: 0;
  background: var(--ui-bg);
}

#appPage .head {
  position: relative;
  min-height: 92px;
  margin-bottom: var(--ui-space-3);
  padding: 14px 116px 12px 16px;
  overflow: hidden;
  border-radius: var(--ui-radius);
  background: var(--ui-brand);
  box-shadow: 0 7px 18px rgba(207, 66, 25, 0.16);
}

#appPage .head h1 {
  max-width: 680px;
  font-size: 19px;
  line-height: 1.25;
  font-weight: 800;
}

#appPage .welcome-text {
  margin-top: 3px;
  font-size: 13px;
  line-height: 1.35;
  font-weight: 700;
}

#appPage .updated {
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.25;
  opacity: 0.9;
}

#appPage .head br {
  display: none;
}

#appPage .refresh-btn,
#appPage .logout {
  position: absolute;
  top: 12px;
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  margin: 0;
  padding: 5px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 9px;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
}

#appPage .refresh-btn {
  right: 62px;
  width: 48px;
}

#appPage .logout {
  right: 10px;
  width: 46px;
  cursor: pointer;
}

#appPage .tabs {
  position: fixed;
  z-index: 100;
  top: auto;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
  width: min(100%, 1180px);
  min-height: calc(var(--ui-nav-height) + var(--ui-safe-bottom));
  grid-column: auto;
  grid-row: auto;
  margin: 0 auto;
  padding: 7px max(5px, env(safe-area-inset-right)) calc(6px + var(--ui-safe-bottom)) max(5px, env(safe-area-inset-left));
  border: 1px solid var(--ui-border);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 -8px 28px rgba(23, 32, 51, 0.09);
}

#appPage .tab {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 52px;
  padding: 4px 3px;
  border-radius: 12px;
  background: transparent;
  color: #4b5563;
  font-size: 10px;
  line-height: 1.22;
  font-weight: 700;
  text-align: center;
  overflow-wrap: anywhere;
}

#appPage .tab.active {
  background: var(--ui-brand-soft);
  color: var(--ui-brand-strong);
  box-shadow: inset 0 0 0 1px rgba(236, 87, 40, 0.13);
}

#appPage .search-box,
#appPage .input-field,
#appPage .select-field,
#appPage .receiving-input,
#appPage .screen-detail-search,
#appPage .production-status-select {
  min-height: 46px;
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  background: var(--ui-surface);
  color: var(--ui-text);
  box-shadow: 0 1px 2px rgba(23, 32, 51, 0.02);
}

#appPage .search-box {
  width: 100%;
  max-width: none;
  margin: 0 0 var(--ui-space-3);
  padding: 11px 14px;
  font-size: 14px;
}

#appPage :is(input, select, button):focus-visible,
#appPage .logout:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.25);
  outline-offset: 2px;
}

#appPage :is(input, select, button):disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

#appPage .cards {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--ui-space-2);
  margin-bottom: var(--ui-space-3);
}

#appPage .card {
  min-width: 0;
  min-height: 82px;
  padding: 11px 12px;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  background: var(--ui-surface);
  color: var(--ui-text);
  box-shadow: var(--ui-shadow);
  font-size: 12px;
  line-height: 1.25;
}

#appPage .card.dark,
#appPage .card.blue {
  border-color: #cfe0ff;
  background: var(--ui-blue-soft);
  color: #174ea6;
}

#appPage .card.red {
  border-color: #fecdd3;
  background: var(--ui-red-soft);
  color: var(--ui-red);
}

#appPage .card.orange {
  border-color: #fed7aa;
  background: var(--ui-warning-soft);
  color: var(--ui-warning);
}

#appPage .card.green {
  border-color: #bbf0cd;
  background: var(--ui-green-soft);
  color: var(--ui-green);
}

#appPage .num {
  margin-top: 6px;
  font-size: 26px;
  line-height: 1;
  font-weight: 800;
}

#appPage .unit {
  margin-top: 3px;
  font-size: 10px;
}

#appPage .filter-title {
  margin: 0 0 var(--ui-space-2);
  color: var(--ui-muted);
  font-size: 12px;
  font-weight: 700;
}

#appPage .subtabs,
#appPage .print-status-tabs {
  gap: var(--ui-space-2);
  margin: 0 0 var(--ui-space-3);
}

#appPage .subtab,
#appPage .print-status-tab {
  min-height: 44px;
  padding: 8px;
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  background: var(--ui-surface);
  color: #4b5563;
  font-size: 12px;
}

#appPage .subtab.active,
#appPage .print-status-tab.active {
  border-color: var(--ui-brand);
  background: var(--ui-brand);
  color: #fff;
}

#appPage .item,
#appPage .receiving-card,
#appPage .form-box,
#appPage .chart-box,
#appPage .week-chart,
#appPage .cup-chart,
#appPage .production-order-card,
#appPage .screen-detail-card,
#appPage .receiving-state {
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow);
}

#appPage .item {
  margin-bottom: 8px;
  padding: 11px 12px;
  font-size: 13px;
  line-height: 1.4;
}

#appPage .item.danger,
#appPage .production-order-card.danger {
  border-color: #fecaca;
  border-left: 4px solid var(--ui-red);
  background: var(--ui-surface);
}

#appPage .stock-code {
  color: var(--ui-text);
  font-size: 14px;
}

#appPage .balance-line {
  color: var(--ui-green);
  font-size: 15px;
}

#appPage .balance-line.danger-balance,
#appPage .due-line,
#appPage .job-due-alert {
  color: var(--ui-red);
}

#appPage .section-title {
  margin: var(--ui-space-4) 0 var(--ui-space-2);
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ui-text);
  font-size: var(--ui-font-title);
  line-height: 1.35;
}

#appPage .overview-grid {
  gap: var(--ui-space-2);
  margin-bottom: var(--ui-space-3);
}

#appPage .overview-card {
  min-width: 0;
  padding: 14px;
  border: 0;
  border-radius: var(--ui-radius);
  box-shadow: var(--ui-shadow);
}

#appPage .overview-card:first-child {
  background: #285d9f;
  border-color: #285d9f;
}

#appPage .overview-card:nth-child(2) {
  background: #19703b;
  border-color: #19703b;
}

#appPage .overview-label {
  margin-bottom: 7px;
  font-size: 13px;
  line-height: 1.35;
}

#appPage .overview-number {
  font-size: 34px;
}

#appPage .overview-sub {
  margin-top: 4px;
  font-size: 10px;
}

#appPage .week-chart,
#appPage .cup-chart,
#appPage .chart-box,
#appPage .form-box {
  padding: 14px;
  margin-bottom: var(--ui-space-3);
}

#appPage .week-chart .section-title,
#appPage .cup-chart .section-title {
  background: transparent;
  color: var(--ui-text);
}

#appPage .week-bars {
  min-height: 152px;
  gap: 5px;
  padding: 12px 0 7px;
}

#appPage .week-bar-track {
  height: 88px;
  max-width: 28px;
  border-radius: 8px 8px 3px 3px;
  background: #f2f3f5;
}

#appPage .week-bar-fill {
  background: var(--ui-brand);
}

#appPage .week-bar-value,
#appPage .week-bar-date {
  font-size: 11px;
}

#appPage .week-bar-day {
  font-size: 10px;
}

#appPage .cup-usage-grid {
  gap: var(--ui-space-3);
}

#appPage .cup-rank-list {
  max-height: 310px;
}

#appPage .cup-rank-row {
  min-height: 45px;
  padding: 7px 5px;
  border-color: var(--ui-border);
}

#appPage .cup-rank-no {
  background: var(--ui-brand-soft);
  color: var(--ui-brand-strong);
}

#appPage .cup-rank-qty {
  color: var(--ui-brand-strong);
}

#appPage .receiving-toolbar {
  align-items: center;
  margin-bottom: var(--ui-space-2);
}

#appPage .receiving-filter {
  min-width: 144px;
}

#appPage .receiving-card {
  margin-bottom: 8px;
  padding: 11px 12px;
}

#appPage .receiving-code {
  color: #111;
  font-size: 18px;
  font-weight: 700;
}

#appPage .receiving-status,
#appPage .production-overall-status,
#appPage .print-badge,
#appPage .job-status {
  border-radius: 999px;
  font-weight: 800;
}

#appPage .receiving-name {
  color: #111;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
}

#appPage .receiving-context,
#appPage .receiving-context-line {
  color: #333;
  font-size: 14.5px;
  font-weight: 500;
  line-height: 1.35;
}

#appPage .receiving-metric {
  font-size: 13.5px;
  font-weight: 500;
}

#appPage .receiving-metrics {
  padding: 8px;
  border-radius: 11px;
  background: #f8fafc;
}

#appPage .receiving-metric b {
  color: #111;
  font-size: 18px;
  font-weight: 700;
}

#appPage .receiving-action {
  grid-template-columns: auto minmax(92px, 1fr) minmax(70px, auto);
}

#appPage .receiving-save,
#appPage .production-status-save,
#appPage .save-btn,
#appPage .print-btn {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--ui-green);
  color: #fff;
  font-weight: 800;
}

#appPage .receiving-message.success,
#appPage .production-status-message.success,
#appPage .save-message.success {
  color: var(--ui-green);
}

#appPage .receiving-message.error,
#appPage .production-status-message.error,
#appPage .save-message.error {
  color: var(--ui-red);
}

#appPage .print-toolbar {
  gap: var(--ui-space-2);
  margin-bottom: var(--ui-space-3);
  padding: 10px;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow);
}

#appPage .production-status-filters {
  flex: 1 0 100%;
  width: 100%;
  padding-top: 10px;
  border-top: 1px solid var(--ui-border);
}

#appPage .production-status-filter-title {
  margin-bottom: 8px;
  color: #374151;
  font-size: 15px;
  line-height: 1.35;
  font-weight: 700;
}

#appPage .production-status-filter-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#appPage .print-toolbar .production-status-filter {
  display: flex;
  flex: 1 1 150px;
  align-items: center;
  min-width: 0;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  background: var(--ui-surface);
  color: #374151;
  font-size: 15px;
  line-height: 1.3;
  font-weight: 600;
  cursor: pointer;
}

#appPage .print-toolbar .production-status-filter:has(input:checked) {
  border-color: var(--ui-brand);
  background: var(--ui-brand-soft);
  color: var(--ui-brand-strong);
}

#appPage .print-toolbar .production-status-filter:focus-within {
  outline: 3px solid rgba(236, 87, 40, 0.24);
  outline-offset: 2px;
}

#appPage .print-toolbar .production-status-filter input {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--ui-brand);
}

#appPage .production-status-filter span {
  min-width: 0;
  overflow-wrap: anywhere;
}

#appPage .print-check {
  width: 24px;
  height: 24px;
  accent-color: var(--ui-brand);
}

#appPage .print-btn {
  background: var(--ui-brand);
}

#appPage .production-order-card {
  padding: 12px;
  color: #1f2937;
}

#appPage .production-customer-name {
  color: #1f2937;
  font-size: 18px;
  font-weight: 700;
}

#appPage .production-block-code {
  color: #374151;
  font-size: 15px;
  font-weight: 600;
}

#appPage .production-card-divider {
  border-color: var(--ui-border);
}

#appPage .production-meta-grid {
  gap: 7px 12px;
  color: #374151;
  font-size: 15px;
}

#appPage .production-meta-label {
  color: #4b5563;
  font-size: 14px;
  line-height: 1.35;
}

#appPage .production-product-summary {
  color: #374151;
  font-size: 15px;
}

#appPage .production-status-panel {
  overflow: visible;
  padding: 8px;
  border-color: var(--ui-border);
  background: #f8fafc;
}

#appPage .production-status-table,
#appPage .production-status-table tbody {
  display: block;
  width: 100%;
}

#appPage .production-status-table thead {
  display: none;
}

#appPage .production-status-table tbody {
  display: grid;
  gap: 8px;
}

#appPage .production-status-table tr {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px 10px;
  padding: 10px;
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  background: var(--ui-surface);
}

#appPage .production-status-table td {
  display: block;
  min-width: 0;
  padding: 0;
  border: 0;
  color: #374151;
  font-size: 16px;
}

#appPage .production-status-table td:nth-child(1) {
  grid-column: span 4;
}

#appPage .production-status-table td:nth-child(2) {
  grid-column: span 2;
  color: #1f2937;
  font-size: 17px;
  font-weight: 600;
}

#appPage .production-status-table td:nth-child(n + 3) {
  grid-column: span 2;
  padding-top: 9px;
  border-top: 1px solid var(--ui-border);
}

#appPage .production-status-table td::before {
  content: attr(data-label);
  display: block;
  margin-bottom: 5px;
  color: #4b5563;
  font-size: 15px;
  line-height: 1.3;
  font-weight: 600;
}

#appPage .production-status-table td:nth-child(1)::before,
#appPage .production-status-table td:nth-child(2)::before {
  margin-bottom: 2px;
}

#appPage .production-status-control {
  grid-template-columns: minmax(0, 1fr) minmax(82px, auto);
  gap: 6px 8px;
  align-items: start;
}
/* CEO 06/09/2026: ป้ายสถานะสกรีนต้องอยู่บรรทัดเดียว — ช่วง 601–655px คอลัมน์ต้องหดได้ ไม่งั้นป้ายถูกตัด */
#appPage .production-status-readonly-control{ grid-template-columns:minmax(0,1fr); }

#appPage .production-status-select {
  width: 100%;
  min-height: 44px;
  min-width: 0;
  color: #1f2937;
  font-size: 16px;
  font-weight: 600;
}

#appPage .production-status-save {
  min-width: 82px;
  min-height: 44px;
  padding-right: 10px;
  padding-left: 10px;
  font-size: 16px;
  font-weight: 600;
}

#appPage .production-status-save:disabled {
  background: #e5e7eb;
  color: #4b5563;
  opacity: 1;
  cursor: not-allowed;
}

#appPage .production-status-message {
  min-height: 0;
  margin-top: 0;
  color: #4b5563;
  font-size: 14px;
}

#appPage .production-screen-done-date {
  margin-top: 5px;
  color: #4b5563;
  font-size: 14px;
  opacity: 1;
}

#appPage .production-empty-cell {
  color: #4b5563;
  font-size: 15px;
}

#appPage .production-product-name {
  color: #1f2937;
  font-size: 18px;
  font-weight: 700;
}

#appPage .production-status-select.status-waiting {
  border-color: #fed7aa;
  background: var(--ui-warning-soft);
  color: var(--ui-warning);
}

#appPage .production-status-select.status-done {
  border-color: #bbf0cd;
  background: var(--ui-green-soft);
  color: var(--ui-green);
}

#appPage .form-grid {
  gap: var(--ui-space-3);
}

#appPage .form-label {
  color: #374151;
  font-size: 12px;
}

#appPage .screen-item-row {
  border-color: var(--ui-border);
  border-radius: 14px;
  background: #fafafa;
}

#appPage .add-btn {
  min-height: 46px;
  border: 1px dashed var(--ui-brand-border);
  border-radius: 12px;
  background: #fff;
  color: var(--ui-brand-strong);
}

#appPage .save-btn {
  position: sticky;
  z-index: 70;
  bottom: calc(var(--ui-nav-height) + var(--ui-safe-bottom) + 8px);
  min-height: 50px;
  background: var(--ui-brand);
  box-shadow: 0 8px 22px rgba(207, 66, 25, 0.22);
}

#appPage .remove-btn {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid #fecaca;
  background: var(--ui-red-soft);
  color: var(--ui-red);
}

#appPage .screen-summary-cards {
  gap: var(--ui-space-2);
}

#appPage .screen-summary-card {
  min-height: 88px;
  border: 1px solid #cfe0ff;
  border-radius: var(--ui-radius);
  background: var(--ui-blue-soft);
  color: #174ea6;
}

#appPage .screen-summary-card.active {
  border-color: var(--ui-brand);
  background: var(--ui-brand-soft);
  color: var(--ui-brand-strong);
}

#appPage .screen-detail-card {
  padding: 11px 12px;
}

#appPage .screen-detail-customer {
  color: var(--ui-text);
}

#appPage .screen-detail-qty {
  color: var(--ui-green);
}

#appPage .receiving-state,
#appPage .item:only-child {
  color: var(--ui-muted);
}

@media (max-width: 768px) {
  #appPage.wrap {
    padding-top: 8px;
    padding-right: 8px;
    padding-left: 8px;
  }

  #appPage .head {
    margin-bottom: 8px;
  }

  #appPage .search-box {
    position: sticky;
    z-index: 60;
    top: 0;
    margin-bottom: 8px;
    box-shadow: 0 5px 14px rgba(23, 32, 51, 0.08);
  }

  #appPage .tabs {
    border-radius: 16px 16px 0 0;
  }

  #appPage .tab {
    font-size: clamp(8px, 2.45vw, 10px);
  }

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

  #appPage .cup-usage-grid {
    grid-template-columns: 1fr;
  }

  #appPage .cup-rank-list {
    max-height: none;
  }

  #appPage .screen-row-head {
    display: none;
  }

  #appPage .screen-item-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px;
    gap: 8px;
    padding: 10px;
  }

  #appPage .screen-item-row > :nth-child(1),
  #appPage .screen-item-row > :nth-child(2),
  #appPage .screen-item-row > :nth-child(3),
  #appPage .screen-item-row > :nth-child(4),
  #appPage .screen-item-row > :nth-child(5) {
    grid-column: span 1;
    min-width: 0;
  }

  #appPage .screen-item-row > :nth-child(6) {
    grid-column: 1 / 3;
  }

  #appPage .screen-item-row > :nth-child(7) {
    grid-column: 3;
  }

  #appPage .screen-filter-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 430px) {
  :root {
    --ui-nav-height: 68px;
  }

  #appPage .head {
    min-height: 88px;
    padding: 12px 108px 10px 13px;
  }

  #appPage .head h1 {
    font-size: 16px;
  }

  #appPage .welcome-text {
    font-size: 11px;
  }

  #appPage .updated {
    font-size: 9px;
  }

  #appPage .refresh-btn {
    right: 57px;
    width: 45px;
  }

  #appPage .logout {
    right: 8px;
    width: 43px;
  }

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

  #appPage .overview-card {
    padding: 12px;
  }

  #appPage .overview-label {
    font-size: 11px;
  }

  #appPage .overview-number {
    font-size: 30px;
  }

  #appPage .card {
    padding: 10px 8px;
    font-size: 10px;
  }

  #appPage .num {
    font-size: 24px;
  }

  #appPage .week-chart,
  #appPage .cup-chart,
  #appPage .chart-box,
  #appPage .form-box {
    padding: 12px;
  }

  #appPage .receiving-action {
    grid-template-columns: auto minmax(74px, 1fr) minmax(64px, auto);
    gap: 6px;
  }

  #appPage .receiving-input,
  #appPage .receiving-save {
    min-width: 0;
    padding-right: 8px;
    padding-left: 8px;
  }

  #appPage .production-meta-grid {
    grid-template-columns: 1fr 1fr;
  }

  #appPage .print-toolbar {
    grid-template-columns: 1fr;
  }

  #appPage .screen-filter-grid {
    grid-template-columns: 1fr;
  }

  #appPage .screen-item-row {
    grid-template-columns: minmax(0, 1fr) 44px;
  }

  #appPage .screen-item-row > :nth-child(1),
  #appPage .screen-item-row > :nth-child(2),
  #appPage .screen-item-row > :nth-child(3),
  #appPage .screen-item-row > :nth-child(4),
  #appPage .screen-item-row > :nth-child(5),
  #appPage .screen-item-row > :nth-child(6) {
    grid-column: 1;
  }

  #appPage .screen-item-row > :nth-child(7) {
    grid-column: 2;
    grid-row: 6;
  }
}

@media (max-width: 600px) {
  #appPage .production-status-panel {
    padding: 8px;
  }

  #appPage .production-status-table tr {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    padding: 9px;
    border-radius: 12px;
    background: #fff;
  }

  #appPage .production-status-table td {
    min-width: 0;
    padding: 0;
  }

  #appPage .production-status-table td:nth-child(1),
  #appPage .production-status-table td:nth-child(2) {
    grid-column: auto;
  }

  #appPage .production-status-table td:nth-child(n + 3) {
    grid-column: 1 / -1;
    padding-top: 10px;
  }

  #appPage .production-status-select,
  #appPage .production-status-save {
    width: 100%;
    max-width: 100%;
    min-height: 48px;
  }
}

@media (max-width: 360px) {
  #appPage .tabs {
    gap: 0;
    padding-right: 2px;
    padding-left: 2px;
  }
}

@media (min-width: 769px) {
  #appPage .head {
    padding-right: 150px;
  }

  #appPage .tab {
    font-size: 12px;
  }

  #appPage .cup-usage-grid {
    grid-template-columns: 1fr 1fr;
  }

  #appPage .receiving-page {
    max-width: 920px;
  }
}

@media print {
  #appPage .tabs,
  #appPage .save-btn {
    position: static;
  }
}


/* Other stock: inventory / withdrawal */
#appPage .other-stock-mode-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
  padding: 4px;
  border: 1px solid var(--ui-border);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--ui-shadow);
}

#appPage .other-stock-mode-tab {
  min-height: 46px;
  padding: 9px 12px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: #374151;
  font-size: 14px;
  line-height: 1.3;
  font-weight: 700;
  cursor: pointer;
}

#appPage .other-stock-mode-tab.active {
  background: var(--ui-brand);
  color: #fff;
}

#appPage .other-stock-withdrawal-title {
  margin-top: 0;
  font-size: 18px;
}

#appPage .other-stock-withdrawal-grid {
  display: grid;
  grid-template-columns: minmax(150px, .7fr) minmax(220px, 1.5fr) minmax(120px, .65fr) minmax(170px, 1fr);
  gap: 12px;
}

#appPage .other-stock-withdrawal-grid label {
  display: block;
  min-width: 0;
}

#appPage .other-stock-note-field {
  grid-column: 1 / -1;
}

#appPage .other-stock-note {
  min-height: 72px;
  resize: vertical;
  font-family: Arial, "Noto Sans Thai", sans-serif;
  line-height: 1.4;
}

#appPage .other-stock-withdrawal-balance {
  min-height: 21px;
  margin-top: 10px;
  color: var(--ui-green);
  font-size: 14px;
  line-height: 1.4;
  font-weight: 700;
}

#appPage .other-stock-withdrawal-balance.danger {
  color: var(--ui-red);
}

#appPage .other-stock-withdrawal-save {
  position: static;
  min-height: 50px;
  margin-top: 8px;
}

#appPage .other-stock-withdrawal-card {
  margin-bottom: 8px;
  padding: 12px 14px;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow);
}

#appPage .other-stock-withdrawal-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  color: var(--ui-text);
  font-size: 16px;
  line-height: 1.35;
}

#appPage .other-stock-withdrawal-qty {
  flex: 0 0 auto;
  color: var(--ui-brand-strong);
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
}

#appPage .other-stock-withdrawal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin-top: 7px;
  color: #374151;
  font-size: 13px;
  line-height: 1.4;
}

#appPage .other-stock-withdrawal-note {
  margin-top: 6px;
  color: #4b5563;
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

@media (max-width: 768px) {
  #appPage .other-stock-withdrawal-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #appPage .other-stock-product-field,
  #appPage .other-stock-note-field {
    grid-column: 1 / -1;
  }
}

@media (max-width: 430px) {
  #appPage .other-stock-mode-tab {
    padding: 8px 6px;
    font-size: 13px;
  }

  #appPage .other-stock-withdrawal-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  #appPage .other-stock-product-field,
  #appPage .other-stock-note-field {
    grid-column: auto;
  }

  #appPage .other-stock-withdrawal-card-head {
    font-size: 15px;
  }

  #appPage .other-stock-withdrawal-meta {
    display: grid;
    gap: 3px;
  }
}
