:root {
  --bg: #f5f6f8; --card: #ffffff; --line: #e4e7ec; --text: #1f2430;
  --muted: #6b7280; --accent: #3556e0; --accent-soft: #eaefff;
  --ok: #16a34a; --warn: #d97706; --err: #dc2626;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }

#topbar {
  display: flex; align-items: center; gap: 20px;
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 0 24px; height: 52px; position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
#nav { display: flex; gap: 4px; }
#nav a {
  padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 500;
}
#nav a.active { background: var(--accent-soft); color: var(--accent); }
.spacer { flex: 1; }

#app { max-width: 1180px; margin: 24px auto; padding: 0 24px; }
h2 { font-size: 18px; margin: 0 0 16px; }
h3 { font-size: 14px; margin: 0 0 10px; color: var(--muted); }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px;
}
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.stat .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
th { color: var(--muted); font-weight: 500; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.err-text { color: var(--err); }
.ok-badge { color: var(--ok); }
.err-badge { color: var(--err); }

button {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 8px; padding: 6px 14px; cursor: pointer; font-size: 13px;
}
button:hover { border-color: var(--accent); color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { opacity: .9; color: #fff; }
button.ghost { border: none; background: none; color: var(--muted); }
button.ghost:hover { color: var(--accent); }
button.danger { color: var(--err); }
button.small { padding: 3px 8px; font-size: 12px; }
button:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
  font-size: 13px; font-family: inherit; background: #fff; color: var(--text);
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }

form .field { margin-bottom: 12px; }
form label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
form .row { display: flex; gap: 12px; }
form .row .field { flex: 1; }

.progress { background: var(--bg); border-radius: 6px; height: 8px; width: 130px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 6px; }
.progress.warn > div { background: var(--warn); }
.progress.full > div { background: var(--err); }

.chart { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 10px; }
.chart .bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.chart .bar { width: 100%; max-width: 42px; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; opacity: .85; }
.chart .bar-label { font-size: 10px; color: var(--muted); white-space: nowrap; }
.chart .bar-value { font-size: 10px; color: var(--text); }

dialog {
  border: none; border-radius: 12px; padding: 0; min-width: 380px; max-width: 560px; width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
dialog::backdrop { background: rgba(0,0,0,.35); }
#dlg-content { padding: 20px 22px; }
#dlg-content h3 { color: var(--text); font-size: 15px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

#toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: #23262f; color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 13px; z-index: 99; max-width: 70vw;
}
#toast.err { background: var(--err); }

.keybox {
  background: var(--bg); border: 1px dashed var(--line); border-radius: 8px;
  padding: 10px 12px; font-family: ui-monospace, Menlo, monospace; font-size: 13px;
  word-break: break-all; user-select: all;
}

.chip {
  display: inline-block; border: 1px solid var(--line); background: var(--bg);
  border-radius: 999px; padding: 3px 10px; margin: 0 6px 6px 0; font-size: 12px;
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

.helpbox {
  background: var(--bg); border: 1px dashed var(--line); border-radius: 8px;
  padding: 10px 12px; font-family: ui-monospace, Menlo, monospace; font-size: 12px;
  white-space: pre-wrap; word-break: break-all; user-select: all; margin: 4px 0 6px;
}
.help-title { font-size: 12px; color: var(--muted); margin-top: 10px; }

.run-badge { color: var(--warn); font-weight: 600; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.login-wrap { display: flex; justify-content: center; padding-top: 12vh; }
.login-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 36px 40px; width: 360px; text-align: center;
}
.login-card .logo { font-size: 26px; margin-bottom: 6px; }
.login-card p { color: var(--muted); margin: 0 0 22px; }
.login-card input { margin-bottom: 14px; text-align: center; }
.login-card button { width: 100%; padding: 9px; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar select, .toolbar input { width: auto; }
.toolbar .spacer { flex: 1; }

.pager { display: flex; align-items: center; gap: 12px; justify-content: flex-end; margin-top: 12px; color: var(--muted); font-size: 13px; }
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.filter-bar select, .filter-bar input:not([type="checkbox"]) { width: auto; min-width: 120px; }
.filter-bar input[type="checkbox"] { width: auto; min-width: 0; margin: 0; }
