:root {
  --bg: #0a0714;
  --surface: #150f28;
  --surface-2: #1c1538;
  --border: rgba(168, 139, 250, 0.22);
  --text: #f3f1ff;
  --text-muted: #a89fce;
  --primary: #9d5cff;
  --primary-dark: #7c3aed;
  --primary-light: rgba(157, 92, 255, 0.16);
  --danger: #ff5470;
  --danger-light: rgba(255, 84, 112, 0.14);
  --success: #22d3a5;
  --success-light: rgba(34, 211, 165, 0.14);
  --warning: #f5a524;
  --warning-light: rgba(245, 165, 36, 0.14);
  --radius: 14px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(157, 92, 255, 0.05);
  --shadow-lg: 0 25px 60px rgba(0, 0, 0, 0.55), 0 0 40px rgba(157, 92, 255, 0.25);
  --sidebar-w: 220px;
}

* { box-sizing: border-box; }

html {
  scrollbar-width: thin;
  scrollbar-color: rgba(157, 92, 255, 0.45) transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background-color: rgba(157, 92, 255, 0.35);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover {
  background-color: rgba(157, 92, 255, 0.6);
  background-clip: content-box;
}
*::-webkit-scrollbar-corner {
  background: transparent;
}

html, body {
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: 'Plus Jakarta Sans', 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  margin: 0;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

h1, h2, h3 { margin-top: 0; font-weight: 700; letter-spacing: -0.02em; color: #fff; }

/* ---------- Auth pages ---------- */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 15% 20%, rgba(157, 92, 255, 0.35), transparent 40%),
    radial-gradient(circle at 85% 15%, rgba(124, 58, 237, 0.3), transparent 45%),
    radial-gradient(circle at 90% 85%, rgba(34, 211, 165, 0.12), transparent 40%),
    linear-gradient(160deg, #0a0714 0%, #120a26 50%, #1a0f38 100%);
}

.auth-shell::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(157, 92, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(157, 92, 255, 0.06) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at 50% 30%, black, transparent 70%);
  pointer-events: none;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
  animation: rise 0.5s ease;
  position: relative;
  z-index: 1;
}

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

.auth-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), #c9a8ff);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 22px;
  margin: 0 auto 20px;
  box-shadow: 0 0 24px rgba(157, 92, 255, 0.55);
  overflow: hidden;
}

.auth-card h1,
.auth-card .auth-subtitle {
  text-align: center;
}

.auth-card h1 {
  font-size: 24px;
  margin-bottom: 4px;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

.auth-card p {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 20px;
  text-align: center;
}

.auth-card p a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}
.auth-card p a:hover { text-decoration: underline; }

/* ---------- Form elements ---------- */
form label,
.field-label {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.field-label { margin-bottom: 10px; }

.select {
  appearance: none;
  width: 100%;
  padding: 11px 38px 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  background: #100a22 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23a89fce' d='M1 1l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 14px center;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
.select:hover { border-color: rgba(168, 139, 250, 0.4); }
.select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}

form input {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 13.5px;
  font-family: inherit;
  background: #100a22;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

form input::placeholder { color: #635a87; }

form input:hover { border-color: rgba(168, 139, 250, 0.4); }

form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
  background: #150e2c;
}

/* Kill browser autofill white background so it matches the dark theme */
form input:-webkit-autofill,
form input:-webkit-autofill:hover,
form input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px #100a22 inset;
  box-shadow: 0 0 0 1000px #100a22 inset;
  transition: background-color 9999s ease-in-out 0s;
  caret-color: var(--text);
}

/* Remove native number-input spinner arrows */
form input[type="number"]::-webkit-inner-spin-button,
form input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
form input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* File input (logo upload) */
form input[type="file"] {
  padding: 9px 12px;
  cursor: pointer;
}
form input[type="file"]::file-selector-button {
  background: var(--surface-2);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 7px 14px;
  margin-right: 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
form input[type="file"]::file-selector-button:hover {
  background: #241a47;
}

.logo-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.logo-preview img {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}
.logo-preview-remove {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
}
.logo-preview-remove input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: var(--danger);
}

/* ---------- Input with icon / prefix / toggle ---------- */
.input-wrap {
  position: relative;
  margin-bottom: 20px;
}

.input-wrap input {
  margin-bottom: 0;
  padding-left: 42px;
}

.input-wrap .input-icon,
.input-wrap .input-prefix,
.input-wrap .input-toggle {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

.input-wrap .input-icon {
  left: 14px;
  width: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  color: var(--text-muted);
  pointer-events: none;
  transition: color 0.15s ease;
}

.input-wrap input:focus ~ .input-icon { color: var(--primary); }

.input-wrap .input-prefix {
  left: 14px;
  font-size: 13.5px;
  line-height: 1;
  font-weight: 700;
  color: var(--text-muted);
  pointer-events: none;
  transition: color 0.15s ease;
  white-space: nowrap;
}

.input-wrap input:focus ~ .input-prefix { color: var(--primary); }

.input-wrap.has-prefix input { padding-left: 40px; }
.input-wrap.has-prefix-wide input { padding-left: 66px; }

.input-wrap.has-toggle input { padding-right: 42px; }

.input-toggle {
  right: 4px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  box-shadow: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0;
}
.input-toggle:hover { color: var(--primary); filter: none; background: none; }
.input-toggle:active { transform: translateY(-50%); }

.label-hint { font-weight: 400; text-transform: none; letter-spacing: normal; color: var(--text-muted); font-size: 12px; }

.form-section-label {
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  padding-bottom: 8px;
  margin: 18px 0 14px;
  border-bottom: 1px solid var(--border);
}
.form-section-label:first-child { margin-top: 0; }

.form-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
@media (max-width: 560px) {
  .form-grid-4 { grid-template-columns: repeat(2, 1fr); }
}

.balance-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, rgba(157, 92, 255, 0.14), rgba(34, 211, 165, 0.08));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
}

.form-icon-badge {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #c9a8ff);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-bottom: 14px;
  box-shadow: 0 0 24px rgba(157, 92, 255, 0.4);
}

button, .btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: filter 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  box-shadow: 0 0 20px rgba(157, 92, 255, 0.35);
}
button:hover, .btn:hover { filter: brightness(1.12); transform: translateY(-1px); }
button:active, .btn:active { transform: translateY(0); }
button[type="submit"] { width: 100%; justify-content: center; }

.btn-danger { background: var(--danger); box-shadow: 0 0 20px rgba(255, 84, 112, 0.35); }
.btn-danger:hover { background: #ff3a5c; filter: none; }

.btn-secondary { background: var(--surface-2); color: var(--text); border: 1.5px solid var(--border); box-shadow: none; }
.btn-secondary:hover { background: #241a47; transform: none; filter: none; }

.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  flex-shrink: 0;
}

.btn-icon-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1.5px solid var(--border);
  box-shadow: none;
}
.btn-icon-secondary:hover { background: #241a47; transform: translateY(-1px); filter: none; }

.btn-icon-danger {
  background: var(--danger-light);
  color: var(--danger);
  border: 1.5px solid rgba(255, 84, 112, 0.3);
  box-shadow: none;
}
.btn-icon-danger:hover { background: var(--danger); color: #fff; transform: translateY(-1px); filter: none; }

.btn-icon-success {
  background: var(--success-light);
  color: var(--success);
  border: 1.5px solid rgba(34, 211, 165, 0.3);
  box-shadow: none;
}
.btn-icon-success:hover { background: var(--success); color: #fff; transform: translateY(-1px); filter: none; }

.balance-toggle { display: flex; gap: 8px; margin-bottom: 20px; }

.balance-toggle-btn {
  flex: 1;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  box-shadow: none;
  justify-content: center;
}
.balance-toggle-btn:hover { background: #241a47; transform: none; filter: none; }

#balanceActionAdd.active {
  background: linear-gradient(135deg, var(--success), #17a67f);
  color: #08150f;
  border-color: transparent;
  box-shadow: 0 0 16px rgba(34, 211, 165, 0.35);
}

#balanceActionReduce.active {
  background: linear-gradient(135deg, var(--warning), #d98a1a);
  color: #2a1700;
  border-color: transparent;
  box-shadow: 0 0 16px rgba(245, 165, 36, 0.35);
}

/* ---------- Modal ---------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(6, 3, 15, 0.72);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 500;
}

.modal-overlay.active { display: flex; }

.modal-box {
  position: relative;
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 0;
  padding-right: 22px;
  animation: rise 0.25s ease;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  box-shadow: none;
  font-size: 12px;
  line-height: 1;
}
.modal-close:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  transform: none;
  filter: none;
}

/* Icon buttons rendered as <button type="submit"> must not inherit the full-width submit style */
button.btn-icon-danger,
button.btn-icon-secondary,
button.btn-icon-success { width: 34px; justify-content: center; }

.error {
  background: var(--danger-light);
  color: #ff8a9c;
  border: 1px solid rgba(255, 84, 112, 0.3);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  margin-bottom: 16px;
  font-weight: 500;
}
.success {
  background: var(--success-light);
  color: #6ee9c8;
  border: 1px solid rgba(34, 211, 165, 0.3);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  margin-bottom: 16px;
  font-weight: 500;
}

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

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.25s ease;
}
.toast.leaving { animation: toast-out 0.2s ease forwards; }

.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  margin-top: 1px;
}
.toast-message { flex: 1; line-height: 1.45; font-size: 13.5px; font-weight: 500; color: var(--text); }

.toast-close {
  background: none;
  border: none;
  box-shadow: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  padding: 2px;
  line-height: 1;
  flex-shrink: 0;
}
.toast-close:hover { color: var(--text); transform: none; filter: none; }

.toast-success { border-left-color: var(--success); }
.toast-success .toast-icon { background: var(--success-light); color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-error .toast-icon { background: var(--danger-light); color: var(--danger); }
.toast-info { border-left-color: var(--primary); }
.toast-info .toast-icon { background: var(--primary-light); color: #c9a8ff; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(24px); }
}

/* ---------- Confirm dialog ---------- */
.confirm-box { text-align: center; padding-top: 30px; }
.confirm-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--danger-light);
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin: 0 auto 16px;
}
.confirm-title { font-size: 16px; font-weight: 700; color: #fff; margin-bottom: 6px; }
.confirm-message { color: var(--text-muted); font-size: 13.5px; margin-bottom: 22px; line-height: 1.5; }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions button { flex: 1; justify-content: center; }

/* ---------- App shell (sidebar + content) ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, #140c29 0%, #1e1240 100%);
  border-right: 1px solid var(--border);
  color: #e7e2ff;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  padding: 0 8px;
  margin-bottom: 22px;
}

.sidebar-logo {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), #c9a8ff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  flex-shrink: 0;
  box-shadow: 0 0 16px rgba(157, 92, 255, 0.5);
  overflow: hidden;
}

.auth-logo img,
.sidebar-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  color: #b6adde;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-nav a .icon {
  font-size: 15px;
  width: 18px;
  text-align: center;
}

.sidebar-nav a:hover {
  background: rgba(157, 92, 255, 0.1);
  color: #fff;
}

.sidebar-nav a.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 0 20px rgba(157, 92, 255, 0.45);
}

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

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 0 4px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #c9a8ff, var(--primary));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13.5px;
  flex-shrink: 0;
  box-shadow: 0 0 14px rgba(157, 92, 255, 0.4);
}

.sidebar-user-name {
  font-size: 13.5px;
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
}

.sidebar-user-role {
  font-size: 12px;
  color: #9a8fce;
  text-transform: capitalize;
}

.btn-logout {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  color: #e7e2ff;
  border: 1px solid var(--border);
  box-shadow: none;
  justify-content: center;
  font-size: 13px;
}
.btn-logout:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  filter: none;
}

.main-content {
  flex: 1;
  min-width: 0;
  width: 100%;
  padding: 28px 32px;
}

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

.page-header h1 { font-size: 21px; margin-bottom: 4px; }
.page-header .subtitle { color: var(--text-muted); font-size: 13px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  border: 1px solid var(--border);
}

.card-narrow { max-width: 420px; }

.settings-row {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.settings-row .card-narrow { flex: 1; max-width: none; margin-bottom: 0; }
.settings-col { display: flex; flex-direction: column; gap: 20px; flex: 1; min-width: 0; }
.settings-col .card-narrow { max-width: none; margin-bottom: 0; }

.version-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }

.settings-card-header { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.settings-card-header .form-icon-badge { margin-bottom: 0; flex-shrink: 0; }
.settings-card-header .collapsible-title { flex: 1; min-width: 0; }
.settings-card-header .collapsible-title .field-label { margin-bottom: 2px; }

/* ---------- Toggle switch ---------- */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; transition: background 0.2s ease;
}
.switch-slider::before {
  content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 50%;
  transform: translateY(-50%);
  background: #fff; border-radius: 50%; transition: transform 0.2s ease;
}
.switch input:checked + .switch-slider { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .switch-slider::before { transform: translate(20px, -50%); }
.switch input:focus-visible + .switch-slider { outline: 2px solid var(--primary); outline-offset: 2px; }

.progress-bar { width: 100%; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  transition: width 0.2s ease;
}

/* ---------- Stat cards ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-icon.purple { background: var(--primary-light); color: #c9a8ff; box-shadow: 0 0 16px rgba(157, 92, 255, 0.25); }
.stat-icon.green { background: var(--success-light); color: var(--success); box-shadow: 0 0 16px rgba(34, 211, 165, 0.25); }

.stat-num { font-size: 28px; font-weight: 800; line-height: 1.1; color: #fff; }
.stat-label { color: var(--text-muted); font-size: 13.5px; margin-top: 2px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }

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

thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1.5px solid var(--border);
  font-weight: 700;
}

tbody td {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.15s ease; }
tbody tr:hover { background: rgba(157, 92, 255, 0.06); }

.cell-user { display: flex; align-items: center; gap: 10px; }
.cell-user .avatar { width: 32px; height: 32px; font-size: 13px; }
.cell-name { font-weight: 600; color: #fff; }
.cell-sub { color: var(--text-muted); font-size: 12.5px; }

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-purple { background: var(--primary-light); color: #c9a8ff; border: 1px solid rgba(157, 92, 255, 0.35); }
.badge-green { background: rgba(34, 197, 94, 0.12); color: #4ade80; border: 1px solid rgba(34, 197, 94, 0.35); }
.badge-red { background: rgba(239, 68, 68, 0.12); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.35); }
.badge-blue { background: rgba(59, 130, 246, 0.12); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.35); }
.badge-orange { background: rgba(245, 165, 36, 0.12); color: #f5a524; border: 1px solid rgba(245, 165, 36, 0.35); }

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

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

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.pagination-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid rgba(157, 92, 255, 0.2);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.pagination-btn:hover:not(.disabled):not(.active) { background: rgba(157, 92, 255, 0.1); color: #fff; }
.pagination-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination-btn.disabled { opacity: 0.4; pointer-events: none; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .app-shell { flex-direction: column; }

  /* Top bar: brand + logout only (nav moves to a bottom tab bar below) */
  .sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 200;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
  }

  .sidebar-brand { margin-bottom: 0; }

  .sidebar-footer { border-top: none; padding-top: 0; }

  .sidebar-user { display: none; }

  .btn-logout { width: auto; padding: 8px 16px; }

  /* Bottom icon tab bar */
  .sidebar-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    flex-direction: row;
    justify-content: space-around;
    align-items: stretch;
    gap: 0;
    background: linear-gradient(180deg, #1c1336, #140c29);
    border-top: 1px solid var(--border);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
  }

  .sidebar-nav a {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 6px 4px;
    font-size: 11px;
    text-align: center;
    border-radius: 10px;
  }

  .sidebar-nav a .icon {
    font-size: 20px;
    width: auto;
  }

  .sidebar-nav a.active { box-shadow: none; }

  .main-content { padding: 24px; padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
}

@media (max-width: 600px) {
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-header > a.btn,
  .page-header > .btn { width: 100%; justify-content: center; }

  .card { padding: 20px; }
  .card-narrow { max-width: 100%; }

  .settings-row { flex-direction: column; }
  .settings-col { width: 100%; }

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

  .table-wrap { padding: 14px; }
  thead { display: none; }
  table, tbody, tr, td { display: block; width: 100%; }
  tbody tr {
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 12px;
    padding: 10px 4px;
  }
  tbody td {
    border-bottom: none;
    padding: 8px 12px;
  }
  tbody td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 4px;
  }
  .actions { justify-content: flex-start; }
}

@media (max-width: 480px) {
  .auth-card { padding: 32px 22px; }
  .auth-card h1 { font-size: 21px; }
  .sidebar-brand span { font-size: 14px; }
  .main-content { padding: 18px; padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
  .page-header h1 { font-size: 21px; }
}
