:root {
  color-scheme: dark;
  --bg: #0b1020;
  --panel: rgba(17, 24, 39, 0.78);
  --panel-strong: rgba(15, 23, 42, 0.96);
  --border: rgba(148, 163, 184, 0.22);
  --text: #e5e7eb;
  --muted: #94a3b8;
  --brand: #8b5cf6;
  --brand-2: #06b6d4;
  --danger: #fb7185;
  --success: #34d399;
  --warning: #fbbf24;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 0%, rgba(139, 92, 246, 0.26), transparent 32rem),
    radial-gradient(circle at 95% 12%, rgba(6, 182, 212, 0.22), transparent 30rem),
    linear-gradient(135deg, #090d18 0%, #111827 48%, #0b1020 100%);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.hidden { display: none !important; }
.app-shell { width: min(1580px, calc(100% - 32px)); margin: 0 auto; padding: 24px 0 36px; }
.login-view {
  min-height: calc(100vh - 48px);
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.65fr);
  gap: 28px;
  align-items: center;
}
.brand-card {
  min-height: 520px;
  border: 1px solid var(--border);
  border-radius: 34px;
  padding: 56px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.18), rgba(6, 182, 212, 0.08)), rgba(15, 23, 42, 0.72);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.brand-mark {
  width: 84px;
  height: 84px;
  border-radius: 26px;
  display: grid;
  place-items: center;
  margin-bottom: auto;
  font-size: 44px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 20px 50px rgba(139, 92, 246, 0.34);
}
.eyebrow { margin: 0 0 10px; color: #a5b4fc; font-size: 12px; font-weight: 800; letter-spacing: 0.18em; }
h1, h2 { margin: 0; line-height: 1.1; }
h1 { font-size: clamp(32px, 4vw, 58px); }
h2 { font-size: 20px; }
.muted { color: var(--muted); }
.panel {
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.login-panel { padding: 28px; display: grid; gap: 18px; }
label { display: grid; gap: 8px; color: #cbd5e1; font-weight: 700; font-size: 13px; }
input, select, textarea {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 14px;
  outline: none;
  color: var(--text);
  background: rgba(2, 6, 23, 0.48);
  padding: 12px 13px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: rgba(139, 92, 246, 0.8); box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.18); }
.primary, .ghost {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  color: white;
  font-weight: 900;
}
.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 16px 36px rgba(6, 182, 212, 0.16); }
.ghost { background: rgba(148, 163, 184, 0.12); border: 1px solid rgba(148, 163, 184, 0.18); }
.danger { color: #fecdd3; }
.status { min-height: 20px; margin: 0; color: var(--danger); }
.dashboard { display: grid; gap: 18px; }
.topbar, .section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.topbar {
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 22px 24px;
  background: rgba(15, 23, 42, 0.74);
  box-shadow: var(--shadow);
}
.topbar h1 { font-size: 32px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.admin-pill, .badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 7px 10px;
  font-weight: 900;
  font-size: 12px;
  background: rgba(139, 92, 246, 0.18);
  color: #ddd6fe;
}
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat-card {
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px;
  background: rgba(15, 23, 42, 0.68);
}
.stat-card span { color: var(--muted); font-size: 13px; font-weight: 800; }
.stat-card strong { display: block; margin-top: 8px; font-size: 34px; }
.workspace { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 18px; align-items: start; }
.create-panel, .users-panel { padding: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
.wide { grid-column: 1 / -1; }
.search { max-width: 420px; }
.table-wrap { margin-top: 16px; overflow: auto; border: 1px solid rgba(148, 163, 184, 0.16); border-radius: 18px; }
.table-wrap.compact { max-height: 560px; }
table { width: 100%; border-collapse: collapse; min-width: 1120px; }
th, td { padding: 13px 12px; border-bottom: 1px solid rgba(148, 163, 184, 0.14); text-align: left; vertical-align: middle; }
th { color: #a5b4fc; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; background: rgba(15, 23, 42, 0.94); position: sticky; top: 0; }
td { color: #dbeafe; }
tr:hover td { background: rgba(148, 163, 184, 0.06); }
.code-cell { font-family: "JetBrains Mono", Consolas, monospace; color: #bae6fd; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.mini {
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 10px;
  padding: 7px 9px;
  color: #e0f2fe;
  background: rgba(148, 163, 184, 0.12);
  font-weight: 800;
}
.mini.danger { color: #fecdd3; }
.status-active { background: rgba(52, 211, 153, 0.16); color: #bbf7d0; }
.status-disabled { background: rgba(251, 113, 133, 0.14); color: #fecdd3; }
.modal { border: 0; padding: 0; background: transparent; color: var(--text); width: min(860px, calc(100% - 24px)); }
.modal::backdrop { background: rgba(2, 6, 23, 0.72); backdrop-filter: blur(8px); }
.modal-card { padding: 22px; border: 1px solid var(--border); border-radius: 24px; background: var(--panel-strong); box-shadow: var(--shadow); }
.modal-head, .modal-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal-actions { margin-top: 18px; justify-content: flex-end; flex-wrap: wrap; }
.icon-btn { width: 36px; height: 36px; border-radius: 999px; border: 0; background: rgba(148, 163, 184, 0.14); color: white; font-size: 22px; }
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 440px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 16px;
  padding: 14px 16px;
  color: white;
  background: rgba(15, 23, 42, 0.94);
  box-shadow: var(--shadow);
  z-index: 50;
}
.split-pane {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
  gap: 18px;
  align-items: start;
  margin-top: 16px;
}
.detail-pre {
  min-height: 360px;
  max-height: 640px;
  overflow: auto;
  margin: 16px 0 0;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 18px;
  padding: 16px;
  color: #dbeafe;
  background: rgba(2, 6, 23, 0.48);
  white-space: pre-wrap;
  word-break: break-word;
}
.compact-stats { margin-top: 16px; }
.compact-stats .stat-card strong { font-size: 24px; }
h3 { margin: 0 0 8px; color: #e0e7ff; }

@media (max-width: 1100px) {
  .login-view, .workspace, .split-pane { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .app-shell { width: min(100% - 18px, 1580px); padding-top: 10px; }
  .brand-card { min-height: 360px; padding: 28px; }
  .topbar, .section-head { align-items: flex-start; flex-direction: column; }
  .stats-grid, .form-grid { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
}
