/* ============================================================
   AI Namecard — Admin theme (Bootstrap 5.3)
   Dark sidebar · light workspace · Google-style preloader
   ============================================================ */

:root {
  --nc-bg: #f3f5fb;
  --nc-ink: #0f172a;
  --nc-muted: #64748b;
  --nc-line: #e6eaf3;
  --nc-primary: #2563eb;
  --nc-sidebar: #0b1220;
  --nc-sidebar-2: #131f36;
  --nc-sidebar-ink: #c7d2e5;
  --nc-sidebar-muted: #7c8aa5;
  --nc-radius: 16px;
  --nc-sidebar-w: 268px;
  --nc-topbar-h: 64px;
  --nc-shadow: 0 10px 30px -12px rgba(15, 23, 42, .18);
}

html, body { height: 100%; }
body.nc-admin {
  background: var(--nc-bg);
  color: var(--nc-ink);
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  overflow-x: hidden;
}
.min-w-0 { min-width: 0; }

/* ---------- Google-style preloader ---------- */
.nc-preloader {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: #fff;
  transition: opacity .5s ease, visibility .5s ease;
}
.nc-preloader.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.nc-google-loader {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #4285F4 0 25%, #EA4335 0 50%, #FBBC05 0 75%, #34A853 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 0);
  mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 0);
  animation: nc-spin .95s linear infinite;
}
@keyframes nc-spin { to { transform: rotate(1turn); } }
.nc-preloader p { margin: 0; color: #5f6368; font-size: 14px; letter-spacing: .02em; }

/* ---------- Page transitions ---------- */
.page-fade { animation: nc-fade-up .5s cubic-bezier(.22, .61, .36, 1) both; }
@keyframes nc-fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
.app-main, .auth-wrap { transition: opacity .18s ease, transform .18s ease; }
body.nc-leaving .app-main,
body.nc-leaving .auth-wrap { opacity: 0; transform: translateY(6px); }

/* ---------- Sidebar ---------- */
.app-sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--nc-sidebar-w);
  z-index: 1045;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  color: var(--nc-sidebar-ink);
  background:
    radial-gradient(120% 60% at 0% 0%, #16233d 0%, transparent 60%),
    linear-gradient(180deg, var(--nc-sidebar), var(--nc-sidebar-2));
  overflow-y: auto;
  transition: transform .3s cubic-bezier(.22, .61, .36, 1);
}
.app-sidebar::-webkit-scrollbar { width: 6px; }
.app-sidebar::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, .25); border-radius: 999px; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 18px;
  color: #fff;
  text-decoration: none;
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: .5px;
  color: #fff;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  box-shadow: 0 8px 20px -6px rgba(37, 99, 235, .7);
}
.brand-text strong { display: block; font-size: 15px; line-height: 1.2; }
.brand-text small { color: var(--nc-sidebar-muted); font-size: 11px; letter-spacing: .14em; }

.side-nav { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.side-nav-label {
  padding: 16px 12px 6px;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--nc-sidebar-muted);
}
.side-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 12px;
  color: var(--nc-sidebar-ink);
  text-decoration: none;
  font-size: 14px;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.side-link svg { width: 20px; height: 20px; flex: none; opacity: .85; }
.side-link:hover { background: rgba(148, 163, 184, .12); color: #fff; }
.side-link.active {
  background: linear-gradient(90deg, rgba(37, 99, 235, .95), rgba(59, 130, 246, .6));
  color: #fff;
  box-shadow: 0 10px 24px -12px rgba(37, 99, 235, .95);
}
.side-link.active svg { opacity: 1; }

.side-foot {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(148, 163, 184, .14);
  display: flex;
  align-items: center;
  gap: 10px;
}
.side-role { color: var(--nc-sidebar-muted); font-size: 11px; }

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  background: rgba(59, 130, 246, .18);
  color: #93c5fd;
  font-weight: 700;
  font-size: 13px;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1040;
  background: rgba(8, 15, 30, .55);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease, visibility .25s ease;
}
.sidebar-backdrop.is-open { opacity: 1; visibility: visible; }

/* ---------- Main / topbar ---------- */
.app-main {
  min-height: 100vh;
  margin-left: var(--nc-sidebar-w);
  display: flex;
  flex-direction: column;
}
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  height: var(--nc-topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  background: rgba(255, 255, 255, .82);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--nc-line);
}
.app-content {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 24px 28px 48px;
}

.btn-icon {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--nc-line);
  background: #fff;
  color: var(--nc-ink);
  transition: background .15s ease, box-shadow .15s ease;
}
.btn-icon:hover { background: #f8fafc; box-shadow: var(--nc-shadow); }
.btn-icon svg { width: 20px; height: 20px; }

.admin-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 10px 5px 6px;
  border: 1px solid var(--nc-line);
  border-radius: 999px;
  background: #fff;
  color: inherit;
  text-decoration: none;
  transition: box-shadow .15s ease;
}
.admin-chip:hover { box-shadow: var(--nc-shadow); color: inherit; }
.admin-chip .avatar { width: 32px; height: 32px; }
.dropdown-menu { --bs-dropdown-border-radius: 14px; }

/* ---------- Page head ---------- */
.page-head {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 22px;
}
.page-head h1 { font-size: 24px; font-weight: 700; margin: 0 0 4px; letter-spacing: -.01em; }
.page-head p { margin: 0; color: var(--nc-muted); font-size: 14px; }

/* ---------- Cards / stats ---------- */
.card {
  --bs-card-border-color: var(--nc-line);
  border-radius: var(--nc-radius);
  box-shadow: var(--nc-shadow);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--nc-line);
  font-weight: 600;
  padding: 16px 20px;
}
.card-body { padding: 20px; }

.stat-card .stat-ico {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  flex: none;
}
.stat-card .stat-ico svg { width: 24px; height: 24px; }
.stat-value { font-size: 26px; font-weight: 750; line-height: 1; letter-spacing: -.02em; }
.stat-label { color: var(--nc-muted); font-size: 13px; margin-top: 6px; }

.quick-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--nc-line);
  border-radius: 14px;
  background: #fff;
  color: inherit;
  text-decoration: none;
  transition: border-color .18s ease, background .18s ease, transform .18s ease, box-shadow .18s ease;
}
.quick-link:hover {
  border-color: #bfdbfe;
  background: #f8fbff;
  transform: translateY(-1px);
  box-shadow: var(--nc-shadow);
  color: inherit;
}
.quick-link .qi {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: #eff6ff;
  color: var(--nc-primary);
  flex: none;
}
.quick-link .qi svg { width: 20px; height: 20px; }

/* ---------- Tables ---------- */
.table { --bs-table-bg: transparent; margin: 0; }
.table > thead th {
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--nc-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--nc-line);
  white-space: nowrap;
}
.table > tbody td { vertical-align: middle; border-color: #f1f5f9; font-size: 14px; }
.table-hover > tbody > tr:hover > * { background: #f8fafc; }

.empty-state { text-align: center; padding: 46px 16px; color: var(--nc-muted); }
.empty-state svg { width: 46px; height: 46px; opacity: .35; margin-bottom: 10px; }

/* ---------- Forms ---------- */
.form-label { font-weight: 600; font-size: 13.5px; color: #334155; }
.form-control { border-radius: 11px; border-color: #dbe2ee; padding: .6rem .8rem; }
.form-select { border-radius: 11px; border-color: #dbe2ee; padding: .6rem 2.25rem .6rem .8rem; line-height: 1.5; height: calc(1.5em + 1.2rem + 2px); -webkit-appearance: none; -moz-appearance: none; appearance: none; }
.form-control-sm { padding: .3rem .65rem; border-radius: 9px; }
.form-select-sm { padding: .3rem 2rem .3rem .65rem; border-radius: 9px; line-height: 1.5; height: calc(1.5em + .6rem + 2px); }
.form-control:focus, .form-select:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 .25rem rgba(37, 99, 235, .12);
}
.btn { border-radius: 11px; font-weight: 600; }
.btn-primary {
  --bs-btn-bg: #2563eb;
  --bs-btn-border-color: #2563eb;
  --bs-btn-hover-bg: #1d4ed8;
  --bs-btn-hover-border-color: #1d4ed8;
  --bs-btn-active-bg: #1e40af;
  --bs-btn-active-border-color: #1e40af;
}

.perm-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--nc-line);
  border-radius: 999px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.perm-pill:has(input:checked) { border-color: #93c5fd; background: #eff6ff; color: #1d4ed8; }

/* ---------- Files ---------- */
.file-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--nc-line);
  background: #f8fafc;
  cursor: zoom-in;
}
.nc-zoom {
  position: fixed;
  inset: 0;
  z-index: 2100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 15, 30, .9);
  cursor: zoom-out;
  animation: nc-fade-in .2s ease;
}
.nc-zoom img {
  max-width: 94vw;
  max-height: 88vh;
  border-radius: 14px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .6);
}
@keyframes nc-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Auth ---------- */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 12% 8%, #e0ecff 0%, transparent 60%),
    radial-gradient(700px 500px at 88% 92%, #ede9fe 0%, transparent 60%),
    #f4f6fb;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 30px 80px -30px rgba(15, 23, 42, .35);
  padding: 34px 30px;
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; text-decoration: none; color: inherit; }
.auth-brand .brand-mark { width: 46px; height: 46px; border-radius: 14px; }
.auth-foot { color: #94a3b8; font-size: 12px; text-align: center; margin-top: 18px; }

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); box-shadow: 0 20px 60px rgba(2, 6, 23, .45); }
  .app-sidebar.is-open { transform: none; }
  .app-main { margin-left: 0; }
  .app-topbar { padding: 0 14px; }
  .app-content { padding: 20px 16px 40px; }
}
@media (max-width: 575.98px) {
  .page-head h1 { font-size: 21px; }
  .stat-value { font-size: 23px; }
  .auth-card { padding: 28px 22px; border-radius: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* Profile avatars */
.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-lg { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; background: #e8ebf3; cursor: zoom-in; }
.avatar-lg.ph { display: grid; place-items: center; font-size: 34px; font-weight: 700; color: #6b7280; cursor: default; }
.mask-val { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .5px; }
#avatar-preview .thumb { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; cursor: zoom-in; display: block; }

/* ---------- Unified List & Filter Bar (sl-*) ---------- */
.sl-bar {
  background: #fff;
  border: 1px solid var(--nc-line);
  border-radius: 14px;
  box-shadow: 0 2px 10px -4px rgba(15, 23, 42, .06);
  margin-bottom: 14px;
  overflow: hidden;
}
.sl-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid #f1f5f9;
}
.sl-search svg { width: 18px; height: 18px; color: #94a3b8; flex: none; }
.sl-search input[type="search"] {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 14.5px;
  color: var(--nc-ink);
  padding: 4px 0;
}
.sl-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
  padding: 10px 16px;
}
.sl-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sl-lbl {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #64748b;
  white-space: nowrap;
}
.sl-seg {
  display: inline-flex;
  border: 1px solid #dbe2ee;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.sl-seg a {
  padding: 5px 11px;
  font-size: 12.5px;
  font-weight: 600;
  color: #475569;
  text-decoration: none;
  border-right: 1px solid #e6eaf3;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.sl-seg a:last-child { border-right: 0; }
.sl-seg a:hover { background: #f8fafc; color: var(--nc-ink); }
.sl-seg a.active { background: #1e293b; color: #fff; border-color: #1e293b; }
.sl-seg a b { font-weight: 600; opacity: .7; margin-left: 3px; }
.sl-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid #dbe2ee;
  background: #fff;
  color: #475569;
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}
.sl-chip:hover { background: #f8fafc; color: var(--nc-ink); border-color: #cbd5e1; }
.sl-chip.active { background: #eef2ff; border-color: #6366f1; color: #3730a3; font-weight: 600; }
.sl-chip.active::before { content: "✓ "; font-weight: 700; }
.sl-select {
  border: 1px solid #dbe2ee;
  border-radius: 8px;
  padding: 5px 28px 5px 10px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--nc-ink);
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 11px;
  -webkit-appearance: none;
  appearance: none;
  height: 31px;
  line-height: 1.4;
}
.sl-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
  border-top: 1px solid #f1f5f9;
  padding: 8px 16px;
  font-size: 12.5px;
  color: #64748b;
}
.sl-pager { display: inline-flex; align-items: center; gap: 5px; }
.sl-pager a {
  padding: 4px 10px;
  border-radius: 7px;
  border: 1px solid #dbe2ee;
  background: #fff;
  color: #334155;
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 600;
}
.sl-pager a:hover { background: #f1f5f9; }
.sl-pager a.disabled { opacity: .4; pointer-events: none; }

.sl-tbl thead th {
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #334155;
  background: #f8fafc;
  border-bottom: 2px solid var(--nc-line);
  padding: 11px 12px;
  white-space: nowrap;
}
.sl-tbl thead th a.sl-sort {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.sl-tbl thead th a.sl-sort:hover { color: var(--nc-primary); }
.sl-tbl tbody td { padding: 11px 12px; font-size: 13.5px; border-color: #f1f5f9; }
.sl-tbl td.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; font-weight: 600; }
.sl-tbl td.r, .sl-tbl th.r { text-align: right; font-variant-numeric: tabular-nums; }
.sl-tbl td.act, .sl-tbl th.act { white-space: nowrap; text-align: right; }
