:root {
  --bg: #0b1220;
  --bg2: #111a2e;
  --card: #151f36;
  --border: #243049;
  --text: #e8eef9;
  --muted: #8b9bb8;
  --primary: #3b82f6;
  --primary-h: #2563eb;
  --success: #22c55e;
  --danger: #ef4444;
  --warn: #f59e0b;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0,0,0,.35);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
code { font-size: .85em; background: var(--bg2); padding: 2px 6px; border-radius: 4px; word-break: break-all; }

/* Login */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 1rem;
  background: radial-gradient(ellipse at top, #1a2744 0%, var(--bg) 60%);
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2rem; box-shadow: var(--shadow);
}
.login-brand { text-align: center; margin-bottom: 1.5rem; }
.login-brand h1 { font-size: 1.4rem; margin-top: .5rem; }
.login-brand p { color: var(--muted); font-size: .85rem; }
.logo-mark {
  width: 48px; height: 48px; margin: 0 auto;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 700;
}
.login-card label { display: block; margin-bottom: 1rem; font-size: .9rem; color: var(--muted); }
.login-card input {
  display: block; width: 100%; margin-top: .35rem;
  padding: .7rem .9rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg2); color: var(--text);
}
.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }
.alert-error { background: rgba(239,68,68,.15); border: 1px solid var(--danger); color: #fca5a5; }

/* Shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 40;
  transition: transform .2s;
}
.sidebar-brand {
  display: flex; align-items: center; gap: .75rem;
  padding: 1.25rem 1rem; border-bottom: 1px solid var(--border);
}
.sidebar-brand small { display: block; color: var(--muted); font-size: .75rem; }
.sidebar-nav { flex: 1; padding: 1rem .5rem; }
.nav-item {
  display: block; padding: .65rem 1rem; border-radius: 8px;
  color: var(--muted); margin-bottom: .25rem; font-size: .95rem;
}
.nav-item:hover, .nav-item.active { background: var(--card); color: var(--text); }
.sidebar-footer {
  padding: 1rem; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: .5rem;
}
.admin-chip { font-size: .8rem; color: var(--muted); }

.main { flex: 1; margin-left: 240px; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem 1.5rem; border-bottom: 1px solid var(--border);
  background: var(--bg2); position: sticky; top: 0; z-index: 20;
}
.topbar h2 { font-size: 1.15rem; flex: 1; }
.menu-toggle { display: none; background: none; border: none; color: var(--text); font-size: 1.4rem; cursor: pointer; }
.badge-network {
  font-size: .75rem; padding: .25rem .6rem; border-radius: 999px;
  background: rgba(34,197,94,.15); color: var(--success); border: 1px solid rgba(34,197,94,.3);
}
.content { padding: 1.5rem; }

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

.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem; margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem;
}
.stat-card.muted .stat-value { color: var(--muted); }
.stat-label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .35rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem;
}
.card h3 { margin-bottom: .75rem; font-size: 1.05rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; }
.card-head h3 { margin: 0; }
.lead { font-size: 1.05rem; margin-bottom: .5rem; }
.muted { color: var(--muted); font-size: .9rem; }

.form-grid label { display: block; margin-bottom: 1rem; font-size: .9rem; color: var(--muted); }
.form-grid input, .form-grid select, .form-grid textarea,
label input, label select, label textarea {
  display: block; width: 100%; margin-top: .35rem;
  padding: .65rem .85rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg2); color: var(--text);
  font: inherit;
}
.form-actions { margin-top: .5rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .6rem 1.1rem; border-radius: 8px; border: none;
  font: inherit; font-weight: 600; cursor: pointer; transition: background .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-sm { padding: .4rem .75rem; font-size: .85rem; }
.btn-block { width: 100%; }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.filters input, .filters select {
  padding: .5rem .7rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg2); color: var(--text); font: inherit;
}

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.data-table th, .data-table td {
  text-align: left; padding: .65rem .5rem; border-bottom: 1px solid var(--border);
}
.data-table th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.data-table td { vertical-align: top; }
.badge-status {
  display: inline-block; padding: .15rem .5rem; border-radius: 6px; font-size: .75rem; font-weight: 600;
}
.badge-SUCCESS { background: rgba(34,197,94,.15); color: var(--success); }
.badge-FAILED { background: rgba(239,68,68,.15); color: #fca5a5; }
.badge-PROCESSING, .badge-PENDING { background: rgba(245,158,11,.15); color: var(--warn); }

.pagination { display: flex; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }
.pagination button {
  padding: .4rem .7rem; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg2); color: var(--text); cursor: pointer;
}
.pagination button.active { background: var(--primary); border-color: var(--primary); }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.modal-box {
  position: relative; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem; width: 100%; max-width: 440px;
  box-shadow: var(--shadow);
}
.modal-box h3 { margin-bottom: 1rem; }
.review-details p { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: .5rem; font-size: .95rem; }
.review-details span { color: var(--muted); }
.review-details .warn { color: var(--warn); font-size: .85rem; margin-top: .75rem; display: block; }
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.25rem; }
.payout-status { margin-top: 1rem; padding: .75rem; border-radius: 8px; font-size: .9rem; }
.payout-status.ok { background: rgba(34,197,94,.12); border: 1px solid var(--success); }
.payout-status.err { background: rgba(239,68,68,.12); border: 1px solid var(--danger); }

@media (max-width: 800px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: block; }
}
