:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #15803d;
  --green-bg: #dcfce7;
  --red: #b91c1c;
  --red-bg: #fee2e2;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --gray-bg: #f3f4f6;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 14px;
}

.topbar {
  background: #111827;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 56px;
}
.brand { font-size: 17px; font-weight: 600; letter-spacing: .5px; }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a {
  color: #d1d5db;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 6px;
}
.topbar nav a:hover { background: #1f2937; color: #fff; }
.topbar nav a.active { background: var(--blue); color: #fff; }

main { max-width: 1280px; margin: 0 auto; padding: 24px; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 16px;
}
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 28px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}
.card .label { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.card .value { font-size: 26px; font-weight: 600; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  margin-top: 16px;
  overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  white-space: nowrap;
}
th { color: var(--muted); font-weight: 600; font-size: 12px; background: #fafafa; }
tr:last-child td { border-bottom: none; }
td.wrap { white-space: normal; min-width: 220px; }

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--gray-bg);
  color: var(--muted);
}
.badge.ok { background: var(--green-bg); color: var(--green); }
.badge.error { background: var(--red-bg); color: var(--red); }
.badge.warn { background: var(--amber-bg); color: var(--amber); }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }
.flash.ok { background: var(--green-bg); color: var(--green); }
.flash.error { background: var(--red-bg); color: var(--red); }

.btn {
  display: inline-block;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
}
.btn:hover { background: #f9fafb; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.danger { color: var(--red); border-color: #fecaca; }
.btn.danger:hover { background: var(--red-bg); }
.btn.small { padding: 4px 8px; font-size: 12px; }

form.inline { display: inline; }

.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--muted); }
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
  background: #fff;
  color: var(--text);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--blue); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.form-actions { margin-top: 20px; display: flex; gap: 10px; }

.log {
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px;
  border-radius: 10px;
  overflow: auto;
  max-height: 70vh;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.notice { padding: 12px 14px; border-radius: 8px; background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; margin-bottom: 16px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 6px; }
.empty { text-align: center; color: var(--muted); padding: 28px; }

.topbar .logout {
  margin-left: auto;
  color: #d1d5db;
  text-decoration: none;
  font-size: 13px;
}
.topbar .logout:hover { color: #fff; }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111827;
}
.login-card {
  width: 320px;
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, .3);
}
.login-card h1 { font-size: 20px; margin: 0; }
.login-card .hint { margin: 0; }
.login-card input { width: 100%; }
.login-card button {
  border: 0;
  background: var(--blue);
  color: #fff;
  padding: 10px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}
.login-card button:hover { background: var(--blue-dark); }
