/*
 * 颐养云 · 养老院 SaaS 管理系统
 * Copyright (c) 2026 颐养云. All rights reserved.
 * 商业授权软件：未经书面许可，不得复制、修改、反编译或分发。
 */
:root {
  --bg: #f4f6fa; --panel: #fff; --line: #e5e9f0; --text: #1f2937; --muted: #6b7280;
  --primary: #2563eb; --ok: #16a34a; --danger: #dc2626; --radius: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); padding-bottom: 62px;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

#loginPage { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, #eef4ff, #f6faf9); }
.login-card { width: 360px; max-width: calc(100vw - 28px); background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 28px 24px; box-shadow: 0 16px 44px rgba(30, 60, 110, .12); text-align: center; }
.login-mark { width: 48px; height: 48px; border-radius: 14px; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 20px; margin: 0 auto 12px; }
.login-title { font-size: 19px; font-weight: 700; }
.login-sub { color: var(--muted); font-size: 12px; margin: 6px 0 22px; }
.field-item { text-align: left; margin-bottom: 12px; }
.field-item label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.field { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; outline: none; background: #fff; color: var(--text); }
.field:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .1); }
.btn { border: 1px solid var(--line); background: #fff; color: var(--text); padding: 9px 14px; border-radius: 8px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn-block { width: 100%; padding: 12px; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.login-error { color: var(--danger); font-size: 13px; margin-top: 10px; }

#topbar { background: #fff; border-bottom: 1px solid var(--line); padding: 14px 18px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 5; }
.app-name { font-weight: 700; font-size: 15px; }
.app-sub { font-size: 12px; color: var(--muted); }
.user-chip { font-size: 12px; color: var(--primary); background: #eff6ff; padding: 4px 10px; border-radius: 20px; }
#content { padding: 14px; max-width: 720px; margin: 0 auto; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 15px; margin-bottom: 12px; box-shadow: 0 2px 8px rgba(20, 40, 80, .04); }
.card-title { font-weight: 700; font-size: 15px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 10px; }
.kv label { display: block; font-size: 11px; color: var(--muted); }
.kv div { word-break: break-all; }
.tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 20px; background: #eff6ff; color: var(--primary); }
.tag-warn { background: #fff6e6; color: #d97706; }
.tag-ok { background: #e8f8ef; color: var(--ok); }
.actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.section-title { font-size: 14px; font-weight: 700; margin: 0 0 10px; }

#tabbar { position: fixed; bottom: 0; left: 0; right: 0; height: 60px; background: #fff; border-top: 1px solid var(--line); display: flex; z-index: 10; }
.tab-item { flex: 1; text-align: center; padding: 8px 0; font-size: 11px; color: var(--muted); }
.tab-item.active { color: var(--primary); font-weight: 700; }
.tab-ico { display: block; width: 24px; height: 24px; line-height: 24px; margin: 0 auto 2px; border-radius: 8px; background: #f1f5f9; font-size: 12px; }
.tab-item.active .tab-ico { background: #eff6ff; }

.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .42); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: #fff; width: 100%; max-width: 720px; max-height: 90vh; border-radius: 16px 16px 0 0; display: flex; flex-direction: column; }
.modal-head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.modal-body { padding: 16px; overflow: auto; }
.modal-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.form-item { margin-bottom: 12px; }
.form-item label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 10px; }
@media (max-width: 520px) { .form-grid { grid-template-columns: 1fr; } }
.form-item.full { grid-column: 1 / -1; }
#toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 100; font-size: 13px; }
#toast.ok { background: var(--ok); }
#toast.err { background: var(--danger); }
.loading { text-align: center; color: var(--muted); padding: 30px; }

/* ---------- 老人照片与家属联系人 ---------- */
.h5-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line); flex: 0 0 auto; }
.h5-avatar-ph { display: inline-flex; align-items: center; justify-content: center; background: #e0e7ff; color: #3730a3; font-weight: 700; }
.card-head-avatar { display: flex; align-items: center; gap: 10px; }
.family-line { padding: 8px 0; border-bottom: 1px solid #eef1f5; font-size: 13px; }
.family-line:last-child { border-bottom: 0; }
/* ---------- AI 助手对话 ---------- */
.ai-msg { display: flex; margin-bottom: 10px; }
.ai-msg.user { justify-content: flex-end; }
.ai-msg.assistant { justify-content: flex-start; }
.ai-bubble { max-width: 86%; padding: 9px 12px; border-radius: 12px; line-height: 1.7; font-size: 13px; word-break: break-word; white-space: normal; }
.ai-msg.user .ai-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 3px; }
.ai-msg.assistant .ai-bubble { background: #f1f5f9; border-bottom-left-radius: 3px; }
[hidden] { display: none !important; }
