/* ============================================================
   SimKeeper · 单色毛玻璃设计系统
   ------------------------------------------------------------
   配色原则：
     1. 只用 白 / 黑 / 灰。交互状态（选中、输入、按下、完成）
        一律靠「明度对比」表达，不引入色相。
     2. 颜色只留给「风险等级」——需要你动手的地方才有颜色。
        红 = 紧急，琥珀 = 临近，良好 = 中性灰（不抢注意力）。
     3. 深浅两套主题跟随系统，可用顶栏按钮手动覆盖。

   毛玻璃成立的前提是背景有层次。单色方案下用「柔和白光晕」
   替代原来的彩色渐变，这样 backdrop-filter 才有东西可模糊。
   ============================================================ */

:root {
  /* ---- 圆角（整体圆角风格） ---- */
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --radius-pill: 999px;

  --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'PingFang SC',
    'Microsoft YaHei', 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --glass-blur: blur(20px);
  --glass-blur-lg: blur(30px);
}

/* ============================================================
   深色主题（默认）
   ============================================================ */
:root,
[data-theme='dark'] {
  color-scheme: dark;

  /* 画布 + 光晕层（玻璃的「背景内容」） */
  --bg-base: #0a0a0b;
  --bg-tint:
    radial-gradient(40% 36% at 16% 10%, rgba(255, 255, 255, 0.085), transparent 68%),
    radial-gradient(36% 32% at 86% 18%, rgba(255, 255, 255, 0.06), transparent 70%),
    radial-gradient(44% 40% at 74% 86%, rgba(255, 255, 255, 0.05), transparent 72%),
    radial-gradient(38% 36% at 22% 90%, rgba(255, 255, 255, 0.04), transparent 72%);

  /* 玻璃材质 */
  --glass-bg: rgba(255, 255, 255, 0.055);
  --glass-bg-hover: rgba(255, 255, 255, 0.085);
  --glass-bg-strong: rgba(255, 255, 255, 0.11);
  --glass-border: 1px solid rgba(255, 255, 255, 0.095);
  --glass-border-soft: 1px solid rgba(255, 255, 255, 0.065);
  --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.065);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.44);
  --glass-shadow-lg: 0 18px 52px rgba(0, 0, 0, 0.55);

  /* 中性填充阶（表单、칩、行背景统一走这几档） */
  --fill-1: rgba(255, 255, 255, 0.035);
  --fill-2: rgba(255, 255, 255, 0.055);
  --fill-3: rgba(255, 255, 255, 0.085);
  --fill-4: rgba(255, 255, 255, 0.125);
  --line-1: rgba(255, 255, 255, 0.075);
  --line-2: rgba(255, 255, 255, 0.13);
  --line-3: rgba(255, 255, 255, 0.22);

  /* 文字 */
  --text: #f5f5f7;
  --text-muted: rgba(255, 255, 255, 0.66);
  --text-subtle: rgba(255, 255, 255, 0.44);
  --text-faint: rgba(255, 255, 255, 0.28);

  /* 反色（主按钮 / 选中态 / FAB） */
  --inverse-bg: #f5f5f7;
  --inverse-text: #0a0a0b;

  /* 状态色：只有风险等级有色相 */
  --c-danger: #ff453a;
  --c-danger-bg: rgba(255, 69, 58, 0.14);
  --c-danger-line: rgba(255, 69, 58, 0.34);
  --c-warn: #ff9f0a;
  --c-warn-bg: rgba(255, 159, 10, 0.14);
  --c-warn-line: rgba(255, 159, 10, 0.3);
  --c-safe: rgba(255, 255, 255, 0.62);
  --c-safe-bg: rgba(255, 255, 255, 0.07);
  --c-safe-line: rgba(255, 255, 255, 0.15);

  /* 强调 = 文字色本身，保持单色 */
  --c-accent: var(--text);
  --c-accent-bg: var(--fill-3);

  --focus-ring: 0 0 0 3px rgba(255, 255, 255, 0.16);
  --chevron: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='rgba(255,255,255,0.55)' d='M1 1l5 5 5-5'/></svg>");
}

/* ============================================================
   浅色主题
   ============================================================ */
[data-theme='light'] {
  color-scheme: light;

  --bg-base: #eeeef0;
  --bg-tint:
    radial-gradient(40% 36% at 16% 10%, #ffffff, transparent 68%),
    radial-gradient(36% 32% at 86% 18%, rgba(255, 255, 255, 0.92), transparent 70%),
    radial-gradient(44% 40% at 74% 86%, rgba(255, 255, 255, 0.82), transparent 72%),
    radial-gradient(38% 36% at 22% 90%, rgba(255, 255, 255, 0.75), transparent 72%);

  --glass-bg: rgba(255, 255, 255, 0.62);
  --glass-bg-hover: rgba(255, 255, 255, 0.8);
  --glass-bg-strong: rgba(255, 255, 255, 0.88);
  --glass-border: 1px solid rgba(255, 255, 255, 0.9);
  --glass-border-soft: 1px solid rgba(0, 0, 0, 0.055);
  --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --glass-shadow: 0 8px 30px rgba(0, 0, 0, 0.062);
  --glass-shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.11);

  --fill-1: rgba(0, 0, 0, 0.028);
  --fill-2: rgba(0, 0, 0, 0.045);
  --fill-3: rgba(0, 0, 0, 0.065);
  --fill-4: rgba(0, 0, 0, 0.095);
  --line-1: rgba(0, 0, 0, 0.06);
  --line-2: rgba(0, 0, 0, 0.1);
  --line-3: rgba(0, 0, 0, 0.18);

  --text: #1d1d1f;
  --text-muted: rgba(0, 0, 0, 0.58);
  --text-subtle: rgba(0, 0, 0, 0.42);
  --text-faint: rgba(0, 0, 0, 0.26);

  --inverse-bg: #1d1d1f;
  --inverse-text: #ffffff;

  --c-danger: #d70015;
  --c-danger-bg: rgba(215, 0, 21, 0.09);
  --c-danger-line: rgba(215, 0, 21, 0.26);
  --c-warn: #9a4c00;
  --c-warn-bg: rgba(200, 120, 0, 0.11);
  --c-warn-line: rgba(200, 120, 0, 0.26);
  --c-safe: rgba(0, 0, 0, 0.5);
  --c-safe-bg: rgba(0, 0, 0, 0.045);
  --c-safe-line: rgba(0, 0, 0, 0.09);

  --c-accent: var(--text);
  --c-accent-bg: var(--fill-3);

  --focus-ring: 0 0 0 3px rgba(0, 0, 0, 0.1);
  --chevron: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='rgba(0,0,0,0.5)' d='M1 1l5 5 5-5'/></svg>");
}

/* 系统偏好为浅色时，在用户没手动指定深色之前跟随 */
@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) {
    color-scheme: light;
    --bg-base: #eeeef0;
    --bg-tint:
      radial-gradient(40% 36% at 16% 10%, #ffffff, transparent 68%),
      radial-gradient(36% 32% at 86% 18%, rgba(255, 255, 255, 0.92), transparent 70%),
      radial-gradient(44% 40% at 74% 86%, rgba(255, 255, 255, 0.82), transparent 72%),
      radial-gradient(38% 36% at 22% 90%, rgba(255, 255, 255, 0.75), transparent 72%);
    --glass-bg: rgba(255, 255, 255, 0.62);
    --glass-bg-hover: rgba(255, 255, 255, 0.8);
    --glass-bg-strong: rgba(255, 255, 255, 0.88);
    --glass-border: 1px solid rgba(255, 255, 255, 0.9);
    --glass-border-soft: 1px solid rgba(0, 0, 0, 0.055);
    --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.9);
    --glass-shadow: 0 8px 30px rgba(0, 0, 0, 0.062);
    --glass-shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.11);
    --fill-1: rgba(0, 0, 0, 0.028);
    --fill-2: rgba(0, 0, 0, 0.045);
    --fill-3: rgba(0, 0, 0, 0.065);
    --fill-4: rgba(0, 0, 0, 0.095);
    --line-1: rgba(0, 0, 0, 0.06);
    --line-2: rgba(0, 0, 0, 0.1);
    --line-3: rgba(0, 0, 0, 0.18);
    --text: #1d1d1f;
    --text-muted: rgba(0, 0, 0, 0.58);
    --text-subtle: rgba(0, 0, 0, 0.42);
    --text-faint: rgba(0, 0, 0, 0.26);
    --inverse-bg: #1d1d1f;
    --inverse-text: #ffffff;
    --c-danger: #d70015;
    --c-danger-bg: rgba(215, 0, 21, 0.09);
    --c-danger-line: rgba(215, 0, 21, 0.26);
    --c-warn: #9a4c00;
    --c-warn-bg: rgba(200, 120, 0, 0.11);
    --c-warn-line: rgba(200, 120, 0, 0.26);
    --c-safe: rgba(0, 0, 0, 0.5);
    --c-safe-bg: rgba(0, 0, 0, 0.045);
    --c-safe-line: rgba(0, 0, 0, 0.09);
    --focus-ring: 0 0 0 3px rgba(0, 0, 0, 0.1);
    --chevron: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='rgba(0,0,0,0.5)' d='M1 1l5 5 5-5'/></svg>");
  }
}

/* ============================================================
   基础
   ============================================================ */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background-color: var(--bg-base);
  background-image: var(--bg-tint);
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color 0.4s var(--ease), color 0.4s var(--ease);
}

/* 缓慢漂移的光晕，让静态的灰底有呼吸感 */
body::before {
  content: '';
  position: fixed;
  inset: -20%;
  z-index: -2;
  background: var(--bg-tint);
  animation: drift 34s var(--ease) infinite alternate;
  pointer-events: none;
  opacity: 0.75;
}

@keyframes drift {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  50%  { transform: translate3d(1.6%, -1.6%, 0) scale(1.05); }
  100% { transform: translate3d(-1.6%, 1.6%, 0) scale(1.02); }
}

@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ============================================================
   玻璃基类
   ============================================================ */
.glass {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
  box-shadow: var(--glass-shadow), var(--glass-highlight);
  border-radius: var(--radius-lg);
}

/* ============================================================
   布局骨架
   ============================================================ */
.app {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 16px 96px;
}

/* ---- 顶部标题栏 ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-radius: var(--radius-pill);
  margin-bottom: 18px;
  position: sticky;
  top: 10px;
  z-index: 40;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 30px; height: 30px;
  border-radius: 10px;
  background: var(--inverse-bg);
  color: var(--inverse-text);
  display: grid; place-items: center;
  font-size: 15px;
  flex-shrink: 0;
}

.topbar-actions { display: flex; align-items: center; gap: 7px; }

/* 主题切换按钮：图标随主题互换 */
.theme-toggle {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--fill-3);
  border: var(--glass-border-soft);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  display: grid; place-items: center;
  font-family: inherit;
  flex-shrink: 0;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.theme-toggle:hover { background: var(--fill-4); color: var(--text); }
.theme-toggle .ico-light { display: none; }
[data-theme='light'] .theme-toggle .ico-light { display: block; }
[data-theme='light'] .theme-toggle .ico-dark { display: none; }

/* ---- 概览统计 ---- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.stat {
  padding: 14px 12px;
  border-radius: var(--radius-md);
  text-align: center;
}

.stat .num {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.stat .lbl {
  font-size: 11px;
  color: var(--text-subtle);
  letter-spacing: 0.06em;
  margin-top: 2px;
}
.stat.danger .num { color: var(--c-danger); }
.stat.warn .num   { color: var(--c-warn); }
.stat.safe .num   { color: var(--c-safe); }
.stat.total .num  { color: var(--text); }

/* ---- Tab 切换（选中 = 反色胶囊，纯明度对比） ---- */
.tabs {
  display: flex;
  gap: 4px;
  padding: 5px;
  border-radius: var(--radius-pill);
  margin-bottom: 18px;
}

.tab {
  flex: 1;
  padding: 9px 8px;
  border-radius: var(--radius-pill);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
  white-space: nowrap;
}
.tab:hover { color: var(--text); background: var(--fill-1); }
.tab.active {
  background: var(--inverse-bg);
  color: var(--inverse-text);
  font-weight: 600;
}

/* ============================================================
   SIM 卡卡片网格
   ============================================================ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 14px;
}

.sim-card {
  padding: 16px 16px 12px;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.3s var(--ease), background 0.3s var(--ease);
  position: relative;
  overflow: hidden;
}
.sim-card:hover {
  transform: translateY(-3px);
  background: var(--glass-bg-hover);
}

/* 左侧一道窄条：良好=中性，临近/紧急才上色 */
.sim-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--c-safe-line);
}
.sim-card[data-status='danger']::before { background: var(--c-danger); opacity: 1; }
.sim-card[data-status='warn']::before   { background: var(--c-warn); }

.card-head {
  display: flex;
  align-items: center;
  gap: 11px;
}

/* 运营商标记：单色玻璃砖，靠短代号区分 */
.op-logo {
  width: 40px; height: 40px;
  border-radius: 13px;
  display: grid; place-items: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  background: var(--fill-3);
  color: var(--text-muted);
  border: var(--glass-border-soft);
  box-shadow: var(--glass-highlight);
}

.op-name { font-weight: 650; font-size: 15px; line-height: 1.3; }
.op-meta {
  font-size: 11.5px;
  color: var(--text-subtle);
  display: flex; align-items: center; gap: 5px;
}

/* 卡片标题列：允许收缩，否则长卡名会把天数徽章挤出去 */
.card-title { min-width: 0; flex: 1; }

/* 整张卡片可点即编辑 —— 给一点可点的反馈，但别抢状态色的戏 */
.sim-card[role='button'] { cursor: pointer; }
.sim-card[role='button']:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* 「演示」徽标：不是为了好看，是为了用户一眼看出这不是自己的数据 */
.demo-badge {
  display: inline-block;
  margin-left: 7px;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.02em;
  vertical-align: 1.5px;
  background: var(--fill-3);
  border: var(--glass-border-soft);
  color: var(--text-muted);
}

/* 截止日来源：'推算' = app 算的估计值；'已核实' = 用户查过运营商后手填的 */
.src-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  vertical-align: 1px;
  white-space: nowrap;
  background: var(--fill-2);
  border: 1px solid var(--line-2);
  color: var(--text-subtle);
}
.src-tag.manual {
  background: transparent;
  border-color: var(--line-3);
  color: var(--text-muted);
}
.src-tag.auto::before { content: '≈ '; }

/* 剩余天数徽章 */
.days-badge {
  margin-left: auto;
  flex-shrink: 0;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  border: 1px solid transparent;
}
.days-badge.safe    { background: var(--c-safe-bg);   color: var(--c-safe);   border-color: var(--c-safe-line); }
.days-badge.warn    { background: var(--c-warn-bg);   color: var(--c-warn);   border-color: var(--c-warn-line); }
.days-badge.danger  { background: var(--c-danger-bg); color: var(--c-danger); border-color: var(--c-danger-line); }
.days-badge.overdue { background: var(--c-danger-bg); color: var(--c-danger); border-color: var(--c-danger); }

/* 卡号 */
.number {
  font-family: var(--font-mono);
  font-size: 13.5px;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  word-break: break-all;
}

/* 进度条：显示当前保号周期已消耗比例 */
.progress {
  height: 5px;
  border-radius: var(--radius-pill);
  background: var(--fill-3);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--c-safe);
  transition: width 0.6s var(--ease);
}
.progress-bar.warn   { background: var(--c-warn); }
.progress-bar.danger { background: var(--c-danger); }

/* 关键信息行 */
.kv-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12.5px;
}
.kv-row .k { color: var(--text-subtle); flex-shrink: 0; }
.kv-row .v { color: var(--text); font-weight: 550; margin-left: auto; text-align: right; }
.kv-row .v.dim { color: var(--text-muted); font-weight: 400; }

/* 卡片底部操作 */
.card-foot {
  display: flex;
  gap: 7px;
  align-items: center;
  padding-top: 10px;
  border-top: var(--glass-border-soft);
  /* 网格里各卡片高度被拉齐，但内容长短不一 —— 让按钮组始终贴到卡片底部，
     否则同一行卡片的按钮会高低错落（截图里很明显）。 */
  margin-top: auto;
}
.card-foot .spacer { flex: 1; }

/* ============================================================
   按钮
   ============================================================ */
.btn {
  padding: 7px 13px;
  border-radius: var(--radius-pill);
  background: var(--fill-3);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: var(--glass-border-soft);
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.22s var(--ease), transform 0.18s var(--ease);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}
.btn:hover { background: var(--fill-4); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* 主按钮 = 反色实底，深色主题下白底黑字，对比度最高 */
.btn.primary {
  background: var(--inverse-bg);
  color: var(--inverse-text);
  border-color: transparent;
  font-weight: 650;
}
.btn.primary:hover { background: var(--inverse-bg); opacity: 0.88; }

.btn.ghost { background: transparent; border-color: var(--line-2); }
.btn.ghost:hover { background: var(--fill-2); }
.btn.danger { color: var(--c-danger); border-color: var(--c-danger-line); }
.btn.danger:hover { background: var(--c-danger-bg); }
.btn.sm { padding: 5px 10px; font-size: 11.5px; }

/* 悬浮添加按钮 */
.fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--inverse-bg);
  color: var(--inverse-text);
  border: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  font-size: 27px;
  font-weight: 300;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.25s var(--ease), opacity 0.2s var(--ease);
  padding-bottom: 3px;
}
.fab:hover { transform: scale(1.07) rotate(90deg); opacity: 0.9; }

/* ============================================================
   表单（弹窗内）
   ============================================================ */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.03em;
}
.field .hint { font-size: 11px; color: var(--text-faint); margin-top: 5px; line-height: 1.5; }

.input, .select, .textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  background: var(--fill-2);
  border: 1px solid var(--line-2);
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.22s var(--ease), background 0.22s var(--ease), box-shadow 0.22s var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
/* 「输入中」状态：靠边框提亮 + 光环，不用色相 */
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--line-3);
  background: var(--fill-3);
  box-shadow: var(--focus-ring);
}
.textarea { resize: vertical; min-height: 62px; }

.select {
  appearance: none;
  background-image: var(--chevron);
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
  cursor: pointer;
}
.select option { background: var(--bg-base); color: var(--text); }

/* 快捷按钮 */
.quick {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.chip {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--fill-2);
  border: var(--glass-border-soft);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.chip:hover { background: var(--fill-4); color: var(--text); }
.chip:active { transform: scale(0.97); }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ============================================================
   弹窗
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  animation: fadeIn 0.22s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%;
  max-width: 520px;
  max-height: 86vh;
  overflow-y: auto;
  padding: 22px;
  border-radius: var(--radius-xl);
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-blur-lg);
  -webkit-backdrop-filter: var(--glass-blur-lg);
  border: var(--glass-border);
  box-shadow: var(--glass-shadow-lg);
  animation: riseIn 0.28s var(--ease);
}
@keyframes riseIn {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.modal.wide { max-width: 640px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.modal-head h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }

.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--fill-3);
  border: var(--glass-border-soft);
  color: var(--text-muted);
  font-size: 17px;
  cursor: pointer;
  display: grid; place-items: center;
  font-family: inherit;
  flex-shrink: 0;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.modal-close:hover { background: var(--fill-4); color: var(--text); }

.modal-foot {
  display: flex;
  gap: 9px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: var(--glass-border-soft);
  flex-wrap: wrap;
}

/* ============================================================
   运营商手册（重点视图）
   ============================================================ */
.manual-hero {
  padding: 20px;
  border-radius: var(--radius-lg);
  margin-bottom: 14px;
  background: var(--glass-bg-strong);
  border: var(--glass-border);
  box-shadow: var(--glass-shadow), var(--glass-highlight);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}
.manual-hero h3 { margin: 0 0 4px; font-size: 20px; font-weight: 700; }
.manual-hero .summary {
  font-size: 14px;
  color: var(--text);
  margin: 10px 0 12px;
  line-height: 1.65;
  font-weight: 500;
}

.tag-row { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  background: var(--fill-3);
  border: var(--glass-border-soft);
  font-size: 11.5px;
  color: var(--text-muted);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tag.hl { background: var(--fill-4); color: var(--text); font-weight: 600; }

.sec-title {
  font-size: 11.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-subtle);
  margin: 18px 0 9px;
  font-weight: 600;
}

/* ---- 立即操作：直达充值 / 订购 / 查询 ---- */
.action-row { display: flex; flex-direction: column; gap: 8px; }

.action-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 15px;
  border-radius: var(--radius-md);
  background: var(--fill-2);
  border: var(--glass-border-soft);
  color: var(--text);
  text-decoration: none;
  font-size: 13.5px;
  transition: background 0.2s var(--ease), transform 0.18s var(--ease);
}
.action-btn:hover { background: var(--fill-4); transform: translateX(2px); }
.action-btn:active { transform: translateX(2px) scale(0.99); }
.action-btn .ico { font-size: 17px; flex-shrink: 0; line-height: 1; }
.action-btn .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.action-btn .t { font-weight: 600; }
.action-btn .d {
  font-size: 11.5px;
  color: var(--text-subtle);
  line-height: 1.45;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.action-btn .arrow { color: var(--text-faint); font-size: 13px; flex-shrink: 0; }

/* 主操作走反色实底 */
.action-btn.primary {
  background: var(--inverse-bg);
  color: var(--inverse-text);
  border-color: transparent;
}
.action-btn.primary .d { color: var(--inverse-text); opacity: 0.62; }
.action-btn.primary .arrow { color: var(--inverse-text); opacity: 0.5; }
.action-btn.primary:hover { background: var(--inverse-bg); opacity: 0.9; }

/* 查询类操作偏弱化 */
.action-btn.quiet { background: transparent; border-style: dashed; }

.action-note {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--text-faint);
  line-height: 1.6;
}

/* ---- 怎样才算「用了」 ---- */
.counts { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.counts-col {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--fill-2);
  border: var(--glass-border-soft);
}
.counts-col.yes { background: var(--fill-3); }
.counts-h {
  font-size: 12px;
  font-weight: 650;
  margin-bottom: 7px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.counts-col.no .counts-h { color: var(--text-subtle); }
.counts-col ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.counts-col li {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-muted);
  padding-left: 13px;
  position: relative;
}
.counts-col li::before {
  content: '';
  position: absolute;
  left: 2px; top: 8px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--text-faint);
}
.counts-col.no li { color: var(--text-faint); }
.counts-note {
  margin-top: 8px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  background: var(--fill-1);
  border: var(--glass-border-soft);
  font-size: 12px;
  color: var(--text-subtle);
  line-height: 1.65;
}
.counts-note b { color: var(--text-muted); font-weight: 600; }
.counts-note code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: var(--fill-3);
  padding: 1px 5px;
  border-radius: 5px;
  color: var(--text-muted);
}

/* 规则表 */
.rule-list { display: flex; flex-direction: column; gap: 1px; overflow: hidden; border-radius: var(--radius-md); }
.rule-item {
  display: flex;
  gap: 12px;
  padding: 11px 14px;
  background: var(--fill-1);
  font-size: 13.5px;
  align-items: baseline;
}
.rule-item .k { color: var(--text-muted); flex-shrink: 0; min-width: 96px; }
.rule-item .v { color: var(--text); font-weight: 550; margin-left: auto; text-align: right; }
/* 长值（官方条款原文等）：改成上下两行、左对齐，避免右对齐产生的大片空白与参差。
   此时标签升格为「小块标题」，正文回落为常规字重，长英文句子才读得下去。 */
.rule-item.wide { display: block; }
.rule-item.wide .k {
  display: block;
  min-width: 0;
  margin-bottom: 5px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text);
}
.rule-item.wide .v {
  display: block;
  margin-left: 0;
  text-align: left;
  font-weight: 450;
  line-height: 1.75;
  color: var(--text-muted);
  word-break: break-word;
}

/* 步骤列表 */
.steps { display: flex; flex-direction: column; gap: 8px; }
.step {
  display: flex;
  gap: 11px;
  padding: 11px 14px;
  background: var(--fill-1);
  border-radius: var(--radius-md);
  font-size: 13.5px;
  line-height: 1.55;
  align-items: flex-start;
}
.step .idx {
  width: 21px; height: 21px;
  border-radius: 50%;
  background: var(--fill-4);
  color: var(--text);
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

/* 来源脚注 */
.source-note {
  margin-top: 18px;
  padding: 13px 15px;
  border-radius: var(--radius-md);
  background: var(--fill-1);
  border: var(--glass-border-soft);
  font-size: 12px;
  color: var(--text-subtle);
  line-height: 1.65;
}
.source-note a { color: var(--text-muted); text-decoration: underline; word-break: break-all; }
.source-note a:hover { color: var(--text); }

/* ============================================================
   提醒日历
   ============================================================ */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}
.cal-dow {
  text-align: center;
  font-size: 11px;
  color: var(--text-subtle);
  padding: 6px 0;
  letter-spacing: 0.05em;
}
.cal-cell {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  background: var(--fill-1);
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 12.5px;
  color: var(--text-muted);
  position: relative;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.cal-cell.empty { background: transparent; }
/* 今天：反色描边，比任何颜色都醒目且不占用色相 */
.cal-cell.today {
  border-color: var(--text);
  background: var(--fill-3);
  color: var(--text);
  font-weight: 650;
}
.cal-cell.has-remind { background: var(--c-warn-bg); color: var(--c-warn); font-weight: 650; border-color: var(--c-warn-line); }
.cal-cell.has-deadline { background: var(--c-danger-bg); color: var(--c-danger); font-weight: 700; border-color: var(--c-danger-line); }
.cal-cell .dots { display: flex; gap: 2.5px; height: 4px; }
.cal-cell .dot { width: 4px; height: 4px; border-radius: 50%; background: currentColor; opacity: 0.85; }

/* 提醒时间线 */
.timeline { display: flex; flex-direction: column; gap: 10px; }
.tl-item {
  display: flex;
  gap: 13px;
  padding: 13px 15px;
  border-radius: var(--radius-md);
  background: var(--fill-2);
  border-left: 3px solid var(--c-warn);
  align-items: center;
}
.tl-item.deadline { border-left-color: var(--c-danger); }
.tl-date {
  font-size: 11.5px;
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  flex-shrink: 0;
  min-width: 46px;
}
.tl-body { flex: 1; min-width: 0; }
.tl-body .t { font-size: 13.5px; font-weight: 550; }
.tl-body .d { font-size: 11.5px; color: var(--text-subtle); }

/* 行内强调：单色方案下靠「满强度文字色 + 加粗」而不是换颜色 */
.emph { color: var(--text); font-weight: 700; }
.dim { color: var(--text-subtle); }

/* ============================================================
   单色图标系统
   ------------------------------------------------------------
   彩色 emoji 会在单色界面里漏出色相（盾牌是蓝的、对勾是绿的），
   所以全部改用内联 SVG 描边图标，颜色由 currentColor 继承，
   在任何主题下都只有明度、没有色相。
   ============================================================ */
.i {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -0.145em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  overflow: visible;
}
.i-lg { width: 34px; height: 34px; stroke-width: 1.35; }
.i-sm { width: 0.92em; height: 0.92em; stroke-width: 2.1; }

/* 行内小圆点：替代彩色圆点 emoji，颜色走状态变量 */
.mk {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
  flex-shrink: 0;
}
.mk-danger { background: var(--c-danger); }
.mk-warn   { background: var(--c-warn); }
.mk-safe   { background: var(--c-safe-line); }

/* ============================================================
   杂项
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-subtle);
}
.empty-state .ico { font-size: 40px; margin-bottom: 10px; opacity: 0.5; }
.empty-state .t { font-size: 15px; color: var(--text-muted); margin-bottom: 5px; font-weight: 550; }
.empty-state .d { font-size: 13px; max-width: 320px; margin: 0 auto; line-height: 1.65; }

.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 2px 12px;
}
.section-head h2 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -0.01em; }
.section-head .sub { font-size: 12px; color: var(--text-subtle); }
.section-head .spacer { flex: 1; }

.banner {
  padding: 12px 15px;
  border-radius: var(--radius-md);
  background: var(--c-danger-bg);
  border: 1px solid var(--c-danger-line);
  font-size: 13px;
  margin-bottom: 14px;
  display: flex;
  gap: 9px;
  align-items: flex-start;
  line-height: 1.55;
}
.banner.info {
  background: var(--fill-2);
  border-color: var(--line-1);
  color: var(--text-muted);
}
/* 演示数据提示：中性玻璃条，不用红黄 —— 它不紧急，只是「不真」 */
.banner.demo {
  background: var(--fill-2);
  border-color: var(--line-2);
  color: var(--text-muted);
  align-items: center;
}
.banner.demo b { color: var(--text); }
.banner.demo .spacer { flex: 1; }
.banner .ico { flex-shrink: 0; }

.pill-select-wrap { position: relative; }

/* 手册下拉预览 */
.op-preview {
  margin-top: 8px;
  padding: 13px 15px;
  border-radius: var(--radius-md);
  background: var(--fill-2);
  border: var(--glass-border-soft);
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text-muted);
}
.op-preview b { color: var(--text); font-weight: 650; }

/* 「怎么查这张卡的真实到期日」—— 编辑弹窗里，让用户当场查到真值再填回来 */
.check-box {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--fill-2);
  border: var(--glass-border-soft);
}
.check-box .cb-h {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text);
  margin-bottom: 8px;
}
.check-box .cb-primary {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
  word-break: break-word;
  margin-bottom: 8px;
}
.check-box .cb-tel {
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none;
  margin-bottom: 8px;
}
.check-box .cb-note {
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--text-subtle);
}
.check-box .cb-note.dim { margin-top: 7px; color: var(--text-faint); }

/* 链接失效提示 */
.link-stale {
  color: var(--c-warn);
  font-size: 11.5px;
}

/* ============================================================
   响应式：移动端优先（为后续 App 封装做准备）
   ============================================================ */
@media (max-width: 640px) {
  .app { padding: 12px 12px 92px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: 1fr; }
  .topbar { padding: 10px 14px; top: 6px; }
  .topbar .brand span.txt { display: none; }
  .tab { font-size: 12.5px; padding: 9px 4px; }
  .modal { max-height: 90vh; padding: 18px; border-radius: var(--radius-lg); }
  .row-2 { grid-template-columns: 1fr; }
  .stat .num { font-size: 23px; }
  .card-foot { flex-wrap: wrap; }
  .counts { grid-template-columns: 1fr; }
}

@media (max-width: 380px) {
  .days-badge { padding: 4px 9px; font-size: 11.5px; }
  .op-name { font-size: 14px; }
}

/* ============================================================
   充值 / 余额 / 自动续期
   ============================================================ */

/* 余额偏低时的数字（唯一着色点：提醒你该去充值了） */
.kv-row .v.low { color: var(--c-warn); }
.kv-row .v .mk { margin-left: 4px; }

/* 复选框行 */
.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text-muted);
  font-size: 13.5px;
  cursor: pointer;
  user-select: none;
}
.check-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 19px;
  height: 19px;
  flex-shrink: 0;
  margin: 0;
  border-radius: 6px;
  background: var(--fill-2);
  border: 1px solid var(--line-2);
  cursor: pointer;
  position: relative;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease);
}
.check-row input[type="checkbox"]:checked {
  background: var(--inverse-bg);
  border-color: var(--inverse-bg);
}
.check-row input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 6px; top: 2px;
  width: 5px; height: 10px;
  border: solid var(--inverse-text);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.check-row input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* 「记一笔充值」弹窗顶部摘要 */
.tu-head {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--fill-1);
  border: var(--glass-border-soft);
  margin-bottom: 16px;
  font-size: 13px;
}
.tu-head .kv-row { padding: 3px 0; }
.tu-head .kv-row + .kv-row { border-top: none; }

/* 实时预览卡 */
.tu-preview {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--fill-1);
  border: var(--glass-border-soft);
  margin-bottom: 16px;
}
.tu-empty { color: var(--text-subtle); font-size: 13px; line-height: 1.6; }
.tu-days {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 26px;
  font-weight: 680;
  letter-spacing: -0.5px;
  color: var(--text);
  margin-bottom: 10px;
}
.tu-tier {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-subtle);
  letter-spacing: 0;
}
.tu-preview .kv-row { padding: 4px 0; }
.tu-mode, .tu-bal {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line-1);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text-muted);
}
.tu-bal { border-top: none; padding-top: 4px; margin-top: 6px; }
.tu-warn {
  margin-top: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: var(--c-warn-bg);
  border: 1px solid var(--c-warn-line);
  color: var(--c-warn);
  font-size: 12.5px;
  line-height: 1.65;
}

/* 手册详情页：档位表 */
.tier-table { margin-bottom: 4px; }
.tier-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 8px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--line-1);
}
.tier-row:last-child { border-bottom: none; }
.tier-row .amt { color: var(--text); font-weight: 550; }
.tier-row .days {
  margin-left: auto;
  color: var(--text);
  font-weight: 650;
  white-space: nowrap;
}
.tier-row.is-min .days { color: var(--text-muted); }
/* 档位表最后一行：算法与上限说明（整段文字，不参与两列对齐） */
.tier-row.meta {
  display: block;
  border-bottom: none;
  padding: 6px 0 2px;
  font-size: 12.5px;
  line-height: 1.85;
  color: var(--text-muted);
}
.tier-row.meta .k {
  display: block;
  margin-bottom: 3px;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .04em;
  color: var(--text-subtle);
}
.tier-row.meta .v { display: block; }

/* 手册详情页：余额 / 自动续期 说明块 */
.bal-row, .auto-renew {
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: var(--fill-1);
  border: var(--glass-border-soft);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.bal-row .big, .auto-renew .big {
  color: var(--text);
  font-weight: 650;
  font-size: 15px;
}
.auto-renew .quota {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-weight: 600;
}
.auto-renew .src { display: block; margin-top: 6px; font-size: 11.5px; color: var(--text-faint); }

@media (max-width: 640px) {
  .tu-days { font-size: 22px; }
  .tier-row { flex-wrap: wrap; gap: 4px 12px; }
  .tier-row .days { margin-left: auto; }
}

/* ============================================================
   数据备份 / 恢复（卡片列表底部）
   这是「换手机、换网址」时唯一的进出口，所以给它独立一块，
   不和卡片操作按钮挤在一起。
   ============================================================ */
.data-tools {
  margin-top: 22px;
  padding: 18px 20px 20px;
}
.dt-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.dt-head h3 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
}
.dt-when {
  margin-left: auto;
  font-size: 12.5px;
  color: var(--text-subtle);
  white-space: nowrap;
}
/* 超过 30 天没备份就变成提醒色 —— 颜色只出现在需要你动手的地方 */
.dt-when.is-stale { color: var(--c-warn); }

.dt-note {
  margin: 9px 0 15px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text-muted);
}
.dt-btns {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .data-tools { padding: 16px 16px 18px; }
  .dt-btns .btn { flex: 1 1 100%; justify-content: center; }
}

/* 打印 / 减少动画时的降级 */
@media print {
  body::before { display: none; }
  .fab, .tabs, .theme-toggle, .data-tools { display: none; }
}

/* ============================================================
   安全区（iPhone 刘海 / 灵动岛 / 底部 Home 指示条）
   env() 在桌面浏览器里恒为 0，所以桌面布局一字不变。
   ============================================================ */
.app {
  padding-top: calc(20px + env(safe-area-inset-top, 0px));
  padding-left: calc(16px + env(safe-area-inset-left, 0px));
  padding-right: calc(16px + env(safe-area-inset-right, 0px));
  padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
}
.fab {
  right: calc(20px + env(safe-area-inset-right, 0px));
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}
.toast {
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
}
/* 加到主屏后没有地址栏，顶栏可以再收紧一点 */
@media (display-mode: standalone) {
  .app { padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
}

