:root {
  --bg: #f0f3f7;
  --panel: #ffffff;
  --text: #1a2332;
  --muted: #6b7785;
  --line: #e6ebf0;
  --brand: #0d6e6a;
  --brand-dark: #0a5754;
  --danger: #b42318;
  --ok: #067647;
  --sidebar: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #0d6e6a;
  --radius: 10px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --shadow: 0 8px 30px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(ellipse at 0% 0%, rgba(13,110,106,.08), transparent 45%),
    radial-gradient(ellipse at 100% 100%, rgba(30,64,175,.06), transparent 40%),
    linear-gradient(165deg, #e8eef5 0%, #f4f7fa 50%, #eaf3f1 100%);
  min-height: 100vh;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 18% 22%, rgba(13,110,106,.16), transparent 42%),
    radial-gradient(circle at 82% 78%, rgba(30,64,175,.1), transparent 40%),
    linear-gradient(160deg, #dce7f0, #eef5f2);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.login-card h1 {
  margin: 0 0 8px;
  font-size: 24px;
  letter-spacing: .02em;
}
.login-card .sub { color: var(--muted); margin-bottom: 24px; font-size: 14px; }

.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 16px 0 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 40;
}
.brand {
  padding: 8px 20px 18px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.nav-close, .nav-toggle {
  display: none;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}
.nav a {
  display: block;
  padding: 11px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
}
.nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav a.active {
  background: rgba(13,110,106,.28);
  color: #fff;
  border-left-color: var(--sidebar-active);
}

.sidebar-mask {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  z-index: 30;
}

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-title { font-weight: 600; }
.topbar .right {
  color: var(--muted);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.topbar .right a { margin-left: 0; }
.admin-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content { padding: 20px; flex: 1; }
.footer {
  padding: 12px 20px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.panel h2 {
  margin: 0 0 14px;
  font-size: 17px;
  font-weight: 650;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat .label { color: var(--muted); font-size: 13px; }
.stat .num { font-size: 26px; font-weight: 700; margin-top: 6px; color: var(--brand-dark); }

.form-row { margin-bottom: 14px; }
.form-row label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--muted);
}
.form-row input[type=text],
.form-row input[type=password],
.form-row input[type=number],
.form-row textarea,
.form-row select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
}
.form-row textarea { min-height: 120px; resize: vertical; }
.form-inline { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.form-inline .form-row { margin: 0; }

.btn {
  display: inline-block;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; color: #fff; }
.btn-ghost {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: #f8fafc; color: var(--text); }
.btn-danger { background: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 13px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 640px;
}
table.data th, table.data td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}
table.data th {
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  background: #f8fafc;
}
table.data tr:hover td { background: #f9fafb; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
}
.badge-ok { background: #d1fae5; color: var(--ok); }
.badge-off { background: #fee2e2; color: var(--danger); }

.alert {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}
.alert-ok { background: #d1fae5; color: var(--ok); }
.alert-err { background: #fee2e2; color: var(--danger); }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.pager {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--muted);
}
.pager .cur { color: var(--text); font-weight: 600; }
.pager a { color: var(--brand); }

.captcha-row { display: flex; gap: 10px; align-items: center; }
.captcha-row img {
  height: 40px;
  border-radius: 6px;
  border: 1px solid var(--line);
  cursor: pointer;
}
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.checkbox-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.checkbox-list label {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 14px;
}
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-all; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.switch-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
}
.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #cbd5e1;
  transition: .2s;
  border-radius: 26px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  transition: .2s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider:before { transform: translateX(20px); }
.switch input:disabled + .slider { opacity: .6; cursor: wait; }

.pkg-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 8px;
}
.pkg-row input[type=text],
.pkg-row input[type=number] {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-mask[hidden] { display: none !important; }
.modal-box {
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow: auto;
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: 0 20px 50px rgba(0,0,0,.18);
}
.modal-hd {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-close {
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}
.modal-bd { padding: 16px 18px; }
.modal-ft {
  padding: 12px 18px 16px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--line);
}

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(280px, 86vw);
    height: 100vh;
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: 8px 0 30px rgba(0,0,0,.2);
  }
  .layout.nav-open .sidebar { transform: translateX(0); }
  .layout.nav-open .sidebar-mask { display: block; }
  .nav-toggle, .nav-close { display: inline-flex; align-items: center; justify-content: center; }
  .nav-toggle { color: var(--text); font-size: 20px; }
  .nav-close { color: #fff; }
  .stats { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .content { padding: 14px; }
  .panel { padding: 14px; }
  .admin-name { display: none; }
}

@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr; }
  .topbar { padding: 10px 12px; }
  .checkbox-list { grid-template-columns: 1fr; }
}
