/* ===== 主题变量 ===== */
:root {
  --bg: #f4f5f9;
  --card: #ffffff;
  --text: #16181d;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #4f46e5;
  --brand-soft: #eef2ff;
  --ok: #16a34a;
  --ok-soft: #e8f7ee;
  --warn: #d97706;
  --warn-soft: #fef3e2;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --card: #171b22;
    --text: #e8eaee;
    --muted: #98a1af;
    --line: #262c36;
    --brand: #818cf8;
    --brand-soft: #1e2440;
    --ok: #4ade80;
    --ok-soft: #14291c;
    --warn: #fbbf24;
    --warn-soft: #2b2210;
    --danger: #f87171;
    --danger-soft: #2c1416;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
.hidden { display: none !important; }
.mt { margin-top: 18px; }
.mt-s { margin-top: 8px; }

/* ===== 按钮 ===== */
.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: var(--card);
  color: var(--text);
  transition: transform .06s ease, filter .15s ease, background .15s;
  font-family: inherit;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.solid-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.solid-danger:hover { filter: brightness(1.06); }
.btn.sm { padding: 8px 13px; font-size: 14px; border-radius: 9px; }
.btn.block { width: 100%; padding: 13px; font-size: 16px; }
.btn:disabled { opacity: .55; pointer-events: none; }
.icon-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  font-family: inherit;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }

/* ===== 登录 ===== */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(120% 80% at 50% 0%, var(--brand-soft) 0%, var(--bg) 55%);
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px 26px 24px;
  box-shadow: var(--shadow);
}
.login-logo { font-size: 34px; text-align: center; line-height: 1; }
.login-card h1 { font-size: 20px; text-align: center; margin: 12px 0 4px; letter-spacing: .5px; }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.login-tip { text-align: center; color: var(--muted); font-size: 12px; margin: 16px 0 0; }
.login-tip code { background: var(--bg); padding: 1px 5px; border-radius: 4px; }

/* ===== 表单 ===== */
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 7px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 8px; }

.month-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.month-grid button {
  padding: 11px 0;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.month-grid button.sel { background: var(--brand); color: #fff; border-color: var(--brand); }
/* 「试用 1 天」「永久」两个快捷时长按钮 */
.quick-dur { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.quick-dur button {
  padding: 11px 0;
  border-radius: 10px;
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.quick-dur button[data-kind="day"] { color: var(--warn); border-color: var(--warn); }
.quick-dur button[data-kind="forever"] { color: var(--ok); border-color: var(--ok); }
.quick-dur button.sel { color: #fff; border-style: solid; }
.quick-dur button[data-kind="day"].sel { background: var(--warn); border-color: var(--warn); }
.quick-dur button[data-kind="forever"].sel { background: var(--ok); border-color: var(--ok); }
.expire-preview { margin-top: 10px; font-size: 13px; color: var(--muted); }
.check-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  cursor: pointer;
}
.check-line input { width: 16px; height: 16px; margin: 1px 0 0; accent-color: var(--brand); flex: none; }
.expire-preview b { color: var(--brand); }

.file-drop {
  display: block;
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  padding: 22px 14px;
  text-align: center;
  cursor: pointer;
  background: var(--bg);
}
.file-drop:hover { border-color: var(--brand); }
.file-drop strong { display: block; font-size: 14px; margin-bottom: 4px; }
.file-drop small { color: var(--muted); font-size: 12px; }

/* ===== 主框架 ===== */
.app { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: var(--card);
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.brand-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.topbar-right { display: flex; align-items: center; gap: 6px; }
.who { font-size: 12px; color: var(--muted); }

.main { max-width: 760px; margin: 0 auto; padding: 14px 14px 110px; }

/* ===== 概览 ===== */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat .n { font-size: 20px; font-weight: 700; line-height: 1.2; }
.stat .l { font-size: 11px; color: var(--muted); margin-top: 3px; }
.stat.s-ok .n { color: var(--ok); }
.stat.s-warn .n { color: var(--warn); }
.stat.s-bad .n { color: var(--danger); }

/* ===== 标签页 ===== */
.tabs {
  display: flex; gap: 4px; padding: 4px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 14px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1 0 auto;
  border: none; background: transparent; color: var(--muted);
  padding: 9px 14px; border-radius: 9px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  font-family: inherit; white-space: nowrap;
}
.tab.active { background: var(--brand-soft); color: var(--brand); }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar > .btn { margin-left: auto; flex: 0 0 auto; }
.hint { font-size: 12.5px; color: var(--muted); flex: 1; min-width: 140px; }

.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  padding: 7px 13px; border-radius: 999px; font-size: 13px; cursor: pointer;
  font-family: inherit; white-space: nowrap;
}
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

/* ===== 卡片列表 ===== */
.list { display: flex; flex-direction: column; gap: 11px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.card.expired { opacity: .72; }

.sub-head { display: flex; align-items: center; gap: 11px; }
.avatar {
  width: 42px; height: 42px; flex: 0 0 42px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px;
  color: #fff;
  background: var(--brand);
}
.sub-title { flex: 1; min-width: 0; }
.sub-name { font-weight: 700; font-size: 15.5px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.sub-meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.sub-meta .mono { font-family: ui-monospace, Menlo, monospace; }

.tag {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  letter-spacing: .3px;
}
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.soon { background: var(--warn-soft); color: var(--warn); }
.tag.exp { background: var(--danger-soft); color: var(--danger); }

.link-row { margin-top: 12px; }
.link-row input {
  width: 100%;
  font-size: 12px;
  font-family: ui-monospace, Menlo, monospace;
  padding: 9px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  text-overflow: ellipsis;
}

.sub-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.sub-info { font-size: 11.5px; color: var(--muted); line-height: 1.6; }
.sub-actions { display: flex; gap: 6px; }
.sub-actions .btn { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }

/* 源卡片 */
.src-row { display: flex; align-items: center; gap: 12px; }
.src-info { flex: 1; min-width: 0; }
.src-name { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.src-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.src-actions { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.src-actions .btn { padding: 7px 12px; font-size: 12.5px; }

/* 生成订阅时的直播源点选 */
.source-picker {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  max-height: 232px;
  overflow-y: auto;
  padding: 2px;
}
.src-tile {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: border-color .12s, background .12s;
}
.src-tile:hover { border-color: var(--brand); }
.src-tile.sel { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.tile-avatar {
  width: 27px; height: 27px; flex: 0 0 27px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12.5px; font-weight: 700;
}
.tile-body { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.tile-body b { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-body small { font-size: 11px; color: var(--muted); }
.tile-check { color: var(--brand); font-weight: 700; font-size: 14px; }
.picker-empty { font-size: 13px; color: var(--muted); padding: 14px; border: 1px dashed var(--line); border-radius: 10px; text-align: center; }

.sync-hint {
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12.5px;
  line-height: 1.5;
  padding: 9px 11px;
  border-radius: 9px;
  margin-bottom: 12px;
}

/* 批量上传列表 */
.batch-list { display: flex; flex-direction: column; gap: 7px; margin-top: 12px; max-height: 300px; overflow-y: auto; }
.batch-item { display: flex; align-items: center; gap: 8px; }
.batch-item input { flex: 1; min-width: 0; padding: 8px 10px; font-size: 13px; }
.batch-meta { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.batch-item .icon-btn { padding: 4px 7px; }

.toolbar-btns { display: flex; gap: 7px; margin-left: auto; flex: 0 0 auto; }

/* 空状态 */
.empty {
  text-align: center;
  padding: 54px 20px;
  color: var(--muted);
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  font-size: 14px;
}
.empty .big { font-size: 30px; display: block; margin-bottom: 10px; opacity: .6; }

/* 日志 */
.log-list { display: flex; flex-direction: column; gap: 1px; background: var(--line); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.log-item { background: var(--card); padding: 11px 13px; }
.log-top { display: flex; align-items: baseline; gap: 8px; }
.log-time { font-size: 11.5px; color: var(--muted); font-family: ui-monospace, Menlo, monospace; flex: 0 0 auto; }
.log-type { font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: var(--brand-soft); color: var(--brand); }
.log-type.t-auto_delete, .log-type.t-sub_delete, .log-type.t-source_delete { background: var(--danger-soft); color: var(--danger); }
.log-type.t-login_fail { background: var(--danger-soft); color: var(--danger); }
.log-type.t-sub_create { background: var(--ok-soft); color: var(--ok); }
.log-msg { font-size: 13px; margin-top: 4px; overflow-wrap: anywhere; word-break: normal; }
.log-url { font-size: 11.5px; color: var(--muted); font-family: ui-monospace, Menlo, monospace; margin-top: 4px; word-break: break-all; }
.log-item.has-detail { cursor: pointer; }
.log-item.has-detail .log-more { margin-left: auto; font-size: 11px; color: var(--brand); flex: 0 0 auto; }
.log-type.t-sub_newip { background: var(--warn-soft); color: var(--warn); }
.log-type.t-risk { background: var(--danger-soft); color: var(--danger); }

/* 日志展开的访问明细 */
.log-detail {
  display: none;
  margin-top: 9px;
  padding: 9px 10px;
  border-radius: 9px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 11.5px;
  line-height: 1.6;
  cursor: default;
}
.log-item.open .log-detail { display: block; }
.log-item.open .log-more { transform: rotate(180deg); }
.ld-title { font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.ld-row { display: flex; gap: 8px; padding: 2px 0; }
.ld-k { flex: 0 0 46px; color: var(--muted); }
.ld-v { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ld-v.ua, .ld-ip .mono, .net-name, .ip-ip, .ip-ua, .dev-ua, .rv-ua, .rv-sub .mono, .rv-top .i { font-family: ui-monospace, Menlo, Consolas, monospace; }
.ld-v.ua { color: var(--muted); font-size: 10.5px; }
.ld-net { padding: 6px 0; border-top: 1px dashed var(--line); }
.ld-net:first-of-type { border-top: 0; }
.ld-net-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.ld-net-head span { color: var(--muted); font-size: 10.5px; }
.ld-ip { display: flex; flex-wrap: wrap; gap: 6px; padding: 3px 0 3px 8px; border-left: 2px solid var(--line); margin: 4px 0 0 4px; }
.ld-ip-meta { color: var(--muted); font-size: 10.5px; }
.ld-ip-dev { color: var(--text); font-size: 10.5px; opacity: .85; }
.ld-empty { color: var(--muted); padding: 6px 0; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }

/* 网络分组卡片 */
.net-card { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: var(--card); overflow: hidden; }
.net-card > summary {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  padding: 9px 11px; cursor: pointer; list-style: none;
}
.net-card > summary::-webkit-details-marker { display: none; }
.net-card > summary::before { content: '▸'; color: var(--muted); font-size: 10px; transition: transform .15s; }
.net-card[open] > summary::before { transform: rotate(90deg); }
.net-card > summary .net-name { font-size: 12.5px; font-weight: 600; overflow-wrap: anywhere; }
.net-card > summary .net-meta { font-size: 11.5px; color: var(--muted); }
.net-card > summary .net-time { margin-left: auto; font-size: 11px; color: var(--muted); white-space: nowrap; }
.net-body { padding: 0 11px 8px; }
.ip-block { padding: 8px 0; border-top: 1px solid var(--line); }
.ip-block:first-child { border-top: 0; padding-top: 2px; }
.ip-line { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
.ip-ip { font-size: 12.5px; overflow-wrap: anywhere; }
.ip-meta { font-size: 11px; color: var(--muted); }
.ip-devs { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.dev-chip { font-size: 10.5px; padding: 2px 7px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); }
.ip-ua { font-size: 10.5px; color: var(--muted); margin-top: 4px; overflow-wrap: anywhere; line-height: 1.5; }
.pill { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 999px; background: var(--line); color: var(--muted); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.btn.tiny { padding: 2px 7px; font-size: 10.5px; border-radius: 6px; }

/* 设备明细 */
.dev-item { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.dev-item:last-child { border-bottom: 0; }
.dev-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; font-size: 12.5px; }
.dev-head span { color: var(--muted); font-size: 11px; }
.dev-ua { font-size: 10.5px; color: var(--muted); margin-top: 3px; overflow-wrap: anywhere; line-height: 1.5; }

/* 最近访问流水 */
.rv-row { padding: 7px 9px; border-bottom: 1px solid var(--line); }
.rv-row:last-child { border-bottom: 0; }
.rv-top { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; font-size: 11.5px; }
.rv-top .t { color: var(--muted); }
.rv-top .i { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.rv-top .c { color: var(--muted); margin-left: auto; }
.rv-sub { font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.rv-ua { font-size: 10px; color: var(--muted); opacity: .85; margin-top: 2px; overflow-wrap: anywhere; line-height: 1.45; }

/* 设置面板 */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.panel h3 { font-size: 14.5px; margin: 0 0 6px; }
.panel .hint { margin: 0 0 10px; }

/* FAB */
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(22px + env(safe-area-inset-bottom));
  width: 54px; height: 54px;
  border-radius: 50%;
  border: none;
  background: var(--brand);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(79, 70, 229, .42);
  z-index: 30;
  display: none;
}
.fab:active { transform: scale(.94); }

/* ===== 弹窗 ===== */
.modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(10, 12, 16, .5);
  backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
}
.modal-card {
  width: 100%; max-width: 520px;
  max-height: 92vh;
  display: flex; flex-direction: column;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, .3);
  animation: slideUp .22s ease;
}
.modal-card.narrow { max-width: 420px; }
@keyframes slideUp { from { transform: translateY(28px); opacity: .4; } to { transform: translateY(0); opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 6px; }
.modal-head h2 { font-size: 17px; margin: 0; }
.modal-body { padding: 10px 18px; overflow-y: auto; }
.modal-foot {
  display: flex; gap: 10px; padding: 12px 18px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.modal-foot .btn { flex: 1; }

/* Toast */
.toast {
  position: fixed;
  left: 50%; bottom: 96px;
  transform: translate(-50%, 16px);
  background: #16181d;
  color: #fff;
  padding: 11px 20px;
  border-radius: 10px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 99;
  max-width: 84vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 桌面端 */
@media (min-width: 700px) {
  .modal { align-items: center; }
  .modal-card { border-radius: 18px; }
  .month-grid { grid-template-columns: repeat(12, 1fr); }
  .fab { display: none !important; }
  .main { padding-bottom: 40px; }
  .source-picker { grid-template-columns: 1fr 1fr; }
}

/* 宽屏：卡片两列，充分利用电脑屏幕 */
@media (min-width: 1000px) {
  .main { max-width: 1120px; padding: 18px 20px 40px; }
  .topbar { padding: 14px 26px; }
  .stats { gap: 12px; margin-bottom: 18px; }
  .stat { padding: 16px 10px; }
  .stat .n { font-size: 24px; }
  .stat .l { font-size: 12px; }
  .tabs { max-width: 620px; }
  .list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
  .list > .empty { grid-column: 1 / -1; }
  .source-picker { grid-template-columns: repeat(3, 1fr); }
  .log-list { max-height: none; }
}
@media (max-width: 699px) {
  .fab.show { display: block; }
  .stat .n { font-size: 18px; }
  .stats { gap: 7px; }
  .stat { padding: 10px 4px; }
  .stat .l { font-size: 10.5px; }
  .toolbar .hint { flex: 1 1 100%; }
}

/* ===== 风险标记：多设备 / 多人共用 ===== */
button.tag { border: 0; font-family: inherit; cursor: pointer; }
.tag.risk { background: var(--danger-soft); color: var(--danger); }
.tag.watch { background: var(--warn-soft); color: var(--warn); }
.tag.reviewed { background: var(--line); color: var(--muted); font-weight: 600; }

.chip.chip-risk { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.chip.chip-risk.active { background: var(--danger); border-color: var(--danger); color: #fff; }
.chip.chip-risk b { font-weight: 800; }

.risk-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; margin-bottom: 11px; border-radius: 11px;
  background: var(--danger-soft); color: var(--danger);
  font-size: 12.5px; line-height: 1.5;
}
.risk-bar .grow { flex: 1; min-width: 0; }
.risk-bar .btn { flex: 0 0 auto; padding: 6px 10px; font-size: 12px; background: transparent; border-color: currentColor; color: inherit; }

/* ===== 使用情况弹窗 ===== */
.risk-hero { border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; }
.risk-hero.high { background: var(--danger-soft); color: var(--danger); }
.risk-hero.watch { background: var(--warn-soft); color: var(--warn); }
.risk-hero.none { background: var(--ok-soft); color: var(--ok); }
.risk-hero .lv { font-size: 14.5px; font-weight: 700; }
.risk-hero .sub { font-size: 12px; margin-top: 4px; line-height: 1.6; opacity: .95; }

.nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.num { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 3px; text-align: center; }
.num b { display: block; font-size: 16px; line-height: 1.3; }
.num span { font-size: 10.5px; color: var(--muted); }

.sec-title { font-size: 12px; font-weight: 700; color: var(--muted); margin: 16px 0 6px; letter-spacing: .3px; }

.reasons { margin: 0; padding: 0; list-style: none; }
.reasons li { font-size: 12.5px; padding: 7px 0 7px 16px; position: relative; line-height: 1.55; border-bottom: 1px dashed var(--line); }
.reasons li:last-child { border-bottom: 0; }
.reasons li::before { content: ''; position: absolute; left: 3px; top: 14px; width: 5px; height: 5px; border-radius: 50%; background: var(--danger); }
.notes { margin: 0; padding: 0; list-style: none; }
.notes li { font-size: 12px; padding: 6px 0 6px 16px; position: relative; line-height: 1.55; color: var(--muted); }
.notes li::before { content: ''; position: absolute; left: 4px; top: 13px; width: 4px; height: 4px; border-radius: 50%; background: var(--brand); opacity: .7; }
.risk-hero.none ~ .reasons li::before { background: var(--ok); }

.ip-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.ip-row:last-child { border-bottom: 0; }
.ip-main { flex: 1; min-width: 0; }
.ip-addr { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; overflow-wrap: anywhere; }
.ip-sub { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.ip-hits { flex: 0 0 auto; color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.ip-row .btn { flex: 0 0 auto; padding: 4px 8px; font-size: 11px; border-radius: 7px; }
.mine-mark { font-size: 11px; color: var(--ok); flex: 0 0 auto; }

.dev-row { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; padding: 6px 0; }
.dev-row span:last-child { color: var(--muted); font-size: 11.5px; white-space: nowrap; }

.recent { max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: 9px; }

.script-box textarea { min-height: 92px; margin-top: 4px; }

.trust-ips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.trust-ips .none-tip { font-size: 12px; color: var(--muted); }
.ip-pill {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 5px 3px 10px; font-size: 12px; font-family: ui-monospace, Menlo, monospace;
}
.ip-pill button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 13px; line-height: 1; padding: 2px 4px; }
.inline-add { display: flex; gap: 7px; align-items: center; }
.inline-add input { flex: 1; min-width: 0; }
.inline-add .btn { flex: 0 0 auto; }

@media (max-width: 400px) {
  .num b { font-size: 14.5px; }
  .num span { font-size: 10px; }
}

/* ===== IP 归属地标签：城市 + 运营商 ===== */
.geo {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; line-height: 1; white-space: nowrap; vertical-align: middle;
}
.geo-city { color: var(--muted); }
.isp {
  font-size: 10px; font-weight: 700; line-height: 1;
  padding: 2px 5px; border-radius: 4px; letter-spacing: .2px;
}
.isp.dx { background: #e8f0ff; color: #1d4ed8; }
.isp.cu { background: #fff0e6; color: #c2410c; }
.isp.cm { background: #e4f6f9; color: #0e7490; }
.isp.gd { background: #f1eaff; color: #6d28d9; }
.isp.tt { background: #f1f5f9; color: #475569; }
.isp.edu { background: #e9f7ee; color: #15803d; }
.isp.bb { background: #f3f4f6; color: #4b5563; }
.isp.cloud { background: #eef2ff; color: #4338ca; }
.isp.abroad { background: #eef6ff; color: #0369a1; }
.isp.lan { background: #f3f4f6; color: #6b7280; }
.isp.other { background: #f3f4f6; color: #4b5563; }

@media (prefers-color-scheme: dark) {
  .isp.dx { background: #1a2740; color: #93b7ff; }
  .isp.cu { background: #33220f; color: #fdba74; }
  .isp.cm { background: #10303a; color: #67e8f9; }
  .isp.gd { background: #241a3d; color: #c4b5fd; }
  .isp.tt, .isp.bb, .isp.lan, .isp.other { background: #232a34; color: #a6b0c0; }
  .isp.edu { background: #132a1c; color: #86efac; }
  .isp.cloud { background: #1e2440; color: #a5b4fc; }
  .isp.abroad { background: #12283a; color: #7dd3fc; }
}

/* 归属地库状态行 */
.geo-status { font-size: 12.5px; line-height: 1.7; color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; }
.geo-ok { color: var(--ok); font-weight: 700; }
.geo-bad { color: var(--danger); font-weight: 700; }
