:root {
  --bg: #0f1419;
  --bg-elev: #171d25;
  --bg-soft: #1e2630;
  --line: rgba(255, 255, 255, 0.08);
  --text: #e8eef4;
  --muted: #8b9aab;
  --accent: #2dd4a8;
  --accent-dim: rgba(45, 212, 168, 0.16);
  --warn: #f0a35a;
  --danger: #ef6b6b;
  --ok: #2dd4a8;
  --trial: #5b9dff;
  --radius: 14px;
  --font: "IBM Plex Sans", "Noto Sans SC", system-ui, sans-serif;
  --mono: "IBM Plex Sans", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
}

body.page-app {
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(45, 212, 168, 0.12), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(91, 157, 255, 0.1), transparent 50%),
    var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.5rem 1.1rem;
  border-right: 1px solid var(--line);
  background: rgba(15, 20, 25, 0.85);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.25rem 0.5rem;
}

.brand strong {
  display: block;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
}

.brand small {
  color: var(--muted);
  font-size: 0.75rem;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background:
    conic-gradient(from 210deg, #2dd4a8, #5b9dff, #2dd4a8);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.12), 0 8px 24px rgba(45, 212, 168, 0.25);
  position: relative;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 6px;
  background: var(--bg);
}

.brand-mark.lg {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  margin: 0 auto 1rem;
}

.brand-mark.lg::after { inset: 11px; border-radius: 8px; }

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.side-nav a {
  color: var(--muted);
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 500;
}

.side-nav a:hover {
  background: var(--bg-soft);
  color: var(--text);
  text-decoration: none;
}

.side-nav a.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.side-foot { padding: 0 0.25rem; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.75rem;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 20, 25, 0.55);
}

.topbar-title { font-weight: 600; }
.topbar-user { color: var(--muted); font-size: 0.9rem; }

.content {
  padding: 1.5rem 1.75rem 2.5rem;
  max-width: 1280px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.page-head h1 {
  margin: 0.2rem 0 0.25rem;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-head p {
  margin: 0;
  color: var(--muted);
}

.crumb {
  display: inline-block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.stat {
  display: block;
  padding: 1rem 1.05rem;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--bg-elev), var(--bg-soft));
  border: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

a.stat:hover {
  border-color: rgba(45, 212, 168, 0.35);
  transform: translateY(-1px);
  text-decoration: none;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 0.45rem;
}

.stat-value {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.stat-value.accent { color: var(--accent); }
.stat-value.warn { color: var(--warn); }
.stat-value small { font-size: 1rem; color: var(--muted); font-weight: 500; }

.split {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1rem;
}

.panel {
  border-radius: var(--radius);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  overflow: hidden;
}

.panel.mt { margin-top: 1rem; }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.95rem 1.1rem;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.table-wrap { overflow-x: auto; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

table.data th,
table.data td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

table.data th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

table.data tr:last-child td { border-bottom: none; }
table.data tr.row-dim { opacity: 0.62; }

.mono { font-family: var(--mono); letter-spacing: 0.02em; }
.muted { color: var(--muted); }
.center { text-align: center !important; }

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(255,255,255,0.06);
  color: var(--muted);
}

.pill.ok, .pill.已授权 { background: var(--accent-dim); color: var(--ok); }
.pill.trial, .pill.试用中 { background: rgba(91, 157, 255, 0.16); color: var(--trial); }
.pill.bad, .pill.已禁用 { background: rgba(239, 107, 107, 0.16); color: var(--danger); }
.pill.muted, .pill.已过期 { background: rgba(255,255,255,0.06); color: var(--muted); }

.toolbar {
  display: flex;
  gap: 0.65rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.input {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  font: inherit;
  min-width: 0;
}

.input:focus {
  outline: none;
  border-color: rgba(45, 212, 168, 0.55);
  box-shadow: 0 0 0 3px rgba(45, 212, 168, 0.15);
}

.input.grow { flex: 1; min-width: 180px; }

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.6rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  text-decoration: none;
}

.btn.lg { padding: 0.8rem 1.1rem; font-size: 1rem; }
.btn.w-full { width: 100%; }

.btn-primary {
  background: linear-gradient(180deg, #3ae0b4, #22c99a);
  color: #06261c;
}

.btn-primary:hover { filter: brightness(1.05); text-decoration: none; color: #06261c; }

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.btn-ghost:hover { background: var(--bg-soft); text-decoration: none; }

.btn-danger {
  background: rgba(239, 107, 107, 0.16);
  border-color: rgba(239, 107, 107, 0.35);
  color: #ffb4b4;
}

.btn-danger:hover { background: rgba(239, 107, 107, 0.28); }

.link {
  color: var(--accent);
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

.link.danger { color: var(--danger); }
.inline-form { display: inline; }

.flash {
  padding: 0.8rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.92rem;
}

.flash.ok {
  background: var(--accent-dim);
  color: #b7f5e0;
  border: 1px solid rgba(45, 212, 168, 0.3);
}

.flash.err {
  background: rgba(239, 107, 107, 0.14);
  color: #ffc2c2;
  border: 1px solid rgba(239, 107, 107, 0.3);
}

.flash code {
  font-size: 0.85em;
  background: rgba(0,0,0,0.25);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.pager {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  margin-top: 1rem;
  color: var(--muted);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1rem;
}

.action-stack {
  padding: 1rem 1.1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.action-row label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 0.45rem;
}

.inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.kv {
  display: grid;
  gap: 0.65rem;
}

.kv > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}

.kv span { color: var(--muted); font-size: 0.85rem; }
.kv strong { font-weight: 600; }

/* Login */
body.page-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(800px 400px at 20% 10%, rgba(45, 212, 168, 0.18), transparent 60%),
    radial-gradient(700px 380px at 90% 80%, rgba(91, 157, 255, 0.14), transparent 55%),
    var(--bg);
}

.login-shell {
  width: min(420px, calc(100% - 2rem));
  padding: 1rem 0 2rem;
}

.login-card {
  padding: 2rem 1.75rem 1.75rem;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(30, 38, 48, 0.95), rgba(23, 29, 37, 0.98));
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

.login-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-brand h1 {
  margin: 0;
  font-size: 1.8rem;
  letter-spacing: 0.04em;
}

.login-brand p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field span {
  font-size: 0.85rem;
  color: var(--muted);
}

.validation-summary-errors ul {
  margin: 0;
  padding-left: 1.1rem;
}

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .split, .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
  }
  .side-nav { flex-direction: row; flex: 1; }
  .side-foot { width: 100%; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content { padding: 1rem; }
}
