/* NewapiMonitor 前端样式 —— 商务风、干净专业。
   配色取自 dataviz 技能的“已验证参考调色板”（对色盲友好、对比达标）。
   只做浅色一版；业务/计算逻辑全在后端，改样式不影响数据。 */

:root {
  /* 画面 / 卡片 / 墨色 */
  --page: #f4f5f7;
  --surface: #ffffff;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --hairline: #e4e6ea;
  --ring: rgba(11, 11, 11, 0.08);
  /* 品牌 / 强调（categorical slot1 blue）*/
  --brand: #2a78d6;
  --brand-ink: #184f95;
  /* 侧栏（深色）*/
  --nav-bg: #14203a;
  --nav-ink: #c9d2e0;
  --nav-ink-strong: #ffffff;
  --nav-active: #2a78d6;
  /* 类别色（固定顺序，供图表/指标）*/
  --c-req: #2a78d6;      /* 请求量 蓝 */
  --c-success: #1baf7a;  /* 成功 aqua */
  --c-429: #eda100;      /* 429 黄 */
  --c-5xx: #e34948;      /* 5xx 红 */
  --c-timeout: #eb6834;  /* 超时 橙 */
  --c-fail: #e34948;     /* 失败 红 */
  /* 状态色（保留，不当类别用）*/
  --good: #0ca30c;
  --good-ink: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.05);
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--page); color: var(--ink); font-size: 14px; line-height: 1.5; }

a { color: var(--brand); text-decoration: none; }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------- 登录页 ---------- */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: linear-gradient(160deg, #14203a 0%, #23324f 60%, #2a3b5c 100%);
}
.login-card {
  width: 360px; background: var(--surface); border-radius: 14px; padding: 32px 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35); display: flex; flex-direction: column; gap: 16px;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.login-logo {
  width: 44px; height: 44px; border-radius: 10px; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; letter-spacing: .5px;
}
.login-title { font-size: 18px; font-weight: 700; }
.login-sub { font-size: 12px; color: var(--muted); }
.login-error {
  background: #fdecec; color: var(--critical); border: 1px solid #f5c6c6;
  padding: 8px 10px; border-radius: 8px; font-size: 13px;
}
.login-foot { text-align: center; font-size: 12px; color: var(--muted); margin-top: 2px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; color: var(--ink-2); font-weight: 600; }
input, select {
  font: inherit; padding: 9px 11px; border: 1px solid var(--hairline); border-radius: 8px;
  background: #fff; color: var(--ink); outline: none;
}
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(42, 120, 214, 0.15); }

/* ---------- 按钮 ---------- */
.btn {
  font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--hairline);
  background: #fff; color: var(--ink); cursor: pointer; transition: all .12s ease;
}
.btn:hover { background: #f3f4f6; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); }
.btn-danger { background: var(--critical); border-color: var(--critical); color: #fff; }
.btn-danger:hover { filter: brightness(0.92); }
.btn-block { width: 100%; padding: 10px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 13px; }

/* ---------- 布局 ---------- */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 216px; flex-shrink: 0; background: var(--nav-bg); color: var(--nav-ink);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { padding: 20px 20px 16px; display: flex; align-items: center; gap: 10px; }
.sidebar-logo {
  width: 34px; height: 34px; border-radius: 8px; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.sidebar-title { color: var(--nav-ink-strong); font-weight: 700; font-size: 15px; }
.sidebar-title small { display: block; color: var(--nav-ink); font-weight: 400; font-size: 11px; }
.nav { list-style: none; margin: 8px 0; padding: 0; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: var(--nav-ink);
  font-weight: 500; border-left: 3px solid transparent;
}
.nav a:hover { background: rgba(255, 255, 255, 0.05); color: var(--nav-ink-strong); }
.nav a.active { background: rgba(42, 120, 214, 0.18); color: #fff; border-left-color: var(--nav-active); }
.nav .nav-ico { width: 18px; text-align: center; opacity: .9; }
.sidebar-foot { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,0.08); font-size: 12px; color: var(--nav-ink); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; background: var(--surface); border-bottom: 1px solid var(--hairline);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 5;
}
.topbar-title { font-size: 17px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 14px; color: var(--ink-2); font-size: 13px; }
.content { padding: 22px 24px 40px; }

/* ---------- 卡片 / 网格 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 12px;
  box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px;
}
.card-title { font-size: 14px; font-weight: 700; margin: 0 0 14px; color: var(--ink); }
.card-title small { font-weight: 400; color: var(--muted); margin-left: 6px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 12px;
  box-shadow: var(--shadow); padding: 16px 18px; display: flex; flex-direction: column; gap: 6px;
}
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 30px; font-weight: 700; line-height: 1.1; }
.kpi-sub { font-size: 12px; color: var(--ink-2); }
.kpi-accent { height: 3px; border-radius: 3px; margin-top: 4px; background: var(--brand); }
/* 分区小标题（概览页“核心指标”/“详细指标”等分组用）*/
.section-title { font-size: 14px; font-weight: 700; color: var(--ink); margin: 4px 0 12px; }

/* 工具条（时间范围/粒度切换等）*/
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--hairline); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: none; background: #fff; padding: 7px 13px; cursor: pointer; font: inherit; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--hairline); }
.seg button.active { background: var(--brand); color: #fff; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th, table.tbl td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--hairline); white-space: nowrap; }
table.tbl th:first-child, table.tbl td:first-child { text-align: left; }
table.tbl th { color: var(--muted); font-weight: 600; font-size: 12px; background: #fafbfc; position: sticky; top: 0; }
table.tbl tbody tr:hover { background: #f7f9fc; }

/* ---------- 徽章 / 状态 ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-good { background: #e6f6e6; color: var(--good-ink); }
.badge-warn { background: #fef3d8; color: #8a5a00; }
.badge-crit { background: #fdecec; color: var(--critical); }
.badge-muted { background: #eef0f3; color: var(--ink-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* 可用性大数字 */
.avail-hero { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.avail-pct { font-size: 60px; font-weight: 800; line-height: 1; }
.avail-pct.pass { color: var(--good-ink); }
.avail-pct.fail { color: var(--critical); }
.avail-verdict { font-size: 15px; font-weight: 700; padding: 6px 12px; border-radius: 8px; }
.avail-verdict.pass { background: #e6f6e6; color: var(--good-ink); }
.avail-verdict.fail { background: #fdecec; color: var(--critical); }

/* 图表容器 */
.chart-box { position: relative; height: 300px; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .chart-grid { grid-template-columns: 1fr; } }

/* 杂项 */
.muted { color: var(--muted); }
.loading { padding: 30px; text-align: center; color: var(--muted); }
.err { padding: 12px 14px; background: #fdecec; color: var(--critical); border: 1px solid #f5c6c6; border-radius: 8px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.pill-input { width: 120px; }
