/* ============================================================
   面向基层医疗设备智能运维与远程诊断系统 — Web 端设计系统
   依据《Web端设计行动清单 V3.1》4-1/4-2/4-3 确认项
   主色：医疗蓝 + 强调绿；状态色全站统一语义
   ============================================================ */

:root {
  /* 品牌色 */
  --primary:        #1565C0;   /* 医疗蓝：标题/按钮/图表主色 */
  --primary-light:  #E3F2FD;
  --primary-dark:   #0D47A1;
  --accent:         #2E7D32;   /* 强调绿：健康/正常 */
  --accent-light:   #E8F5E9;

  /* 状态色（4-2 确认：绿=正常/运行，黄=告警/空载，红=故障/离线，橙=预警） */
  --st-green:       #2E7D32;   /* 正常/运行/健康 */
  --st-green-bg:    #E8F5E9;
  --st-yellow:      #F9A825;   /* 告警/空载 */
  --st-yellow-bg:   #FFF8E1;
  --st-orange:      #EF6C00;   /* 预警：倒计时1~30天/老年期 */
  --st-orange-bg:   #FFF3E0;
  --st-red:         #C62828;   /* 故障/离线/报废/倒计时≤0 */
  --st-red-bg:      #FFEBEE;
  --st-gray:        #616161;   /* 待机/停用/报废历史 */
  --st-gray-bg:     #F5F5F5;

  /* 中性色 */
  --text:           #263238;
  --text-secondary: #546E7A;
  --text-muted:     #90A4AE;
  --border:         #ECEFF1;
  --border-strong:  #CFD8DC;
  --bg-page:        #F4F7FA;
  --bg-card:        #FFFFFF;
  --readonly-bg:    #F5F7F9;   /* 只读字段灰底 */

  /* 尺寸 */
  --sidebar-w:      232px;
  --header-h:       60px;
  --radius:         10px;
  --radius-sm:      6px;
  --shadow:         0 1px 3px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-page);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 布局骨架 ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #0D47A1 0%, #1565C0 100%);
  color: #fff;
  position: fixed; top: 0; left: 0; bottom: 0;
  display: flex; flex-direction: column;
  z-index: 100;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.15);
}
.brand-logo {
  width: 36px; height: 36px; border-radius: 8px;
  background: #fff; color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; flex-shrink: 0;
}
.brand-logo img { width: 100%; height: 100%; object-fit: contain; border-radius: 8px; }
.brand-text { font-size: 14px; font-weight: 600; line-height: 1.35; }
.brand-text small { display: block; font-size: 10px; opacity: .75; font-weight: 400; margin-top: 2px; }

.nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-group { padding: 8px 12px 4px; font-size: 11px; opacity: .6; letter-spacing: .5px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 18px; cursor: pointer;
  color: rgba(255,255,255,.82); text-decoration: none;
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.14); color: #fff; border-left-color: #fff; font-weight: 600; }
.nav-item .icon { width: 18px; text-align: center; font-size: 15px; }
.nav-badge { margin-left: auto; background: var(--st-red); color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 11px; }
.sidebar-foot { padding: 14px 18px; font-size: 11px; opacity: .6; border-top: 1px solid rgba(255,255,255,.15); }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; }
.header {
  height: var(--header-h); background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; position: sticky; top: 0; z-index: 50;
}
.header h1 { font-size: 18px; font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 16px; font-size: 13px; color: var(--text-secondary); }
.env-tag { background: var(--accent-light); color: var(--accent); padding: 3px 10px; border-radius: 12px; font-size: 12px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; }

.content { padding: 24px 28px 40px; }

/* ---------- 通用组件 ---------- */
.page { display: none; }
.page.active { display: block; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 18px; }
.page-title { font-size: 20px; font-weight: 600; }
.page-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.card {
  background: var(--bg-card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px;
}
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.card-title .bar { width: 3px; height: 15px; background: var(--primary); border-radius: 2px; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

/* KPI 卡片 */
.kpi { background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--primary); }
.kpi.green::before { background: var(--st-green); }
.kpi.orange::before { background: var(--st-orange); }
.kpi.red::before { background: var(--st-red); }
.kpi-label { font-size: 12px; color: var(--text-secondary); }
.kpi-value { font-size: 30px; font-weight: 700; line-height: 1.2; margin: 6px 0 2px; }
.kpi-unit { font-size: 14px; font-weight: 400; color: var(--text-muted); margin-left: 3px; }
.kpi-foot { font-size: 11px; color: var(--text-muted); }

/* 状态标签 */
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag-green  { color: var(--st-green);  background: var(--st-green-bg); }
.tag-yellow { color: #B8860B;          background: var(--st-yellow-bg); }
.tag-orange { color: var(--st-orange); background: var(--st-orange-bg); }
.tag-red    { color: var(--st-red);    background: var(--st-red-bg); }
.tag-gray   { color: var(--st-gray);   background: var(--st-gray-bg); }
.tag-blue   { color: var(--primary);   background: var(--primary-light); }

/* 来源徽标（3-3 确认） */
.src-badge { display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 4px; margin-left: 6px; vertical-align: middle; font-weight: 400; }
.src-device { background: #E8EAF6; color: #3F51B5; }
.src-system { background: #E0F2F1; color: #00695C; }
.readonly { background: var(--readonly-bg); color: var(--text-secondary); border-radius: 4px; padding: 3px 8px; }

/* 表格 */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { background: #F5F8FA; color: var(--text-secondary); font-weight: 600; text-align: left; padding: 11px 12px; border-bottom: 2px solid var(--border); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--border); }
tbody tr:hover { background: #F9FBFD; }
.table-wrap { overflow-x: auto; }

/* 按钮 */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: #fff; color: var(--text); font-size: 13px; cursor: pointer; transition: all .15s; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { color: var(--st-red); border-color: #FFCDD2; }

/* 筛选栏 */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; padding: 14px; background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow); }
.filter-bar label { font-size: 12px; color: var(--text-secondary); }
select, input[type=text], input[type=number], input[type=date], input[type=datetime-local] {
  padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-size: 13px; font-family: inherit; color: var(--text); background: #fff;
}
select:focus, input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }

/* 进度条/直方图条 */
.bar-track { height: 8px; background: #ECEFF1; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--primary); transition: width .5s; }
.bar-fill.green { background: var(--st-green); }
.bar-fill.orange { background: var(--st-orange); }
.bar-fill.red { background: var(--st-red); }

/* 模态框 */
.modal-mask { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; align-items: center; justify-content: center; }
.modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: 12px; width: min(760px, 92vw); max-height: 88vh; overflow-y: auto; box-shadow: 0 12px 40px rgba(0,0,0,.2); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { font-size: 16px; }
.modal-close { cursor: pointer; font-size: 22px; color: var(--text-muted); line-height: 1; }
.modal-body { padding: 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* 表单 */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-item label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 5px; }
.form-item label .req { color: var(--st-red); }
.form-item input, .form-item select { width: 100%; }
.form-item .hint { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.form-item .err { font-size: 11px; color: var(--st-red); margin-top: 3px; display: none; }
.form-item.invalid input { border-color: var(--st-red); }
.form-item.invalid .err { display: block; }
.field-hidden { display: none !important; }

/* 详情卡片分组 */
.detail-group { margin-bottom: 16px; }
.detail-group h4 { font-size: 13px; color: var(--primary); padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 20px; }
.detail-field { font-size: 13px; }
.detail-field .k { color: var(--text-muted); font-size: 11px; display: block; }
.detail-field .v { color: var(--text); margin-top: 2px; }

/* 曲线图容器 */
.chart-box { position: relative; height: 300px; }
.chart-svg { width: 100%; height: 100%; }

/* 时间轴/告警流 */
.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding: 0 0 18px 8px; }
.tl-item::before { content: ""; position: absolute; left: -19px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--primary-light); }
.tl-item.red::before { background: var(--st-red); box-shadow: 0 0 0 2px var(--st-red-bg); }
.tl-item.orange::before { background: var(--st-orange); box-shadow: 0 0 0 2px var(--st-orange-bg); }

/* 提示条 */
.notice { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px; background: var(--primary-light); color: var(--primary-dark); border-left: 3px solid var(--primary); }
.notice.warn { background: var(--st-orange-bg); color: #BF360C; border-left-color: var(--st-orange); }

/* 响应式 */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .sidebar { width: 64px; }
  .brand-text, .nav-item span:not(.icon), .sidebar-foot, .nav-group { display: none; }
  .nav-item { justify-content: center; padding: 12px 0; }
  .main { margin-left: 64px; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
