/**
 * ThreadLAB Workbench - 全局样式 V6
 * 设计语言：极简 · 高级 · 白灰系统
 */

/* ====== Design Tokens ====== */
:root {
  /* Surface */
  --bg-page: #f7f7f8;
  --bg-surface: #ffffff;
  --bg-elevated: #ffffff;
  --bg-inset: #f4f4f5;
  --bg-hover: #f4f4f5;
  --bg-active: #ececec;

  /* Text */
  --text-primary: #18181b;
  --text-secondary: #52525b;
  --text-tertiary: #a1a1aa;
  --text-inverse: #ffffff;

  /* Border */
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --border-focus: #71717a;

  /* Accent */
  --accent: #18181b;
  --accent-hover: #3f3f46;
  --accent-subtle: #f4f4f5;

  /* Semantic */
  --color-danger: #dc2626;
  --color-success: #16a34a;
  --btn-danger-hover: #fef2f2;
  --btn-success-hover: #f0fdf4;

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;

  /* Radius */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  /* Transition */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  /* Nav */
  --nav-divider: #e4e4e7;
  --nav-icon: #71717a;

  /* Glass */
  --glass-bg: rgba(255, 255, 255, 0.8);
  --glass-blur: 12px;
}

/* ====== Reset ====== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

/* ====== App Shell ====== */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  background: var(--bg-page);
}

/* ====== Topbar ====== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--sp-4);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  height: 44px;
  flex-shrink: 0;
  z-index: 100;
  position: relative;
}
.topbar-left {
  position: absolute;
  left: var(--sp-3);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
}
.topbar-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
  white-space: nowrap;
  text-align: center;
  letter-spacing: -0.02em;
}
.topbar-right {
  position: absolute;
  right: var(--sp-3);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

/* Language switch */
.lang-switch {
  display: flex;
  background: var(--bg-inset);
  border-radius: var(--radius-full);
  padding: 2px;
  font-size: 12px;
}
.lang-switch span {
  padding: 3px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  color: var(--text-tertiary);
  transition: all 0.15s var(--ease);
  font-weight: 500;
}
.lang-switch span.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

/* ====== Content ====== */
.content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0;
  padding-bottom: 16px;
}

/* ====== Navigation ====== */
.avatar-menu { position: static; flex-shrink: 0; }
.avatar-menu-trigger {
  width: 32px; height: 32px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; position: relative; z-index: 310;
  outline: none !important; border: 1px solid var(--border); padding: 0;
  background: var(--bg-surface) !important;
  transition: border-color 0.15s var(--ease);
}
.avatar-menu-trigger:hover { border-color: var(--border-strong); }
.avatar-menu-trigger::before {
  content: '';
  position: absolute; left: 50%; top: 50%;
  width: 16px; height: 2px;
  background: var(--text-primary); border-radius: 1px;
  transform: translate(-50%, calc(-50% - 5px));
  box-shadow: 0 6px 0 var(--text-primary), 0 12px 0 var(--text-primary);
  pointer-events: none;
}
.avatar-menu-trigger:focus,
.avatar-menu-trigger:focus-visible,
.avatar-menu-trigger:active,
.avatar-menu-trigger:hover {
  background: var(--bg-surface) !important;
  outline: none !important; box-shadow: none !important;
}
#avatarTrigger { background: var(--bg-surface) !important; }
#avatarTrigger:focus,
#avatarTrigger:focus-visible,
#avatarTrigger:active,
#avatarTrigger:hover {
  background: var(--bg-surface) !important;
  outline: none !important; box-shadow: none !important;
}
.avatar-dropdown-overlay {
  display: none; position: fixed; inset: 0;
  z-index: 400; background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(2px);
}
.avatar-dropdown {
  position: fixed; top: 44px; left: 0;
  width: 220px; max-width: 220px;
  height: auto; max-height: calc(100vh - 44px); overflow-y: auto;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  z-index: 500;
  display: none; flex-direction: column;
}
.nav-user {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.1s;
}
.nav-user:hover { background: var(--bg-hover); }
.nav-avatar {
  width: 28px; height: 28px; border-radius: var(--radius);
  overflow: hidden; flex-shrink: 0;
  background: var(--bg-inset);
  display: flex; align-items: center; justify-content: center;
}
.nav-avatar img { width: 100%; height: 100%; object-fit: cover; }
.nav-avatar svg { width: 14px; height: 14px; color: var(--nav-icon); }
.nav-user-name {
  font-size: 13px; font-weight: 500; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dropdown-items {
  overflow-y: auto; padding: var(--sp-1) 0; flex-shrink: 1; min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; padding: 10px var(--sp-4);
  font-size: 13px; font-weight: 500; color: var(--text-secondary);
  background: transparent;
  border: none; border-bottom: 1px solid var(--nav-divider);
  text-align: left; cursor: pointer;
  outline: none;
  transition: background 0.1s, color 0.1s;
}
.nav-item:last-child { border-bottom: none; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--nav-icon); }
.nav-item span { line-height: 1.3; }
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item:hover svg { color: var(--text-primary); }
.nav-item:focus,
.nav-item:focus-visible { outline: none; }
.nav-item:active { background: var(--bg-active); }
.nav-item:disabled { opacity: 0.35; display: none; }
.nav-item, .nav-item * { -webkit-tap-highlight-color: rgba(0,0,0,0) !important; }
.nav-badge { color: var(--color-danger); font-size: 12px; font-weight: 600; margin-left: 2px; }
.nav-theme {
  display: flex; gap: var(--sp-5);
  padding: var(--sp-3) var(--sp-4) var(--sp-3);
  border-top: 1px solid var(--border);
  justify-content: center; flex-shrink: 0;
}
.theme-btn {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  cursor: pointer; color: var(--text-tertiary); outline: none; padding: 0;
  transition: all 0.15s var(--ease);
}
.theme-btn.active { background: var(--accent); color: var(--text-inverse); border-color: var(--accent); }
.theme-btn:hover { background: var(--bg-hover); }
.theme-btn.active:hover { background: var(--accent-hover); }
.theme-btn svg { width: 14px; height: 14px; }

/* ====== Cards ====== */
.card {
  background: var(--bg-surface);
  border-radius: var(--radius);
  padding: var(--sp-4);
  margin: var(--sp-2) var(--sp-4);
  border: 1px solid var(--border);
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: var(--sp-3);
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

/* ====== Buttons ====== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s var(--ease);
  white-space: nowrap;
  background: var(--bg-surface);
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn:active { background: var(--bg-active); }
.btn-primary { background: var(--text-primary); color: var(--text-inverse); border-color: var(--text-primary); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-secondary { background: var(--bg-surface); color: var(--text-secondary); }
.btn-danger { background: var(--bg-surface); color: var(--color-danger); border-color: var(--color-danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-success { background: var(--bg-surface); color: var(--color-success); border-color: var(--color-success); }
.btn-success:hover { background: #f0fdf4; }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

/* ====== Forms ====== */
.form-group { margin-bottom: var(--sp-4); }
.factory-contact-row { display: none; gap: 12px; padding: 8px 12px; background: var(--bg-inset); border-radius: var(--radius); margin-top: -8px; margin-bottom: var(--sp-4); }
.factory-contact-row input { background: transparent; border: none; padding: 4px 0; font-size: 13px; color: var(--text-primary); width: 100%; outline: none; }
.factory-contact-row input:read-only { color: var(--text-secondary); }
.factory-contact-row label { font-size: 11px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.03em; display: block; margin-bottom: 2px; }
.form-label {
  display: block;
  margin-bottom: var(--sp-1);
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.form-label .required { color: var(--color-danger); }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s var(--ease);
  font-family: inherit;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--border-focus);
}
.form-input::placeholder, .form-textarea::placeholder {
  color: var(--text-tertiary);
}
.form-select option, .filter-select option { background: var(--bg-surface); color: var(--text-primary); }
.custom-select { position: relative; }
.custom-select-trigger {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 8px 12px;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary);
  font-size: 13px; cursor: pointer; user-select: none;
  transition: border-color 0.15s var(--ease);
}
.custom-select-trigger:hover { border-color: var(--border-strong); }
.custom-select-trigger::after { content: '▾'; font-size: 10px; color: var(--text-tertiary); margin-left: 8px; }
.custom-select-dropdown {
  display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 100;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-top: var(--sp-1);
  max-height: 200px; overflow-y: auto; box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.custom-select-item {
  padding: 8px 12px; font-size: 13px; color: var(--text-primary);
  cursor: pointer; transition: background 0.1s;
}
.custom-select-item:hover { background: var(--bg-hover); }
.custom-select-item-disabled { color: var(--text-tertiary); cursor: not-allowed; }
.custom-select-item-disabled:hover { background: transparent; }
.form-textarea { min-height: 72px; resize: vertical; line-height: 1.5; }
.form-row { display: flex; gap: var(--sp-3); }
.form-row > * { flex: 1; }

/* ====== Lists ====== */
.list-item {
  background: var(--bg-surface);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.list-item:hover { background: var(--bg-hover); }
.list-item-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.list-item-sub {
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

/* ====== Tags ====== */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  background: var(--bg-surface);
  letter-spacing: 0.01em;
}
.tag-draft, .tag-pending, .tag-processing, .tag-completed,
.tag-suspended, .tag-abnormal, .tag-canceled {
  border-color: var(--border);
  color: var(--text-secondary);
}

/* ====== Tabs ====== */
.tabs {
  display: flex;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab {
  padding: 10px var(--sp-4);
  font-size: 13px;
  color: var(--text-tertiary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all 0.15s var(--ease);
  font-weight: 500;
}
.tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--text-primary);
}
.tab:hover { color: var(--text-secondary); }

/* ====== Modal ====== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--sp-5);
}
.modal-box {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 400px;
  max-height: 85vh;
  overflow-y: auto;
  padding: var(--sp-5);
  border: 1px solid var(--border);
  animation: modalIn 0.2s var(--ease);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-4);
  font-size: 16px;
  font-weight: 600;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { cursor: pointer; font-size: 18px; color: var(--text-tertiary); }
.modal-body { margin-bottom: var(--sp-4); }
.modal-footer { display: flex; gap: var(--sp-2); justify-content: flex-end; }
.modal-footer .btn { min-width: 72px; }

/* ====== Timeline ====== */
.timeline { padding: 0 var(--sp-4); }
.timeline-item {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-strong);
  margin-top: 6px;
  flex-shrink: 0;
}
.timeline-content { flex: 1; min-width: 0; }
.timeline-action { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.timeline-meta { display: flex; gap: var(--sp-3); flex-wrap: wrap; font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
.timeline-remark { font-size: 12px; color: var(--text-secondary); margin-top: var(--sp-1); padding: var(--sp-2) var(--sp-3); background: var(--bg-inset); border-radius: var(--radius-sm); }
.timeline-handler { font-size: 12px; color: var(--text-tertiary); }
.timeline-images { display: flex; gap: var(--sp-2); margin-top: var(--sp-2); flex-wrap: wrap; }
.timeline-images img { width: 56px; height: 56px; object-fit: cover; border-radius: var(--radius-sm); cursor: pointer; border: 1px solid var(--border); }
.timeline-item-flex { display: flex; gap: var(--sp-3); align-items: flex-start; }
.timeline-item-flex .timeline-content { flex: 1; }
.timeline-images-right { display: flex; gap: var(--sp-2); flex-wrap: wrap; min-width: 56px; }
.timeline-images-right img { width: 56px; height: 56px; object-fit: cover; border-radius: var(--radius-sm); cursor: pointer; border: 1px solid var(--border); }
.timeline-date { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }
.timeline-deadline { font-size: 12px; color: var(--text-secondary); margin-top: var(--sp-1); padding: var(--sp-1) var(--sp-2); background: var(--bg-inset); border-radius: var(--radius-sm); display: inline-block; }

/* ====== Tables ====== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  background: var(--bg-inset);
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

/* ====== Filter Bar ====== */
.filter-bar {
  padding: var(--sp-2) var(--sp-4);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  align-items: center;
}
.sort-bar {
  padding: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.order-select-toolbar {
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.order-select-item {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  margin: var(--sp-2) var(--sp-4);
}
.order-select-item .order-card {
  margin: 0;
  flex: 1;
  min-width: 0;
}
.order-select-item .order-select-cb {
  margin-top: 14px;
  flex-shrink: 0;
  display: none;
}
.order-select-item.show-cb .order-select-cb {
  display: inline-block;
}
.doc-select-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: var(--sp-2) var(--sp-4);
}
.doc-select-item .doc-select-cb {
  display: none;
}
.doc-select-item.show-cb .doc-select-cb {
  display: inline-block;
}
.doc-select-cb {
  margin-top: 14px;
  flex-shrink: 0;
}
.filter-input {
  width: 160px;
  max-width: 200px;
  padding: 6px 10px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s var(--ease);
}
.filter-input:focus { border-color: var(--border-focus); }
.filter-input.filter-input-wide {
  width: 200px;
  max-width: 260px;
}
.filter-date {
  width: 140px;
  padding: 6px 8px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
}
.filter-select {
  padding: 6px 8px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
  min-width: 120px;
}
.filter-label {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  margin-right: -4px;
}

/* ====== Pagination ====== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  padding: var(--sp-3) var(--sp-4);
  flex-wrap: wrap;
}
.pagination button {
  padding: 4px 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  min-width: 28px;
  transition: all 0.1s;
}
.pagination button:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.pagination button.active { background: var(--text-primary); color: var(--text-inverse); border-color: var(--text-primary); }
.pagination button:disabled { opacity: 0.3; cursor: not-allowed; }
.pagination select {
  padding: 3px 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
}
.pagination-info {
  font-size: 12px;
  color: var(--text-tertiary);
  padding: 0 var(--sp-2);
}

/* ====== Upload Area ====== */
.upload-area {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-2);
}
.upload-item {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-inset);
  border: 1px solid var(--border);
}
.upload-item img { width: 100%; height: 100%; object-fit: cover; }
.upload-item { position: relative; }
.upload-item .remove {
  position: absolute;
  top: 2px; right: 2px;
  width: 18px; height: 18px;
  background: rgba(0,0,0,0.5);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  font-size: 10px;
  opacity: 0.7;
  transition: opacity 0.15s;
  z-index: 3;
}
.upload-item:hover .remove { opacity: 1; }

/* File upload items */
.upload-file-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 8px;
  background: var(--bg-inset);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.upload-file-item .file-icon { font-size: 20px; flex-shrink: 0; }
.upload-file-item .file-name {
  flex: 1; font-size: 12px; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.upload-file-item .file-download { color: var(--text-tertiary); cursor: pointer; font-size: 16px; flex-shrink: 0; }
.upload-file-item .remove {
  position: static;
  width: 18px; height: 18px;
  background: var(--bg-active);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 10px;
  flex-shrink: 0;
}

.upload-add {
  width: 100%;
  aspect-ratio: 1;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-tertiary);
  font-size: 24px;
  transition: border-color 0.15s var(--ease), color 0.15s;
}
.upload-add:hover { border-color: var(--text-tertiary); color: var(--text-secondary); }
.upload-area.drag-over { outline: 3px dashed var(--accent); outline-offset: 4px; border-radius: var(--radius-sm); }

/* 附件上传区竖向布局 */
.upload-area-attachment {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.upload-area-attachment .upload-add {
  width: 100%;
  height: 48px;
  min-height: 48px;
  aspect-ratio: auto;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-tertiary);
  font-size: 24px;
  transition: border-color 0.15s var(--ease), color 0.15s;
}
.upload-area-attachment .upload-add:hover { border-color: var(--text-tertiary); color: var(--text-secondary); }

/* ====== Multi-select ====== */
.multi-select { position: relative; }
.multi-select-trigger {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-surface); cursor: pointer; min-height: 38px;
  font-size: 13px;
  transition: border-color 0.15s var(--ease);
}
.multi-select-trigger:hover { border-color: var(--border-strong); }
.multi-select-placeholder { color: var(--text-tertiary); font-size: 13px; }
.multi-select-arrow { font-size: 10px; color: var(--text-tertiary); margin-left: 8px; }
.multi-select-drop {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 1000;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-top: var(--sp-1);
  max-height: 260px; overflow: hidden; box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}
.multi-select-search { padding: var(--sp-2); border-bottom: 1px solid var(--border); }
.multi-select-search input {
  width: 100%; padding: 6px 8px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg-inset); color: var(--text-primary);
  font-size: 12px; outline: none; box-sizing: border-box;
}
.multi-select-search input:focus { border-color: var(--border-focus); }
.multi-select-options { max-height: 180px; overflow-y: auto; padding: var(--sp-1) 0; }
.multi-select-option {
  display: flex; align-items: center; gap: var(--sp-2); padding: 6px 12px;
  cursor: pointer; font-size: 13px; color: var(--text-primary);
  transition: background 0.1s;
}
.multi-select-option:hover { background: var(--bg-hover); }
.multi-select-option input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--accent); margin: 0; cursor: pointer; }
.multi-select-footer {
  padding: var(--sp-2) var(--sp-3); border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-tertiary);
}

/* ====== Draft actions ====== */
.draft-actions {
  display: flex; gap: var(--sp-2); margin-top: var(--sp-3); padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
}
.draft-actions .btn { font-size: 12px; padding: 4px 12px; }
.btn-xs { font-size: 11px; padding: 3px 6px; min-width: auto; }
.admin-item-actions { display: flex; gap: var(--sp-1); flex-shrink: 0; }
.admin-item-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }

/* ====== Detail Page ====== */
.detail-actions { padding: var(--sp-4) 0; }
.detail-actions-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}
.detail-action-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px var(--sp-2);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  text-align: center;
  transition: all 0.12s var(--ease);
  white-space: nowrap;
}
.detail-action-btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.detail-action-btn:disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }
.detail-action-btn.primary { background: var(--text-primary); color: var(--text-inverse); border-color: var(--text-primary); }
.detail-action-btn.action-red { background: var(--bg-surface); color: var(--text-primary); border-color: var(--border); }
.detail-action-btn.btn-block { display: block; width: 100%; }

/* ====== Icon Grid ====== */
.icon-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin: var(--sp-2) var(--sp-4);
  background: var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.icon-grid-item {
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-5) var(--sp-2);
  cursor: pointer;
  transition: background 0.12s;
  aspect-ratio: 1;
}
.icon-grid-item:hover { background: var(--bg-hover); }
.icon-grid-item svg { width: 24px; height: 24px; color: var(--text-secondary); }
.icon-grid-item span { font-size: 11px; color: var(--text-tertiary); text-align: center; }
.icon-grid-item.disabled { opacity: 0.4; }

/* ====== Toast ====== */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(24, 24, 27, 0.88);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 2000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s var(--ease);
  max-width: 80%;
  text-align: center;
  backdrop-filter: blur(8px);
}
.toast.show { opacity: 1; }

/* ====== Empty State ====== */
.empty-state {
  text-align: center;
  padding: 48px var(--sp-5);
  color: var(--text-tertiary);
  font-size: 13px;
}
.empty-state svg { width: 40px; height: 40px; margin-bottom: var(--sp-3); opacity: 0.4; }

/* ====== FAB ====== */
.fab {
  position: fixed;
  bottom: 100px;
  right: 20px;
  z-index: 50;
  border-radius: var(--radius);
  width: 48px;
  height: 48px;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--text-primary);
  color: var(--text-inverse);
  border: none;
  cursor: pointer;
  transition: transform 0.15s var(--ease), opacity 0.15s;
}
.fab:hover { transform: scale(1.05); }
.fab:active { transform: scale(0.95); }

/* ====== Page ====== */
.page { padding: 0 0 80px; }
.page-actions { padding: var(--sp-2) var(--sp-4); display: flex; gap: var(--sp-2); flex-wrap: wrap; }

/* ====== Order Card ====== */
.order-list { display: flex; flex-direction: column; }
.order-card {
  background: var(--bg-surface);
  border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-4);
  margin: var(--sp-2) var(--sp-4);
  cursor: pointer;
  transition: background 0.1s;
  border: 1px solid var(--border);
}
.order-card:hover { background: var(--bg-hover); }
.order-card:active { background: var(--bg-active); }
.order-card-del-btn { margin-top: var(--sp-2); font-size: 12px; padding: 2px 10px; }
.order-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-2);
}
.order-no { font-weight: 600; font-size: 14px; color: var(--text-primary); letter-spacing: -0.01em; }
.order-card-info {
  display: flex;
  gap: var(--sp-4);
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: var(--sp-1);
  flex-wrap: wrap;
}
.order-card-bottom {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-tertiary);
}
.order-card-deadline {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: var(--sp-1);
  padding-top: var(--sp-1);
  border-top: 1px solid var(--border);
}
.order-card-deadline.order-deadline-overdue { color: var(--color-danger); font-weight: 600; }

/* ====== Enhanced Order Card (V2) ====== */
.order-card-enhanced {
  padding: var(--sp-5);
  margin: var(--sp-2) var(--sp-4);
}
.order-card-enhanced .ord-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--sp-1);
}
.order-card-enhanced .ord-customer-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.4;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: var(--sp-2);
}
.order-card-enhanced .ord-status-wrap {
  flex-shrink: 0;
}
.order-card-enhanced .ord-product-name {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: var(--sp-3);
  line-height: 1.4;
}
.order-card-enhanced .ord-divider {
  height: 1px;
  background: var(--border);
  margin: var(--sp-3) 0;
  opacity: 0.6;
}
.order-card-enhanced .ord-info-grid {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.order-card-enhanced .ord-info-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 14px;
  line-height: 1.4;
}
.order-card-enhanced .ord-row-icon {
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  font-size: 13px;
  opacity: 0.8;
}
.order-card-enhanced .ord-row-label {
  color: var(--text-tertiary);
  min-width: 64px;
  flex-shrink: 0;
  font-size: 13px;
}
.order-card-enhanced .ord-row-value {
  color: var(--text-primary);
  font-weight: 500;
  min-width: 0;
}
.order-card-enhanced .ord-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.order-card-enhanced .ord-order-id {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 400;
  letter-spacing: -0.01em;
}
.order-card-enhanced .ord-deadline {
  font-size: 12px;
  color: var(--text-tertiary);
}
.order-card-enhanced .ord-deadline.ord-deadline-overdue {
  color: var(--color-danger);
  font-weight: 600;
}
.order-card-enhanced .ord-menu {
  position: relative;
  flex-shrink: 0;
  margin-left: auto;
}
.order-card-enhanced .ord-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: var(--text-tertiary);
  letter-spacing: 0;
  user-select: none;
  transition: background 0.1s;
}
.order-card-enhanced .ord-menu-btn:hover { background: var(--bg-hover); }
.order-card-enhanced .ord-menu-btn:active { background: var(--bg-active); }
.order-card-enhanced .ord-menu-drop {
  position: absolute;
  right: 0;
  bottom: 100%;
  margin-bottom: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  min-width: 100px;
  z-index: 10;
  overflow: hidden;
}
.order-card-enhanced .ord-menu-item {
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s;
}
.order-card-enhanced .ord-menu-item:hover { background: var(--bg-hover); }
.order-card-enhanced .ord-menu-item.ord-menu-danger { color: var(--color-danger); }
.order-card-enhanced .draft-actions {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
  align-items: center;
}
.order-card-enhanced .draft-actions .btn {
  font-size: 13px;
  padding: 6px 14px;
}
.order-card-enhanced .draft-actions .btn-primary {
  flex: 1;
}

/* ====== Detail Page ====== */
.detail-page { padding-bottom: 80px; }
.detail-header {
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}
.detail-order-no { font-size: 17px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.02em; }
.detail-status { display: flex; align-items: center; }
.detail-actions-top {
  padding: var(--sp-2) var(--sp-4);
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}
.detail-section {
  background: var(--bg-surface);
  margin: var(--sp-2) var(--sp-4);
  border-radius: var(--radius);
  padding: var(--sp-4);
  border: 1px solid var(--border);
}
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--sp-3);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.detail-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}
.detail-info-grid > div { display: flex; flex-direction: column; gap: 2px; }
.detail-info-grid label { font-size: 11px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.03em; }
.detail-info-grid span { font-size: 13px; color: var(--text-primary); word-break: break-all; }
.detail-text { font-size: 13px; color: var(--text-primary); line-height: 1.6; white-space: pre-wrap; }

/* ====== Image Grid ====== */
.image-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}
.grid-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid var(--border);
  transition: opacity 0.15s;
}
.grid-img:hover { opacity: 0.85; }
.image-grid-item { display: flex; flex-direction: column; }

/* ====== Upload image cards ====== */
#create-images-upload, #form-images-upload {
  display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: flex-start;
}
.upload-image-card { width: 96px; flex-shrink: 0; position: relative; }
.upload-image-card .upload-item { width: 96px; height: 96px; aspect-ratio: auto; margin-bottom: 0; }
.upload-image-card .mini-input { width: 100%; font-size: 11px; padding: 3px 5px; }
.upload-image-card.drag-over { opacity: 0.6; }
.upload-image-card[draggable="true"] { cursor: grab; }
.upload-image-card[draggable="true"]:active { cursor: grabbing; }
.upload-image-card .rotate-btn {
  position: absolute; top: 0; right: 24px; z-index: 2;
  width: 20px; height: 20px;
  background: rgba(0,0,0,0.35);
  border-radius: 0 0 0 var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px; line-height: 1;
  cursor: pointer; user-select: none;
}
.upload-image-card .rotate-btn:hover { background: rgba(0,0,0,0.55); }
.upload-image-card[draggable="true"] .drag-handle {
  position: absolute; top: 0; left: 0; z-index: 2;
  width: 20px; height: 20px;
  background: rgba(0,0,0,0.35);
  border-radius: 0 var(--radius-sm) 0 var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px; line-height: 1;
  cursor: grab; user-select: none;
  touch-action: none;
}
.upload-image-card[draggable="true"] .drag-handle:active { cursor: grabbing; }
#create-images-upload .upload-add { width: 96px; height: 96px; aspect-ratio: auto; flex-shrink: 0; }

/* ====== Order card thumbnail ====== */
.order-card-enhanced .ord-info-row-wrap {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.order-card-enhanced .ord-info-row-wrap .ord-info-grid {
  flex: 1;
  min-width: 0;
}
.order-card-enhanced .card-thumb {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 2px;
}
.order-card-enhanced .card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: pointer;
}

/* ====== Attachment ====== */
.attachment-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.attachment-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 8px; background: var(--bg-inset); border-radius: var(--radius-sm);
  cursor: pointer; text-decoration: none; color: var(--text-primary);
  border: 1px solid var(--border);
  transition: background 0.1s;
}
.attachment-item:hover { background: var(--bg-hover); }
.attachment-name { flex: 1; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ====== Flow choice ====== */
.flow-choice-card {
  flex: 1; padding: var(--sp-4) var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--radius);
  text-align: center; cursor: pointer;
  transition: all 0.15s var(--ease);
}
.flow-choice-card:hover { border-color: var(--border-strong); background: var(--bg-hover); }

/* ====== Form sections ====== */
.form-section {
  background: var(--bg-surface); margin: var(--sp-2) var(--sp-4);
  border-radius: var(--radius); padding: var(--sp-4);
  border: 1px solid var(--border);
}
.form-actions { padding: var(--sp-4); display: flex; gap: var(--sp-2); justify-content: center; }
.form-actions .btn { flex: 1; }
.create-page { padding-bottom: 80px; }

/* ====== Data tables ====== */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  background: var(--bg-inset); padding: 6px 8px; text-align: center;
  font-weight: 600; color: var(--text-secondary); border-bottom: 1px solid var(--border);
  white-space: nowrap; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em;
}
.data-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); color: var(--text-primary); text-align: center; }
.data-table tr:hover { background: var(--bg-hover); }

/* ====== Mini inputs ====== */
.mini-input {
  width: 100%; max-width: 72px; padding: 5px 6px;
  background: var(--bg-inset); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: 12px; outline: none;
}
.mini-input:focus { border-color: var(--border-focus); }
.edit-input {
  width: 100%; max-width: 100%; padding: 8px 10px;
  background: var(--bg-inset); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary);
  font-size: 13px; outline: none; box-sizing: border-box;
}
.edit-input:focus { border-color: var(--border-focus); }

/* ====== Icon button ====== */
.btn-icon {
  background: none; border: none; color: var(--text-tertiary);
  cursor: pointer; font-size: 16px; padding: 2px 6px;
  border-radius: var(--radius-sm); transition: all 0.12s;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-secondary); }

/* ====== Grand total ====== */
.grand-total {
  margin-top: var(--sp-3); padding: 6px 10px;
  background: var(--bg-inset); border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; text-align: right;
}
.grand-total span { color: var(--text-primary); font-size: 16px; }

/* ====== Color card ====== */
.color-card {
  background: var(--bg-inset); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.color-card-header { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.color-card-header .color-select { flex: 1; min-width: 0; }
.color-card-label {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  flex-shrink: 0; min-width: 72px;
}
.color-card-header .btn-icon { flex-shrink: 0; }
.color-card-sizes { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.size-tag {
  display: flex; align-items: center;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 2px 2px 2px 6px; gap: 2px;
  min-width: 72px; flex: 0 1 auto;
}
.size-tag-label { font-size: 11px; font-weight: 600; color: var(--text-tertiary); min-width: 20px; text-align: center; }
.size-tag-input {
  width: 42px; padding: 2px 3px; border: none; background: transparent;
  font-size: 12px; text-align: center; color: var(--text-primary);
}
.size-tag-input:focus { outline: none; }
.color-card-total {
  text-align: right; font-size: 12px; color: var(--text-tertiary);
  padding-top: var(--sp-2); border-top: 1px solid var(--border);
}
.color-card-total strong { color: var(--text-primary); font-size: 13px; }

/* ====== CS Detail ====== */
.cs-detail-item {
  background: var(--bg-inset); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-2);
}
.cs-detail-color { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.cs-detail-sizes { font-size: 12px; color: var(--text-secondary); line-height: 1.6; }
.cs-detail-total { text-align: right; font-size: 12px; color: var(--text-secondary); }
.cs-detail-total strong { color: var(--text-primary); }
.cs-grand-total { text-align: right; font-size: 14px; font-weight: 600; padding: var(--sp-2) 0; color: var(--text-primary); }
.cs-grand-total strong { color: var(--text-primary); font-size: 15px; }

/* ====== Logistics card ====== */
.log-card-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.log-card {
  background: var(--bg-inset); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--sp-3);
}
.log-card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: var(--sp-3); padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border);
}
.log-card-order { font-size: 14px; font-weight: 700; color: var(--text-primary); cursor: pointer; text-decoration: none; }
.log-card-date { font-size: 12px; color: var(--text-tertiary); }
.log-card-body { display: flex; flex-direction: column; gap: var(--sp-1); }
.log-card-row { display: flex; justify-content: space-between; font-size: 13px; }
.log-card-label { color: var(--text-tertiary); min-width: 56px; }
.log-card-footer { margin-top: var(--sp-3); padding-top: var(--sp-2); border-top: 1px solid var(--border); text-align: right; }

/* ====== Print detail ====== */
.print-detail-item {
  background: var(--bg-inset); border-radius: var(--radius-sm);
  padding: var(--sp-3); margin-bottom: var(--sp-3);
  border: 1px solid var(--border);
}
.print-detail-header {
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 600; margin-bottom: var(--sp-2); font-size: 13px;
}

/* ====== Share link ====== */
.share-link-box { display: flex; gap: var(--sp-2); align-items: center; }

/* ====== Size checkbox ====== */
.size-checkbox-area { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.size-checkbox-item {
  display: flex; align-items: center; gap: var(--sp-1);
  padding: 3px 10px; background: var(--bg-inset);
  border: 1px solid var(--border); border-radius: var(--radius-full);
  cursor: pointer; font-size: 12px; transition: all 0.12s;
  user-select: none;
}
.size-checkbox-item.active { background: var(--text-primary); color: var(--text-inverse); border-color: var(--text-primary); }

/* ====== Generate checkbox ====== */
.generate-checkbox-area { display: flex; gap: var(--sp-4); margin-bottom: var(--sp-3); flex-wrap: wrap; }
.generate-checkbox-item { display: flex; align-items: center; gap: var(--sp-2); font-size: 13px; cursor: pointer; }
.generate-checkbox-item input { accent-color: var(--accent); width: 15px; height: 15px; }

/* ====== User select ====== */
.user-select-area { max-height: 180px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--sp-2); background: var(--bg-inset); }
.user-select-item {
  display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2);
  cursor: pointer; border-radius: var(--radius-sm); transition: background 0.1s;
}
.user-select-item:hover { background: var(--bg-hover); }
.user-select-item input { accent-color: var(--accent); }
.user-select-item .user-name { font-size: 13px; color: var(--text-primary); }
.user-select-item .user-role { font-size: 11px; color: var(--text-tertiary); }

/* ====== Order type row ====== */
.type-row { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--sp-2); }
.type-row-left { flex: 1; min-width: 0; }
.type-row .share-form-btn { flex-shrink: 0; white-space: nowrap; }

/* ====== Admin ====== */
.admin-page { padding: var(--sp-2) 0 80px; }
.admin-section {
  background: var(--bg-surface); margin: var(--sp-2) var(--sp-4);
  border-radius: var(--radius); padding: var(--sp-4);
  border: 1px solid var(--border);
}
.admin-section-title { font-size: 13px; font-weight: 600; margin-bottom: var(--sp-3); color: var(--text-primary); text-transform: uppercase; letter-spacing: 0.03em; }
.admin-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--sp-2) 0; border-bottom: 1px solid var(--border); font-size: 13px; gap: var(--sp-2);
}
.admin-item:last-child { border-bottom: none; }
.admin-item-clickable { cursor: pointer; padding: var(--sp-2); border-radius: var(--radius-sm); transition: background 0.15s; }
.admin-item-clickable:hover { background: var(--bg-hover); }
.admin-section-header { display:flex; align-items:center; gap:6px; cursor:pointer; user-select:none; padding:4px 0; }
.admin-section-header:hover { opacity:0.8; }
.admin-section-arrow { font-size:10px; transition:transform 0.2s; display:inline-block; width:14px; text-align:center; }
.admin-section-arrow.collapsed { transform:rotate(-90deg); }
.admin-section-body { overflow:hidden; transition:max-height 0.25s ease; }
.admin-section-body.collapsed { max-height:0 !important; }

/* ====== Export list ====== */
.export-list { display: flex; flex-direction: column; margin: var(--sp-2) var(--sp-4); }
.export-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--sp-3) var(--sp-4); background: var(--bg-surface);
  border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.1s;
}
.export-item:hover { background: var(--bg-hover); }
.export-item:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.export-item:last-child { border-radius: 0 0 var(--radius) var(--radius); border-bottom: none; }
.export-label { font-size: 14px; font-weight: 500; color: var(--text-primary); }

/* ====== Settings ====== */
.settings-page { padding: var(--sp-2) 0 80px; }
.settings-section {
  background: var(--bg-surface); margin: var(--sp-2) var(--sp-4);
  border-radius: var(--radius); padding: var(--sp-4);
  border: 1px solid var(--border);
}
.settings-section-title { font-size: 13px; font-weight: 600; margin-bottom: var(--sp-3); color: var(--text-primary); text-transform: uppercase; letter-spacing: 0.03em; }
.theme-options { display: flex; gap: var(--sp-2); }
.theme-option {
  flex: 1; padding: 8px; text-align: center;
  background: var(--bg-inset); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer; font-size: 13px;
  transition: all 0.12s;
}
.theme-option.active { background: var(--text-primary); color: var(--text-inverse); border-color: var(--text-primary); }

/* ====== Sheet view ====== */
.sheet-view { background: #fff; color: #333; padding: 20px; min-height: 100%; }
.sheet-view .sheet-logo { max-width: 120px; max-height: 60px; }
.sheet-view .sheet-section { margin-bottom: 16px; }
.sheet-view .sheet-section-title {
  font-weight: 700; font-size: 14px; padding: 6px 10px;
  background: #f5f5f5; border-left: 3px solid #333; margin-bottom: 8px;
}
.sheet-view table { width: 100%; border-collapse: collapse; font-size: 12px; }
.sheet-view th, .sheet-view td { border: 1px solid #ccc; padding: 6px 8px; text-align: center; }
.sheet-view th { background: #f5f5f5; font-weight: 600; }
.sheet-view .sheet-info-row { display: flex; gap: 20px; margin-bottom: 6px; font-size: 13px; }
.sheet-view .sheet-signature { display: flex; gap: 40px; margin-top: 20px; font-size: 13px; }
.sheet-view .sheet-img { max-width: 150px; max-height: 150px; border: 1px solid #ddd; }
.sheet-view .sheet-img-group { display: flex; flex-wrap: wrap; gap: 12px; }
.sheet-view .sheet-img-item { text-align: center; }
.sheet-view .sheet-img-item .label { font-size: 11px; color: #666; margin-top: 4px; }

/* ====== Sheet page ====== */
.sheet-page { padding: 0; }
.sheet-toolbar {
  display: flex; gap: var(--sp-2); padding: var(--sp-2) var(--sp-4);
  background: var(--bg-surface); border-bottom: 1px solid var(--border);
}
.sheet-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: var(--sp-3); }
.sheet-meta { font-size: 13px; line-height: 1.6; }
.sheet-title-main { font-size: 20px; font-weight: 700; text-align: center; flex: 1; }
.sheet-info-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 12px; }
.sheet-info-table td { border: 1px solid #ccc; padding: 6px 10px; }
.sheet-info-table td:nth-child(odd) { background: #f5f5f5; font-weight: 600; width: 15%; }
.sheet-data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.sheet-data-table th, .sheet-data-table td { border: 1px solid #ccc; padding: 6px 8px; text-align: center; }
.sheet-data-table th { background: #f0f0f0; font-weight: 600; }
.mat-list { display: flex; flex-direction: column; gap: 4px; padding: 4px 0; }
.mat-list-item { display: flex; align-items: baseline; gap: 6px; line-height: 1.7; padding: 1px 0; word-break: break-word; }
.mat-list-num { color: var(--text-tertiary); font-size: 11px; min-width: 20px; font-weight: 600; text-align: right; }
.mat-list-label { font-weight: 600; color: var(--text-primary); }
.mat-list-note { font-weight: 400; color: var(--text-secondary); }

.mat-checkbox-list { display: flex; flex-direction: column; gap: 6px; padding: 4px 0; }
.mat-checkbox-list-aux { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 4px 0; min-width: 0; }
@media (min-width: 768px) {
  .mat-checkbox-list-aux { grid-template-columns: 1fr 1fr; }
}
.mat-checkbox-list-aux .mat-checkbox-item { min-width: 0; overflow: hidden; }
.mat-checkbox-list-aux .mat-checkbox-label { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
.mat-checkbox-list-aux .mat-note { min-width: 0; width: auto; flex: 1 1 40px; }
.mat-checkbox-item { display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-radius: 6px; background: var(--bg-surface); border: 1px solid var(--border); transition: border-color 0.15s, background 0.15s; }
.mat-checkbox-item:hover { border-color: var(--border-strong); }
.mat-checkbox-item:has(input:checked) { background: #f0f5ff; border-color: var(--accent); }
.mat-checkbox-item input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.mat-checkbox-item .mat-checkbox-label { font-weight: 500; font-size: 13px; color: var(--text-primary); min-width: 56px; white-space: nowrap; cursor: pointer; }
.mat-checkbox-item input[type="text"] { font-size: 13px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-surface); flex: 1; min-width: 100px; transition: opacity 0.15s, border-color 0.15s; }
.mat-checkbox-item input[type="text"]:disabled { opacity: 0.35; cursor: not-allowed; background: var(--bg-secondary, #f9f9f9); }
.mat-checkbox-item input[type="text"]:focus { outline: none; border-color: var(--border-focus); }
.mat-section-divider { margin: 8px 0 6px; border: none; border-top: 1px dashed var(--border); }
.mat-extra-textarea { font-size: 13px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-surface); min-height: 52px; width: 100%; box-sizing: border-box; resize: vertical; line-height: 1.5; transition: border-color 0.15s; }
.mat-extra-textarea:focus { outline: none; border-color: var(--border-focus); }
.mat-extra-textarea::placeholder { color: var(--text-tertiary); }

.preview-nav { position: fixed; top: 50%; transform: translateY(-50%); z-index: 10000; font-size: 48px; color: rgba(255,255,255,0.7); cursor: pointer; padding: 12px 16px; user-select: none; transition: color 0.15s; line-height: 1; }
.preview-nav:hover { color: #fff; }
.preview-nav.prev { left: 16px; }
.preview-nav.next { right: 16px; }
.preview-counter { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 10000; color: rgba(255,255,255,0.6); font-size: 14px; background: rgba(0,0,0,0.4); padding: 4px 14px; border-radius: 20px; }
#preview-modal { touch-action: none; }

.detail-info-grid .mat-list { padding: 0; }
.detail-info-grid .mat-list-item { font-size: 13px; word-break: break-word; }
.sheet-material-text { font-size: 13px; line-height: 1.6; margin-bottom: 8px; white-space: pre-wrap; }
.sheet-img-section { margin-top: 8px; }
.sheet-img-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.sheet-img-row { display: flex; flex-wrap: wrap; gap: 12px; }
.sheet-sign-table { display: flex; gap: 40px; margin-top: 20px; }
.sign-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.sign-label { font-size: 13px; font-weight: 600; }
.sign-line { width: 100px; border-bottom: 1px solid #333; height: 30px; }
.sign-name { font-size: 12px; color: #666; }
.sheet-thumb { width: 56px; height: 56px; object-fit: cover; border: 1px solid #ddd; border-radius: 2px; }
.sheet-img-large { max-width: 100%; border: 1px solid #ddd; }

/* ====== Share form button ====== */
.share-form-btn { display: inline-flex; align-items: center; gap: 4px; }

/* ====== CS Table (order detail) ====== */
.cs-table { font-size: 12px; width: 100%; table-layout: fixed; }
.cs-table th { text-align: center; padding: 8px 6px; }
.cs-table td { padding: 8px 6px; text-align: center; }
.cs-table-color { text-align: left !important; font-weight: 600; width: 25%; }
.cs-table-total { text-align: center; font-weight: 700; }
.cs-table-grand { background: var(--bg-inset); font-weight: 700; }

/* ====== Utilities ====== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-secondary { color: var(--text-secondary); }
.mt-8 { margin-top: var(--sp-2); }
.mt-16 { margin-top: var(--sp-4); }
.mb-8 { margin-bottom: var(--sp-2); }
.mb-16 { margin-bottom: var(--sp-4); }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: var(--sp-2); }
.gap-12 { gap: var(--sp-3); }
.hidden { display: none !important; }

/* ====== Print ====== */
@media print {
  @page { size: A4 portrait; margin: 15mm; }
  body { background: #fff !important; color: #000 !important; }
  body * { visibility: hidden; }
  .sheet-view, .sheet-view * { visibility: visible; }
  .sheet-view { position: absolute; left: 0; top: 0; width: 100%; background: #fff; color: #000; }
  .sheet-toolbar, .no-print, .topbar { display: none !important; }
  .sheet-page { padding: 0 !important; margin: 0 !important; }
  .sheet-img { max-width: 120px; max-height: 120px; object-fit: contain; }
  .sheet-img-large { max-width: 100%; max-height: 250px; object-fit: contain; }
  .sheet-section { page-break-inside: avoid; margin-bottom: 12px; }
  .sheet-section-title { background: #f0f0f0 !important; color: #000 !important; font-weight: bold; padding: 6px 8px; }
  .sheet-material-text { white-space: pre-wrap; font-size: 12px; }
  table { font-size: 10px; border-collapse: collapse; width: 100%; }
  th, td { border: 1px solid #999; padding: 4px 6px; text-align: center; }
  th { background: #e8e8e8 !important; font-weight: bold; }
  .sheet-info-table td:first-child { background: #f5f5f5 !important; font-weight: bold; width: 25%; }
  .sheet-sign-table { display: flex; gap: 20px; page-break-inside: avoid; }
  .sign-cell { flex: 1; }
  .sign-line { border-bottom: 1px solid #000; margin: 6px 0 2px; min-height: 20px; }
}

/* ====== Desktop (>=768px) ====== */
@media (min-width: 768px) {
  #app { max-width: 900px; }
  .topbar { width: 100% !important; height: 52px !important; padding: 0 var(--sp-6) !important; }
  .topbar-left { left: 20px !important; }
  .topbar-title { font-size: 16px !important; }
  .topbar-right { right: 24px !important; gap: var(--sp-4) !important; }
  .lang-switch { font-size: 13px !important; }
  .lang-switch span { padding: 4px 12px !important; }
  .content { flex: 1; padding-bottom: 16px; }

  .card { margin: var(--sp-3) var(--sp-6) !important; padding: var(--sp-5) !important; }
  .card-title { font-size: 16px !important; }
  .list-item { padding: var(--sp-4) var(--sp-6) !important; }
  .list-item-title { font-size: 15px !important; }
  .list-item-sub { font-size: 13px !important; }
  .btn { padding: 10px 24px !important; font-size: 14px !important; }
  .btn-sm { padding: 6px 14px !important; font-size: 13px !important; }
  .form-input, .form-select, .form-textarea { font-size: 14px !important; padding: 10px 14px !important; }
  .form-label { font-size: 12px !important; }

  .modal { max-width: 520px !important; }
  .modal-box { max-width: 520px !important; padding: var(--sp-6) !important; }
  .modal-title { font-size: 18px !important; }
  table { font-size: 14px !important; }
  th, td { padding: 10px 14px !important; }
  .filter-bar { padding: var(--sp-3) var(--sp-6) !important; }
  .sort-bar { padding: var(--sp-3) var(--sp-6) !important; }
  .order-select-toolbar { padding: 0 !important; }
  .order-select-item { margin: var(--sp-3) var(--sp-6) !important; }
  .filter-input { font-size: 14px !important; padding: 8px 12px !important; width: 200px !important; max-width: 260px !important; }
  .filter-date { width: 150px !important; font-size: 13px !important; padding: 8px 10px !important; }
  .filter-select { font-size: 13px !important; padding: 8px 10px !important; min-width: 140px !important; }
  .pagination { padding: var(--sp-3) var(--sp-6) !important; }
  .pagination button { padding: 6px 12px !important; font-size: 13px !important; min-width: 36px !important; }
  .pagination select { font-size: 13px !important; padding: 4px 10px !important; }
  .icon-grid { max-width: 700px !important; margin: var(--sp-3) var(--sp-6) !important; }
  .icon-grid-item { padding: var(--sp-6) var(--sp-3) !important; }
  .icon-grid-item svg { width: 32px !important; height: 32px !important; }
  .icon-grid-item span { font-size: 13px !important; }
  .upload-area { gap: var(--sp-3) !important; }
  .upload-add { font-size: 32px !important; }
  .upload-area-attachment { gap: var(--sp-3) !important; }
  .upload-area-attachment .upload-add { font-size: 32px !important; height: 56px !important; min-height: 56px !important; }
  .fab { bottom: 100px !important; right: 24px !important; width: 52px !important; height: 52px !important; font-size: 22px !important; }
  .user-select-area { max-height: 240px !important; }
  .user-select-item { padding: 8px !important; }
  .user-select-item .user-name { font-size: 14px !important; }
  .detail-actions { padding: var(--sp-5) var(--sp-6) !important; }
  .detail-action-btn { padding: 12px 6px !important; font-size: 14px !important; }
  .form-row { gap: var(--sp-4) !important; }
  .tag { font-size: 12px !important; padding: 2px 10px !important; }
  .page { padding: 0 0 100px; }
  .detail-section { margin: var(--sp-3) var(--sp-6); padding: var(--sp-5); }
  .form-section { margin: var(--sp-3) var(--sp-6); padding: var(--sp-5); }
  .order-card { margin: var(--sp-3) var(--sp-6); padding: var(--sp-4) var(--sp-5); }
  .order-card-enhanced { margin: var(--sp-3) var(--sp-6); padding: var(--sp-5) var(--sp-6); }
  .order-card-enhanced .ord-customer-name { font-size: 18px; }
  .order-card-enhanced .ord-info-row { font-size: 14px; }
  .order-card-enhanced .card-thumb { width: 64px; height: 64px; }
  .image-grid { grid-template-columns: repeat(4, 1fr); }
  .detail-info-grid { grid-template-columns: 1fr 1fr 1fr 1fr; }
  .detail-header { padding: var(--sp-4) var(--sp-6); }
  .detail-order-no { font-size: 20px; }
  .settings-section { margin: var(--sp-3) var(--sp-6); padding: var(--sp-5); }
  .admin-section { margin: var(--sp-3) var(--sp-6); padding: var(--sp-5); }
  .export-list { margin: var(--sp-3) var(--sp-6); }
  .sheet-view { padding: 32px; }
  .data-table { font-size: 14px; }
  .data-table th, .data-table td { padding: 10px 12px; }
  .section-title { font-size: 15px; }
  .order-card-top { margin-bottom: var(--sp-3); }
  .order-no { font-size: 15px; }
  .order-card-info { font-size: 13px; }
  .grand-total { font-size: 16px; }
  .grand-total span { font-size: 18px; }
  .avatar-dropdown { top: 52px; width: 200px; max-width: 200px; }
}

/* ====== Dark Mode ====== */
[data-theme="dark"] {
  --bg-page: #0f0f11;
  --bg-surface: #18181b;
  --bg-elevated: #1f1f23;
  --bg-inset: #27272a;
  --bg-hover: #2a2a2e;
  --bg-active: #333338;
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-tertiary: #52525b;
  --text-inverse: #18181b;
  --border: #2e2e33;
  --border-strong: #3f3f46;
  --border-focus: #71717a;
  --accent: #fafafa;
  --accent-hover: #d4d4d8;
  --accent-subtle: #27272a;
  --color-danger: #f87171;
  --color-success: #4ade80;
  --nav-divider: #2e2e33;
  --nav-icon: #71717a;
  --glass-bg: rgba(24, 24, 27, 0.85);
  --btn-danger-hover: #3b1111;
  --btn-success-hover: #0f2e1a;
}
[data-theme="dark"] .btn-danger:hover { background: var(--btn-danger-hover); }
[data-theme="dark"] .btn-success:hover { background: var(--btn-success-hover); }
