/* Argus 百眼 v1.0 — 配色 A，低饱和，禁满屏鲜艳 */
:root {
  --bg: #F5F6F8;
  --card: #FFFFFF;
  --sub-bg: #F9FAFB;
  --text: #344054;
  --muted: #667085;
  --faint: #98A2B3;
  --disabled: #B8C0CC;
  --border: #EAECF0;
  --border-strong: #D0D5DD;
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-light: #DBEAFE;
  --primary-border: #BFDBFE;
  --primary-text: #1D4ED8;
  --input-focus-border: #8BAEDB;
  --input-focus-ring: #E5EFFD;
  --secondary-bg: #F3F4F6;
  /* 状态色（低饱和偏灰调） */
  --ok: #557967; --ok-bg: #E8F0EB; --ok-border: #C8D9CD; --ok-bar: #668B7A;
  --warn: #9A7135; --warn-bg: #F5EEDC; --warn-border: #E5D4AE; --warn-bar: #B08A4E;
  --crit: #A44740; --crit-bg: #F5E7E5; --crit-border: #E3C5C1; --crit-bar: #B65C56;
  --off: #667085; --off-bg: #EAECF0; --off-border: #D0D5DD; --off-bar: #7B8794;
  --danger: #B42318; --danger-hover: #912018; --danger-bg: #F8E8E6; --danger-border: #E2B8B4;
  /* 曲线色 */
  --c-cpu: #5879A8; --c-mem: #8A6FA8; --c-disk: #B08A4E;
  --c-rx: #4D8C83; --c-tx: #B66B7B; --c-load: #6B7280; --c-ping: #738B58;
  --grid: #EAECF0;
  --radius: 12px;
  --gap: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 8px; }
h3 { font-size: 14px; margin: 0 0 8px; }
p { margin: 0 0 8px; }
a { color: var(--primary-text); }
.muted { color: var(--muted); font-size: 12px; }
.faint { color: var(--faint); font-size: 12px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 12px 16px; position: sticky; top: 0; z-index: 10;
}
.brand { font-size: 16px; font-weight: 700; white-space: nowrap; }
.brand small { color: var(--muted); font-weight: 400; font-size: 12px; }
.topbar nav { display: flex; gap: 6px; }
.topbar .spacer { flex: 1; }
.user-chip { font-size: 12px; color: var(--muted); }

/* ---------- 布局 ---------- */
.page { max-width: 1080px; margin: 0 auto; padding: 12px; }
.page-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.page-head h1 { flex: 1; }
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; margin-bottom: 12px;
}
/* 设置页分组标题（服务器管理 / 系统设置 / 账户管理） */
.set-group { font-size: 14px; color: var(--muted); margin: 20px 0 8px; }
.set-group:first-of-type { margin-top: 0; }
/* 设置页服务器列表行：名字 + 状态 + 操作，手机上换行不重叠 */
.host-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 0; border-top: 1px solid var(--border); }
.host-row:first-child { border-top: 0; padding-top: 0; }
.host-row .hr-name { font-weight: 600; overflow-wrap: anywhere; }
.host-row .hr-meta { color: var(--muted); font-size: 12px; }
.host-row .hr-spacer { flex: 1; }
.host-row .hr-actions { display: flex; gap: 6px; flex-wrap: wrap; }
/* 复选框行：框与文字同一行 */
.field label.check { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.field label.check input { width: auto; margin: 0; }
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; }

/* ---------- 按钮三级体系 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 44px; padding: 0 16px; border-radius: 8px; border: 1px solid transparent;
  font-size: 14px; cursor: pointer; background: transparent; color: var(--text);
  white-space: nowrap; text-decoration: none;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--secondary-bg); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: #E5E7EB; }
.btn-tertiary { background: transparent; color: var(--muted); height: 36px; padding: 0 10px; }
.btn-tertiary:hover:not(:disabled) { color: var(--text); background: var(--secondary-bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-sm { height: 36px; padding: 0 12px; font-size: 13px; }

/* 选择器：8px 圆角方形，绝不 999px */
.selector {
  display: inline-flex; align-items: center; gap: 0;
  border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden;
  background: var(--card);
}
.selector button {
  border: 0; background: transparent; color: var(--text);
  padding: 0 12px; height: 36px; font-size: 13px; cursor: pointer;
}
.selector button + button { border-left: 1px solid var(--border); }
.selector button.active { background: var(--primary-light); color: var(--primary-text); font-weight: 600; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; height: 44px; padding: 0 12px; font-size: 14px; color: var(--text);
  background: #fff; border: 1px solid var(--border-strong); border-radius: 8px; outline: none;
}
.field textarea { height: auto; min-height: 88px; padding: 8px 12px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--input-focus-border);
  box-shadow: 0 0 0 3px var(--input-focus-ring);
}
.field .hint { font-size: 12px; color: var(--faint); margin-top: 4px; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; margin: 4px 0 8px; }
.err:empty { display: none; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: #fff; font-size: 13px;
  padding: 10px 16px; border-radius: 8px; z-index: 60; max-width: 90vw;
}

/* ---------- 状态徽章：颜色 + 文字 + 不同形状图标 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; padding: 2px 8px;
  border-radius: 8px; border: 1px solid; white-space: nowrap;
}
.badge .bi { font-style: normal; font-weight: 700; }
.badge-normal { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-border); }
.badge-warning { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.badge-critical { color: var(--crit); background: var(--crit-bg); border-color: var(--crit-border); }
.badge-offline { color: var(--off); background: var(--off-bg); border-color: var(--off-border); }

/* ---------- 总览：卡片布局（设计稿结构，配色 A） ----------
 * 一台机子一张卡片：4px 状态色顶栏 + 状态底色顶栏（名称 + 规格 +
 * 状态徽章）、CPU / 内存 / 磁盘三列（标签在上、大数值、6px 进度条，
 * 三列 flex:1 等分 + min-width:0，标签与数值永不互相覆盖——旧手机
 * 端表格 56px 固定列 + nowrap 就是这么挤重叠的）、底部网络 / Load /
 * 运行时间 / Agent 行；Swap / 磁盘 I/O / 进程 / Agent / 规格进默认
 * 收起的展开层。桌面端 ≥900px 两列网格；手机端单列。 */
.page.overview-page { max-width: 1320px; }
.page.overview-page .page-head {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px;
}
.live-ind { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ok); font-weight: 600; white-space: nowrap; }
.live-ind i { font-style: normal; font-size: 10px; }
/* 统计卡片：总数 / 正常 / 警告 / 异常（严重 + 离线），四张一行。 */
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; min-width: 0; }
.sc-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.sc-ico { font-style: normal; font-weight: 700; }
.sc-count { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.sc-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sc-total { color: var(--primary); }
.sc-ok { color: var(--ok); }
.sc-warn { color: var(--warn); }
.sc-crit { color: var(--crit); }
.sc-num { display: block; font-size: 28px; line-height: 1.25; font-weight: 700; font-variant-numeric: tabular-nums; }
.hosts-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 2px 8px; }
.hosts-head h2 { margin: 0; }
/* 服务器卡片网格：手机单列，桌面 ≥900px 两列。 */
.hosts-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .hosts-grid { grid-template-columns: 1fr 1fr; } }
.host-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; cursor: pointer; }
.host-card:hover { border-color: var(--border-strong); }
.hc-top { height: 4px; }
.st-normal .hc-top { background: var(--ok); }
.st-warning .hc-top { background: var(--warn); }
.st-critical .hc-top { background: var(--crit); }
.st-offline .hc-top { background: var(--off); }
.hc-head { display: flex; align-items: flex-start; gap: 8px; padding: 12px 12px 10px; }
.st-normal .hc-head { background: var(--ok-bg); }
.st-warning .hc-head { background: var(--warn-bg); }
.st-critical .hc-head { background: var(--crit-bg); }
.st-offline .hc-head { background: var(--off-bg); }
.hc-title { flex: 1; min-width: 0; }
.hc-name { display: block; font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hc-spec { font-size: 12px; color: var(--muted); margin-top: 2px; word-break: break-word; }
.hc-ip { cursor: pointer; }
.hc-ip:hover { color: var(--primary-text); text-decoration: underline; }
.hc-head .badge { flex-shrink: 0; margin-top: 2px; }
.expand-btn { background: transparent; border: 0; color: var(--muted); font-size: 14px; line-height: 1; padding: 6px 4px; cursor: pointer; transition: transform 150ms; flex-shrink: 0; }
.host-card.expanded .expand-btn { transform: rotate(180deg); }
/* 三列指标：等分、标签在上、大数值、6px 进度条。 */
.hc-metrics { display: flex; gap: 12px; padding: 12px; }
.hc-metric { flex: 1 1 0; min-width: 0; }
.hm-label { display: block; font-size: 12px; color: var(--muted); }
.hm-value-row { display: flex; align-items: baseline; gap: 4px; min-width: 0; }
.hm-value { flex-shrink: 0; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hm-mount { flex: 1; min-width: 0; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hc-metric .bar { height: 6px; margin-top: 6px; }
.hc-metric .bar > i { border-radius: 6px; }
/* 底部信息行：可换行，单项不换行；手机端运行时间另起一行。 */
.hc-foot { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 0 12px 12px; font-size: 12px; color: var(--muted); }
.hf-break { display: none; }
.hf-item { white-space: nowrap; }
.hf-item [data-field] { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
/* 展开层：默认收起，展开后一行或两行轻量信息 + 操作按钮。 */
.hc-extra { display: none; border-top: 1px solid var(--border); padding: 10px 12px; font-size: 12px; color: var(--muted); }
.hc-extra.open { display: block; }
.x-item + .x-item::before { content: "|"; margin: 0 8px; color: var(--faint); }
.x-item b { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.x-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.btn-xs { height: 28px; padding: 0 8px; font-size: 12px; }
/* 离线卡片：灰化 + 最后已知值，不用 0 冒充。 */
.host-card.offline { background: var(--sub-bg); }
.host-card.offline .hc-name, .host-card.offline .hm-value { color: var(--muted); }
.bar { height: 8px; background: var(--border); border-radius: 8px; overflow: hidden; margin-top: 4px; }
.bar > i { display: block; height: 100%; border-radius: 8px; background: var(--ok-bar); transition: none; }
.bar.warn > i { background: var(--warn-bar); }
.bar.crit > i { background: var(--crit-bar); }
.bar.off > i { background: var(--off-bar); transition: none; }
.empty { text-align: center; color: var(--muted); padding: 32px 12px; }

/* ---------- 详情 ---------- */
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.kv .k { font-size: 12px; color: var(--muted); }
.kv .v { font-size: 14px; font-weight: 600; }
.na {
  color: var(--muted); font-size: 13px; background: var(--sub-bg);
  border: 1px dashed var(--border-strong); border-radius: 8px; padding: 8px 12px;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 12px; font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.stat-num { font-size: 20px; font-weight: 700; }
.range-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ---------- 详情：历史曲线（静态，不跳动；方案 §7/§15/§16） ---------- */
.page.detail-page { max-width: 1440px; }
.tab-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.tab-bar .selector { max-width: 100%; overflow-x: auto; }
.si-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; }
.si-head h2 { margin: 0; }
.si-chevron { color: var(--muted); font-size: 14px; flex-shrink: 0; }
.si-group { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.si-group:first-of-type { border-top: 0; padding-top: 0; margin-top: 8px; }
.si-group h3 { font-size: 13px; color: var(--muted); margin: 0 0 8px; font-weight: 600; }
.si-full { font-size: 14px; font-weight: 500; margin-bottom: 8px; word-break: break-word; }
.si-group .kv .k { font-size: 12px; color: var(--muted); }
.si-group .kv .v { font-size: 14px; font-weight: 500; }
.chart-wrap { position: relative; margin-top: 8px; }
.chart-svg { width: 100%; height: 170px; display: block; }
@media (min-width: 641px) { .chart-svg { height: 200px; } }
.chart-tip {
  position: absolute; display: none; background: var(--text); color: #fff;
  font-size: 12px; line-height: 1.6; padding: 6px 8px; border-radius: 8px;
  pointer-events: none; z-index: 5; white-space: nowrap; max-width: 90%;
}
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.legend-item i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; }
.legend-item[data-key] { cursor: pointer; }
.legend-item.off { opacity: .45; }
.legend-item.off .legend-label { text-decoration: line-through; }

/* ---------- 登录 ---------- */
.auth-wrap { max-width: 420px; margin: 48px auto 0; }
.auth-wrap .card { padding: 16px; }
.auth-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.code-row { display: flex; gap: 6px; }
.code-row .field { flex: 1; margin-bottom: 0; }

/* ---------- 弹窗 ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(52, 64, 84, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 24px 12px; z-index: 50; overflow-y: auto;
}
.modal { background: var(--card); border-radius: var(--radius); padding: 16px; width: 100%; max-width: 560px; }
.modal h2 { margin-bottom: 12px; }
.steps { display: flex; gap: 6px; margin-bottom: 12px; }
.steps span {
  flex: 1; text-align: center; font-size: 12px; color: var(--muted);
  padding: 6px 4px; border-radius: 8px; background: var(--sub-bg); border: 1px solid var(--border);
}
.steps span.active { background: var(--primary-light); color: var(--primary-text); border-color: var(--primary-border); font-weight: 600; }
.cmd-box {
  background: var(--sub-bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; word-break: break-all; font-size: 12px; white-space: pre-wrap;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 12px; flex-wrap: wrap; }

/* ---------- 手机端 ---------- */
@media (max-width: 640px) {
  body { font-size: 13px; }
  .page { padding: 8px; }
  .btn-primary { width: 100%; }
  .topbar { padding: 8px 12px; }
  .user-chip { display: none; }
  .auth-wrap { margin-top: 24px; }
  /* 统计卡片四张一行：收紧内边距、间距与字号，360px 屏也放得下
   * （标签行现在带数量，如“10 台总机器”）。 */
  .stat-cards { gap: 6px; }
  .stat-card { padding: 8px 6px; }
  .sc-label { font-size: 10px; gap: 3px; }
  .sc-num { font-size: 24px; }
  /* 卡片底部：运行时间另起一行，Agent 跟在它后面。 */
  .hf-break { display: block; flex-basis: 100%; height: 0; }
}
