/* ===== 银发守护AI - 本地网页样式（对应设计稿：暖白底 + 深蓝主色） ===== */
:root {
  --bg: #F9F9F9;
  --card: #FFFFFF;
  --primary: #014DB2;
  --primary-light: #E0ECFF;
  --primary-soft: #F0F6FF;
  --text: #0A1628;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  --success: #10B981;
  --success-bg: #DDF4EC;
  --warning: #F59E0B;
  --warning-bg: #FFF3E0;
  --danger: #EF4444;
  --danger-bg: #FEF2F2;
  --border: #E5E7EB;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 2px 10px rgba(0,0,0,0.05);
  --shadow-lg: 0 8px 24px rgba(1,77,178,0.12);
}

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

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

a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ===== 顶部导航 ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .logo { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 18px; }
.logo-badge {
  width: 32px; height: 32px; border-radius: 8px; background: var(--primary);
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.topbar .right { display: flex; align-items: center; gap: 16px; }
.topbar .elderly-chip {
  background: var(--bg); border-radius: 8px; padding: 6px 12px;
  font-size: 13px; color: var(--text-secondary);
}
.topbar .logout-btn {
  border: none; background: none; color: var(--text-secondary); font-size: 13px;
}
.topbar .logout-btn:hover { color: var(--danger); }

/* ===== 布局 ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 24px; }
.page-title { font-size: 22px; font-weight: 600; margin-bottom: 4px; }
.page-sub { color: var(--text-secondary); font-size: 14px; margin-bottom: 20px; }

/* ===== 卡片 ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title-row h3 { font-size: 16px; font-weight: 600; }
.card-title-row a { font-size: 13px; }

/* ===== KPI 宫格 ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi-card { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.kpi-card .label { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
.kpi-card .value { font-size: 26px; font-weight: 600; }
.kpi-card .value.green { color: var(--success); }
.kpi-card .value.orange { color: var(--warning); }
.kpi-card .value.blue { color: var(--primary); }

/* ===== 双栏 ===== */
.two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* ===== 记录列表 ===== */
.record-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid #F1F3F5;
}
.record-item:last-child { border-bottom: none; }
.risk-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.risk-dot.critical, .risk-dot.high { background: var(--danger); }
.risk-dot.medium { background: var(--warning); }
.risk-dot.low { background: var(--primary); }
.risk-dot.safe { background: var(--success); }
.record-body { flex: 1; min-width: 0; }
.record-title { font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* 风险徽章 */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500; flex-shrink: 0;
}
.badge.critical, .badge.high { background: var(--danger-bg); color: #B91C1C; }
.badge.medium { background: var(--warning-bg); color: #B45309; }
.badge.low { background: var(--primary-light); color: var(--primary); }
.badge.safe { background: var(--success-bg); color: #047857; }

/* ===== 预警列表 ===== */
.alert-item {
  display: flex; gap: 12px; padding: 14px; border-radius: 12px;
  background: var(--card); box-shadow: var(--shadow); margin-bottom: 12px;
}
.alert-item .stripe { width: 4px; border-radius: 2px; flex-shrink: 0; }
.alert-item .stripe.red { background: var(--danger); }
.alert-item .stripe.orange { background: var(--warning); }
.alert-item .stripe.blue { background: var(--primary); }
.alert-body { flex: 1; }
.alert-title { font-weight: 600; font-size: 14px; }
.alert-title.red { color: #B91C1C; }
.alert-title.orange { color: #B45309; }
.alert-title.blue { color: #1D4ED8; }
.alert-desc { font-size: 13px; color: var(--text); margin-top: 4px; }
.alert-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 12px; color: var(--text-secondary); }
.alert-meta .action { font-weight: 500; }

/* ===== 表单 ===== */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 8px; }
.input {
  width: 100%; height: 48px; padding: 0 16px; border: 1px solid var(--border);
  border-radius: 12px; font-size: 15px; background: var(--card); color: var(--text);
  outline: none; transition: border-color .2s;
}
.input:focus { border-color: var(--primary); }
textarea.input { height: auto; padding: 14px 16px; resize: vertical; min-height: 120px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 24px; border: none; border-radius: 12px;
  font-size: 15px; font-weight: 600; color: #fff; background: var(--primary);
  transition: opacity .2s, transform .1s;
}
.btn:hover { opacity: 0.9; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-ghost { background: var(--card); color: var(--primary); border: 1px solid var(--border); font-weight: 500; }

/* ===== 登录页 ===== */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card { width: 420px; background: var(--card); border-radius: 20px; padding: 40px; box-shadow: var(--shadow-lg); }
.login-logo { display: flex; flex-direction: column; align-items: center; margin-bottom: 28px; }
.login-logo .logo-badge { width: 64px; height: 64px; border-radius: 18px; font-size: 28px; margin-bottom: 12px; }
.login-logo h1 { font-size: 24px; font-weight: 600; }
.login-logo p { color: var(--text-secondary); font-size: 13px; margin-top: 4px; }
.tab-switch { display: flex; background: var(--bg); border-radius: 10px; padding: 4px; margin-bottom: 24px; }
.tab-switch button {
  flex: 1; height: 36px; border: none; background: none; border-radius: 8px;
  font-size: 14px; color: var(--text-secondary); font-weight: 500;
}
.tab-switch button.active { background: var(--card); color: var(--primary); box-shadow: var(--shadow); font-weight: 600; }
.login-tip { display: flex; align-items: center; gap: 8px; margin-top: 16px; font-size: 12px; color: var(--text-secondary); justify-content: center; }
.form-error { background: var(--danger-bg); color: #B91C1C; font-size: 13px; padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; display: none; }
.code-row { display: flex; gap: 10px; }
.code-row .input { flex: 1; }
.code-row .btn { width: 110px; padding: 0; flex-shrink: 0; }

/* ===== 检测页 ===== */
.detect-result { margin-top: 20px; }
.risk-card { border-radius: 20px; padding: 24px; text-align: center; margin-bottom: 16px; }
.risk-card.critical, .risk-card.high { background: var(--danger-bg); }
.risk-card.medium { background: var(--warning-bg); }
.risk-card.low { background: var(--primary-light); }
.risk-card.safe { background: var(--success-bg); }
.risk-card .risk-level { font-size: 24px; font-weight: 600; }
.risk-card.critical .risk-level, .risk-card.high .risk-level { color: #B91C1C; }
.risk-card.medium .risk-level { color: #B45309; }
.risk-card.low .risk-level { color: var(--primary); }
.risk-card.safe .risk-level { color: #047857; }
.risk-card .risk-score { font-size: 14px; margin-top: 8px; color: var(--text-secondary); }
.risk-bar { height: 8px; border-radius: 4px; background: rgba(0,0,0,0.08); margin-top: 14px; overflow: hidden; }
.risk-bar .fill { height: 100%; border-radius: 4px; }
.risk-bar .fill.critical, .risk-bar .fill.high { background: var(--danger); }
.risk-bar .fill.medium { background: var(--warning); }
.risk-bar .fill.low { background: var(--primary); }
.risk-bar .fill.safe { background: var(--success); }

/* 要点列表 */
.point-list { list-style: none; }
.point-list li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; font-size: 14px; color: #374151; }
.point-list li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--danger); margin-top: 7px; flex-shrink: 0; }

/* 建议卡片 */
.advice-box {
  background: var(--primary-soft); border-radius: 12px; padding: 16px;
  font-size: 15px; line-height: 1.7; color: var(--text); margin-top: 12px;
}
.advice-box .advice-label { font-size: 12px; font-weight: 600; color: var(--primary); display: block; margin-bottom: 6px; }

/* 加载 */
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px; color: var(--text-secondary); }
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 空状态 */
.empty { text-align: center; color: var(--text-muted); padding: 32px 0; font-size: 13px; }

/* ===== 移动端适配（手机阅读优化） ===== */
@media (max-width: 640px) {
  body { font-size: 15px; }

  /* 顶部导航：紧凑 + 链接可横向滑动，避免换行拥挤 */
  .topbar { height: 52px; padding: 0 14px; }
  .topbar .logo span { font-size: 16px; }
  .topbar .logo { gap: 8px; }
  .topbar .right { gap: 14px; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .topbar .right::-webkit-scrollbar { display: none; }
  .topbar .right a, .topbar .logout-btn { font-size: 13px; }
  .topbar .elderly-chip { display: none; }

  /* 内容区收窄留白 */
  .container { padding: 16px; }
  .page-title { font-size: 20px; }
  .page-sub { font-size: 13px; }
  .card { padding: 16px; }
  .card-title, .card-title-row h3 { font-size: 15px; }

  /* KPI 宫格：4 列改 2 列 */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .kpi-card { padding: 16px; }
  .kpi-card .value { font-size: 22px; }

  /* 双栏在窄屏已折叠为单栏（900px 断点），此处仅缩间距 */
  .two-col { gap: 12px; }

  /* 登录/注册卡片撑满并内缩 */
  .login-wrap { padding: 16px; align-items: flex-start; padding-top: 40px; }
  .login-card { width: 100%; max-width: 420px; padding: 28px 20px; }

  /* 记录标题与建议文字略微放大，方便阅读 */
  .record-title { font-size: 15px; }
  .record-meta { font-size: 12px; }
  .advice-box { font-size: 16px; line-height: 1.8; }
  .point-list li { font-size: 15px; }
}
