/* ═══════════════════════════════════════════
   GOAuth Design System
   ═══════════════════════════════════════════ */

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

/* ── Tokens ── */
:root {
  --font: "Manrope", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --gray-50:  #f9fafb;  --gray-100: #f3f4f6;  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;  --gray-400: #9ca3af;  --gray-500: #6b7280;
  --gray-600: #4b5563;  --gray-700: #374151;  --gray-800: #1f2937;
  --gray-900: #111827;

  --blue-50:  #eff6ff;  --blue-100: #dbeafe;  --blue-200: #bfdbfe;
  --blue-500: #3b82f6;  --blue-600: #2563eb;  --blue-700: #1d4ed8;

  --green-50:  #f0fdf4;  --green-100: #dcfce7;  --green-500: #22c55e;  --green-700: #15803d;
  --red-50:    #fef2f2;  --red-100:   #fee2e2;  --red-500:   #ef4444;  --red-700:   #b91c1c;
  --amber-50:  #fffbeb;  --amber-100: #fef3c7;  --amber-500: #f59e0b;  --amber-700: #b45309;
  --teal-600:  #0d9488;  --teal-700:  #0f766e;

  --radius-sm: 6px;
  --radius:    8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  --shadow-sm:  0 1px 2px rgba(0,0,0,0.05);
  --shadow:     0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:  0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --shadow-lg:  0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
  --shadow-xl:  0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
  --shadow-soft: 0 6px 16px -14px rgba(15, 23, 42, 0.24);
}

body {
  font-family: var(--font);
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════════════
   Typography
   ═══════════════════════════════════════════ */
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.025em; color: var(--gray-900); }
h2 { font-size: 1.125rem; font-weight: 600; letter-spacing: -0.015em; color: var(--gray-900); }
h3 { font-size: 1rem; font-weight: 600; color: var(--gray-900); }
p  { color: var(--gray-500); font-size: 0.875rem; }

/* ═══════════════════════════════════════════
   Forms
   ═══════════════════════════════════════════ */
input, select, textarea {
  width: 100%;
  padding: 0.62rem 0.74rem;
  border: 1px solid #d0d7e2;
  border-radius: 8px;
  font-size: 0.875rem;
  font-family: var(--font);
  color: #111827;
  background: #fff;
  transition: border-color 0.16s, box-shadow 0.16s, background-color 0.16s;
}
input:hover, select:hover, textarea:hover {
  border-color: #bcc7d8;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59,130,246,0.16);
  background: #fff;
}
input::placeholder { color: var(--gray-400); }
input[readonly] { background: var(--gray-100); color: var(--gray-500); }

/* ═══════════════════════════════════════════
   Buttons
   ═══════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0.625rem 1rem;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  line-height: 1.25;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--blue-600);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) {
  background: var(--blue-700);
}

.btn-secondary {
  background: #fff;
  color: var(--gray-700);
  border-color: var(--gray-300);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

.btn-danger {
  background: #fff;
  color: var(--red-700);
  border-color: var(--red-100);
}
.btn-danger:hover:not(:disabled) {
  background: var(--red-50);
  border-color: var(--red-500);
}

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--gray-100);
}

.btn-google {
  background: #fff;
  color: var(--gray-700);
  border-color: var(--gray-300);
  box-shadow: var(--shadow-sm);
}
.btn-google:hover:not(:disabled) {
  background: var(--gray-50);
}

.btn-teal {
  background: var(--teal-600);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-teal:hover:not(:disabled) {
  background: var(--teal-700);
}

button.btn {
  border-style: solid;
  cursor: pointer;
}

/* ═══════════════════════════════════════════
   Badge
   ═══════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
}
.badge-blue   { background: var(--blue-50);  color: var(--blue-700);  border-color: var(--blue-100); }
.badge-green  { background: var(--green-50); color: var(--green-700); border-color: var(--green-100); }
.badge-red    { background: var(--red-50);   color: var(--red-700);   border-color: var(--red-100); }
.badge-amber  { background: var(--amber-50); color: var(--amber-700); border-color: var(--amber-100); }
.badge-gray   { background: var(--gray-100); color: var(--gray-600);  border-color: var(--gray-200); }

/* ═══════════════════════════════════════════
   Toast
   ═══════════════════════════════════════════ */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.25s ease-out;
  max-width: 380px;
}
.toast.toast-success {
  background: var(--green-50);
  color: var(--green-700);
  border: 1px solid var(--green-100);
}
.toast.toast-error {
  background: var(--red-50);
  color: var(--red-700);
  border: 1px solid var(--red-100);
}
.toast.toast-info {
  background: var(--blue-50);
  color: var(--blue-700);
  border: 1px solid var(--blue-100);
}
.toast.toast-hide {
  animation: toast-out 0.2s ease-in forwards;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

/* Legacy status — kept for JS compatibility */
.status { display: none; }

/* ═══════════════════════════════════════════
   Auth Layout (Login, Register, Forgot, Reset, Invite)
   ═══════════════════════════════════════════ */
.auth-layout {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(ellipse at 0% 0%, #bfdbfe 0%, transparent 55%),
    radial-gradient(ellipse at 100% 0%, #c7d2fe 0%, transparent 45%),
    radial-gradient(ellipse at 80% 100%, #a5f3fc 0%, transparent 40%),
    radial-gradient(ellipse at 20% 80%, #ddd6fe 0%, transparent 35%),
    linear-gradient(160deg, #eff6ff 0%, #eef2ff 40%, #f0f9ff 70%, #f5f3ff 100%);
}

.auth-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 2rem;
  width: 100%;
  max-width: 420px;
}

.auth-header {
  text-align: center;
  margin-bottom: 1.5rem;
}
.auth-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: var(--blue-50);
  border: 1px solid var(--blue-100);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  color: var(--blue-600);
}
.auth-header h1 {
  margin-bottom: 4px;
}
.auth-header p {
  margin: 0;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.auth-form .btn {
  width: 100%;
  margin-top: 4px;
}

.auth-separator {
  position: relative;
  margin: 20px 0 16px;
  text-align: center;
}
.auth-separator::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 1px;
  background: var(--gray-200);
}
.auth-separator span {
  position: relative;
  display: inline-block;
  padding: 0 12px;
  background: #fff;
  color: var(--gray-400);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.auth-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-200);
  text-align: center;
}
.auth-footer p {
  margin-bottom: 10px;
}
.auth-footer .btn {
  width: 100%;
}

.btn-google-full { width: 100%; }

.auth-link {
  display: inline-block;
  margin-top: 12px;
  color: var(--gray-500);
  font-size: 0.8125rem;
  text-decoration: none;
}
.auth-link:hover {
  color: var(--blue-600);
  text-decoration: underline;
}

.reset-expiry-note {
  font-size: 0.8125rem;
  color: var(--gray-400);
  margin-top: -4px;
}

.reset-rules {
  font-size: 0.8125rem;
  color: var(--gray-500);
}
.reset-rules .ok { color: var(--green-700); font-weight: 600; }
.reset-rules .ko { color: var(--red-700); font-weight: 600; }

/* ═══════════════════════════════════════════
   Home Layout (Profile)
   ═══════════════════════════════════════════ */
.home-layout {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(ellipse at 0% 0%, #bfdbfe 0%, transparent 55%),
    radial-gradient(ellipse at 100% 0%, #c7d2fe 0%, transparent 45%),
    radial-gradient(ellipse at 80% 100%, #a5f3fc 0%, transparent 40%),
    radial-gradient(ellipse at 20% 80%, #ddd6fe 0%, transparent 35%),
    linear-gradient(160deg, #eff6ff 0%, #eef2ff 40%, #f0f9ff 70%, #f5f3ff 100%);
}

.home-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 2rem;
  width: 100%;
  max-width: 480px;
  text-align: center;
}

/* Avatar */
.avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--gray-200);
  box-shadow: var(--shadow-md);
}

.avatar-edit {
  position: relative;
  display: inline-block;
  border-radius: 50%;
  cursor: pointer;
  line-height: 0;
  margin-bottom: 12px;
}
.avatar-edit .avatar { margin-bottom: 0; }

.avatar-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}
.avatar-edit:hover .avatar-overlay,
.avatar-edit:focus-within .avatar-overlay {
  opacity: 1;
}

/* Name edit */
.name-edit {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}
.name-edit h1 {
  position: relative;
  margin-bottom: 0;
  cursor: text;
}
.name-edit-btn {
  position: absolute;
  left: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  background: var(--gray-50);
  color: var(--gray-500);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.name-edit:hover .name-edit-btn,
.name-edit:focus-within .name-edit-btn {
  opacity: 1;
}
.name-edit-btn:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}
.name-editing {
  background: var(--blue-50);
  border-radius: var(--radius-sm);
  outline: 2px solid var(--blue-200);
  padding: 2px 8px;
}

/* Email badge */
.email-badge {
  display: inline-block;
  background: var(--gray-100);
  color: var(--gray-600);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 500;
  margin-bottom: 16px;
}

/* Details table */
.details {
  width: 100%;
  margin-bottom: 20px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  text-align: left;
  font-size: 0.8125rem;
}
.details th {
  color: var(--gray-500);
  font-weight: 500;
  padding: 10px 12px;
  background: var(--gray-50);
  width: 1%;
  white-space: nowrap;
}
.details td {
  color: var(--gray-800);
  padding: 10px 12px;
  word-break: break-all;
}
.details tr + tr {
  border-top: 1px solid var(--gray-200);
}

.inline-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
}
.inline-status.yes {
  background: var(--green-50);
  color: var(--green-700);
  border: 1px solid var(--green-100);
}
.inline-status.no {
  background: var(--red-50);
  color: var(--red-700);
  border: 1px solid var(--red-100);
}

.home-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.home-actions .btn {
  flex: 1 1 0;
  min-width: 120px;
  max-width: 180px;
}

.btn-admin {
  background: var(--teal-600);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-admin:hover:not(:disabled) {
  background: var(--teal-700);
}

.btn-logout {
  background: var(--gray-100);
  color: var(--gray-600);
  border-color: var(--gray-200);
}
.btn-logout:hover:not(:disabled) {
  background: var(--gray-200);
}

/* ═══════════════════════════════════════════
   Admin Layout
   ═══════════════════════════════════════════ */
.admin-layout {
  display: flex;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #f8faff 0%, #f4f7fb 100%);
}

/* Sidebar */
.sidebar {
  width: 256px;
  background: linear-gradient(180deg, #0b1221 0%, #0f172a 72%, #111827 100%);
  color: var(--gray-300);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 40;
  transition: transform 0.2s ease;
}
.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #fff;
  font-weight: 700;
  font-size: 1.125rem;
}
.sidebar-brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: linear-gradient(145deg, #2f77f3 0%, #1d4ed8 100%);
  border-radius: var(--radius);
  color: #fff;
}
.sidebar-label {
  padding: 16px 20px 8px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-500);
}

.sidebar-nav {
  padding: 0 8px;
}
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-400);
  cursor: pointer;
  transition: all 0.12s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font);
  text-decoration: none;
}
.sidebar-nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: var(--gray-200);
}
.sidebar-nav-item.active {
  background: rgba(37,99,235,0.28);
  color: #fff;
  border: 1px solid rgba(125, 181, 255, 0.22);
}
.sidebar-nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.sidebar-nav-count {
  margin-left: auto;
  background: rgba(255,255,255,0.1);
  padding: 1px 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--blue-600);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 600;
  flex-shrink: 0;
}
.sidebar-user-avatar-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.15);
}
.sidebar-user-info {
  overflow: hidden;
}
.sidebar-user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-email {
  font-size: 0.6875rem;
  color: var(--gray-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-footer .btn {
  width: 100%;
  color: var(--gray-400);
  border-color: rgba(255,255,255,0.1);
  font-size: 0.8125rem;
  padding: 7px 12px;
}
.sidebar-footer .btn:hover {
  background: rgba(255,255,255,0.06);
  color: var(--gray-200);
}

/* Mobile sidebar toggle */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 50;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  background: #fff;
  color: var(--gray-700);
  cursor: pointer;
  box-shadow: var(--shadow);
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 35;
}

/* Content area */
.admin-content {
  flex: 1;
  margin-left: 256px;
  padding: 24px 32px;
  min-height: 100vh;
  background: transparent;
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding: 8px 4px;
}
.content-header h1 {
  margin: 0;
  font-size: 1.62rem;
  letter-spacing: -0.03em;
}
.content-header p {
  margin: 6px 0 0;
  font-size: 0.9rem;
  color: #667085;
}

/* Admin surfaces */
.admin-surface {
  background: #fff;
  border: 1px solid #dbe3ef;
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
  padding: 20px 20px 18px;
  margin-bottom: 20px;
}

.admin-surface-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.admin-surface-header h2 {
  margin: 0;
  font-size: 1.03rem;
}

/* Filters */
.admin-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.admin-filters input,
.admin-filters select {
  min-width: 140px;
  flex: 1;
  height: 38px;
  font-size: 0.84rem;
}
.admin-filters .btn {
  height: 38px;
  padding: 8px 14px;
  font-size: 0.82rem;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Keep old class for invite filters */
.admin-filters-invite { }

/* Tables */
.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid #dbe3ef;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: none;
}
.admin-table {
  width: 100%;
  min-width: 900px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.84rem;
}
.admin-table th,
.admin-table td {
  padding: 11px 12px;
  border-bottom: 1px solid #edf1f7;
  vertical-align: middle;
}
.admin-table th {
  color: #667085;
  font-weight: 600;
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.055em;
  background: #f8fafc;
  text-align: left;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
.admin-table th.avatar-col {
  width: 52px;
  min-width: 52px;
  text-align: center;
}
.admin-table tbody tr:hover td {
  background: #f8fafc;
}
.admin-table td input,
.admin-table td select {
  width: 100%;
  min-width: 112px;
  height: 36px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.82rem;
}
.admin-empty {
  text-align: center;
  color: var(--gray-400);
  padding: 32px 12px !important;
}

/* Admin actions */
.admin-actions-cell {
  white-space: nowrap;
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
}

/* Avatar in table */
.avatar-cell {
  width: 52px;
  min-width: 52px;
  text-align: center;
}
.admin-avatar-picker {
  position: relative;
  display: inline-flex;
  cursor: pointer;
}
.admin-avatar-picker:hover { opacity: 0.85; }
.admin-avatar-thumb {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #d7deea;
  box-shadow: none;
}

/* Icon buttons */
.admin-icon-btn {
  width: 34px !important;
  height: 34px;
  padding: 0 !important;
  min-width: 34px;
  border-radius: 8px;
  position: relative;
  flex-shrink: 0;
  border-width: 1px;
  box-shadow: none;
}
.admin-icon-btn svg {
  width: 15px;
  height: 15px;
  pointer-events: none;
}
.btn-icon-save {
  color: #0f766e;
  border-color: #c8f3ea;
  background: #ecfdf8;
}
.btn-icon-save:hover { background: #cff7ed; }
.btn-icon-verify {
  color: #155eef;
  border-color: #cfe0ff;
  background: #eef4ff;
}
.btn-icon-verify:hover { background: #dfe9ff; }
.btn-icon-reset {
  color: #1d4ed8;
  border-color: #dbeafe;
  background: #eff6ff;
}
.btn-icon-reset:hover { background: #d2e8ff; }
.btn-icon-delete {
  color: #b42318;
  border-color: #ffd9d6;
  background: #fff5f4;
}
.btn-icon-delete:hover { background: #ffddda; }

/* Icon button tooltips */
.admin-icon-btn[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-900);
  color: #fff;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.6875rem;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
  z-index: 20;
}
.admin-icon-btn[data-tooltip]::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 0px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--gray-900);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
  z-index: 20;
}
.admin-icon-btn[data-tooltip]:hover::after,
.admin-icon-btn[data-tooltip]:hover::before {
  opacity: 1;
}

/* Invite link */
.invite-link-cell {
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Pagination */
.admin-pagination {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid #e6edf8;
  padding-top: 12px;
}
.admin-pagination .btn {
  height: 36px;
  padding: 6px 14px;
  font-size: 0.82rem;
}
.admin-pagination span {
  color: #667085;
  font-size: 0.82rem;
  min-width: 120px;
  text-align: center;
}

/* Create form */
.admin-create-form {
  margin-bottom: 20px;
}
.admin-create-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}
.admin-create-grid input,
.admin-create-grid select {
  min-width: 0;
  height: 38px;
  font-size: 0.84rem;
}
.admin-create-submit {
  margin-top: 0 !important;
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 38px;
  border-radius: 8px;
  font-weight: 600;
  box-shadow: none;
}

/* Admin view panels */
.admin-view-panel { display: none; }
.admin-view-panel.active { display: block; }

/* ═══════════════════════════════════════════
   Dialog
   ═══════════════════════════════════════════ */
.admin-dialog {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 0;
  width: min(420px, 92vw);
  box-shadow: var(--shadow-xl);
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
}
.admin-dialog::backdrop {
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(2px);
}
.admin-dialog-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
}
.admin-dialog-form h3 { margin: 0; }
.admin-dialog-form p { margin: 0; }
.admin-dialog-form input {
  padding: 8px 10px;
  font-size: 0.8125rem;
}
.admin-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
.admin-dialog-actions .btn {
  width: auto;
  min-width: 110px;
}

/* ═══════════════════════════════════════════
   OAuth2 Consent Page
   ═══════════════════════════════════════════ */
.consent-header {
  text-align: center;
  margin-bottom: 20px;
}
.consent-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--blue-50);
  color: var(--blue-600);
  margin-bottom: 12px;
}
.consent-app-name {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--gray-900);
  margin: 4px 0 2px;
}
.consent-description {
  color: var(--gray-500);
  font-size: 0.875rem;
  margin: 0;
}

.consent-user {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  font-size: 0.8125rem;
  color: var(--gray-500);
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-bottom: 16px;
}
.consent-user-label { font-weight: 400; }
.consent-user strong { color: var(--gray-800); }

.consent-scopes {
  margin-bottom: 20px;
}
.consent-scopes-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 8px;
}
.consent-scopes-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.consent-scopes-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--gray-700);
}
.consent-scopes-list li svg {
  flex-shrink: 0;
}

.consent-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.consent-actions .btn {
  width: 100%;
}

/* ═══════════════════════════════════════════
   TOTP 2FA
   ═══════════════════════════════════════════ */
.totp-code-wrapper {
  display: flex;
  justify-content: center;
  margin: 4px 0;
}
.totp-code-input {
  width: 180px !important;
  text-align: center;
  font-size: 1.5rem !important;
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  letter-spacing: 0.35em;
  padding: 10px 12px !important;
  border-radius: var(--radius-lg) !important;
  border: 1.5px solid var(--gray-300) !important;
  transition: border-color 0.16s, box-shadow 0.16s;
}
.totp-code-input:focus {
  border-color: var(--blue-500) !important;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15) !important;
}
.totp-code-input::placeholder {
  letter-spacing: 0.25em;
  color: var(--gray-300);
  font-size: 1.25rem;
}

.totp-backup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 14px;
  background: var(--gray-50);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-100);
  margin: 12px 0;
}
.totp-backup-code {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.8125rem;
  color: var(--gray-700);
  text-align: center;
  padding: 4px 8px;
  background: #fff;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  user-select: all;
}

/* ── Compat aliases ── */
.btn-close {
  background: var(--gray-100);
  color: var(--gray-600);
  border-color: var(--gray-200);
}
.btn-close:hover {
  background: var(--gray-200);
}

/* ═══════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════ */
@media (max-width: 768px) {
  .auth-card {
    padding: 1.5rem;
    border-radius: var(--radius-lg);
  }

  .home-card {
    padding: 1.5rem;
  }
  .home-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .home-actions .btn {
    max-width: none;
  }

  /* Admin sidebar collapse */
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-toggle {
    display: flex;
  }
  .sidebar-overlay.open {
    display: block;
  }
  .admin-content {
    margin-left: 0;
    padding: 12px;
    padding-top: 56px;
  }

  .content-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 16px;
  }
  .content-header h1 { font-size: 1.25rem; }

  .admin-surface {
    padding: 14px;
    border-radius: var(--radius-md);
    margin-bottom: 14px;
  }

  /* Filters stack vertically */
  .admin-filters {
    flex-direction: column;
  }
  .admin-filters input,
  .admin-filters select {
    min-width: 100%;
    flex: unset;
  }
  .admin-filters .btn {
    width: 100%;
  }

  /* Create / Invite form stack vertically */
  .admin-create-grid {
    grid-template-columns: 1fr;
  }
  .admin-create-grid input,
  .admin-create-grid select {
    min-width: 100%;
  }
  .admin-create-submit {
    width: 100%;
  }

  /* Table: card layout on mobile */
  .admin-table-wrap {
    border: none;
    border-radius: 0;
    background: transparent;
    overflow: visible;
  }
  .admin-table {
    min-width: 0;
  }
  .admin-table thead {
    display: none;
  }
  .admin-table tbody {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .admin-table tbody tr {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: 12px;
  }
  .admin-table tbody tr:hover td {
    background: transparent;
  }
  .admin-table td {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    border-bottom: none;
  }
  .admin-table td::before {
    content: attr(data-label);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-400);
    min-width: 70px;
    flex-shrink: 0;
  }
  .admin-table td input {
    min-width: 0;
    flex: 1;
  }
  .admin-table td.avatar-cell {
    min-width: 0;
    width: auto;
  }
  .admin-table td.avatar-cell::before {
    display: none;
  }
  .admin-table td.admin-actions-cell {
    justify-content: flex-end;
    padding-top: 4px;
    border-top: 1px solid var(--gray-100);
  }
  .admin-table td.admin-actions-cell::before {
    display: none;
  }

  /* Invite link on mobile */
  .invite-link-cell {
    max-width: none;
    white-space: normal;
    word-break: break-all;
  }

  /* Pagination */
  .admin-pagination span {
    min-width: 0;
    font-size: 0.75rem;
  }
}

@media (max-width: 480px) {
  .auth-layout, .home-layout {
    padding: 16px;
  }
  .admin-content {
    padding: 8px;
    padding-top: 52px;
  }
  .admin-surface {
    padding: 10px;
  }
}
