:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --border: rgba(255,255,255,.08);
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #3b82f6;
  --accent2: #6366f1;
  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0,0,0,.35);
  --sidebar-w: 240px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(145deg, #0c1018 0%, #151c28 40%, #0f1419 100%);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: #93c5fd; text-decoration: none; }
a:hover { color: #bfdbfe; }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: var(--shadow);
}
.login-brand {
  text-align: center;
  margin-bottom: 28px;
}
.login-brand h1 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: .02em;
}
.login-brand p { margin: 0; color: var(--muted); font-size: 13px; }
.login-form label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}
.login-form input {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface2);
  color: var(--text);
  font-size: 15px;
}
.login-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.25);
}
.login-form button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.login-form button:hover { filter: brightness(1.08); }
.login-error {
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.35);
  color: #fca5a5;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
}
.login-step { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 12px; }

/* App shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: rgba(26,35,50,.95);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}
.sidebar-brand {
  padding: 22px 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand strong { font-size: 16px; display: block; }
.sidebar-brand span { font-size: 11px; color: var(--muted); }
.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  margin-bottom: 4px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 13px;
  transition: .15s;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(59,130,246,.25), rgba(99,102,241,.2));
  color: #fff;
  border: 1px solid rgba(59,130,246,.35);
}
.sidebar-foot {
  padding: 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 24px 28px 40px;
  min-width: 0;
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 22px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header h1 { margin: 0; font-size: 22px; font-weight: 600; }
.page-header .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat-strip {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.stat-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--muted);
}
.stat-pill strong { color: var(--text); margin-left: 4px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: 0 2px 12px rgba(0,0,0,.15);
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 12px;
}
.card-desc { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.muted { color: var(--muted); font-size: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

input, select, textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
}
button, .btn {
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: .15s;
}
button.primary, .btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-color: transparent;
  color: #fff;
}
button:hover, .btn:hover { filter: brightness(1.06); }
button:disabled { opacity: .5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; }
th, td {
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
  font-size: 13px;
}
th { color: var(--muted); font-weight: 500; font-size: 12px; }
.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  max-height: 360px;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  background: var(--surface2);
}
.badge.ok { background: rgba(16,185,129,.2); color: #6ee7b7; }
.badge.warn { background: rgba(245,158,11,.2); color: #fcd34d; }
.badge.danger { background: rgba(239,68,68,.2); color: #fca5a5; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 960px) {
  .sidebar { width: 72px; }
  .sidebar-brand span, .nav-item span { display: none; }
  .main { margin-left: 72px; padding: 16px; }
  .grid2 { grid-template-columns: 1fr; }
}

.modal-mask {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.flash-ok {
  background: rgba(16,185,129,.12);
  border: 1px solid rgba(16,185,129,.35);
  color: #6ee7b7;
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
}
.card.danger {
  background: rgba(239,68,68,.08);
  border-color: rgba(239,68,68,.35);
}
