/* =========================================================
   西安三级医院智能导诊 —— 全局样式
   设计令牌 + 组件样式（按页面前缀隔离，替代 scoped CSS）
   ========================================================= */

:root {
  --brand: #0d9488;
  --brand-strong: #0f766e;
  --brand-soft: #ccfbf1;
  --urgent: #dc2626;
  --warn: #d97706;
  --info: #2563eb;

  --bg: #f4f6f9;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);

  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 22px;

  --tabbar-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

[data-theme='dark'] {
  --brand: #2dd4bf;
  --brand-strong: #5eead4;
  --brand-soft: #134e4a;
  --urgent: #f87171;
  --warn: #fbbf24;
  --info: #60a5fa;

  --bg: #0b1220;
  --bg-elevated: #111c2e;
  --surface: #142033;
  --surface-2: #1a283c;
  --border: #22344c;
  --border-strong: #2f4560;

  --text: #e8eef6;
  --text-2: #a8b8cc;
  --text-3: #6b7f96;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 14px 36px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color .28s ease, color .28s ease;
}

#app {
  max-width: 620px;
  margin: 0 auto;
  min-height: 100%;
  background: var(--bg);
  position: relative;
}

/* ============ 通用组件 ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.5;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.chip-brand { background: var(--brand-soft); color: var(--brand-strong); border-color: transparent; }
.chip-danger { background: color-mix(in srgb, var(--urgent) 14%, transparent); color: var(--urgent); border-color: transparent; }
.chip-warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); border-color: transparent; }
.chip-info { background: color-mix(in srgb, var(--info) 13%, transparent); color: var(--info); border-color: transparent; }

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: .04em;
  margin: 18px 4px 10px;
}

.btn {
  border: none;
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  padding: 14px 20px;
  border-radius: 14px;
  cursor: pointer;
  transition: transform .16s cubic-bezier(.16, 1, .3, 1), box-shadow .16s, opacity .16s;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 32%, transparent);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .55; box-shadow: none; cursor: not-allowed; }
.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: none;
  font-weight: 500;
}

.divider { height: 1px; background: var(--border); margin: 14px 0; }

.value-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 4px 0; }
.value-row dt { color: var(--text-2); margin: 0; }
.value-row dd { margin: 0; color: var(--text); font-weight: 500; text-align: right; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, color-mix(in srgb, var(--surface-2) 60%, var(--surface)) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 10px;
}
@keyframes shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.page {
  padding: calc(10px + var(--safe-t)) 16px calc(18px + var(--safe-b));
  animation: fade-up .32s cubic-bezier(.16, 1, .3, 1);
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

::-webkit-scrollbar { width: 0; height: 0; }

/* ============ 应用外壳 ============ */
.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* 预留给底部固定 tabbar 的高度，避免页脚被遮挡 */
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b));
}
.appbar {
  position: sticky; top: 0; z-index: 50;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  display: flex; align-items: center; justify-content: space-between;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 55%, var(--info)));
  color: #fff; font-weight: 700; font-size: 16px;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--brand) 34%, transparent);
}
.brand strong { display: block; font-size: 16px; letter-spacing: .01em; }
.brand small { display: block; font-size: 11px; color: var(--text-3); }
.theme {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2); cursor: pointer;
  transition: transform .2s, color .2s;
}
.theme:active { transform: scale(.92); }

.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 620px;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border-top: 1px solid var(--border);
  z-index: 60;
}
.tabbar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-3);
  font-size: 11px;
  text-decoration: none;
  transition: color .2s;
}
.tabbar-item.active { color: var(--brand); }
.tabbar-item svg { width: 23px; height: 23px; }

/* ============ 页脚备案（版权 + ICP） ============ */
.beian-bar {
  margin-top: auto;
  padding: 12px 16px;
  background: linear-gradient(90deg, #1e5bb8, #2563eb);
  color: rgba(255, 255, 255, .85);
  font-size: 12px;
  line-height: 1.8;
  letter-spacing: .2px;
  border-top: 1px solid rgba(255, 255, 255, .18);
  text-align: center;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.beian-bar a {
  color: #fff;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, .45);
  padding-bottom: 1px;
  transition: opacity .18s;
}
.beian-bar a:hover { opacity: .85; }
[data-theme='dark'] .beian-bar {
  background: linear-gradient(90deg, #17407e, #1d4ed8);
}

/* ============ 定位条 ============ */
.locbar { display: flex; gap: 8px; align-items: center; position: relative; }
.loc-btn {
  flex: 1;
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); padding: 9px 12px; border-radius: 12px; font-size: 14px;
  cursor: pointer; min-width: 0;
}
.loc-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; text-align: left; }
.loc-btn > svg:first-child { color: var(--brand); flex: none; }
.gps-btn {
  display: flex; align-items: center; gap: 5px;
  background: var(--brand-soft); color: var(--brand-strong);
  border: none; padding: 9px 12px; border-radius: 12px; font-size: 13px; font-weight: 600;
  cursor: pointer; flex: none;
}
.gps-btn:disabled { opacity: .6; }

.toast {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-md); border-radius: 10px; padding: 8px 12px;
  font-size: 12.5px; color: var(--text-2); z-index: 40;
}
.toast-enter-active, .toast-leave-active { transition: all .24s ease; }
.toast-enter-from, .toast-leave-to { opacity: 0; transform: translateY(-6px); }

.sheet-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: flex-end; justify-content: center; z-index: 90;
}
.sheet {
  width: 100%; max-width: 620px;
  background: var(--bg-elevated); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 16px 16px calc(20px + var(--safe-b)); box-shadow: var(--shadow-lg);
  animation: up .28s cubic-bezier(.16, 1, .3, 1);
}
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; font-size: 15px; }
.sheet-close { background: none; border: none; font-size: 18px; color: var(--text-3); cursor: pointer; }
.sheet-hint { font-size: 12px; color: var(--text-3); margin: 6px 0 12px; }
.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-pick { padding: 8px 14px; font-size: 13px; cursor: pointer; }
.chip-pick.on {
  background: var(--brand-soft); color: var(--brand-strong);
  border-color: var(--brand); font-weight: 600;
}
.sheet-enter-active, .sheet-leave-active { transition: opacity .24s; }
.sheet-enter-from, .sheet-leave-to { opacity: 0; }

/* ============ 首页 ============ */
.home-input { padding: 14px; margin-top: 12px; }
.home-input textarea {
  width: 100%; border: none; outline: none; resize: none;
  background: transparent; color: var(--text);
  font-family: inherit; font-size: 15.5px; line-height: 1.65;
}
.home-input textarea::placeholder { color: var(--text-3); }
.home-input .row { display: flex; justify-content: space-between; align-items: center; margin: 8px 0 12px; }
.home-input .count { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.home-input .count.danger { color: var(--urgent); }
.home-input .tip { font-size: 11px; color: var(--text-3); }

.home-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-ex {
  padding: 8px 13px; font-size: 13px; cursor: pointer; border-radius: 999px;
  transition: all .18s; background: var(--surface); border: 1px solid var(--border);
  color: var(--text-2);
}
.chip-ex:active { transform: scale(.96); background: var(--brand-soft); color: var(--brand-strong); }

.err {
  margin: 14px 0; padding: 11px 13px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--urgent) 10%, transparent); color: var(--urgent); font-size: 13px;
}

.summary { padding: 13px 14px; margin-top: 14px; }
.summary .s-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.summary .s-head strong { font-size: 14px; }
.dept-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; }
.dept-line b { font-size: 12px; color: var(--text-3); font-weight: 500; margin-right: 2px; }
.dept-line b + * { margin-right: 6px; }
.route-note { margin: 9px 0 0; font-size: 11.5px; color: var(--text-3); }

.clarify {
  margin: 12px 0; padding: 12px 14px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border-left: 3px solid var(--warn); font-size: 13px; color: var(--text);
}
.empty { text-align: center; color: var(--text-3); font-size: 13.5px; padding: 24px 0; }
.disclaimers { margin-top: 16px; }
.disclaimers p { margin: 3px 0; font-size: 11px; color: var(--text-3); line-height: 1.6; }

/* ============ 推荐卡片 ============ */
.rec { padding: 14px; margin-bottom: 12px; cursor: pointer; transition: transform .18s, box-shadow .18s; }
.rec:active { transform: scale(.995); }
.rec header { display: flex; gap: 10px; align-items: flex-start; }
.rec .rank {
  flex: none; width: 26px; height: 26px; border-radius: 8px;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.rec .rank.gold { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #fff; border-color: transparent; }
.rec .title { flex: 1; min-width: 0; }
.rec .title h3 { margin: 0 0 5px; font-size: 15.5px; line-height: 1.35; }
.rec .tags { display: flex; flex-wrap: wrap; gap: 5px; }
.rec .dist { flex: none; text-align: right; }
.rec .dist strong { display: block; font-size: 15px; color: var(--brand); }
.rec .dist span { font-size: 11px; color: var(--text-3); }

.rec .score { display: flex; align-items: center; gap: 9px; margin: 11px 0 9px; }
.rec .bar { flex: 1; height: 5px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.rec .bar i {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--brand), color-mix(in srgb, var(--brand) 45%, var(--info)));
  transition: width .6s cubic-bezier(.16, 1, .3, 1);
}
.rec .score-num { font-size: 12px; font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; }

.rec .hot { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 9px; }
.rec .d-name { font-size: 13.5px; font-weight: 600; }
.rec .qual { font-size: 11.5px; color: var(--text-3); }

.reasons { margin: 0; padding: 0; list-style: none; }
.reasons li { position: relative; padding-left: 14px; font-size: 13px; color: var(--text-2); line-height: 1.7; }
.reasons li::before {
  content: ''; position: absolute; left: 3px; top: 10px;
  width: 4px; height: 4px; border-radius: 50%; background: var(--brand);
}

.rec-more {
  margin-top: 10px; background: none; border: none; padding: 4px 0;
  color: var(--brand); font-size: 12.5px; cursor: pointer;
  display: flex; align-items: center; gap: 3px;
}
.rec-more svg { transition: transform .24s; }

.rec-detail { overflow: hidden; }
.factor { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.f-label { width: 52px; font-size: 11.5px; color: var(--text-2); flex: none; }
.f-bar { flex: 1; height: 4px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.f-bar i { display: block; height: 100%; background: var(--brand); border-radius: 99px; transition: width .5s; }
.f-val { width: 34px; text-align: right; font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.facts { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.geo-note { font-size: 11px; color: var(--text-3); margin: 8px 0 0; }

.expand-enter-active, .expand-leave-active { transition: all .28s cubic-bezier(.16, 1, .3, 1); }
.expand-enter-from, .expand-leave-to { opacity: 0; max-height: 0; transform: translateY(-6px); }

/* ============ 红旗弹窗 ============ */
.rf-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100;
}
.rf-dialog {
  width: 100%; max-width: 400px;
  background: var(--bg-elevated); border-radius: var(--radius-lg);
  padding: 22px 20px calc(20px + var(--safe-b)); box-shadow: var(--shadow-lg);
  animation: zoom .26s cubic-bezier(.16, 1, .3, 1);
}
@keyframes zoom { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
.rf-top { text-align: center; }
.rf-pulse {
  width: 54px; height: 54px; margin: 0 auto 10px; border-radius: 50%;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--urgent) 15%, transparent); color: var(--urgent);
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--urgent) 30%, transparent); }
  50% { box-shadow: 0 0 0 12px transparent; }
}
.rf-top h3 { margin: 0 0 4px; font-size: 18px; color: var(--urgent); }
.rf-tag { margin: 0; font-size: 12.5px; color: var(--text-2); }
.rf-advice {
  margin: 16px 0; padding: 14px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--urgent) 9%, transparent);
  border-left: 3px solid var(--urgent);
  font-size: 14px; line-height: 1.75; color: var(--text);
}
.hotlines { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hotline {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 12px 8px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--urgent);
  color: var(--urgent); text-decoration: none;
}
.h-name { font-size: 11.5px; color: var(--text-2); }
.h-tel { font-size: 19px; font-weight: 700; letter-spacing: .03em; }
.pop-enter-active, .pop-leave-active { transition: opacity .22s; }
.pop-enter-from, .pop-leave-to { opacity: 0; }

/* ============ 医院列表 ============ */
.search {
  display: flex; align-items: center; gap: 8px; padding: 11px 14px; color: var(--text-3);
}
.search input {
  flex: 1; border: none; outline: none; background: transparent; color: var(--text);
  font-family: inherit; font-size: 15px;
}
.search .clear { background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 14px; }
.filters { display: flex; gap: 7px; overflow-x: auto; padding: 10px 0 0; }
.chip-f { padding: 6px 12px; font-size: 12.5px; cursor: pointer; flex: none; }
.chip-f.on { background: var(--brand-soft); color: var(--brand-strong); border-color: var(--brand); font-weight: 600; }

.hlist { list-style: none; margin: 0; padding: 0; }
.row-item { display: flex; align-items: center; gap: 10px; padding: 12px 13px; margin-bottom: 9px; cursor: pointer; }
.row-item:active { transform: scale(.99); }
.row-main { flex: 1; min-width: 0; }
.row-main strong { font-size: 14.5px; display: block; line-height: 1.4; }
.row-main .tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 5px 0 3px; }
.row-main small { font-size: 11.5px; color: var(--text-3); }
.row-nums { flex: none; text-align: right; font-size: 13px; font-weight: 600; color: var(--text-2); }
.row-nums span { display: block; font-variant-numeric: tabular-nums; }
.row-nums em { font-style: normal; font-size: 10.5px; color: var(--text-3); font-weight: 400; margin-left: 2px; }
.list-tip { text-align: center; color: var(--text-3); font-size: 13px; padding: 14px 0; }

/* ============ 医院详情 ============ */
.back {
  display: flex; align-items: center; gap: 2px; background: none; border: none;
  color: var(--brand); font-size: 14px; cursor: pointer; padding: 4px 0 8px;
}
.detail-hero { padding: 15px; }
.detail-hero h2 { margin: 0 0 8px; font-size: 18px; line-height: 1.35; }
.detail-hero .tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.detail-hero .meta { margin: 0; }
.detail-hero .meta dd a { color: var(--brand); text-decoration: none; }

.note-card { padding: 12px 14px; margin-top: 10px; }
.note-card .lbl { font-size: 11px; color: var(--text-3); }
.note-card p { margin: 4px 0 0; font-size: 13px; color: var(--text-2); }

.spec { padding: 11px 14px; border-bottom: 1px solid var(--border); }
.spec:last-child { border-bottom: none; }
.spec .s-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.spec .s-title strong { font-size: 14.5px; }
.spec .s-body { display: flex; justify-content: space-between; gap: 8px; margin-top: 3px; font-size: 12px; color: var(--text-3); }
.spec .s-body a { color: var(--info); text-decoration: none; }
.pad { padding: 14px; }
.muted { color: var(--text-3); font-size: 13px; }
.dept-card { padding: 13px; margin-top: 8px; display: flex; flex-wrap: wrap; gap: 7px; }
.chip-dept { padding: 5px 10px; font-size: 12.5px; }
.chip-dept em { font-style: normal; color: var(--text-3); margin-left: 4px; font-size: 11px; }
.foot { margin-top: 16px; font-size: 11px; color: var(--text-3); }

/* ============ 关于页 ============ */
.about-hero { padding: 15px; }
.about-hero h2 { margin: 0 0 10px; font-size: 16px; }
.steps { margin: 0; padding-left: 18px; }
.steps li { font-size: 13.5px; color: var(--text-2); line-height: 1.75; margin-bottom: 6px; }
.steps b { color: var(--text); }

.stat-card { padding: 14px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 4px; padding: 6px 0; }
.grid div { text-align: center; }
.grid b { display: block; font-size: 20px; color: var(--brand); font-variant-numeric: tabular-nums; }
.grid span { font-size: 11px; color: var(--text-3); }
.stat-card .meta { margin: 0; }

.limits, .plain { margin: 0; padding: 14px 14px 14px 30px; }
.limits li { font-size: 12.5px; color: var(--text-2); line-height: 1.7; margin-bottom: 7px; }
.limits b { color: var(--warn); font-weight: 600; }
.plain li { font-size: 12.5px; color: var(--text-2); line-height: 1.8; }
.disclaim { margin-top: 18px; font-size: 11.5px; color: var(--text-3); line-height: 1.7; }

.notfound { text-align: center; padding: 60px 20px; color: var(--text-3); }
