:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --line: #e6eaf0;
  --text: #1f2937;
  --muted: #8b93a1;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --ok: #16a34a;
  --warn: #f59e0b;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 6px 20px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

code { background: #eef2f7; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ---------- 登录页 ---------- */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 55%, #38bdf8 100%);
}
.login-card {
  width: 360px; background: #fff; padding: 38px 34px 32px; border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .25); text-align: center;
}
.login-logo { font-size: 40px; }
.login-card h1 { font-size: 21px; margin: 10px 0 4px; }
.login-sub { color: var(--muted); margin: 0 0 22px; font-size: 13px; }
.login-card .field { text-align: left; }
.login-err { color: var(--danger); font-size: 13px; min-height: 20px; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; height: 60px; background: #0f172a; color: #fff;
}
.brand { font-size: 17px; font-weight: 600; letter-spacing: .3px; }
.brand-icon { margin-right: 6px; }
.top-right { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.chip { background: rgba(255, 255, 255, .12); padding: 4px 11px; border-radius: 20px; }
.user { opacity: .85; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 22px 26px 60px; }

/* ---------- 统计卡 ---------- */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.stat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); border-left: 4px solid var(--primary);
}
.stat-card.ok { border-left-color: var(--ok); }
.stat-card.warn { border-left-color: var(--warn); }
.stat-card.danger { border-left-color: var(--danger); }
.stat-card.muted { border-left-color: #9ca3af; }
.stat-num { font-size: 26px; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 2px; }

.banner {
  margin-top: 16px; padding: 11px 16px; border-radius: 10px;
  background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; font-size: 13px;
}

/* ---------- 标签页 ---------- */
.tabs { display: flex; gap: 6px; margin: 20px 0 12px; }
.tab {
  border: none; background: transparent; padding: 8px 16px; border-radius: 8px;
  cursor: pointer; font-size: 14px; color: #64748b;
}
.tab.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: var(--shadow); }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- 工具栏 ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.spacer { flex: 1; }
.search {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px;
  font-size: 13px; outline: none; background: #fff; min-width: 150px;
}
.search:focus { border-color: var(--primary); }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; transition: .15s;
}
.btn:hover { background: #f3f6fb; border-color: #cfd8e3; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-ghost { border-color: transparent; background: transparent; color: inherit; }
.btn-ghost:hover { background: rgba(125, 137, 156, .14); }
.btn-block { width: 100%; padding: 10px; font-size: 15px; margin-top: 12px; }
.btn-mini { padding: 4px 9px; font-size: 12px; }
.btn-danger { color: var(--danger); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; padding: 11px 14px; background: #f8fafc; color: #64748b;
  font-weight: 600; white-space: nowrap; border-bottom: 1px solid var(--line);
}
.table td { padding: 11px 14px; border-bottom: 1px solid #f1f4f8; vertical-align: middle; }
.table tr:hover td { background: #fbfcfe; }
.ta-r { text-align: right; }
.empty { text-align: center; color: var(--muted); padding: 40px 0 !important; }
.host { font-weight: 600; cursor: pointer; color: var(--text); }
.host:hover { color: var(--primary); text-decoration: underline; }
.remark { color: var(--muted); font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }

/* 拖拽排序 */
.drag-handle { cursor: grab; color: #c0c8d4; font-size: 16px; width: 28px; text-align: center; user-select: none; padding: 6px 2px; }
.drag-handle:hover { color: var(--primary); }
tr[draggable="true"] { transition: background 0.15s; }
tr.dragging { opacity: 0.5; background: #eef3ff; box-shadow: 0 4px 12px rgba(37,99,235,.15); }
tr[draggable="true"]:hover td:not(.drag-handle) { background: #fbfcfe; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; color: #fff; white-space: nowrap; }
.badge.ok { background: var(--ok); }
.badge.warning { background: var(--warn); }
.badge.expired { background: var(--danger); }
.badge.error { background: #6b7280; }
.badge.unknown { background: #cbd5e1; color: #475569; }

.days-warn { color: var(--warn); font-weight: 700; }
.days-danger { color: var(--danger); font-weight: 700; }
.days-ok { color: var(--ok); font-weight: 600; }

/* 开关 */
.toggle { position: relative; display: inline-block; width: 38px; height: 21px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span {
  position: absolute; inset: 0; background: #cbd5e1; border-radius: 21px; transition: .2s; cursor: pointer;
}
.toggle span::before {
  content: ""; position: absolute; width: 15px; height: 15px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .2s;
}
.toggle input:checked + span { background: var(--primary); }
.toggle input:checked + span::before { transform: translateX(17px); }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; padding: 22px; }
.form-section h3 { margin: 0 0 14px; font-size: 15px; }
.form-section.full, .form-actions.full { grid-column: 1 / -1; }
.field { display: block; margin-bottom: 15px; }
.field > span { display: block; font-size: 13px; color: #4b5563; margin-bottom: 6px; }
.field input[type=text], .field input[type=password], .field input[type=number], .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; outline: none; font-family: inherit; background: #fff;
}
.field input:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .1); }
.field small { display: block; color: var(--muted); font-size: 12px; margin-top: 5px; }
.inline { display: flex; align-items: center; gap: 8px; }
.inline input { width: 84px !important; }
.inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.switch-row { display: flex; align-items: center; gap: 9px; margin-bottom: 15px; font-size: 13px; cursor: pointer; }
.switch-row input { width: 16px; height: 16px; accent-color: var(--primary); }
.form-actions { display: flex; gap: 10px; }

/* ---------- 弹窗 ---------- */
[hidden] { display: none !important; }
.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-card { background: #fff; width: 560px; max-width: 94vw; border-radius: 14px; padding: 24px; box-shadow: 0 24px 60px rgba(0, 0, 0, .3); }
.modal-card h3 { margin: 0 0 18px; font-size: 17px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* ---------- 抽屉 ---------- */
.drawer { position: fixed; inset: 0; z-index: 60; }
.drawer-mask { position: absolute; inset: 0; background: rgba(15, 23, 42, .35); }
.drawer-card {
  position: absolute; right: 0; top: 0; bottom: 0; width: 560px; max-width: 96vw;
  background: #fff; box-shadow: -8px 0 30px rgba(0, 0, 0, .15); display: flex; flex-direction: column;
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h3 { margin: 0; font-size: 16px; }
.drawer-body { padding: 18px 20px; overflow-y: auto; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.drawer-body h4 { margin: 22px 0 10px; font-size: 14px; }
.log-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.log-table th, .log-table td { padding: 7px 8px; border-bottom: 1px solid #f1f4f8; text-align: left; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 11px 20px; border-radius: 10px;
  font-size: 13px; z-index: 80; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); max-width: 80vw;
}
.toast.err { background: #b91c1c; }
.toast.ok { background: #15803d; }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .form-grid, .inline-fields { grid-template-columns: 1fr; }
}

/* 编辑弹窗 */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.modal-box {
  background: var(--card); border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.2); width: 420px; max-width: 90vw;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.modal-header h3 { margin: 0; font-size: 15px; }
.modal-close {
  background: none; border: none; font-size: 22px; cursor: pointer;
  color: var(--muted); line-height: 1; padding: 0 2px;
}
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.modal-body label { font-size: 13px; font-weight: 600; color: var(--text); }
.modal-body input {
  width: 100%; padding: 9px 12px; border: 1px solid #d1d5db; border-radius: 8px;
  font-size: 14px; outline: none; transition: border-color .2s;
}
.modal-body input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--line);
}
