/**
 * Cyber Lemur Admin — ops UI
 * Tokens from tokens.css; premium dark emerald, restrained glass.
 */

:root {
  --admin-sidebar: 248px;
  --admin-top: 64px;
  --grad-primary: linear-gradient(135deg, #00e676 0%, #00c853 55%, #009e4a 100%);
  --grad-primary-soft: linear-gradient(135deg, rgba(0, 230, 118, 0.22), rgba(0, 158, 74, 0.08));
  --grad-danger: linear-gradient(135deg, #ff7a88 0%, #e84a5f 100%);
  --grad-surface: linear-gradient(180deg, rgba(14, 24, 20, 0.92), rgba(10, 18, 15, 0.88));
  --shadow-btn: 0 8px 24px rgba(0, 230, 118, 0.22);
  --shadow-card: 0 12px 40px rgba(0, 0, 0, 0.35);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-sans);
  background:
    radial-gradient(1100px 520px at 8% -8%, rgba(0, 230, 118, 0.14), transparent 55%),
    radial-gradient(900px 480px at 100% 0%, rgba(0, 90, 60, 0.2), transparent 50%),
    radial-gradient(700px 400px at 70% 110%, rgba(0, 230, 118, 0.05), transparent 45%),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--primary-bright); text-decoration: none; }
a:hover { text-decoration: underline; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.hidden { display: none !important; }

/* —— Shell —— */
.shell { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; }
.topbar {
  display: flex; align-items: center; gap: var(--sp-3);
  min-height: var(--admin-top);
  padding: 10px 20px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(5, 9, 7, 0.78);
  backdrop-filter: blur(16px) saturate(1.2);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.brand img {
  width: 36px; height: 36px; border-radius: 10px;
  box-shadow: 0 0 0 1px var(--border), 0 8px 20px rgba(0, 230, 118, 0.15);
}
.brand strong {
  display: block; font-size: 15px; font-weight: 650;
  letter-spacing: -0.03em; line-height: 1.2;
}
.brand span { display: block; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.pill {
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 7px 12px; border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--grad-primary-soft);
  color: var(--primary-bright);
  white-space: nowrap;
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
}
@media (min-width: 960px) {
  .layout {
    grid-template-columns: var(--admin-sidebar) 1fr;
    min-height: calc(100dvh - var(--admin-top));
  }
  .nav {
    border-right: 1px solid var(--border-soft);
    position: sticky;
    top: var(--admin-top);
    height: calc(100dvh - var(--admin-top));
    overflow: auto;
    flex-direction: column;
    overflow-x: visible;
    padding: 20px 14px;
    gap: 4px;
  }
}

.nav {
  padding: 12px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.nav button {
  appearance: none; border: 1px solid transparent; background: transparent;
  color: var(--text-secondary); text-align: left;
  padding: 11px 14px; border-radius: 10px;
  cursor: pointer; min-height: 44px; white-space: nowrap;
  display: flex; align-items: center; gap: 10px;
  font-size: 13.5px; font-weight: 500;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.nav button svg { width: 18px; height: 18px; opacity: 0.7; flex-shrink: 0; }
.nav button:hover, .nav button:focus-visible {
  color: var(--text); background: var(--glass); outline: none;
}
.nav button:hover svg, .nav button.active svg { opacity: 1; color: var(--primary-bright); }
.nav button.active {
  color: var(--text);
  background: var(--grad-primary-soft);
  border-color: var(--border);
  box-shadow: inset 0 0 0 1px rgba(0, 230, 118, 0.08);
}

.main { padding: 20px 16px 48px; min-width: 0; }
@media (min-width: 960px) { .main { padding: 28px 28px 64px; } }

.panel { display: none; }
.panel.active { display: block; animation: rise .28s var(--ease); }
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 22px;
}
.page-head h1 {
  margin: 0 0 6px;
  font-size: clamp(24px, 3vw, 30px);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.15;
}
.page-head .sub {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
  max-width: 42ch;
}

.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }

/* —— Buttons —— */
.btn {
  appearance: none;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-radius: 11px;
  padding: 11px 16px;
  min-height: 44px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: -0.01em;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), filter var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.btn:hover, .btn:focus-visible {
  border-color: var(--border);
  filter: brightness(1.06);
  outline: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }
.btn-primary {
  background: var(--grad-primary);
  color: var(--text-on-primary);
  border-color: transparent;
  box-shadow: var(--shadow-btn);
}
.btn-primary:hover, .btn-primary:focus-visible {
  filter: brightness(1.08);
  box-shadow: 0 10px 28px rgba(0, 230, 118, 0.32);
}
.btn-danger {
  color: #fff;
  border-color: transparent;
  background: var(--grad-danger);
  box-shadow: 0 8px 20px rgba(232, 74, 95, 0.25);
}
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-soft);
}
.btn-soft {
  background: var(--grad-primary-soft);
  color: var(--primary-bright);
  border-color: var(--border);
}
.btn-sm { min-height: 40px; padding: 8px 12px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; display: inline-flex; justify-content: center; align-items: center; }

/* —— KPI / cards —— */
.kpi-row {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
  margin-bottom: 16px;
}
@media (min-width: 640px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .kpi-row { grid-template-columns: repeat(4, 1fr); } }

.kpi {
  position: relative;
  overflow: hidden;
  padding: 18px 18px 16px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border-soft);
  background: var(--grad-surface);
  box-shadow: var(--shadow-card);
}
.kpi::before {
  content: "";
  position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--grad-primary);
  opacity: 0.9;
}
.kpi .label {
  font-size: 12px; font-weight: 550; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px;
}
.kpi .value {
  font-size: 28px; font-weight: 700; letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.kpi .hint { margin-top: 8px; font-size: 12px; color: var(--text-secondary); }
.kpi.accent-warn::before { background: linear-gradient(180deg, #f5c15c, #c9942e); }
.kpi.accent-info::before { background: linear-gradient(180deg, #4fc3f7, #1e88b8); }
.kpi.accent-danger::before { background: linear-gradient(180deg, #ff6b7a, #c6283d); }

.grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  margin-bottom: 16px;
}
.stat {
  padding: 14px 14px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  background: rgba(10, 18, 15, 0.7);
}
.stat b {
  display: block;
  font-size: 20px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}
.stat span { font-size: 12px; color: var(--text-muted); }

.charts {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
  margin-bottom: 18px;
}
@media (min-width: 900px) { .charts { grid-template-columns: 1.1fr 1fr; } }

.chart-card {
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  background: var(--grad-surface);
  padding: 16px 16px 12px;
  box-shadow: var(--shadow-card);
  min-height: 280px;
}
.chart-card h2 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.chart-card p {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--text-muted);
}
.chart-wrap { position: relative; height: 220px; }

.field { display: flex; gap: 10px; flex-wrap: wrap; width: 100%; }
.field input, .field textarea, .field select {
  flex: 1; min-width: 160px; min-height: 44px;
  padding: 11px 14px; border-radius: 11px;
  border: 1px solid var(--border-soft);
  background: rgba(14, 24, 20, 0.9);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.field textarea { min-height: 100px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(0, 230, 118, 0.15);
}

.list { display: grid; gap: 10px; }
.item {
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  background: var(--grad-surface);
  padding: 14px 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.item h3 { margin: 0 0 6px; font-size: 15px; font-weight: 650; letter-spacing: -0.02em; }
.meta { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); line-height: 1.55; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 600; padding: 3px 9px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-soft);
  color: var(--text-secondary);
  vertical-align: middle;
}
.badge.ok { color: var(--primary-bright); border-color: var(--border); background: var(--primary-wash); }
.badge.warn { color: var(--warning); border-color: rgba(245,193,92,.35); background: rgba(245,193,92,.08); }
.badge.bad { color: var(--danger); border-color: rgba(255,107,122,.35); background: rgba(255,107,122,.08); }

.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translateX(-50%) translateY(16px);
  background: rgba(14, 24, 20, 0.95);
  border: 1px solid var(--border);
  padding: 12px 18px; border-radius: 12px;
  opacity: 0; pointer-events: none;
  transition: .22s var(--ease); z-index: 60;
  max-width: min(92vw, 420px); text-align: center;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(12px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: rgba(255,107,122,.45); color: #ffc0c7; }

.gate, .unlock {
  max-width: 440px;
  margin: clamp(32px, 8vh, 72px) auto;
  padding: 28px 24px;
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  background: var(--grad-surface);
  box-shadow: var(--shadow-card);
}
.gate-brand {
  display: flex; align-items: center; gap: 14px; margin-bottom: 22px;
}
.gate-brand img {
  width: 48px; height: 48px; border-radius: 14px;
  box-shadow: 0 0 0 1px var(--border), 0 10px 28px rgba(0, 230, 118, 0.18);
}
.gate-brand strong {
  display: block; font-size: 15px; font-weight: 650; letter-spacing: -0.03em;
}
.gate-brand span {
  display: block; font-size: 12px; color: var(--text-muted); margin-top: 2px;
}
.gate h1, .unlock h1 {
  font-size: 28px; font-weight: 700; letter-spacing: -0.04em; margin: 0 0 8px;
}
.gate .sub, .unlock .sub { color: var(--text-secondary); font-size: 14px; margin: 0 0 18px; }
.code-inputs { display: flex; gap: 8px; justify-content: center; margin: 18px 0; }
.code-inputs input {
  width: 46px; height: 54px; text-align: center;
  font-size: 22px; font-weight: 650;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: rgba(14, 24, 20, 0.95);
  font-variant-numeric: tabular-nums;
}
.code-inputs input:focus {
  outline: none;
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(0, 230, 118, 0.18);
}

pre.dump, .data-card {
  white-space: pre-wrap; word-break: break-word;
  font-family: var(--font-mono); font-size: 12px;
  color: var(--text-secondary); margin: 0;
  background: rgba(5, 9, 7, 0.55);
  padding: 14px; border-radius: var(--r-md);
  border: 1px solid var(--border-soft);
}
details.tech {
  margin-top: 8px;
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  background: rgba(10, 18, 15, 0.5);
  overflow: hidden;
}
details.tech summary {
  cursor: pointer; padding: 12px 14px;
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
  list-style: none;
}
details.tech summary::-webkit-details-marker { display: none; }
details.tech[open] summary { border-bottom: 1px solid var(--border-soft); color: var(--text); }
details.tech pre { border: 0; border-radius: 0; }

.msg { padding: 10px 12px; border-radius: 10px; margin: 8px 0; background: rgba(5, 9, 7, 0.45); border: 1px solid var(--border-soft); }
.msg.admin { border-left: 3px solid var(--primary); }
.msg.user { border-left: 3px solid var(--info); }

.ref-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  margin-bottom: 14px;
}
