:root {
  --bg: #0f1420;
  --surface: #161d2b;
  --surface-2: #1d2636;
  --border: #2a3344;
  --text: #e6ebf4;
  --muted: #8b97ab;
  --accent: #6ea8fe;
  --green: #3dd68c;
  --red: #f07178;
  --amber: #f0b775;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.9em;
}
.muted { color: var(--muted); }
.inline { display: inline; }

/* ---- top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  background: var(--accent);
  color: #0b1020;
  font-weight: 700;
  font-size: 13px;
  padding: 5px 8px;
  border-radius: 7px;
  letter-spacing: 0.5px;
}
.brand-text { font-weight: 600; letter-spacing: 0.2px; }
.topbar-user { display: flex; align-items: center; gap: 12px; }
.user-name { color: var(--muted); font-size: 14px; }

.content { max-width: 1180px; margin: 0 auto; padding: 28px 24px 64px; }

.page-head { margin-bottom: 22px; }
.page-head h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -0.2px; }
.page-head p { margin: 0; }
.back-link { font-size: 14px; display: inline-block; margin-bottom: 10px; }

/* ---- notices ---- */
.notice {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  background: var(--surface);
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
}
.notice-error { border-left-color: var(--red); }

/* ---- toast: the same sentence, next to where the button was ---- */
.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 340px;
  /* The stack spans a corner of the viewport; only the toast itself should
     swallow clicks, or it would sit invisibly over a case card's buttons. */
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 11px 13px;
  font-size: 14px;
  line-height: 1.45;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  animation: toast-in 180ms ease-out;
  transition: opacity 320ms ease, transform 320ms ease;
}
.toast-ok { border-left-color: var(--green); }
.toast-error { border-left-color: var(--red); }
.toast-text { flex: 1; }
.toast-close {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}
.toast-close:hover { color: var(--text); }
.toast.is-leaving { opacity: 0; transform: translateY(6px); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* A ruling can take many seconds while the bot DMs the member and edits its
   staff card. Without this the button looks ignored, which is exactly how a
   working button gets reported as broken. */
.btn.is-working { opacity: 0.65; cursor: progress; }

@media (max-width: 560px) {
  .toast-stack { right: 12px; left: 12px; bottom: 12px; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; transition: none; }
}

/* ---- cards ---- */
.bot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
}
.bot-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.card-head { display: flex; align-items: center; gap: 12px; }
.bot-label {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--accent);
  font-weight: 700;
  font-size: 12px;
  padding: 6px 9px;
  border-radius: 8px;
  letter-spacing: 0.6px;
}
.card-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-title h2 { margin: 0; font-size: 17px; font-weight: 600; }

.pill {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.state-running { background: rgba(61,214,140,0.14); color: var(--green); border-color: rgba(61,214,140,0.35); }
.state-stopped { background: rgba(139,151,171,0.14); color: var(--muted); border-color: var(--border); }
.state-failed  { background: rgba(240,113,120,0.14); color: var(--red); border-color: rgba(240,113,120,0.35); }
.state-warn    { background: rgba(240,183,117,0.14); color: var(--amber); border-color: rgba(240,183,117,0.35); }
.state-unknown { background: var(--surface-2); color: var(--muted); border-color: var(--border); }

.card-warning {
  margin: 0;
  font-size: 13px;
  color: var(--amber);
  background: rgba(240,183,117,0.08);
  border: 1px solid rgba(240,183,117,0.25);
  border-radius: 8px;
  padding: 9px 11px;
}

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.metric {
  background: var(--surface-2);
  border-radius: 9px;
  padding: 10px 8px;
  text-align: center;
}
.metric-value { display: block; font-size: 19px; font-weight: 650; letter-spacing: -0.3px; }
.metric-label { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.metrics-empty {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 9px;
  padding: 12px;
  text-align: center;
}

.details { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 13px; }
.detail { display: flex; gap: 6px; }
.detail span { color: var(--muted); }
.detail b { font-weight: 600; }

.card-actions { display: flex; flex-direction: column; gap: 8px; margin-top: auto; }
.action-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- buttons ---- */
.btn {
  display: inline-block;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: filter 0.12s ease, opacity 0.12s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.18); text-decoration: none; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #0b1020; font-weight: 600; }
.btn-start   { border-color: rgba(61,214,140,0.4); color: var(--green); }
.btn-stop    { border-color: rgba(240,113,120,0.4); color: var(--red); }
.btn-restart { border-color: rgba(240,183,117,0.4); color: var(--amber); }
.btn-danger  { background: var(--red); border-color: var(--red); color: #1a0d0f; font-weight: 600; }
.btn-quiet   { color: var(--muted); }

/* ---- login ---- */
.page-login .content { display: grid; place-items: center; min-height: 70vh; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 30px;
  width: min(380px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font: inherit;
}
.login-card input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.form-error {
  background: rgba(240,113,120,0.12);
  border: 1px solid rgba(240,113,120,0.35);
  color: var(--red);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13px;
}

/* ---- console ---- */
.console-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.console-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.console-toolbar label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.console-toolbar select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 7px;
  padding: 5px 8px;
  font: inherit;
  font-size: 13px;
}
.console-toolbar .checkbox { cursor: pointer; }
.stream-state { margin-left: auto; font-size: 12px; color: var(--muted); }
.stream-state.live { color: var(--green); }
.stream-state.down { color: var(--red); }

.console {
  margin: 0;
  padding: 14px 16px;
  height: min(62vh, 640px);
  overflow: auto;
  font: 12.5px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  background: #0c1017;
}
.log-line { display: block; }
.log-time { color: #5c677d; margin-right: 8px; }
.log-level { font-weight: 700; margin-right: 8px; }
.level-DEBUG    { color: #6c7a91; }
.level-INFO     { color: var(--accent); }
.level-WARNING  { color: var(--amber); }
.level-ERROR    { color: var(--red); }
.level-CRITICAL { color: #fff; background: var(--red); padding: 0 4px; border-radius: 3px; }
.level-UNKNOWN  { color: var(--muted); }
.log-msg { color: #c8d2e0; }

/* ---- confirm / error ---- */
.confirm-wrap, .error-wrap { display: grid; place-items: center; padding: 40px 0; }
.confirm-card {
  background: var(--surface);
  border: 1px solid rgba(240,113,120,0.4);
  border-radius: var(--radius);
  padding: 28px;
  width: min(520px, 92vw);
}
.confirm-card h1 { margin: 0 0 12px; font-size: 20px; }
.confirm-warning { color: var(--red); }
.confirm-actions { display: flex; gap: 10px; align-items: center; margin-top: 20px; }

@media (max-width: 560px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 20px 16px 48px; }
}

/* ---- members / retention ---- */
/* Reuses the existing tokens and the .panel/.metric shapes from the cards, so
   this page reads as part of the same panel rather than a bolted-on report. */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.panel-head h2 { margin: 0; font-size: 17px; font-weight: 600; }

/* auto-fit rather than a fixed column count: the same markup has to hold four
   tiles on a phone and six on a desktop without a second breakpoint. */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.metric-grid-wide { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.metric-hero {
  background: linear-gradient(180deg, rgba(110,168,254,0.16), rgba(110,168,254,0.05));
  border: 1px solid rgba(110,168,254,0.3);
}
.metric-hero .metric-value { font-size: 30px; color: var(--accent); }

.period-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.period-tab {
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface-2);
  white-space: nowrap;
}
.period-tab:hover { text-decoration: none; color: var(--text); }
.period-tab.is-active {
  background: rgba(110,168,254,0.16);
  border-color: rgba(110,168,254,0.35);
  color: var(--accent);
}

/* The Profile / Chat switch on the Mod action queue. Same pills as the server
   tabs, plus a dimmed count - every tab shows every category's number, so an
   empty tab still says how much is waiting on the other one. */
.case-tabs { margin: 12px 0 4px; }
.tab-count {
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
  margin-left: 2px;
}

.pill-quiet {
  background: var(--surface-2);
  color: var(--muted);
  border-color: var(--border);
}

/* A wide table must scroll INSIDE its own box - never let the page itself
   scroll sideways on a phone. */
.table-scroll { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  white-space: nowrap;
}
.data-table th,
.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.data-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  font-weight: 600;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .is-muted td { color: var(--muted); }
.data-table .is-error td { color: var(--red); }
.error-text { color: var(--red); }

.hint {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 10px 12px;
}

/* ---------------------------------------------------------------------------
   Moderation pages
   --------------------------------------------------------------------------- */

.topbar-nav { display: flex; gap: 2px; margin-left: 22px; flex: 1; flex-wrap: wrap; }
.nav-link {
  color: var(--muted); text-decoration: none; padding: 7px 12px;
  border-radius: 8px; font-size: 13px; font-weight: 500; white-space: nowrap;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.is-active { color: var(--text); background: var(--surface-2); }

.server-grid {
  display: grid; gap: 14px; margin-top: 16px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.server-card {
  display: block; padding: 18px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface-2); text-decoration: none;
  color: var(--text);
}
.server-card:hover { border-color: var(--accent); }
.server-card h3 { margin: 0 0 4px; font-size: 16px; }
.server-card .btn { margin-top: 12px; pointer-events: none; }

.queue-summary { color: var(--muted); font-size: 13px; margin: 12px 0 4px; }
.case-grid {
  display: grid; gap: 16px; margin-top: 12px;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
}
.case-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); padding: 16px;
}
.case-report { border-left: 3px solid var(--amber); }
.case-underage { border-left: 3px solid var(--red); }
.case-catfish { border-left: 3px solid var(--accent); }
.case-adfilter { border-left: 3px solid var(--green); }

.case-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.case-head h3 { margin: 2px 0; font-size: 17px; word-break: break-word; }
.case-kind { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.case-ids { margin: 0; font-size: 12px; color: var(--muted); }
.case-blurb { color: var(--muted); font-size: 13px; margin: 10px 0; }

.case-reason h4, .case-bio h4, .case-evidence h4 {
  margin: 14px 0 6px; font-size: 12px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted);
}
.case-reason blockquote {
  margin: 0; padding: 10px 12px; background: var(--bg);
  border-left: 2px solid var(--border); border-radius: 6px;
  white-space: pre-wrap; word-break: break-word;
}
.case-facts, .case-links { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.case-links a { color: var(--accent); word-break: break-all; }
.case-fields { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 10px 0; font-size: 13px; }
.case-fields dt { color: var(--muted); }
.case-fields dd { margin: 0; word-break: break-word; }
.case-bio p { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 13px; }
.case-evidence ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.case-evidence code {
  display: block; padding: 8px 10px; background: var(--bg); border-radius: 6px;
  white-space: pre-wrap; word-break: break-word; font-size: 12px;
}
.evidence-state { font-size: 11px; color: var(--muted); text-transform: uppercase; }

.case-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px;
  padding-top: 14px; border-top: 1px solid var(--border); }
.owner-tag {
  margin-left: 6px; font-size: 10px; text-transform: uppercase;
  opacity: .75; letter-spacing: .05em;
}

/* Photos arrive blurred. A moderator working a queue of reports should decide
   when a picture appears on their screen, not have it appear because the page
   finished loading. */
.photo-strip { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.photo-tile {
  position: relative; padding: 0; border: 1px solid var(--border);
  border-radius: 8px; overflow: hidden; background: var(--bg);
  cursor: pointer; line-height: 0;
}
.photo-tile img { width: 150px; height: 150px; object-fit: cover; display: block; }
.photo-tile.is-blurred img { filter: blur(18px); }
.photo-hint {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; font-size: 11px; color: var(--text);
  background: rgba(15, 20, 32, .55); line-height: 1.4; text-align: center;
}
.photo-tile:not(.is-blurred) .photo-hint { display: none; }
.photo-tile img[data-broken="1"] { filter: none; }
.photo-none { font-size: 13px; margin: 8px 0; }

.empty-queue { padding: 28px 4px; text-align: center; color: var(--muted); }
.empty-queue h3 { margin: 0 0 6px; color: var(--text); }

.lookup-form { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.lookup-form input[type="search"], .lookup-form input[type="text"], .lookup-form select {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 8px 11px; font: inherit; min-width: 170px;
}
.state-warn { background: rgba(240, 183, 117, .16); color: var(--amber); }
