/* ===== HAZOP 系统共享样式 ===== */
:root {
  --primary: #1890ff;
  --primary-hover: #40a9ff;
  --primary-active: #096dd9;
  --success: #52c41a;
  --warning: #faad14;
  --danger: #ff4d4f;
  --text: #262626;
  --text-2: #595959;
  --text-3: #8c8c8c;
  --border: #e8e8e8;
  --bg: #f0f2f5;
  --card: #ffffff;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.06);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--primary); text-decoration: none; cursor: pointer; }
a:hover { color: var(--primary-hover); }

/* ===== 顶部导航 ===== */
.topbar { background: linear-gradient(90deg, #096dd9, #1890ff); color: #fff; height: 56px; display: flex; align-items: center; padding: 0 24px; gap: 16px; box-shadow: 0 2px 8px rgba(0,21,41,.12); position: sticky; top: 0; z-index: 50; }
.topbar .logo { font-size: 17px; font-weight: 600; letter-spacing: 1px; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.topbar .logo img { height: 30px; width: 30px; border-radius: 6px; background: #fff; object-fit: cover; }
.topbar .logo .badge { background: rgba(255,255,255,.2); border-radius: 4px; padding: 1px 8px; font-size: 12px; font-weight: 400; }
.topbar .spacer { flex: 1; }
.topbar .user { font-size: 13px; opacity: .95; display: flex; align-items: center; gap: 14px; }
.topbar a { color: #fff; opacity: .9; }
.topbar a:hover { opacity: 1; }

/* ===== 布局 ===== */
.page { max-width: 1280px; margin: 20px auto; padding: 0 20px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 24px; margin-bottom: 16px; }
.card-title { font-size: 15px; font-weight: 600; margin: 0 0 16px; padding-left: 10px; border-left: 3px solid var(--primary); display: flex; align-items: center; justify-content: space-between; }

/* ===== 表单 ===== */
.form-row { display: flex; align-items: flex-start; margin-bottom: 16px; gap: 10px; }
.form-row > label { width: 130px; text-align: right; padding-top: 7px; color: var(--text-2); flex-shrink: 0; }
.form-row > label .req { color: var(--danger); margin-right: 2px; }
.form-row .control { flex: 1; }
.input, select.input, textarea.input { border: 1px solid #d9d9d9; border-radius: 6px; padding: 7px 12px; font-size: 14px; width: 100%; max-width: 520px; transition: border-color .2s, box-shadow .2s; outline: none; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(24,144,255,.12); }
.hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.radio-group { display: flex; gap: 20px; padding-top: 7px; flex-wrap: wrap; }
.radio-group label { display: flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }

/* ===== 按钮 ===== */
.btn { border: 1px solid transparent; border-radius: 6px; padding: 7px 16px; font-size: 13px; cursor: pointer; transition: all .2s; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; flex-shrink: 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-default { background: #fff; border-color: #d9d9d9; color: var(--text); }
.btn-default:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #ff7875; }
.btn-link { background: none; border: none; color: var(--primary); padding: 4px 6px; cursor: pointer; font-size: 13px; white-space: nowrap; }
.btn-link:hover { color: var(--primary-hover); }
.btn-link.danger { color: var(--danger); }
.btn-lg { padding: 9px 28px; font-size: 14px; }

/* ===== 表格 ===== */
.table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
.table th { background: #fafafa; color: var(--text-2); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid #f5f5f5; }
.table tbody tr:hover { background: #f5f9ff; }
.table .empty { text-align: center; color: var(--text-3); padding: 32px 0; }
.table-scroll { overflow-x: auto; }
.table-scroll .table { min-width: 960px; }
.table .cell-ellipsis { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table .col-nowrap { white-space: nowrap; }

/* ===== 标签 ===== */
.tag { display: inline-flex; align-items: center; background: #e6f7ff; color: var(--primary); border: 1px solid #91d5ff; border-radius: 4px; padding: 2px 10px; font-size: 12px; gap: 6px; white-space: nowrap; }
.tag .x { cursor: pointer; color: var(--text-3); }
.tag .x:hover { color: var(--danger); }
.tag.gray { background: #f5f5f5; color: var(--text-2); border-color: #d9d9d9; }
.tag.green { background: #f6ffed; color: var(--success); border-color: #b7eb8f; }
.tag.orange { background: #fff7e6; color: #d46b08; border-color: #ffd591; }

/* ===== 弹窗 ===== */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(2px); }
.modal-mask.open { display: flex; }
.modal { background: #fff; border-radius: 10px; width: 640px; max-width: 94vw; max-height: 86vh; overflow: auto; box-shadow: 0 8px 32px rgba(0,0,0,.18); animation: pop .18s ease-out; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header { padding: 14px 20px; border-bottom: 1px solid var(--border); font-size: 15px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: #fff; z-index: 1; }
.modal-header .close { cursor: pointer; color: var(--text-3); font-size: 18px; line-height: 1; }
.modal-header .close:hover { color: var(--text); }
.modal-body { padding: 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ===== 进度弹窗 ===== */
.progress-track { height: 10px; background: #f0f0f0; border-radius: 5px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--primary), #69c0ff); width: 0; transition: width .4s; border-radius: 5px; }
.stage-list { margin-top: 14px; max-height: 260px; overflow: auto; }
.stage-item { display: flex; align-items: center; gap: 10px; padding: 7px 0; color: var(--text-3); font-size: 13px; border-bottom: 1px dashed #f0f0f0; }
.stage-item.active { color: var(--primary); font-weight: 500; }
.stage-item.done { color: var(--text-2); }
.stage-item .dot { width: 8px; height: 8px; border-radius: 50%; background: #d9d9d9; flex-shrink: 0; }
.stage-item.active .dot { background: var(--primary); box-shadow: 0 0 0 4px rgba(24,144,255,.15); animation: pulse 1.2s infinite; }
.stage-item.done .dot { background: var(--success); }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(24,144,255,.05); } }

/* ===== 文件行（上传列表） ===== */
.file-row { display: flex; align-items: center; gap: 10px; background: #f7faff; border: 1px solid #d6e4ff; border-radius: 6px; padding: 8px 10px; }
.file-row .fr-icon { flex-shrink: 0; }
.file-row .fr-name { flex-shrink: 0; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.file-row .fr-size { flex-shrink: 0; }
.file-row .fr-desc { flex: 1; max-width: none; padding: 5px 10px; font-size: 13px; background: #fff; min-width: 120px; }
.file-row .fr-del { flex-shrink: 0; font-size: 16px; }
@media (max-width: 768px) {
  .file-row { flex-wrap: wrap; }
  .file-row .fr-name { max-width: calc(100% - 70px); }
  .file-row .fr-desc { flex: 1 1 100%; order: 2; margin-top: 6px; }
  .file-row .fr-del { margin-left: auto; }
}

/* ===== 上传区 ===== */
.upload-zone { border: 2px dashed #d9d9d9; border-radius: 8px; padding: 26px; text-align: center; color: var(--text-3); cursor: pointer; transition: all .2s; background: #fafafa; }
.upload-zone:hover, .upload-zone.drag { border-color: var(--primary); background: #f0f7ff; color: var(--primary); }
.upload-zone .icon { font-size: 28px; margin-bottom: 6px; }
.file-list { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }

/* ===== 分页 ===== */
.pagination { display: flex; justify-content: flex-end; align-items: center; gap: 6px; margin-top: 14px; font-size: 13px; color: var(--text-2); }
.pagination button { border: 1px solid #d9d9d9; background: #fff; border-radius: 4px; min-width: 30px; height: 30px; cursor: pointer; }
.pagination button.cur { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

/* ===== 问询卡片 ===== */
.q-item { border: 1px solid #ffe58f; background: #fffbe6; border-radius: 8px; padding: 14px 16px; margin-bottom: 12px; }
.q-item .q-header { font-weight: 600; margin-bottom: 6px; }
.q-item .q-text { color: var(--text-2); margin-bottom: 10px; white-space: pre-wrap; }
.q-item .opt { display: block; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 6px; cursor: pointer; }
.q-item .opt:hover { border-color: var(--primary); background: #f0f7ff; }
.q-item .opt input { margin-right: 8px; }

/* ===== 记录编辑器 ===== */
.rec-grid table { font-size: 12px; }
/* 弹窗内容过宽时：标题/工具栏固定，仅表格区滚动（横纵均不带动头部） */
.modal-fixed { display: flex; flex-direction: column; overflow: hidden; }
.modal-fixed .modal-header { flex-shrink: 0; }
.modal-fixed .modal-body { flex: 1; min-height: 0; overflow: auto; }
.modal-fixed .modal-body thead th { position: sticky; top: 0; background: #fafafa; z-index: 1; }
.rec-grid input { width: 100%; border: 1px solid #eee; border-radius: 4px; padding: 4px 6px; font-size: 12px; }
.rec-grid input:focus { border-color: var(--primary); outline: none; }

/* ===== 工具 ===== */
.hidden { display: none !important; }
.toolbar { display: flex; gap: 10px; align-items: center; }
.mb16 { margin-bottom: 16px; }
.muted { color: var(--text-3); font-size: 12px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* ===== 公共弹窗组件（hzAlert/hzConfirm/hzPrompt） ===== */
.dlg { max-width: 460px; width: 460px; }
.dlg .dlg-icon { font-size: 20px; flex-shrink: 0; line-height: 1.2; margin-top: 2px; }
.dlg .dlg-msg { white-space: pre-wrap; word-break: break-word; color: var(--text); line-height: 1.7; font-size: 14px; }
.dlg .dlg-body { display: flex; gap: 12px; align-items: flex-start; }
.dlg .input { width: 100%; max-width: none; margin-top: 10px; }
.dlg-info .dlg-icon { color: var(--primary); }
.dlg-warn .dlg-icon { color: var(--warning); }
.dlg-danger .dlg-icon { color: var(--danger); }
.dlg-success .dlg-icon { color: var(--success); }
/* 结构化选项块（恢复/重开等场景） */
.dlg-choices { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; width: 100%; }
.dlg-choice { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; background: #fafafa; }
.dlg-choice .c-label { font-weight: 600; color: var(--text); margin-bottom: 2px; }
.dlg-choice .c-desc { font-size: 12.5px; color: var(--text-2); line-height: 1.6; }
/* 编号列表（假设/资料缺失说明） */
.dlg-list { display: flex; flex-direction: column; gap: 2px; }
.dlg-list-item { display: flex; gap: 10px; padding: 10px 4px; border-bottom: 1px dashed #f0f0f0; line-height: 1.7; font-size: 13.5px; color: var(--text); }
.dlg-list-item:last-child { border-bottom: none; }
.dlg-list-item .n { flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; background: #fff7e6; color: #d46b08; font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; margin-top: 1px; }
.dlg-list-item .t { flex: 1; }

/* ===== 嵌入模式（iframe 分享）：无顶部信息 ===== */
body.embedded .topbar { display: none; }
body.embedded .page { margin-top: 8px; }
body.embedded { background: #fff; }

/* ===== 响应式：手机端适配 ===== */
@media (max-width: 768px) {
  .page { padding: 0 10px; margin: 10px auto; }
  .card { padding: 14px; border-radius: 6px; }
  .form-row { flex-direction: column; gap: 4px; align-items: stretch; }
  .form-row > label { width: auto; text-align: left; padding-top: 0; font-weight: 500; }
  .input, select.input, textarea.input { max-width: none; width: 100%; }
  .topbar { padding: 0 12px; height: auto; min-height: 52px; flex-wrap: wrap; row-gap: 4px; }
  .topbar .logo { font-size: 15px; }
  .modal { width: 96vw; max-height: 90vh; }
  .modal-body { padding: 14px; }
  .radio-group { gap: 14px; }
  .toolbar { flex-wrap: wrap; }
  .analyze-bar .btn-lg { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }
  .upload-zone { padding: 18px 10px; }
  .pagination { flex-wrap: wrap; justify-content: center; }
  .flex-between { flex-wrap: wrap; gap: 8px; }
  .rec-grid { overflow-x: auto; }
}
