:root {
  --vision-red: #db2828;
  --vision-red-hover: #bf0000;
  --vision-red-dim: rgba(219, 40, 40, 0.15);
  --bg: #0f1115;
  --bg-elevated: #161a21;
  --bg-card: #1b2130;
  --bg-input: #12161e;
  --line: #2a3142;
  --text: #e8ecf4;
  --text-muted: #9aa3b5;
  --text-dim: #6b7385;
  --success: #2ecc71;
  --warn: #f0b429;
  --danger: #e74c3c;
  --info: #3b82f6;
  --radius: 8px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "Consolas", "Courier New", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--vision-red); text-decoration: none; }
a:hover { color: var(--vision-red-hover); }

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--bg-elevated);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.1rem 1.2rem;
  border-bottom: 1px solid var(--line);
}
.brand img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.brand-text strong {
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}
.brand-text span {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.nav {
  padding: 0.75rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
}
.nav button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  text-align: left;
  padding: 0.7rem 0.85rem;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  transition: 0.15s ease;
}
.nav button:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav button.active {
  background: var(--vision-red-dim);
  color: #fff;
  border-left: 3px solid var(--vision-red);
  padding-left: calc(0.85rem - 3px);
}
.nav-icon {
  width: 1.1rem;
  text-align: center;
  opacity: 0.9;
}
.sidebar-foot {
  padding: 0.9rem 1rem 1.1rem;
  border-top: 1px solid var(--line);
  font-size: 0.75rem;
  color: var(--text-dim);
}
.sidebar-foot a { color: var(--text-muted); }

/* Main */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.4rem;
  border-bottom: 1px solid var(--line);
  background: rgba(22, 26, 33, 0.92);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}
.topbar-actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--text-muted);
}
.status-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
}
.status-pill.online .dot { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-pill.offline .dot { background: var(--danger); }

.content { padding: 1.25rem 1.4rem 2rem; }

/* Cards / grid */
.grid {
  display: grid;
  gap: 1rem;
}
.grid.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: 1.4fr 1fr; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(0,0,0,0.15);
}
.card-header h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}
.card-body { padding: 1rem; }
.card-body.tight { padding: 0; }

.stat {
  padding: 1rem 1.1rem;
}
.stat-label {
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.35rem;
}
.stat-value {
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.1;
}
.stat-sub {
  margin-top: 0.3rem;
  color: var(--text-dim);
  font-size: 0.8rem;
}

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: 6px;
  padding: 0.5rem 0.85rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.btn:hover { border-color: #3d4660; background: #1e2432; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--vision-red);
  border-color: var(--vision-red);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: var(--vision-red-hover); border-color: var(--vision-red-hover); }
.btn-danger {
  background: transparent;
  border-color: rgba(231, 76, 60, 0.5);
  color: #ff8e84;
}
.btn-danger:hover { background: rgba(231, 76, 60, 0.12); }
.btn-sm { padding: 0.3rem 0.55rem; font-size: 0.78rem; }
.btn-group { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* Forms */
.field { margin-bottom: 0.85rem; }
.check-card {
  border: 1px solid var(--line);
  border-left: 3px solid var(--vision-red);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.13);
  padding: 0.85rem;
  margin-bottom: 0.8rem;
}
.check-card h3 {
  margin: 0;
  font-size: 0.92rem;
}
.check-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
}
.check-card p {
  margin: 0 0 0.75rem;
  color: var(--text-muted);
  font-size: 0.79rem;
  line-height: 1.45;
}
.check-card .field { margin-bottom: 0.55rem; }
.check-card .field:last-child { margin-bottom: 0; }
.field-help {
  display: block;
  margin-top: 0.22rem;
  color: var(--text-dim);
  font-size: 0.72rem;
  line-height: 1.35;
}
.field label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.admin-accounts-card { margin-bottom: 1rem; border-top: 2px solid var(--vision-red); }
.accounts-header { background: linear-gradient(90deg, rgba(219, 40, 40, 0.1), transparent 55%); }
.accounts-header h2 { margin-top: 0.12rem; }
.section-kicker {
  color: #ff7777;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.account-count {
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.18);
  font-size: 0.75rem;
}
.accounts-summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}
.accounts-summary p { margin: 0; color: var(--text-muted); font-size: 0.84rem; }
.account-summary-icon, .account-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(219, 40, 40, 0.42);
  background: var(--vision-red-dim);
  color: #ff9b9b;
  font-weight: 700;
}
.account-summary-icon { width: 36px; height: 36px; border-radius: 10px; }
.accounts-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(280px, 0.8fr);
  gap: 1rem;
  align-items: start;
}
.account-section-head { display: flex; justify-content: space-between; margin-bottom: 0.7rem; }
.account-section-head h3, .account-panel h3 { margin: 0; font-size: 0.95rem; }
.account-section-head p { margin: 0.2rem 0 0; color: var(--text-dim); font-size: 0.75rem; }
.account-list, .account-tools { display: grid; gap: 0.7rem; }
.account-row {
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(255,255,255,0.025), rgba(0,0,0,0.12));
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.account-row:hover { border-color: #3a4358; transform: translateY(-1px); }
.account-row.is-self { border-left: 3px solid var(--vision-red); }
.account-identity { display: flex; align-items: center; gap: 0.65rem; margin-bottom: 0.8rem; }
.account-avatar { width: 34px; height: 34px; border-radius: 50%; }
.account-name { min-width: 0; flex: 1; }
.account-name strong { display: block; overflow: hidden; text-overflow: ellipsis; }
.account-name span { color: var(--text-dim); font-size: 0.7rem; }
.account-badges { display: flex; gap: 0.35rem; align-items: center; }
.account-fields { display: grid; grid-template-columns: 150px minmax(180px, 1fr); gap: 0.55rem; }
.account-row .field { margin: 0; }
.account-actions { display: flex; justify-content: flex-end; gap: 0.4rem; margin-top: 0.65rem; }
.account-panel {
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.14);
}
.account-panel h3 { margin: 0.15rem 0 0.85rem; }
.account-primary { width: 100%; justify-content: center; }
.account-note { margin: 0.65rem 0 0; color: var(--text-dim); font-size: 0.7rem; line-height: 1.4; }
.btn:disabled, input:disabled, select:disabled { opacity: 0.48; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid #ff7777; outline-offset: 2px; }
@media (max-width: 1000px) {
  .accounts-layout { grid-template-columns: 1fr; }
  .account-tools { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .account-tools, .account-fields { grid-template-columns: 1fr; }
  .account-actions { justify-content: stretch; }
  .account-actions .btn { flex: 1; }
  .accounts-summary { align-items: flex-start; }
}
input[type="text"],
input[type="password"],
input[type="number"],
textarea,
select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-size: 0.9rem;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--vision-red);
  box-shadow: 0 0 0 3px var(--vision-red-dim);
}
textarea { min-height: 110px; resize: vertical; font-family: var(--mono); font-size: 0.82rem; }

/* Tables */
.table-wrap { overflow: auto; max-height: 520px; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
th, td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}
th {
  position: sticky;
  top: 0;
  background: #1a2030;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  z-index: 1;
}
tr:hover td { background: rgba(255,255,255,0.02); }
.mono { font-family: var(--mono); font-size: 0.8rem; }
.muted { color: var(--text-muted); }
.badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid var(--line);
}
.badge.red { background: var(--vision-red-dim); color: #ff8f8f; border-color: rgba(180,30,30,0.4); }
.badge.green { background: rgba(46,204,113,0.12); color: #6eef9f; border-color: rgba(46,204,113,0.35); }
.badge.yellow { background: rgba(240,180,41,0.12); color: #ffd56a; border-color: rgba(240,180,41,0.35); }
.badge.blue { background: rgba(59,130,246,0.12); color: #8eb7ff; border-color: rgba(59,130,246,0.35); }

/* Log console */
.console {
  background: #0b0d12;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.45;
  max-height: 420px;
  overflow: auto;
  padding: 0.85rem 1rem;
  color: #c8d0e0;
}
.console .line { white-space: pre-wrap; word-break: break-word; padding: 0.1rem 0; }
.console .line.strike { color: #ff9a9a; }
.console .line.boot { color: #8eb7ff; }
.console .line.warn { color: #ffd56a; }

/* Map */
.map-viewport {
  position: relative;
  overflow: hidden;
  border-radius: 0 0 var(--radius) var(--radius);
  background: #0d121a;
  min-height: 560px;
  aspect-ratio: 1 / 1;
  cursor: grab;
  user-select: none;
}
.map-viewport:active { cursor: grabbing; }
.map-viewport.dragging { cursor: grabbing; }

.map-layer {
  position: absolute;
  transform-origin: 0 0;
  width: 100%;
  height: 100%;
  background-image: url("/img/chernarus.png");
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
}
.map-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  z-index: 2;
  cursor: pointer;
}
.map-marker .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--vision-red);
  border: 2px solid #fff;
  box-shadow: 0 0 0 3px rgba(219,40,40,0.35), 0 0 10px rgba(219,40,40,0.5);
}
.map-marker .label {
  position: absolute; left: 14px; top: -4px;
  font-size: 0.68rem; font-weight: 600; color: #fff;
  white-space: nowrap;
  text-shadow: 0 1px 2px #000, 0 0 4px #000;
}
.map-marker.vehicle .dot { background: #3b82f6; box-shadow: 0 0 0 2px rgba(59,130,246,0.3), 0 0 6px rgba(59,130,246,0.4); }
.map-marker.zombie .dot { background: #f0b429; box-shadow: 0 0 0 2px rgba(240,180,41,0.3), 0 0 4px rgba(240,180,41,0.4); }
.map-marker.item .dot { background: #6b7280; box-shadow: 0 0 0 1px rgba(107,114,128,0.3); width: 7px; height: 7px; border-width: 1px; }

.map-controls {
  position: absolute;
  right: 0.6rem;
  top: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  z-index: 10;
}
.map-ctrl-btn {
  width: 30px; height: 30px;
  border: 1px solid var(--line); border-radius: 4px;
  background: rgba(0,0,0,0.55); color: var(--text);
  font-size: 0.85rem; display: grid; place-items: center;
  cursor: pointer; font-weight: 600;
}
.map-ctrl-btn:hover { background: rgba(0,0,0,0.75); }

.map-legend {
  position: absolute;
  left: 0.75rem; bottom: 0.75rem;
  background: rgba(0,0,0,0.6); border: 1px solid var(--line);
  border-radius: 6px; padding: 0.4rem 0.65rem;
  font-size: 0.72rem; color: var(--text-muted);
  display: flex; gap: 0.75rem; z-index: 3;
}
.map-legend span { display: inline-flex; align-items: center; gap: 0.3rem; }
.map-legend .ldot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.map-legend .ldot.lp { background: var(--vision-red); }
.map-legend .ldot.lv { background: #3b82f6; }
.map-legend .ldot.lz { background: #f0b429; }
.map-legend .ldot.li { background: #6b7280; }

/* Player detail drawer */
.detail-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  z-index: 50; display: none;
}
.detail-overlay.show { display: block; }
.detail-drawer {
  position: fixed; right: 0; top: 0; bottom: 0;
  width: min(400px, 90vw); background: var(--bg-card);
  border-left: 1px solid var(--line); box-shadow: -8px 0 28px rgba(0,0,0,0.5);
  z-index: 51; overflow-y: auto;
  transform: translateX(100%); transition: transform 0.2s ease;
}
.detail-drawer.open { transform: translateX(0); }
.detail-head {
  padding: 1rem 1.1rem; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
  background: rgba(0,0,0,0.2);
}
.detail-head h3 { margin: 0; font-size: 1rem; }
.detail-close {
  background: none; border: 0; color: var(--text-muted);
  font-size: 1.3rem; cursor: pointer; padding: 0 0.3rem;
}
.detail-close:hover { color: #fff; }
.detail-body { padding: 1rem 1.1rem; }
.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem 0.8rem;
  font-size: 0.85rem; margin-bottom: 1rem;
}
.detail-grid .dg-label { color: var(--text-muted); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em; }
.detail-grid .dg-val { font-weight: 600; }
.detail-actions { display: flex; gap: 0.45rem; flex-wrap: wrap; margin-top: 0.6rem; }

@media (max-width: 820px) {
  .detail-drawer { width: 100vw; }
}

/* Login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse at top, rgba(180,30,30,0.18), transparent 55%),
    var(--bg);
  padding: 1.5rem;
}
.login-card {
  width: min(420px, 100%);
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.login-hero {
  background: linear-gradient(135deg, #8f1515, #b41e1e 55%, #5c1010);
  padding: 1.4rem 1.3rem 1.2rem;
  text-align: center;
}
.login-hero img {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  margin-bottom: 0.6rem;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}
.login-hero h1 {
  margin: 0;
  font-size: 1.35rem;
}
.login-hero p {
  margin: 0.35rem 0 0;
  color: rgba(255,255,255,0.85);
  font-size: 0.88rem;
}
.login-body { padding: 1.25rem 1.3rem 1.4rem; }
.login-error {
  color: #ff8e84;
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
  min-height: 1.1em;
}

.panel { display: none; }
.panel.active { display: block; }

.empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-left: 3px solid var(--vision-red);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 100;
  max-width: 360px;
  display: none;
}
.toast.show { display: block; animation: fadein 0.2s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.switch input { accent-color: var(--vision-red); }

@media (max-width: 1100px) {
  .grid.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two, .grid.three { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .nav { flex-direction: row; flex-wrap: wrap; }
}
