:root {
  --bg: #0b1020;
  --panel: #141a33;
  --panel-2: #1b2444;
  --line: #2a3560;
  --text: #e8ecf8;
  --muted: #93a0c4;
  --accent: #5b8cff;
  --accent-2: #38d39f;
  --danger: #ff6b81;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 80% -10%, #1d2b5c 0%, transparent 60%), var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 22px clamp(16px, 4vw, 48px);
}
.topbar-right { display: flex; align-items: center; gap: 10px; }

/* 顶部导航：分区切换 */
.nav {
  display: flex; gap: 4px; padding: 4px; border-radius: 12px;
  background: #0e1530; border: 1px solid var(--line);
}
.nav-item {
  border: 0; background: transparent; padding: 8px 14px; border-radius: 9px;
  color: var(--muted); font-weight: 600; white-space: nowrap;
}
.nav-item:hover { background: #16224a; color: var(--text); transform: none; }
.nav-item[aria-current="page"] {
  background: linear-gradient(135deg, var(--accent), #7aa2ff); color: #08122b;
}

.view { display: contents; }
.view[hidden] { display: none; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
}
.badge.allow { background: rgba(56, 211, 159, .16); color: var(--accent-2); }
.badge.deny { background: rgba(255, 107, 129, .14); color: var(--danger); }

#acl-check-msg[data-action="allow"] { color: var(--accent-2); }
#acl-check-msg[data-action="deny"] { color: var(--danger); }

select {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: #0e1530; color: var(--text); font: inherit;
}
code {
  font: 12.5px/1.4 ui-monospace, "Cascadia Code", Consolas, monospace;
  color: #cfe0ff;
}
code.truncate {
  display: inline-block; max-width: 340px; white-space: normal;
  overflow-wrap: anywhere; vertical-align: middle;
  user-select: all;
}
.copy-box {
  width: 100%; resize: vertical; min-height: 76px;
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: #0a1128; color: var(--text);
  font: 12.5px/1.5 ui-monospace, "Cascadia Code", Consolas, monospace;
  overflow-wrap: anywhere;
}

@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
}

.login {
  min-height: 100vh; display: grid; place-items: center;
  padding: 24px;
}
.login-card { width: min(420px, 100%); display: grid; gap: 14px; }
.login-card .brand { margin-bottom: 6px; }
#bind-view .login-card { width: min(460px, 100%); }
.qr-wrap {
  display: grid; place-items: center; gap: 6px;
  padding: 12px; border-radius: 12px; background: #0e1530; border: 1px solid var(--line);
}
.qr-wrap img { border-radius: 8px; background: #fff; padding: 6px; }
.captcha {
  display: grid; gap: 10px; padding: 12px; border-radius: 10px;
  border: 1px dashed var(--line); background: #0e1530;
}
.captcha .warn { margin: 0; }
.totp-bar {
  height: 4px; border-radius: 999px; overflow: hidden; background: #0a1128;
  border: 1px solid var(--line);
}
.totp-bar span {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width .25s linear;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #08122b; font-weight: 800; letter-spacing: .5px;
}
h1 { margin: 0; font-size: 20px; letter-spacing: .3px; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.status {
  padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
}
.status[data-state="ok"] { color: #0b1a12; background: var(--accent-2); border-color: transparent; }
.status[data-state="warn"] { color: #2a1a06; background: #ffc861; border-color: transparent; }
.status[data-state="error"] { color: #2a0a10; background: var(--danger); border-color: transparent; }

.layout {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  padding: 0 clamp(16px, 4vw, 48px) 48px;
  align-items: start;
}

.card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
  min-width: 0;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h2 { margin: 0; font-size: 16px; }
.hint, .muted { color: var(--muted); font-size: 12.5px; }

.form { display: grid; gap: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.field.grow { flex: 1 1 180px; }
input:not([type="checkbox"]) {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: #0e1530; color: var(--text); font: inherit;
}
input:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); padding-bottom: 10px; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
button, .primary, .ghost {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 10px;
  padding: 9px 16px; border: 1px solid var(--line); text-decoration: none;
  background: #0e1530; color: var(--text); transition: transform .06s ease, background .15s;
}
button:hover, .primary:hover, .ghost:hover { transform: translateY(-1px); background: #16224a; }
.primary { background: linear-gradient(135deg, var(--accent), #7aa2ff); color: #08122b; border: 0; }
.ghost { background: transparent; }
.link { display: inline-block; }
button[disabled] { opacity: .55; cursor: progress; transform: none; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
td.empty { color: var(--muted); text-align: center; padding: 22px; }
td .danger { color: var(--danger); background: transparent; border-color: var(--line); padding: 5px 10px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

dialog {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0;
  background: var(--panel); color: var(--text); width: min(680px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(4, 8, 20, .72); backdrop-filter: blur(3px); }
.dialog-form { padding: 22px; display: grid; gap: 12px; }
.dialog-form h2 { margin: 0; font-size: 17px; }
.code {
  margin: 0; padding: 14px; border-radius: 10px; background: #0a1128; border: 1px solid var(--line);
  overflow: auto; max-height: 42vh; font: 12.5px/1.5 ui-monospace, "Cascadia Code", Consolas, monospace;
}
.warn { color: #ffc861; font-size: 12.5px; margin: 0; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: #0e1530; border: 1px solid var(--line); color: var(--text);
  padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; max-width: min(560px, calc(100vw - 32px));
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: var(--danger); color: #ffd7de; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}