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

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #1c2230;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --text-dim: #484f58;
  --green: #3fb950;
  --green-bg: rgba(63,185,80,.12);
  --red: #f85149;
  --red-bg: rgba(248,81,73,.12);
  --blue: #58a6ff;
  --blue-bg: rgba(88,166,255,.12);
  --purple: #bc8cff;
  --purple-bg: rgba(188,140,255,.12);
  --orange: #e3b341;
  --accent: #58a6ff;
  --radius: 8px;
  --sidebar-w: 230px;
  --shadow: 0 4px 24px rgba(0,0,0,.4);
}

html, body { height: 100%; font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }

.hidden { display: none !important; }

/* ===== LOGIN ===== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 60% 40%, #1a2340 0%, #0d1117 70%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 40px 36px;
  box-shadow: var(--shadow);
}
.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.logo-icon {
  font-size: 40px;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 10px;
}
.login-logo h1 { font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
.login-logo p  { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* ===== FIELDS ===== */
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 6px; }
.field input, .select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s;
}
.field input:focus, .select:focus { border-color: var(--accent); }
.input-wrap { position: relative; }
.input-wrap input { padding-right: 40px; }
.eye-btn {
  position: absolute;
  right: 12px; top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  padding: 0;
  line-height: 1;
}

/* ===== ALERTS ===== */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 14px; }
.alert-error { background: var(--red-bg); color: var(--red); border: 1px solid rgba(248,81,73,.25); }
.alert-success { background: var(--green-bg); color: var(--green); border: 1px solid rgba(63,185,80,.25); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity .15s, background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover:not(:disabled)  { opacity: .85; }
.btn-outline  { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover:not(:disabled)  { border-color: var(--accent); color: var(--accent); }
.btn-danger   { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover:not(:disabled)   { opacity: .85; }
.btn-full     { width: 100%; }
.btn-sm       { padding: 5px 12px; font-size: 12px; }
.btn-icon     { padding: 6px 10px; font-size: 13px; }
.btn-green    { background: var(--green); color: #fff; border-color: var(--green); }
.btn-green:hover:not(:disabled) { opacity: .85; }
.btn-spinner  { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

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

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.sidebar-logo .logo-icon { font-size: 22px; color: var(--accent); }

.sidebar-nav {
  flex: 1;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background .15s, color .15s;
}
.nav-item:hover  { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--blue-bg); color: var(--blue); }
.nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-info { flex: 1; display: flex; align-items: center; gap: 10px; overflow: hidden; }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}
.user-details { display: flex; flex-direction: column; overflow: hidden; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); }
.logout-btn {
  background: none; border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  transition: color .15s, border-color .15s;
  flex-shrink: 0;
}
.logout-btn:hover { color: var(--red); border-color: var(--red); }

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  padding: 0 0 40px;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 50;
}
.page-title { font-size: 18px; font-weight: 700; }
.hamburger {
  display: none;
  background: none; border: none; color: var(--text);
  font-size: 20px; cursor: pointer;
}

/* ===== VIEWS ===== */
.view { display: none; padding: 28px; }
.view.active { display: block; }

/* ===== STATS GRID ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-icon {
  font-size: 22px;
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-card.green .stat-icon { background: var(--green-bg); color: var(--green); }
.stat-card.red   .stat-icon { background: var(--red-bg);   color: var(--red); }
.stat-card.blue  .stat-icon { background: var(--blue-bg);  color: var(--blue); }
.stat-card.purple .stat-icon { background: var(--purple-bg); color: var(--purple); }
.stat-body { display: flex; flex-direction: column; }
.stat-val { font-size: 26px; font-weight: 700; line-height: 1.1; font-family: 'JetBrains Mono', monospace; }
.stat-lbl { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 14px; font-weight: 600; }

/* ===== TABLE ===== */
.table { width: 100%; border-collapse: collapse; }
.table thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody td {
  padding: 12px 16px;
  font-size: 13px;
  border-bottom: 1px solid rgba(48,54,61,.5);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(255,255,255,.02); }
.table td.empty { text-align: center; color: var(--text-muted); padding: 32px; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.badge-allowed  { background: var(--green-bg);  color: var(--green); }
.badge-blocked  { background: var(--red-bg);    color: var(--red); }
.badge-superadmin { background: var(--purple-bg); color: var(--purple); }
.badge-admin    { background: var(--blue-bg);   color: var(--blue); }

/* ===== IP MONO ===== */
.ip-mono { font-family: 'JetBrains Mono', monospace; font-size: 13px; }

/* ===== TOOLBAR ===== */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.toolbar-left { display: flex; gap: 10px; flex: 1; flex-wrap: wrap; }
.search-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 14px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s;
  min-width: 200px;
}
.search-input:focus { border-color: var(--accent); }
.select { cursor: pointer; width: auto; }

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.page-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, border-color .15s;
}
.page-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }
.page-info { font-size: 12px; color: var(--text-muted); }

/* ===== ACTIONS ===== */
.actions { display: flex; gap: 6px; }
.action-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: color .15s, border-color .15s, background .15s;
}
.action-btn:hover { color: var(--text); border-color: var(--text-muted); }
.action-btn.block:hover  { color: var(--red);   border-color: var(--red);   background: var(--red-bg); }
.action-btn.allow:hover  { color: var(--green); border-color: var(--green); background: var(--green-bg); }
.action-btn.edit:hover   { color: var(--blue);  border-color: var(--blue);  background: var(--blue-bg); }
.action-btn.delete:hover { color: var(--red);   border-color: var(--red);   background: var(--red-bg); }

/* ===== MODAL ===== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(3px);
  z-index: 200;
}
.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 300;
  width: calc(100% - 32px);
  max-width: 440px;
}
.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 28px;
}
.modal-sm { max-width: 340px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none;
  color: var(--text-muted);
  font-size: 16px; cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color .15s, background .15s;
}
.modal-close:hover { color: var(--text); background: var(--surface2); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}
.confirm-msg {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 4px;
  line-height: 1.6;
}

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  pointer-events: auto;
  animation: slideIn .25s ease;
  max-width: 320px;
}
.toast.success { border-left: 3px solid var(--green); color: var(--green); }
.toast.error   { border-left: 3px solid var(--red);   color: var(--red); }
.toast.info    { border-left: 3px solid var(--blue);  color: var(--blue); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .hamburger { display: block; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .view { padding: 16px; }
  .topbar { padding: 14px 16px; }
  .table thead th:nth-child(4),
  .table tbody td:nth-child(4),
  .table thead th:nth-child(5),
  .table tbody td:nth-child(5) { display: none; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .login-card { padding: 28px 20px; }
}
