/* ============================================================
   J&J Vision · EHS 风险智能运营系统 — 设计系统
   风格：强生红白品牌风 · 医疗器械级专业感
   ============================================================ */

:root {
  /* 品牌色 */
  --red: #CC0000;
  --red-hover: #B00000;
  --red-dark: #8C0000;
  --red-tint: #FBEAEA;
  --red-soft: #FDF4F4;
  /* 墨色 */
  --ink: #171A1F;
  --ink-2: #434952;
  --ink-3: #78808B;
  --ink-4: #A9B0B9;
  /* 中性 */
  --bg: #F4F5F7;
  --card: #FFFFFF;
  --line: #E6E9ED;
  --line-2: #EFF1F4;
  /* 语义 */
  --green: #0B8A5C; --green-tint: #E7F5EF;
  --amber: #C77700; --amber-tint: #FCF2DF;
  --orange: #E05E0B; --orange-tint: #FDEEE1;
  --blue: #1A66CC; --blue-tint: #E9F1FB;
  --purple: #6C4FC7; --purple-tint: #F0ECFA;
  --cyan: #0C8FA3; --cyan-tint: #E4F4F7;
  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(23,26,31,.05);
  --shadow: 0 1px 2px rgba(23,26,31,.04), 0 4px 16px rgba(23,26,31,.06);
  --shadow-lg: 0 10px 40px rgba(23,26,31,.14);
  --radius: 14px;
  --radius-sm: 9px;
  --font-num: "SF Mono", "DIN Alternate", "Bahnschrift", Menlo, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 14px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #D3D8DE; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #B9C0C8; }
::-webkit-scrollbar-track { background: transparent; }

/* ================= 布局 ================= */
#app { display: flex; height: 100vh; }

#sidebar {
  width: 236px; flex-shrink: 0;
  background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  z-index: 20;
}
.brand { display: flex; flex-direction: column; align-items: stretch; gap: 10px; padding: 20px 18px 16px; border-bottom: 1px solid var(--line-2); }
.jj-script {
  font-family: 'Snell Roundhand', 'Savoye LET', 'Segoe Script', 'Brush Script MT', 'Kaiti SC', cursive;
  font-size: 25px; font-weight: 700; font-style: italic;
  color: var(--red); line-height: 1.05; letter-spacing: .3px;
  white-space: nowrap; transform: rotate(-1.5deg);
  user-select: none;
}
.brand-divider { height: 1px; background: var(--line-2); }
.brand-logo-img {
  width: 100%; height: auto; object-fit: contain;
  mix-blend-mode: multiply; user-select: none;
}
.brand-text .brand-name { font-size: 13.5px; font-weight: 800; letter-spacing: .8px; color: var(--ink); }
.brand-text .brand-sub { font-size: 10.5px; color: var(--ink-3); margin-top: 3px; letter-spacing: 1.8px; }

#nav { flex: 1; overflow-y: auto; padding: 10px 12px; }
.nav-group { margin-bottom: 6px; }
.nav-group-label {
  font-size: 10.5px; color: var(--ink-4); letter-spacing: 2px; font-weight: 600;
  padding: 10px 10px 6px; text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; margin: 1px 0;
  border-radius: 9px; cursor: pointer;
  color: var(--ink-2); font-size: 13px; font-weight: 500;
  transition: background .15s, color .15s;
  position: relative; user-select: none;
}
.nav-item svg { flex-shrink: 0; opacity: .75; }
.nav-item:hover { background: var(--bg); }
.nav-item.active {
  background: var(--red-tint); color: var(--red); font-weight: 600;
}
.nav-item.active svg { opacity: 1; }
.nav-item.active::before {
  content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  background: var(--red); border-radius: 0 3px 3px 0;
}
.nav-item .nav-badge {
  margin-left: auto; font-size: 10px; padding: 1px 6px; border-radius: 8px;
  background: var(--red-tint); color: var(--red); font-weight: 700; font-family: var(--font-num);
}

.sidebar-foot { padding: 12px; border-top: 1px solid var(--line-2); }
.env-card {
  background: var(--bg); border-radius: 10px; padding: 9px 12px; margin-bottom: 10px;
}
.env-row { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; }
.env-meta { font-size: 10.5px; color: var(--ink-4); margin-top: 4px; }
.copyright { font-size: 10px; color: var(--ink-4); line-height: 1.7; text-align: center; }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--green); }
.dot-red { background: var(--red); }
.dot-amber { background: var(--amber); }
.pulse-dot { animation: pulseDot 2s infinite; }
@keyframes pulseDot { 0%,100% { box-shadow: 0 0 0 0 rgba(11,138,92,.45);} 50% { box-shadow: 0 0 0 5px rgba(11,138,92,0);} }

#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

#topbar {
  height: 62px; flex-shrink: 0;
  background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
}
#page-title { font-size: 17px; font-weight: 800; letter-spacing: .3px; }
.page-desc { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600; color: var(--ink-2);
  padding: 5px 11px; border-radius: 20px;
  background: var(--bg); border: 1px solid var(--line);
}
.chip svg { color: var(--ink-3); }
.chip-data { color: var(--red); background: var(--red-soft); border-color: #F2D4D4; }
.chip-data svg { color: var(--red); }
.clock { font-family: var(--font-num); font-size: 12.5px; color: var(--ink-3); font-weight: 600; min-width: 64px; text-align: right; }

#content { flex: 1; overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth; }
.page { display: none; padding: 20px 24px 40px; max-width: 1680px; margin: 0 auto; animation: pageIn .3s ease; }
.page.active { display: block; }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ================= 卡片 ================= */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card + .card { margin-top: 14px; }
.card-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 0;
}
.card-title { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-title .t-en { font-size: 10px; color: var(--ink-4); font-weight: 600; letter-spacing: 1.5px; }
.card-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }
.card-bd { padding: 14px 18px 18px; }
.card-hd + .card-bd { padding-top: 12px; }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g5 { grid-template-columns: repeat(5, 1fr); }
.g21 { grid-template-columns: 2fr 1fr; }
.g12 { grid-template-columns: 1fr 2fr; }
.g23 { grid-template-columns: 2fr 3fr; }

/* ================= KPI 卡片 ================= */
.kpi-row { display: grid; gap: 14px; grid-template-columns: repeat(5, 1fr); margin-bottom: 14px; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; position: relative; overflow: hidden;
  box-shadow: var(--shadow-sm); transition: transform .18s, box-shadow .18s;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--kc, var(--red)); }
.kpi-label { font-size: 11.5px; color: var(--ink-3); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi-value { font-family: var(--font-num); font-size: 30px; font-weight: 700; margin: 7px 0 5px; letter-spacing: -.5px; }
.kpi-value .kpi-unit { font-size: 13px; color: var(--ink-3); font-weight: 500; margin-left: 3px; }
.kpi-foot { font-size: 11px; color: var(--ink-3); display: flex; align-items: center; gap: 5px; }
.kpi-delta { font-weight: 700; font-family: var(--font-num); }
.kpi-delta.up { color: var(--red); }
.kpi-delta.down { color: var(--green); }
.kpi-delta.neutral { color: var(--blue); }

/* ================= 按钮 ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-size: 13px; font-weight: 600; font-family: inherit;
  padding: 8px 16px; border-radius: 9px; border: 1px solid transparent;
  cursor: pointer; transition: all .15s; user-select: none; white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--red-hover); box-shadow: 0 3px 10px rgba(204,0,0,.25); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover:not(:disabled) { background: #2A2E35; }
.btn-ghost { background: #fff; color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { border-color: var(--ink-4); background: var(--bg); }
.btn-danger-ghost { background: #fff; color: var(--red); border-color: #EFC9C9; }
.btn-danger-ghost:hover { background: var(--red-tint); }
.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 7px; }
.btn-lg { padding: 11px 26px; font-size: 14.5px; border-radius: 11px; }
.btn-icon { padding: 7px; border-radius: 8px; }

/* ================= 标签/徽章 ================= */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 700; padding: 2.5px 8px; border-radius: 6px;
  letter-spacing: .3px;
}
.tag-p0 { background: var(--red-tint); color: var(--red); }
.tag-p1 { background: var(--orange-tint); color: var(--orange); }
.tag-p2 { background: var(--amber-tint); color: var(--amber); }
.tag-p3 { background: var(--green-tint); color: var(--green); }
.tag-red { background: var(--red-tint); color: var(--red); }
.tag-green { background: var(--green-tint); color: var(--green); }
.tag-blue { background: var(--blue-tint); color: var(--blue); }
.tag-gray { background: var(--bg); color: var(--ink-3); border: 1px solid var(--line); }
.tag-purple { background: var(--purple-tint); color: var(--purple); }
.tag-cyan { background: var(--cyan-tint); color: var(--cyan); }
.tag-line { background: var(--ink); color: #fff; }

/* ================= 表单 ================= */
.field { margin-bottom: 12px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; display: flex; justify-content: space-between; }
.select, .input, .textarea {
  width: 100%; font-family: inherit; font-size: 13px; color: var(--ink);
  padding: 8px 11px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; outline: none; transition: border .15s, box-shadow .15s;
}
.select:focus, .input:focus, .textarea:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(204,0,0,.08); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2378808B' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; cursor: pointer; }
.textarea { resize: vertical; min-height: 60px; }

.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 2px; }
.seg-item {
  padding: 6px 14px; border-radius: 7px; font-size: 12.5px; font-weight: 600;
  color: var(--ink-3); cursor: pointer; transition: all .15s; user-select: none;
}
.seg-item.active { background: #fff; color: var(--red); box-shadow: var(--shadow-sm); }

/* 滑块 */
input[type=range] { -webkit-appearance: none; width: 100%; height: 6px; border-radius: 6px; background: linear-gradient(to right, var(--red) 0%, var(--red) var(--fill,50%), var(--line) var(--fill,50%)); outline: none; }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 3px solid var(--red); box-shadow: 0 1px 4px rgba(0,0,0,.2); cursor: pointer;
}

/* ================= 表格 ================= */
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th {
  text-align: left; font-size: 11px; color: var(--ink-3); font-weight: 600;
  padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--bg);
  letter-spacing: .5px; white-space: nowrap;
}
.table td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--red-soft); }

/* ================= 模态框 ================= */
.modal-mask {
  position: fixed; inset: 0; background: rgba(23,26,31,.45); backdrop-filter: blur(3px);
  z-index: 100; display: flex; align-items: center; justify-content: center;
  animation: fadeIn .2s ease;
}
.modal {
  background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg);
  width: min(680px, 92vw); max-height: 86vh; display: flex; flex-direction: column;
  animation: modalIn .25s cubic-bezier(.2,.9,.3,1.2);
}
.modal-lg { width: min(900px, 94vw); }
.modal-hd { padding: 18px 22px 14px; border-bottom: 1px solid var(--line-2); display: flex; justify-content: space-between; align-items: flex-start; }
.modal-title { font-size: 16px; font-weight: 800; }
.modal-bd { padding: 18px 22px; overflow-y: auto; }
.modal-ft { padding: 14px 22px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 10px; }
.modal-close { cursor: pointer; color: var(--ink-4); font-size: 20px; line-height: 1; padding: 2px 6px; border-radius: 6px; }
.modal-close:hover { background: var(--bg); color: var(--ink); }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: scale(.94) translateY(10px); } }

/* ================= Toast ================= */
#toast-root { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px;
  font-size: 12.5px; font-weight: 500; box-shadow: var(--shadow-lg);
  animation: toastIn .25s ease; max-width: 360px;
}
.toast-success { background: var(--green); }
.toast-error { background: var(--red); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } }

/* ================= 骨架屏 ================= */
.skeleton { position: relative; overflow: hidden; background: var(--line-2); border-radius: 8px; }
.skeleton::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.75), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%);} to { transform: translateX(100%);} }

/* ================= Markdown 渲染 ================= */
.md { font-size: 13px; line-height: 1.85; color: var(--ink-2); word-break: break-word; }
.md h1 { font-size: 19px; color: var(--ink); margin: 14px 0 10px; font-weight: 800; }
.md h2 { font-size: 16px; color: var(--ink); margin: 18px 0 9px; font-weight: 800; padding-left: 10px; border-left: 3px solid var(--red); }
.md h3 { font-size: 14px; color: var(--ink); margin: 14px 0 7px; font-weight: 700; }
.md p { margin: 7px 0; }
.md strong { color: var(--ink); }
.md ul, .md ol { margin: 7px 0 7px 20px; }
.md li { margin: 4px 0; }
.md table { border-collapse: collapse; margin: 10px 0; width: 100%; font-size: 12px; }
.md th { background: var(--bg); border: 1px solid var(--line); padding: 6px 10px; text-align: left; font-weight: 700; color: var(--ink); }
.md td { border: 1px solid var(--line); padding: 6px 10px; }
.md blockquote { border-left: 3px solid var(--line); padding: 4px 12px; margin: 8px 0; color: var(--ink-3); background: var(--bg); border-radius: 0 8px 8px 0; }
.md code { background: var(--bg); padding: 1.5px 6px; border-radius: 5px; font-size: 12px; font-family: var(--font-num); }
.md hr { border: none; border-top: 1px solid var(--line); margin: 14px 0; }

/* ================= 通用 ================= */
.muted { color: var(--ink-3); }
.small { font-size: 11.5px; }
.num { font-family: var(--font-num); }
.bold { font-weight: 700; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap8 { gap: 8px; } .gap12 { gap: 12px; }
.mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mb12 { margin-bottom: 12px; }
.scroll-y { overflow-y: auto; }

.pulse-red { animation: pulseRed 1.6s infinite; }
@keyframes pulseRed {
  0%,100% { box-shadow: 0 0 0 0 rgba(204,0,0,.35); }
  50% { box-shadow: 0 0 0 7px rgba(204,0,0,0); }
}

.divider { height: 1px; background: var(--line-2); margin: 12px 0; }

.empty {
  text-align: center; padding: 46px 20px; color: var(--ink-4); font-size: 12.5px;
}
.empty-icon { font-size: 34px; margin-bottom: 10px; opacity: .5; }

.spin { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.progress-track { height: 6px; background: var(--line-2); border-radius: 6px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 6px; background: var(--red); transition: width .4s ease; }

/* 打字光标 */
.cursor-blink { display: inline-block; width: 8px; height: 15px; background: var(--red); margin-left: 2px; vertical-align: -2px; animation: blink .8s step-end infinite; border-radius: 1px; }
@keyframes blink { 50% { opacity: 0; } }

/* 响应式兜底 */
@media (max-width: 1280px) {
  .g4, .kpi-row { grid-template-columns: repeat(3, 1fr); }
  .g3 { grid-template-columns: 1fr 1fr; }
}
