/* =========================================================================
   Murder Maker — admin console stylesheet.
   Desktop-first, on-brand (gold on near-black, FR). Tokens mirror the landing
   site / Flutter AppColors so the operator surface feels like one product.
   Zero-build, zero-framework.
   ========================================================================= */

:root {
  --bg: #06060e;
  --bg-2: #0b0b18;
  --surface: #12121f;
  --surface-2: #1a1a30;
  --border: #272742;
  --border-2: #38385c;

  --gold: #c9a84c;
  --gold-bright: #d4af37;
  --gold-soft: rgba(201, 168, 76, 0.14);
  --gold-line: rgba(201, 168, 76, 0.22);

  --violet: #a78bfa;
  --oxblood: #7b1f1f;

  --text: #e8e0d0;
  --text-dim: #8a8aaa;
  --text-muted: #5a5a7a;

  --success: #10b981;
  --warn: #d99a2b;
  --danger: #f87171;

  --radius: 14px;
  --radius-sm: 9px;

  --font-display: "Playfair Display", Georgia, "Times New Roman", serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(60rem 40rem at 80% -10%, rgba(201, 168, 76, 0.07), transparent 60%),
    radial-gradient(48rem 36rem at 6% 6%, rgba(123, 31, 31, 0.10), transparent 55%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; margin: 0; }
.mono { font-family: var(--font-mono); font-size: 0.86em; color: var(--text-dim); }

/* ── Brand ──────────────────────────────────────────────────────────────── */
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 1.5rem; color: var(--text); }
.brand-sub { margin: 2px 0 0; color: var(--gold); font-size: 0.85rem; letter-spacing: 0.04em; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  border: 1px solid var(--gold-line);
  color: var(--gold-bright); font-family: var(--font-display); font-size: 1.4rem; font-weight: 700;
}
.brand-sm .brand-mark { width: 30px; height: 30px; font-size: 1.05rem; border-radius: 8px; }
.brand-sm strong { font-family: var(--font-display); font-size: 1.05rem; }
.tag {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--gold); border: 1px solid var(--gold-line); border-radius: 6px;
  padding: 1px 6px;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  font: inherit; cursor: pointer; border-radius: var(--radius-sm);
  padding: 9px 16px; border: 1px solid var(--border-2);
  background: var(--surface-2); color: var(--text);
  transition: filter 0.12s ease, border-color 0.12s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.15); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-sm { padding: 6px 11px; font-size: 0.86rem; }
.btn-gold { background: linear-gradient(160deg, var(--gold), #a98a35); color: #1a1404; border-color: var(--gold-bright); font-weight: 600; }
.btn-ghost { background: transparent; }
.btn-warn { background: transparent; color: var(--warn); border-color: var(--warn); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: rgba(248, 113, 113, 0.12); }
.link-quiet {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font: inherit; font-size: 0.82rem; text-decoration: underline; padding: 4px;
}
.link-quiet:hover { color: var(--gold); }

/* ── Form fields ────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 0.82rem; color: var(--text-dim); }
input, select {
  font: inherit; color: var(--text);
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 11px;
}
input:focus, select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
select option { background: var(--bg-2); }

/* ── Messages ───────────────────────────────────────────────────────────── */
.msg { border-radius: var(--radius-sm); padding: 9px 12px; font-size: 0.88rem; margin: 10px 0; }
.msg-error { background: rgba(248, 113, 113, 0.12); border: 1px solid rgba(248, 113, 113, 0.4); color: #fca5a5; }
.msg-ok { background: rgba(16, 185, 129, 0.12); border: 1px solid rgba(16, 185, 129, 0.4); color: #6ee7b7; }

/* ── Login ──────────────────────────────────────────────────────────────── */
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
  display: flex; flex-direction: column; gap: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.login-card .brand { margin-bottom: 4px; }

/* ── Top bar ────────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; border-bottom: 1px solid var(--border);
  background: rgba(11, 11, 24, 0.85); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.topbar-right { display: flex; align-items: center; gap: 14px; }
.me-label { color: var(--text-dim); font-size: 0.85rem; }

/* ── Content ────────────────────────────────────────────────────────────── */
.content { max-width: 1240px; margin: 0 auto; padding: 22px 24px 60px; position: relative; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar #search { flex: 1; min-width: 240px; }

/* ── Users table ────────────────────────────────────────────────────────── */
.users-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.users-table thead th {
  text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-muted); font-weight: 600; padding: 11px 14px;
  border-bottom: 1px solid var(--border); background: var(--bg-2);
}
.users-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.users-table tbody tr:last-child td { border-bottom: none; }
.users-table .row { cursor: pointer; transition: background 0.1s ease; }
.users-table .row:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.ok-cell { color: var(--success); }
.dim-cell { color: var(--text-muted); }
.loading { text-align: center; color: var(--text-muted); padding: 26px; font-style: italic; }

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em;
  padding: 2px 9px; border-radius: 999px; border: 1px solid transparent; text-transform: capitalize;
}
.badge-gold { background: var(--gold-soft); color: var(--gold-bright); border-color: var(--gold-line); }
.badge-admin { background: rgba(167, 139, 250, 0.16); color: var(--violet); border-color: rgba(167, 139, 250, 0.4); }
.badge-dim { background: var(--surface-2); color: var(--text-dim); border-color: var(--border); }
.badge-ok { background: rgba(16, 185, 129, 0.14); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.35); }
.badge-danger { background: rgba(248, 113, 113, 0.14); color: #fca5a5; border-color: rgba(248, 113, 113, 0.35); }
.badge-warn { background: rgba(245, 158, 11, 0.14); color: #fcd34d; border-color: rgba(245, 158, 11, 0.4); }

/* ── Nav badge (pending-count pip on the Modération tab) ────────────────── */
.nav-badge {
  display: inline-block; min-width: 18px; margin-left: 6px; padding: 0 5px;
  font-size: 0.68rem; font-weight: 700; line-height: 18px; text-align: center;
  border-radius: 999px; background: rgba(245, 158, 11, 0.2); color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

/* ── Checklist (moderation pre-checks) ──────────────────────────────────── */
.checklist { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.chk-item { display: flex; gap: 9px; align-items: flex-start; font-size: 0.86rem; }
.chk-icon { flex: 0 0 1.1em; font-weight: 700; }
.chk-ok .chk-icon { color: #6ee7b7; }
.chk-warn .chk-icon { color: #fcd34d; }
.chk-bad .chk-icon { color: #fca5a5; }
.chk-detail { margin-top: 2px; }

/* ── Pager ──────────────────────────────────────────────────────────────── */
.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 18px; }
.page-info { color: var(--text-dim); font-size: 0.85rem; }

/* ── Detail panel (slide-over) ──────────────────────────────────────────── */
.detail {
  position: fixed; top: 0; right: 0; height: 100vh; width: 480px; max-width: 92vw;
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: -24px 0 60px rgba(0, 0, 0, 0.5);
  padding: 20px 22px; overflow-y: auto; z-index: 20;
}
.detail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.detail-head h2 { font-size: 1.3rem; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin-bottom: 8px; }
.kv { display: flex; flex-direction: column; gap: 2px; }
.kv-k { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.kv-v { font-size: 0.92rem; }
.self-note { font-size: 0.82rem; color: var(--warn); background: rgba(217, 154, 43, 0.1); border: 1px solid rgba(217, 154, 43, 0.3); border-radius: var(--radius-sm); padding: 8px 10px; }

.action-block { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.action-block h4 { font-size: 0.92rem; color: var(--gold); }
.action-block .inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.action-block .inline input, .action-block .inline select { flex: 1; min-width: 120px; }
.danger-zone { border-top-color: rgba(248, 113, 113, 0.3); }
.danger-zone h4 { color: var(--danger); }

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(3, 3, 8, 0.72); backdrop-filter: blur(3px);
  display: grid; place-items: center; z-index: 40; padding: 24px;
}
.modal {
  width: 100%; max-width: 420px;
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--radius); padding: 22px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.6);
}
.modal h3 { font-size: 1.15rem; }
.modal p { margin: 0; color: var(--text-dim); font-size: 0.9rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* ── Top-bar tabs / view nav ────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; }
.tab {
  font: inherit; cursor: pointer; background: transparent; color: var(--text-dim);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 7px 14px; font-size: 0.9rem; transition: color 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}
.tab:hover { color: var(--text); background: var(--surface); }
.tab.is-active {
  color: var(--gold-bright); background: var(--gold-soft); border-color: var(--gold-line); font-weight: 600;
}

/* ── View header (dashboard / sizes) ────────────────────────────────────── */
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.view-title { font-size: 1.5rem; color: var(--text); }
.view-sub { margin: 4px 0 0; color: var(--text-muted); font-size: 0.82rem; }
.view-head-actions { display: flex; gap: 10px; align-items: center; }

/* ── Metric cards ───────────────────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 22px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 6px;
}
.card-gold { border-color: var(--gold-line); background: linear-gradient(160deg, var(--gold-soft), var(--surface)); }
.card-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); }
.card-value { font-family: var(--font-display); font-size: 1.9rem; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.card-gold .card-value { color: var(--gold-bright); }
.card-sub { font-size: 0.8rem; color: var(--text-dim); }
.card-sub.muted { color: var(--text-muted); font-style: italic; }

/* ── Panels (titled blocks) ─────────────────────────────────────────────── */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 20px;
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-title { font-size: 1.05rem; color: var(--gold); }
.panel-note { font-size: 0.78rem; color: var(--text-muted); }
.panels-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 920px) { .panels-2 { grid-template-columns: 1fr; } }

.unavailable { color: var(--text-muted); font-style: italic; font-size: 0.88rem; padding: 8px 0; }

/* ── Sparkline / bar chart (inline SVG) ─────────────────────────────────── */
.spark { width: 100%; height: 64px; display: block; }
.spark-bar { fill: var(--gold); opacity: 0.85; }
.spark-bar:hover { opacity: 1; fill: var(--gold-bright); }
.spark-baseline { stroke: var(--border); stroke-width: 1; }
.chart-legend { display: flex; gap: 18px; margin-top: 10px; flex-wrap: wrap; }
.legend-item { display: flex; flex-direction: column; gap: 1px; }
.legend-k { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.legend-v { font-size: 1.1rem; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }

/* ── Inline ratio bars (plan mix, verification, byLabel) ────────────────── */
.ratio-row { display: grid; grid-template-columns: 130px 1fr 64px; align-items: center; gap: 12px; margin: 8px 0; }
.ratio-label { font-size: 0.84rem; color: var(--text-dim); }
.ratio-track { height: 9px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.ratio-fill { height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-bright)); border-radius: 999px; }
.ratio-fill.alt { background: linear-gradient(90deg, #6d5fc0, var(--violet)); }
.ratio-val { font-size: 0.82rem; color: var(--text-dim); text-align: right; font-variant-numeric: tabular-nums; }

/* ── Data tables (sizes / top lists) ────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th {
  text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--border);
}
.data-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.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; }
.cell-name { font-weight: 500; color: var(--text); }
.cell-strong { color: var(--gold-bright); font-weight: 600; }

/* ── Supervision / health view ──────────────────────────────────────────── */
/* Auto-refresh toggle (sits in the view header actions). */
.autoref { display: flex; align-items: center; gap: 7px; font-size: 0.84rem; color: var(--text-dim); cursor: pointer; user-select: none; }
.autoref input { width: auto; accent-color: var(--gold); }

/* Status dot — green/amber/red health indicator on each card. */
.dot {
  width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block;
  background: var(--text-muted);
}
.dot-ok { background: var(--success); box-shadow: 0 0 8px rgba(16, 185, 129, 0.65); }
.dot-warn { background: var(--warn); box-shadow: 0 0 8px rgba(217, 154, 43, 0.65); }
.dot-bad { background: var(--danger); box-shadow: 0 0 9px rgba(248, 113, 113, 0.7); animation: dot-pulse 1.4s ease-in-out infinite; }
.dot-idle { background: var(--text-muted); }
@keyframes dot-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* The health cards reuse .card but put a dot beside the label. */
.hcard .card-label { display: flex; align-items: center; gap: 7px; }

.obs-note {
  font-size: 0.8rem; color: var(--text-muted); margin: -6px 0 22px;
  background: var(--bg-2); border: 1px solid var(--border); border-left: 2px solid var(--gold-line);
  border-radius: var(--radius-sm); padding: 9px 12px;
}
.obs-note strong { color: var(--text-dim); }

.panel-head-actions { display: flex; align-items: center; gap: 12px; }

/* Errors table: status colouring + expandable redacted stack. */
.err-row { cursor: pointer; }
.err-msg { color: var(--text-dim); max-width: 1px; }
.st-5xx { color: var(--danger); font-weight: 600; }
.st-4xx { color: var(--warn); font-weight: 600; }
.err-stack {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; margin: 4px 0; font-family: var(--font-mono); font-size: 0.78rem;
  line-height: 1.5; color: var(--text-dim); white-space: pre-wrap; word-break: break-word;
  max-height: 320px; overflow: auto;
}

/* Recent logs: dense monospace tail with level badges. */
.log-list {
  display: flex; flex-direction: column;
  max-height: 440px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-2);
}
.log-line {
  display: grid; grid-template-columns: 74px 56px 1fr auto; gap: 10px; align-items: baseline;
  padding: 5px 10px; border-bottom: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 0.8rem;
}
.log-line:last-child { border-bottom: none; }
.log-line:hover { background: var(--surface); }
.log-time { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.log-msg { color: var(--text); white-space: pre-wrap; word-break: break-word; }
.log-rid { color: var(--text-muted); font-size: 0.92em; }
.lvl {
  text-transform: uppercase; font-size: 0.62rem; font-weight: 700; letter-spacing: 0.04em;
  padding: 2px 0; border-radius: 5px; text-align: center;
}
.lvl-trace, .lvl-debug { background: var(--surface-2); color: var(--text-dim); }
.lvl-info { background: rgba(167, 139, 250, 0.16); color: var(--violet); }
.lvl-warn { background: rgba(217, 154, 43, 0.18); color: var(--warn); }
.lvl-error, .lvl-fatal { background: rgba(248, 113, 113, 0.18); color: var(--danger); }

[hidden] { display: none !important; }
