:root {
  --bg: #05060a;
  --bg-grad-1: #0d0f1c;
  --bg-grad-2: #050609;
  --panel: rgba(18, 19, 28, 0.68);
  --panel-border: rgba(255, 255, 255, 0.09);
  --accent: #7c6cf6;
  --accent-2: #c084fc;
  --accent-3: #22d3ee;
  --accent-glow: rgba(124, 108, 246, 0.45);
  --text: #f5f5fb;
  --muted: #9093a8;
  --danger: #f87171;
  --success: #34d399;
  --radius: 18px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 18%, rgba(124,108,246,0.16), transparent 42%),
    radial-gradient(circle at 88% 82%, rgba(192,132,252,0.14), transparent 42%),
    linear-gradient(160deg, var(--bg-grad-1), var(--bg-grad-2) 70%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.1px;
}

/* ---------- Login ---------- */
.login-body { overflow-x: hidden; }

.login-screen {
  min-height: 100vh;
  display: flex;
}

.login-visual {
  position: relative;
  flex: 1.1;
  overflow: hidden;
  background: linear-gradient(155deg, #14152b, #05060a 75%);
  display: flex;
  align-items: center;
  padding: 60px;
}

.login-visual::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: radial-gradient(circle at 30% 30%, #000 0%, transparent 70%);
  opacity: 0.6;
  pointer-events: none;
}

.login-visual::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.03) 50%, transparent);
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  animation: float 9s ease-in-out infinite;
}
.blob-a { width: 340px; height: 340px; background: var(--accent); top: -60px; left: -60px; }
.blob-b { width: 280px; height: 280px; background: var(--accent-2); bottom: -60px; right: -40px; animation-delay: -4s; }

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(20px, -24px) scale(1.06); }
}

.visual-content { position: relative; z-index: 1; max-width: 420px; }
.brand-name-lg { font-weight: 700; font-size: 17px; }
.visual-title { font-size: 30px; font-weight: 700; line-height: 1.25; margin: 28px 0 14px; letter-spacing: -0.3px; }
.visual-sub { color: var(--muted); font-size: 14.5px; line-height: 1.65; margin: 0 0 26px; }
.visual-points { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.visual-points li { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: #d3d5e2; }
.visual-points li::before {
  content: '';
  width: 8px; height: 8px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  flex-shrink: 0;
  box-shadow: 0 0 10px var(--accent-glow);
}

.login-form-side {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  min-width: 0;
}

.brand-mobile { display: none; }

.card {
  position: relative;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent 40%), var(--panel);
  border: 1px solid transparent;
  background-clip: padding-box;
  border-radius: var(--radius);
  padding: 38px 36px;
  width: 100%;
  max-width: 390px;
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  box-shadow: 0 25px 70px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.03) inset;
  animation: rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(160deg, rgba(124,108,246,0.55), rgba(255,255,255,0.03) 30%, rgba(255,255,255,0.03) 70%, rgba(192,132,252,0.4));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  z-index: -1;
}

.status-chip {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  background: #0d0e17;
  border: 1px solid var(--panel-border);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.3px;
  text-transform: uppercase;
  box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}

.pulse {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(52,211,153,0.6);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52,211,153,0.55); }
  70% { box-shadow: 0 0 0 7px rgba(52,211,153,0); }
  100% { box-shadow: 0 0 0 0 rgba(52,211,153,0); }
}

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

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 8px 20px var(--accent-glow);
}

.card h1 {
  font-size: 22px;
  font-weight: 800;
  margin: 10px 0 4px;
  text-align: center;
  letter-spacing: -0.3px;
}

.subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 26px;
}

label {
  display: block;
  margin-top: 16px;
  margin-bottom: 6px;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 500;
}

.input-wrap {
  position: relative;
}

input {
  width: 100%;
  padding: 13px 14px 13px 40px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  -webkit-appearance: none;
}

input::placeholder { color: #55596b; }

input:focus {
  border-color: var(--accent);
  background: rgba(255,255,255,0.06);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  display: flex;
  pointer-events: none;
}

#password { padding-right: 42px; }

.toggle-pw {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}
.toggle-pw:hover { color: var(--text); background: rgba(255,255,255,0.06); }

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
}

.remember {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  margin: 0;
  font-weight: 400;
}
.remember input[type="checkbox"] {
  width: 15px; height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

button[type="submit"] {
  margin-top: 26px;
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  background-size: 160% 160%;
  background-position: 0% 50%;
  border: none;
  border-radius: 11px;
  color: #fff;
  font-weight: 600;
  font-size: 14.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 12px 26px var(--accent-glow);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, background-position 0.3s ease;
}

.btn-arrow { transition: transform 0.15s ease; }
button[type="submit"]:hover .btn-arrow { transform: translateX(3px); }
button[type="submit"]:hover { transform: translateY(-1px); box-shadow: 0 16px 34px var(--accent-glow); background-position: 100% 50%; }
button[type="submit"]:active { transform: translateY(0); }
button[type="submit"]:disabled { opacity: 0.65; cursor: default; transform: none; }
button[type="submit"].loading .btn-arrow { display: none; }

.spinner {
  width: 15px; height: 15px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}
button[type="submit"].loading .spinner { display: inline-block; }
button[type="submit"].loading .btn-label { display: none; }

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

.error {
  color: var(--danger);
  margin-top: 12px;
  font-size: 13px;
  min-height: 16px;
  text-align: center;
}

.error.visible {
  animation: shake 0.35s ease;
}

@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.footnote {
  margin-top: 22px;
  text-align: center;
  color: #4b4f61;
  font-size: 11.5px;
}

/* ---------- Dashboard ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: rgba(10, 11, 18, 0.9);
  border-right: 1px solid var(--panel-border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  z-index: 40;
  transition: transform 0.25s ease;
}

.sidebar .brand { justify-content: flex-start; margin-bottom: 22px; padding-left: 4px; position: relative; }
.sidebar .brand-mark { width: 32px; height: 32px; font-size: 14px; }
.sidebar .brand-name { font-weight: 700; font-size: 14.5px; letter-spacing: -0.1px; }

.nav-close { display: none; margin-left: auto; background: none; border: none; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 6px; }
.nav-close:hover { background: rgba(255,255,255,0.06); color: var(--text); }

.nav-icon { flex-shrink: 0; opacity: 0.85; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  user-select: none;
}

.nav-item .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.6; }

.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(124,108,246,0.2), rgba(192,132,252,0.12));
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(124,108,246,0.4);
}
.nav-item.active .nav-icon { opacity: 1; color: var(--accent-3); }

.sidebar-footer { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--panel-border); }

.lock-badge {
  display: flex; align-items: center; gap: 7px;
  font-size: 11.5px; color: var(--success);
  padding: 8px 10px;
  background: rgba(52,211,153,0.08);
  border: 1px solid rgba(52,211,153,0.25);
  border-radius: 8px;
}

.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(2px);
  z-index: 30;
}
.nav-overlay.open { display: block; }

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 6px;
  margin-right: 4px;
  border-radius: 8px;
}
.nav-toggle:hover { background: rgba(255,255,255,0.08); }

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

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 28px;
  background: rgba(10,11,18,0.65);
  border-bottom: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left { display: flex; align-items: center; }
.topbar-title { font-size: 15px; font-weight: 700; letter-spacing: -0.1px; }
.topbar-title span { color: var(--muted); font-weight: 400; font-size: 12.5px; display: block; margin-top: 2px; letter-spacing: 0; }

.topbar-right { display: flex; align-items: center; gap: 14px; }

.lock-pill {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600;
  color: var(--success);
  padding: 7px 11px;
  background: rgba(52,211,153,0.08);
  border: 1px solid rgba(52,211,153,0.25);
  border-radius: 999px;
}

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  box-shadow: 0 0 0 2px rgba(124,108,246,0.25), 0 4px 12px var(--accent-glow);
}

.topbar button {
  padding: 9px 16px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}
.topbar button:hover { background: rgba(255,255,255,0.12); }

.dashboard-shell {
  padding: 28px;
  flex: 1;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  position: relative;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent 40%), var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 20px;
  backdrop-filter: blur(14px);
  animation: rise 0.4s ease both;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(0,0,0,0.35); }
.stat-card::after {
  content: '';
  position: absolute;
  top: -40%; right: -20%;
  width: 120px; height: 120px;
  background: radial-gradient(circle, var(--accent-glow), transparent 70%);
  pointer-events: none;
}

.stat-card .stat-label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat-card .stat-value { font-size: 27px; font-weight: 800; margin-top: 8px; letter-spacing: -0.5px; }
.stat-card .stat-sub { margin-top: 6px; font-size: 12px; color: var(--success); }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 24px;
  backdrop-filter: blur(14px);
}

.panel h2 { font-size: 15px; margin: 0 0 6px; font-weight: 700; }
.panel p { color: var(--muted); font-size: 13.5px; line-height: 1.6; margin: 0; }

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
  }
  .sidebar.open { transform: translateX(0); }
  .nav-close { display: flex; }
  .nav-toggle { display: flex; }
  .dashboard-shell { padding: 18px; }
  .topbar { padding: 14px 18px; }
  .lock-pill span { display: none; }
}

/* ---------- Users management ---------- */
a.nav-item { text-decoration: none; }

.primary-btn {
  padding: 10px 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  border-radius: 9px;
  color: #fff;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  box-shadow: 0 8px 20px var(--accent-glow);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.primary-btn:hover { transform: translateY(-1px); box-shadow: 0 12px 26px var(--accent-glow); }

.ghost-btn {
  padding: 10px 16px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--panel-border);
  border-radius: 9px;
  color: var(--text);
  font-weight: 500;
  font-size: 13.5px;
  cursor: pointer;
}
.ghost-btn:hover { background: rgba(255,255,255,0.09); }

.danger-btn {
  padding: 10px 16px;
  background: rgba(248,113,113,0.15);
  border: 1px solid rgba(248,113,113,0.4);
  border-radius: 9px;
  color: #fca5a5;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
}
.danger-btn:hover { background: rgba(248,113,113,0.25); }

.table-panel { padding: 8px; overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; min-width: 480px; }
.data-table th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  font-weight: 600;
  padding: 14px 16px;
  border-bottom: 1px solid var(--panel-border);
}
.data-table td {
  padding: 13px 16px;
  font-size: 13.5px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background 0.15s ease; }
.data-table tbody tr:hover { background: rgba(255,255,255,0.03); }

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

.user-cell { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.avatar-sm { width: 26px; height: 26px; font-size: 11px; box-shadow: none; }

.role-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(124,108,246,0.14);
  color: #c9c3ff;
  border: 1px solid rgba(124,108,246,0.3);
  margin-right: 4px;
}
.role-badge.role-admin { background: rgba(34,211,238,0.12); color: #7fe3f4; border-color: rgba(34,211,238,0.3); }
.role-badge.role-none { background: rgba(255,255,255,0.05); color: var(--muted); border-color: var(--panel-border); }

.actions-cell { text-align: right; white-space: nowrap; }
.icon-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--panel-border);
  color: var(--muted);
  padding: 7px;
  border-radius: 7px;
  cursor: pointer;
  margin-left: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: rgba(255,255,255,0.1); color: var(--text); }
.icon-btn.icon-danger:hover { background: rgba(248,113,113,0.15); color: #fca5a5; border-color: rgba(248,113,113,0.35); }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(3px);
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 16px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: #0e0f19;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 26px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 30px 70px rgba(0,0,0,0.6);
  animation: rise 0.25s ease both;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-sm { max-width: 360px; }

.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 6px; }
.modal-close:hover { background: rgba(255,255,255,0.06); color: var(--text); }

.roles-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.role-check {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--text);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--panel-border);
  padding: 7px 11px;
  border-radius: 8px;
  cursor: pointer;
}
.role-check input { width: auto; accent-color: var(--accent); }

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

@media (max-width: 480px) {
  .table-panel { padding: 4px; }
  .data-table th, .data-table td { padding: 10px 12px; font-size: 12.5px; }
}

/* ---------- Login responsive ---------- */
@media (max-width: 860px) {
  .login-visual { display: none; }
  .brand-mobile { display: flex; justify-content: center; margin-bottom: 14px; }
  .login-form-side { padding: 16px; }
  .card { max-width: 420px; padding: 32px 26px; }
}

@media (max-width: 400px) {
  .card { padding: 26px 18px; border-radius: 14px; }
  .card h1 { font-size: 18px; }
  input { font-size: 16px; padding-top: 12px; padding-bottom: 12px; }
  button[type="submit"] { padding: 13px; font-size: 15px; }
}

@media (min-width: 861px) and (max-width: 1080px) {
  .visual-title { font-size: 25px; }
  .login-visual { padding: 40px; }
}
