/**
 * 孵化间系统 — 淡绿主题 PWA 样式
 * 顶部 6 tab，平面图长方形布局
 */
:root {
  --primary: #2e7d32;
  --primary-light: #e8f5e9;
  --primary-dark: #1b5e20;
  --danger: #d32f2f;
  --success: #2e7d32;
  --warning: #f57c00;
  --gray: #9e9e9e;
  --gray-light: #f5f5f5;
  --bg: #f0f7f0;
  --text: #212121;
  --text-light: #757575;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.12);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, 'PingFang SC', 'Noto Sans SC', sans-serif;
  font-size: 22px; color: var(--text); background: var(--bg);
  min-height: 100vh; overflow-x: hidden;
}
.hidden { display: none !important; }
.page { padding: 12px; max-width: 820px; margin: 0 auto; padding-bottom: 16px; }
.page-title { font-size: 26px; font-weight: 700; text-align: center; padding: 10px 0; color: var(--primary); }

.topbar { background: var(--primary); color: #fff; padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }
.topbar .title { font-size: 20px; font-weight: 700; }
.topbar .user { font-size: 15px; opacity: 0.9; }
.topbar button { background: rgba(255,255,255,0.2); color: #fff; border: 0; border-radius: 8px; padding: 6px 12px; font-size: 16px; }

/* 顶部 tab */
.top-tabs { background: #fff; display: flex; border-bottom: 2px solid var(--primary-light); position: sticky; top: 46px; z-index: 49; max-width: 820px; margin: 0 auto; overflow-x: auto; }
.top-tabs .tab { flex: 1; min-width: 80px; padding: 10px 4px; text-align: center; font-size: 14px; color: var(--text-light); cursor: pointer; border: 0; background: none; white-space: nowrap; }
.top-tabs .tab .icon { font-size: 20px; display: block; }
.top-tabs .tab.active { color: var(--primary); font-weight: 700; border-bottom: 3px solid var(--primary); }

.card { background: #fff; border-radius: var(--radius); padding: 12px; margin: 10px 0; box-shadow: var(--shadow); }
.card h3 { font-size: 17px; color: var(--primary-dark); margin-bottom: 8px; border-bottom: 2px solid var(--primary-light); padding-bottom: 6px; }

.field { margin: 10px 0; }
.field label { display: block; font-size: 15px; color: var(--text-light); margin-bottom: 5px; }
.field input, .field select, .field textarea { width: 100%; padding: 11px; font-size: 19px; border: 2px solid #ddd; border-radius: 10px; background: #fff; }
.field input:focus, .field select:focus { border-color: var(--primary); outline: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 10px 14px; border-radius: 20px; background: #fff; border: 2px solid #ddd; font-size: 17px; cursor: pointer; user-select: none; }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip.disabled { opacity: 0.4; background: #eee; }

.btn { display: block; width: 100%; padding: 15px; font-size: 21px; font-weight: 600; border: 0; border-radius: 12px; background: var(--primary); color: #fff; cursor: pointer; margin: 10px 0; }
.btn:active { transform: scale(0.98); }
.btn.secondary { background: #fff; color: var(--primary); border: 2px solid var(--primary); }
.btn.danger { background: var(--danger); }
.btn.warn { background: var(--warning); }

/* ─── 平面图 ─── */
.plan { display: flex; gap: 6px; background: #fff; padding: 8px; border-radius: var(--radius); box-shadow: var(--shadow); margin: 8px 0; }
.plan-side { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.plan-line {
  border: 2px solid var(--primary-light); border-radius: 10px; padding: 8px; text-align: center; cursor: pointer;
  background: #fff; transition: 0.15s;
}
.plan-line:hover { border-color: var(--primary); }
.plan-line.disabled { background: #eee; color: var(--gray); cursor: not-allowed; opacity: 0.6; }
.plan-line.warn { border-color: var(--warning); background: #fff3e0; }
.plan-line .ln { font-size: 13px; color: var(--text-light); }
.plan-line .cap { font-size: 18px; font-weight: 700; color: var(--primary); }
.plan-line .days { font-size: 14px; }
.plan-aisle { width: 18px; background: repeating-linear-gradient(45deg, #ddd, #ddd 4px, #fff 4px, #fff 8px); border-radius: 4px; }
.plan-temp { font-size: 12px; color: var(--text-light); text-align: center; padding: 4px; }

.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th, .tbl td { padding: 7px 5px; text-align: center; border-bottom: 1px solid #eee; }
.tbl th { background: var(--primary-light); color: var(--primary-dark); }
.tbl tr.total td { font-weight: 700; background: var(--primary-light); }

.list-item { background: #fff; border-radius: 10px; padding: 12px; margin: 8px 0; box-shadow: var(--shadow); }
.list-item .meta { font-size: 14px; color: var(--text-light); }
.badge { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 13px; }
.badge.pending { background: #fff3e0; color: var(--warning); }
.badge.approved { background: #e8f5e9; color: var(--success); }
.badge.rejected { background: #ffebee; color: var(--danger); }
.badge.issue { background: #fff3e0; color: var(--warning); }
.badge.normal { background: #e8f5e9; color: var(--success); }

.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.kpi-card { background: #fff; border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.kpi-card .label { font-size: 14px; color: var(--text-light); }
.kpi-card .value { font-size: 26px; font-weight: 700; color: var(--primary); }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 12px; }
.modal-box { background: #fff; border-radius: 16px; padding: 18px; max-width: 540px; width: 100%; max-height: 88vh; overflow-y: auto; }
.modal-title { font-size: 20px; font-weight: 700; margin-bottom: 10px; color: var(--primary); }
.modal-detail { font-size: 15px; margin-bottom: 14px; line-height: 1.6; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { margin: 0; }

.login-box { max-width: 360px; margin: 60px auto; background: #fff; border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.login-box h1 { text-align: center; color: var(--primary); font-size: 26px; margin-bottom: 18px; }
.toast { position: fixed; top: 60px; left: 50%; transform: translateX(-50%); background: #333; color: #fff; padding: 11px 18px; border-radius: 8px; z-index: 300; font-size: 15px; }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--success); }
.link-btn { background: none; border: 0; color: var(--primary); font-size: 15px; text-decoration: underline; cursor: pointer; }
.sig-canvas { border: 2px solid #ddd; border-radius: 8px; background: #fff; width: 100%; touch-action: none; }
.back-btn { background: none; border: 0; color: var(--primary); font-size: 16px; cursor: pointer; margin-bottom: 8px; }

/* ─── 平面图（v2：分房间+过道+温度+容量条） ─── */
.plan { display: flex; gap: 6px; background: #e8efe8; border: 3px solid #7a8a7a; border-radius: 16px; padding: 12px; }
.plan-side { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.plan-aisle { width: 16px; display: flex; align-items: center; justify-content: center; color: #8a9a8a; font-size: 10px; writing-mode: vertical-rl; background: #dfe8df; border-radius: 6px; }
.plan-room { background: #fff; border: 2px solid var(--primary); border-radius: 12px; padding: 8px; }
.plan-room.abandoned { opacity: .4; border-style: dashed; border-color: #999; }
.room-head { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; color: var(--primary); margin-bottom: 3px; }
.room-cat { font-size: 11px; color: #888; font-weight: 400; }
.room-temp { font-size: 10px; color: #aaa; border-bottom: 1px dashed #eee; padding-bottom: 4px; margin-bottom: 4px; }
.room-lines { display: flex; flex-direction: column; gap: 4px; }
.plan-line { display: flex; align-items: center; gap: 6px; background: #f5faf5; border: 1.5px solid #dbe8db; border-radius: 8px; padding: 5px 6px; cursor: pointer; font-size: 12px; }
.plan-line:active { background: #e8f5e9; }
.plan-line.warn .cap { color: var(--warning); font-weight: 700; }
.plan-line.disabled { opacity: .5; cursor: not-allowed; background: #f0f0f0; border-style: dashed; }
.plan-line .ln { font-weight: 700; color: var(--primary); width: 48px; }
.plan-line .bar { flex: 1; height: 11px; background: #e5ede5; border-radius: 6px; overflow: hidden; }
.plan-line .bar i { display: block; height: 100%; background: linear-gradient(90deg, #66bb6a, var(--primary)); border-radius: 6px; }
.plan-line.warn .bar i { background: linear-gradient(90deg, #ffb74d, var(--warning)); }
.plan-line .cap { width: 34px; text-align: right; font-weight: 700; }
.plan-line .days { width: 44px; text-align: right; color: #999; font-size: 11px; }
.row-2 { display: flex; gap: 10px; margin: 8px 0; }
.row-2 .btn { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { border: 1px solid #e5ede5; padding: 7px 8px; text-align: center; }
.tbl th { background: #eef4ee; color: var(--primary); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: #eef4ee; border: 2px solid #d0e0d0; border-radius: 20px; padding: 9px 14px; font-size: 14px; cursor: pointer; font-weight: 600; }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ─── 移动/平板适配：平面图可横向滚动（手机 + iPad 竖屏放不下时滚动看全） ─── */
@media(max-width: 900px) {
  #tab-plan { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  #tab-plan .plan { min-width: 640px; }
  #tab-plan .page-title { font-size: 22px; padding: 10px 0; }
  #tab-plan .card { min-width: 640px; }
  .tbl { font-size: 12px; }
  .tbl th, .tbl td { padding: 5px 4px; }
}

/* ═══ Spec 094：全屏视图（线详情 / 入库 / 出库）+ 大按钮 ═══ */
.view-overlay { position: fixed; inset: 0; background: var(--bg); z-index: 190; display: flex; flex-direction: column; }
.view-head { display: flex; align-items: center; gap: 8px; background: var(--primary); color: #fff; padding: 8px 10px; }
.view-head .back-btn { color: #fff; font-size: 18px; margin: 0; background: rgba(255,255,255,0.15); border-radius: 8px; padding: 8px 14px; flex: 0 0 auto; }
.view-title { font-size: 20px; font-weight: 700; flex: 1; text-align: center; }
.view-right { flex: 0 0 60px; }
.view-body { flex: 1; overflow-y: auto; padding: 12px; max-width: 820px; width: 100%; margin: 0 auto; }
.view-body .card { margin: 8px 0; }
.view-actions { display: flex; gap: 10px; padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); background: #fff; border-top: 2px solid var(--primary-light); max-width: 820px; width: 100%; margin: 0 auto; }
.view-actions .big-btn { flex: 1; }
.big-btn { border: 0; border-radius: 16px; color: #fff; font-size: 24px; font-weight: 800; padding: 20px 10px; box-shadow: 0 4px 12px rgba(0,0,0,0.18); cursor: pointer; }
.big-btn:active { transform: scale(0.98); }
.big-btn.green { background: var(--primary); }
.big-btn.orange { background: var(--warning); }
.big-btn.gray { background: var(--gray); }
.chk { display: flex; align-items: center; gap: 6px; font-size: 15px; padding: 8px; background: #f0f7f0; border-radius: 8px; flex: 1; cursor: pointer; }
.chk input { width: 20px; height: 20px; }
.rem { font-size: 11px; color: #888; }
.del-reason { width: 100%; min-height: 70px; padding: 10px; font-size: 17px; border: 2px solid #ddd; border-radius: 10px; }
