/* ═══════════════════════════════════════════════════════════
   JHA 助手（工作危害分析记录表）
   版式唯一标准：assets/JHA 样表 —— 宋体公文风 / 黑框 / A4 横版
   屏幕预览可放大字号，列名、rowspan 合并、四色必须与打印一致
   ═══════════════════════════════════════════════════════════ */

.tool-hero.is-jha { --tool-hero: linear-gradient(118deg, #0f172a 0%, #155e75 50%, #0891b2 100%); --tool-shadow: rgba(21, 94, 117, .25); }

/* ── 页签 ── */
.jha-tabs { display: flex; gap: 8px; margin: 14px 0; }
.jha-tab {
  flex: 1; padding: 11px 8px; border: 1px solid var(--line, #dbe4ee); border-radius: 10px;
  background: #fff; font-size: 14px; color: var(--ink, #243b53); cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.jha-tab.is-active { background: var(--primary, #2f7cf6); border-color: var(--primary, #2f7cf6); color: #fff; font-weight: 600; }
@media (prefers-reduced-motion: no-preference) { .jha-tab:active { transform: scale(.985); } }

/* ── 输入页 ── */
.jha-form { padding: 14px; }
.jha-sec-head { display: flex; align-items: baseline; gap: 8px; margin: 14px 0 8px; }
.jha-sec-head:first-child { margin-top: 0; }
.jha-sec-head b { font-size: 14px; }
.jha-sec-head .muted { font-size: 12px; }
.jha-photos { display: flex; gap: 10px; flex-wrap: wrap; }
.jha-photo { position: relative; width: 148px; margin: 0; }
.jha-photo img { width: 148px; height: 110px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line, #dbe4ee); display: block; }
.jha-photo-rm {
  position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; border-radius: 50%;
  border: none; background: #e5484d; color: #fff; font-size: 14px; line-height: 1; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
}
.jha-photo-add {
  width: 148px; height: 110px; border: 1.5px dashed var(--primary, #2f7cf6); border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  cursor: pointer; color: var(--primary, #2f7cf6); font-size: 13px; background: #f5f9ff;
}
.jha-add-ico { font-size: 22px; line-height: 1; }
.jha-add-ico + span { font-weight: 600; }
.jha-photo-add .muted { font-size: 11px; }
.jha-text-wrap { position: relative; }
#jha-text { width: 100%; box-sizing: border-box; padding: 10px 54px 10px 12px; border: 1px solid var(--line, #dbe4ee); border-radius: 10px; font-size: 14px; line-height: 1.6; resize: vertical; min-height: 108px; }
.jha-mic { position: absolute; right: 8px; bottom: 8px; width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  border: 0; background: transparent; color: #b9c4d6; transition: color .18s ease, background .18s ease, box-shadow .18s ease; }
.jha-text-wrap:focus-within .jha-mic { color: #9db0cc; }
.jha-mic svg { width: 17px; height: 17px; }
.jha-mic:hover { color: var(--primary, #2f7cf6); background: rgba(47, 124, 246, .09); }
.jha-mic:active { transform: scale(.92); }
.jha-mic.is-on { width: auto; min-width: 36px; height: 34px; padding: 0 14px 0 12px; border-radius: 17px; gap: 7px;
  color: #fff; background: linear-gradient(135deg, #ff8585, #e5484d);
  box-shadow: 0 6px 16px rgba(229, 72, 77, .3);
  animation: jhaMicPulse 1.8s ease-out infinite; }
.jha-mic.is-on:hover { background: linear-gradient(135deg, #ff8585, #e5484d); color: #fff; }
.jha-mic.is-on::after { content: '聆听中'; font-size: 12px; font-weight: 600; letter-spacing: 1px; white-space: nowrap; }
@keyframes jhaMicPulse {
  0% { box-shadow: 0 6px 16px rgba(229, 72, 77, .3), 0 0 0 0 rgba(229, 72, 77, .28); }
  70% { box-shadow: 0 6px 16px rgba(229, 72, 77, .3), 0 0 0 12px rgba(229, 72, 77, 0); }
  100% { box-shadow: 0 6px 16px rgba(229, 72, 77, .3), 0 0 0 0 rgba(229, 72, 77, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .jha-mic.is-on { animation: none; }
}
@media (prefers-reduced-motion: reduce) { .jha-mic.is-on { animation: none; } }
.chip-btn { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line, #dbe4ee); background: #fff; font-size: 12px; cursor: pointer; color: var(--ink, #243b53); }
.chip-btn.is-on { border-color: #e5484d; color: #e5484d; background: #fff5f5; }
.jha-meta-row { display: flex; gap: 10px; margin: 12px 0; flex-wrap: wrap; }
.jha-field { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2, #51637a); }
.jha-field input { padding: 8px 10px; border: 1px solid var(--line, #dbe4ee); border-radius: 8px; font-size: 14px; }
.jha-tip-warn { margin: 8px 0; padding: 8px 12px; border-radius: 8px; background: #fff8e1; color: #8a6d00; font-size: 12.5px; border: 1px solid #f2e3a0; }
.jha-tip-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 10px 0 4px; }
.jha-tip-bar .mini-btn { flex-shrink: 0; }
.jha-hint { margin: 10px 2px 0; font-size: 12px; }

/* ── 记录表（屏幕 = 打印同构） ── */
.jha-doc { font-family: SimSun, '宋体', serif; color: #111; background: #fff; border-radius: 12px; padding: 16px 12px; box-shadow: var(--card-shadow, 0 1px 4px rgba(15, 30, 60, .08)); }
.jha-doc-title h2 { margin: 0 0 2px; text-align: center; font-size: 20px; letter-spacing: 2px; font-weight: 700; }
.jha-doc-en { margin: 0 0 10px; text-align: center; font-size: 11px; color: #555; letter-spacing: 1px; }
.jha-head-table { width: 100%; border-collapse: collapse; border: 1.2px solid #000; table-layout: fixed; margin-bottom: 10px; }
.jha-head-table th, .jha-head-table td { border: 1px solid #000; font-size: 13px; padding: 6px 8px; vertical-align: middle; }
.jha-head-table .jha-lab { background: #f5f5f5; text-align: center; width: 12%; white-space: nowrap; font-weight: 600; }
.jha-head-table input, .jha-head-table textarea { width: 100%; box-sizing: border-box; border: 1px dashed transparent; background: transparent; font-family: inherit; font-size: 13px; padding: 2px 4px; resize: vertical; }
.jha-head-table input:focus, .jha-head-table textarea:focus { outline: none; border-color: var(--primary, #2f7cf6); background: #fbfdff; }
.jha-photo-cell { display: flex; gap: 8px; flex-wrap: wrap; }
.jha-table-photo { width: 120px; height: 90px; object-fit: cover; border: 1px solid #000; }

.jha-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.jha-table { width: 100%; min-width: 1080px; border-collapse: collapse; border: 1.2px solid #000; table-layout: fixed; }
.jha-table th { background: #f0f0f0; border: 1px solid #000; font-size: 13px; padding: 6px 4px; text-align: center; font-weight: 600; }
.jha-table td { border: 1px solid #000; font-size: 12.5px; padding: 5px 6px; vertical-align: top; line-height: 1.55; }
.jha-table td.jha-c-no { text-align: center; vertical-align: middle; font-size: 14px; font-weight: 600; }
.jha-table td.jha-c-num { text-align: center; vertical-align: middle; }
.jha-table td.jha-c-ops { vertical-align: middle; }
.jha-c-no, .jha-c-step { background: #fff; }
.jha-table textarea, .jha-table input, .jha-table select {
  width: 100%; box-sizing: border-box; border: 1px dashed transparent; background: transparent;
  font-family: inherit; font-size: 12.5px; line-height: 1.5; padding: 2px 3px; resize: vertical;
}
.jha-table textarea:focus, .jha-table input:focus, .jha-table select:focus { outline: none; border-color: var(--primary, #2f7cf6); background: #fbfdff; }
.jha-table select { cursor: pointer; text-align: center; }
.jha-c-r { font-weight: 700; font-size: 14px; }
.jha-step-ops { margin-top: 4px; }
.jha-step-gap td { border: none; padding: 0; background: transparent; }
.jha-gap-bar { display: flex; align-items: center; gap: 8px; padding: 4px 2px; font-size: 11px; color: #667; }
.jha-gap-bar span { font-weight: 600; }
.mini-btn { padding: 3px 9px; border-radius: 6px; border: 1px solid var(--line, #dbe4ee); background: #fff; font-size: 11.5px; cursor: pointer; color: var(--ink, #243b53); }
.mini-btn.is-danger { border-color: #f3b6b8; color: #e5484d; background: #fff7f7; }
.mini-btn.is-ghost { border-color: transparent; color: #8a97a8; }
.mini-btn:hover { border-color: var(--primary, #2f7cf6); color: var(--primary, #2f7cf6); }
.jha-table-ops { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; font-size: 12px; }

.jha-note { margin-top: 10px; border: 1px solid #000; padding: 7px 12px; font-size: 12px; line-height: 1.8; }
.jha-note-title { font-weight: 700; margin: 0 0 2px; }
.jha-note p { margin: 0; }
.jha-doc-no { margin: 10px 2px 0; text-align: right; font-size: 12.5px; font-family: SimSun, '宋体', serif; }

.jha-risk { display: inline-block; padding: 2px 10px; border-radius: 4px; font-size: 12px; white-space: nowrap; }
.risk-low { background: #4dabf7; color: #fff; }
.risk-medium { background: #ffd43b; color: #111; }
.risk-medium-high { background: #ffa94d; color: #fff; }
.risk-high { background: #ff6b6b; color: #fff; }

.jha-result-ops { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.jha-loading { padding: 40px 0; text-align: center; color: #8a97a8; font-size: 13px; }
.jha-empty { padding: 48px 16px; text-align: center; color: #8a97a8; font-size: 13.5px; background: #fff; border-radius: 12px; border: 1px dashed var(--line, #dbe4ee); }

/* ── 台账 ── */
.jha-ledger { background: #fff; border-radius: 12px; padding: 12px; }
.jha-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.jha-filters input, .jha-filters select { padding: 7px 10px; border: 1px solid var(--line, #dbe4ee); border-radius: 8px; font-size: 13px; }
.jha-filters input:first-child { flex: 1; min-width: 180px; }
/* 台账表：auto 布局（继承的 fixed 会把 9 列均分导致操作列溢出），操作列定宽 140px */
.jha-ledger-table { min-width: 880px; table-layout: auto; }
.jha-ledger-table td { font-size: 12.5px; }
.jha-td-act { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 操作列：图标按钮一行排开，不再溢出 */
.jha-td-ops { white-space: nowrap; width: 140px; min-width: 140px; }
.jha-td-ops .mini-btn { margin-right: 4px; }
.mini-btn.is-icon { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0; border-radius: 7px; }
.mini-btn.is-icon svg { width: 15px; height: 15px; display: block; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.ta-c { text-align: center; }

/* ── 看板（纯 CSS 条） ── */
.jha-board { display: flex; flex-direction: column; gap: 12px; }
.jha-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.jha-kpi { background: #fff; border-radius: 12px; padding: 14px 12px; text-align: center; box-shadow: var(--card-shadow, 0 1px 4px rgba(15, 30, 60, .08)); }
.jha-kpi b { display: block; font-size: 26px; color: var(--ink, #243b53); }
.jha-kpi span { font-size: 12px; color: #8a97a8; }
.jha-kpi.is-high b { color: #e5484d; }
.jha-kpi.is-midhigh b { color: #e8590c; }
.jha-board-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.jha-panel { background: #fff; border-radius: 12px; padding: 14px; box-shadow: var(--card-shadow, 0 1px 4px rgba(15, 30, 60, .08)); }
.jha-panel h4 { margin: 0 0 12px; font-size: 14px; }
.jha-bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.jha-bar-label { width: 72px; font-size: 12px; color: var(--ink-2, #51637a); text-align: right; flex-shrink: 0; }
.jha-bar-track { flex: 1; height: 14px; background: #eef2f7; border-radius: 7px; overflow: hidden; }
.jha-bar-fill { height: 100%; border-radius: 7px; transition: width .3s ease; }
.jha-bar-fill.risk-low { background: #4dabf7; }
.jha-bar-fill.risk-medium { background: #ffd43b; }
.jha-bar-fill.risk-medium-high { background: #ffa94d; }
.jha-bar-fill.risk-high { background: #ff6b6b; }
.jha-bar-fill.is-blue { background: #2f7cf6; }
.jha-bar-num { font-size: 12px; color: var(--ink-2, #51637a); width: 78px; flex-shrink: 0; }
.jha-weeks { display: flex; align-items: flex-end; gap: 8px; height: 130px; padding-top: 6px; }
.jha-week-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.jha-week-bar { width: 100%; max-width: 34px; min-height: 2px; background: linear-gradient(180deg, #2f7cf6, #6ea8ff); border-radius: 4px 4px 0 0; position: relative; }
.jha-week-bar b { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--ink-2, #51637a); }
.jha-week-col span { font-size: 10.5px; color: #8a97a8; white-space: nowrap; }
.jha-top-row { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; font-size: 12.5px; }
.jha-top-act { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 760px) {
  .jha-kpis { grid-template-columns: repeat(2, 1fr); }
  .jha-board-grid { grid-template-columns: 1fr; }
  .jha-tab { padding: 9px 4px; font-size: 13px; }
  .jha-doc { padding: 12px 8px; }
}

/* ── 打印：黑框宋体（仅打印 print-root；@page 横/竖由 js/jha.js 按按钮注入，勿在此写死） ── */
@media print {
  body.is-printing-jha { margin: 0 !important; padding: 0 !important; background: #fff !important; }
  body.is-printing-jha #app { display: none !important; }
  body.is-printing-jha #print-root { display: block !important; }
  /* 平时兜底隐藏（hidden 属性在场时）；打印时 JS 已移除 hidden，不命中本条 */
  #print-root[hidden] { display: none !important; }
  /* 兜底：防止屏幕宽表 min-width 溢出 A4 页宽（右侧裁切） */
  body.is-printing-jha #print-root .jha-table,
  body.is-printing-jha #print-root .jha-print-table,
  body.is-printing-jha #print-root .jha-head-table { min-width: 0 !important; width: 100% !important; }
  body.is-printing-jha #print-root .jha-doc { box-shadow: none; border-radius: 0; padding: 0; }
  body.is-printing-jha #print-root .jha-doc h2 { font-size: 18px; }
  body.is-printing-jha #print-root .jha-head-table th,
  body.is-printing-jha #print-root .jha-head-table td,
  body.is-printing-jha #print-root .jha-print-table th,
  body.is-printing-jha #print-root .jha-print-table td { font-size: 11px; }
  body.is-printing-jha #print-root .jha-c-ctl { font-size: 10px; text-align: left; }
  body.is-printing-jha #print-root .jha-note { font-size: 10px; }
  body.is-printing-jha #print-root .jha-photo-cell { display: flex; gap: 8px; flex-wrap: wrap; }
  /* 竖版：字号/内距收紧（特异性需压过上面的横版 11px 规则） */
  body.is-printing-jha #print-root .jha-doc-port .jha-head-table th,
  body.is-printing-jha #print-root .jha-doc-port .jha-head-table td,
  body.is-printing-jha #print-root .jha-doc-port .jha-print-table th,
  body.is-printing-jha #print-root .jha-doc-port .jha-print-table td { font-size: 10px; padding: 3px 4px; }
  body.is-printing-jha #print-root .jha-doc-port .jha-c-ctl { font-size: 9.5px; }
  body.is-printing-jha #print-root .jha-doc-port .jha-doc h2 { font-size: 16px; }
}