/* ============================================================
   生产管理系统 — 现代化响应式设计
   ============================================================ */

/* ---------- Design Tokens ---------- */
:root {
  /* Colors */
  --c-blue-50: #EFF6FF;  --c-blue-100: #DBEAFE; --c-blue-200: #BFDBFE;
  --c-blue-500: #3B82F6; --c-blue-600: #2563EB; --c-blue-700: #1D4ED8; --c-blue-800: #1E40AF;
  --c-green-50: #F0FDF4; --c-green-500: #22C55E; --c-green-600: #16A34A; --c-green-700: #15803D;
  --c-red-50: #FEF2F2;   --c-red-500: #EF4444;  --c-red-600: #DC2626;  --c-red-700: #B91C1C;
  --c-amber-50: #FFFBEB;  --c-amber-500: #F59E0B; --c-amber-600: #D97706; --c-amber-700: #B45309;
  --c-teal-50: #F0FDFA;   --c-teal-500: #14B8A6;  --c-teal-600: #0D9488;
  --c-slate-50: #F8FAFC;  --c-slate-100: #F1F5F9; --c-slate-200: #E2E8F0;
  --c-slate-300: #CBD5E1; --c-slate-400: #94A3B8; --c-slate-500: #64748B;
  --c-slate-600: #475569; --c-slate-700: #334155; --c-slate-800: #1E293B; --c-slate-900: #0F172A;

  /* Light Theme (default) */
  --bg: var(--c-slate-50);
  --surface: #FFFFFF;
  --surface-hover: var(--c-slate-50);
  --surface-secondary: var(--c-slate-100);
  --text-primary: var(--c-slate-900);
  --text-secondary: var(--c-slate-500);
  --text-tertiary: var(--c-slate-400);
  --border: var(--c-slate-200);
  --border-light: var(--c-slate-100);

  /* Brand */
  --primary: var(--c-blue-600);
  --primary-hover: var(--c-blue-700);
  --primary-light: var(--c-blue-50);
  --primary-ring: rgba(37, 99, 235, 0.15);

  /* Semantic */
  --success: var(--c-green-600);
  --success-light: var(--c-green-50);
  --danger: var(--c-red-600);
  --danger-light: var(--c-red-50);
  --warning: var(--c-amber-600);
  --warning-light: var(--c-amber-50);
  --info: var(--c-teal-600);
  --info-light: var(--c-teal-50);

  /* Layout */
  --sidebar-w: 260px;
  --sidebar-collapsed-w: 0px;
  --topbar-h: 44px;
  --mobile-nav-h: 60px;

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

  /* Borders */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-2xl: 24px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.04);

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Consolas", monospace;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --duration-fast: 150ms;
  --duration: 250ms;
  --duration-slow: 400ms;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 14px; line-height: 1.6;
  color: var(--text-primary); background: var(--bg);
  min-height: 100vh; -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
img, video { max-width: 100%; height: auto; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--c-slate-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--c-slate-400); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
#login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: var(--sp-6);
  background: linear-gradient(135deg, #0F172A 0%, #1E3A5F 40%, #1E40AF 100%);
  position: relative; overflow: hidden;
}
#login-page::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 20% 50%, rgba(59,130,246,0.15) 0%, transparent 70%),
              radial-gradient(ellipse at 80% 20%, rgba(34,197,94,0.08) 0%, transparent 60%);
  pointer-events: none;
}
.login-card {
  position: relative; z-index: 1;
  background: rgba(255,255,255,0.97); backdrop-filter: blur(20px);
  border-radius: var(--radius-2xl); padding: var(--sp-10) var(--sp-8);
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(255,255,255,0.1);
}
.login-logo { text-align: center; margin-bottom: var(--sp-8); }
.login-logo .icon { font-size: 48px; }
.login-logo h1 { font-size: 22px; color: var(--c-slate-800); margin-top: var(--sp-3); font-weight: 700; letter-spacing: -0.02em; }
.login-logo p { color: var(--text-secondary); font-size: 13px; margin-top: var(--sp-1); }

#file-warning {
  background: var(--warning-light); border: 1px solid var(--c-amber-200);
  border-radius: var(--radius); padding: var(--sp-4);
  margin-bottom: var(--sp-5); font-size: 12px; color: var(--c-amber-700);
}
#file-warning code { background: #fff; padding: 1px 6px; border-radius: 3px; font-size: 11px; }

.login-hint { margin-top: var(--sp-4); text-align: center; }
.login-hint details { display: inline-block; }
.login-hint summary:hover { color: var(--primary) !important; }
.login-accounts {
  margin-top: var(--sp-2); padding: var(--sp-3); background: var(--surface-secondary);
  border-radius: var(--radius); border: 1px solid var(--border-light);
  text-align: left; font-size: 11px;
}
.account-row {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 2px 0; white-space: nowrap;
}
.account-row code {
  background: var(--surface); padding: 1px 6px; border-radius: 3px;
  font-size: 11px; font-family: var(--font-mono); color: var(--text-primary);
  border: 1px solid var(--border);
}
#file-warning a { font-weight: 600; text-decoration: underline; }

/* ============================================================
   LAYOUT
   ============================================================ */
#app { display: none; min-height: 100vh; }
.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w); background: linear-gradient(180deg, #0F172A 0%, #1E293B 100%);
  color: white; flex-shrink: 0; display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh; z-index: 200;
  transition: transform var(--duration-slow) var(--ease-out);
  border-right: 1px solid rgba(255,255,255,0.06);
}
.sidebar-header {
  padding: var(--sp-5) var(--sp-4);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3);
}
.sidebar-brand {
  display: flex; align-items: center; gap: var(--sp-3);
  min-width: 0;
}
.sidebar-header h2 { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.sidebar-header .logo-icon { font-size: 22px; }
.header-actions {
  display: flex; align-items: center; gap: 2px;
  flex-shrink: 0;
}
.header-actions .notification-bell {
  padding: 6px 8px;
  color: rgba(255,255,255,0.7);
}
.header-actions .notification-bell:hover {
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.95);
}
.header-actions .notification-bell .bell-icon { font-size: 17px; }
.sidebar-nav { flex: 1; padding: var(--sp-2) 0; overflow-y: auto; }

.nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-5); margin: 2px var(--sp-3);
  cursor: pointer; font-size: 14px; font-weight: 500;
  border-radius: var(--radius);
  transition: all var(--duration-fast) var(--ease-out);
  color: rgba(255,255,255,0.65); position: relative;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.9); }
.nav-item.active {
  background: rgba(59,130,246,0.2); color: white;
  font-weight: 600;
}
.nav-item .nav-icon { font-size: 18px; width: 28px; text-align: center; flex-shrink: 0; }
.nav-item .nav-label { flex: 1; }
.nav-item .nav-arrow { font-size: 10px; color: rgba(255,255,255,0.4); transition: transform 0.2s; }
.nav-item .nav-badge {
  margin-left: auto; font-size: 10px; padding: 2px 8px;
  border-radius: 20px; background: var(--c-red-500); color: white; font-weight: 700;
}

/* 二级子菜单 */
.nav-submenu { display: none; overflow: hidden; }
.nav-subitem {
  display: flex; align-items: center;
  padding: 5px 14px; margin: 1px 8px;
  cursor: pointer; font-size: 13px; font-weight: 400;
  border-radius: var(--radius);
  transition: all var(--duration-fast) var(--ease-out);
  color: rgba(255,255,255,0.45);
}
.nav-subitem:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.85); }
.nav-subitem.active {
  background: rgba(59,130,246,0.15); color: #93c5fd;
  font-weight: 600;
}

.sidebar-footer {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid rgba(255,255,255,0.08);
}
.user-info-card {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-2); border-radius: var(--radius);
  transition: background var(--duration-fast);
}
.user-info-card:hover { background: rgba(255,255,255,0.06); }
.user-info-left {
  display: flex; align-items: center; gap: var(--sp-2);
  flex: 1; min-width: 0;
}
.user-actions {
  display: flex; align-items: center; gap: 2px;
  flex-shrink: 0;
}
.user-avatar {
  width: 34px; height: 34px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--c-blue-500), var(--c-blue-700));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.user-detail { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: rgba(255,255,255,0.5); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-logout {
  background: rgba(255,255,255,0.08); border: none; color: rgba(255,255,255,0.6);
  padding: 5px 8px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 16px; line-height: 1; transition: all var(--duration-fast);
}
.btn-logout:hover { background: rgba(239,68,68,0.3); color: var(--c-red-400); }

/* Main Content */
.main-content {
  flex: 1; margin-left: var(--sidebar-w);
  min-height: 100vh; display: flex; flex-direction: column;
  transition: margin-left var(--duration-slow) var(--ease-out);
}

/* Topbar */
.topbar {
  background: var(--surface); height: var(--topbar-h); min-height: var(--topbar-h);
  padding: 0 var(--sp-6); display: flex; align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  position: sticky; top: 0; z-index: 100;
  border-bottom: 1px solid var(--border-light);
}
.topbar-left { display: flex; align-items: center; gap: var(--sp-3); }
.topbar-left h1 { display: block; font-size: 15px; font-weight: 600; color: var(--text-primary); white-space: nowrap; letter-spacing: -0.2px; }
.mobile-menu-btn {
  display: none; width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; font-size: 18px; color: var(--text-primary);
  align-items: center; justify-content: center;
}
.topbar-actions { display: flex; gap: var(--sp-2); align-items: center; }
.topbar-actions .btn { height: 36px; }

/* Page Content */
.page-content { padding: var(--sp-1) var(--sp-6) var(--sp-6); flex: 1; animation: fadeIn var(--duration) var(--ease-out); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================
   COMPONENTS: CARDS
   ============================================================ */
.card {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); border: 1px solid var(--border-light);
  overflow: hidden; transition: box-shadow var(--duration-fast);
}
.card:hover { box-shadow: var(--shadow); }
.card-header {
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.card-body { padding: var(--sp-5); }

/* 群组权限管理（Phase 5） */
.group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--sp-4); padding: var(--sp-5); }
.group-card { border: 1px solid var(--border-light); border-radius: var(--radius); padding: var(--sp-4); background: var(--bg-card); }
.group-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.group-card-head h4 { font-size: 15px; font-weight: 700; color: var(--text-primary); margin: 0; }
.group-card-head p { font-size: 12px; margin: 4px 0 0; }
.perm-wrap { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; max-height: 140px; overflow-y: auto; }
.perm-chip { display: inline-block; padding: 2px 8px; font-size: 11px; border-radius: 10px; background: var(--primary-light, #eef2ff); color: var(--c-indigo-700, #4338ca); border: 1px solid var(--border-light); }

/* ============================================================
   COMPONENTS: STATS
   ============================================================ */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-4); margin-bottom: var(--sp-6);
}
.stat-card {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: var(--sp-5); box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  display: flex; align-items: flex-start; gap: var(--sp-4);
  transition: all var(--duration-fast) var(--ease-out);
  cursor: default; position: relative; overflow: hidden;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card::after {
  content: ''; position: absolute; top: 0; right: 0;
  width: 80px; height: 80px; border-radius: 50%;
  transform: translate(40px, -40px); opacity: 0.06;
}
.stat-card.blue::after { background: var(--c-blue-500); }
.stat-card.green::after { background: var(--c-green-500); }
.stat-card.amber::after { background: var(--c-amber-500); }
.stat-card.red::after { background: var(--c-red-500); }
.stat-card.teal::after { background: var(--c-teal-500); }

.stat-icon {
  width: 48px; height: 48px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-icon.blue { background: var(--primary-light); color: var(--c-blue-600); }
.stat-icon.green { background: var(--success-light); color: var(--c-green-600); }
.stat-icon.amber { background: var(--warning-light); color: var(--c-amber-600); }
.stat-icon.red { background: var(--danger-light); color: var(--c-red-600); }
.stat-icon.teal { background: var(--info-light); color: var(--c-teal-600); }

.stat-body { flex: 1; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--text-primary); line-height: 1.1; letter-spacing: -0.02em; }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.stat-change { font-size: 11px; margin-top: 4px; display: inline-flex; align-items: center; gap: 2px; }
.stat-change.up { color: var(--c-green-600); }
.stat-change.down { color: var(--c-red-600); }

/* ============================================================
   COMPONENTS: TABLE
   ============================================================ */
.table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  position: relative;
}
table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
thead { position: sticky; top: 0; z-index: 10; }
th {
  background: var(--surface-secondary);
  padding: var(--sp-3) var(--sp-4); text-align: left;
  font-weight: 600; color: var(--text-secondary);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap; user-select: none;
}
th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--primary); }
th.sortable .sort-arrow { margin-left: 4px; opacity: 0.4; }
th.sortable.sorted .sort-arrow { opacity: 1; }

td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle; color: var(--text-primary);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-hover); }
tr.selected td { background: var(--primary-light); }

/* Status badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.01em;
}
.badge-pending    { background: var(--warning-light); color: var(--c-amber-700); }
.badge-in_progress,
.badge-inprogress { background: var(--primary-light); color: var(--c-blue-700); }
.badge-submitted  { background: #F0FDFA; color: #0F766E; }
.badge-approved   { background: var(--success-light); color: var(--c-green-700); }
.badge-rejected   { background: var(--danger-light); color: var(--c-red-700); }
.badge-completed  { background: var(--surface-secondary); color: var(--text-secondary); }
.badge-active     { background: var(--primary-light); color: var(--c-blue-700); }
.badge-cancelled  { background: var(--danger-light); color: var(--c-red-700); }

/* Empty table state */
.table-empty {
  text-align: center; padding: var(--sp-12) var(--sp-6);
  color: var(--text-tertiary);
}
.table-empty .icon { font-size: 40px; margin-bottom: var(--sp-3); opacity: 0.5; }
.table-empty p { font-size: 13px; }

/* ============================================================
   COMPONENTS: BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: var(--radius);
  border: none; cursor: pointer; font-size: 13px; font-weight: 600;
  transition: all var(--duration-fast) var(--ease-out);
  text-decoration: none; line-height: 1.4; white-space: nowrap;
  position: relative; overflow: hidden;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--primary); color: white; box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); box-shadow: var(--shadow-md); }
.btn-success { background: var(--c-green-600); color: white; }
.btn-success:hover:not(:disabled) { background: var(--c-green-700); }
.btn-danger { background: var(--c-red-600); color: white; }
.btn-danger:hover:not(:disabled) { background: var(--c-red-700); }
.btn-warning { background: var(--c-amber-600); color: white; }
.btn-warning:hover:not(:disabled) { background: var(--c-amber-700); }
.btn-info { background: var(--c-teal-600); color: white; }
.btn-info:hover:not(:disabled) { background: #0F766E; }

.btn-outline {
  background: var(--surface); border: 1.5px solid var(--border);
  color: var(--text-primary);
}
.btn-outline:hover:not(:disabled) { background: var(--surface-secondary); border-color: var(--c-slate-300); }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-secondary); color: var(--text-primary); }

.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-lg { padding: 14px 24px; font-size: 15px; border-radius: var(--radius-lg); }
.btn-block { width: 100%; }

.btn .spinner {
  width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white; border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   COMPONENTS: FORMS
   ============================================================ */
.form-group { margin-bottom: var(--sp-4); }
.form-group label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text-primary); margin-bottom: var(--sp-1);
}
.form-group label .req { color: var(--c-red-500); margin-left: 2px; }

.form-control {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius); font-size: 14px; font-family: inherit;
  color: var(--text-primary); background: var(--surface);
  transition: all var(--duration-fast) var(--ease-out);
  outline: none;
}
.form-control::placeholder { color: var(--text-tertiary); }
.form-control:hover:not(:disabled) { border-color: var(--c-slate-300); }
.form-control:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring);
}
.form-control:disabled { background: var(--surface-secondary); opacity: 0.7; }
.form-control.is-invalid { border-color: var(--c-red-500); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(220,38,38,0.12); }

textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.form-row.single { grid-template-columns: 1fr; }
.form-row.triple { grid-template-columns: 1fr 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.field label .req { color: var(--c-red-500); }
.field .hint { font-size: 11px; color: var(--text-tertiary); }

/* ============================================================
   COMPONENTS: MODAL
   ============================================================ */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5); backdrop-filter: blur(4px);
  z-index: 10000; align-items: center; justify-content: center; padding: var(--sp-4);
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius-xl);
  width: 100%; max-width: 600px; max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-xl);
  animation: modalIn var(--duration) var(--ease-out);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(24px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-max {
  max-width: 100vw !important;
  width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  margin: 0 !important;
}
.modal-max-overlay {
  padding: 0 !important;
  align-items: flex-start !important;
}
.modal.small { max-width: 400px; }

.modal-header {
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
/* 2026-09-21 需求F：宽弹窗默认不再沾满整屏（原为 calc(100vw - 32px)，观感等同全屏）。
   收敛为 min(1280px, 92vw)，大屏居中留白；用户可自行拖拽右下角放大。 */
.modal.wide { max-width: min(1280px, 92vw); width: min(1280px, 92vw); max-height: min(88vh, 900px); }
.modal.wide .modal-body { padding: var(--sp-3); }

/* ===== MODAL RESIZE (需求F 2026-09-21) ===== */
/* 用户可拖拽右下角原生手柄缩放弹窗。
   要点：
   - 必须 overflow:hidden，否则浏览器不绘制 resize 手柄；
     内容滚动仍由 .modal-body 的 overflow-y:auto 负责，不受影响。
   - min-width/min-height 防止被拖成 0（拖没了就找不回来了）。
   ⚠️ 2026-09-21 修正前一版注释的错误断言：
     inline width **不能**突破 max-width —— max-width 永远参与 min/max 钳制。
     实测：.modal(max-width:600px)+inline width:1200px 实际只渲染 600px，
     表现为「只能纵向拉高、横向拉不宽」。
     因此宽度可拖拽靠 JS 兜底（见 MODAL RESIZE CLAMP FIX 段）：
     拖拽结束后把 max-width/max-height 同步抬到用户拖出的尺寸（并被视口封顶）。*/
.modal {
  resize: both;
  overflow: hidden;
  min-width: 360px;
  min-height: 240px;
}
/* 全屏态禁止再拖拽，并把过渡交还给布局 */
.modal.modal-max {
  resize: none !important;
  min-width: 0 !important;
  min-height: 0 !important;
}

/* ===== MODAL RESIZE CLAMP FIX (需求F P1 2026-09-21) ===== */
/* 视口封顶只由 JS 负责（_modalEnsureResizeClamp 里用 innerWidth/innerHeight - 16 封顶）。
   ⚠️ 这里曾加过一条 .modal:not(.modal-max){max-height:96vh} 作为「CSS 保险」，
   但它与 .modal.wide 同 specificity(0,2,0) 且位置更靠后 ⇒ 反而覆盖掉
   .modal.wide 的 max-height:min(88vh,900px)，把「默认尺寸收敛」在高度维度上抵消。
   已删除：封顶保持单一事实来源（JS），避免两处规则互相打架。*/
/* 窄屏（≤767px）弹窗是底部抽屉形态，宽高已由视口决定，禁用手动缩放避免误触 */
@media (max-width: 767px) {
  .modal { resize: none; min-width: 0; min-height: 0; }
}

/* ===== 自建弹窗拖拽缩放（需求F-2 2026-09-21） =====
   用户要求「所有弹窗」都能拖拽缩放。除 .modal 系（走 openModal()）外，项目里还有
   4 个自建弹窗，它们不经 openModal、各有自己的容器结构，这里逐个补上。
   共同要点：
   - resize:both 必须配 overflow:hidden，否则浏览器不画右下角手柄；
     内容滚动交给内层的 body/容器，不受影响。
   - min-width/min-height 防止拖成 0 后找不回来。
   - 只在桌面/平板（≥768px）启用：窄屏这些弹窗本身就是整屏或底部抽屉形态，
     宽高由视口决定，允许缩放只会带来误触。 */

/* 1) 拆单详情弹窗卡片（#spaSO_modal > #spaSO_modal_card）
   该卡片已是 flex column + max-height，追加 resize 即可。
   ⚠️ 全屏(minimized 除外)与最小化态要禁用，否则会破坏那两个形态的尺寸契约。 */
/* ⚠️ 2026-09-21 实测修正：该卡片原是 `width:min(100vw,1920px)`，
   在 1920 视口下渲染 1872px（父 padding 48px）=> **横向零余量**，往右拖没有增长空间，
   叠加 `transition:all .25s`（拖拽期间每个 mousemove 触发 250ms 过渡，与 resize 打架）
   => 9 个偏移全部拖不动。这里给一个明确的、留有余量的宽度基准，并去掉过渡。 */
/* ⚠️ 2026-09-21 二次修正（用户报「全屏不满屏右边少一截 + 拖不动」）：
   1) 全屏不满屏根因：旧规则 width:min(1400px,...)!important 没有 :not(.fullscreen)，
      全屏态也被 1400px 基准压死（实测 1920 视口 computed width=1400，左右各空 260px）；
   2) 拖不动根因：width 带 !important 会压制浏览器 resize 手柄写入的 inline width
      （非 !important 的 inline 永远输给样式表 !important）→ 手柄拖了等于没拖。
   现改为：基准宽度只作用于普通态（:not 排除全屏/最小化），且去掉 width 的 !important
   —— 用户拖出的 inline width 直接生效；max-width 只做视口兜底。 */
#spaSO_modal_card:not(.fullscreen):not(.minimized) {
  resize: both;
  overflow: hidden;
  min-width: 640px;
  min-height: 360px;
  width: min(1400px, calc(100vw - 96px));
  max-width: calc(100vw - 16px);
  transition: none !important;
}
/* 右下角可视化拖拽把手：原生 resize 手柄无任何视觉提示，用户不知道从哪拖 */
#spaSO_modal_card:not(.fullscreen):not(.minimized)::after {
  content: '';
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: repeating-linear-gradient(
    -45deg,
    transparent 0 3px,
    #94a3b8 3px 5px,
    transparent 5px 7px
  );
  opacity: .55;
  pointer-events: none;
  z-index: 30;
}
#spaSO_modal_card.fullscreen,
#spaSO_modal_card.minimized {
  resize: none !important;
  min-width: 0 !important;
  min-height: 0 !important;
}

/* 2) 图纸管理对话框（#drawing-modal 内的 .modal，带 max-width:700px 内联样式）
   ⚠️ 它内联写了 max-width:700px，inline width 突破不了 max-width
   （本项目实测：max-width 永远参与 min/max 钳制）=> 宽度由 JS 兜底抬 max-width，
   见 index.html 的 _selfModalEnsureResizeClamp()。 */
#drawing-modal .modal {
  resize: both;
  overflow: hidden;
  min-width: 360px;
  min-height: 240px;
}

/* 3) 财务记录新建/编辑弹窗（#spaFR_modalWrap 内联渲染的卡片）
   内联写了 width:90%;max-width:800px;max-height:90vh。同样需要 JS 抬 max-width。 */
/* ⚠️ 2026-09-21 实测修正：卡片自带内联 `overflow-y:auto`，内联优先于本类，
   会让 computed 变成 `overflow-x:visible / overflow-y:auto` —— 这个组合下浏览器
   不在右下角绘制可抓取的 resize 手柄（实测 9 个候选偏移全拖不动，off>=5 时反而
   把宽度拖成 -161px）。故必须用 !important 压过内联，真正得到 overflow:hidden。
   内容滚动改由内层容器承担（index.html 里已把滚动下移到 .sfr-scroll）。 */
#spaFR_modalWrap .sfr-card {
  resize: both;
  overflow: hidden !important;
  min-width: 420px;
  min-height: 260px;
}

/* 4) Excel 编辑器（#excel-editor-modal）：整屏 flex，缩放会破坏内部
   height:calc(100vh - 44px) 的容器契约。保持整屏，不做缩放。 */

@media (max-width: 767px) {
  #spaSO_modal_card,
  #drawing-modal .modal,
  #spaFR_modalWrap .sfr-card {
    resize: none;
    min-width: 0;
    min-height: 0;
  }
}
.modal-close {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  border: none; background: var(--surface-secondary);
  cursor: pointer; font-size: 16px; color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--duration-fast);
}
.modal-close:hover { background: var(--c-slate-200); color: var(--text-primary); }
.modal-max-btn {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  border: none; background: var(--surface-secondary);
  cursor: pointer; font-size: 14px; color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--duration-fast);
}
.modal-max-btn:hover { background: var(--c-slate-200); color: var(--text-primary); }
.modal-body { padding: var(--sp-6); overflow-y: auto; flex: 1; }
.modal-footer {
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border-light);
  display: flex; justify-content: flex-end; gap: var(--sp-3);
  flex-shrink: 0;
}
/* 2026-09-21 需求F：桌面端弹窗可拖拽缩放，浏览器会在右下角画约 16×16 的把手，
   会把右对齐的页脚按钮热区盖住（点不到）。给 footer 右下角让出空间。
   窄屏本来 resize:none，不需要让位，所以放在 >767px 的媒体查询里。*/
@media (min-width: 768px) {
  .modal > .modal-footer { padding-right: calc(var(--sp-6) + 14px); padding-bottom: calc(var(--sp-4) + 4px); }
  .modal.modal-max > .modal-footer { padding-right: var(--sp-6); padding-bottom: var(--sp-4); }
}

/* ============================================================
   COMPONENTS: TOAST
   ============================================================ */
.toast-container {
  position: fixed; top: var(--sp-4); right: var(--sp-4);
  /* 2026-09-16：从 100000 提到 100100 —— openModal 会把通用弹窗自抬到 topZ+10（最高 10060）、
     图纸弹窗 topZ+20、stagemodal-overlay 为 100000，100100 保证 toast 永远在这些浮层之上 */
  z-index: 100100; display: flex; flex-direction: column; gap: var(--sp-2);
  pointer-events: none; max-width: 380px;
}
.toast {
  padding: var(--sp-3) var(--sp-4); border-radius: var(--radius);
  color: white; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.35s var(--ease-out);
  pointer-events: auto; display: flex; align-items: center; gap: var(--sp-2);
  position: relative; overflow: hidden;
}
.toast .toast-progress {
  position: absolute; bottom: 0; left: 0; height: 3px;
  background: rgba(255,255,255,0.4); border-radius: 0 2px 0 0;
  animation: toastProgress 2.8s linear forwards;
}
@keyframes toastIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(120%); opacity: 0; } }
@keyframes toastProgress { from { width: 100%; } to { width: 0%; } }

.toast.success { background: var(--c-green-600); }
.toast.error { background: var(--c-red-600); }
.toast.warning { background: var(--c-amber-600); }
.toast.info { background: var(--c-blue-600); }

/* ============================================================
   COMPONENTS: SKELETON LOADING
   ============================================================ */
.skeleton {
  background: linear-gradient(90deg, var(--surface-secondary) 25%, var(--border-light) 50%, var(--surface-secondary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-text { height: 14px; margin-bottom: var(--sp-2); }
.skeleton-text.short { width: 60%; }
.skeleton-heading { height: 20px; width: 40%; margin-bottom: var(--sp-4); }
.skeleton-card { height: 100px; border-radius: var(--radius-lg); }
.skeleton-row { display: flex; gap: var(--sp-4); padding: var(--sp-3) 0; }
.skeleton-cell { height: 14px; flex: 1; }

/* ============================================================
   COMPONENTS: FILTER BAR
   ============================================================ */
.filter-bar {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: var(--sp-4) var(--sp-5); box-shadow: var(--shadow-sm);
  margin-bottom: var(--sp-4);
  display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: flex-end;
  border: 1px solid var(--border-light);
}
.filter-group { display: flex; flex-direction: column; gap: 4px; min-width: 140px; }
.filter-group label { font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.03em; }
.filter-input {
  padding: 8px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; font-family: inherit; outline: none; background: var(--surface);
  color: var(--text-primary); transition: all var(--duration-fast);
}
.filter-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
select.filter-input { cursor: pointer; }

/* ============================================================
   COMPONENTS: PAGINATION
   ============================================================ */
.pagination {
  display: flex; align-items: center; justify-content: center; gap: var(--sp-1);
  padding: var(--sp-4) 0;
}
.pagination button {
  min-width: 32px; height: 32px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; font-size: 13px; color: var(--text-primary);
  transition: all var(--duration-fast);
}
.pagination button:hover:not(:disabled) { background: var(--surface-secondary); }
.pagination button.active { background: var(--primary); color: white; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============================================================
   INSPECTION PAGE SPECIFIC
   ============================================================ */
.section-title {
  background: var(--surface-secondary);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--radius);
  font-size: 14px; font-weight: 700; color: var(--text-primary);
  margin: var(--sp-5) 0 var(--sp-3);
  display: flex; align-items: center; gap: var(--sp-2);
  border: 1px solid var(--border-light);
}
.section-title:first-child { margin-top: 0; }

/* Inspection items table */
.inspect-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.inspect-table th {
  background: var(--primary); color: white; padding: 8px 6px;
  font-size: 11px; text-align: center; border: none;
}
.inspect-table td { padding: 6px; border: 1px solid var(--border); text-align: center; }
.inspect-table input {
  width: 100%; padding: 6px 4px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 12px; text-align: center;
  font-family: inherit; color: var(--text-primary);
}
.inspect-table input[type="number"] { width: 60px; }
.inspect-table input:focus { border-color: var(--primary); outline: none; }
.inspect-table .item-name {
  text-align: left; font-weight: 600; background: var(--surface-secondary);
  min-width: 100px;
}
.inspect-table .standard {
  text-align: left; font-size: 11px; color: var(--text-secondary); max-width: 200px;
}

.result-btn {
  padding: 4px 10px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); cursor: pointer;
  font-size: 11px; font-weight: 600; white-space: nowrap;
  background: var(--surface); transition: all var(--duration-fast);
}
.result-btn.pass { border-color: var(--c-green-500); color: var(--c-green-600); }
.result-btn.pass.active, .result-btn.pass:hover { background: var(--c-green-500); color: white; border-color: var(--c-green-500); }
.result-btn.fail { border-color: var(--c-red-500); color: var(--c-red-600); }
.result-btn.fail.active, .result-btn.fail:hover { background: var(--c-red-500); color: white; border-color: var(--c-red-500); }
.result-btn.pending { border-color: var(--c-amber-500); color: var(--c-amber-600); }
.result-btn.pending.active, .result-btn.pending:hover { background: var(--c-amber-500); color: white; border-color: var(--c-amber-500); }

/* Photo upload zones */
.photo-section { margin-bottom: var(--sp-4); }
.photo-section-title {
  font-size: 13px; font-weight: 700; color: var(--text-primary);
  padding: var(--sp-3) var(--sp-4); background: var(--surface-secondary);
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid var(--border); border-bottom: none;
  display: flex; align-items: center; justify-content: space-between;
}
.photo-section-title .add-btn {
  font-size: 11px; padding: 5px 14px; background: var(--primary);
  color: white; border: none; border-radius: var(--radius-sm);
  cursor: pointer; font-weight: 600; transition: background var(--duration-fast);
}
.photo-section-title .add-btn:hover { background: var(--primary-hover); }
.photo-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--sp-3);
  padding: var(--sp-3); border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--radius) var(--radius); background: var(--surface);
}

.photo-card {
  position: relative; border: 2px dashed var(--border);
  border-radius: var(--radius); background: var(--surface-secondary);
  cursor: pointer; transition: all var(--duration-fast);
  display: flex; flex-direction: column; overflow: hidden;
  aspect-ratio: 4/3; max-height: 200px;
}
.photo-card:hover { border-color: var(--primary); background: var(--primary-light); }
.photo-card.filled { border-style: solid; border-color: var(--c-green-500); }
.photo-card .card-label {
  font-size: 11px; font-weight: 600; color: var(--text-primary);
  padding: var(--sp-2) var(--sp-3) 4px; flex-shrink: 0;
  background: var(--surface); display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
}
.photo-card .card-label .del-card {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface-secondary); color: var(--text-secondary);
  border: none; cursor: pointer; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--duration-fast);
}
.photo-card .card-label .del-card:hover { background: var(--c-red-500); color: white; }
.photo-card .card-body {
  flex: 1; display: flex; align-items: center; justify-content: center;
  min-height: 0; position: relative;
}
.photo-card .card-body img,
.photo-card .card-body video { width: 100%; height: 100%; object-fit: contain; }
.photo-card .card-body .placeholder {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; color: var(--text-tertiary); gap: var(--sp-1);
}
.photo-card .card-body .placeholder .icon { font-size: 28px; }
.photo-card .card-body .placeholder .txt { font-size: 11px; }
.photo-card .play-badge {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  font-size: 36px; color: white; text-shadow: 0 0 10px rgba(0,0,0,0.6);
  pointer-events: none;
}
.photo-card .card-desc {
  flex-shrink: 0; padding: var(--sp-1) var(--sp-3) var(--sp-2);
  background: var(--surface); border-top: 1px solid var(--border-light);
}
.photo-card .card-desc textarea {
  width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 6px 8px; font-size: 11px; font-family: inherit;
  resize: none; rows: 2; background: var(--surface-secondary);
  color: var(--text-primary); outline: none;
  transition: border-color var(--duration-fast);
}
.photo-card .card-desc textarea:focus { border-color: var(--primary); background: var(--surface); }
.photo-card .card-desc .saved-hint {
  font-size: 10px; color: var(--c-green-600); text-align: right; margin-top: 2px;
  opacity: 0; transition: opacity 0.3s;
}
.photo-card .card-desc .saved-hint.show { opacity: 1; }

.photo-add-card {
  border: 2px dashed var(--border); border-radius: var(--radius);
  background: var(--surface-secondary); cursor: pointer;
  transition: all var(--duration-fast); display: flex;
  flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-2); aspect-ratio: 4/3; max-height: 200px;
}
.photo-add-card:hover { border-color: var(--primary); background: var(--primary-light); }
.photo-add-card .plus { font-size: 28px; color: var(--text-tertiary); }
.photo-add-card .txt { font-size: 12px; color: var(--text-tertiary); }

/* AQL selector */
.aql-row { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; }
.aql-col { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.aql-col label { font-size: 11px; font-weight: 600; }
.aql-col input {
  width: 80px; padding: 8px; border: 1.5px solid var(--border);
  border-radius: var(--radius); font-size: 13px; text-align: center;
  font-family: inherit; color: var(--text-primary);
}
.aql-col input:focus { border-color: var(--primary); outline: none; }

.sampling-toggle {
  display: flex; gap: 0; border: 1.5px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.sampling-toggle button {
  padding: 10px 18px; border: none; cursor: pointer;
  font-size: 13px; font-weight: 600; background: var(--surface);
  color: var(--text-secondary); transition: all var(--duration-fast);
}
.sampling-toggle button.active { background: var(--primary); color: white; }

/* Signature area */
.sign-area {
  border: 2px dashed var(--border); border-radius: var(--radius);
  min-height: 100px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; background: var(--surface-secondary);
  transition: all var(--duration-fast);
}
.sign-area:hover { border-color: var(--primary); }
.sign-area canvas { max-width: 100%; max-height: 100px; }
.sign-area .placeholder { color: var(--text-tertiary); font-size: 13px; }

/* ============================================================
   QC MOBILE TASK CARDS
   ============================================================ */
.qc-task-card {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: var(--sp-5); margin-bottom: var(--sp-3);
  box-shadow: var(--shadow-sm); border: 1px solid var(--border-light);
  border-left: 4px solid var(--primary);
  transition: all var(--duration-fast) var(--ease-out);
  cursor: pointer;
}
.qc-task-card:hover { box-shadow: var(--shadow-md); transform: translateX(2px); }
.qc-task-card.urgent { border-left-color: var(--c-red-500); }
.qc-task-title { font-size: 15px; font-weight: 700; margin-bottom: var(--sp-2); color: var(--text-primary); }
.qc-task-meta { font-size: 12px; color: var(--text-secondary); display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.qc-task-meta span {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; background: var(--surface-secondary);
  border-radius: var(--radius-sm); font-size: 11px;
}

/* ============================================================
   REJECT BANNER (驳回提示条)
   ============================================================ */
.reject-banner {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  background: #FEF2F2; border: 1px solid #FECACA;
  border-left: 4px solid var(--c-red-500);
  border-radius: var(--radius); padding: var(--sp-4);
  margin-bottom: var(--sp-4);
}
.reject-banner-icon { font-size: 24px; line-height: 1; flex-shrink: 0; }
.reject-banner-body { flex: 1; }
.reject-banner-title {
  font-weight: 600; color: var(--c-red-600);
  font-size: 14px; margin-bottom: var(--sp-1);
}
.reject-banner-notes {
  font-size: 13px; color: var(--c-red-700);
  background: rgba(255,255,255,0.7); border-radius: var(--radius-sm);
  padding: var(--sp-2) var(--sp-3);
  margin-top: var(--sp-1);
}

/* ============================================================
   IMAGE VIEWER
   ============================================================ */
.image-viewer {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.95);
  /* 2026-09-19 修：原 9999 低于 .modal-overlay 的 10000 —— 产品美化图库本身是弹窗，
     从卡片里点视频缩略图时播放器会被弹窗盖在下面，用户「点了没反应」。
     提到 100050：高于 .modal-overlay(10000)、openModal 自抬的 topZ+10(≤10060)、
     drawing-modal(21000)、stagemodal-overlay(100000)，仍低于 toast(100100)。 */
  z-index: 100050;
  align-items: center; justify-content: center;
}
.image-viewer.show { display: flex; }
.image-viewer img, .image-viewer video { max-width: 95vw; max-height: 95vh; border-radius: var(--radius); }
.image-viewer .close {
  position: absolute; top: var(--sp-5); right: var(--sp-5);
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,0.15); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; cursor: pointer; border: none;
  transition: background var(--duration-fast);
}
.image-viewer .close:hover { background: rgba(255,255,255,0.3); }

/* ============================================================
   ORDER PRODUCT ROW (inline in modal)
   ============================================================ */
.order-product-row {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--sp-4); margin-bottom: var(--sp-3);
  background: var(--surface-secondary);
}
.order-product-row .row-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: var(--sp-3);
}
.order-product-row .row-header strong { font-size: 13px; }

/* ============================================================
   TABS
   ============================================================ */
.tabs {
  display: flex; gap: 0; border-bottom: 2px solid var(--border-light);
  margin-bottom: var(--sp-5);
}
.tab-item {
  padding: var(--sp-3) var(--sp-5); cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all var(--duration-fast);
}
.tab-item:hover { color: var(--text-primary); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.hidden { display: none !important; }
.text-muted { color: var(--text-secondary); }
.text-success { color: var(--c-green-600); }
.text-danger { color: var(--c-red-600); }
.text-warning { color: var(--c-amber-600); }
.text-info { color: var(--c-blue-600); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }
.mt-4 { margin-top: var(--sp-1); }
.mt-8 { margin-top: var(--sp-2); }
.mt-12 { margin-top: var(--sp-3); }
.mt-16 { margin-top: var(--sp-4); }
.mt-24 { margin-top: var(--sp-6); }
.mb-8 { margin-bottom: var(--sp-2); }
.mb-16 { margin-bottom: var(--sp-4); }
.mb-24 { margin-bottom: var(--sp-6); }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: var(--sp-2); }
.gap-12 { gap: var(--sp-3); }
.gap-16 { gap: var(--sp-4); }

.loading {
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-12); color: var(--text-tertiary); gap: var(--sp-3);
}
.loading .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); animation: dotPulse 1.2s ease-in-out infinite; }
.loading .dot:nth-child(2) { animation-delay: 0.15s; }
.loading .dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes dotPulse { 0%, 80%, 100% { transform: scale(0.5); opacity: 0.3; } 40% { transform: scale(1); opacity: 1; } }

.empty-state {
  text-align: center; padding: var(--sp-12) var(--sp-5);
  color: var(--text-tertiary);
}
.empty-state .icon { font-size: 48px; margin-bottom: var(--sp-3); opacity: 0.6; }
.empty-state .title { font-size: 15px; font-weight: 600; color: var(--text-secondary); margin-bottom: var(--sp-1); }
.empty-state .desc { font-size: 13px; }

/* ============================================================
   操作记录页：自适应填充，避免内容被 .inspect-table 的窄列规则挤压
   ============================================================ */
.op-log-page {
  width: 100%;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.op-log-header { display: flex; flex-direction: column; gap: 2px; }
.op-log-header h2 { margin: 0; font-size: 18px; }
.op-log-tip { font-size: 12px; color: var(--text-secondary); }
.op-log-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
  padding: var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.op-log-filters select,
.op-log-filters input {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--surface);
  color: var(--text-primary);
}
.op-log-filters input[type="date"] { width: 130px; }
.op-log-filters input#opLogKeyword { min-width: 160px; flex: 1; max-width: 300px; }
.op-log-filters button { white-space: nowrap; }
.op-log-table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.op-log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: auto;
  background: var(--surface);
}
.op-log-table thead { position: sticky; top: 0; z-index: 1; }
.op-log-table th {
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  background: var(--c-blue-100);
  color: var(--c-blue-800);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.op-log-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  font-size: 12px;
  color: var(--text-primary);
}
.op-log-table tbody tr:nth-child(even) { background: var(--c-slate-50); }
.op-log-table tbody tr:hover { background: var(--c-blue-50); }
.op-log-table th:nth-child(1), .op-log-table td:nth-child(1) { min-width: 140px; } /* 时间 */
.op-log-table th:nth-child(2), .op-log-table td:nth-child(2) { min-width: 80px; }  /* 用户 */
.op-log-table th:nth-child(3), .op-log-table td:nth-child(3) { min-width: 70px; }  /* 角色 */
.op-log-table th:nth-child(4), .op-log-table td:nth-child(4) { min-width: 80px; }  /* 模块 */
.op-log-table th:nth-child(5), .op-log-table td:nth-child(5) { min-width: 60px; }  /* 动作 */
.op-log-table th:nth-child(6), .op-log-table td:nth-child(6) { min-width: 110px; } /* 对象 */
.op-log-table th:nth-child(7), .op-log-table td:nth-child(7) { min-width: 260px; } /* 描述 */
.op-log-table th:nth-child(8), .op-log-table td:nth-child(8) { min-width: 110px; } /* IP */
.op-log-table th:nth-child(9), .op-log-table td:nth-child(9) { min-width: 60px; text-align: center; } /* 状态 */

/* ============================================================
   RESPONSIVE — Mobile (< 768px)
   ============================================================ */
@media (max-width: 767px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-xl);
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.5); z-index: 199;
  }
  .sidebar-overlay.show { display: block; }
  .main-content { margin-left: 0; }
  .mobile-menu-btn { display: flex; }

  /* Mobile bottom nav */
  .mobile-nav-bar {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--surface); border-top: 1px solid var(--border);
    display: flex; z-index: 150;
    padding: 4px 0 env(safe-area-inset-bottom, 0);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
  }
  .mobile-nav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    padding: 6px 4px; cursor: pointer; font-size: 10px;
    color: var(--text-secondary); transition: color var(--duration-fast);
    gap: 2px;
  }
  .mobile-nav-item.active { color: var(--primary); font-weight: 600; }
  .mobile-nav-item .icon { font-size: 20px; }

  .page-content { padding: var(--sp-4) var(--sp-3) calc(var(--mobile-nav-h) + var(--sp-5)); }
  .topbar { padding: 0 var(--sp-4); }
  .topbar-left h1 { font-size: 15px; }

  .stats-grid { grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
  .stat-card { padding: var(--sp-3); }
  .stat-value { font-size: 22px; }
  .stat-icon { width: 40px; height: 40px; font-size: 18px; }

  .form-row, .form-row.triple { grid-template-columns: 1fr; gap: var(--sp-3); }
  .modal {
    max-height: 95vh; border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-width: 100%;
    /* 2026-09-21 需求F：窄屏是底部抽屉，尺寸由视口接管，禁用拖拽缩放 */
    resize: none; min-width: 0; min-height: 0; width: 100%;
  }
  .modal-overlay {
    align-items: flex-end; padding: 0;
  }
  .modal-body { padding: var(--sp-4); }

  .photo-grid { grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
  .photo-card, .photo-add-card { min-height: 130px; }
  .filter-bar { flex-direction: column; }
  .filter-group { min-width: 100%; }

  /* Tables: show as cards on very small screens */
  .table-wrap table { font-size: 12px; }
  th, td { padding: var(--sp-2) var(--sp-2); font-size: 11px; }
}

/* Tablet */
@media (min-width: 768px) and (max-width: 1023px) {
  .sidebar { width: 220px; }
  .main-content { margin-left: 220px; }
  .form-row.triple { grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
  .mobile-nav-bar { display: none; }
  .mobile-menu-btn { display: none; }
}

/* Desktop */
@media (min-width: 1024px) {
  .mobile-nav-bar { display: none; }
  .mobile-menu-btn { display: none; }
}

/* ========== 生产进度时间线 ========== */
.production-timeline { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }
.production-stage { border: 2px solid var(--border); border-radius: var(--radius); padding: 16px; transition: all var(--duration-fast); }
.production-stage.completed { border-color: var(--c-green-500); background: #F0FDF4; }
.production-stage.in_progress { border-color: var(--c-blue-500); background: #EFF6FF; }
.production-stage.pending { border-color: var(--border); background: var(--surface); }
.stage-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.stage-title { font-weight: 600; font-size: 16px; }
.stage-body { display: flex; flex-direction: column; gap: 12px; }
.stage-dates { display: flex; gap: 16px; flex-wrap: wrap; }
.stage-date { flex: 1; min-width: 180px; }
.stage-date label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.stage-notes { margin-top: 8px; }
.stage-notes label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.stage-actions { display: flex; gap: 8px; margin-top: 12px; }

/* 编辑弹窗 - 产品卡片表格化排版 */
#generic-modal .order-product-row {
  display: grid;
  grid-template-columns: 40px 80px 60px 80px 90px 80px 90px 60px 50px 70px 70px 70px 70px 70px 70px 70px 40px;
  gap: 4px;
  align-items: start;
  padding: 8px;
  border-bottom: 1px solid var(--border);
}
#generic-modal .order-product-row .field {
  margin-bottom: 0;
}
#generic-modal .order-product-row .form-row {
  display: contents;
}

/* ============================================================
   Luckysheet Excel 编辑器样式覆盖
   ============================================================ */

/* 确保编辑器弹窗完全可交互 */
#excel-editor-modal {
  pointer-events: auto;
  user-select: text;
}
#excel-editor-modal * {
  pointer-events: auto !important;
  box-sizing: border-box;
}

/* Luckysheet 容器 */
#excel-editor-container {
  position: relative;
  overflow: hidden;
  user-select: text;
}
#excel-editor-container .luckysheet-grid-window,
#excel-editor-container .luckysheet-cell-main,
#excel-editor-container .luckysheet-canvas-control,
#excel-editor-container .luckysheet-cols-h,
#excel-editor-container .luckysheet-rows-h {
  position: relative !important;
  z-index: auto !important;
  pointer-events: auto !important;
  user-select: text !important;
}

/* 确保 Luckysheet 工具栏可点击 */
#excel-editor-container .luckysheet-toolbar-container,
#excel-editor-container .luckysheet-wa-editor {
  z-index: auto !important;
  pointer-events: auto !important;
}
