/* ============================================================
   慢病管理平台 — Design tokens + global styles (native CSS)
   ============================================================ */
:root {
  /* palette: calm clinical teal + neutral slate */
  --c-primary: #0f766e;         /* teal-700 */
  --c-primary-600: #0d9488;
  --c-primary-500: #14b8a6;
  --c-primary-050: #f0fdfa;
  --c-accent: #2563eb;
  --c-bg: #f6f8fa;
  --c-surface: #ffffff;
  --c-border: #e5e9ef;
  --c-text: #1f2937;
  --c-text-soft: #6b7280;
  --c-text-faint: #9ca3af;

  /* risk levels */
  --risk-low: #16a34a;
  --risk-medium: #d97706;
  --risk-high: #ea580c;
  --risk-very_high: #dc2626;

  --danger: #dc2626;
  --ok: #16a34a;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.05);
  --shadow-md: 0 4px 12px rgba(16,24,40,.08);
  --sidebar-w: 236px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--c-text);
  background: var(--c-bg);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ---------- layout shell ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: #0b3b39;
  color: #cdeae6;
  display: flex; flex-direction: column;
  position: fixed; inset: 0 auto 0 0; height: 100vh;
}
.sidebar__brand {
  padding: 22px 22px 18px;
  font-size: 17px; font-weight: 700; color: #fff;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar__brand .dot {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, var(--c-primary-500), var(--c-primary-600));
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff;
}
.sidebar__brand .dot svg { width: 16px; height: 16px; display: block; }
.sidebar__brand small {
  font-size: 11px; font-weight: 500; color: rgba(255,255,255,.55);
  letter-spacing: .2px;
}
.nav { padding: 12px 12px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; margin: 2px 0;
  border-radius: var(--radius-sm);
  color: #a9d3ce; font-weight: 500; cursor: pointer;
  transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: var(--c-primary-600); color: #fff; }
.nav a .ico { width: 18px; text-align: center; }
.nav-group { margin-bottom: 10px; }
.nav-group__title {
  padding: 8px 14px 4px; font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; color: #6f9f9a; font-weight: 700;
}
.sidebar__user {
  padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08);
  font-size: 13px; color: #8fbdb8;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.sidebar__user button {
  background: transparent; border: 1px solid rgba(255,255,255,.2);
  color: #cdeae6; border-radius: 6px; padding: 4px 10px; cursor: pointer;
  font-size: 12px;
}
.sidebar__user button:hover { background: rgba(255,255,255,.1); }

.main {
  margin-left: var(--sidebar-w);
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
}
.topbar {
  height: 60px; background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; padding: 0 28px;
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 650; }
.content { padding: 26px 28px; flex: 1; min-width: 0; }

/* ---------- cards / grid ---------- */
.grid { display: grid; gap: 16px; }
.cards { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.card {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 18px 20px;
}
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat .label { color: var(--c-text-soft); font-size: 13px; }
.stat .value { font-size: 30px; font-weight: 700; letter-spacing: -.5px; }
.stat .value.warn { color: var(--risk-high); }
.stat .sub { font-size: 12px; color: var(--c-text-faint); }

.panel { background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden;
  min-width: 0; overflow-x: auto; }
.panel__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--c-border);
}
.panel__head h2 { font-size: 15px; margin: 0; font-weight: 650; }
.panel__body { padding: 18px 20px; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 20px; font-size: 13.5px; }
thead th {
  color: var(--c-text-soft); font-weight: 600; background: #fafbfc;
  border-bottom: 1px solid var(--c-border); position: sticky; top: 0;
}
tbody tr { border-bottom: 1px solid #f0f2f5; cursor: pointer; }
tbody tr:hover { background: var(--c-primary-050); }
tbody tr:last-child { border-bottom: none; }

/* ---------- badges ---------- */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.6;
}
.badge--low       { background: #dcfce7; color: var(--risk-low); }
.badge--medium    { background: #fef3c7; color: var(--risk-medium); }
.badge--high       { background: #ffedd5; color: var(--risk-high); }
.badge--very_high { background: #fee2e2; color: var(--risk-very_high); }
.badge--pending   { background: #fef3c7; color: var(--risk-medium); }
.badge--completed { background: #dcfce7; color: var(--ok); }
.badge--missed    { background: #fee2e2; color: var(--danger); }
.badge--disease   { background: #e0f2fe; color: #0369a1; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--c-border); background: var(--c-surface);
  color: var(--c-text); font-weight: 600; font-size: 13.5px; cursor: pointer;
  transition: all .15s;
}
.btn:hover { border-color: var(--c-primary-500); color: var(--c-primary); }
.btn--primary {
  background: var(--c-primary); border-color: var(--c-primary); color: #fff;
}
.btn--primary:hover { background: var(--c-primary-600); color: #fff; }
.btn--sm { padding: 5px 12px; font-size: 12.5px; }
.btn--danger { color: var(--danger); border-color: #fca5a5; }
.btn--danger:hover { background: #fee2e2; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--c-text-soft); font-weight: 500; }
.input, select, textarea {
  width: 100%; padding: 9px 12px; font-size: 14px; font-family: inherit;
  border: 1px solid var(--c-border); border-radius: var(--radius-sm);
  background: #fff; color: var(--c-text); transition: border .15s, box-shadow .15s;
}
.input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--c-primary-500);
  box-shadow: 0 0 0 3px rgba(20,184,166,.15);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.45);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  padding: 20px;
}
.modal {
  background: #fff; border-radius: var(--radius); width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-md);
}
.modal__head { display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px; border-bottom: 1px solid var(--c-border); }
.modal__head h3 { margin: 0; font-size: 16px; }
.modal__head .x { cursor: pointer; color: var(--c-text-faint); font-size: 20px; background:none;border:none; }
.modal__body { padding: 20px 22px; max-height: 70vh; overflow-y: auto; }
.modal__foot { padding: 14px 22px; border-top: 1px solid var(--c-border);
  display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0b3b39 0%, #0f766e 100%);
  padding: 20px;
}
.login-card {
  background: #fff; border-radius: 16px; box-shadow: var(--shadow-md);
  width: 100%; max-width: 400px; padding: 36px 34px;
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; display:flex; align-items:center; gap:12px; }
.login-card h1 .brand-logo {
  width: 40px; height: 40px; border-radius: 11px; flex: none;
  background: linear-gradient(135deg, var(--c-primary-500), var(--c-primary-600));
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; box-shadow: 0 6px 16px rgba(13,148,136,.28);
}
.login-card h1 .brand-logo svg { width: 24px; height: 24px; display: block; }
.login-card .sub { color: var(--c-text-soft); margin: 0 0 26px; font-size: 13.5px; }
.login-hint { margin-top: 16px; font-size: 12.5px; color: var(--c-text-faint); text-align: center; }

/* ---------- misc ---------- */
.muted { color: var(--c-text-soft); }
.empty { text-align: center; color: var(--c-text-faint); padding: 40px 20px; }
.row-between { display:flex; align-items:center; justify-content:space-between; gap: 12px; }
.mb-16 { margin-bottom: 16px; }
.mt-20 { margin-top: 20px; }
.toolbar { display:flex; gap: 10px; align-items:center; margin-bottom: 16px; flex-wrap: wrap; }
.search { max-width: 280px; }
.error-text { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 18px; }
.chart-legend { display:flex; gap:16px; flex-wrap:wrap; margin-top:12px; font-size:12.5px; color: var(--c-text-soft);}
.chart-legend span { display:inline-flex; align-items:center; gap:6px; }
.chart-legend i { width:10px; height:10px; border-radius:2px; display:inline-block; }
.kv { display:grid; grid-template-columns: 96px 1fr; gap: 8px 12px; font-size:13.5px; }
.kv dt { color: var(--c-text-soft); }
.spinner { text-align:center; padding: 50px; color: var(--c-text-faint); }

/* 二级选项卡（模块内子页切换） */
.tabs { display:flex; gap:4px; margin-bottom:18px; border-bottom:1px solid var(--c-border); flex-wrap:wrap; }
.tab { background:none; border:none; padding:9px 16px; font-size:14px; cursor:pointer;
  color: var(--c-text-soft); border-bottom:2px solid transparent; margin-bottom:-1px; }
.tab:hover { color: var(--c-text); }
.tab.active { color: var(--c-accent, #0f766e); border-bottom-color: var(--c-accent, #0f766e); font-weight:600; }

/* 简易横向键值（div/span 版，用于弹窗信息展示） */
.kv-inline { display:flex; flex-wrap:wrap; gap:8px 24px; font-size:13.5px; margin-bottom:14px; }
.kv-inline > div { display:flex; gap:6px; }
.kv-inline span { color: var(--c-text-soft); }

/* ===== 可视化监控大屏 ===== */
.screen { background:#0b1220; color:#e2e8f0; border-radius:12px; padding:20px 22px 26px;
  margin:-4px; min-height:calc(100vh - 120px); }
.screen__head { display:flex; align-items:center; justify-content:space-between;
  padding-bottom:16px; border-bottom:1px solid #1e293b; margin-bottom:18px; }
.screen__title { font-size:22px; font-weight:700; letter-spacing:1px;
  background:linear-gradient(90deg,#38bdf8,#a78bfa); -webkit-background-clip:text;
  background-clip:text; color:transparent; }
.screen__clock { font-size:14px; color:#94a3b8; font-variant-numeric:tabular-nums; }
.screen__kpis { display:grid; grid-template-columns:repeat(5,1fr); gap:14px; margin-bottom:18px; }
.screen__kpi { background:linear-gradient(160deg,#111c33,#0d1526); border:1px solid #1e293b;
  border-radius:10px; padding:16px 14px; text-align:center; }
.screen__kpi-v { font-size:28px; font-weight:700; color:#38bdf8; font-variant-numeric:tabular-nums; }
.screen__kpi-l { font-size:14px; color:#cbd5e1; margin-top:6px; }
.screen__kpi-s { font-size:12px; color:#64748b; margin-top:3px; }
.screen__grid { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
.screen__panel { background:#0d1526; border:1px solid #1e293b; border-radius:10px; padding:16px 18px; }
.screen__panel--wide { grid-column:1 / -1; }
.screen__map { width:100%; height:420px; }
.screen__panel-h { font-size:15px; font-weight:600; color:#e2e8f0; margin-bottom:16px;
  padding-left:10px; border-left:3px solid #38bdf8; }
.screen__gauges { display:flex; justify-content:space-around; gap:12px; }
.screen__gauge { text-align:center; }
.screen__ring { width:104px; height:104px; border-radius:50%; display:flex;
  align-items:center; justify-content:center; }
.screen__ring-in { width:78px; height:78px; border-radius:50%; background:#0d1526;
  display:flex; align-items:center; justify-content:center; }
.screen__ring-in span { font-size:20px; font-weight:700; color:#f1f5f9; }
.screen__gauge-l { margin-top:10px; font-size:13px; color:#94a3b8; }
.screen__bars { display:flex; flex-direction:column; gap:11px; }
.screen__bar { display:flex; align-items:center; gap:10px; }
.screen__bar-l { width:88px; font-size:13px; color:#cbd5e1; flex-shrink:0;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.screen__bar-t { flex:1; background:#1e293b; border-radius:5px; height:16px; overflow:hidden; }
.screen__bar-f { height:100%; border-radius:5px; min-width:2px; transition:width .4s; }
.screen__bar-v { width:38px; text-align:right; font-size:13px; font-weight:600;
  color:#f1f5f9; font-variant-numeric:tabular-nums; }
.screen .empty { color:#64748b; }
@media (max-width:1000px) {
  .screen__kpis { grid-template-columns:repeat(2,1fr); }
  .screen__grid { grid-template-columns:1fr; }
}

/* ===== AI 干预建议 ===== */
.head-actions { display:flex; gap:8px; align-items:center; }
.ai-summary { background: var(--c-primary-050); border:1px solid var(--c-border);
  border-radius: var(--radius-sm); padding:12px 14px; margin-bottom:14px; }
.ai-summary__badge { display:inline-block; font-size:12px; color: var(--c-primary);
  background:#fff; border:1px solid var(--c-primary-500); border-radius:999px;
  padding:2px 10px; margin-bottom:6px; }
.ai-summary p { margin:0; font-size:14px; color: var(--c-text); line-height:1.6; }
.ai-suggestions { display:flex; flex-direction:column; gap:10px; }
.ai-card { border:1px solid var(--c-border); border-radius: var(--radius-sm); padding:12px 14px; }
.ai-card__head { display:flex; align-items:center; gap:10px; margin-bottom:6px; }
.ai-card__head strong { flex:1; font-size:14px; }
.ai-card p { margin:0; font-size:13px; line-height:1.6; }
.ai-disclaimer { margin-top:14px; font-size:12px; color: var(--c-text-soft);
  border-top:1px dashed var(--c-border); padding-top:10px; }

/* ---------- 汉堡按钮（移动端侧边栏开关） ---------- */
.hamburger {
  display: none;
  position: fixed; top: 12px; left: 12px; z-index: 90;
  width: 40px; height: 40px; align-items: center; justify-content: center;
  border: 1px solid var(--c-border); border-radius: 8px;
  background: var(--c-surface); color: var(--c-text);
  font-size: 18px; cursor: pointer; box-shadow: var(--shadow-sm);
}
.sidebar-mask {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.4); z-index: 40;
}

@media (max-width: 860px) {
  .hamburger { display: flex; }
  .sidebar { transform: translateX(-100%); transition: transform .25s; z-index: 60; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .form-row { grid-template-columns: 1fr; }
}

/* ---- pager ---- */
.pager { display:flex; align-items:center; gap:4px; padding:12px 4px 2px; font-size:13px; }
.pager__info { color:#6b7280; }
.pager__btn { min-width:30px; height:30px; padding:0 8px; border:1px solid #e5e7eb; background:#fff; border-radius:6px; cursor:pointer; font-size:13px; color:#374151; }
.pager__btn:hover:not(:disabled) { border-color:#0f766e; color:#0f766e; }
.pager__btn--active { background:#0f766e; border-color:#0f766e; color:#fff; }
.pager__btn:disabled { opacity:.4; cursor:not-allowed; }
.pager__dots { color:#9ca3af; padding:0 2px; }
