/* ==========================================================================
   MoonStone DLC — design system
   Dark, minimal, cool-toned: moonstone silver → periwinkle → violet.
   ========================================================================== */

:root {
  --bg: #06060c;
  --bg-elevated: #0c0c17;
  --surface: rgba(255, 255, 255, 0.032);
  --surface-strong: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);

  --text: #eef0f7;
  --muted: #99a1b8;
  --faint: #6b7387;

  --primary: #8b9cff;
  --primary-strong: #6b7dff;
  --accent: #bda9ff;
  --glow: rgba(139, 156, 255, 0.32);

  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #fb7185;

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Ambient background light — two soft moonstone glows. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(760px 520px at 12% -10%, rgba(139, 156, 255, 0.16), transparent 62%),
    radial-gradient(680px 460px at 92% 8%, rgba(189, 169, 255, 0.12), transparent 60%),
    radial-gradient(900px 600px at 50% 120%, rgba(107, 125, 255, 0.09), transparent 65%);
  z-index: 0;
}

a { color: var(--primary); text-decoration: none; transition: color 0.18s var(--ease); }
a:hover { color: var(--accent); }

h1, h2, h3, h4 { margin: 0 0 0.5em; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; }
p { margin: 0 0 1em; }

.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: 13px; }
.center { text-align: center; }
.mono { font-family: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace; }
.nowrap { white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- layout */

.shell {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 26px 22px 72px;
  animation: rise 0.5s var(--ease) both;
}

.page-centered {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 28px 18px;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------------------------------------------------------------- header */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 0 26px;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
  letter-spacing: -0.02em;
}
.brand:hover { color: var(--text); }
.brand-center { justify-content: center; margin-bottom: 14px; }
.brand-mark { width: 30px; height: 30px; display: block; filter: drop-shadow(0 0 14px var(--glow)); }
.brand-mark.lg { width: 58px; height: 58px; }
.brand-tag {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid rgba(189, 169, 255, 0.32);
  background: rgba(189, 169, 255, 0.1);
  border-radius: 999px;
  padding: 2px 9px;
}

.nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nav a {
  color: var(--muted);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.nav a:hover { color: var(--text); background: var(--surface-strong); }
.nav a.active { color: var(--text); background: var(--surface-strong); }

/* ---------------------------------------------------------------- cards */

.card {
  position: relative;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.018));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  animation: rise 0.45s var(--ease) both;
}
.card + .card { margin-top: 18px; }
.card-narrow { width: 100%; max-width: 440px; padding: 34px 30px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.card-title { font-size: 17px; font-weight: 650; margin: 0; }
.card-sub { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.card-grid.tight { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.h1 { font-size: clamp(26px, 3.4vw, 40px); margin-bottom: 10px; }
.h2 { font-size: clamp(21px, 2.4vw, 27px); }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 10px var(--success); }
.dot.idle { background: var(--muted); box-shadow: none; }
.dot.bad { background: var(--danger); box-shadow: 0 0 10px var(--danger); }
.dot.warn { background: var(--warning); box-shadow: 0 0 10px var(--warning); }

/* ---------------------------------------------------------------- hero */

.hero { padding: 34px 0 20px; }
.hero-title { font-size: clamp(31px, 5vw, 54px); line-height: 1.06; margin-bottom: 16px; }
.hero-title .grad {
  background: linear-gradient(100deg, #ffffff 8%, var(--accent) 48%, var(--primary-strong) 92%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-desc { max-width: 620px; color: var(--muted); font-size: 16.5px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 8px; }
.feature {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease), background 0.2s var(--ease);
}
.feature:hover { border-color: var(--border-strong); transform: translateY(-2px); background: var(--surface-strong); }
.feature-icon {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: rgba(139, 156, 255, 0.13);
  border: 1px solid rgba(139, 156, 255, 0.24);
  color: var(--primary);
  margin-bottom: 13px;
}
.feature h3 { font-size: 15.5px; margin-bottom: 6px; }
.feature p { margin: 0; color: var(--muted); font-size: 14px; }

.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px; counter-reset: step; }
.step { position: relative; padding-left: 44px; }
.step::before {
  counter-increment: step;
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0; top: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  opacity: 0.85;
}
.step h4 { font-size: 15px; margin-bottom: 4px; }
.step p { margin: 0; font-size: 13.5px; color: var(--muted); }

/* ---------------------------------------------------------------- forms */

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--faint); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }

input, select, textarea {
  width: 100%;
  padding: 11px 13px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.18s var(--ease);
}
input::placeholder, textarea::placeholder { color: #5b6274; }
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139, 156, 255, 0.16);
  background: rgba(0, 0, 0, 0.4);
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
textarea { min-height: 104px; resize: vertical; }

.search-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.search-row input, .search-row select { width: auto; min-width: 170px; }
.search-row .grow { flex: 1 1 220px; }

.check { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--muted); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary-strong); }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--surface-strong);
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.16s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease), opacity 0.2s var(--ease);
  text-align: center;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(120deg, var(--primary-strong), var(--accent));
  color: #0a0a14;
  box-shadow: 0 10px 26px rgba(107, 125, 255, 0.28);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 14px 32px rgba(107, 125, 255, 0.4); }

.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-strong); border-color: var(--primary); }

.btn-danger { background: rgba(251, 113, 133, 0.14); border-color: rgba(251, 113, 133, 0.38); color: #ffd9df; }
.btn-danger:hover:not(:disabled) { background: rgba(251, 113, 133, 0.24); }

.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }

/* ---------------------------------------------------------------- badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  white-space: nowrap;
}
.badge.owner { color: #ffe9a8; border-color: rgba(251, 191, 36, 0.36); background: rgba(251, 191, 36, 0.11); }
.badge.admin { color: #cfd6ff; border-color: rgba(139, 156, 255, 0.36); background: rgba(139, 156, 255, 0.12); }
.badge.user { color: #c6f6d5; border-color: rgba(74, 222, 128, 0.3); background: rgba(74, 222, 128, 0.1); }
.badge.active { color: #c6f6d5; border-color: rgba(74, 222, 128, 0.3); background: rgba(74, 222, 128, 0.1); }
.badge.blocked { color: #ffd9df; border-color: rgba(251, 113, 133, 0.36); background: rgba(251, 113, 133, 0.12); }
.badge.locked { color: #ffe9a8; border-color: rgba(251, 191, 36, 0.36); background: rgba(251, 191, 36, 0.11); }
.badge.muted { color: var(--muted); }

/* ---------------------------------------------------------------- stats */

.stat { padding: 18px; }
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); font-weight: 600; }
.stat-value { font-size: 27px; font-weight: 680; margin-top: 6px; letter-spacing: -0.02em; }
.stat-note { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
thead th {
  text-align: left;
  padding: 12px 14px;
  font-size: 11.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.022);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid rgba(255, 255, 255, 0.045); vertical-align: middle; }
tbody tr { transition: background 0.16s var(--ease); }
tbody tr:hover { background: rgba(255, 255, 255, 0.026); }
tbody tr:last-child td { border-bottom: none; }
.empty { text-align: center; color: var(--muted); padding: 30px 14px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- notices */

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13.5px;
  margin-bottom: 16px;
  animation: fade 0.25s var(--ease) both;
}
.notice.success { border-color: rgba(74, 222, 128, 0.34); background: rgba(74, 222, 128, 0.09); color: #d7fbe4; }
.notice.error { border-color: rgba(251, 113, 133, 0.36); background: rgba(251, 113, 133, 0.1); color: #ffe0e5; }
.notice.warning { border-color: rgba(251, 191, 36, 0.34); background: rgba(251, 191, 36, 0.1); color: #fdf0cf; }
.notice.info { border-color: rgba(139, 156, 255, 0.32); background: rgba(139, 156, 255, 0.1); color: #e2e7ff; }
.notice:empty { display: none; }

.toast-host {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 90;
  pointer-events: none;
}
.toast {
  min-width: 220px;
  max-width: 340px;
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: rgba(14, 14, 24, 0.96);
  box-shadow: var(--shadow);
  font-size: 13.5px;
  animation: rise 0.28s var(--ease) both;
}
.toast.success { border-color: rgba(74, 222, 128, 0.45); }
.toast.error { border-color: rgba(251, 113, 133, 0.45); }

/* ---------------------------------------------------------------- tabs */

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.tab {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  transition: all 0.18s var(--ease);
}
.tab:hover { color: var(--text); background: var(--surface-strong); }
.tab.active { color: var(--text); background: var(--surface-strong); border-color: var(--border-strong); }
.pane { display: none; animation: rise 0.32s var(--ease) both; }
.pane.active { display: block; }

/* ---------------------------------------------------------------- modal */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 4, 10, 0.82);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 80;
  animation: fade 0.2s var(--ease) both;
}
.overlay .card { max-width: 460px; width: 100%; max-height: 90vh; overflow-y: auto; }

/* ---------------------------------------------------------------- misc */

.kv { display: grid; grid-template-columns: minmax(120px, 180px) 1fr; gap: 9px 18px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

.sep { height: 1px; background: var(--border); margin: 22px 0; border: 0; }

.link-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }

.footer { margin-top: 46px; padding-top: 20px; border-top: 1px solid var(--border); color: var(--faint); font-size: 13px; display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; }

.spinner {
  width: 15px; height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.session-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13.5px;
}
.avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--primary-strong), var(--accent));
  color: #0a0a14;
  font-size: 12.5px;
  font-weight: 700;
}

@media (max-width: 640px) {
  .shell { padding: 18px 14px 60px; }
  .card { padding: 20px; }
  .card-narrow { padding: 26px 20px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 10px; }
}
