:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #111827;
  --muted: #667085;
  --line: #e6eaf2;
  --primary: #1366d6;
  --primary-dark: #0d4fae;
  --green: #0a9e74;
  --amber: #b54708;
  --red: #c4320a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px -18px rgba(16, 24, 40, .35);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
h1, h2, h3 { margin: 0; font-weight: 650; }
h1 { font-size: 22px; letter-spacing: -.2px; }
h2 { font-size: 15px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 22px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #1366d6, #0a9e74);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .5px;
  box-shadow: 0 4px 12px -6px rgba(19, 102, 214, .7);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 14px; }
.brand-text small { color: var(--muted); font-size: 11px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a {
  color: var(--muted);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 13.5px;
}
.nav a:hover { color: var(--ink); background: #eef3fb; text-decoration: none; }
.nav a.active { color: var(--primary); background: #e8f0fe; font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar-right form { margin: 0; }
.who { color: var(--muted); font-size: 12.5px; }

.page {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
  flex: 1;
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-head p { margin: 4px 0 0; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.head-actions form { margin: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.card-actions form { margin: 0; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.grid-2 > .card { margin-bottom: 18px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat { margin: 0; padding: 16px 18px; }
.stat-label { color: var(--muted); font-size: 12.5px; }
.stat-value { font-size: 24px; font-weight: 700; letter-spacing: -.5px; margin-top: 4px; display: flex; align-items: center; gap: 8px; }
.stat-foot { color: var(--muted); font-size: 12px; margin-top: 2px; }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-on { background: var(--green); box-shadow: 0 0 0 4px rgba(10, 158, 116, .14); }
.dot-off { background: #98a2b3; box-shadow: 0 0 0 4px rgba(152, 162, 179, .16); }

.kv-list { display: flex; flex-direction: column; }
.kv {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13.5px;
}
.kv:last-child { border-bottom: 0; }
.kv > span:first-child { color: var(--muted); min-width: 110px; }
.kv code { background: #f3f6fb; padding: 2px 7px; border-radius: 6px; }
.kv code[data-copy] { cursor: pointer; }
.kv code[data-copy]:hover { background: #e5edfb; }

.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  background: #f8fafd;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td { padding: 11px 12px; border-bottom: 1px solid #f0f3f9; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcff; }
.actions-col { width: 1%; white-space: nowrap; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.8;
  white-space: nowrap;
}
.badge-on, .badge-active, .badge-connect { background: #e7f8f1; color: #067a5b; }
.badge-off, .badge-disabled, .badge-disconnect { background: #eef1f6; color: #475467; }
.badge-expiring { background: #fff4e5; color: var(--amber); }
.badge-expired, .badge-auth_fail, .badge-kick { background: #feeceb; color: var(--red); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 8px 14px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: .15s ease;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 14px -10px rgba(19, 102, 214, .8); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #fff; border-color: #d6deea; color: #344054; }
.btn-ghost:hover { background: #f5f8fd; border-color: #b9c6da; }
.btn-danger-ghost { background: #fff; border-color: #f3c0b8; color: var(--red); }
.btn-danger-ghost:hover { background: #fff5f4; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-xs { padding: 4px 9px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; }

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 13px; font-weight: 600; color: #344054; }
.field > span em { color: var(--red); font-style: normal; }
.field small { color: var(--muted); font-size: 12px; }
input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="date"], input[type="search"], select, textarea {
  width: 100%;
  border: 1px solid #d6deea;
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 13.5px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
  transition: .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(19, 102, 214, .12);
}
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.inline-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.inline-row input[type="date"] { width: auto; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.check input { width: 16px; height: 16px; margin: 0; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.form-card { max-width: none; }

.search { display: flex; gap: 6px; }
.search input { width: 210px; }
.filter-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter-form select, .filter-form input { width: auto; min-width: 120px; }

.callout {
  background: #f7f9fd;
  border: 1px solid #e3eaf5;
  border-radius: 10px;
  padding: 11px 13px;
  color: #475467;
  font-size: 12.5px;
}

.empty { text-align: center; padding: 28px 10px; color: var(--muted); }
.empty p { margin: 0 0 12px; }

.login-wrap { display: flex; justify-content: center; padding: 8vh 0 4vh; }
.login-card { width: 100%; max-width: 380px; padding: 28px 28px 26px; }
.login-head { text-align: center; margin-bottom: 18px; }
.login-head .brand-mark { width: 46px; height: 46px; font-size: 16px; margin-bottom: 12px; }
.login-head h1 { font-size: 20px; }
.login-head p { color: var(--muted); font-size: 12.5px; margin: 4px 0 0; }

.credentials { padding: 22px; }
.cred-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--line);
}
.cred-label { color: var(--muted); width: 76px; flex: none; font-size: 13px; }
.cred-value {
  background: #f2f7ff;
  border: 1px solid #dbe7fb;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 15px;
  letter-spacing: .4px;
  word-break: break-all;
  flex: 1;
}
.cred-hint { margin-top: 14px; color: var(--amber); background: #fff8ec; border: 1px solid #f6e2bf; border-radius: 9px; padding: 10px 12px; font-size: 12.5px; }

.log-box {
  background: #0d1420;
  color: #c8d3e3;
  border-radius: 10px;
  padding: 14px;
  font-size: 11.5px;
  line-height: 1.7;
  overflow: auto;
  max-height: 340px;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
}
.log-box.tall { max-height: 70vh; }

.link { font-size: 13px; }
.muted { color: var(--muted); }
.tiny { font-size: 11.5px; }
.ok-text { color: var(--green); }
.warn-text { color: var(--amber); }
.break { word-break: break-all; }
.row-actions { display: flex; align-items: center; gap: 5px; }
.row-actions form { margin: 0; }

.flash-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash {
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  border: 1px solid;
  white-space: pre-wrap;
  word-break: break-word;
}
.flash-success { background: #ecfaf3; border-color: #b9ecd6; color: #067a5b; }
.flash-error { background: #fff1f0; border-color: #f6c9c2; color: #b42318; }
.flash-warn { background: #fff8e8; border-color: #f3dfae; color: #8a4b08; }

.footer {
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
  padding: 14px 24px 22px;
  display: flex;
  justify-content: space-between;
  color: #98a2b3;
  font-size: 11.5px;
  flex-wrap: wrap;
  gap: 6px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 9px 16px;
  border-radius: 9px;
  font-size: 13px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .4);
  z-index: 50;
}

.error-card { text-align: center; padding: 48px 20px; }
.error-card h1 { font-size: 48px; color: var(--primary); }
.error-card p { color: var(--muted); }

@media (max-width: 980px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .topbar-inner { padding: 10px 16px; gap: 12px; }
  .nav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .page { padding: 18px 16px; }
}
@media (max-width: 640px) {
  .stat-grid { grid-template-columns: 1fr; }
  .page-head { align-items: flex-start; }
  .head-actions { width: 100%; }
  .search { width: 100%; }
  .search input { flex: 1; width: auto; }
  .kv { flex-wrap: wrap; }
  .kv > span:first-child { min-width: 88px; }
  .cred-row { flex-wrap: wrap; }
  .cred-value { width: 100%; }
}
