/* ============ 血糖监测管理系统 全局样式 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #0d9488;
  --primary-2: #14b8a6;
  --primary-light: #ccfbf1;
  --dark: #0f172a;
  --dark-2: #1e293b;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-2: #64748b;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.05);
}
html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; background: var(--dark); color: #cbd5e1;
  display: flex; flex-direction: column; position: fixed; top:0; bottom:0; left:0; z-index: 20;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px; font-size: 17px; font-weight: 700; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand .logo {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--primary-2), #059669);
  display: flex; align-items: center; justify-content: center;
}
.brand .logo svg { width: 20px; height: 20px; }
.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav-group { font-size: 11px; color: #64748b; padding: 12px 10px 6px; text-transform: uppercase; letter-spacing: .5px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px; margin: 2px 0; border-radius: 9px;
  color: #cbd5e1; font-size: 14px; transition: .18s;
}
.nav-item svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, var(--primary-2), var(--primary)); color: #fff; box-shadow: 0 4px 12px rgba(20,184,166,.35); }
.nav-item.active svg { opacity: 1; }
.sidebar-foot { padding: 14px 18px; font-size: 12px; color: #64748b; border-top: 1px solid rgba(255,255,255,.08); }

.main { flex: 1; margin-left: 232px; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  height: 62px; background: var(--card); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; position: sticky; top: 0; z-index: 10;
}
.topbar .page-title { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 9px; }
.topbar .page-title svg { width: 20px; height: 20px; color: var(--primary); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.user-chip .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-2), var(--primary));
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600;
}
.btn-logout {
  border: 1px solid var(--border); background: #fff; color: var(--text-2);
  padding: 6px 14px; border-radius: 8px; font-size: 13px; transition: .15s;
}
.btn-logout:hover { color: var(--danger); border-color: var(--danger); }
.btn-pwd { margin-right: 8px; }
.btn-pwd:hover { color: var(--primary, #0d9488); border-color: var(--primary, #0d9488); }
.btn-pwd svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; }

.content { padding: 24px 26px; flex: 1; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--border); padding: 20px;
}
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.card-title svg { width: 18px; height: 18px; color: var(--primary); }

/* 统计卡片 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--border); padding: 18px; display: flex; align-items: center; gap: 14px;
}
.stat-icon {
  width: 46px; height: 46px; border-radius: 11px; flex: none;
  display: flex; align-items: center; justify-content: center;
}
.stat-icon svg { width: 24px; height: 24px; }
.stat-icon.teal { background: #ccfbf1; color: var(--primary); }
.stat-icon.blue { background: #e0f2fe; color: #0284c7; }
.stat-icon.amber { background: #fef3c7; color: #d97706; }
.stat-icon.red { background: #fee2e2; color: #dc2626; }
.stat-icon.green { background: #dcfce7; color: #16a34a; }
.stat-num { font-size: 24px; font-weight: 800; line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.stat-sub { font-size: 11px; color: var(--text-2); }

/* 面板栅格 */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .grid-2, .grid-3, .grid-1-2 { grid-template-columns: 1fr; } }
.chart-box { width: 100%; height: 300px; }
.chart-title { margin: -8px 0 10px; font-size: 12px; color: var(--text-2); line-height: 1.4; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table thead th {
  text-align: left; padding: 11px 12px; background: #f8fafc; color: var(--text-2);
  font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table tbody td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: #f8fafc; }
.table .actions { display: flex; gap: 6px; }

/* 状态标签 */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.ok { background: #dcfce7; color: #16a34a; }
.badge.warn { background: #fef3c7; color: #d97706; }
.badge.danger { background: #fee2e2; color: #dc2626; }
.badge.gray { background: #f1f5f9; color: #64748b; }

/* ---------- 按钮 ---------- */
.btn {
  border: none; padding: 8px 16px; border-radius: 9px; font-size: 13.5px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px; transition: .15s;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: linear-gradient(135deg, var(--primary-2), var(--primary)); color: #fff; box-shadow: 0 4px 12px rgba(13,148,136,.3); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--text-2); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }

/* 表单 */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; font-weight: 600; }
.field .req::after { content: " *"; color: var(--danger); }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px;
  background: #fff; color: var(--text); transition: .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary-2); box-shadow: 0 0 0 3px rgba(20,184,166,.15);
}
.field .hint { font-size: 11px; color: var(--text-2); margin-top: 4px; }
.field input[type="date"], .field input[type="time"] { color-scheme: light; }
.modal-body .field { margin-bottom: 14px; }
.modal-body .field:last-child { margin-bottom: 0; }

/* 工具条 */
.toolbar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.toolbar .spacer { flex: 1; }
.search-input {
  padding: 8px 12px 8px 34px; border: 1px solid var(--border); border-radius: 9px; width: 240px;
  background: #fff url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%2364748b" stroke-width="2"><circle cx="11" cy="11" r="7"/><path d="M21 21l-4-4"/></svg>') no-repeat 10px center;
}
.search-input:focus { outline: none; border-color: var(--primary-2); }
.select-input { padding: 8px 12px; border: 1px solid var(--border); border-radius: 9px; background: #fff; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 100;
  display: none; align-items: flex-start; justify-content: center; padding: 40px 20px; overflow-y: auto;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 640px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2); animation: pop .2s ease;
}
.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-body { padding: 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
@keyframes pop { from { transform: translateY(-12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Toast 动态提示 */
#toastBox { position: fixed; top: 78px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
.toast {
  background: #fff; border-radius: 11px; box-shadow: 0 8px 30px rgba(0,0,0,.16);
  padding: 13px 16px; display: flex; gap: 11px; align-items: flex-start;
  border-left: 4px solid var(--primary-2); animation: slideIn .3s ease;
  max-width: 360px;
}
.toast svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.toast .toast-msg { font-size: 13px; line-height: 1.45; }
.toast.ok { border-left-color: var(--ok); } .toast.ok svg { color: var(--ok); }
.toast.warn { border-left-color: var(--warn); } .toast.warn svg { color: var(--warn); }
.toast.danger { border-left-color: var(--danger); } .toast.danger svg { color: var(--danger); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* 预警面板 */
.alert-list { display: flex; flex-direction: column; gap: 10px; max-height: 400px; overflow-y: auto; }
.alert-item {
  display: flex; gap: 11px; align-items: flex-start; padding: 12px 14px;
  border-radius: 10px; border: 1px solid var(--border); background: #f8fafc;
}
.alert-item svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert-item.danger { border-left: 4px solid var(--danger); } .alert-item.danger svg { color: var(--danger); }
.alert-item.warn { border-left: 4px solid var(--warn); } .alert-item.warn svg { color: var(--warn); }
.alert-item.ok { border-left: 4px solid var(--ok); } .alert-item.ok svg { color: var(--ok); }
.alert-item .alert-title { font-weight: 700; font-size: 13px; }
.alert-item .alert-desc { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }

/* 空状态 */
.empty { text-align: center; padding: 40px 20px; color: var(--text-2); }
.empty svg { width: 48px; height: 48px; opacity: .3; margin-bottom: 10px; }

/* 登录页 */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #134e4a 60%, #0d9488 100%);
  position: relative; overflow: hidden;
}
.login-wrap::before, .login-wrap::after {
  content: ""; position: absolute; border-radius: 50%; background: rgba(255,255,255,.05);
}
.login-wrap::before { width: 420px; height: 420px; top: -120px; right: -100px; }
.login-wrap::after { width: 340px; height: 340px; bottom: -110px; left: -80px; }
.login-card {
  position: relative; z-index: 2; width: 100%; max-width: 400px;
  background: rgba(255,255,255,.97); border-radius: 18px; padding: 40px 38px;
  box-shadow: 0 24px 80px rgba(0,0,0,.35);
}
.login-logo {
  width: 62px; height: 62px; border-radius: 16px; margin: 0 auto 18px;
  background: linear-gradient(135deg, var(--primary-2), #059669);
  display: flex; align-items: center; justify-content: center;
}
.login-logo svg { width: 34px; height: 34px; color: #fff; }
.login-title { text-align: center; font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.login-sub { text-align: center; color: var(--text-2); font-size: 13px; margin-bottom: 26px; }
.login-field { margin-bottom: 16px; }
.login-field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; font-weight: 600; }
.login-field .input-wrap { position: relative; }
.login-field .input-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: #94a3b8; }
.login-field input {
  width: 100%; padding: 12px 12px 12px 40px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px;
}
.login-field input:focus { outline: none; border-color: var(--primary-2); box-shadow: 0 0 0 3px rgba(20,184,166,.15); }
.login-btn {
  width: 100%; padding: 13px; border: none; border-radius: 10px; font-size: 15px; font-weight: 700;
  color: #fff; background: linear-gradient(135deg, var(--primary-2), var(--primary));
  margin-top: 6px; box-shadow: 0 8px 20px rgba(13,148,136,.35);
}
.login-btn:hover { filter: brightness(1.05); }
.login-tip { text-align: center; margin-top: 18px; font-size: 12px; color: var(--text-2); }
.login-tip code { background: #f1f5f9; padding: 2px 7px; border-radius: 6px; }

/* 页眉说明条 */
.info-bar {
  background: var(--primary-light); border: 1px solid #99f6e4; color: #0f766e;
  padding: 10px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 16px; display: flex; gap: 8px; align-items: center;
}
.info-bar svg { width: 18px; height: 18px; flex: none; }

/* 详情网格 */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.detail-item { background: #f8fafc; border-radius: 10px; padding: 12px 14px; border: 1px solid var(--border); }
.detail-item .k { font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.detail-item .v { font-size: 16px; font-weight: 700; }
.detail-item .v small { font-size: 11px; color: var(--text-2); font-weight: 400; }

.section-title { font-size: 14px; font-weight: 700; margin: 4px 0 12px; display: flex; align-items: center; gap: 8px; }
.section-title svg { width: 17px; height: 17px; color: var(--primary); }
.mt-4 { margin-top: 16px; }
.mt-2 { margin-top: 8px; }
.text-muted { color: var(--text-2); }
.flex { display: flex; align-items: center; gap: 10px; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }

/* ---------- 手机端菜单按钮 ---------- */
.menu-toggle {
  display: none; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; color: var(--text); margin-right: 4px;
}
.menu-toggle svg { width: 20px; height: 20px; }
.overlay { display: none; }

/* ---------- 响应式（手机/平板） ---------- */
@media (max-width: 960px) {
  .sidebar {
    transform: translateX(-100%); transition: transform .28s ease;
    width: 248px; box-shadow: 4px 0 24px rgba(0,0,0,.2);
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .overlay { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 15; opacity: 0; pointer-events: none; transition: opacity .28s; }
  .overlay.show { opacity: 1; pointer-events: auto; }
  .content { padding: 16px 14px; }
  .topbar { padding: 0 14px; height: 58px; }
  .user-chip span:last-child { display: none; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .search-input { width: 100%; }
  .toolbar { gap: 8px; }
  .card { padding: 16px; }
  .chart-box { height: 260px; }
  .stat-num { font-size: 20px; }
  .stat-icon { width: 40px; height: 40px; }
  .stat-icon svg { width: 21px; height: 21px; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .login-card { padding: 30px 22px; margin: 16px; }
  .btn-logout { padding: 6px 10px; }
  .table thead th, .table tbody td { padding: 8px 8px; font-size: 12px; }
}
