/* ==========================================================
   Edgycore Admin — standalone styles
   Self-contained: not coupled to the main game CSS.
   ========================================================== */

:root {
  --bg-0: #06050d;
  --bg-1: #0a0814;
  --bg-2: #110d22;
  --bg-3: #1a1530;
  --bg-4: #221b3d;
  --border:        rgba(167, 139, 250, 0.14);
  --border-mid:    rgba(167, 139, 250, 0.28);
  --border-strong: rgba(167, 139, 250, 0.5);
  --text-0: #f4f1ff;
  --text-1: #d2cdf0;
  --text-2: #9590bd;
  --text-3: #756e9c;
  --violet: #8b5cf6;
  --violet-soft: #a78bfa;
  --violet-deep: #6d28d9;
  --amber: #f59e0b;
  --amber-soft: #fbbf24;
  --gold: #fbbf24;
  --success: #34d399;
  --warning: #f59e0b;
  --danger: #f43f5e;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(167, 139, 250, 0.08), transparent 50%),
    radial-gradient(120% 80% at 100% 100%, rgba(244, 63, 94, 0.05), transparent 50%),
    var(--bg-0);
  color: var(--text-1);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  min-height: 100vh;
  overflow-x: hidden;
}

button { font-family: inherit; }

.mono { font-family: 'JetBrains Mono', monospace; }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger  { color: var(--danger); }
.muted        { color: var(--text-2); }

.tag-amber {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--amber-soft);
  font-weight: 600;
  font-size: 12.5px;
  min-width: 64px;
  text-align: center;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  background: var(--bg-3);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  color: var(--text-0);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s, background 0.15s, border-color 0.15s;
  white-space: nowrap;
  user-select: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn svg { width: 14px; height: 14px; }

.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; }

.btn-primary {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  border-color: rgba(167, 139, 250, 0.5);
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.3);
}
.btn-primary:hover { box-shadow: 0 6px 22px rgba(139, 92, 246, 0.5); }

.btn-violet {
  background: linear-gradient(135deg, #22d3ee, #0891b2);
  border-color: rgba(34, 211, 238, 0.5);
  box-shadow: 0 4px 14px rgba(34, 211, 238, 0.3);
  color: #0a0814;
}

.btn-warn {
  background: linear-gradient(135deg, #f59e0b, #b45309);
  border-color: rgba(245, 158, 11, 0.5);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
  color: #0a0814;
}

.btn-danger {
  background: linear-gradient(135deg, #f43f5e, #be123c);
  border-color: rgba(244, 63, 94, 0.5);
  box-shadow: 0 4px 14px rgba(244, 63, 94, 0.3);
}

.btn-ghost {
  background: rgba(34, 27, 61, 0.6);
  border-color: var(--border);
}
.btn-ghost:hover { border-color: var(--border-mid); background: rgba(34, 27, 61, 0.9); }

/* ===== LOCK SCREEN ===== */
.lock-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  z-index: 1000;
}
.lock-card {
  width: 100%; max-width: 380px;
  background: linear-gradient(180deg, rgba(34, 27, 61, 0.85), rgba(22, 16, 41, 0.85));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 36px 32px 28px;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6), 0 0 28px rgba(167, 139, 250, 0.15);
  backdrop-filter: blur(16px);
}
.lock-mark {
  width: 64px; height: 64px;
  margin: 0 auto 20px;
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.18), rgba(167, 139, 250, 0.12));
  border: 1px solid rgba(244, 63, 94, 0.4);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--danger);
  box-shadow: 0 0 24px rgba(244, 63, 94, 0.25);
}
.lock-mark svg { width: 26px; height: 26px; }
.lock-card h1 {
  font-family: 'Instrument Serif', serif;
  font-size: 26px;
  font-weight: 400;
  color: var(--text-0);
  margin-bottom: 8px;
}
.lock-card p {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 24px;
  line-height: 1.5;
}
#lock-form {
  display: flex; flex-direction: column;
  gap: 10px;
}
#lock-form input[type="password"] {
  width: 100%;
  height: 44px;
  padding: 0 16px;
  background: rgba(6, 5, 13, 0.6);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  color: var(--text-0);
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  text-align: center;
  letter-spacing: 0.2em;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#lock-form input[type="password"]:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.12);
}
.lock-error {
  min-height: 16px;
  font-size: 12px;
  color: var(--danger);
  font-weight: 500;
}
.lock-submit {
  width: 100%;
  height: 44px;
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  border: 1px solid rgba(167, 139, 250, 0.5);
  border-radius: var(--radius-sm);
  color: white;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.35);
  transition: box-shadow 0.15s;
}
.lock-submit:hover { box-shadow: 0 6px 22px rgba(139, 92, 246, 0.5); }
.lock-submit:disabled { opacity: 0.6; cursor: not-allowed; }
.lock-foot {
  margin-top: 20px;
  font-size: 10.5px;
  color: var(--text-3);
  letter-spacing: 0.04em;
}

/* ===== APP SHELL ===== */
.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px 80px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 0 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--violet) 0%, var(--violet-deep) 100%);
  display: flex; align-items: center; justify-content: center;
  color: white;
  box-shadow: 0 0 18px rgba(139, 92, 246, 0.4);
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-name {
  font-family: 'Instrument Serif', serif;
  font-size: 20px;
  color: var(--text-0);
  line-height: 1.1;
}
.brand-sub {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--violet-soft);
  font-weight: 700;
  margin-top: 2px;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-3);
  box-shadow: 0 0 8px var(--text-3);
  transition: background 0.2s, box-shadow 0.2s;
}
.status-dot.connected { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-dot.error { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.status-text {
  font-size: 11.5px;
  color: var(--text-2);
  margin-right: 6px;
  font-family: 'JetBrains Mono', monospace;
}

/* ===== KPI ROW ===== */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}
.kpi {
  background: linear-gradient(180deg, rgba(34, 27, 61, 0.7), rgba(22, 16, 41, 0.7));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}
.kpi-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-2);
  font-weight: 700;
}
.kpi-value {
  font-family: 'Instrument Serif', serif;
  font-size: 30px;
  font-weight: 400;
  color: var(--text-0);
  margin-top: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-value.mono { font-family: 'JetBrains Mono', monospace; font-size: 24px; font-weight: 700; }
.kpi-delta {
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 6px;
}

/* ===== CARD ===== */
.card {
  background: linear-gradient(180deg, rgba(20, 16, 38, 0.85), rgba(12, 9, 24, 0.85));
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  margin-bottom: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.card-head h2 {
  font-family: 'Instrument Serif', serif;
  font-size: 22px;
  font-weight: 400;
  color: var(--text-0);
  line-height: 1.1;
}
.card-head p { font-size: 12.5px; color: var(--text-2); margin-top: 4px; }

.card-head-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.card-head-actions input,
.card-head-actions select {
  height: 36px;
  padding: 0 12px;
  background: rgba(6, 5, 13, 0.6);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  color: var(--text-0);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  min-width: 0;
}
.card-head-actions input { width: 220px; }
.card-head-actions input:focus,
.card-head-actions select:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.1);
}

/* ===== GLOBALS GRID ===== */
.globals-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.globals-broadcast { grid-column: 1 / -1; }
.globals-block .lab {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-2);
  font-weight: 700;
  margin-bottom: 8px;
  display: block;
}
.globals-block .row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.globals-block input[type="range"] {
  flex: 1;
  accent-color: var(--violet-soft);
}
.globals-block input[type="text"] {
  flex: 1;
  height: 38px;
  padding: 0 14px;
  background: rgba(6, 5, 13, 0.6);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  color: var(--text-0);
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
}
.globals-block .hint {
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 8px;
  line-height: 1.5;
}

/* ===== USERS TABLE ===== */
.users-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.users-table thead th {
  background: rgba(34, 27, 61, 0.6);
  color: var(--text-2);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.users-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-1);
  vertical-align: middle;
}
.users-table tbody tr:last-child td { border-bottom: none; }
.users-table tbody tr:hover { background: rgba(167, 139, 250, 0.04); }

.users-table .empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}
.actions-col { width: 1%; white-space: nowrap; }

.user-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  position: relative;
}
.av-1 { background: linear-gradient(135deg, #a78bfa, #6d4bd8); box-shadow: 0 0 10px rgba(167, 139, 250, 0.4); }
.av-2 { background: linear-gradient(135deg, #22d3ee, #0891b2); box-shadow: 0 0 10px rgba(34, 211, 238, 0.4); }
.av-3 { background: linear-gradient(135deg, #34d399, #059669); box-shadow: 0 0 10px rgba(52, 211, 153, 0.4); }
.av-4 { background: linear-gradient(135deg, #f43f5e, #be123c); box-shadow: 0 0 10px rgba(244, 63, 94, 0.4); }
.av-5 { background: linear-gradient(135deg, #fbbf24, #d97706); box-shadow: 0 0 10px rgba(251, 191, 36, 0.4); }
.av-6 { background: linear-gradient(135deg, #ec4899, #be185d); box-shadow: 0 0 10px rgba(236, 72, 153, 0.4); }
.user-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: inherit;
}
.user-name {
  font-weight: 700;
  color: var(--text-0);
  font-size: 13.5px;
}
.user-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  color: var(--text-3);
  margin-top: 2px;
}
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: rgba(167, 139, 250, 0.15);
  border: 1px solid rgba(167, 139, 250, 0.3);
  color: var(--violet-soft);
}
.pill.amber { background: rgba(245, 158, 11, 0.15); border-color: rgba(245, 158, 11, 0.3); color: var(--amber-soft); }
.pill.warn { background: rgba(244, 63, 94, 0.15); border-color: rgba(244, 63, 94, 0.3); color: var(--danger); }
.pill.success { background: rgba(52, 211, 153, 0.15); border-color: rgba(52, 211, 153, 0.3); color: var(--success); }

.heat-meter {
  display: inline-flex;
  gap: 2px;
}
.heat-meter span {
  width: 4px; height: 12px;
  border-radius: 1px;
  background: rgba(167, 139, 250, 0.15);
}
.heat-meter span.on { background: var(--danger); box-shadow: 0 0 4px var(--danger); }

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* ===== DANGER ZONE ===== */
.danger-card {
  border-color: rgba(244, 63, 94, 0.25);
}
.danger-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}
.danger-block {
  background: rgba(244, 63, 94, 0.04);
  border: 1px solid rgba(244, 63, 94, 0.18);
  border-radius: var(--radius-md);
  padding: 18px 18px 20px;
}
.danger-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-0);
  margin-bottom: 6px;
}
.danger-desc {
  font-size: 11.5px;
  color: var(--text-2);
  line-height: 1.5;
  margin-bottom: 14px;
}

/* ===== USER MODAL ===== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(6, 5, 13, 0.78);
  backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  z-index: 900;
  padding: 24px;
  animation: backdrop-in 0.16s ease;
}
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 540px;
  background: linear-gradient(180deg, rgba(34, 27, 61, 0.95), rgba(22, 16, 41, 0.95));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 26px 28px;
  position: relative;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 30px; height: 30px;
  background: rgba(6, 5, 13, 0.6);
  border: 1px solid var(--border-mid);
  border-radius: 8px;
  color: var(--text-1);
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.modal-close:hover { color: var(--text-0); border-color: var(--border-strong); }
.modal-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}
.modal-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a78bfa, #6d4bd8);
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 0 16px rgba(167, 139, 250, 0.35);
}
.modal-name {
  font-family: 'Instrument Serif', serif;
  font-size: 22px;
  color: var(--text-0);
}
.modal-sub {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}
.modal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}
.modal-stat {
  background: rgba(6, 5, 13, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.modal-stat .lab {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-3);
  font-weight: 700;
}
.modal-stat .val {
  font-size: 15px;
  color: var(--text-0);
  font-weight: 700;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.modal-section {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 16px;
}
.modal-section .lab {
  display: block;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-2);
  font-weight: 700;
  margin-bottom: 10px;
}
.modal-section .row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.modal-section .row.wrap { flex-wrap: wrap; }
.modal-section input[type="text"] {
  flex: 1;
  height: 38px;
  padding: 0 14px;
  background: rgba(6, 5, 13, 0.6);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  color: var(--text-0);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13.5px;
  outline: none;
}

/* ===== TOASTS ===== */
.toast-stack {
  position: fixed;
  top: 24px; right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 260px;
  max-width: 360px;
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(34, 27, 61, 0.95), rgba(22, 16, 41, 0.95));
  border: 1px solid var(--border-strong);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  font-size: 12.5px;
  color: var(--text-0);
  animation: toast-in 0.18s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.danger  { border-left-color: var(--danger); }
.toast.info    { border-left-color: var(--violet); }
.toast .title { font-weight: 700; margin-bottom: 2px; }
.toast .body  { color: var(--text-2); font-size: 11.5px; line-height: 1.4; }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 960px) {
  .kpi-row        { grid-template-columns: repeat(2, 1fr); }
  .globals-grid   { grid-template-columns: 1fr; }
  .danger-grid    { grid-template-columns: 1fr; }
  .modal-grid     { grid-template-columns: repeat(2, 1fr); }
  .topbar         { flex-wrap: wrap; }
}

@media (max-width: 640px) {
  .app                  { padding: 0 14px 60px; }
  .kpi-row              { grid-template-columns: 1fr 1fr; }
  .card                 { padding: 18px 18px; }
  .card-head-actions    { width: 100%; }
  .card-head-actions input { width: 100%; }
  .users-table thead th { padding: 10px 12px; }
  .users-table tbody td { padding: 12px; }
  .users-table th:nth-child(2),
  .users-table td:nth-child(2),
  .users-table th:nth-child(5),
  .users-table td:nth-child(5),
  .users-table th:nth-child(6),
  .users-table td:nth-child(6) { display: none; }
}
