/* 新版外壳与新页面：左侧导航、概览、图谱、结果页增强件。 */

/* ── 外壳：左侧持久导航 ─────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .brand {
  font-family: var(--font-mono);
  font-size: 13px; font-weight: 700;
  padding: 4px 8px 14px;
  color: var(--fg-strong);
  letter-spacing: 0.02em;
}
.sidebar .brand .dot { color: var(--accent); }
.sidebar .group {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--muted); padding: 14px 8px 6px;
}
.sidebar button {
  display: flex; align-items: center; gap: 9px;
  width: 100%; text-align: left;
  background: none; border: 1px solid transparent;
  color: var(--muted);
  padding: 7px 9px; border-radius: var(--radius-sm);
  font-size: 13px; cursor: pointer;
}
.sidebar button:hover { background: var(--bg-3); color: var(--fg); }
.sidebar button.active {
  background: var(--accent-soft); color: var(--accent);
  border-color: var(--accent-dim);
}
.sidebar button .ico { width: 15px; text-align: center; opacity: 0.85; }
.sidebar button .tally {
  margin-left: auto; font-family: var(--font-mono);
  font-size: 10px; color: var(--muted);
}

.workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
  position: sticky; top: 0; z-index: 50;
}
.topbar .spacer { margin-left: auto; }
.topbar select, .topbar input[type="text"] { width: auto; min-width: 150px; }
.topbar .icon-btn {
  background: none; border: 1px solid var(--line-2); color: var(--muted);
  border-radius: var(--radius-sm); padding: 6px 9px; cursor: pointer;
  font-size: 13px; line-height: 1;
}
.topbar .icon-btn:hover { color: var(--fg); border-color: var(--accent-dim); }

/* 常驻任务状态，不用切到 tasks 页才能看进度 */
.task-pill {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line-2); border-radius: 999px;
  padding: 4px 12px 4px 10px;
  font-family: var(--font-mono); font-size: 11px;
  color: var(--muted); cursor: pointer; background: none;
}
.task-pill.running { border-color: var(--accent-dim); color: var(--accent); }
.task-pill.failed { border-color: var(--err); color: var(--err); }
.task-pill.partial { border-color: var(--warn); color: var(--warn); }
.task-pill .spin {
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }

.page { padding: 20px; max-width: 1560px; width: 100%; }

/* ── 概览页 ────────────────────────────────────────────────── */
.kpi-row {
  display: grid; gap: 12px; margin-bottom: 16px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.kpi {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
}
.kpi .label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted);
}
.kpi .value {
  font-family: var(--font-mono); font-size: 26px; font-weight: 700;
  color: var(--fg-strong); line-height: 1.25; margin-top: 4px;
}
.kpi .value.accent { color: var(--accent); }
.kpi .sub { font-size: 11px; color: var(--muted); }

.grid-2 {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
}

/* 来源贡献条：search / chart / similar 的命中率对比 */
.source-row { margin-bottom: 14px; }
.source-row:last-child { margin-bottom: 0; }
.source-row .head {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 12px; margin-bottom: 5px;
}
.source-row .head .name { color: var(--fg); font-weight: 600; }
.source-row .head .rate {
  margin-left: auto; font-family: var(--font-mono);
  font-size: 13px; font-weight: 700;
}
.source-row .head .count {
  font-family: var(--font-mono); font-size: 11px; color: var(--muted);
}
.bar-track {
  height: 8px; background: var(--bg-3); border-radius: 999px; overflow: hidden;
}
.bar-fill { height: 100%; border-radius: 999px; transition: width 0.3s ease; }

.dist { display: flex; flex-direction: column; gap: 7px; }
.dist-row { display: flex; align-items: center; gap: 9px; font-size: 12px; }
.dist-row .swatch {
  width: 9px; height: 9px; border-radius: 2px; flex: 0 0 auto;
}
.dist-row .name { flex: 1; min-width: 0; }
.dist-row .n { font-family: var(--font-mono); color: var(--muted); }
.dist-row .mini-track {
  flex: 0 0 90px; height: 5px; background: var(--bg-3);
  border-radius: 999px; overflow: hidden;
}
.dist-row .mini-fill { height: 100%; }

/* ── 新鲜度：视觉信号而不是又一列数字 ───────────────────────── */
.fresh-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  flex: 0 0 auto;
}
.fresh-dot.active  { background: var(--fresh-active); }
.fresh-dot.slowing { background: var(--fresh-slowing); }
.fresh-dot.stale   { background: var(--fresh-stale); }
.fresh-dot.unknown {
  background: transparent; border: 1px solid var(--line-2);
}

.seg {
  display: inline-flex; border: 1px solid var(--line);
  border-radius: var(--radius-sm); overflow: hidden;
}
.seg button {
  background: var(--bg); border: none; color: var(--muted);
  padding: 6px 11px; font-size: 12px; cursor: pointer;
  border-right: 1px solid var(--line); white-space: nowrap;
  font-family: var(--font-sans);
}
.seg button:last-child { border-right: none; }
.seg button:hover { color: var(--fg); background: var(--bg-3); }
.seg button.on { background: var(--accent-soft); color: var(--accent); }

/* 已激活的筛选以可删除 chip 呈现，取代一整排控件墙 */
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-3); border: 1px solid var(--line-2);
  border-radius: 999px; padding: 3px 9px; font-size: 11px; color: var(--fg);
}
.chip .x {
  cursor: pointer; color: var(--muted); font-size: 13px; line-height: 1;
}
.chip .x:hover { color: var(--err); }
.chip.empty { color: var(--muted); border-style: dashed; }

.badge {
  display: inline-block; padding: 1px 6px; border-radius: 3px;
  font-size: 10px; border: 1px solid currentColor; opacity: 0.9;
}
.badge.search  { color: var(--src-search); }
.badge.chart   { color: var(--src-chart); }
.badge.genre_chart { color: var(--src-chart); border-style: dashed; }
.badge.similar { color: var(--src-similar); }

.deg {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--src-similar); font-weight: 700;
}

/* ── 相似 app 抽屉区块 ──────────────────────────────────────── */
.similar-list { display: flex; flex-direction: column; gap: 2px; }
.similar-item {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer;
}
.similar-item:hover { background: var(--bg-3); }
.similar-item img {
  width: 26px; height: 26px; border-radius: 6px; flex: 0 0 auto;
}
.similar-item .meta { flex: 1; min-width: 0; }
.similar-item .nm {
  font-size: 12px; color: var(--fg);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.similar-item .sub { font-size: 10px; color: var(--muted); }

.empty-state {
  padding: 34px 20px; text-align: center; color: var(--muted); font-size: 13px;
}
.empty-state .big { font-size: 26px; opacity: 0.4; margin-bottom: 8px; }

.hint {
  font-size: 11px; color: var(--muted); line-height: 1.5; margin-top: 5px;
}
.hint.warn { color: var(--warn); }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none; height: auto; position: static;
    flex-direction: row; flex-wrap: wrap; gap: 3px;
    border-right: none; border-bottom: 1px solid var(--line);
  }
  .sidebar .brand, .sidebar .group { display: none; }
  .sidebar button { width: auto; }
}

/* ── 结果表：列数变多后需要显式排布，否则 app 名会被挤成三行 ───── */
/* 最小宽度 = 可见列宽之和（模板里按列配置算），列少时铺满、列多时横向滚动 */
.apps-table { table-layout: fixed; width: 100%; }
.table-scroll { overflow-x: auto; }
.apps-table th, .apps-table td { overflow: hidden; }

.apps-table td .cn {
  display: block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.apps-table td .hint {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 亮色主题下，靠 class 写死的分类色同样需要提高对比度 */
:root[data-theme="light"] .pill.cat-esim_marketplace { color: #1f7a45; border-color: #9fd9b8; }
:root[data-theme="light"] .pill.cat-roaming_service  { color: #21598f; border-color: #a9caea; }
:root[data-theme="light"] .pill.cat-travel_platform  { color: #96601f; border-color: #eccb9c; }
:root[data-theme="light"] .pill.cat-local_carrier    { color: #1d7a70; border-color: #9dd8d1; }
:root[data-theme="light"] .pill.cat-mvno_app         { color: #5b3fa0; border-color: #c6b6ea; }
:root[data-theme="light"] .pill.cat-data_tool        { color: #7d6f1a; border-color: #ddd59a; }
:root[data-theme="light"] .pill.cat-vpn_or_other     { color: #a33b63; border-color: #edb4c9; }
:root[data-theme="light"] .pill.ok { color: var(--accent); border-color: #9fd9b8; }

/* ── 结果页重做（E0–E4 / G1–G3） ─────────────────────────────── */
.results-toolbar { flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.view-select { width: auto; max-width: 160px; }
button.btn.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-dim); }

/* 四个常驻分段控件：左侧统一宽度的标签，各占一行 */
.filter-grid {
  display: grid; grid-template-columns: 44px 1fr; gap: 8px 10px; align-items: center;
}
.filter-grid .seg { justify-self: start; }
.filter-label { font-size: 11px; color: var(--muted); white-space: nowrap; }
.chip-sep { width: 1px; height: 16px; background: var(--line); margin: 0 4px; }
.sort-chip { font-family: var(--font-mono); font-size: 11px; }

.more-filters {
  display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center;
  margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line);
  font-size: 12px;
}
.more-filters label.row { margin: 0; gap: 6px; }
.more-filters .full-row { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.popover-anchor { position: relative; }
.popover {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  background: var(--bg-2); border: 1px solid var(--line-2);
  border-radius: var(--radius); padding: 12px; box-shadow: 0 8px 28px rgba(0, 0, 0, .28);
}
.columns-pop { width: 360px; max-height: 70vh; overflow-y: auto; }
.col-group { margin-bottom: 10px; }
.col-group-title { font-size: 10px; text-transform: uppercase; margin-bottom: 4px; }
.col-choice { display: inline-flex; align-items: center; gap: 4px; width: 50%; font-size: 12px; margin: 2px 0; }
.menu-pop { width: 260px; padding: 6px; display: flex; flex-direction: column; }
.menu-item {
  text-align: left; background: none; border: none; color: var(--fg);
  padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px;
}
.menu-item:hover:not(:disabled) { background: var(--bg-3); }
.menu-item:disabled { color: var(--muted); cursor: not-allowed; }
.menu-item.danger { color: var(--err); }

/* 免费额度徽章：trial 琥珀、recurring 绿、ad_supported 紫 */
.ft-badge {
  display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-size: 11px; padding: 2px 7px; border-radius: 999px;
  border: 1px solid var(--line-2); color: var(--accent); background: var(--accent-soft);
  vertical-align: middle;
}
.ft-recurring { color: var(--fresh-active); border-color: color-mix(in srgb, var(--fresh-active) 50%, transparent);
                background: color-mix(in srgb, var(--fresh-active) 14%, transparent); }
.ft-trial { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, transparent);
            background: color-mix(in srgb, var(--warn) 14%, transparent); }
.ft-ad_supported { color: #b48cff; border-color: color-mix(in srgb, #b48cff 50%, transparent);
                   background: color-mix(in srgb, #b48cff 14%, transparent); }
.text-err { color: var(--err); }
.nowrap { white-space: nowrap; }
.clamp-2 {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; font-size: 12px;
}

/* G2 虚拟滚动：只在行数多时启用，表头吸顶 */
.table-scroll.virtual { max-height: 72vh; overflow-y: auto; }
.table-scroll.virtual thead th { position: sticky; top: 0; z-index: 2; background: var(--bg-2); }
.pad-row td { padding: 0 !important; border: none !important; }

.confirm-modal { max-width: 520px; }
.danger-zone { border-color: color-mix(in srgb, var(--err) 45%, var(--line)); }
.danger-zone h2 { color: var(--err); }

.detail-subtitle { font-size: 13px; color: var(--accent); margin: 2px 0; }
.review-panel { background: var(--bg-3); margin-bottom: 16px; }
.kpi-inline { font-size: 13px; margin-bottom: 10px; }
.privacy-list { display: flex; flex-direction: column; gap: 6px; }
.privacy-row { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.privacy-kind { font-size: 11px; min-width: 190px; color: var(--muted); }
.privacy-track .privacy-kind { color: var(--err); font-weight: 700; }

/* ── eSIM 配置（eUICC）页 ─────────────────────────────────────── */
.euicc-table { table-layout: fixed; width: 100%; min-width: 1100px; }
.euicc-table td { overflow: hidden; text-overflow: ellipsis; vertical-align: top; }
.euicc-table tr.data-row { cursor: pointer; }
.small { font-size: 11px; }
.type-badge { font-size: 11px; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line-2); }
.type-reseller { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-dim); }
.type-mno_official { color: var(--src-search); }
.type-mvno { color: var(--src-similar); }
.type-unknown { color: var(--muted); border-style: dashed; }
.ws { font-size: 11px; margin-top: 2px; }
.ws-verified { color: var(--fresh-active); }
.ws-mismatch, .ws-unconfirmed { color: var(--warn); }
.ws-irrelevant { color: var(--err); }
.ws-unreachable, .ws-invalid { color: var(--err); }
.ws-none { color: var(--muted); }
