:root {
  --bg:        #0a1020;
  --bg-2:      #0f1730;
  --surface:   #121c38;
  --surface-2: #172347;
  --border:    #243363;
  --text:      #e6ecff;
  --muted:     #8a97c4;
  --accent:    #3b82f6;
  --accent-2:  #60a5fa;
  --accent-dk: #1e3a8a;
  --danger:    #ef4444;
  --danger-dk: #7f1d1d;
  --ok:        #22c55e;
  --radius:    10px;
  --shadow:    0 6px 24px rgba(2, 8, 30, 0.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 700px at 0% 0%, #172347 0%, var(--bg) 60%) fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 14.5px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.92em;
  color: #c7d4ff;
}

/* ===== Sidebar layout ===== */
body:has(.sidebar) { display: grid; grid-template-columns: 240px 1fr; }
.sidebar {
  position: sticky; top: 0;
  height: 100vh;
  background: linear-gradient(180deg, #0d1530, #0a1020);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 22px 16px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-center { justify-content: center; margin-bottom: 12px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dk));
  display: grid; place-items: center;
  font-weight: 800; color: white; font-size: 18px;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}
.brand-title { font-weight: 700; letter-spacing: 0.3px; }
.brand-sub { color: var(--muted); font-size: 12px; }

.nav { margin-top: 24px; display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 8px;
  color: #c8d3ff; font-weight: 500;
}
.nav a:hover { background: var(--surface); text-decoration: none; }
.nav a.active {
  background: linear-gradient(90deg, rgba(59,130,246,0.18), rgba(59,130,246,0.04));
  color: white;
  box-shadow: inset 2px 0 0 var(--accent);
}
.nav-ico { color: var(--accent-2); width: 16px; text-align: center; }

.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.who { color: var(--muted); font-size: 13px; margin-bottom: 8px; }

.main { padding: 28px 36px 60px; max-width: 1200px; }

/* ===== Page head ===== */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 22px; }
.page-head h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: -0.3px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 12px; }
.card-head h2 { margin: 0; font-size: 16px; letter-spacing: 0.1px; }

.card-hero {
  display: flex; justify-content: space-between; align-items: center; gap: 24px;
  background: linear-gradient(135deg, #1a2a5c 0%, var(--surface) 70%);
  border-color: #2c4294;
}
.hero-kicker { color: var(--accent-2); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.hero-title { margin: 6px 0 10px; font-size: 22px; }
.hero-notes { margin: 0 0 8px; color: #d8e1ff; }
.hero-meta { margin-top: 6px; }

/* ===== Badges / pills ===== */
.badge {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-2);
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 3px 10px; border-radius: 999px; font-size: 12px;
}
.pill {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 2px 10px; border-radius: 999px; font-size: 12px;
}

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; margin: 4px -6px -6px; padding: 0 6px 6px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.table tr:hover td { background: rgba(59, 130, 246, 0.04); }
.row-actions { display: flex; gap: 6px; white-space: nowrap; }

/* ===== Forms ===== */
.form { display: flex; flex-direction: column; gap: 12px; }
.form-row { flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.form label.grow { flex: 1 1 220px; }
.form input[type=text], .form input[type=password], .form input:not([type]), .form input[type=file] {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
  min-width: 160px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,0.2); }

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, var(--accent), #2563eb);
  color: white;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
}
.btn-primary:hover { background: linear-gradient(180deg, #4f8df7, #2563eb); }
.btn-lg { padding: 12px 22px; font-size: 14px; }
.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-ghost:hover { background: var(--surface-2); border-color: var(--accent); }
.btn-danger {
  background: transparent;
  border-color: var(--danger-dk);
  color: #fca5a5;
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.1); border-color: var(--danger); }

/* ===== Alerts ===== */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.alert-err { background: rgba(239,68,68,0.12); border: 1px solid var(--danger-dk); color: #fecaca; }

/* ===== Empty state ===== */
.empty { padding: 30px 10px; text-align: center; color: var(--muted); }
.empty p { margin: 4px 0; }

/* ===== Keybox ===== */
.keybox {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-2);
  border: 1px dashed var(--border);
  padding: 12px 14px;
  border-radius: 8px;
}
.keybox code { flex: 1; word-break: break-all; color: var(--accent-2); }

/* ===== Auth page ===== */
body.auth { display: flex; align-items: center; justify-content: center; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 30px 28px;
  box-shadow: var(--shadow);
}
.auth-title { margin: 18px 0 18px; font-size: 20px; text-align: center; }

/* ===== Live indicator ===== */
.live-indicator {
  display: flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px;
}
.live-indicator .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
  animation: livePulse 1.8s infinite;
}
@keyframes livePulse {
  0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
  70%  { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* ===== Injector block ===== */
.inj {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.inj:last-child { margin-bottom: 0; }
.inj-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px; gap: 12px;
}
.inj-status { margin-bottom: 10px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.88em; }

/* ===== Pill variants ===== */
.pill-ok {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #86efac;
}
.pill-muted {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}

/* ===== Form actions row ===== */
.form-actions { display: flex; gap: 10px; margin-top: 6px; }

/* ===== Toasts / flash ===== */
.toast-container {
  position: fixed;
  top: 18px; right: 18px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 200;
  max-width: 360px;
}
.toast {
  padding: 10px 14px;
  border-radius: 8px;
  color: white;
  font-size: 13px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  cursor: pointer;
  animation: toastIn 0.22s ease-out;
}
.toast-success { background: linear-gradient(180deg, #16a34a, #15803d); }
.toast-error   { background: linear-gradient(180deg, #ef4444, #b91c1c); }
.toast-leaving { animation: toastOut 0.25s forwards; }
@keyframes toastIn  { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to   { opacity: 0; transform: translateX(12px); } }

/* ===== Hamburger + mobile ===== */
.hamburger {
  display: none;
  position: fixed; top: 14px; right: 14px;
  z-index: 150;
  width: 40px; height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
}
@media (max-width: 820px) {
  body:has(.sidebar) { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0;
    width: 240px; height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.22s ease-out;
    z-index: 140;
  }
  .sidebar.open { transform: translateX(0); }
  .hamburger { display: grid; place-items: center; }
  .main { padding: 56px 18px 40px; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .card-tools { flex-wrap: wrap; }
}

/* ===== Drag-and-drop zone ===== */
.dd-zone {
  margin-top: 14px;
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 22px;
  text-align: center;
  color: var(--muted);
  transition: background 0.15s, border-color 0.15s;
}
.dd-inner { display: flex; flex-direction: column; gap: 4px; }
.dd-zone.hover {
  background: rgba(59,130,246,0.08);
  border-color: var(--accent);
  color: var(--text);
}

/* ===== Card tools header row ===== */
.card-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.head-actions { display: flex; align-items: center; gap: 12px; }
.input-sm {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  min-width: 140px;
}
.input-sm:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,0.2); }

/* ===== Sticky table headers ===== */
.table thead th {
  position: sticky; top: 0;
  background: var(--surface);
  z-index: 1;
}

/* ===== Clickable rows + copy buttons ===== */
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: rgba(59, 130, 246, 0.06); }
.copy-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 4px;
  padding: 0 6px;
  font-size: 12px;
  cursor: pointer;
  margin-left: 4px;
  line-height: 1.6;
}
.copy-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--accent); }
.hash-cell { display: flex; align-items: center; gap: 6px; white-space: nowrap; }

/* ===== Character detail ===== */
.grid2 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px 24px;
  margin-top: 6px;
}
.grid2 .big { font-size: 16px; margin-top: 2px; }
.status-lines { margin-top: 14px; display: flex; flex-direction: column; gap: 4px; }
.status-line { font-size: 13px; }
.activity {
  list-style: none;
  margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
  max-height: 280px; overflow-y: auto;
}
.activity li { font-size: 13px; padding: 6px 8px; background: var(--bg-2); border-radius: 6px; }
.activity li.empty { background: transparent; padding: 10px 0; }

/* ===== Error pages ===== */
.error-wrap {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  min-height: 50vh;
  gap: 14px;
}
.error-code {
  font-size: 72px; letter-spacing: -2px;
  margin: 0;
  background: linear-gradient(180deg, var(--accent-2), var(--accent-dk));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.error-card { text-align: center; }
.error-card .error-code { font-size: 56px; }

/* ===== Active link in sidebar ===== */
.active-link { color: white; }

/* ===== Empty state CTA ===== */
.empty-cta { padding: 36px 12px; }
.empty-cta p:first-child { font-size: 15px; margin-bottom: 6px; color: var(--text); }
