:root {
  --primary: #1e6bff;
  --primary-dark: #1557d6;
  --primary-soft: #eaf1ff;
  --up: #22a06b;
  --warn: #f59f00;
  --down: #e5484d;
  --muted: #6b7686;
  --text: #1f2633;
  --line: #e6e9ef;
  --bg: #f4f6fa;
  --card: #fff;
  --side: #0f1b33;
  --radius: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #f1f3f7; padding: 1px 5px; border-radius: 4px; font-size: 12px; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }

/* 布局 */
.layout { display: flex; min-height: 100vh; }
.side { width: 210px; background: var(--side); color: #c9d3e6; flex: none; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.logo { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; font-weight: 600; font-size: 16px; }
.side nav { flex: 1; padding: 6px 10px; overflow-y: auto; }
.side nav a { display: block; color: #c9d3e6; padding: 9px 12px; border-radius: 6px; margin-bottom: 2px; }
.side nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; }
.side nav a.active { background: var(--primary); color: #fff; }
.side-foot { padding: 12px 18px; font-size: 12px; color: #7f8ba3; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 56px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 20px; gap: 12px; position: sticky; top: 0; z-index: 20; }
.topbar h2 { margin: 0; font-size: 17px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-right { display: flex; align-items: center; gap: 10px; }
.menu-btn { display: none; }
.banner { background: #fff7e6; color: #8a5a00; padding: 8px 20px; border-bottom: 1px solid #ffe2a8; }
.content { padding: 20px; max-width: 1400px; width: 100%; }
.side-mask { display: none; }

/* 通用组件 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; border: 1px solid #d5dbe5; background: #fff; color: var(--text); border-radius: 6px; padding: 7px 14px; font-size: 14px; cursor: pointer; line-height: 1.3; white-space: nowrap; font-family: inherit; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-danger { color: var(--down); border-color: #f3c3c4; }
.btn-danger:hover { background: var(--down); color: #fff; border-color: var(--down); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-link { border: 0; background: none; color: var(--primary); padding: 2px 4px; cursor: pointer; font-size: 13px; font-family: inherit; }
.btn-link.danger { color: var(--down); }
.btn-block { width: 100%; }
.icon-btn { border: 0; background: none; font-size: 20px; cursor: pointer; padding: 4px 8px; color: var(--text); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.card h3 { margin: 0 0 12px; font-size: 15px; display: flex; align-items: center; gap: 8px; justify-content: space-between; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 26px; line-height: 1.2; }
.stat span { color: var(--muted); font-size: 13px; }
.stat.up b { color: var(--up); }
.stat.down b { color: var(--down); }
.stat.warn b { color: var(--warn); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.toolbar input, .toolbar select { width: auto; min-width: 120px; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: #f8f9fc; font-weight: 600; color: #4a5568; font-size: 13px; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td .sub { color: var(--muted); font-size: 12px; word-break: break-all; }
.actions { white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 36px 12px; }
.loading { text-align: center; color: var(--muted); padding: 40px; }
.error-box { background: #fdecec; color: #a1262a; border: 1px solid #f6c5c6; border-radius: 6px; padding: 12px 14px; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: #eef0f4; color: #556070; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.up { background: #e6f6ee; color: var(--up); }
.badge.down { background: #fdecec; color: var(--down); }
.badge.warn { background: #fff4e0; color: #c07a00; }
.badge.paused, .badge.pending, .badge.error { background: #eef0f4; color: #7a8494; }
.chip { display: inline-block; font-size: 12px; padding: 0 7px; border-radius: 4px; background: var(--primary-soft); color: var(--primary); margin: 1px 3px 1px 0; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.tabs { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.tabs button { border: 0; background: #fff; padding: 5px 12px; cursor: pointer; font-size: 13px; font-family: inherit; }
.tabs button.on { background: var(--primary); color: #fff; }
.chart-box { width: 100%; overflow: hidden; }
.chart-box svg { width: 100%; height: auto; display: block; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 8px 0; border-bottom: 1px dashed var(--line); display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.list li:last-child { border-bottom: 0; }
.lv { font-size: 12px; padding: 0 6px; border-radius: 4px; white-space: nowrap; }
.lv-critical { background: #fdecec; color: var(--down); }
.lv-warning { background: #fff4e0; color: #c07a00; }
.lv-success { background: #e6f6ee; color: var(--up); }
.lv-info { background: var(--primary-soft); color: var(--primary); }
.diff { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; font-size: 13px; }
.diff div { padding: 2px 0; word-break: break-all; }
.diff .add { color: #11734b; }
.diff .add::before { content: "+ "; }
.diff .del { color: #a1262a; text-decoration: line-through; }
.diff .del::before { content: "- "; }
.score { font-size: 32px; font-weight: 700; }
.pass { color: var(--up); }
.fail { color: var(--down); }
.warn-text { color: #c07a00; }
h4 { margin: 10px 0 6px; font-size: 13px; }
.item-row { display: grid; grid-template-columns: 24px 1fr 1fr; gap: 8px; align-items: center; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.item-row input[type=text] { margin: 0; }
.embed { font-size: 12px; background: #f6f8fb; border: 1px solid var(--line); border-radius: 6px; padding: 8px; word-break: break-all; }

/* 表单 */
label { display: block; margin-bottom: 12px; font-size: 13px; color: #4a5568; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; border: 1px solid #d5dbe5; border-radius: 6px; padding: 7px 10px; font: inherit; color: var(--text); background: #fff; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30, 107, 255, .12); }
input[type=checkbox], input[type=radio] { display: inline-block; width: auto; margin: 0 6px 0 0; vertical-align: -2px; }
label.check { display: inline-flex; align-items: center; margin-right: 14px; color: var(--text); }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.form-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.hint { color: var(--muted); font-size: 12px; margin: -6px 0 12px; }
.form-error { color: var(--down); min-height: 20px; margin: 0 0 8px; font-size: 13px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px 4px; margin: 0 0 14px; }
legend { padding: 0 6px; font-weight: 600; font-size: 14px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* 弹窗 / 提示 */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 27, 51, .45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 12px; z-index: 100; overflow-y: auto; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 560px; box-shadow: 0 10px 40px rgba(0, 0, 0, .2); }
.modal.wide { max-width: 820px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 16px 18px; max-height: calc(100vh - 200px); overflow-y: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast { background: #1f2633; color: #fff; padding: 10px 16px; border-radius: 6px; box-shadow: 0 4px 14px rgba(0, 0, 0, .2); font-size: 14px; max-width: 380px; word-break: break-word; }
.toast.ok { background: #138a5a; }
.toast.err { background: #c8343a; }

/* 登录页 */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0f1b33, #1e3f8a); padding: 16px; }
.login-box { background: #fff; border-radius: 12px; padding: 30px 28px 18px; width: 100%; max-width: 380px; box-shadow: 0 16px 50px rgba(0, 0, 0, .3); }
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }
.login-brand h1 { margin: 0; font-size: 20px; }
.login-brand p { margin: 0; color: var(--muted); font-size: 12px; }
.login-tip { color: var(--muted); font-size: 12px; margin: 14px 0 0; }
.login-foot { text-align: center; color: #9aa4b2; font-size: 12px; margin: 14px 0 0; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
  .side { position: fixed; left: 0; top: 0; bottom: 0; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .side-mask.open { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 50; }
  .menu-btn { display: inline-block; }
  .topbar { padding: 0 10px; }
  .content { padding: 12px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-3, .form-row, .form-row.three { grid-template-columns: 1fr; }
  .modal-mask { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; max-width: none; }
  .modal-body { max-height: none; }
  .toolbar input, .toolbar select { flex: 1 1 140px; }
  .kv { grid-template-columns: 90px 1fr; }
  th, td { padding: 8px; }
}
