:root {
  --bg: #0f172a;
  --fg: #f8fafc;
  --muted: #94a3b8;
  --card: #1b2336;
  --card-2: #272f42;
  --line: #475569;
  --green: #22c55e;
  --green-ink: #0f172a;
  --red: #ef4444;
  --amber: #fbbf24;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  --sidebar: 232px;
  --font: "Fira Sans", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --mono: "Fira Code", "SF Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
}
a { color: #86efac; text-decoration: none; }
a:hover { text-decoration: underline; }
button, .btn, .icon-btn, .help-btn, summary { cursor: pointer; }
:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.skip {
  position: absolute; left: 12px; top: -40px; background: #fff; color: #000; padding: 8px 12px; z-index: 20;
}
.skip:focus { top: 12px; }

.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar);
  flex: none;
  background: rgba(27, 35, 54, 0.92);
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(14px);
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: block; color: var(--fg); font-weight: 650; letter-spacing: 0.01em; padding: 4px 10px 18px; text-decoration: none; }
.brand small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; margin-top: 4px; }
.nav-link {
  display: block; color: var(--fg); text-decoration: none; border-radius: 10px;
  padding: 9px 12px; margin-bottom: 4px;
}
.nav-link:hover, .nav-link.active { background: var(--card-2); text-decoration: none; }
.side-foot { margin-top: 18px; padding: 10px; color: var(--muted); font-size: 13px; }
.main { flex: 1; min-width: 0; padding: 28px 32px 64px; }
.topbar { display: flex; justify-content: flex-end; gap: 14px; align-items: center; margin-bottom: 8px; color: var(--muted); font-size: 14px; }
.page-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; margin: 8px 0 20px; }
.page-head h1 { margin: 0; font-size: 28px; letter-spacing: -0.02em; }
.sub { color: var(--muted); margin: 6px 0 0; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 22px; }
.metric, .panel {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.metric { display: block; color: inherit; text-decoration: none; padding: 16px; }
.metric:hover { background: #222b40; text-decoration: none; }
.metric b { display: block; font-size: 28px; font-family: var(--mono); margin-top: 6px; }
.metric span, .muted { color: var(--muted); }
.panel { padding: 16px 18px; margin-bottom: 16px; }
.panel h2 { margin: 0 0 12px; font-size: 18px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
tr:hover td { background: rgba(255, 255, 255, 0.03); }

.btn, button.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--green); color: var(--green-ink); border: 0; border-radius: 10px;
  padding: 9px 14px; font: inherit; font-weight: 650; text-decoration: none;
}
.btn:hover { background: #4ade80; text-decoration: none; }
.btn.secondary { background: transparent; color: var(--fg); border: 1px solid var(--line); }
.btn.secondary:hover { background: var(--card-2); }
.btn.danger { background: var(--red); color: #000; }
.btn[disabled], button[aria-busy="true"] { opacity: 0.65; cursor: wait; }
.icon-btn, .help-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line);
  background: transparent; color: var(--fg); display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover, .help-btn:hover { background: var(--card-2); }
.help-btn { width: 22px; height: 22px; border-radius: 50%; margin-left: 4px; vertical-align: middle; }
.text-btn { background: none; border: 0; color: #86efac; font: inherit; padding: 0 4px; }

.badge { display: inline-block; border-radius: 999px; padding: 2px 8px; font-size: 12px; background: #334155; color: #e2e8f0; }
.badge.normal, .badge.low { background: #14532d; color: #dcfce7; }
.badge.pending, .badge.review, .badge.medium { background: #713f12; color: #fef3c7; }
.badge.limited, .badge.high, .badge.banned, .badge.failed { background: #7f1d1d; color: #fee2e2; }
.badge.disabled, .badge.retired { background: #334155; color: #e2e8f0; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.input, select.input, textarea.input {
  width: 100%; background: #0f172a; color: var(--fg); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 11px; font: inherit;
}
textarea.input, .area { min-height: 88px; }
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 6px; }
.hint, .errorlist { color: var(--muted); font-size: 13px; margin: 6px 0 0; padding: 0; list-style: none; }
.errorlist { color: #fecaca; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.mono { font-family: var(--mono); }
.secret-slot { letter-spacing: 0.04em; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a { color: var(--fg); text-decoration: none; border: 1px solid transparent; border-radius: 999px; padding: 6px 12px; }
.tabs a.active, .tabs a:hover { border-color: var(--line); background: var(--card); text-decoration: none; }
.empty { padding: 28px 8px; color: var(--muted); }
.messages { list-style: none; padding: 0; }
.messages li { background: #14532d; color: #dcfce7; border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.messages li.error { background: #7f1d1d; color: #fee2e2; }

.popover {
  position: fixed; z-index: 30; width: min(360px, calc(100vw - 24px));
  background: #111827; color: var(--fg); border: 1px solid rgba(255,255,255,.2);
  border-radius: 12px; padding: 14px; box-shadow: var(--shadow);
}
.popover h3 { margin: 0 0 8px; font-size: 16px; }
.popover p { margin: 6px 0; }
.toast {
  position: fixed; bottom: 18px; right: 18px; background: var(--fg); color: var(--green-ink);
  padding: 10px 14px; border-radius: 10px; font-weight: 650;
}
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(420px, 100%); }
.menu-btn { display: none; }

@media (max-width: 960px) {
  .metrics, .grid-2 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 800px) {
  .shell { display: block; }
  .sidebar { display: none; width: auto; height: auto; position: static; }
  .sidebar.open { display: block; }
  .menu-btn { display: inline-flex; }
  .main { padding: 18px 14px 48px; }
  .metrics, .grid-2 { grid-template-columns: 1fr; }
  .page-head { display: block; }
}

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