/* ============================================================
   SSO Admin Panel — Premium Dark UI
   Design: Deep navy bg, electric blue/purple accents, Inter font
   ============================================================ */

/* ─── CSS Variables ─────────────────────────────────────────── */
:root {
  /* Colors */
  --bg-base:       #0D1117;
  --bg-surface:    #161B22;
  --bg-elevated:   #1C2331;
  --bg-hover:      #21293A;

  --accent-blue:   #4F8EF7;
  --accent-purple: #7C5DEA;
  --accent-green:  #3DD68C;
  --accent-yellow: #F7C948;
  --accent-red:    #F75858;

  --text-primary:  #E6EDF3;
  --text-secondary:#8B949E;
  --text-muted:    #6E7681;

  --border:        rgba(240,246,252,0.10);
  --border-hover:  rgba(240,246,252,0.18);

  --sidebar-w:     240px;
  --topbar-h:      60px;
  --radius:        10px;
  --radius-sm:     6px;
  --radius-lg:     14px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:  0 12px 40px rgba(0,0,0,0.6);

  /* Transitions */
  --t:          0.2s ease;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-base);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

code { font-family: 'Fira Code', 'Cascadia Code', ui-monospace, monospace; }

/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-hover); }

/* ─── Auth Layout ────────────────────────────────────────────── */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  background-image:
    radial-gradient(ellipse 80% 60% at 20% -10%, rgba(79,142,247,0.15) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 110%, rgba(124,93,234,0.12) 0%, transparent 60%);
  padding: 24px;
}

.auth-container { width: 100%; max-width: 400px; }

.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.4s ease;
}

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

.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.auth-title {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  color: var(--text-primary);
  margin-bottom: 6px;
}

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

.auth-error {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(247, 88, 88, 0.12);
  border: 1px solid rgba(247, 88, 88, 0.3);
  color: #FF8080;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 13px;
}

/* ─── Admin Layout ───────────────────────────────────────────── */
.admin-body { display: flex; min-height: 100vh; }

/* ─── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width var(--t), transform var(--t);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand {
  font-size: 15px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}

.sidebar-toggle-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: color var(--t), background var(--t);
  display: none;
}

.sidebar-toggle-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 12px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: color var(--t), background var(--t);
  white-space: nowrap;
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  text-decoration: none;
}

.nav-item.active {
  color: var(--accent-blue);
  background: rgba(79, 142, 247, 0.12);
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-profile {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.admin-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
}

.admin-info { min-width: 0; }
.admin-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-role { font-size: 11px; color: var(--text-muted); }

.logout-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 7px;
  border-radius: var(--radius-sm);
  transition: color var(--t), background var(--t);
  flex-shrink: 0;
}
.logout-btn:hover { color: var(--accent-red); background: rgba(247,88,88,0.1); }

/* ─── Main Wrapper ───────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0; /* Crucial for preventing flex blowout */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--t);
}

/* ─── Topbar ─────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  flex: 1;
  min-width: 0; /* Allow flex child to shrink */
  white-space: nowrap;
  overflow: hidden;
}

.breadcrumb-item { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; }
.breadcrumb-sep  { color: var(--text-muted); flex-shrink: 0; }
.breadcrumb-current { color: var(--text-primary); font-weight: 500; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }

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

.topbar-admin {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  text-transform: uppercase;
}

.topbar-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ─── Page Content ───────────────────────────────────────────── */
.page-content {
  flex: 1;
  min-width: 0; /* Prevent flex blowout */
  padding: 28px 28px;
  max-width: 100%;
  width: 100%;
}

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

.page-header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ─── Back Button ────────────────────────────────────────────── */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 8px;
  transition: color var(--t);
}
.back-btn:hover { color: var(--text-primary); text-decoration: none; }

/* ─── Stats Grid ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color var(--t), box-shadow var(--t);
}

.stat-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon--blue   { background: rgba(79,142,247,0.15);  color: var(--accent-blue); }
.stat-icon--purple { background: rgba(124,93,234,0.15); color: var(--accent-purple); }
.stat-icon--green  { background: rgba(61,214,140,0.15);  color: var(--accent-green); }

.stat-body { flex: 1; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text-primary); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.stat-label-sm { font-size: 11px; color: var(--text-muted); }
.stat-link { font-size: 12px; color: var(--accent-blue); white-space: nowrap; }
.stat-link:hover { text-decoration: underline; }

/* ─── Dashboard Grid ─────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* ─── Card ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
}

.card-action {
  font-size: 12px;
  color: var(--accent-blue);
}
.card-action:hover { text-decoration: underline; }

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

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.table th {
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }

.table-row-hover:hover td { background: var(--bg-hover); }

.user-cell, .app-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  color: #fff;
  text-transform: uppercase;
  flex-shrink: 0;
}

.app-icon-sm {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: rgba(79,142,247,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-blue);
  flex-shrink: 0;
}

.user-name  { font-weight: 500; }
.user-id    { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

.empty-state {
  text-align: center;
  padding: 48px 20px !important;
  color: var(--text-muted);
}

.empty-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
  color: var(--text-muted);
}

.empty-state p { margin-bottom: 12px; }

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

/* ─── Pagination ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px;
  border-top: 1px solid var(--border);
}

.page-btn {
  min-width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--t);
  border: 1px solid transparent;
}

.page-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  text-decoration: none;
  border-color: var(--border);
}

.page-btn--active {
  background: var(--accent-blue);
  color: #fff !important;
  border-color: var(--accent-blue);
  font-weight: 600;
}

/* ─── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success { background: rgba(61,214,140,0.15); color: var(--accent-green); }
.badge-danger  { background: rgba(247,88,88,0.15);  color: var(--accent-red);   }
.badge-blue    { background: rgba(79,142,247,0.15);  color: var(--accent-blue); }
.badge-warning { background: rgba(247,201,72,0.15);  color: var(--accent-yellow); }
.badge-neutral { background: var(--bg-elevated);     color: var(--text-secondary); border: 1px solid var(--border); }
.badge-purple  { background: rgba(124,93,234,0.15);  color: var(--accent-purple); }

.badge-lg { padding: 4px 12px; font-size: 12px; }

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--t);
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  gap: 6px;
  line-height: 1;
}

.btn-disabled, .btn-disabled:hover {
  opacity: 0.5;
  cursor: not-allowed !important;
}

.btn-primary {
  background: var(--accent-blue);
  color: #fff;
  border-color: var(--accent-blue);
}
.btn-primary:hover {
  background: #3b7de8;
  border-color: #3b7de8;
  text-decoration: none;
  color: #fff;
  box-shadow: 0 0 0 3px rgba(79,142,247,0.2);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
  text-decoration: none;
}

.btn-danger {
  background: transparent;
  color: var(--accent-red);
  border-color: rgba(247,88,88,0.3);
}
.btn-danger:hover {
  background: rgba(247,88,88,0.12);
  border-color: var(--accent-red);
  text-decoration: none;
}

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-full { width: 100%; }

.btn-arrow {
  transition: transform var(--t);
}
.btn:hover .btn-arrow { transform: translateX(3px); }

/* ─── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.required { color: var(--accent-red); margin-left: 2px; }

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
  z-index: 1;
}

.form-input, .form-select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--t), box-shadow var(--t);
  outline: none;
  appearance: none;
}

.input-wrapper .form-input {
  padding-left: 38px;
  padding-right: 38px;
}

.form-input::placeholder { color: var(--text-muted); }

.form-input:focus, .form-select:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(79,142,247,0.15);
}

.toggle-password {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  transition: color var(--t);
}
.toggle-password:hover { color: var(--text-primary); }

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 5px;
}

.form-info-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(79,142,247,0.08);
  border: 1px solid rgba(79,142,247,0.2);
  color: var(--accent-blue);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 13px;
  line-height: 1.5;
}

.form-error-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(247,88,88,0.08);
  border: 1px solid rgba(247,88,88,0.25);
  color: #FF8080;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 13px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.form-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 640px;
}

/* ─── Auth Form ──────────────────────────────────────────────── */
.auth-form { display: flex; flex-direction: column; gap: 4px; }
.auth-form .form-group { margin-bottom: 16px; }
.auth-form .form-input { padding-left: 38px; }

/* ─── Search ─────────────────────────────────────────────────── */
.toolbar {
  margin-bottom: 16px;
}

.search-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.search-wrapper {
  position: relative;
  flex: 1;
  max-width: 400px;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 9px 36px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--t);
}

.search-input:focus {
  border-color: var(--accent-blue);
}

.search-input::placeholder { color: var(--text-muted); }

.search-clear {
  position: absolute;
  right: 10px;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  text-decoration: none;
  transition: color var(--t);
}
.search-clear:hover { color: var(--text-primary); text-decoration: none; }

/* ─── Flash messages ─────────────────────────────────────────── */
.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 13.5px;
  font-weight: 500;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.flash-success {
  background: rgba(61,214,140,0.10);
  border: 1px solid rgba(61,214,140,0.25);
  color: var(--accent-green);
}

.flash-error {
  background: rgba(247,88,88,0.10);
  border: 1px solid rgba(247,88,88,0.25);
  color: #FF8080;
}

.flash span { flex: 1; }

.flash-close {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  opacity: 0.6;
  padding: 0 2px;
}
.flash-close:hover { opacity: 1; }

/* ─── User Status Badges ─────────────────────────────────────── */
.user-status-badges {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ─── User Detail Grid ───────────────────────────────────────── */
.user-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.grid-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ─── Access List ────────────────────────────────────────────── */
.access-list {
  display: flex;
  flex-direction: column;
}

.access-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  transition: background var(--t);
}

.access-item:last-child { border-bottom: none; }
.access-item:hover { background: var(--bg-hover); }

.access-app-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(79,142,247,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-blue);
  flex-shrink: 0;
}

.access-app-info { flex: 1; min-width: 0; }
.access-app-name { font-size: 13px; font-weight: 500; }
.access-app-url  { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── Grant Form ─────────────────────────────────────────────── */
.grant-form { padding: 20px; }

/* ─── Apps Dashboard List ────────────────────────────────────── */
.apps-list { display: flex; flex-direction: column; }

.app-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--border);
  transition: background var(--t);
}
.app-item:last-child { border-bottom: none; }
.app-item:hover { background: var(--bg-hover); }

.app-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: rgba(124,93,234,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-purple);
  flex-shrink: 0;
}

.app-info { flex: 1; min-width: 0; }
.app-name { font-size: 13px; font-weight: 500; }
.app-url  { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-users { margin-right: 8px; }

/* ─── Action Buttons ─────────────────────────────────────────── */
.action-btns {
  display: flex;
  gap: 6px;
  align-items: center;
}

.inline-form { display: inline; }

/* ─── Code ───────────────────────────────────────────────────── */
.code-badge {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11.5px;
  color: var(--accent-purple);
}

.code-block {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--accent-purple);
  word-break: break-all;
}

/* ─── Credentials ────────────────────────────────────────────── */
.credentials-section {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 20px;
}

.credentials-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.credential-row {
  margin-bottom: 12px;
}
.credential-row:last-child { margin-bottom: 0; }

.credential-value {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
}

.copy-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--t);
  flex-shrink: 0;
}
.copy-btn:hover {
  background: var(--bg-hover);
  color: var(--accent-blue);
  border-color: var(--accent-blue);
}

/* ─── URL Links ──────────────────────────────────────────────── */
.url-link {
  color: var(--text-muted);
  font-size: 13px;
  transition: color var(--t);
}
.url-link:hover { color: var(--accent-blue); }

/* ─── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity var(--t);
}
.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  transform: translateY(0);
  transition: transform var(--t);
  margin: 20px;
}
.modal-overlay.hidden .modal-card {
  transform: translateY(20px);
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 24px; cursor: pointer; line-height: 1; margin: -5px -5px -5px 0; }
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 24px; color: var(--text-secondary); font-size: 14px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 12px; }

/* ─── Utility classes ────────────────────────────────────────── */
.text-muted    { color: var(--text-muted); }
.text-sm       { font-size: 12px; }
.font-medium   { font-weight: 500; }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .dashboard-grid,
  .user-detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-wrapper {
    margin-left: 0;
  }
  .topbar-menu-btn {
    display: flex;
  }
  .page-content {
    padding: 20px 16px;
  }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .search-form {
    flex-direction: column;
    align-items: stretch;
  }
  .search-wrapper {
    max-width: 100%;
  }
  .form-card {
    padding: 20px;
  }
}

@media (max-width: 480px) {
  .topbar-name { display: none; }
  .action-btns { flex-direction: column; gap: 4px; }
  .auth-body { padding: 16px; }
  .auth-card { padding: 32px 24px; }
  .auth-title { font-size: 20px; }
  .page-title { font-size: 18px; }
  .btn { width: 100%; justify-content: center; } /* Make buttons full width on small mobile */
  .page-header { gap: 12px; }
}
