/* ============================================================
   小工具集 · 主站样式
   设计令牌取自 消防安全平台-服务器资源测算/tokens.json（项目既有令牌优先）
   ============================================================ */
:root{
  /* 品牌 / 语义色 */
  --color-primary:#2563eb; --color-primary-strong:#1d4ed8;
  --color-success:#1E7A45; --color-danger:#B91C1C; --color-warning:#92400E;
  /* 文字 */
  --color-text-strong:#0f172a; --color-text:#334155; --color-text-muted:#5b6b7f; --color-text-inverse:#ffffff;
  /* 表面与背景 */
  --color-bg:#f5f7fb; --color-surface:#ffffff;
  --color-bg-subtle:#f7f9fc; --color-bg-muted:#f8fafd; --color-bg-tint:#f0f4fb; --color-bg-soft:#fafcff;
  --color-bg-inset:#f1f5f9;
  /* 线条 */
  --color-line:#e8edf4; --color-line-strong:#e0e7f1; --color-track:#cbd5e1;
  /* 状态浅底 */
  --color-success-bg:#f0faf4; --color-warning-bg:#fff8e6; --color-warning-text:#7a4a00;
  /* 字号 */
  --fs-xs:11px; --fs-sm:12px; --fs-md:13px; --fs-label:13.5px;
  --fs-body:14px; --fs-subtitle:14.5px; --fs-card-title:16px; --fs-metric:18px; --fs-page-title:22px;
  /* 圆角 */
  --radius-sm:4px; --radius-md:6px; --radius-lg:8px; --radius-xl:10px;
  --radius-2xl:12px; --radius-3xl:16px; --radius-full:24px;
  /* 阴影 */
  --shadow-card:0 1px 2px rgba(15,23,42,.04);
  --shadow-card-hover:0 10px 28px rgba(15,23,42,.10);
  --shadow-bar:0 1px 0 rgba(15,23,42,.06);
}

*{box-sizing:border-box; margin:0; padding:0;}
html,body{height:100%;}
body{
  font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Helvetica Neue","Microsoft YaHei","Segoe UI",sans-serif;
  background:var(--color-bg); color:var(--color-text); font-size:var(--fs-body); line-height:1.55;
  -webkit-font-smoothing:antialiased;
}
button{font:inherit; color:inherit; background:none; border:none; cursor:pointer;}
a{color:inherit; text-decoration:none;}
svg{display:block;}
:focus-visible{outline:2px solid var(--color-primary); outline-offset:2px; border-radius:var(--radius-sm);}

/* ==================== 顶部品牌栏 ==================== */
.topbar{
  position:sticky; top:0; z-index:30;
  display:flex; align-items:center; gap:var(--radius-2xl);
  padding:0 28px; height:60px;
  background:rgba(255,255,255,.88); backdrop-filter:saturate(180%) blur(12px);
  border-bottom:1px solid var(--color-line);
}
.brand{display:flex; align-items:center; gap:10px; flex:none;}
.brand .mark{
  width:34px; height:34px; border-radius:10px; flex:none;
  background:linear-gradient(135deg,var(--color-primary),#6d5ef2);
  display:flex; align-items:center; justify-content:center;
  box-shadow:0 4px 12px rgba(37,99,235,.28);
}
.brand .mark svg{width:19px; height:19px; stroke:#fff; fill:none; stroke-width:1.9; stroke-linecap:round; stroke-linejoin:round;}
.brand .name{font-size:15.5px; font-weight:650; color:var(--color-text-strong); letter-spacing:.2px;}

.topbar .count{
  margin-left:auto; font-size:var(--fs-md); color:var(--color-text-muted);
  display:flex; align-items:center; gap:7px; white-space:nowrap;
}
.topbar .count b{color:var(--color-text-strong); font-weight:650; font-variant-numeric:tabular-nums;}
.topbar .count .dot{width:6px; height:6px; border-radius:50%; background:var(--color-success);}
/* 版本号（部署时由 deploy.sh 盖章注入） */
.topbar .ver{
  font-size:var(--fs-xs); color:#9aa6b5; font-variant-numeric:tabular-nums;
  padding-left:12px; border-left:1px solid var(--color-line); white-space:nowrap;
}

/* ==================== 首页视图 ==================== */
.view-home{min-height:calc(100% - 60px); display:flex; flex-direction:column;}

.hero{padding:44px 28px 26px; max-width:1280px; width:100%; margin:0 auto;}
.hero h1{
  font-size:30px; font-weight:700; color:var(--color-text-strong);
  letter-spacing:-.3px; line-height:1.25;
}
.hero p{margin-top:9px; font-size:var(--fs-subtitle); color:var(--color-text-muted); max-width:640px;}
.hero .stats{display:flex; gap:26px; margin-top:22px; flex-wrap:wrap;}
.hero .stats .s{display:flex; flex-direction:column;}
.hero .stats .s b{font-size:var(--fs-metric); font-weight:650; color:var(--color-text-strong); font-variant-numeric:tabular-nums; line-height:1.2;}
.hero .stats .s span{font-size:var(--fs-sm); color:var(--color-text-muted);}

/* ---------- 工具栏：搜索 + 分类 ---------- */
.toolbar-row{
  display:flex; align-items:center; gap:12px; flex-wrap:wrap;
  padding:0 28px 20px; max-width:1280px; width:100%; margin:0 auto;
}
.search{
  position:relative; flex:1 1 260px; max-width:340px; min-width:200px;
}
.search svg{
  position:absolute; left:11px; top:50%; transform:translateY(-50%);
  width:15px; height:15px; stroke:var(--color-text-muted); fill:none; stroke-width:2; stroke-linecap:round; pointer-events:none;
}
.search input{
  width:100%; height:38px; padding:0 32px 0 33px;
  border:1px solid var(--color-line-strong); border-radius:var(--radius-xl);
  background:var(--color-surface); color:var(--color-text-strong); font-size:var(--fs-md);
  transition:border-color .15s, box-shadow .15s;
}
.search input::placeholder{color:#9aa6b5;}
.search input:focus{outline:none; border-color:var(--color-primary); box-shadow:0 0 0 3px rgba(37,99,235,.12);}
.search .clear{
  position:absolute; right:8px; top:50%; transform:translateY(-50%);
  width:22px; height:22px; border-radius:50%; color:var(--color-text-muted);
  display:none; align-items:center; justify-content:center;
}
.search .clear svg{position:static; transform:none; width:11px; height:11px; stroke:currentColor; stroke-width:2.2;}
.search .clear:hover{background:var(--color-bg-inset); color:var(--color-text-strong);}
.search.filled .clear{display:flex;}

.chips{display:flex; gap:7px; flex-wrap:wrap;}
.chip{
  height:30px; padding:0 13px; border-radius:var(--radius-full);
  border:1px solid var(--color-line-strong); background:var(--color-surface);
  color:var(--color-text-muted); font-size:var(--fs-md); font-weight:500;
  display:inline-flex; align-items:center; gap:6px; transition:.15s;
}
.chip:hover{border-color:#c3d0e2; color:var(--color-text);}
.chip.on{background:var(--color-primary); border-color:var(--color-primary); color:#fff; font-weight:600;}
.chip .n{font-size:var(--fs-xs); opacity:.72; font-variant-numeric:tabular-nums;}

/* ---------- 工具卡片网格 ---------- */
.grid{
  display:grid; grid-template-columns:repeat(auto-fill,minmax(320px,1fr));
  gap:16px; padding:0 28px 44px; max-width:1280px; width:100%; margin:0 auto;
}
.card{
  position:relative; text-align:left; width:100%;
  background:var(--color-surface); border:1px solid var(--color-line);
  border-radius:var(--radius-3xl); padding:20px;
  box-shadow:var(--shadow-card); transition:.18s cubic-bezier(.4,0,.2,1);
  display:flex; flex-direction:column; gap:13px;
}
.card:hover{transform:translateY(-3px); border-color:var(--color-line-strong); box-shadow:var(--shadow-card-hover);}
.card:active{transform:translateY(-1px);}
.card .top{display:flex; align-items:flex-start; gap:12px;}
.card .ico{
  width:42px; height:42px; border-radius:var(--radius-xl); flex:none;
  display:flex; align-items:center; justify-content:center;
  background:var(--color-bg-tint); border:1px solid #dce6fa;
}
.card .ico svg{width:21px; height:21px; stroke:var(--color-primary); fill:none; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round;}
.card .ttl{flex:1; min-width:0;}
.card .ttl h3{font-size:var(--fs-card-title); font-weight:650; color:var(--color-text-strong); line-height:1.35;}
.card .ttl .cat{
  display:inline-block; margin-top:4px; font-size:var(--fs-xs); color:var(--color-text-muted);
  background:var(--color-bg-inset); padding:2px 8px; border-radius:var(--radius-sm);
}
.card p{font-size:var(--fs-md); color:var(--color-text-muted); line-height:1.62;}
.card .feats{display:flex; flex-direction:column; gap:6px;}
.card .feats li{
  list-style:none; font-size:var(--fs-sm); color:var(--color-text);
  display:flex; align-items:flex-start; gap:7px;
}
.card .feats svg{width:13px; height:13px; flex:none; margin-top:3px; stroke:var(--color-success); fill:none; stroke-width:2.4; stroke-linecap:round; stroke-linejoin:round;}
.card .go{
  margin-top:auto; padding-top:13px; border-top:1px solid var(--color-line);
  display:flex; align-items:center; gap:6px;
  font-size:var(--fs-md); font-weight:600; color:var(--color-primary);
}
.card .go svg{width:14px; height:14px; stroke:currentColor; fill:none; stroke-width:2.1; stroke-linecap:round; stroke-linejoin:round; transition:transform .18s;}
.card:hover .go svg{transform:translateX(3px);}

.empty{
  grid-column:1/-1; text-align:center; padding:64px 20px; color:var(--color-text-muted);
}
.empty svg{width:40px; height:40px; stroke:#c3cedd; fill:none; stroke-width:1.5; stroke-linecap:round; stroke-linejoin:round; margin:0 auto 12px;}
.empty p{font-size:var(--fs-md);}

/* ==================== 工具工作台视图（嵌入） ==================== */
.view-tool{
  position:fixed; inset:0; z-index:40; display:none;
  flex-direction:column; background:var(--color-bg);
}
body.tool-mode .view-tool{display:flex;}
body.tool-mode .view-home{display:none;}

.workbar{
  flex:none; display:flex; align-items:center; gap:12px;
  height:52px; padding:0 14px; background:var(--color-surface);
  border-bottom:1px solid var(--color-line); box-shadow:var(--shadow-bar);
}
.workbar .back{
  display:inline-flex; align-items:center; gap:6px; height:32px; padding:0 12px;
  border:1px solid var(--color-line-strong); border-radius:var(--radius-lg);
  font-size:var(--fs-md); font-weight:600; color:var(--color-text); background:var(--color-surface);
  transition:.15s; white-space:nowrap;
}
.workbar .back:hover{border-color:var(--color-primary); color:var(--color-primary); background:var(--color-bg-tint);}
.workbar .back svg{width:15px; height:15px; stroke:currentColor; fill:none; stroke-width:2.1; stroke-linecap:round; stroke-linejoin:round;}
.workbar .ico{
  width:28px; height:28px; border-radius:var(--radius-lg); flex:none;
  display:flex; align-items:center; justify-content:center;
  background:var(--color-bg-tint); border:1px solid #dce6fa;
}
.workbar .ico svg{width:16px; height:16px; stroke:var(--color-primary); fill:none; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round;}
.workbar .ttl{display:flex; flex-direction:column; min-width:0; line-height:1.25;}
.workbar .ttl b{font-size:var(--fs-label); font-weight:650; color:var(--color-text-strong); overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.workbar .ttl span{font-size:var(--fs-xs); color:var(--color-text-muted);}
.workbar .spacer{flex:1;}
.workbar .ext{
  display:inline-flex; align-items:center; gap:6px; height:32px; padding:0 12px;
  border:1px solid var(--color-line-strong); border-radius:var(--radius-lg);
  font-size:var(--fs-md); font-weight:600; color:var(--color-text); background:var(--color-surface);
  transition:.15s; white-space:nowrap;
}
.workbar .ext:hover{border-color:var(--color-primary); color:var(--color-primary); background:var(--color-bg-tint);}
.workbar .ext svg{width:14px; height:14px; stroke:currentColor; fill:none; stroke-width:2.1; stroke-linecap:round; stroke-linejoin:round;}

.frame-wrap{flex:1; min-height:0; position:relative; background:var(--color-bg);}
.frame-wrap iframe{position:absolute; inset:0; width:100%; height:100%; border:0; display:block;}
.frame-wrap.loading::after{
  content:"加载中…"; position:absolute; inset:0; display:flex; align-items:center; justify-content:center;
  color:var(--color-text-muted); font-size:var(--fs-md); background:var(--color-bg);
}

/* ==================== 响应式 ==================== */
@media (max-width:760px){
  .topbar{padding:0 16px; height:54px;}
  .hero{padding:30px 16px 20px;}
  .hero h1{font-size:24px;}
  .hero p{font-size:var(--fs-body);}
  .toolbar-row{padding:0 16px 16px;}
  .grid{padding:0 16px 34px; grid-template-columns:1fr;}
  .workbar{gap:8px; padding:0 8px;}
  .workbar .ttl span{display:none;}
  .workbar .back span{display:none;}
  .workbar .back{padding:0 10px;}
}
