/* 生产线日报表 —— 平板/电脑现场快速填写 */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #f1f5f9;
  --card: #fff;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --line: #e2e8f0;
  --brand: #1d4ed8;
  --tech: #0891b2;
  --op: #16a34a;
  --qa: #ea580c;
  --danger: #dc2626;
  --warn: #f59e0b;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--ink);
  font-size: 16px; line-height: 1.5;
}

/* ===== 顶栏 ===== */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(135deg, #1e3a8a, #1d4ed8);
  color: #fff; padding: 12px 18px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  box-shadow: 0 2px 12px rgba(29,78,216,.25);
}
.topbar h1 { font-size: 19px; font-weight: 800; letter-spacing: .5px; }
.topbar h1 small { display: block; font-size: 11.5px; font-weight: 400; opacity: .85; }
.tb-sp { flex: 1; }
.tb-field { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.tb-field label { opacity: .9; }
.topbar input, .topbar select {
  border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.16);
  color: #fff; padding: 8px 11px; border-radius: 8px; font-size: 15px;
  font-family: inherit; outline: none;
}
.topbar input::-webkit-calendar-picker-indicator { filter: invert(1); }
.topbar select option { color: var(--ink); }
.tb-who {
  font-size: 12.5px; font-weight: 600; padding: 5px 11px; border-radius: 20px;
  background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.28);
  white-space: nowrap;
}
.tb-btn {
  border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.16);
  color: #fff; padding: 8px 14px; border-radius: 8px; font-size: 14px;
  font-weight: 600; cursor: pointer; font-family: inherit; white-space: nowrap;
}
.tb-btn:hover { background: rgba(255,255,255,.26); }
.tb-btn.primary { background: #fff; color: var(--brand); border-color: #fff; }

.wrap { padding: 16px; max-width: 1280px; margin: 0 auto; }

/* ===== 角色分区 ===== */
.section {
  background: var(--card); border-radius: 14px; margin-bottom: 18px;
  box-shadow: 0 1px 3px rgba(15,23,42,.07); overflow: hidden;
  border-left: 5px solid var(--line);
}
.section.tech { border-left-color: var(--tech); }
.section.op { border-left-color: var(--op); }
.section.qa { border-left-color: var(--qa); }

.sec-head {
  padding: 14px 18px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
}
.sec-no {
  width: 30px; height: 30px; flex: none; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 15px;
}
.section.tech .sec-no { background: var(--tech); }
.section.op .sec-no { background: var(--op); }
.section.qa .sec-no { background: var(--qa); }
.sec-title { font-size: 16.5px; font-weight: 800; }
.sec-sub { font-size: 12px; color: var(--ink-3); }
.sec-role {
  margin-left: auto; font-size: 12px; font-weight: 700;
  padding: 4px 11px; border-radius: 20px;
}
.section.tech .sec-role { background: #cffafe; color: #0e7490; }
.section.op .sec-role { background: #dcfce7; color: #15803d; }
.section.qa .sec-role { background: #ffedd5; color: #c2410c; }
.sec-body { padding: 16px 18px 18px; }

/* 锁定提示（不是该工种时） */
.locked {
  padding: 16px 18px; background: #f8fafc; color: var(--ink-2);
  font-size: 14px; display: flex; align-items: center; gap: 9px;
}
.locked svg { width: 18px; height: 18px; color: var(--ink-3); flex: none; }

/* ===== 产线选择 ===== */
.linebar {
  display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 18px; margin-bottom: 18px;
}
.linebar .f { display: flex; flex-direction: column; gap: 5px; }
.linebar .f > label { font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.linebar input, .linebar select {
  border: 1.5px solid var(--line); border-radius: 9px; padding: 10px 12px;
  font-size: 16px; font-family: inherit; background: #fff; color: var(--ink);
  outline: none; min-width: 130px;
}
.linebar input:focus, .linebar select:focus { border-color: var(--brand); }
.linebar .curline { font-size: 13px; color: var(--ink-3); margin-left: auto; }

/* ===== 表单网格 ===== */
.grid { display: grid; gap: 14px; }
.grid.g3 { grid-template-columns: repeat(3, 1fr); }
.grid.g2 { grid-template-columns: repeat(2, 1fr); }
.grid.g1 { grid-template-columns: 1fr; }
@media (max-width: 1000px) { .grid.g3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px) { .grid.g3, .grid.g2 { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label {
  font-size: 13.5px; font-weight: 700; color: var(--ink-2);
  display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap;
}
/* 单位标注 */
.field .unit {
  font-size: 12px; font-weight: 600; color: var(--brand);
  background: #eff6ff; padding: 1px 7px; border-radius: 4px;
}
/* 必填 / 选填 标记 */
.field .req, .field .opt {
  font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px;
}
.field .req { color: #b91c1c; background: #fee2e2; }
.field .opt { color: #64748b; background: #f1f5f9; }
/* 字段说明 */
.field .tip { font-size: 11.5px; color: var(--ink-3); line-height: 1.5; }

.field input, .field select, .field textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 10px;
  padding: 12px; font-size: 16px; font-family: inherit;
  color: var(--ink); background: #fff; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29,78,216,.1);
}
.field textarea { resize: vertical; min-height: 78px; line-height: 1.6; }
.field input.bad, .field textarea.bad, .field select.bad {
  border-color: var(--danger); background: #fef2f2;
}
.field .err { font-size: 12px; color: var(--danger); font-weight: 600; }

/* ===== 自动计算指标卡===== */
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; }
@media (max-width: 720px) { .metrics { grid-template-columns: 1fr; } }
.metric {
  border-radius: 12px; padding: 14px; text-align: center;
  border: 2px solid var(--line); background: #f8fafc;
}
.metric .mv { font-size: 27px; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
.metric .ml { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; font-weight: 600; }
.metric .mf { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
/* 正常 */
.metric.ok { border-color: #86efac; background: #f0fdf4; }
.metric.ok .mv { color: #15803d; }
/* 偏低预警 */
.metric.warn { border-color: #fcd34d; background: #fffbeb; }
.metric.warn .mv { color: #b45309; }
/* 严重异常高亮 */
.metric.danger {
  border-color: var(--danger); background: #fef2f2;
  animation: pulseRed 1.6s ease-in-out infinite;
}
.metric.danger .mv { color: #b91c1c; }
@keyframes pulseRed {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0); }
  50% { box-shadow: 0 0 0 5px rgba(220,38,38,.12); }
}

/* ===== 巡检 5 次 ===== */
.chk-list { display: flex; flex-direction: column; gap: 12px; }
.chk {
  border: 1.5px solid var(--line); border-radius: 12px; padding: 13px;
  background: #fcfdff;
}
.chk.done { border-color: #86efac; background: #f0fdf4; }
.chk.abn { border-color: var(--danger); background: #fef2f2; }
/* 提交中（蓝）/ 提交失败（橙），与「已提交」的绿、「异常」的红区分开 */
.chk.sending { border-color: #93c5fd; background: #eff6ff; }
.chk.failed { border-color: #f97316; background: #fff7ed; }
.chk.sending .chk-seq { background: #2563eb; }
.chk.failed .chk-seq { background: var(--qa); }
.chk.sending .badge { background: #dbeafe; color: #1d4ed8; }
.chk.failed .badge { background: #ffedd5; color: #c2410c; }
.chk-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 11px;
}
.chk-seq {
  width: 26px; height: 26px; flex: none; border-radius: 7px;
  background: var(--qa); color: #fff; font-size: 13px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.chk.done .chk-seq { background: #16a34a; }
.chk.abn .chk-seq { background: var(--danger); }
.chk-label { font-size: 14px; font-weight: 700; }
.chk-slot { font-size: 12px; color: var(--ink-3); }
.chk-head .badge {
  margin-left: auto; font-size: 11.5px; font-weight: 700;
  padding: 3px 9px; border-radius: 20px; background: #f1f5f9; color: var(--ink-3);
}
.chk.done .badge { background: #dcfce7; color: #15803d; }
.chk.abn .badge { background: #fee2e2; color: #b91c1c; }
.chk-body { display: grid; grid-template-columns: 170px 1fr; gap: 12px; }
@media (max-width: 720px) { .chk-body { grid-template-columns: 1fr; } }

.res-group { display: flex; gap: 8px; }
.res-btn {
  flex: 1; padding: 11px; border: 1.5px solid var(--line); background: #fff;
  border-radius: 10px; font-size: 15px; font-weight: 700; color: var(--ink-2);
  cursor: pointer; font-family: inherit;
}
.res-btn.ok.on { background: #16a34a; border-color: #16a34a; color: #fff; }
.res-btn.ng.on { background: var(--danger); border-color: var(--danger); color: #fff; }

/* 巡检进度 */
.qa-progress {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 16px; padding: 13px 15px; border-radius: 11px;
  background: #fff7ed; border: 1px solid #fed7aa;
}
.qa-progress b { font-size: 15px; color: #c2410c; }
.qa-progress .dots { display: flex; gap: 6px; }
.qa-progress .dot {
  width: 15px; height: 15px; border-radius: 50%; background: #e2e8f0;
  border: 2px solid #fdba74;
}
.qa-progress .dot.ok { background: #16a34a; border-color: #16a34a; }
.qa-progress .dot.ng { background: var(--danger); border-color: var(--danger); }
.qa-progress.full { background: #f0fdf4; border-color: #86efac; }
.qa-progress.full b { color: #15803d; }

/* ---------- 每张卡独立的提交按钮 ---------- */
.chk-save {
  width: 100%; margin-top: 12px; padding: 12px;
  border: none; border-radius: 10px;
  background: var(--qa); color: #fff;
  font-size: 15px; font-weight: 700; font-family: inherit;
  cursor: pointer; transition: filter .15s;
}
.chk-save:hover { filter: brightness(1.06); }
.chk-save:active { transform: translateY(1px); }
.chk-save:disabled { background: #94a3b8; cursor: not-allowed; }
/* 已提交过 → 次要样式，提示可重改 */
.chk-save.sent {
  background: #fff; color: var(--qa);
  border: 2px solid #fdba74;
}
.chk.done .chk-save.sent { color: #15803d; border-color: #86efac; }
.chk.abn .chk-save.sent { color: #b91c1c; border-color: #fca5a5; }
/* 失败重试：醒目 + 呼吸感，提示「还可以再点」 */
.chk-save.failed {
  background: #ea580c;
  animation: chkRetryPulse 1.6s ease-in-out infinite;
}
@keyframes chkRetryPulse {
  0%, 100% { box-shadow: 0 3px 12px rgba(234,88,12,.4); }
  50% { box-shadow: 0 3px 18px rgba(234,88,12,.7); }
}

/* ---------- 今日巡检记录（逐次提交后增量追加） ---------- */
.qa-log {
  margin-top: 14px; padding: 13px 15px; border-radius: 11px;
  background: #f8fafc; border: 1px solid var(--line);
}
.qa-log-head {
  font-size: 13.5px; font-weight: 700; color: var(--ink-2);
  margin-bottom: 9px; display: flex; align-items: center; gap: 8px;
}
.qa-log-head span { font-size: 12px; font-weight: 400; color: var(--ink-3); }
#qaLog { display: flex; flex-direction: column; gap: 6px; }
.qa-log-row {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 9px 11px; border-radius: 9px;
  background: #fff; border: 1px solid var(--line);
  font-size: 13px; line-height: 1.5;
}
.qa-log-row.ok { background: #f0fdf4; border-color: #bbf7d0; }
.qa-log-row.ng { background: #fef2f2; border-color: #fecaca; }
/* 刚追加的那条高亮一下，让「这一次进去了」有即时反馈 */
.qa-log-row.newest { animation: qaLogIn .5s ease-out; border-color: #16a34a; }
.qa-log-row.ng.newest { border-color: var(--danger); }
@keyframes qaLogIn {
  from { opacity: 0; transform: translateY(-6px); background: #dcfce7; }
  to { opacity: 1; transform: none; }
}
.qa-log-row .no {
  width: 21px; height: 21px; flex: none; border-radius: 6px;
  background: #16a34a; color: #fff; font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.qa-log-row.ng .no { background: var(--danger); }
.qa-log-row .tm { font-weight: 700; font-variant-numeric: tabular-nums; }
.qa-log-row .rs {
  font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 20px;
  background: #dcfce7; color: #15803d;
}
.qa-log-row.ng .rs { background: #fee2e2; color: #b91c1c; }
.qa-log-row .ex {
  color: #b91c1c; font-size: 12px;
  max-width: 34%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.qa-log-row .nt {
  color: var(--ink-3); font-size: 12px;
  max-width: 26%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.qa-log-row .at {
  margin-left: auto; font-size: 11px; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* ===== 提交按钮 ===== */
.sec-actions { display: flex; gap: 12px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.btn-save {
  padding: 13px 26px; border: none; border-radius: 11px; color: #fff;
  font-size: 16px; font-weight: 800; letter-spacing: 1px; cursor: pointer;
  font-family: inherit; box-shadow: 0 4px 12px rgba(15,23,42,.16);
}
.section.tech .btn-save { background: var(--tech); box-shadow: 0 4px 12px rgba(8,145,178,.3); }
.section.op .btn-save { background: var(--op); box-shadow: 0 4px 12px rgba(22,163,74,.3); }
.section.qa .btn-save { background: var(--qa); box-shadow: 0 4px 12px rgba(234,88,12,.3); }
.btn-save:active { transform: translateY(1px); }
.btn-save:disabled { background: #94a3b8; box-shadow: none; cursor: not-allowed; }
.save-hint { font-size: 12.5px; color: var(--ink-3); }

/* ===== 历史记录 ===== */
.hist-bar { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.hist-bar .f { display: flex; flex-direction: column; gap: 5px; }
.hist-bar .f > label { font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.hist-bar input {
  border: 1.5px solid var(--line); border-radius: 9px; padding: 9px 11px;
  font-size: 15px; font-family: inherit; background: #fff; outline: none;
}
.hist {
  overflow-x: auto; background: #fff; border-radius: 12px;
  border: 1px solid var(--line);
}
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 760px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: #f8fafc; font-size: 12.5px; font-weight: 700; color: var(--ink-2); position: sticky; top: 0; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: none; }
.t-dim { color: var(--ink-3); font-size: 12.5px; }
.t-ok { color: #15803d; font-weight: 700; }
.t-bad { color: #b91c1c; font-weight: 700; background: #fef2f2; }
.empty { text-align: center; padding: 34px 0; color: var(--ink-3); font-size: 14px; }

/* ===== 吐司 ===== */
#toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%) translateY(20px);
  background: rgba(15,23,42,.95); color: #fff; padding: 13px 22px;
  border-radius: 10px; font-size: 15px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 100;
  max-width: 88vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.ok { background: #15803d; }
#toast.err { background: #b91c1c; }

/* ===== 登录 ===== */
#loginPage {
  min-height: 100vh; background: #070d1c;
  display: flex; align-items: center; justify-content: center; padding: 22px;
}
.lg {
  background: #fff; border-radius: 16px; padding: 30px 26px;
  width: 100%; max-width: 380px; box-shadow: 0 20px 50px rgba(2,8,23,.5);
}
.lg h2 { font-size: 20px; margin-bottom: 5px; }
.lg p.sub { font-size: 12.5px; color: var(--ink-3); margin-bottom: 20px; }
.lg .field { margin-bottom: 14px; }
.lg .btn {
  width: 100%; padding: 14px; border: none; border-radius: 11px;
  background: var(--brand); color: #fff; font-size: 17px; font-weight: 700;
  letter-spacing: 3px; cursor: pointer; font-family: inherit;
}
.lg .btn:disabled { background: #94a3b8; }
.lg .err { color: var(--danger); font-size: 13px; text-align: center; min-height: 18px; margin-top: 8px; }
.lg .back { display: block; text-align: center; margin-top: 14px; font-size: 13px; color: var(--brand); text-decoration: none; }
