/* ============================================================
   无忧短信台 · iOS 玻璃拟态移动端设计系统
   移动端优先 · 毛玻璃 · 大圆角 · 柔和配色
   ============================================================ */

:root {
  --bg: #f2f2f7;                    /* iOS 系统灰 */
  --bg-grad-top: #e8f0ff;
  --bg-grad-mid: #f4f6fb;
  --card: rgba(255, 255, 255, 0.72);
  --card-solid: #ffffff;
  --ink: #1c1c1e;                   /* 主文字 */
  --ink-2: #6b6b70;                 /* 次级文字 */
  --ink-3: #a2a2a8;                 /* 弱文字 */
  --accent: #0a84ff;                /* iOS 蓝 */
  --accent-soft: rgba(10, 132, 255, 0.12);
  --green: #30d158;                 /* 托管开/成功 */
  --green-soft: rgba(48, 209, 88, 0.14);
  --red: #ff3b30;                   /* 危险 */
  --red-soft: rgba(255, 59, 48, 0.12);
  --orange: #ff9500;
  --orange-soft: rgba(255, 149, 0, 0.14);
  --purple: #bf5af2;
  --hairline: rgba(60, 60, 67, 0.10);
  --hairline-strong: rgba(60, 60, 67, 0.18);
  --shadow: 0 8px 28px rgba(20, 40, 80, 0.10), 0 1px 3px rgba(20, 40, 80, 0.06);
  --shadow-sm: 0 2px 8px rgba(20, 40, 80, 0.07);
  --radius: 22px;
  --radius-lg: 28px;
  --radius-sm: 14px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
          "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
}

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

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100%;
}

body {
  background:
    radial-gradient(120% 60% at 0% 0%, var(--bg-grad-top) 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-grad-mid) 0%, var(--bg) 40%);
  background-attachment: fixed;
}

/* 全局模糊背景光斑（玻璃拟态氛围） */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(30% 20% at 90% 5%, rgba(10,132,255,.10) 0%, transparent 70%),
    radial-gradient(25% 18% at 5% 40%, rgba(191,90,242,.08) 0%, transparent 70%);
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; }
a { color: var(--accent); text-decoration: none; }

/* ------------------------------- 通用控件 ------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 18px;
  border-radius: 16px;
  font-size: 15px;
  font-weight: 600;
  background: var(--card);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border: 1px solid var(--hairline);
  color: var(--ink);
  transition: transform .12s ease, background .2s ease, opacity .2s;
  user-select: none;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 16px rgba(10,132,255,.28);
}
.btn-primary:active { box-shadow: 0 3px 8px rgba(10,132,255,.22); }

.btn-ghost { background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; border-color: transparent; color: var(--accent); }
.btn-danger { background: var(--red-soft); color: var(--red); border-color: transparent; }

.btn-sm { padding: 8px 13px; font-size: 13.5px; border-radius: 12px; }
.btn-block { width: 100%; }

/* 字段输入 */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
  padding-left: 4px;
}
.input {
  width: 100%;
  padding: 13px 16px;
  font-size: 16px;
  border-radius: 15px;
  border: 1px solid var(--hairline-strong);
  background: rgba(255,255,255,.85);
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--ink-3); }

/* ------------------------------- 卡片 ------------------------------- */

.card {
  background: var(--card);
  backdrop-filter: blur(24px) saturate(1.7);
  -webkit-backdrop-filter: blur(24px) saturate(1.7);
  border: 1px solid rgba(255,255,255,.6);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* iOS 分组列表样式 */
.group {
  background: var(--card);
  backdrop-filter: blur(24px) saturate(1.7);
  -webkit-backdrop-filter: blur(24px) saturate(1.7);
  border: 1px solid rgba(255,255,255,.6);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.group .row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--hairline);
}
.group .row:last-child { border-bottom: none; }

/* ------------------------------- 登录页 ------------------------------- */

.auth-screen {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: calc(40px + var(--safe-t)) 22px calc(40px + var(--safe-b));
}

.auth-brand {
  text-align: center;
  margin-bottom: 34px;
}
.brand-mark {
  width: 84px;
  height: 84px;
  margin: 0 auto 18px;
  border-radius: 24px;
  background: linear-gradient(135deg, #0a84ff, #5ac8fa);
  box-shadow: 0 12px 28px rgba(10,132,255,.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  font-weight: 700;
  color: #fff;
}
.brand-mark i { font-style: normal; letter-spacing: -2px; }
.auth-brand h1 { font-size: 26px; margin: 0 0 8px; font-weight: 700; letter-spacing: -.4px; }
.auth-brand p { margin: 0; color: var(--ink-2); font-size: 15px; }

.auth-card {
  max-width: 400px;
  margin: 0 auto;
  width: 100%;
  padding: 26px 22px 22px;
}
.auth-card h2 { margin: 0 0 4px; font-size: 20px; font-weight: 700; }
.auth-card .sub { margin: 0 0 20px; color: var(--ink-2); font-size: 14px; }
.auth-alert {
  display: none;
  background: var(--red-soft);
  color: var(--red);
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 14px;
  margin-bottom: 14px;
}
.auth-alert.on { display: block; }
.auth-foot {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--ink-3);
}

/* ------------------------------- 主界面 ------------------------------- */

.app-screen {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: calc(12px + var(--safe-t)) 18px 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  background: rgba(242,242,247,.7);
}
.topbar .title { font-size: 24px; font-weight: 800; letter-spacing: -.5px; margin: 0; flex: 1; }
.topbar .avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5ac8fa, #0a84ff);
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex: 0 0 auto;
  border: none;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* 头像下拉菜单 */
.avatar-menu-wrap { position: relative; }
.avatar-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 140px;
  background: var(--card);
  backdrop-filter: blur(24px) saturate(1.7);
  -webkit-backdrop-filter: blur(24px) saturate(1.7);
  border: 1px solid rgba(255,255,255,.6);
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,.16);
  padding: 6px;
  z-index: 30;
}
.avatar-menu-item {
  display: block;
  width: 100%;
  padding: 12px 14px;
  background: transparent;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  text-align: left;
  color: var(--red);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.avatar-menu-item:active { background: rgba(0,0,0,.06); }

.page { padding: 6px 18px 16px; }
.page-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 2px 14px;
}
.page-head h2 { margin: 0; font-size: 20px; font-weight: 700; flex: 1; }

/* 实时状态胶囊 */
.live-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--green);
  background: var(--green-soft);
  padding: 5px 11px;
  border-radius: 999px;
}
.live-chip i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  animation: pulse 1.6s ease infinite;
}
.live-chip.off { color: var(--orange); background: var(--orange-soft); }
.live-chip.off i { background: var(--orange); animation: none; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.35} }

/* ------------------------------- 账号卡片 ------------------------------- */

.acc-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  margin-bottom: 12px;
  border-radius: var(--radius);
}
.acc-card:active { transform: scale(.985); }
.acc-card .avatar {
  width: 50px; height: 50px; flex: 0 0 auto;
  border-radius: 16px;
  background: linear-gradient(135deg, #a78bfa, #7c6cf0);
  color: #fff; font-weight: 700; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
}
.acc-card .info { flex: 1; min-width: 0; }
.acc-card .name {
  font-size: 14.5px; font-weight: 700;
  display: flex; align-items: center; gap: 6px;
  flex-wrap: nowrap;
}
.acc-card .name .phone-txt {
  flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  letter-spacing: .3px;
}
.acc-card .meta {
  font-size: 11.5px; color: var(--ink-3); margin-top: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 未读角标 */
.badge-num {
  min-width: 22px; height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--red);
  color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}

/* 托管开关 */
.switch {
  position: relative;
  width: 52px; height: 32px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(120,120,128,.28);
  transition: background .25s;
}
.switch.on { background: var(--green); }
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,.25);
  transition: transform .25s cubic-bezier(.4,1.6,.6,1);
}
.switch.on::after { transform: translateX(20px); }
.switch.busy { opacity: .5; pointer-events: none; }

/* ------------------------------- 短信列表 ------------------------------- */

.search-box {
  position: relative;
  margin-bottom: 14px;
}
.search-box .input { padding-left: 40px; background: var(--card); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.search-box .icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--ink-3); font-size: 16px;
}

.msg-list { display: flex; flex-direction: column; gap: 10px; }

.msg-card {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  animation: slideIn .3s ease both;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.msg-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.msg-from { font-weight: 700; font-size: 15px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-time { font-size: 12px; color: var(--ink-3); flex: 0 0 auto; }

.tag {
  font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 8px;
  flex: 0 0 auto;
}
.tag.code { background: var(--accent-soft); color: var(--accent); }
.tag.bill { background: var(--orange-soft); color: var(--orange); }
.tag.order { background: rgba(191,90,242,.12); color: var(--purple); }
.tag.text { background: rgba(120,120,128,.12); color: var(--ink-2); }

.msg-body {
  font-size: 14px; line-height: 1.5; color: var(--ink-2); word-break: break-word;
  user-select: none;
  -webkit-user-select: none;
}

.code-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 2px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: opacity .15s;
}
.code-chip:active { opacity: .6; }
.code-chip .copy-hint { font-size: 11px; font-weight: 600; letter-spacing: 0; opacity: .7; }

.msg-card.unread { background: rgba(10,132,255,.06); border-color: rgba(10,132,255,.18); }

.empty {
  text-align: center;
  padding: 50px 20px;
  color: var(--ink-3);
}
.empty .big { font-size: 48px; margin-bottom: 10px; }
.empty h3 { margin: 0 0 6px; color: var(--ink-2); font-size: 17px; }
.empty p { margin: 0; font-size: 13px; }

/* ------------------------------- 底部 Tab ------------------------------- */

.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 20;
  max-width: 560px;
  margin: 0 auto;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex;
  align-items: stretch;
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(24px) saturate(1.8);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
  border-top: 1px solid var(--hairline);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 600;
  transition: color .2s;
  position: relative;
}
.tab .ico { font-size: 22px; line-height: 1; }
.tab.on { color: var(--accent); }
.tab .dot {
  position: absolute;
  top: 8px; right: 50%;
  margin-right: -24px;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  background: var(--red);
  color: #fff; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

/* ------------------------------- 弹层 / 抽屉 ------------------------------- */

.modal-mask {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .25s;
}
.modal-mask.on { opacity: 1; pointer-events: auto; }
.modal-sheet {
  width: 100%;
  max-width: 560px;
  background: var(--card-solid);
  border-radius: 26px 26px 0 0;
  padding: 20px 20px calc(24px + var(--safe-b));
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.3,1,.4,1);
}
.modal-mask.on .modal-sheet { transform: translateY(0); }
.modal-sheet .grabber {
  width: 38px; height: 5px; border-radius: 3px;
  background: rgba(60,60,67,.22);
  margin: 0 auto 16px;
}
.modal-sheet h3 { margin: 0 0 4px; font-size: 18px; font-weight: 700; }
.modal-sheet .sub { margin: 0 0 18px; color: var(--ink-2); font-size: 13.5px; }

/* ------------------------------- Toast ------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 18px);
  transform: translateX(-50%) translateY(20px);
  z-index: 60;
  background: rgba(30,30,34,.92);
  color: #fff;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .25s;
  max-width: 88vw;
  text-align: center;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ------------------------------- 状态行（kv） ------------------------------- */

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 2px; font-size: 14px; border-bottom: 1px solid var(--hairline); }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--ink-2); flex: 0 0 auto; }
.kv .v { color: var(--ink); text-align: right; word-break: break-all; }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}
.status-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.status-pill.ok { color: var(--green); background: var(--green-soft); }
.status-pill.ok i { background: var(--green); }
.status-pill.warn { color: var(--orange); background: var(--orange-soft); }
.status-pill.warn i { background: var(--orange); }
.status-pill.err { color: var(--red); background: var(--red-soft); }
.status-pill.err i { background: var(--red); }

/* 隐藏页 */
.hidden { display: none !important; }

/* 大屏适配：居中 + 顶部留白 */
@media (min-width: 640px) {
  .app-screen { padding-top: 20px; }
  .tabbar { border-radius: 22px 22px 0 0; }
}

/* ------------------------- 设置页折叠卡片 ------------------------- */
.fold-card {
  overflow: hidden;
}
.fold-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  font: inherit;
  color: inherit;
}
.fold-head:active { background: rgba(0,0,0,.04); }
.fold-title {
  font-size: 16px;
  font-weight: 600;
}
.fold-arrow {
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--ink-3);
  border-bottom: 2px solid var(--ink-3);
  transform: rotate(45deg);
  transition: transform .25s ease;
  flex: 0 0 auto;
}
.fold-card.folded .fold-arrow { transform: rotate(-45deg); }
.fold-body {
  padding: 0 16px 16px;
}
.fold-card.folded .fold-body { display: none; }

/* ------------------------- 号码筛选下拉框 ------------------------- */
.filter-select-wrap { position: relative; }
.filter-select {
  width: 100%;
  padding: 13px 32px 13px 12px;
  font-size: 15px;
  border-radius: 15px;
  border: 1px solid var(--hairline-strong);
  background: rgba(255,255,255,.85);
  color: var(--ink);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.filter-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
/* 自定义下拉箭头 */
.filter-select-wrap::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--ink-3);
  border-bottom: 2px solid var(--ink-3);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
