:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #1f2430;
  --muted: #7a8394;
  --line: #e3e8ef;
  --brand: #2f6bff;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 10px;
}

* { box-sizing: border-box; }

/* hidden 属性必须压过下面那些 display:flex 的规则，否则弹窗和顶部栏关不掉 */
[hidden] { display: none !important; }

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

a { color: var(--brand); text-decoration: none; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }

.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 0 20px; height: 56px;
  background: #10182b; color: #fff;
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; letter-spacing: .3px; }
.brand span { font-weight: 400; color: #93a4c8; margin-left: 8px; font-size: 13px; }
.nav { display: flex; gap: 4px; }
.nav a {
  color: #c3cee5; padding: 6px 12px; border-radius: 8px; font-size: 13px;
}
.nav a:hover { background: #1b2740; color: #fff; }
.nav a.active { background: #24345a; color: #fff; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar-right .muted { color: #8ea0c0; font-size: 12px; }

.view { max-width: 1180px; margin: 0 auto; padding: 22px 20px 60px; }

h2 { margin: 0 0 16px; font-size: 20px; }
h3 { margin: 0; font-size: 15px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer;
}
.card:hover { border-color: #c8d4ea; }
.card .label { color: var(--muted); font-size: 12px; }
.card .value { font-size: 24px; font-weight: 700; margin-top: 4px; }
.card.warn .value { color: var(--warn); }
.card.ok .value { color: var(--ok); }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
}

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }

input, select, textarea {
  font: inherit; color: inherit; background: #fff;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
input[readonly] { background: #f7f9fc; }
textarea { width: 100%; min-height: 84px; resize: vertical; }

.btn {
  font: inherit; cursor: pointer; border-radius: 8px; padding: 8px 14px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
}
.btn:hover { border-color: #c8d4ea; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #2559e0; }
.btn.danger { color: var(--danger); border-color: #f3c6c6; }
.btn.ghost { background: transparent; border-color: transparent; color: inherit; }
.topbar .btn.ghost { color: #c3cee5; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
tr.clickable:hover td { background: #f8fafd; cursor: pointer; }

.tag {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px;
  background: #eef2f9; color: #4a5670; margin-right: 4px;
}
.tag.ok { background: #e8f7ee; color: var(--ok); }
.tag.warn { background: #fdf3e3; color: var(--warn); }
.tag.danger { background: #fdeaea; color: var(--danger); }

.empty { padding: 40px; text-align: center; color: var(--muted); }

/* 破坏性操作的提示块 */
.warn-box {
  background: #fdeaea;
  border: 1px solid #f3c6c6;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #7f1d1d;
}
.warn-box p { margin: 0 0 6px; }
.warn-box ul { margin: 0; padding-left: 18px; }
.warn-box li { word-break: break-all; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16, 24, 43, .45);
  display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; z-index: 20;
}
.modal {
  background: #fff; border-radius: 12px; width: 100%; max-width: 640px;
  max-height: 80vh; display: flex; flex-direction: column; overflow: hidden;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 18px; overflow: auto; }

.form-row { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.form-row > label { flex: 1; min-width: 160px; display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }

.code-box { display: flex; gap: 8px; align-items: flex-start; }
.code-box textarea { font-family: ui-monospace, Consolas, monospace; font-size: 12px; min-height: 120px; }

.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 30; }
.toast {
  background: #10182b; color: #fff; padding: 10px 14px; border-radius: 8px;
  font-size: 13px; max-width: 360px; box-shadow: 0 6px 20px rgba(16,24,43,.25);
}
.toast.err { background: #7f1d1d; }

.login-wrap { max-width: 360px; margin: 12vh auto 0; }
.login-wrap .panel { padding: 24px; }
.login-wrap h2 { margin-bottom: 6px; }
dl.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: 12px; }
dl.kv dd { margin: 0; word-break: break-all; }
