/* ===== Reset & Base ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0f1117;
  --bg-secondary: #1a1d27;
  --bg-card: #1e2130;
  --bg-hover: #252838;
  --bg-input: #161822;
  --border-color: #2a2d3e;
  --border-focus: #6C5CE7;
  --text-primary: #e4e6f0;
  --text-secondary: #8b8fa3;
  --text-muted: #5a5e72;
  --accent: #6C5CE7;
  --accent-hover: #5a4bd6;
  --accent-soft: rgba(108, 92, 231, 0.12);
  --green: #00D9A6;
  --green-soft: rgba(0, 217, 166, 0.12);
  --orange: #F5A623;
  --orange-soft: rgba(245, 166, 35, 0.12);
  --red: #E74C6F;
  --red-soft: rgba(231, 76, 111, 0.12);
  --blue: #4C9AFF;
  --blue-soft: rgba(76, 154, 255, 0.12);
  --sidebar-width: 260px;
  --header-height: 64px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  --transition: 0.2s ease;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  font-size: 14px;
  line-height: 1.5;
}

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

.hidden { display: none !important; }

/* ===== Login Screen ===== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  background-image: radial-gradient(ellipse at 50% 0%, rgba(108, 92, 231, 0.08) 0%, transparent 60%);
  padding: 16px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo svg { margin-bottom: 12px; }
.login-logo h1 { font-size: 24px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.login-logo p { color: var(--text-secondary); font-size: 14px; }

.error-msg {
  color: var(--red);
  font-size: 13px;
  margin-top: 12px;
  text-align: center;
}

/* ===== Form Elements ===== */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--transition);
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-group input::placeholder { color: var(--text-muted); }

.form-hint {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Form layouts */
.form-stack {
  display: flex;
  flex-direction: column;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.cashout-form-layout {
  max-width: 480px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.inline-form {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.inline-form input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}

.inline-form input:focus { border-color: var(--border-focus); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }

.btn-secondary { background: var(--bg-hover); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: var(--border-color); }

.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ===== App Layout ===== */
.app {
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-title { font-size: 20px; font-weight: 700; color: var(--text-primary); }

.sidebar-nav {
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 400;
  transition: all var(--transition);
}

.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.nav-item svg { flex-shrink: 0; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-color);
}

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-header {
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.main-header h2 { font-size: 18px; font-weight: 600; flex: 1; min-width: 0; }

.btn-menu {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.header-badge {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.page-container {
  flex: 1;
  padding: 24px;
}

/* ===== Pages ===== */
.page { display: none; }
.page.active { display: block; }

/* ===== Stats Grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color var(--transition);
  min-width: 0;
}

.stat-card:hover { border-color: var(--accent); }

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon-blue { background: var(--blue-soft); color: var(--blue); }
.stat-icon-green { background: var(--green-soft); color: var(--green); }
.stat-icon-orange { background: var(--orange-soft); color: var(--orange); }
.stat-icon-red { background: var(--red-soft); color: var(--red); }

.stat-info { display: flex; flex-direction: column; min-width: 0; }
.stat-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.card-header h3 { font-size: 16px; font-weight: 600; }

/* ===== Filters Bar ===== */
.filters-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}

/* ===== Tables ===== */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table { width: 100%; border-collapse: collapse; }

.table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.table td {
  padding: 12px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.table tbody tr:hover { background: var(--bg-hover); }

.table-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 14px !important;
}

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-success { background: var(--green-soft); color: var(--green); }
.badge-warning { background: var(--orange-soft); color: var(--orange); }
.badge-danger { background: var(--red-soft); color: var(--red); }
.badge-info { background: var(--blue-soft); color: var(--blue); }
.badge-pending { background: var(--orange-soft); color: var(--orange); }
.badge-cashout { background: var(--red-soft); color: var(--red); }
.badge-deposit { background: var(--green-soft); color: var(--green); }

/* ===== Toggle ===== */
.toggle-group { display: flex; flex-direction: column; gap: 8px; }

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  user-select: none;
}

.toggle input { display: none; }

.toggle-slider {
  width: 40px;
  height: 22px;
  background: var(--border-color);
  border-radius: 11px;
  position: relative;
  transition: background var(--transition);
  flex-shrink: 0;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: all var(--transition);
}

.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::after { transform: translateX(18px); background: #fff; }

/* ===== Filters ===== */
.filter-select,
.filter-input {
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  min-width: 0;
}

.filter-select:focus,
.filter-input:focus { border-color: var(--border-focus); }

.filter-input { width: 180px; }

/* ===== Pagination ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.pagination button {
  padding: 6px 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
}

.pagination button:hover { border-color: var(--accent); color: var(--accent); }
.pagination button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== Result Box ===== */
.result-box {
  margin-top: 20px;
  padding: 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  overflow-x: auto;
  word-break: break-word;
}

.result-box.success { background: var(--green-soft); border: 1px solid rgba(0, 217, 166, 0.2); color: var(--green); }
.result-box.error { background: var(--red-soft); border: 1px solid rgba(231, 76, 111, 0.2); color: var(--red); }

.result-box pre {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
}

/* ===== Domains List ===== */
.domains-list { display: flex; flex-direction: column; gap: 6px; }

.domain-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  gap: 10px;
  flex-wrap: wrap;
}

.domain-item .domain-name { color: var(--text-primary); font-weight: 500; min-width: 0; word-break: break-all; }
.domain-item .domain-actions { display: flex; gap: 6px; flex-shrink: 0; }
.domain-item.inactive { opacity: 0.5; }

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: calc(100vw - 40px);
}

.toast {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease;
  max-width: 360px;
  word-break: break-word;
}

.toast.toast-success { background: var(--green); color: #fff; }
.toast.toast-error { background: var(--red); color: #fff; }
.toast.toast-info { background: var(--accent); color: #fff; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ===== Loading Spinner ===== */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================ */
/* ========== RESPONSIVE - DESKTOP ============ */
/* ============================================ */
@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ============================================ */
/* ========== RESPONSIVE - TABLET ============= */
/* ============================================ */
@media (max-width: 900px) {
  .form-row-2 {
    grid-template-columns: 1fr;
  }
}

/* ============================================ */
/* ========== RESPONSIVE - MOBILE ============= */
/* ============================================ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

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

  .sidebar-overlay.active {
    display: block;
  }

  .main-content {
    margin-left: 0;
  }

  .btn-menu {
    display: block;
  }

  .main-header {
    padding: 0 16px;
  }

  .page-container {
    padding: 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stat-card {
    padding: 16px;
  }

  .stat-value {
    font-size: 18px;
  }

  .card {
    padding: 16px;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  /* Filters responsivo */
  .filters-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-select,
  .filter-input {
    width: 100%;
  }

  .btn-filter {
    width: 100%;
    justify-content: center;
  }

  /* Inline form responsivo */
  .inline-form {
    flex-direction: column;
  }

  .inline-form .btn {
    width: 100%;
    justify-content: center;
  }

  /* Form actions responsivo */
  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* Domain item responsivo */
  .domain-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .domain-item .domain-actions {
    width: 100%;
  }

  .domain-item .domain-actions .btn {
    flex: 1;
    justify-content: center;
  }

  /* Toast responsivo */
  .toast-container {
    top: 10px;
    right: 10px;
    left: 10px;
  }

  .toast {
    max-width: 100%;
  }

  /* Header badge */
  .header-badge {
    font-size: 11px;
    padding: 4px 10px;
  }

  /* Login responsivo */
  .login-card {
    padding: 24px;
  }

  /* Cashout form */
  .cashout-form-layout {
    max-width: 100%;
  }

  /* Pagination responsivo */
  .pagination {
    gap: 4px;
  }

  .pagination button {
    padding: 6px 10px;
    font-size: 12px;
  }
}

/* ============================================ */
/* ========== RESPONSIVE - VERY SMALL ========= */
/* ============================================ */
@media (max-width: 400px) {
  .main-header h2 {
    font-size: 15px;
  }

  .card-header h3 {
    font-size: 14px;
  }

  .stat-icon {
    width: 40px;
    height: 40px;
  }

  .stat-icon svg {
    width: 20px;
    height: 20px;
  }

  .stat-value {
    font-size: 16px;
  }

  .table th, .table td {
    padding: 8px 10px;
    font-size: 12px;
  }
}