:root {
  --bg: #0b1120;
  --panel: #111827;
  --panel-2: #1a2332;
  --border: #243047;
  --text: #e5edf8;
  --muted: #8494ad;
  --accent: #3b82f6;
  --accent-2: #6366f1;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
}

* { box-sizing: border-box; }

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

#app { display: flex; min-height: 100vh; }
.hidden { display: none !important; }

.sidebar {
  width: 220px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; gap: 10px; align-items: center; margin-bottom: 26px; padding: 0 6px; }
.logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px;
}
.brand-name { font-weight: 600; }
.brand-sub { color: var(--muted); font-size: 11px; }

nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
nav a {
  color: var(--muted); text-decoration: none; padding: 9px 12px;
  border-radius: 8px; transition: all .12s;
}
nav a:hover { background: var(--panel-2); color: var(--text); }
nav a.active { background: var(--accent); color: #fff; font-weight: 500; }

.content { flex: 1; padding: 30px 36px; overflow-x: auto; }
h1 { font-size: 22px; margin: 0 0 20px; }
h2 { margin: 0 0 6px; }
h3 { font-size: 15px; margin: 0 0 14px; font-weight: 600; }
.muted { color: var(--muted); }

.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.section-head h1 { margin: 0; }
.actions { display: flex; gap: 8px; }

button {
  font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid transparent;
  padding: 8px 16px; transition: all .12s;
}
.primary { background: var(--accent); color: #fff; }
.primary:hover { background: #2f74e0; }
.ghost { background: transparent; border-color: var(--border); color: var(--text); }
.ghost:hover { background: var(--panel-2); }
.ghost.danger { color: var(--red); border-color: #4a2530; }
.small { padding: 4px 10px; font-size: 12px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px 20px;
}
.stat .label { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.stat .value { font-size: 26px; font-weight: 600; }
.stat .value.green { color: var(--green); }
.stat .value.red { color: var(--red); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
tbody tr:hover { background: var(--panel-2); }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 500;
}
.badge.ok { background: rgba(34,197,94,.15); color: var(--green); }
.badge.err { background: rgba(239,68,68,.15); color: var(--red); }
.badge.warn { background: rgba(245,158,11,.15); color: var(--amber); }
.badge.off { background: rgba(132,148,173,.15); color: var(--muted); }

input, select {
  font: inherit; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
label { display: block; margin-bottom: 14px; }
label span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; }

.login-view { display: flex; align-items: center; justify-content: center; min-height: 80vh; }
.login-card { width: 340px; }
.login-card p { margin: 0 0 18px; font-size: 13px; }
.login-card button { width: 100%; margin-top: 6px; }
.error { color: var(--red); margin-top: 12px; font-size: 13px; }

/* Inline failure banner: keeps a pane from looking empty when its load fails. */
.load-error {
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.35);
  color: #fca5a5;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* Full-page standalone login */
.login-page {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #17243c 0%, var(--bg) 60%);
}
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 26px; }
.login-title { font-size: 18px; font-weight: 600; }
.login-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.login-page .login-card {
  width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 34px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.login-card label { margin-bottom: 20px; }
.login-btn { width: 100%; padding: 11px 0; font-size: 15px; }
.login-foot { margin-top: 18px; text-align: center; color: var(--muted); font-size: 12px; }

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 26px; width: 460px; max-height: 80vh; overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.qr-box { text-align: center; margin: 16px 0; }
.qr-box img { width: 200px; height: 200px; background: #fff; border-radius: 10px; padding: 8px; }
.link-box { word-break: break-all; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-size: 12px; color: var(--accent); }

.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4); z-index: 100; font-size: 13px;
}
.toast.err { border-color: #4a2530; color: #fca5a5; }

.settings-form label { max-width: 420px; }
.row { display: flex; gap: 14px; align-items: flex-end; }
.row > * { flex: 1; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; }
