/* ============== 基础重置 ============== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
/* 确保 hidden 属性优先于 display:flex 等规则 */
[hidden] { display: none !important; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", Roboto, "Helvetica Neue", sans-serif;
  font-size: 14px;
  color: #1f2937;
  background: #f3f5f9;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; color: inherit; }
table { border-collapse: collapse; width: 100%; }
em { color: #ef4444; font-style: normal; }

/* ============== 应用外壳：左侧边栏 + 右侧主内容 ============== */
.app-shell {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

/* ============== 左侧边栏（WorkBuddy 风格深色） ============== */
.sidebar {
  flex: 0 0 240px;
  width: 240px;
  background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand .logo {
  width: 38px; height: 38px; flex: 0 0 38px;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  border: none; border-radius: 10px;
  color: #fff; font-weight: 700; font-size: 14px;
}
.sidebar-title { color: #f8fafc; font-size: 14px; font-weight: 600; line-height: 1.3; }
.sidebar-sub { color: #64748b; font-size: 11px; margin-top: 2px; }

.sidebar-nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-link {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px;
  border: none; background: transparent;
  border-radius: 8px;
  color: #94a3b8;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  width: 100%;
  text-align: left;
  transition: all 0.15s;
}
.sidebar-link:hover { background: rgba(148,163,184,0.12); color: #e2e8f0; }
.sidebar-link.active { background: #2563eb; color: #fff; }
.sidebar-btn { font: inherit; }

.sidebar-stats {
  margin: auto 0 0;
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-stats-title { font-size: 11px; color: #64748b; margin-bottom: 8px; letter-spacing: 0.5px; }
.sidebar-stat {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 2px;
  font-size: 12px; color: #94a3b8;
}
.sidebar-stat b { font-size: 13px; color: #e2e8f0; }
.sidebar-stat b.num-warn { color: #f59e0b; }
.sidebar-stat b.num-danger { color: #f87171; }
.sidebar-stat b.num-ok { color: #34d399; }

.sidebar-footer { padding: 12px 16px 16px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-user-actions { display: flex; gap: 6px; margin-top: 10px; }
.sidebar-btn-ghost {
  flex: 1;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  color: #cbd5e1;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.sidebar-btn-ghost:hover { background: rgba(255,255,255,0.16); color: #fff; }

/* ============== 通用按钮 ============== */
.btn {
  border: 1px solid transparent;
  background: transparent;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s;
  display: inline-flex; align-items: center; gap: 4px;
  white-space: nowrap;
}
.btn-primary { background: #fff; color: #1e3a8a; }
.btn-primary:hover { background: #eff6ff; }
.btn-ghost { background: rgba(255,255,255,0.1); color: #fff; border-color: rgba(255,255,255,0.2); }
.btn-ghost:hover { background: rgba(255,255,255,0.2); }
.btn-ghost.danger { background: rgba(239, 68, 68, 0.15); border-color: rgba(239, 68, 68, 0.4); }
.btn-ghost.danger:hover { background: rgba(239, 68, 68, 0.3); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-link { background: transparent; color: #2563eb; padding: 2px 6px; }
.btn-link:hover { background: #eff6ff; }
.btn-link.danger { color: #ef4444; }
.btn-link.danger:hover { background: #fee2e2; }

/* ============== 右侧主内容区 ============== */
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content-header {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 12px 24px;
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 40;
}
.content-title { font-size: 16px; font-weight: 600; color: #1f2937; }
.content-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.content-actions .btn { background: #fff; border: 1px solid #d1d5db; color: #374151; }
.content-actions .btn:hover { background: #f3f4f6; }
.content-actions .btn.danger { color: #dc2626; border-color: #fca5a5; }
.content-actions .btn.danger:hover { background: #fef2f2; }
.content-actions .btn-primary-solid { background: #2563eb; border-color: #2563eb; color: #fff; }
.content-actions .btn-primary-solid:hover { background: #1d4ed8; }
.content-body { flex: 1; padding: 22px 24px; max-width: 1600px; width: 100%; margin: 0 auto; }
.section { background: #fff; border-radius: 12px; padding: 20px 24px; margin-bottom: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.03);
  scroll-margin-top: 130px; }
.section-title { font-size: 15px; font-weight: 600; color: #1e3a8a; margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px; }
.section-title::before {
  content: ''; width: 4px; height: 16px; background: #2563eb; border-radius: 2px;
}

/* ============== 老化箱：左侧箱子栏 + 右侧样品明细 ============== */
.box-layout {
  display: flex;
  gap: 14px;
  align-items: stretch;
}
.box-sidebar {
  flex: 0 0 280px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  max-height: 720px;
  padding-right: 2px;
}
.box-item {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  padding: 12px 14px;
  cursor: pointer;
  position: relative;
  transition: all 0.15s;
}
.box-item:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.07); border-color: #c7d2fe; }
.box-item.active { border-color: #2563eb; background: #eff6ff; box-shadow: 0 0 0 2px rgba(37,99,235,0.12); }
.box-item.has-overdue { border-left: 3px solid #ef4444; }
.box-item.has-warning { border-left: 3px solid #f59e0b; }
.box-item-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.box-item-id { font-size: 20px; font-weight: 800; color: #1e3a8a; letter-spacing: 1px; }
.box-item.active .box-item-id { color: #1d4ed8; }
.box-item-temp {
  background: #2563eb; color: #fff;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
}
.box-item-temp.hot { background: #dc2626; }
.box-item-temp.warm { background: #f59e0b; }
.box-item-temp.cool { background: #0891b2; }
.box-item-info { font-size: 11px; color: #6b7280; margin-top: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.box-item-stats { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; font-size: 11px; color: #6b7280; }
.box-item-stats b { color: #1f2937; font-size: 12px; }
.box-item-stats .warn b { color: #f59e0b; }
.box-item-stats .danger b { color: #ef4444; }
.box-item-stats .ok b { color: #10b981; }
.box-item-alert {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: #ef4444; margin-right: 6px; vertical-align: middle;
  animation: pulse 1.5s infinite;
}
.box-item-empty { padding: 24px 10px; text-align: center; color: #9ca3af; font-size: 12px;
  border: 1px dashed #e5e7eb; border-radius: 10px; }

/* 右侧样品明细面板 */
.box-detail {
  flex: 1;
  min-width: 0;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
  max-height: 720px;
  overflow: hidden;
  transition: box-shadow 0.2s;
  position: relative;
}
.box-detail:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.06); }
.box-detail.has-overdue { border-color: #ef4444; }
.box-detail.has-warning { border-color: #f59e0b; }

.box-col-head { padding: 14px 16px 10px; border-bottom: 1px solid #f3f4f6; }
.box-col-head-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.box-col-id {
  font-size: 22px; font-weight: 800; color: #1e3a8a;
  letter-spacing: 1px; cursor: default;
}
body.is-admin .box-col-id { cursor: pointer; }
body.is-admin .box-col-id:hover { color: #2563eb; text-decoration: underline dotted; }
.box-col-temp {
  background: #2563eb; color: #fff;
  padding: 4px 12px; border-radius: 20px;
  font-size: 13px; font-weight: 600;
  cursor: default;
}
.box-col-temp.hot { background: #dc2626; }
.box-col-temp.warm { background: #f59e0b; }
.box-col-temp.cool { background: #0891b2; }
body.is-admin .box-col-temp { cursor: pointer; }
body.is-admin .box-col-temp:hover { opacity: 0.85; }
.box-col-info { font-size: 11px; color: #6b7280; margin-bottom: 8px; }
.box-col-stats { display: flex; gap: 6px; flex-wrap: wrap; }
.box-col-stat {
  background: #f3f4f6; border-radius: 6px;
  padding: 4px 8px; font-size: 11px; color: #4b5563;
  display: inline-flex; align-items: center; gap: 3px;
}
.box-col-stat b { font-size: 13px; color: #1f2937; }
.box-col-stat.warn b { color: #f59e0b; }
.box-col-stat.danger b { color: #ef4444; }
.box-col-stat.ok b { color: #10b981; }

.box-col-products { flex: 1; overflow-y: auto; padding: 8px; }
.box-product-card {
  border: 1px solid #e5e7eb; border-radius: 8px;
  padding: 10px; margin-bottom: 8px;
  background: #f9fafb; cursor: pointer; transition: all 0.15s;
}
.box-product-card:hover { background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.box-product-card.status-overdue { border-left: 3px solid #ef4444; background: #fef2f2; }
.box-product-card.status-warning { border-left: 3px solid #f59e0b; background: #fffbeb; }
.box-product-card.status-active { border-left: 3px solid #3b82f6; }
.box-product-card.status-done { opacity: 0.55; border-left: 3px solid #10b981; }
.box-product-batch {
  font-family: monospace; font-size: 12px; font-weight: 600;
  color: #1f2937; margin-bottom: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.box-product-name {
  font-size: 12px; color: #6b7280; margin-bottom: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.box-product-meta { display: flex; justify-content: space-between; align-items: center; font-size: 11px; }
.box-product-layer { background: #eef2ff; color: #4338ca; padding: 1px 6px; border-radius: 4px; font-weight: 500; }
.box-product-countdown { font-weight: 600; }
.box-product-countdown.danger { color: #ef4444; }
.box-product-countdown.warn { color: #f59e0b; }
.box-product-countdown.ok { color: #10b981; }
.box-product-countdown.muted { color: #9ca3af; }
.box-col-empty { padding: 20px 10px; text-align: center; color: #9ca3af; font-size: 12px; }
.box-col-foot {
  padding: 8px 12px; border-top: 1px solid #f3f4f6;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: #6b7280;
}
.box-col-foot .rule { background: #eef2ff; color: #4338ca; padding: 2px 8px; border-radius: 4px; font-weight: 500; }
.box-col-admin { padding: 6px 12px 8px; text-align: right; }

.box-alert {
  position: absolute; top: 8px; right: 8px;
  width: 10px; height: 10px; border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
  70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* 温度调整规则提示 */
.temp-rule-hint { padding: 8px 12px; border-radius: 8px; font-size: 12px; margin-top: 4px; }
.temp-rule-hint.ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.temp-rule-hint.warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* ============== 筛选条 ============== */
.filter-bar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
.filter-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab {
  background: #f3f4f6; color: #4b5563;
  border: 1px solid transparent;
  padding: 6px 14px; border-radius: 8px;
  cursor: pointer; font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all 0.15s;
}
.tab:hover { background: #e5e7eb; }
.tab.active { background: #2563eb; color: #fff; }
.count {
  background: rgba(255,255,255,0.25); color: inherit;
  font-size: 11px; padding: 1px 7px; border-radius: 10px; font-weight: 600;
}
.tab:not(.active) .count { background: #e5e7eb; color: #4b5563; }
.count.warn { background: #fef3c7; color: #92400e; }
.tab.active .count.warn { background: rgba(255,255,255,0.25); color: #fff; }
.count.danger { background: #fee2e2; color: #991b1b; }
.tab.active .count.danger { background: rgba(255,255,255,0.25); color: #fff; }
.count.ok { background: #d1fae5; color: #065f46; }
.tab.active .count.ok { background: rgba(255,255,255,0.25); color: #fff; }

.filter-right { display: flex; gap: 8px; }
.input, .select {
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  outline: none;
  transition: border 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.input.small { width: 110px; }

/* ============== 表格 ============== */
.table-wrap { overflow-x: auto; border-radius: 8px; border: 1px solid #e5e7eb; }
.data-table { font-size: 13px; min-width: 1200px; }
.data-table th, .data-table td {
  padding: 10px 12px; text-align: left;
  border-bottom: 1px solid #f3f4f6;
  white-space: nowrap;
}
.data-table th {
  background: #f9fafb; color: #4b5563; font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.3px;
  position: sticky; top: 0; z-index: 1;
}
.data-table tbody tr { transition: background 0.1s; }
.data-table tbody tr:hover { background: #f9fafb; }
.data-table tbody tr.row-overdue { background: #fef2f2; }
.data-table tbody tr.row-overdue:hover { background: #fee2e2; }
.data-table tbody tr.row-warning { background: #fffbeb; }
.data-table tbody tr.row-done { opacity: 0.65; }

.status-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 12px;
  font-size: 11px; font-weight: 600;
}
.status-active { background: #dbeafe; color: #1e40af; }
.status-warning { background: #fef3c7; color: #92400e; }
.status-overdue { background: #fee2e2; color: #991b1b; }
.status-done { background: #d1fae5; color: #065f46; }

.countdown { font-weight: 600; }
.countdown.danger { color: #ef4444; }
.countdown.warn { color: #f59e0b; }
.countdown.ok { color: #10b981; }
.countdown.muted { color: #9ca3af; }

.actions { display: flex; gap: 4px; }
.empty { padding: 60px 20px; text-align: center; color: #9ca3af; font-size: 14px; }

.muted { color: #6b7280; }
.muted.small { font-size: 12px; }
.hint { color: #6b7280; font-size: 11px; margin-top: 4px; display: block; }
.hint.auto { color: #059669; font-weight: 500; }

/* ============== 弹窗 ============== */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-mask { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.5); backdrop-filter: blur(2px); }
.modal-box {
  position: relative;
  background: #fff; border-radius: 14px;
  width: 100%; max-width: 720px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 24px; border-bottom: 1px solid #e5e7eb;
}
.modal-head h3 { font-size: 16px; font-weight: 600; color: #1f2937; }
.icon-btn { background: transparent; border: none; cursor: pointer; font-size: 18px;
  color: #6b7280; width: 32px; height: 32px; border-radius: 6px; }
.icon-btn:hover { background: #f3f4f6; color: #1f2937; }
.modal-body { padding: 20px 24px; }
.modal-foot {
  padding: 14px 24px; border-top: 1px solid #e5e7eb;
  display: flex; justify-content: flex-end; gap: 8px;
}
.modal-foot .btn-ghost { color: #4b5563; background: #f3f4f6; }
.modal-foot .btn-ghost:hover { background: #e5e7eb; }
.modal-foot .btn-primary { background: #2563eb; color: #fff; }
.modal-foot .btn-primary:hover { background: #1d4ed8; }
.modal-foot .detail-actions { margin-right: auto; display: flex; gap: 8px; align-items: center; }

/* ============== 表单 ============== */
.form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.field span { color: #4b5563; font-weight: 500; }
.field .input, .field .select, .field textarea {
  border: 1px solid #d1d5db; background: #fff;
  border-radius: 8px; padding: 8px 12px; font-size: 13px;
  outline: none; transition: border 0.15s, box-shadow 0.15s;
}
.field .input:focus, .field .select:focus, .field textarea:focus {
  border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.field input[readonly] { background: #f9fafb; color: #6b7280; }
.field.full { grid-column: span 2; }
.field textarea { resize: vertical; min-height: 60px; }
.free-rule-inputs { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============== 存放位置清单（多箱多规则） ============== */
.placement-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 6px; }
.placement-row {
  border: 1px solid #e5e7eb; border-radius: 8px; padding: 10px;
  background: #f9fafb; display: flex; flex-direction: column; gap: 8px;
}
.placement-row:focus-within { border-color: #93c5fd; background: #fff; }
.p-line1 {
  display: grid; grid-template-columns: minmax(0,1.1fr) minmax(0,1.6fr) 76px auto;
  gap: 8px; align-items: center;
}
.placement-row select, .placement-row input {
  border: 1px solid #d1d5db; border-radius: 6px; padding: 7px 8px;
  font-size: 13px; background: #fff; color: #111827; width: 100%;
  box-sizing: border-box;
}
.p-line1 .p-qty { text-align: center; }
.p-free { display: flex; gap: 8px; flex-wrap: wrap; }
.p-free input { flex: 0 1 auto; }
.p-free .p-free-temp { max-width: 110px; }
.p-free .p-free-days { max-width: 100px; }
.p-free .p-free-hours { max-width: 100px; }
.p-free .p-free-label { flex: 1; min-width: 120px; }
.btn-add-placement {
  margin-top: 4px; border: 1px dashed #94a3b8; background: #fff; color: #1d4ed8;
  border-radius: 8px; padding: 8px 14px; cursor: pointer; font-size: 13px; width: 100%;
}
.btn-add-placement:hover { background: #eff6ff; border-color: #2563eb; }

/* ============== 规则表 ============== */
.rules-table { font-size: 13px; }
.rules-table th, .rules-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid #f3f4f6; }
.rules-table th { background: #f9fafb; color: #4b5563; font-weight: 600; }
.rules-table input { width: 80px; padding: 4px 8px; border: 1px solid #d1d5db; border-radius: 6px; }
.add-rule { display: flex; gap: 8px; margin-top: 14px; align-items: center; padding: 12px;
  background: #f9fafb; border-radius: 8px; }
.add-rule .btn { color: #2563eb; background: #fff; border: 1px solid #d1d5db; }
.add-rule .btn:hover { background: #eff6ff; border-color: #2563eb; }

/* ============== 详情 ============== */
.detail-row { display: flex; padding: 10px 0; border-bottom: 1px solid #f3f4f6; }
.detail-row:last-child { border-bottom: none; }
.detail-label { width: 120px; color: #6b7280; font-size: 13px; }
.detail-value { flex: 1; color: #1f2937; font-weight: 500; }

/* ============== Toast ============== */
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
  background: #1f2937; color: #fff;
  padding: 10px 20px; border-radius: 8px;
  font-size: 13px; z-index: 200;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  animation: toastIn 0.2s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.toast.success { background: #059669; }
.toast.error { background: #dc2626; }
.toast.warn { background: #d97706; }

/* ============== 页脚 ============== */
.footer {
  margin-top: 24px; padding: 16px 0;
  display: flex; justify-content: space-between;
  color: #9ca3af; font-size: 12px;
}

/* 响应式 */
@media (max-width: 768px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    flex: none; width: 100%; height: auto; position: static;
    flex-direction: row; flex-wrap: wrap; align-items: center;
    overflow: visible;
  }
  .sidebar-brand { border-bottom: none; padding: 10px 12px; }
  .sidebar-nav { flex-direction: row; padding: 8px 10px; flex-wrap: wrap; }
  .sidebar-stats { margin: 0; border-top: none; padding: 8px 12px;
    display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
  .sidebar-stats-title { display: none; }
  .sidebar-stat { padding: 2px; }
  .sidebar-footer { padding: 10px 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
  .sidebar-user-actions { margin-top: 0; margin-left: auto; }
  .content-header { padding: 10px 14px; }
  .content-body { padding: 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: span 1; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .box-layout { flex-direction: column; }
  .box-sidebar { flex-direction: row; flex: 0 0 auto; overflow-x: auto; overflow-y: hidden; max-height: none; }
  .box-item { flex: 0 0 220px; }
  .box-detail { max-height: none; }
}

/* ============== 登录页 ============== */
.login-page {
  position: fixed; inset: 0; z-index: 999;
  background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #2563eb 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%; max-width: 380px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: loginIn 0.3s ease;
}
@keyframes loginIn {
  from { opacity: 0; transform: translateY(-15px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.login-logo {
  width: 64px; height: 64px; margin: 0 auto 16px;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 24px; letter-spacing: 1px;
}
.login-card h2 { font-size: 20px; color: #1f2937; margin-bottom: 4px; }
.login-sub { font-size: 12px; color: #9ca3af; margin-bottom: 28px; }
.login-field { margin-bottom: 14px; }
.login-field input {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 14px;
  outline: none;
  transition: border 0.15s, box-shadow 0.15s;
}
.login-field input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.login-error {
  background: #fee2e2; color: #991b1b;
  padding: 8px 14px; border-radius: 8px;
  font-size: 13px; margin-bottom: 14px;
}
.btn-login {
  width: 100%;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 15px; font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.btn-login:hover { opacity: 0.92; }
.btn-login:active { transform: scale(0.98); }
.login-hint { font-size: 12px; color: #9ca3af; margin-top: 18px; }

/* ============== 用户徽章 ============== */
.user-badge {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
}
.user-badge .role-tag {
  background: #fbbf24; color: #78350f;
  font-size: 10px; padding: 1px 6px; border-radius: 8px; font-weight: 700;
}
.user-badge .role-tag.user { background: #a7f3d0; color: #064e3b; }

/* 管理员专属按钮：普通用户隐藏 */
.admin-only { display: none; }
body.is-admin .admin-only { display: inline-flex; }

/* 小弹窗 */
.modal-sm { max-width: 420px; }
.form-grid.single { grid-template-columns: 1fr; }

/* ============== 添加老化箱按钮 ============== */
.btn-add-box {
  margin-left: auto;
  background: #2563eb; color: #fff;
  border: none; border-radius: 8px;
  padding: 5px 14px; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background 0.15s;
}
.btn-add-box:hover { background: #1d4ed8; }

/* 箱卡移除按钮 */
.box-admin-actions { margin-top: 8px; text-align: right; }

