﻿:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --bg-body: #f3f4f6;
  --bg-surface: #ffffff;
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --header-bg: #111827;
  --header-hover: #1f2937;
  --header-text: #9ca3af;
  --danger: #ef4444;
  --success: #10b981;
  --radius-sm: 6px;
  --radius-md: 12px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { 
  font-family: "Inter", "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "BIZ UDPGothic", Meiryo, sans-serif;
  background-color: var(--bg-body); 
  color: var(--text-main); 
  height: 100vh; 
  display: flex; 
  flex-direction: column; 
  overflow: hidden; 
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Layout --- */
.app-container { display: flex; flex-direction: column; width: 100%; height: 100%; }
.main-content { flex-grow: 1; display: flex; flex-direction: column; overflow: hidden; }
.app-container.auth-locked .global-header,
.app-container.auth-locked .topbar,
.app-container.auth-locked .panels {
  filter: blur(6px);
  pointer-events: none;
  user-select: none;
}

/* --- Global Header (Top Menu) --- */
.global-header { min-height: 68px; background: var(--header-bg); display: flex; align-items: center; gap: 20px; padding: 12px 24px; flex-shrink: 0; border-bottom: 1px solid rgba(255,255,255,0.08); }
.header-brand { display: flex; align-items: center; flex: 0 0 auto; }
.logo { color: white; font-size: 18px; font-weight: 700; letter-spacing: 0.05em; margin-right: 12px; }
.logo span { color: #60a5fa; }

.top-nav { display: flex; align-items: center; gap: 6px; flex: 1 1 auto; overflow-x: auto; padding: 0; }
.nav-item { background: transparent; border: none; padding: 10px 16px; border-radius: 12px; color: var(--header-text); font-weight: 700; cursor: pointer; transition: all 0.2s; font-size: 13px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.nav-item:hover { background: rgba(255,255,255,0.08); color: white; }
.nav-item.active { background: #ffffff; color: #0f172a; font-weight: 800; box-shadow: 0 8px 18px rgba(15, 23, 42, 0.24); }
.nav-divider { width: 1px; height: 20px; background: rgba(255,255,255,0.2); margin: 0 8px; }

.header-actions { display: flex; align-items: center; gap: 12px; color: white; font-size: 14px; flex: 0 0 auto; }
.auth-role-badge {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(96, 165, 250, 0.12);
  border: 1px solid rgba(96, 165, 250, 0.28);
  color: #dbeafe;
  font-size: 12px;
  font-weight: 700;
}
.profile-menu {
  position: relative;
}
.profile-trigger {
  min-width: 44px;
  height: 44px;
  padding: 0 14px 0 15px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.06);
  color: white;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}
.profile-name {
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}
.profile-icon {
  position: relative;
  width: 16px;
  height: 16px;
  display: inline-block;
}
.profile-icon::before,
.profile-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: currentColor;
}
.profile-icon::before {
  top: 0;
  width: 8px;
  height: 8px;
  border-radius: 999px;
}
.profile-icon::after {
  bottom: 0;
  width: 14px;
  height: 7px;
  border-radius: 999px 999px 6px 6px;
}
.profile-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 160px;
  padding: 8px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
  display: grid;
  gap: 6px;
  z-index: 3100;
}
.profile-popover[aria-hidden="true"] {
  display: none;
}
.profile-action {
  border: none;
  background: #f8fafc;
  border-radius: 10px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: var(--text-main);
}
.profile-action.danger {
  color: #b91c1c;
}

/* --- Sub Topbar (Page Title) --- */
.topbar { min-height: 56px; background: var(--bg-surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 10px 24px; flex-shrink: 0; }
.eyebrow { display: none; }
.topbar h1 { font-size: 20px; margin: 0; color: var(--text-main); font-weight: 600; }
.inline-actions { display: flex; align-items: center; gap: 16px; }
.network-badge { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; border: 1px solid var(--border); }
.network-badge.online { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.network-badge.retry { background: #fef9c3; color: #854d0e; border-color: #fde047; }
.network-badge.offline { background: #fee2e2; color: #991b1b; border-color: #fecaca; }

/* --- Panels & Cards --- */
.panels { flex-grow: 1; overflow-y: auto; padding: 24px; }
.panel { display: none; }
.panel.active { display: block; }

.card { background: var(--bg-surface); border-radius: 16px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); padding: 24px; margin-bottom: 20px; max-width: 1400px; margin-left: auto; margin-right: auto; }
.card-subtle {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border-color: #dbe4f0;
}
.card-primary {
  border-color: #c7d2fe;
  box-shadow: 0 18px 38px rgba(37, 99, 235, 0.08);
}
.card-admin {
  border-color: #d8e2f2;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.06);
}
.card-primary::before,
.card-admin::before {
  content: "";
  display: block;
  width: 72px;
  height: 4px;
  border-radius: 999px;
  margin-bottom: 18px;
  background: linear-gradient(90deg, #2563eb 0%, #93c5fd 100%);
}
.order-entry-card {
  max-width: 1260px;
}
.order-list-card {
  max-width: 1400px;
}
h2 { font-size: 18px; margin-bottom: 16px; border-bottom: 1px solid var(--border); padding-bottom: 12px; font-weight: 600; }
h3 { font-size: 16px; margin-bottom: 12px; font-weight: 600; }
.list-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.list-head-meta { display: flex; align-items: center; gap: 12px; }
.inline-select.compact {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.inline-select.compact select {
  min-width: 132px;
  padding: 8px 12px;
}
.pill { background: #eef2ff; color: #334155; padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 800; border: 1px solid #dbe3ff; }
.sync-last-executed { margin: 0; color: #6b7280; white-space: nowrap; }
.order-filter-bar {
  display: grid;
  grid-template-columns: minmax(240px, 1.15fr) minmax(0, 2fr);
  gap: 12px;
  margin-bottom: 14px;
}
.order-filter-search,
.order-filter-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}
.order-filter-search .mini-input {
  width: 100%;
  min-width: 0;
}
.order-filter-meta .mini-select,
.order-filter-meta .mini-input.date {
  min-width: 132px;
}
.factory-slip-filter-bar {
  display: grid;
  grid-template-columns: minmax(240px, 1.1fr) minmax(0, 1.9fr);
  gap: 12px;
  margin-bottom: 16px;
}
.factory-slip-filter-search,
.factory-slip-filter-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}
.factory-slip-filter-search .mini-input {
  width: 100%;
  min-width: 0;
}
.factory-slip-filter-meta .mini-select,
.factory-slip-filter-meta .mini-input.date {
  min-width: 132px;
}
.order-bulk-toolbar {
  padding: 0 0 14px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  margin-bottom: 16px;
}
.order-bulk-toolbar .inline-actions {
  gap: 10px;
  justify-content: flex-start;
  flex-wrap: wrap;
}
.table-check-head {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: inherit;
  white-space: nowrap;
  vertical-align: middle;
  cursor: pointer;
}
.table-check-head.only-check {
  gap: 0;
  width: 18px;
  justify-content: center;
}
.table-check-head span {
  line-height: inherit;
}
.table-check-head input[type="checkbox"] {
  margin: 0;
  pointer-events: none;
}

/* --- Forms --- */
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 16px; }
.order-entry-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: #4b5563; }
input, select { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; background: #f9fafb; transition: all 0.2s; height: 40px; color: var(--text-main); font-family: inherit; }
input:focus, select:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }
.check { display: flex; flex-direction: row; align-items: center; gap: 8px; font-weight: normal; cursor: pointer; margin-bottom: 16px; font-size: 14px; }

.label-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 20px;
}

.label-main {
  min-width: 0;
}

.help-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid #fbbf24;
  background: #fef3c7;
  color: #92400e;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  cursor: help;
}

.help-tip::before,
.help-tip::after {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.help-tip::before {
  content: "";
  top: calc(100% + 4px);
  left: 2px;
  border-width: 6px;
  border-style: solid;
  border-color: transparent transparent #111827 transparent;
  transform: translateY(-4px);
}

.help-tip::after {
  content: attr(data-tip);
  top: calc(100% + 10px);
  left: 0;
  width: max-content;
  max-width: 260px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #111827;
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
  white-space: normal;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.22);
  transform: translateY(-4px);
  z-index: 20;
}

.help-tip:hover::before,
.help-tip:hover::after,
.help-tip:focus-visible::before,
.help-tip:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.help-tip:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}

.field-span-2 {
  grid-column: span 2;
}

#productDetailModal .detail-card {
  width: min(860px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.product-detail-media {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  margin: 4px 0 18px;
}

.product-detail-preview {
  width: 120px;
  height: 120px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, #ffffff 0%, #eef2f7 100%);
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
}

.product-detail-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* --- Order Lines --- */
.order-flow { display: none; }
.products { display: grid; gap: 8px; margin-bottom: 16px; }
.order-line { display: grid; grid-template-columns: minmax(150px, 2fr) 100px 120px auto; gap: 12px; align-items: end; background: #f8fafc; padding: 12px; border-radius: var(--radius-md); border: 1px solid var(--border); }
.line-col { display: flex; flex-direction: column; gap: 4px; }
.mini-label { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.order-quick-code { margin-bottom: 0; }
.combo-box {
  position: relative;
  width: 100%;
}
.combo-input {
  width: 100%;
  padding-right: 42px;
}
.combo-toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.combo-toggle::before {
  content: "";
  position: absolute;
  inset: 7px 5px 5px;
  border-left: 2px solid #94a3b8;
  border-bottom: 2px solid #94a3b8;
  transform: rotate(-45deg);
}
.combo-box.open .combo-toggle::before {
  inset: 9px 5px 3px;
  transform: rotate(135deg);
}
.combo-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 30;
  background: #ffffff;
  border: 1px solid #dbe4f0;
  border-radius: 14px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.16);
  overflow: hidden;
}
.combo-options {
  max-height: 260px;
  overflow-y: auto;
}
.combo-option {
  width: 100%;
  border: 0;
  background: #ffffff;
  padding: 12px 14px;
  display: grid;
  gap: 2px;
  text-align: left;
  cursor: pointer;
  font: inherit;
}
.combo-option:hover,
.combo-option.active {
  background: #eff6ff;
}
.combo-option-code {
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
}
.combo-option-name {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
}
.combo-empty {
  padding: 14px;
  color: #64748b;
  font-size: 13px;
}
.order-product-picker { display: block; }
.order-product-picker .combo-box { width: 100%; }

/* --- Buttons --- */
.cta-row { display: flex; gap: 12px; justify-content: flex-end; margin-top: 16px; }
.btn { padding: 10px 16px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; cursor: pointer; border: 1px solid transparent; transition: all 0.2s; display: inline-flex; align-items: center; justify-content: center; font-family: inherit; }
.btn.compact { height: 40px; padding: 0 12px; }
.btn.primary { background: var(--primary); color: white; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { background: white; color: var(--text-main); border-color: var(--border); }
.btn.ghost:hover { background: #f3f4f6; }
.btn.danger { color: var(--danger); background: #fef2f2; border-color: #fecaca; }
.btn.danger:hover { background: #fee2e2; }
.btn.danger-solid { background: var(--danger); color: #ffffff; border-color: var(--danger); }
.btn.danger-solid:hover { background: #dc2626; border-color: #dc2626; }

.toast-area {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: calc(88px + env(safe-area-inset-bottom));
  display: grid;
  gap: 10px;
  z-index: 3000;
  pointer-events: none;
  transform: translateX(-50%);
}

.toast {
  min-width: 280px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.94);
  color: #f8fafc;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.24);
  font-size: 13px;
  line-height: 1.5;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success {
  background: rgba(18, 94, 64, 0.96);
}

.toast.error {
  background: rgba(153, 27, 27, 0.96);
}

.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 84px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.tag.ok {
  background: #e0f2fe;
  color: #075985;
}

.tag.ng {
  background: #fee2e2;
  color: #b91c1c;
}

.tag.muted {
  background: #f3f4f6;
  color: #4b5563;
}

.status-text {
  font-weight: 700;
}

.status-text.status-received {
  color: #475569;
}

.status-text.status-checking {
  color: #6d28d9;
}

.status-text.status-confirmed {
  color: #15803d;
}

.status-text.status-shipped {
  color: #1d4ed8;
}

.status-text.status-on-hold {
  color: #b45309;
}

.status-text.status-cancelled {
  color: #b91c1c;
}

.tag.pca-pending {
  background: #f3f4f6;
  color: #4b5563;
}

.tag.pca-synced {
  background: #dcfce7;
  color: #15803d;
}

.tag.pca-exported {
  background: #dbeafe;
  color: #1d4ed8;
}

.tag.pca-error {
  background: #fee2e2;
  color: #b91c1c;
}

.tag.pca-blocked {
  background: #fef3c7;
  color: #b45309;
}

.tag.pca-cancelled,
.tag.pca-inactive {
  background: #f3f4f6;
  color: #6b7280;
}

/* --- Tables & Lists --- */
.table-wrap { overflow-x: auto; border-radius: 14px; border: 1px solid var(--border); background: white; margin-bottom: 16px; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; }
th { background: #f8fafc; padding: 12px 16px; font-weight: 600; color: var(--text-muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text-main); vertical-align: middle; }
tbody tr:hover { background: #f8fafc; cursor: pointer; }
.order-no-cell {
  display: grid;
  gap: 4px;
}
.order-subref {
  font-size: 11px;
  line-height: 1.35;
  color: var(--text-muted);
}
.fixed-table-wrap { max-height: 500px; overflow-y: auto; }
.fixed-table-wrap thead th { position: sticky; top: 0; z-index: 10; }
.list-head-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.hint.compact {
  margin: 0;
}
.inline-check.compact-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
}
.muted-inline {
  color: var(--text-muted);
  font-size: 12px;
}
.empty-cell {
  text-align: center;
  color: var(--text-muted);
}
.table-inline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.table-inline-actions .btn {
  min-height: 32px;
  flex: 0 0 auto;
  padding-inline: 10px;
}
.audit-table-wrap {
  overflow-x: hidden;
}

.audit-table {
  table-layout: fixed;
}

.audit-table th,
.audit-table td {
  padding: 10px 12px;
  vertical-align: top;
}

.audit-table th {
  white-space: normal;
  line-height: 1.35;
}

.audit-table th:nth-child(1),
.audit-table td:nth-child(1) {
  width: 112px;
}

.audit-table th:nth-child(2),
.audit-table td:nth-child(2) {
  width: 72px;
}

.audit-table th:nth-child(3),
.audit-table td:nth-child(3) {
  width: 148px;
}

.audit-table th:nth-child(4),
.audit-table td:nth-child(4) {
  width: 104px;
}

.audit-table th:nth-child(5),
.audit-table td:nth-child(5) {
  width: 88px;
}

.audit-table th:nth-child(7),
.audit-table td:nth-child(7) {
  width: 76px;
  text-align: right;
}

.audit-cell-text,
.audit-cell-detail {
  display: block;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.45;
}

.audit-cell-detail {
  color: #31424c;
}

.audit-table .mini-btn {
  min-width: 0;
  width: 100%;
  padding-inline: 10px;
}

/* --- Settings Sub-tabs --- */
.settings-tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.order-subtabs {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.order-subtabs .settings-tab-btn {
  min-width: 132px;
}

.settings-tab-btn {
  border: 1px solid #d9e1f0;
  background: #f8fafc;
  color: var(--text-main);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.settings-tab-btn.active {
  border-color: #c7d2fe;
  background: #e0e7ff;
  color: #1e3a8a;
}

[data-settings-content="user"] .table-wrap {
  margin-bottom: 0;
}

[data-settings-content="user"] .cta-row .filters {
  width: 100%;
  justify-content: flex-start;
}

[data-settings-content="user"] .hint + .table-wrap {
  margin-top: 14px;
}

.category-inline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px auto;
  gap: 8px;
  align-items: stretch;
}

.category-inline input[type="color"] {
  min-height: 42px;
  padding: 4px;
  border-radius: 10px;
}

#productRows {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  align-content: start;
}

#productRows.list-view {
  display: block;
}

.view-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
}

.view-toggle-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.92rem;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.view-toggle-btn.active {
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.product-card {
  --product-accent: #cbd5e1;
  position: relative;
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(248,250,252,0.98) 100%),
    linear-gradient(135deg, var(--product-accent), rgba(255,255,255,0));
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.product-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  border-radius: 18px 18px 0 0;
  background: linear-gradient(90deg, var(--product-accent), rgba(37, 99, 235, 0.22));
}

.product-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--product-accent) 45%, #dbe4f0 55%);
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.1);
}

.product-card.selected {
  border-color: color-mix(in srgb, var(--product-accent) 58%, #1d4ed8 42%);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12), 0 18px 36px rgba(15, 23, 42, 0.1);
}

.product-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.product-check-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid #dbe3ee;
  background: #ffffff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.product-check-wrap input {
  margin: 0;
}

.product-side-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.product-category-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--product-accent) 18%, #ffffff 82%);
  border: 1px solid color-mix(in srgb, var(--product-accent) 38%, #dbe4f0 62%);
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}

.product-card-body {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.product-thumb {
  width: 88px;
  height: 88px;
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.95), rgba(241,245,249,0.95)),
    linear-gradient(135deg, var(--product-accent), rgba(255,255,255,0));
  background-position: center;
  background-size: cover;
  display: grid;
  place-items: center;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid rgba(148, 163, 184, 0.18);
  overflow: hidden;
}

.product-main {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.product-main h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
  color: #0f172a;
}

.product-list-table-wrap {
  margin-bottom: 0;
}

.customer-product-linked-products {
  padding: 18px 20px;
}

.customer-product-bulk-copy {
  padding: 18px 20px;
}

.customer-product-copy-grid {
  margin-top: 12px;
  margin-bottom: 12px;
}

.customer-product-bulk-copy .check.compact {
  align-self: end;
  min-height: 42px;
}

.customer-product-bulk-copy .cta-row {
  justify-content: flex-start;
  margin-top: 0;
}

.customer-product-linked-products .field-grid {
  margin-top: 12px;
}

.customer-product-linked-products .combo-box {
  max-width: 420px;
}

.customer-product-linked-table td:nth-child(1),
.customer-product-linked-table th:nth-child(1) {
  width: 84px;
}

.customer-product-linked-table td:nth-child(5),
.customer-product-linked-table th:nth-child(5),
.customer-product-linked-table td:nth-child(6),
.customer-product-linked-table th:nth-child(6),
.customer-product-linked-table td:nth-child(7),
.customer-product-linked-table th:nth-child(7) {
  white-space: nowrap;
}

.sort-header {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  background: transparent;
  padding: 0;
  font: inherit;
  font-weight: 700;
  color: inherit;
  cursor: pointer;
}

.sort-header:hover {
  color: #1d4ed8;
}

.sort-header.active {
  color: #1d4ed8;
}

.product-list-table td:nth-child(1),
.product-list-table th:nth-child(1) {
  width: 52px;
}

.product-list-table td:nth-child(2),
.product-list-table th:nth-child(2) {
  width: 84px;
}

.product-list-table td:nth-child(3),
.product-list-table th:nth-child(3) {
  width: 110px;
  white-space: nowrap;
}

.product-list-table td:nth-child(6),
.product-list-table th:nth-child(6),
.product-list-table td:nth-child(7),
.product-list-table th:nth-child(7),
.product-list-table td:nth-child(8),
.product-list-table th:nth-child(8) {
  white-space: nowrap;
}

.product-list-row.selected td {
  background: rgba(37, 99, 235, 0.06);
}

.product-list-thumb {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.95), rgba(241,245,249,0.95)),
    linear-gradient(135deg, #dbe4f0, rgba(255,255,255,0));
  background-position: center;
  background-size: cover;
  display: grid;
  place-items: center;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid rgba(148, 163, 184, 0.18);
  overflow: hidden;
}

.image-placeholder-icon {
  width: 24px;
  height: 18px;
  border: 2px solid #7e95a5;
  border-radius: 4px;
  position: relative;
  display: block;
  margin: 0 auto 5px;
  box-sizing: border-box;
}

.image-placeholder-icon::before {
  content: "";
  position: absolute;
  left: 3px;
  bottom: 3px;
  width: 8px;
  height: 6px;
  background: #7e95a5;
  clip-path: polygon(0 100%, 45% 35%, 65% 60%, 100% 0, 100% 100%);
}

.image-placeholder-icon::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 4px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #7e95a5;
}

.image-placeholder-text {
  display: block;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.2;
  color: #6b7f8d;
  text-align: center;
  letter-spacing: 0.02em;
}

.product-list-name {
  min-width: 0;
}

.product-list-name strong {
  display: block;
  font-size: 14px;
  color: var(--text-main);
}

.product-code {
  margin: 0;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.product-price {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: #475569;
  font-size: 13px;
}

.product-price strong {
  color: #0f172a;
  font-size: 20px;
  font-weight: 800;
}

.product-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.product-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #4338ca;
  font-size: 12px;
  font-weight: 700;
}

.product-empty {
  display: grid;
  place-items: center;
  min-height: 180px;
  border: 1px dashed #cbd5e1;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  color: #64748b;
  font-weight: 700;
}
.fixed-products-wrap {
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

.category-inline .btn {
  width: auto;
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(17, 24, 39, 0.42);
  z-index: 2000;
}

.modal.open {
  display: flex;
}

.reflect-loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(241, 245, 249, 0.56);
  backdrop-filter: blur(14px) saturate(1.05);
  -webkit-backdrop-filter: blur(14px) saturate(1.05);
  z-index: 2600;
}

.reflect-loading[hidden] {
  display: none !important;
}

.purchase-loading {
  z-index: 1400;
}

.reflect-loading-card {
  width: min(320px, calc(100vw - 48px));
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: 28px 24px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255,255,255,0.78) 0%, rgba(248,250,252,0.86) 100%);
  box-shadow:
    0 24px 60px rgba(15, 23, 42, 0.12),
    inset 0 1px 0 rgba(255,255,255,0.65);
}

.reflect-loading-orb {
  position: relative;
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
}

.reflect-loading-ring {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  border: 3px solid rgba(148, 163, 184, 0.22);
  border-top-color: #111827;
  border-right-color: rgba(37, 99, 235, 0.72);
  animation: reflect-spin 1s linear infinite;
}

.reflect-loading-core {
  width: 50px;
  height: 50px;
  border-radius: 999px;
  background: radial-gradient(circle at 32% 28%, rgba(255,255,255,0.92), rgba(255,255,255,0.56) 42%, rgba(226,232,240,0.92) 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.86);
}

.reflect-loading-copy {
  display: grid;
  gap: 6px;
  text-align: center;
}
.notice-broadcast-editor-wrap {
  margin-top: 14px;
}
.notice-target-picker {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 14px;
}
.notice-target-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.notice-target-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}
.notice-target-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.notice-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.notice-editor-select {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
}
.notice-editor-select.small {
  min-width: 110px;
}
.notice-editor-btn {
  min-height: 34px;
}
.notice-editor-btn.icon {
  min-width: 34px;
  padding: 0 10px;
  font-weight: 700;
  line-height: 1;
}
.notice-color-popover-wrap {
  position: relative;
}
.notice-color-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 24px);
  gap: 8px;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
}
.notice-color-popover[hidden] {
  display: none !important;
}
.notice-color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  cursor: pointer;
}
.notice-broadcast-thumb {
  width: 48px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.95), rgba(241,245,249,0.95)),
    linear-gradient(135deg, #dbe4f0, rgba(255,255,255,0));
  background-size: cover;
  background-position: center;
}
.notice-broadcast-preview {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}
.notice-broadcast-preview-label {
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}
.notice-broadcast-preview-body {
  min-height: 120px;
  padding: 14px;
  font-size: 14px;
  line-height: 1.7;
  outline: none;
  cursor: text;
}
.notice-broadcast-preview-body:focus {
  box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.16);
}
.notice-broadcast-preview-body h2 {
  margin: 0 0 10px;
  font-size: 24px;
  line-height: 1.35;
}
.notice-broadcast-preview-body p {
  margin: 0 0 10px;
}
.notice-broadcast-preview-body ul,
.notice-broadcast-preview-body ol {
  margin: 0 0 10px 20px;
}
.notice-broadcast-preview-body img {
  max-width: 100%;
  border-radius: 12px;
  display: block;
}
@media (max-width: 800px) {
  .notice-target-options {
    grid-template-columns: 1fr;
  }
}

.reflect-loading-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #0f172a;
}

.reflect-loading-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: #475569;
}

@keyframes reflect-spin {
  to {
    transform: rotate(360deg);
  }
}

.modal-card {
  width: min(720px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
  padding: 24px;
}

.login-modal-card {
  width: min(460px, calc(100vw - 48px));
}

.header-actions .auth-role-badge {
  align-self: center;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}

.login-logo {
  margin-right: 0;
  font-size: 22px;
  color: #111827;
}

.login-title {
  text-align: left;
  margin-bottom: 20px;
}

.pca-sync-modal-card {
  width: min(1040px, calc(100vw - 48px));
  display: grid;
  gap: 16px;
}

.pca-sync-modal-copy {
  display: grid;
  gap: 4px;
}

.pca-sync-modal-kicker {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
}

.pca-sync-modal-card h3 {
  margin: 0;
}

.pca-sync-modal-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  border: 1px solid #d7deea;
  background: #f8fafc;
}

#pca-sync .card {
  border-radius: 12px;
  box-shadow: none;
}

.pca-sync-pane {
  border-color: #d7deea;
}

.pca-sync-summary-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  border: 1px solid #d7deea;
  background: #f8fafc;
  margin-bottom: 12px;
}

.pca-sync-summary-cell {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-right: 1px solid #d7deea;
}

.pca-sync-summary-cell:last-child {
  border-right: 0;
}

.pca-sync-summary-term {
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
}

.pca-sync-summary-cell strong {
  font-size: 20px;
  line-height: 1;
  color: #0f172a;
}

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

.pca-sync-toolbar .toolbar-left.filters {
  margin-bottom: 0;
}

.pca-sync-toolbar .inline-actions {
  justify-content: flex-end;
}

.pca-sync-main-table thead th {
  white-space: nowrap;
}

.pca-sync-main-table tbody tr:nth-child(even) td {
  background: #fbfdff;
}

.pca-sync-main-table td:nth-child(3) {
  width: 110px;
}

.pca-sync-main-table td:last-child {
  color: #334155;
  line-height: 1.45;
}

.pca-sync-pane .hint {
  margin-top: 10px;
}

.sales-check-customer-picker {
  width: 320px;
  min-width: 320px;
  flex: 0 0 320px;
}

.sales-check-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pca-sync-execution-box {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid #cfe0ff;
  border-radius: 10px;
  background: #f8fbff;
}

.pca-sync-execution-title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: #1d4ed8;
}

.pca-sync-execution-text {
  margin: 0;
  color: #1e293b;
  line-height: 1.6;
}

.pca-sync-execution-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pca-sync-execution-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
}

.pca-sync-modal-table-wrap {
  max-height: min(56vh, 560px);
  margin-bottom: 0;
}

.pca-sync-preview-table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  white-space: nowrap;
}

.pca-sync-preview-table tbody tr:nth-child(even) td {
  background: #fbfdff;
}

.pca-sync-status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 86px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.pca-sync-status-chip.same {
  background: #e2e8f0;
  color: #475569;
}

.pca-sync-status-chip.update_candidate {
  background: #dbeafe;
  color: #1d4ed8;
}

.pca-sync-status-chip.import_candidate {
  background: #dcfce7;
  color: #15803d;
}

.pca-sync-status-chip.local_only {
  background: #fef3c7;
  color: #b45309;
}

.pca-sync-status-chip.review_required {
  background: #fee2e2;
  color: #b91c1c;
}

.pca-sync-detail-text {
  color: #475569;
  line-height: 1.5;
}

@media (max-width: 760px) {
  .pca-sync-summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pca-sync-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .sales-check-customer-picker {
      width: 100%;
      min-width: 0;
      flex: 1 1 auto;
    }

  .sales-check-filters {
    align-items: stretch;
  }
  }
/* Order detail modal */
#orderDetailModal {
  background: rgba(17, 24, 39, 0.48);
  padding: 24px;
}

#orderDetailModal .detail-card {
    width: min(1180px, calc(100vw - 48px));
    max-height: calc(100vh - 48px);
    overflow: auto;
    border-radius: 18px;
    position: relative;
  border: 1px solid var(--border);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
  background: #ffffff;
  padding: 28px;
}

#orderDetailModal h3 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: var(--text-main);
}

#orderDetailModal .detail-toolbar {
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 8px;
}

#orderDetailModal .detail-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

#orderDetailModal .detail-nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

#orderDetailModal .detail-toolbar-copy {
  display: grid;
  gap: 4px;
}

.btn.icon-only {
  min-width: 36px;
  width: 36px;
  min-height: 36px;
  border-radius: 999px;
  padding-inline: 0;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  border-color: #d8e0ef;
  color: #28406d;
  background: linear-gradient(180deg, #ffffff 0%, #f4f8ff 100%);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.btn.icon-only:hover {
  border-color: #bfd0ef;
  background: linear-gradient(180deg, #ffffff 0%, #ebf3ff 100%);
  transform: translateY(-1px);
}

#orderDetailModal .detail-kicker {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
}

#orderDetailModal .detail-hint {
      position: static;
      margin: 0 0 12px;
      max-width: none;
      z-index: auto;
      padding: 10px 12px;
      background: #fff7f7;
      box-shadow: none;
      border: 1px solid #fecaca;
      backdrop-filter: none;
      color: #991b1b;
      font-size: 13px;
      font-weight: 600;
      text-align: left;
      border-radius: 12px;
      line-height: 1.6;
}

#orderDetailModal .detail-hint:empty {
      display: none;
}

#orderDetailModal .detail-hint.is-loading::after {
      content: attr(data-dots);
      display: inline-block;
      width: 1.5em;
      text-align: left;
      vertical-align: bottom;
      white-space: nowrap;
}

#orderDetailModal .detail-lock-notice {
  display: grid;
  gap: 10px;
  margin: 0 0 16px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid #f7d7aa;
  background: linear-gradient(180deg, #fff8ef 0%, #fff3df 100%);
}

#orderDetailModal .detail-lock-notice[hidden] {
  display: none;
}

#orderDetailModal .detail-lock-notice-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
}

#orderDetailModal .detail-lock-notice-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
  flex: 1 1 auto;
}

#orderDetailModal .detail-lock-notice-head strong {
  font-size: 14px;
  color: #9a3412;
}

#orderDetailModal .detail-lock-notice-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(251, 146, 60, 0.14);
  border: 1px solid rgba(251, 146, 60, 0.28);
  color: #c2410c;
  font-size: 11px;
  font-weight: 800;
}

#orderDetailModal .detail-lock-notice-body {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: #7c2d12;
}

#orderDetailModal .detail-lock-help {
  flex: 0 0 auto;
  border-color: rgba(251, 146, 60, 0.38);
  background: rgba(255, 255, 255, 0.9);
  color: #c2410c;
}

#orderDetailModal .detail-lock-help::before {
  left: auto;
  right: 2px;
}

#orderDetailModal .detail-lock-help::after {
  left: auto;
  right: 0;
  text-align: left;
}

#orderDetailModal .detail-lock-notice-actions {
  display: flex;
  justify-content: flex-start;
}

#orderDetailModal .detail-lock-notice-actions[hidden] {
  display: none;
}

#orderDetailModal .detail-section {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
}

#orderDetailModal .detail-section:last-child {
  margin-bottom: 0;
}

#orderDetailModal .detail-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#orderDetailModal .detail-section-head h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #374151;
}

#orderDetailModal .detail-overview-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

#orderDetailModal .detail-overview-card,
#orderDetailModal .detail-info-card,
#orderDetailModal .detail-summary-card,
#orderDetailModal .detail-lines-card,
#orderDetailModal .detail-history-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 14px;
}

#orderDetailModal .detail-overview-card {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  min-width: 0;
}

#orderDetailModal .detail-field-label,
#orderDetailModal .detail-card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

#orderDetailModal .detail-overview-card input,
#orderDetailModal .detail-overview-card select,
#orderDetailModal .detail-data-list input,
#orderDetailModal .detail-data-list select,
#orderDetailModal .detail-support-grid input,
#orderDetailModal .detail-support-grid select {
  background: #ffffff;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

#orderDetailModal input[readonly] {
  background: #f9fafb;
  color: #374151;
}

#orderDetailModal .detail-panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.22fr) minmax(0, 0.9fr);
  gap: 10px;
}

#orderDetailModal .detail-info-card {
  display: grid;
  gap: 10px;
  padding: 14px;
}

#orderDetailModal .detail-data-list {
  display: grid;
  gap: 10px;
}

#orderDetailModal .detail-data-list label,
#orderDetailModal .detail-support-grid label {
  font-size: 12px;
  color: var(--text-muted);
}

#orderDetailModal .detail-customer-card {
  padding: 0;
  overflow: hidden;
}

#orderDetailModal .detail-customer-headline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 140px;
  align-items: start;
  gap: 12px;
  padding: 16px 16px 0;
}

#orderDetailModal .meta-chip {
  display: grid;
  gap: 2px;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  grid-column: 2;
}

#orderDetailModal .meta-chip-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

#orderDetailModal .meta-chip-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  word-break: break-all;
}

#orderDetailModal .plain-row {
  display: flex;
  align-items: center;
  min-height: 52px;
  padding: 12px 16px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
}

#orderDetailModal .plain-row.code-name {
  font-size: 16px;
  font-weight: 700;
}

#orderDetailModal .plain-row.customer-head-row {
  display: block;
  min-height: auto;
  padding-top: 6px;
  padding-bottom: 10px;
  background: #f8fafc;
}

#orderDetailModal .plain-row.customer-head-row .plain-row.code-name {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  line-height: 1.35;
}

#orderDetailModal .plain-row.address.two-line {
  min-height: 64px;
  align-items: flex-start;
  white-space: pre-wrap;
  line-height: 1.5;
  font-size: 15px;
}

#orderDetailModal .plain-row.telfax {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  background: #f9fafb;
  font-size: 15px;
  font-weight: 600;
  color: #374151;
}

#orderDetailModal .plain-row.telfax span {
  min-width: 0;
}

#orderDetailModal .detail-summary-card,
#orderDetailModal .detail-lines-card {
  padding: 0;
  overflow: hidden;
}

#orderDetailTotals {
  display: block;
}

#orderDetailModal .summary-table-wrap {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

#orderDetailModal .summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

#orderDetailModal .summary-table th,
#orderDetailModal .summary-table td {
  padding: 12px 14px;
  border-right: 1px solid #eef2f7;
  border-bottom: 1px solid #eef2f7;
  text-align: right;
}

#orderDetailModal .summary-table th:last-child,
#orderDetailModal .summary-table td:last-child {
  border-right: 0;
}

#orderDetailModal .summary-table thead th {
  background: #f8fafc;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

#orderDetailModal .summary-table tbody td:first-child,
#orderDetailModal .summary-table tbody td:nth-child(4) {
  text-align: center;
}

#orderDetailModal .summary-table .summary-blank {
  background: #ffffff;
}

#orderDetailModal .summary-table .summary-total-label {
  background: #eff6ff;
  color: #1e40af;
  font-weight: 700;
  text-align: center;
}

#orderDetailModal .summary-table .total-cell {
  font-weight: 700;
  color: #111827;
}

#orderDetailModal .summary-table .grand-total {
  background: #dbeafe;
  color: #1d4ed8;
}

#orderDetailModal .table-wrap {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: #ffffff;
  overflow-x: hidden;
}

#orderDetailModal table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

#orderDetailModal .detail-lines-card table {
  table-layout: auto;
}

#orderDetailModal thead th {
  background: #f8fafc;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  padding: 10px 12px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid #eef2f7;
}

#orderDetailModal td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid #f3f4f6;
  background: #ffffff;
  vertical-align: middle;
}

#orderDetailModal tbody tr:hover td {
  background: #f9fafb;
}

#orderDetailModal #orderDetailLines th:nth-child(6),
#orderDetailModal #orderDetailLines td:nth-child(6),
#orderDetailModal #orderDetailLines th:nth-child(7),
#orderDetailModal #orderDetailLines td:nth-child(7) {
  text-align: right;
}

#orderDetailModal #orderDetailLines th:nth-child(1),
#orderDetailModal #orderDetailLines td:nth-child(1),
#orderDetailModal #orderDetailLines th:nth-child(3),
#orderDetailModal #orderDetailLines td:nth-child(3),
#orderDetailModal #orderDetailLines th:nth-child(5),
#orderDetailModal #orderDetailLines td:nth-child(5) {
  text-align: center;
}

#orderDetailModal #orderDetailLines th:nth-child(2),
#orderDetailModal #orderDetailLines td:nth-child(2),
#orderDetailModal #orderDetailLines th:nth-child(4),
#orderDetailModal #orderDetailLines td:nth-child(4),
#orderDetailModal #orderDetailLines th:nth-child(8),
#orderDetailModal #orderDetailLines td:nth-child(8),
#orderDetailModal #orderDetailLines th:nth-child(9),
#orderDetailModal #orderDetailLines td:nth-child(9) {
  text-align: center;
}

#orderDetailModal #orderDetailLines th:nth-child(2),
#orderDetailModal #orderDetailLines td:nth-child(2) {
  text-align: left;
}

#orderDetailModal #orderDetailLines th:nth-child(2),
#orderDetailModal #orderDetailLines td:nth-child(2) {
  white-space: normal;
  overflow-wrap: anywhere;
  padding-left: 16px;
}

#orderDetailModal .detail-cell-editor {
  display: grid;
  justify-items: center;
  width: 100%;
}

#orderDetailModal .detail-cell-editor .mini-input {
  width: 100%;
  min-width: 0;
  max-width: 84px;
  text-align: center;
  min-height: 36px;
  height: 36px;
  padding: 6px 10px;
  line-height: 1.2;
}

#orderDetailModal .detail-cell-editor.is-readonly .mini-input {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  padding-left: 0;
  padding-right: 0;
  color: #111827;
  pointer-events: none;
}

#orderDetailModal .detail-cell-editor.is-editing .mini-input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

#orderDetailModal .detail-cell-editor.is-editing .mini-input[type="number"]::-webkit-outer-spin-button,
#orderDetailModal .detail-cell-editor.is-editing .mini-input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#orderDetailModal .detail-line-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

#orderDetailModal .sub-note {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.35;
}

#orderDetailModal .detail-support-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 0;
}

#orderDetailModal .detail-wide-field {
  grid-column: 1 / -1;
}

#orderDetailModal .detail-history-card {
  padding: 8px 16px 14px;
}

#orderDetailModal .history-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
  font-size: 12px;
  color: #374151;
}

#orderDetailModal .order-history-item {
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #f8fafc;
}

#orderDetailModal .order-history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: center;
  color: #64748b;
  font-size: 11px;
  margin-bottom: 6px;
}

#orderDetailModal .order-history-action {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-weight: 700;
}

#orderDetailModal .order-history-subject,
#orderDetailModal .order-history-changes {
  margin: 0;
  line-height: 1.55;
}

#orderDetailModal .order-history-subject {
  font-weight: 700;
  color: #1f2937;
}

#orderDetailModal .order-history-changes {
  margin-top: 4px;
  color: #334155;
}

#orderDetailModal .inline-actions .btn {
  min-height: 40px;
}

@media (max-width: 960px) {
  #orderDetailModal {
    padding: 16px;
  }

  #orderDetailModal .detail-card {
      width: min(100%, calc(100vw - 32px));
      max-height: calc(100vh - 32px);
      padding: 22px;
    }

    #orderDetailModal .detail-hint {
      margin-bottom: 12px;
      max-width: none;
    }

  #orderDetailModal .detail-overview-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #orderDetailModal .detail-panel-grid {
    grid-template-columns: 1fr;
  }

  #orderDetailModal .detail-lock-notice-head {
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  .pca-sync-modal-card {
    width: min(100%, calc(100vw - 24px));
    padding: 18px;
  }

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

  .pca-sync-modal-card .list-head,
  .pca-sync-modal-card .inline-actions {
    align-items: stretch;
  }

  .pca-sync-modal-card .inline-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .pca-sync-modal-card .inline-actions .btn {
    flex: 1 1 180px;
  }

  #orderDetailModal {
    padding: 12px;
  }

  #orderDetailModal .detail-card {
      width: min(100%, calc(100vw - 24px));
      max-height: calc(100vh - 24px);
      padding: 18px;
    }

    #orderDetailModal .detail-hint {
      position: static;
      top: auto;
      right: auto;
      max-width: none;
      margin-bottom: 12px;
    }

  #orderDetailModal .detail-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  #orderDetailModal .detail-toolbar-actions {
    flex-direction: column;
    align-items: stretch;
    margin-left: 0;
  }

  #orderDetailModal .detail-nav-actions {
    justify-content: flex-end;
  }

  #orderDetailModal .detail-toolbar .inline-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }

  #orderDetailModal .detail-toolbar .inline-actions .btn {
    flex: 1 1 140px;
  }

  #orderDetailModal .detail-overview-grid,
  #orderDetailModal .detail-support-grid {
    grid-template-columns: 1fr;
  }

  #orderDetailModal .plain-row.telfax {
    grid-template-columns: 1fr;
  }
}

.meta-item {
  background: #f7fbfd;
  border: 1px solid #e4ecef;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
}
.meta-item b { display: block; color: #4e6671; margin-bottom: 4px; font-size: 11px; }
.history-list {
  margin: 8px 0 0;
  padding-left: 18px;
  color: #39505a;
  font-size: 12px;
  display: grid;
  gap: 6px;
}
.inline-actions .btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: auto;
  }

.btn.pseudo-disabled,
.btn[aria-disabled="true"] {
    opacity: 0.45;
    cursor: not-allowed;
}

.factory-slip-modal-card {
  width: min(1320px, calc(100vw - 48px));
  display: grid;
  gap: 18px;
}

.factory-slip-header-actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.factory-slip-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

.factory-slip-preview-pane {
  min-width: 0;
  overflow: hidden;
  padding: 4px 0 8px;
}

.factory-slip-sheet-preview {
  width: calc(100% / 0.64);
  transform: scale(0.64);
  transform-origin: top left;
}

.factory-slip-side-pane {
  display: grid;
  gap: 12px;
  align-content: start;
}

.factory-slip-toolbar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #f8fafc;
}

.factory-slip-toolbar label {
  display: grid;
  gap: 8px;
}

.factory-ship-at-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.factory-slip-sheet {
  border: 2px solid #1f2937;
  background: #fff;
}

.factory-slip-sheet-header {
  display: grid;
  gap: 10px;
  padding: 20px 28px 14px;
  border-bottom: 2px solid #1f2937;
}

.factory-slip-kind-row {
  text-align: center;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.factory-slip-date-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  align-items: center;
  gap: 24px;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.35;
}

.factory-slip-date-row span {
  min-height: 42px;
  display: flex;
  align-items: center;
}

.factory-slip-date-row span:first-child {
  justify-content: flex-start;
}

.factory-slip-date-row span:last-child {
  justify-content: flex-end;
}

.factory-slip-customer-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  min-height: 110px;
  border-bottom: 2px solid #1f2937;
}

.factory-slip-customer-box,
.factory-slip-stamp-box {
  padding: 16px 20px;
}

.factory-slip-customer-box {
  border-right: 2px solid #1f2937;
  display: grid;
  gap: 12px;
}

.factory-slip-box-label {
  font-size: 18px;
  font-weight: 700;
}

.factory-slip-customer-box input {
  border: 0;
  border-radius: 0;
  padding: 0;
  font-size: 40px;
  font-weight: 700;
  background: transparent;
}

.factory-slip-stamp-box {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 12px;
  font-size: 16px;
  font-weight: 700;
}

.factory-slip-stamp-label {
  text-align: center;
}

.factory-slip-stamp-value {
  display: block;
  min-height: 42px;
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  line-height: 1.3;
  word-break: break-word;
}

.factory-slip-grid-head,
.factory-slip-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) 180px minmax(0, 1fr) 54px;
}

.external-order-grid-head,
.external-order-row {
  grid-template-columns: minmax(0, 1.2fr) 140px 120px 180px 54px;
}

.factory-slip-grid-head {
  border-bottom: 1px solid #1f2937;
  background: #fafafa;
  font-weight: 700;
  font-size: 20px;
}

.factory-slip-grid-head span,
.factory-slip-row > * {
  padding: 12px 14px;
  border-right: 1px solid #1f2937;
}

.factory-slip-grid-head > *:last-child,
.factory-slip-row > *:last-child {
  border-right: 0;
}

.factory-slip-add-row-btn.btn,
.factory-slip-add-row-btn.btn.ghost,
.factory-slip-add-row-btn.btn.compact {
  width: 100%;
  height: 100%;
  border-radius: 0;
  border: 0;
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  color: #ffffff;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.16);
}

.factory-slip-add-row-btn.btn:hover,
.factory-slip-add-row-btn.btn.ghost:hover,
.factory-slip-add-row-btn.btn.compact:hover {
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  border: 0;
}

.factory-slip-row {
  min-height: 70px;
  border-bottom: 1px solid #1f2937;
}

.factory-slip-row input {
  width: 100%;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  font-size: 26px;
  font-weight: 600;
}

.factory-slip-row .qty-cell input {
  text-align: center;
  font-size: 28px;
}

.factory-slip-row .remove-cell {
  display: flex;
  align-items: center;
  justify-content: center;
}

.factory-slip-row .remove-cell .btn {
  min-width: 36px;
  width: 36px;
  padding-inline: 0;
}

.external-order-greeting {
  padding: 16px 18px;
  font-size: 20px;
  line-height: 1.6;
  min-height: 78px;
  white-space: pre-line;
}

.external-order-top-row,
.external-order-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
}

.external-order-title-row {
  justify-content: center;
  font-size: 36px;
  font-weight: 800;
  letter-spacing: 0.2em;
}

.external-order-top-row {
  font-size: 26px;
  font-weight: 700;
}

.external-order-greeting-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  border-bottom: 1px solid #1f2937;
}

.external-order-company-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 18px;
  font-size: 24px;
  font-weight: 700;
  border-left: 1px solid #1f2937;
}

.external-order-delivery-box,
.external-order-remarks-box,
.external-order-footer-grid > div {
  border: 1px solid #1f2937;
  margin-top: 16px;
}

.external-order-remarks-box {
  padding: 12px 14px;
  min-height: 92px;
}

.external-order-footer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  margin-top: 16px;
  align-items: stretch;
}

.external-order-delivery-box {
  padding: 12px 14px;
  margin-top: 0;
}

.external-order-footer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 0;
  align-items: stretch;
}

.external-order-footer-grid > div {
  padding: 12px 14px;
  margin-top: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

#externalOrderRemarksPreview,
#externalOrderDeliveryPreview,
#externalOrderGreetingCompanyPreview,
#externalOrderIssuerPreview,
#externalOrderSenderPreview {
  white-space: pre-line;
  margin: 6px 0 0;
  line-height: 1.6;
}

#externalOrderRemarksPreview {
  min-height: 3.2em;
}

#externalOrderIssuerPreview,
#externalOrderSenderPreview {
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
}

#externalOrderDeliveryPreview {
  font-size: 24px;
  font-weight: 700;
}

@media (max-width: 960px) {
  .factory-slip-modal-card {
    width: min(100%, calc(100vw - 24px));
  }

  .factory-slip-stage {
    grid-template-columns: 1fr;
  }

  .factory-slip-sheet-preview {
    width: 100%;
    transform: none;
  }

  .factory-slip-side-pane {
    order: -1;
  }

  .factory-slip-header-actions {
    justify-content: stretch;
  }

  .factory-slip-header-actions .btn {
    flex: 1 1 160px;
  }

  .factory-ship-at-fields {
    grid-template-columns: 1fr;
  }

  .factory-slip-date-row,
  .factory-slip-customer-panel,
  .factory-slip-grid-head,
  .factory-slip-row {
    grid-template-columns: 1fr;
  }

  .factory-slip-customer-box {
    border-right: 0;
    border-bottom: 2px solid #1f2937;
  }

  .factory-slip-grid-head {
    display: none;
  }

  .factory-slip-row > * {
    border-right: 0;
    border-bottom: 1px solid #e5e7eb;
  }

}

/* purchase mini app */
.purchase-page {
  background: #f6f7f8;
  padding-bottom: 96px;
  height: auto;
  min-height: 100vh;
  display: block;
  overflow-x: hidden;
  overflow-y: auto;
}

.purchase-page.purchase-unlinked .purchase-shell,
.purchase-page.purchase-unlinked .sticky-order-bar {
  visibility: hidden;
  pointer-events: none;
}

.purchase-page .purchase-shell {
  width: min(1120px, calc(100% - 24px));
  margin: 0 auto;
  padding: 14px 0 18px;
}

.purchase-page .mini-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #111827;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 12px;
}

.purchase-page .mini-header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.purchase-page .mini-header-copy {
  min-width: 0;
}

.purchase-page .mini-logo-mark {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #60a5fa;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.12);
  flex: 0 0 auto;
}

.purchase-page .mini-header-side {
  display: flex;
  align-items: center;
  gap: 10px;
}

.purchase-page .mini-bell-button {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,0.92);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: none;
  position: relative;
}

.purchase-page .mini-notice-dot {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #ef4444;
  box-shadow: 0 0 0 2px #111827;
}

.purchase-page .mini-bell-icon {
  position: relative;
  width: 22px;
  height: 22px;
  display: inline-block;
}

.purchase-page .mini-bell-icon::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 3px;
  width: 16px;
  height: 14px;
  transform: translateX(-50%);
  background: currentColor;
  border-radius: 9px 9px 2px 2px;
}

.purchase-page .mini-bell-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 8px;
  height: 6px;
  transform: translateX(-50%);
  background: currentColor;
  border-radius: 0 0 999px 999px;
}

.purchase-page .mini-bell-button::before {
  content: "";
  position: absolute;
  top: 1px;
  left: 50%;
  width: 7px;
  height: 7px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: currentColor;
}

.purchase-page .mini-bell-button::after {
  content: "";
  position: absolute;
  top: 15px;
  left: 50%;
  width: 18px;
  height: 4px;
  transform: translateX(-50%);
  border-radius: 2px;
  background: currentColor;
}

.purchase-page .mini-header h1 {
  margin: 0;
  font-size: 20px;
  color: #ffffff;
}

.purchase-page .mini-header-badge {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  font-size: 12px;
  font-weight: 800;
  color: #e5e7eb;
}

.purchase-page .mini-account-chip {
  min-width: 132px;
  height: 40px;
  padding: 0 14px 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.purchase-page .mini-account-icon {
  position: relative;
  width: 16px;
  height: 16px;
  display: inline-block;
  flex: 0 0 auto;
}

.purchase-page .mini-account-icon::before,
.purchase-page .mini-account-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: currentColor;
}

.purchase-page .mini-account-icon::before {
  top: 0;
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.purchase-page .mini-account-icon::after {
  bottom: 0;
  width: 14px;
  height: 7px;
  border-radius: 999px 999px 6px 6px;
}

.purchase-page .mini-account-name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
}

.purchase-page .purchase-section {
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 14px 16px;
}

.purchase-page .purchase-dev-customer-row {
  margin-top: 10px;
}

.purchase-page .purchase-dev-customer-row label {
  display: grid;
  gap: 6px;
  color: #4c6270;
  font-size: 12px;
  font-weight: 700;
}

.purchase-page .purchase-dev-customer-row select {
  width: min(360px, 100%);
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 12px;
  background: #fff;
  color: #223743;
  font-size: 14px;
}

.purchase-page .purchase-auth-card {
  margin: 0 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfcfc;
  padding: 10px 12px;
}

.purchase-page .purchase-auth-card summary {
  cursor: pointer;
  font-weight: 800;
  color: #2f4450;
  list-style: none;
}

.purchase-page .purchase-auth-card summary::-webkit-details-marker {
  display: none;
}

.purchase-page .purchase-auth-card[open] summary {
  margin-bottom: 10px;
}

.purchase-page.purchase-linked .purchase-auth-card {
  display: none;
}

.purchase-page.purchase-linked #purchaseLinkHint {
  display: none;
}

.purchase-page .mini-session-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.purchase-page .session-label {
  margin: 0 0 4px;
  color: #6a7c86;
  font-size: 11px;
  font-weight: 700;
}

.purchase-page .mini-session strong {
  display: block;
  font-size: 14px;
  line-height: 1.35;
  color: #233742;
}

.purchase-page .purchase-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.purchase-page .purchase-list-head h2 {
  margin: 0;
  font-size: 18px;
}

.purchase-page .mini-products {
  display: grid;
  gap: 0;
}

.purchase-page .mini-product-card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 12px;
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 12px 0;
}

.purchase-page .mini-product-card:first-child {
  border-top: 0;
  padding-top: 0;
}

.purchase-page .product-thumb {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f5fbff, #e3edf3);
  background-position: center;
  background-size: cover;
  display: grid;
  place-items: center;
  color: #607785;
  font-size: 12px;
  font-weight: 700;
}

.purchase-page .product-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.purchase-page .product-thumb-placeholder-icon {
  width: 24px;
  height: 18px;
  border: 2px solid #7e95a5;
  border-radius: 4px;
  position: relative;
  display: block;
  margin: 0 auto 5px;
  box-sizing: border-box;
}

.purchase-page .product-thumb-placeholder-icon::before {
  content: "";
  position: absolute;
  left: 3px;
  bottom: 3px;
  width: 8px;
  height: 6px;
  background: #7e95a5;
  clip-path: polygon(0 100%, 45% 35%, 65% 60%, 100% 0, 100% 100%);
}

.purchase-page .product-thumb-placeholder-icon::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 4px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #7e95a5;
}

.purchase-page .product-thumb-placeholder-text {
  display: block;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.2;
  color: #6b7f8d;
  text-align: center;
  letter-spacing: 0.02em;
}

.purchase-page .product-main .name {
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
}

.purchase-page .qty-badge {
  margin: 4px 0 0;
  text-align: left;
  color: #6a7c86;
  font-size: 11px;
  font-weight: 700;
}

.purchase-page .price {
  font-size: 18px;
  font-weight: 800;
  color: #d26b2f;
  line-height: 1.25;
  margin: 4px 0;
}

.purchase-page .desc {
  margin: 0;
  font-size: 12px;
  color: #6a7c86;
  line-height: 1.35;
}

.purchase-page .actions-side {
  display: grid;
  align-content: center;
  min-width: 140px;
}

.purchase-page .line-actions {
  display: grid;
  grid-template-columns: 82px 48px;
  gap: 8px;
  align-items: center;
}

.purchase-page .qty-input,
.purchase-page .add-btn {
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-weight: 700;
}

.purchase-page .qty-input {
  padding: 0 8px;
  background: #fff;
}

.purchase-page .add-btn {
  border: 0;
  background: linear-gradient(135deg, #f08b46, #d2641b);
  color: #fff;
}

.purchase-page .history {
  margin: 0;
}

.purchase-page .history summary {
  cursor: pointer;
  font-weight: 700;
}

.purchase-page .history-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding: 12px 0;
  align-items: flex-start;
}

.purchase-page .history-main {
  min-width: 0;
  flex: 1;
}

.purchase-page .history-main-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.purchase-page .history-main p {
  margin: 4px 0 0;
}

.purchase-page .history-subline {
  color: #5f727f;
  font-size: 12px;
}

.purchase-page .history-meta-row {
  color: #465864;
  font-size: 13px;
}

.purchase-page .history-note {
  color: #b45309;
  font-size: 12px;
}

.purchase-page .history-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef4ff;
  color: #315ea8;
  border: 1px solid #d7e4ff;
  font-size: 12px;
  font-weight: 800;
}

.purchase-page .history-status.is-neutral {
  background: #eef4ff;
  color: #315ea8;
  border-color: #d7e4ff;
}

.purchase-page .history-status.is-accepted {
  background: #ecfdf3;
  color: #166534;
  border-color: #bbf7d0;
}

.purchase-page .history-status.is-attention {
  background: #fff7ed;
  color: #b45309;
  border-color: #fed7aa;
}

.purchase-page .history-status.is-cancelled {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.purchase-page .history-row .right {
  text-align: right;
  white-space: nowrap;
  padding-top: 10px;
}

.purchase-page .history-row .right p {
  margin: 0;
}

.purchase-page .history-amount-label {
  color: #6b7d88;
  font-size: 11px;
  font-weight: 700;
}

.purchase-page .history-amount-value {
  color: #12222d;
  font-size: 18px;
  font-weight: 800;
  margin-top: 2px;
}

.purchase-page .empty-card {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 18px;
  color: #5f727f;
  background: #fbfcfc;
}

.purchase-page .sticky-order-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(18, 28, 34, 0.94);
  color: #fff;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.purchase-page .sticky-order-bar .label {
  color: #b9c5cc;
  font-size: 11px;
}

.purchase-page .sticky-order-bar strong {
  font-size: 18px;
}

.purchase-page .bar-actions {
  display: flex;
  gap: 8px;
}

.purchase-page .bar-actions .btn {
  width: auto;
  padding: 10px 12px;
  border-radius: 10px;
}

.purchase-page .purchase-confirm-card {
  width: min(360px, 100%);
  text-align: center;
  border-radius: 16px;
}

.purchase-page .purchase-link-modal-card {
  width: min(760px, calc(100vw - 32px));
  max-height: min(88vh, 760px);
  overflow-y: auto;
  border-radius: 16px;
}

.purchase-page .purchase-notice-modal-card,
.purchase-page .purchase-notice-detail-card {
  width: min(720px, calc(100vw - 32px));
  max-height: min(88vh, 760px);
  overflow-y: auto;
  border-radius: 16px;
}

.purchase-page #purchaseCloseNoticeModal,
.purchase-page #purchaseCloseNoticeDetailModal {
  display: none;
}

.purchase-page .purchase-notice-list {
  display: grid;
}

.purchase-page .purchase-notice-row {
  border: 0;
  border-top: 1px solid var(--border);
  background: #fff;
  padding: 14px 0;
  text-align: left;
  cursor: pointer;
  display: grid;
  gap: 4px;
}

.purchase-page .purchase-notice-row:first-child {
  border-top: 0;
}

.purchase-page .purchase-notice-row-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.purchase-page .purchase-notice-row-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.purchase-page .purchase-notice-row-type,
.purchase-page .purchase-notice-type {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #475569;
  font-size: 11px;
  font-weight: 700;
}

.purchase-page .purchase-notice-row-title {
  font-size: 15px;
  font-weight: 700;
  color: #223743;
}

.purchase-page .purchase-notice-row-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}

.purchase-page .purchase-notice-row.unread .purchase-notice-row-title {
  color: #0f2f4f;
}

.purchase-page .purchase-notice-row-date {
  flex: 0 0 auto;
  font-size: 12px;
  color: #6a7c86;
}

.purchase-page .purchase-notice-body {
  white-space: normal;
  line-height: 1.7;
  color: #223743;
}

.purchase-page .purchase-notice-image {
  margin: 8px 0 16px;
  border: 1px solid #dbe4f0;
  border-radius: 12px;
  overflow: hidden;
  background: #f8fbff;
}

.purchase-page .purchase-notice-image img {
  display: block;
  width: 100%;
  height: auto;
}

.purchase-page .purchase-notice-footer {
  display: flex;
  justify-content: center;
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid #e5edf4;
}

.purchase-page .confirm-icon {
  width: 52px;
  height: 52px;
  border-radius: 999px;
  margin: 2px auto 14px;
  border: 2px solid #f2c19a;
  background: #fff7f1;
  color: #d97706;
  font-size: 28px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.purchase-page .confirm-line {
  margin: 6px 0;
  font-weight: 700;
  color: #2f4450;
  text-align: center;
}

.purchase-page .confirm-items {
  display: grid;
  gap: 0;
  margin: 14px 0 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  text-align: left;
}

.purchase-page .confirm-item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 12px 14px;
  background: #f8fafc;
  border-top: 1px solid var(--border);
}

.purchase-page .confirm-item-row:first-child {
  border-top: 0;
}

.purchase-page .confirm-item-main,
.purchase-page .confirm-item-side {
  display: grid;
  gap: 4px;
}

.purchase-page .confirm-item-side {
  text-align: right;
  justify-items: end;
}

.purchase-page .confirm-item-name,
.purchase-page .confirm-item-qty {
  font-size: 14px;
  font-weight: 700;
  color: #223743;
}

.purchase-page .confirm-item-unit-price,
.purchase-page .confirm-item-subtotal {
  font-size: 12px;
  color: #5b7080;
  line-height: 1.45;
}

.purchase-page .confirm-question {
  margin: 14px 0 12px;
  font-weight: 700;
  color: #2f4450;
  text-align: center;
}

.purchase-page .confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.purchase-page .confirm-actions .btn {
  width: 100%;
}

@media (max-width: 420px) {
  .purchase-page .price {
    font-size: 15px;
  }

  .purchase-page .line-actions {
    grid-template-columns: 64px 40px;
  }

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

@media (max-width: 760px) {
  .purchase-page .purchase-shell {
    width: min(100%, calc(100% - 16px));
    padding: 10px 0 14px;
  }

  .purchase-page .purchase-section {
    padding: 12px;
  }

  .purchase-page .mini-product-card {
    grid-template-columns: 60px minmax(0, 1fr);
  }

  .purchase-page .product-thumb {
    width: 60px;
    height: 60px;
  }

  .purchase-page .actions-side {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .purchase-page .qty-badge {
    text-align: right;
  }
}

@media (max-width: 1180px) {
  .app {
    width: min(1080px, calc(100vw - 24px));
  }

  .topbar {
    grid-template-columns: 1fr;
    justify-items: stretch;
  }

  .tabs {
    justify-content: flex-start;
  }

  .topbar-ops {
    grid-template-columns: 1fr auto;
    justify-items: stretch;
    align-items: end;
  }

  .operator-field {
    width: 100%;
  }

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

  .composer-card {
    position: relative;
    top: auto;
  }

  .monitor-card {
    min-height: 0;
  }
}

@media (max-width: 760px) {
  body::before {
    display: none;
  }

  .app {
    width: calc(100vw - 16px);
    margin: 8px auto 20px;
  }

  .topbar {
    top: 6px;
    gap: 14px;
    padding: 18px;
    border-radius: 24px;
  }

  h1 {
    font-size: 28px;
  }

  h2 {
    font-size: 24px;
  }

  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    padding-bottom: 2px;
  }

  .topbar-ops {
    grid-template-columns: 1fr;
  }

  .status-row {
    justify-content: space-between;
  }

  .card {
    padding: 18px;
    border-radius: 20px;
  }

  .field-grid,
  .detail-grid,
  .detail-head-grid {
    grid-template-columns: 1fr;
  }

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

  .audit-table-wrap {
    height: auto;
    max-height: none;
  }

  #productRows {
    grid-template-columns: 1fr;
  }

  #productRows.list-view {
    display: block;
  }

  .product-card {
    gap: 12px;
  }

  .product-card-body {
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 12px;
  }

  .product-thumb {
    width: 64px;
    height: 64px;
    border-radius: 14px;
  }

  .product-side-actions {
    justify-content: flex-start;
  }

  .view-toggle {
    width: 100%;
    justify-content: stretch;
  }

  .view-toggle-btn {
    flex: 1 1 0;
    text-align: center;
  }

  .product-list-table th,
  .product-list-table td {
    padding: 10px 12px;
  }

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

  .product-price {
    flex-direction: column;
    gap: 2px;
    align-items: flex-start;
  }

  .purchase-item {
    grid-template-columns: 52px 1fr auto;
  }

  .filters,
  .bulk-toolbar,
  .toolbar-left,
  .cta-row,
  .action-pack,
  .section-row,
  .card-head,
  .monitor-head,
  .list-head {
    flex-direction: column;
    align-items: stretch;
  }

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

  .factory-slip-filter-bar {
    grid-template-columns: 1fr;
  }

  .order-filter-meta {
    width: 100%;
  }

  .factory-slip-filter-meta {
    width: 100%;
  }

  .order-filter-meta .mini-select,
  .order-filter-meta .mini-input.date,
  .factory-slip-filter-meta .mini-select,
  .factory-slip-filter-meta .mini-input.date {
    width: 100%;
    min-width: 0;
  }

  .fixed-products-wrap {
    max-height: none;
  }

  .category-inline {
    grid-template-columns: 1fr;
  }
}










@media (max-width: 760px) {
  .field-span-2 {
    grid-column: span 1;
  }

  .product-detail-media {
    grid-template-columns: 1fr;
  }

  .product-detail-preview {
    width: 100%;
    max-width: 180px;
  }
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin-top: 8px;
}

.compact-checkbox-grid {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}

.checkbox-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.checkbox-chip input {
  margin: 0;
}
