/* ==========================================================================
   CareLink 康达赋跨境医疗平台 — 一期原型 · 共享设计系统
   --------------------------------------------------------------------------
   Design Contract（设计契约，所有页面必须遵循，不得擅自改色/改字号/改 Nav）
   --------------------------------------------------------------------------
   · Style Tier   : business-international（国际化医疗 SaaS）
   · Aesthetic    : 克制、专业、可信赖的跨境医疗风；高信息密度 + 清晰层级
   · Tone         : 专业 / 克制 / 可信赖 / 国际化
   · Tech         : vanilla HTML + CSS + JS（纯静态，离线可打开）
   · Icon         : Lucide（inline SVG，通过 components.js 的 data-icon 注入）
   · 主色         : teal 医疗青绿 #0F766E；深色 #0B2B28；强调 cyan #0E7490
   ========================================================================== */

:root {
  /* —— 色彩 —— */
  --primary: #0F766E;
  --primary-hover: #0D6B63;
  --primary-soft: #E4F2F0;
  --accent: #0E7490;
  --deep: #0B2B28;               /* sidebar / appbar 深色 */
  --deep-2: #103531;

  --bg: #F5F7F6;
  --surface: #FFFFFF;
  --surface-2: #F0F4F3;
  --border: #E2E8E7;
  --border-strong: #CBD7D4;

  --text: #1E2B2A;               /* 非纯黑 */
  --text-sub: #5C6B69;
  --text-mut: #8A9996;

  --success: #16A34A;
  --success-soft: #E7F6EC;
  --warning: #D97706;
  --warning-soft: #FDF1E2;
  --danger: #DC2626;
  --danger-soft: #FCE8E8;
  --info: #0E7490;
  --info-soft: #E3F1F6;

  /* —— 字体 —— */
  --font-display: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-body: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", Consolas, "Courier New", monospace;
  --fs-12: 12px; --fs-13: 13px; --fs-14: 14px; --fs-16: 16px;
  --fs-20: 20px; --fs-24: 24px; --fs-28: 28px; --fs-32: 32px;

  /* —— 圆角 & 阴影 —— */
  --r-sm: 6px; --r-md: 10px; --r-lg: 16px; --r-xl: 22px;
  --sh-sm: 0 1px 2px rgba(11,43,40,.05);
  --sh-md: 0 4px 14px rgba(11,43,40,.08);
  --sh-lg: 0 12px 32px rgba(11,43,40,.12);

  /* —— 间距（4px 基数）—— */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;

  /* —— 布局 —— */
  --sidebar-w: 232px;
  --topbar-h: 60px;
  --appbar-h: 56px;
  --tabbar-h: 60px;
  --content-max: 1200px;
}

/* ===== Reset ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  font-size: var(--fs-14);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
ul { list-style: none; }
h1,h2,h3,h4 { font-family: var(--font-display); font-weight: 650; line-height: 1.3; }

/* 背景氛围：浅色渐变 + 轻微噪点（克制的医疗氛围） */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(1200px 500px at 15% -10%, rgba(15,118,110,.06), transparent 60%),
    radial-gradient(900px 420px at 100% 0%, rgba(14,116,144,.06), transparent 55%),
    linear-gradient(180deg, #FAFBFA 0%, #F3F6F5 100%);
}

/* ===== 通用组件 ===== */
/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border-radius: var(--r-md);
  border: 1px solid transparent; cursor: pointer;
  font-family: var(--font-body); font-size: var(--fs-14); font-weight: 550;
  transition: all .15s ease; white-space: nowrap;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: translateY(1px); }
.btn-ghost { background: transparent; color: var(--primary); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--primary-soft); border-color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.94); }
.btn-sm { height: 32px; padding: 0 12px; font-size: var(--fs-13); border-radius: var(--r-sm); }
.btn-lg { height: 48px; padding: 0 24px; font-size: var(--fs-16); border-radius: var(--r-md); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 输入 */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: var(--fs-13); font-weight: 600; color: var(--text-sub); }
.input, .select, .textarea {
  width: 100%; height: 42px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  font-family: var(--font-body); font-size: var(--fs-14); color: var(--text);
  background: var(--surface); transition: border .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 96px; padding: 12px 14px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15,118,110,.12);
}
.input:disabled { background: var(--surface-2); color: var(--text-mut); }
.input-hint { font-size: var(--fs-12); color: var(--text-mut); }

/* 卡片 */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh-sm);
}
.card-pad { padding: var(--sp-5); }
.card-hover { transition: transform .15s, box-shadow .15s; }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--sh-md); }
.card-title { font-size: var(--fs-16); font-weight: 650; margin-bottom: 4px; }

/* 标签 / 徽章 */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  height: 24px; padding: 0 10px; border-radius: 999px;
  font-size: var(--fs-12); font-weight: 600; line-height: 1;
}
.tag-green { background: var(--success-soft); color: var(--success); }
.tag-amber { background: var(--warning-soft); color: var(--warning); }
.tag-red   { background: var(--danger-soft); color: var(--danger); }
.tag-blue  { background: var(--info-soft); color: var(--info); }
.tag-gray  { background: var(--surface-2); color: var(--text-sub); }

/* 表格 */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-14); }
.table th {
  text-align: left; padding: 12px 16px; background: var(--surface-2);
  font-weight: 600; color: var(--text-sub); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: #FAFCFB; }
.table .num { font-family: var(--font-mono); font-size: var(--fs-13); }

/* 空状态 */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 48px 20px; text-align: center; color: var(--text-mut);
}
.empty .icon-wrap { width: 56px; height: 56px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; color: var(--text-sub); }

/* 头像（无图，首字母圆形） */
.avatar {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; font-weight: 650; font-size: var(--fs-14); flex: none;
}
.avatar.sm { width: 32px; height: 32px; font-size: var(--fs-12); }
.avatar.lg { width: 56px; height: 56px; font-size: var(--fs-20); }

/* 图标容器（components.js 会把 data-icon 替换为 Lucide SVG） */
.icon { display: inline-flex; width: 20px; height: 20px; flex: none; }
.icon svg { width: 100%; height: 100%; stroke-width: 1.6; }
.icon.sm { width: 16px; height: 16px; }
.icon.lg { width: 24px; height: 24px; }
.m-brand .logo svg, .admin-logo .logo svg { width: 16px; height: 16px; }
.m-appbar .icon-btn svg, .admin-topbar svg { width: 18px; height: 18px; }

/* 进度条 */
.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(20px);
  background: var(--deep); color: #fff; padding: 12px 20px; border-radius: var(--r-md);
  font-size: var(--fs-14); box-shadow: var(--sh-lg); opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s; z-index: 999;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== 移动端 App Shell（客户端 / 渠道端共用结构）===== */
.m-appbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--appbar-h); z-index: 50;
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.m-brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 700; font-size: var(--fs-16); color: var(--primary); }
.m-brand .logo { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--primary), var(--accent)); display: grid; place-items: center; color: #fff; }
.m-appbar .spacer { flex: 1; }
.m-appbar .icon-btn { width: 34px; height: 34px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); display: grid; place-items: center; color: var(--text-sub); cursor: pointer; }

.m-content {
  padding: calc(var(--appbar-h) + 16px) 16px calc(var(--tabbar-h) + 24px);
  max-width: 560px; margin: 0 auto;
}

.m-tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--tabbar-h); z-index: 50;
  display: flex; background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.m-tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--text-mut); font-size: var(--fs-12); font-weight: 550;
}
.m-tabbar a .icon { width: 22px; height: 22px; }
.m-tabbar a.active { color: var(--primary); }
.m-tabbar a.active .icon { stroke-width: 2; }

/* ===== 桌面后台 App Shell（运营/医疗后台）===== */
.admin-sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 60;
  background: var(--deep); color: rgba(255,255,255,.82);
  display: flex; flex-direction: column; padding: 20px 14px;
}
.admin-logo { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; color: #fff; font-family: var(--font-display); font-weight: 700; font-size: var(--fs-16); }
.admin-logo .logo { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--primary), var(--accent)); display: grid; place-items: center; color: #fff; }
.admin-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }
.admin-nav .nav-group { font-size: var(--fs-12); color: rgba(255,255,255,.4); padding: 16px 12px 6px; letter-spacing: .5px; }
.admin-nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: var(--r-md);
  font-size: var(--fs-14); font-weight: 550; color: rgba(255,255,255,.78); transition: all .15s;
}
.admin-nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.admin-nav a.active { background: var(--primary); color: #fff; }
.admin-sidebar .side-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.1); font-size: var(--fs-12); color: rgba(255,255,255,.45); }

.admin-main { margin-left: var(--sidebar-w); min-height: 100vh; }
.admin-topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px; padding: 0 28px;
  background: rgba(255,255,255,.9); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.admin-topbar .crumb { font-weight: 600; color: var(--text); }
.admin-topbar .crumb-sub { color: var(--text-mut); }
.admin-topbar .spacer { flex: 1; }
.search-box { display: flex; align-items: center; gap: 8px; width: 260px; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--r-md); color: var(--text-mut); background: var(--surface); }
.search-box input { flex: 1; border: none; outline: none; font-family: var(--font-body); font-size: var(--fs-14); color: var(--text); background: transparent; }
.admin-content { padding: 28px; max-width: var(--content-max); }

/* 统计卡片 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.stat-card { padding: 20px; }
.stat-card .stat-label { font-size: var(--fs-13); color: var(--text-sub); margin-bottom: 8px; }
.stat-card .stat-value { font-family: var(--font-display); font-size: var(--fs-28); font-weight: 700; line-height: 1; }
.stat-card .stat-delta { font-size: var(--fs-12); color: var(--success); margin-top: 6px; }

/* 布局工具 */
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.mt-1{margin-top:4px} .mt-2{margin-top:8px} .mt-3{margin-top:12px} .mt-4{margin-top:16px} .mt-5{margin-top:24px}
.mb-2{margin-bottom:8px} .mb-4{margin-bottom:16px} .mb-5{margin-bottom:24px}
.text-sub{color:var(--text-sub)} .text-mut{color:var(--text-mut)} .text-primary{color:var(--primary)}
.text-sm{font-size:var(--fs-13)} .text-xs{font-size:var(--fs-12)}
.fw{font-weight:650}
.mono{font-family:var(--font-mono)}

/* 页面加载 stagger 动效 */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.reveal { animation: rise .4s ease both; }
.reveal.d1 { animation-delay: .05s; } .reveal.d2 { animation-delay: .12s; } .reveal.d3 { animation-delay: .2s; }
.reveal.d4 { animation-delay: .28s; } .reveal.d5 { animation-delay: .36s; }

/* 移动端缩放安全检查：≤480 单列，768 双列，≥1024 内容居中 */
@media (max-width: 480px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== 返回入口按钮（全端通用）===== */
.back-btn {
  display: grid; place-items: center; flex: none;
  width: 34px; height: 34px; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-sub); cursor: pointer; transition: all .15s;
}
.back-btn:hover { color: var(--primary); border-color: var(--primary); }
.back-btn svg { width: 18px; height: 18px; }

/* ===== 客户端 · 375px 手机展示框 ===== */
.client-phone .m-appbar,
.client-phone .m-tabbar {
  left: 50%; right: auto; transform: translateX(-50%);
  width: min(375px, 100vw);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.client-phone .m-content {
  width: min(375px, 100vw); max-width: 375px;
  min-height: 100vh;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

/* ===== 原型入口页（Portal，三端引导）===== */
.portal-main { max-width: 1080px; margin: 0 auto; padding: 48px 32px 80px; }
.portal-hero { text-align: center; margin-bottom: 40px; }
.portal-brand {
  display: inline-flex; align-items: center; gap: 12px;
  font-family: var(--font-display); font-size: var(--fs-28); font-weight: 700; color: var(--deep);
}
.portal-brand .logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid; place-items: center; color: #fff;
}
.portal-brand .logo svg { width: 22px; height: 22px; }
.portal-section { margin-top: 28px; }
.portal-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
  font-family: var(--font-display); font-size: var(--fs-16); font-weight: 650; color: var(--text);
}
.portal-head .icon { color: var(--primary); }
.portal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.portal-card { display: flex; flex-direction: column; gap: 4px; }
.portal-card .desc { font-size: var(--fs-12); color: var(--text-mut); }