/**
 * admin.css — Aviator admin panel
 */
body.admin-body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  overflow: hidden;
}

.admin-login-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(229, 5, 57, 0.14), transparent),
    var(--bg);
}

.admin-login-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 22px;
}

.admin-login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
  margin-bottom: 20px;
}

.admin-login-card h1 {
  font-size: 1.15rem;
  margin-bottom: 8px;
}

.admin-login-hint {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 16px;
}

.admin-login-hint code {
  font-size: 0.72rem;
  background: var(--panel2);
  padding: 2px 6px;
  border-radius: 4px;
}

.admin-login-form .admin-field {
  margin-bottom: 12px;
}

.admin-btn-block {
  width: 100%;
  margin-top: 4px;
}

.admin-back-link {
  display: block;
  margin-top: 16px;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}

.admin-app {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

.admin-app.hidden,
.admin-login-screen.hidden {
  display: none !important;
}

.admin-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #141415;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  z-index: 200;
}

.admin-sidebar-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 0.95rem;
  padding: 4px 8px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.admin-nav-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.admin-nav-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.admin-nav-btn.active {
  background: rgba(229, 5, 57, 0.15);
  color: #fff;
}

.admin-sidebar-foot {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-nav-link {
  display: block;
  padding: 8px 12px;
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
}

.admin-nav-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.admin-main-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.admin-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: #141415;
  flex-shrink: 0;
}

.admin-menu-toggle {
  display: none;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  cursor: pointer;
}

.admin-topbar-title {
  font-size: 1rem;
  font-weight: 700;
  flex: 1;
}

.admin-topbar-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(240, 160, 32, 0.2);
  color: var(--orange);
}

.admin-user-pill {
  font-size: 0.72rem;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--panel2);
  color: var(--muted);
}

.admin-main {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 20px;
  -webkit-overflow-scrolling: touch;
}

.admin-section {
  display: none;
}

.admin-section.active {
  display: block;
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.admin-stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.admin-stat-label {
  font-size: 0.68rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.admin-stat-value {
  font-size: 1.25rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.admin-stat-value.is-green {
  color: var(--green);
}

.admin-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 16px;
}

.admin-panel h2 {
  font-size: 0.88rem;
  margin-bottom: 8px;
}

.admin-panel-danger {
  border-color: rgba(229, 5, 57, 0.35);
}

.admin-muted {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 12px;
}

.admin-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.admin-search,
.admin-select,
.admin-field input,
.admin-field select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel2);
  color: var(--text);
  font-size: 0.82rem;
  min-width: 0;
}

.admin-search {
  flex: 1 1 200px;
}

.admin-table-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
  max-height: calc(100vh - 200px);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.admin-table th,
.admin-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.admin-table th {
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 600;
  background: rgba(0, 0, 0, 0.2);
  position: sticky;
  top: 0;
}

.admin-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.admin-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
}

.admin-tag.is-good {
  background: var(--green-dim);
  color: var(--green);
}

.admin-tag.is-bad {
  background: var(--red-dim);
  color: var(--red);
}

.admin-tag.is-muted {
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.admin-btn {
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.admin-btn:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.admin-btn-secondary {
  background: #2a2b2e;
}

.admin-btn-danger {
  border-color: rgba(229, 5, 57, 0.5);
  color: var(--red);
  background: rgba(229, 5, 57, 0.1);
}

.admin-btn-sm {
  padding: 4px 10px;
  font-size: 0.7rem;
}

.admin-form {
  max-width: 720px;
}

.admin-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.admin-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-field span {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
}

.admin-toggle-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.admin-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.82rem;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.admin-alert {
  background: var(--red-dim);
  color: #ff8fa8;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  margin-bottom: 12px;
}

.admin-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.admin-modal-backdrop.hidden {
  display: none !important;
}

.admin-modal {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.admin-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.admin-modal-head h2 {
  font-size: 0.95rem;
}

.admin-modal-close {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.admin-modal-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}

.admin-toast-wrap {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 600;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-toast {
  background: #2a2b2e;
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.78rem;
  animation: adminToastIn 0.2s ease;
}

.admin-toast.is-success {
  border-color: rgba(40, 169, 9, 0.4);
}

.admin-toast.is-error {
  border-color: rgba(229, 5, 57, 0.4);
}

@keyframes adminToastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.amount-pos { color: var(--green); }
.amount-neg { color: var(--red); }

@media (max-width: 900px) {
  .admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
  }

  .admin-sidebar.open {
    transform: translateX(0);
  }

  .admin-menu-toggle {
    display: block;
  }

  .admin-main {
    padding: 14px;
  }

  .admin-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
