:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e2e6ec;
  --text: #1f2329;
  --text-dim: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #d97706;
  --code-bg: #f1f3f6;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #1a1d23;
    --border: #2a2f38;
    --text: #e6e8ec;
    --text-dim: #8a93a1;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --code-bg: #232830;
  }
}

* { box-sizing: border-box; }

/* 任何元素的 hidden 属性必须真正隐藏。
   login-wrap 有 display: flex,会覆盖 hidden 默认的 display: none,
   没这条规则的话登录后登录框会跟主面板一起显示。 */
[hidden] { display: none !important; }

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

/* ===== 登录 ===== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 420px;
}
.login-card h1 {
  margin: 0 0 8px;
  font-size: 20px;
}
.login-card .hint {
  margin: 0 0 16px;
  color: var(--text-dim);
  font-size: 13px;
}
.login-card label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.login-card input,
.login-card button {
  width: 100%;
  margin-bottom: 12px;
}

/* ===== 主面板 ===== */
.app-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
}
.app-header h1 {
  margin: 0;
  font-size: 20px;
}

/* ===== 通用卡片 ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}
.card h2 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
}

/* ===== 筛选条 ===== */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-dim);
}
.filters input,
.filters select,
.filters button {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.filters button {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  cursor: pointer;
  padding: 6px 16px;
}
.filters button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.status {
  font-size: 12px;
  color: var(--text-dim);
  margin-left: auto;
}

/* ===== 概览卡片行 ===== */
.cards-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}
.stat-card .label {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.stat-card .value {
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.stat-card.warn { border-left: 3px solid var(--warn); }
.stat-card.danger { border-left: 3px solid var(--danger); }

/* ===== 表格 ===== */
.table-scroll { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th {
  font-weight: 600;
  color: var(--text-dim);
  background: var(--bg);
  position: sticky;
  top: 0;
}
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--bg); }

/* 事件类型徽章 */
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}
.badge-web   { background: #dbeafe; color: #1d4ed8; }
.badge-ssh   { background: #fef3c7; color: #b45309; }
.badge-mysql { background: #fee2e2; color: #b91c1c; }
@media (prefers-color-scheme: dark) {
  .badge-web   { background: #1e3a8a; color: #bfdbfe; }
  .badge-ssh   { background: #78350f; color: #fde68a; }
  .badge-mysql { background: #7f1d1d; color: #fecaca; }
}

/* 错误态 */
.error {
  color: var(--danger);
  font-size: 13px;
  margin: 8px 0 0;
  min-height: 1em;
}

/* 分页 */
.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.pager { display: flex; gap: 8px; align-items: center; }
.pager button {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.pager button:disabled { opacity: 0.5; cursor: not-allowed; }
#pageInfo { font-size: 12px; color: var(--text-dim); }

/* 退出按钮 */
.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
}
.link-btn:hover { text-decoration: underline; }

code {
  background: var(--code-bg);
  padding: 1px 6px;
  border-radius: 3px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.9em;
}