/* ============================================================
   Admin Console — Variables & Dark Mode
   ============================================================ */
:root {
  /* Brand */
  --brand:        #2954e3;
  --brand-soft:   #3b6cf6;
  --brand-dark:   #1f43c4;
  --danger:       #dc2626;
  --success:      #059669;
  --warning:      #d97706;

  /* Admin theme — light */
  --admin-bg:        #f4f7fb;
  --admin-bg-2:      #eef4ff;
  --panel:           #ffffff;
  --panel-soft:      #f8fafc;
  --panel-overlay:   rgba(255, 255, 255, .92);
  --line:            #e2e8f0;
  --line-strong:     #cbd5e1;
  --text:            #0f172a;
  --muted:           #64748b;
  --muted-soft:      #94a3b8;
  --sidebar:         #0b1220;
  --sidebar-soft:    #111b2e;
  --sidebar-text:    #dbeafe;
  --sidebar-muted:   #93a4bd;
  --topbar-bg:       rgba(248, 251, 255, .82);
  --topbar-border:   rgba(226, 232, 240, .78);
  --tag-bg:          #eef2ff;
  --tag-fg:          #3730a3;
  --shadow:          0 16px 40px rgba(15, 23, 42, .08);
  --shadow-soft:     0 4px 14px rgba(15, 23, 42, .05);
}

.admin-body[data-theme="dark"] {
  --admin-bg:        #07101f;
  --admin-bg-2:      #0b1730;
  --panel:           #0f1a2d;
  --panel-soft:      #131f36;
  --panel-overlay:   rgba(15, 26, 45, .85);
  --line:            rgba(255, 255, 255, .08);
  --line-strong:     rgba(255, 255, 255, .14);
  --text:            #e2e8f0;
  --muted:           #94a3b8;
  --muted-soft:      #64748b;
  --sidebar:         #06091a;
  --sidebar-soft:    #0a1024;
  --sidebar-text:    #cbd5e1;
  --sidebar-muted:   #6b7a93;
  --topbar-bg:       rgba(7, 16, 31, .72);
  --topbar-border:   rgba(255, 255, 255, .06);
  --tag-bg:          rgba(99, 102, 241, .16);
  --tag-fg:          #a5b4fc;
  --shadow:          0 16px 40px rgba(0, 0, 0, .45);
  --shadow-soft:     0 4px 14px rgba(0, 0, 0, .35);
}
@media (prefers-color-scheme: dark) {
  .admin-body[data-theme="auto"] {
    --admin-bg:        #07101f;
    --admin-bg-2:      #0b1730;
    --panel:           #0f1a2d;
    --panel-soft:      #131f36;
    --panel-overlay:   rgba(15, 26, 45, .85);
    --line:            rgba(255, 255, 255, .08);
    --line-strong:     rgba(255, 255, 255, .14);
    --text:            #e2e8f0;
    --muted:           #94a3b8;
    --muted-soft:      #64748b;
    --sidebar:         #06091a;
    --sidebar-soft:    #0a1024;
    --sidebar-text:    #cbd5e1;
    --sidebar-muted:   #6b7a93;
    --topbar-bg:       rgba(7, 16, 31, .72);
    --topbar-border:   rgba(255, 255, 255, .06);
    --tag-bg:          rgba(99, 102, 241, .16);
    --tag-fg:          #a5b4fc;
    --shadow:          0 16px 40px rgba(0, 0, 0, .45);
    --shadow-soft:     0 4px 14px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

/* ============================================================
   Base
   ============================================================ */
.admin-body {
  min-height: 100vh;
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background:
    radial-gradient(circle at top left, rgba(59,108,246,.10), transparent 30rem),
    radial-gradient(circle at bottom right, rgba(167,139,250,.08), transparent 25rem),
    linear-gradient(180deg, var(--admin-bg-2) 0%, var(--admin-bg) 60%);
  color: var(--text);
}

/* ============================================================
   Layout
   ============================================================ */
.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar-toggle {
  display: none;
  position: fixed;
  top: .75rem;
  left: .75rem;
  z-index: 40;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: .75rem;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

/* ============================================================
   Sidebar
   ============================================================ */
.admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 1.25rem 1.1rem;
  background:
    linear-gradient(180deg, rgba(41, 84, 227, .22) 0%, transparent 30%),
    var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
  border-right: 1px solid rgba(255, 255, 255, .04);
}

.admin-sidebar::-webkit-scrollbar { width: 4px; }
.admin-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 4px; }

.brand-block,
.login-brand {
  display: flex;
  align-items: center;
  gap: .8rem;
  text-decoration: none;
  color: inherit;
  padding: .15rem 0;
}

.brand-mark {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: .85rem;
  background: linear-gradient(135deg, #60a5fa, #2954e3);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 28px rgba(41, 84, 227, .35), inset 0 1px 0 rgba(255,255,255,.3);
  flex-shrink: 0;
}

.brand-block strong,
.login-brand strong {
  display: block;
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.1;
  letter-spacing: -.01em;
}
.brand-block small,
.login-brand small {
  display: block;
  margin-top: .15rem;
  font-size: .72rem;
  color: var(--sidebar-muted);
  letter-spacing: .03em;
}

.side-section-label {
  margin: .5rem 0 -.25rem;
  padding: 0 .5rem;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  opacity: .7;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: .25rem;
}

.side-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-height: 2.65rem;
  padding: .6rem .75rem;
  border-radius: .75rem;
  color: #b6c4d8;
  text-decoration: none;
  font-size: .88rem;
  font-weight: 600;
  position: relative;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.side-link:hover {
  background: rgba(255, 255, 255, .06);
  color: #fff;
}
.side-link.is-active {
  background: rgba(255, 255, 255, .12);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
}
.side-link.is-active::before {
  content: "";
  position: absolute;
  left: -1.1rem;
  top: 50%;
  width: 3px;
  height: 1.4rem;
  background: linear-gradient(180deg, #60a5fa, #2954e3);
  border-radius: 0 4px 4px 0;
  transform: translateY(-50%);
}

.side-icon {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: .5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .05);
  color: inherit;
  flex-shrink: 0;
  transition: background .18s ease, color .18s ease;
}
.side-link.is-active .side-icon {
  background: linear-gradient(135deg, rgba(96, 165, 250, .25), rgba(41, 84, 227, .35));
  color: #93c5fd;
}

.side-note {
  margin-top: auto;
  display: flex;
  gap: .65rem;
  padding: .85rem;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: .9rem;
  background: rgba(255, 255, 255, .04);
}
.side-note strong {
  display: block;
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
}
.side-note p {
  margin: .2rem 0 0;
  color: var(--sidebar-muted);
  font-size: .72rem;
  line-height: 1.45;
}
.pulse-dot {
  width: .55rem;
  height: .55rem;
  margin-top: .35rem;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 0 rgba(52, 211, 153, .55);
  animation: pulse-ring 1.8s infinite;
  flex-shrink: 0;
}
@keyframes pulse-ring {
  70%  { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.side-user {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .65rem .75rem;
  border-radius: .85rem;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .06);
}
.side-user-avatar {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  background: linear-gradient(135deg, #60a5fa, #2954e3);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: .82rem;
  text-transform: uppercase;
  box-shadow: 0 6px 18px rgba(41, 84, 227, .35);
  flex-shrink: 0;
}
.side-user-info { min-width: 0; }
.side-user-info strong {
  display: block;
  color: #fff;
  font-size: .82rem;
  font-weight: 700;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
.side-user-info small {
  display: block;
  color: var(--sidebar-muted);
  font-size: .68rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* ============================================================
   Main + Top bar
   ============================================================ */
.admin-main { min-width: 0; }

.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 4.5rem;
  padding: .85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
          backdrop-filter: blur(18px) saturate(1.4);
}

.topbar-titles { min-width: 0; }
.eyebrow,
.panel-kicker {
  margin: 0 0 .18rem;
  color: var(--brand);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.admin-topbar h1 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -.01em;
  color: var(--text);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icon-btn {
  width: 2.35rem;
  height: 2.35rem;
  border-radius: .7rem;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
  box-shadow: var(--shadow-soft);
}
.icon-btn:hover { transform: translateY(-1px); background: var(--panel-soft); }
.icon-btn .theme-icon-moon { display: none; }
.admin-body[data-theme="dark"] .icon-btn .theme-icon-sun  { display: none; }
.admin-body[data-theme="dark"] .icon-btn .theme-icon-moon { display: inline-block; }
@media (prefers-color-scheme: dark) {
  .admin-body[data-theme="auto"] .icon-btn .theme-icon-sun  { display: none; }
  .admin-body[data-theme="auto"] .icon-btn .theme-icon-moon { display: inline-block; }
}

/* Save indicator */
.save-indicator {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .35rem .7rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  transition: all .2s ease;
}
.save-dot {
  width: .45rem;
  height: .45rem;
  border-radius: 50%;
  background: currentColor;
}
.save-indicator.save-idle    { color: var(--muted); }
.save-indicator.save-dirty   { color: var(--warning); background: #fffbeb; border-color: #fed7aa; }
.save-indicator.save-saving  { color: var(--brand); background: #eff6ff; border-color: #bfdbfe; }
.save-indicator.save-saved   { color: var(--success); background: #ecfdf5; border-color: #a7f3d0; }
.save-indicator.save-saving .save-dot { animation: pulse-fast .9s ease-in-out infinite; }
.admin-body[data-theme="dark"] .save-indicator.save-dirty  { background: rgba(217, 119, 6, .15); border-color: rgba(245, 158, 11, .3); }
.admin-body[data-theme="dark"] .save-indicator.save-saving { background: rgba(41, 84, 227, .15); border-color: rgba(96, 165, 250, .3); }
.admin-body[data-theme="dark"] .save-indicator.save-saved  { background: rgba(5, 150, 105, .15); border-color: rgba(52, 211, 153, .3); }
@media (prefers-color-scheme: dark) {
  .admin-body[data-theme="auto"] .save-indicator.save-dirty  { background: rgba(217, 119, 6, .15); border-color: rgba(245, 158, 11, .3); }
  .admin-body[data-theme="auto"] .save-indicator.save-saving { background: rgba(41, 84, 227, .15); border-color: rgba(96, 165, 250, .3); }
  .admin-body[data-theme="auto"] .save-indicator.save-saved  { background: rgba(5, 150, 105, .15); border-color: rgba(52, 211, 153, .3); }
}
@keyframes pulse-fast {
  0%, 100% { opacity: 1; }
  50%      { opacity: .35; }
}

/* ============================================================
   Buttons
   ============================================================ */
.admin-btn {
  min-height: 2.35rem;
  border-radius: .7rem;
  padding: .55rem .85rem;
  font-size: .82rem;
  font-weight: 700;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.admin-btn:hover:not(:disabled) { transform: translateY(-1px); }
.admin-btn:disabled { opacity: .65; cursor: not-allowed; transform: none; }

.admin-btn-ghost  { background: transparent; color: var(--muted); }
.admin-btn-ghost:hover { color: var(--text); background: rgba(15, 23, 42, .05); }
.admin-body[data-theme="dark"] .admin-btn-ghost:hover { background: rgba(255, 255, 255, .06); }

.admin-btn-light {
  background: var(--panel);
  color: var(--text);
  border-color: var(--line);
  box-shadow: var(--shadow-soft);
}
.admin-btn-light:hover { background: var(--panel-soft); border-color: var(--line-strong); }

.admin-btn-primary {
  background: linear-gradient(135deg, var(--brand-soft), var(--brand-dark));
  color: #fff;
  border-color: rgba(41, 84, 227, .35);
  box-shadow: 0 10px 24px rgba(41, 84, 227, .28), inset 0 1px 0 rgba(255,255,255,.2);
}
.admin-btn-primary:hover { box-shadow: 0 14px 28px rgba(41, 84, 227, .34); }

.admin-btn-danger {
  background: var(--panel);
  color: var(--danger);
  border-color: #fecaca;
}
.admin-btn-danger:hover { background: #fef2f2; }
.admin-body[data-theme="dark"] .admin-btn-danger { border-color: rgba(248, 113, 113, .25); }
.admin-body[data-theme="dark"] .admin-btn-danger:hover { background: rgba(220, 38, 38, .12); }

/* ============================================================
   Content + Loading
   ============================================================ */
.admin-content { padding: 1.5rem; }

/* Section navigation — hanya satu section visible pada satu waktu */
#admin-app > section { display: none; }
#admin-app > section.is-active-section { display: block; animation: section-fade .25s ease both; }
#admin-app > section.stats-grid.is-active-section { display: grid; }
@keyframes section-fade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.admin-state {
  padding: 1.5rem;
  border-radius: 1rem;
  border: 1px solid var(--line);
  background: var(--panel-overlay);
  color: var(--muted);
  font-size: .9rem;
  text-align: center;
}
.state-loader {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
}
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(41, 84, 227, .2);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ============================================================
   Stats Grid
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.stat-card {
  position: relative;
  overflow: hidden;
  padding: 1.1rem 1.15rem;
  border-radius: 1.1rem;
  border: 1px solid var(--line);
  background: var(--panel-overlay);
  box-shadow: var(--shadow);
  animation: card-in .45s ease both;
  transition: transform .2s ease, box-shadow .2s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 22px 50px rgba(15, 23, 42, .1); }
.stat-card::after {
  content: "";
  position: absolute;
  width: 9rem;
  height: 9rem;
  right: -3.5rem;
  top: -3.5rem;
  border-radius: 50%;
  background: rgba(41, 84, 227, .07);
}

.stat-primary {
  color: #fff;
  background: linear-gradient(135deg, #1e3a8a 0%, #2954e3 100%);
  border-color: rgba(41, 84, 227, .2);
}
.stat-primary::after { background: rgba(255, 255, 255, .12); }

.stat-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  position: relative;
  z-index: 1;
}
.stat-label {
  display: block;
  color: inherit;
  opacity: .72;
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.stat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: .55rem;
  background: rgba(41, 84, 227, .1);
  color: var(--brand);
}
.stat-primary .stat-icon { background: rgba(255, 255, 255, .15); color: #fff; }
.stat-card strong {
  display: block;
  position: relative;
  z-index: 1;
  margin-top: .6rem;
  font-size: 2.1rem;
  line-height: 1;
  font-weight: 800;
  color: inherit;
  letter-spacing: -.02em;
}
.stat-card small {
  display: block;
  position: relative;
  z-index: 1;
  margin-top: .55rem;
  color: inherit;
  opacity: .65;
  font-size: .76rem;
}

/* ============================================================
   Panels
   ============================================================ */
.admin-panel {
  padding: 1.4rem;
  border-radius: 1.1rem;
  border: 1px solid var(--line);
  background: var(--panel-overlay);
  box-shadow: var(--shadow);
}
.reveal-card { animation: card-in .45s ease both; }
@keyframes card-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.admin-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
}
.admin-panel-head h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -.01em;
  color: var(--text);
}
.admin-panel-head p {
  margin: .25rem 0 0;
  color: var(--muted);
  font-size: .83rem;
  line-height: 1.55;
  max-width: 38rem;
}

/* Pages section */
.pages-grid {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 1.25rem;
}

.admin-tabs {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.admin-tab {
  width: 100%;
  min-height: 4rem;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: .85rem;
  padding: .75rem .9rem;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease;
  font-family: inherit;
}
.admin-tab:hover { transform: translateX(2px); border-color: var(--line-strong); }
.admin-tab.is-active {
  border-color: rgba(41, 84, 227, .4);
  background: linear-gradient(135deg, rgba(96, 165, 250, .12), var(--panel));
  box-shadow: 0 10px 24px rgba(41, 84, 227, .1);
}
.admin-tab .title {
  display: block;
  color: var(--text);
  font-size: .9rem;
  font-weight: 800;
}
.admin-tab .meta {
  display: inline-flex;
  margin-top: .4rem;
  padding: .15rem .5rem;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: .68rem;
  font-weight: 700;
  border: 1px solid var(--line);
}

.admin-editor { min-width: 0; }
.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .85rem;
}

/* Default profile box */
.default-profile-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, .5fr);
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: .95rem;
  background: linear-gradient(135deg, rgba(96, 165, 250, .08), var(--panel));
}

/* Profile grid */
.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.profile-card,
.admin-feature {
  border: 1px solid var(--line);
  border-radius: .95rem;
  background: var(--panel-soft);
}

.profile-card { padding: 1.1rem; transition: border-color .16s ease, transform .16s ease; }
.profile-card:hover { border-color: var(--line-strong); }
.profile-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: 1rem;
}
.profile-title {
  color: var(--text);
  font-size: .95rem;
  font-weight: 800;
}
.profile-sub {
  display: inline-flex;
  margin-top: .3rem;
  padding: .18rem .55rem;
  border-radius: 999px;
  background: rgba(96, 165, 250, .15);
  color: var(--brand);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .02em;
}

.admin-feature {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .75rem;
  padding: .9rem;
  transition: border-color .16s ease, transform .16s ease;
}
.admin-feature:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.admin-feature + .admin-feature { margin-top: .65rem; }

.admin-switch {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 600;
  user-select: none;
  cursor: pointer;
}
.admin-switch input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--brand);
  cursor: pointer;
}

.key-list { margin-top: .35rem; }
.key-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .5rem;
  margin-top: .55rem;
}

/* ============================================================
   Table
   ============================================================ */
.table-wrap {
  border: 1px solid var(--line);
  border-radius: .9rem;
  overflow: hidden;
  background: var(--panel);
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}
.admin-table th,
.admin-table td {
  border-bottom: 1px solid var(--line);
  padding: .75rem;
  text-align: left;
  vertical-align: middle;
  color: var(--text);
}
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table tbody tr { transition: background .15s ease; }
.admin-table tbody tr:hover { background: var(--panel-soft); }
.admin-table tr.is-hidden-row { display: none; }
.admin-table th {
  color: var(--muted);
  background: var(--panel-soft);
  font-size: .68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  position: sticky;
  top: 0;
}
.admin-table code {
  padding: .22rem .5rem;
  border-radius: .45rem;
  background: var(--tag-bg);
  color: var(--tag-fg);
  font-size: .75rem;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

/* ============================================================
   JSON editor
   ============================================================ */
.admin-json {
  width: 100%;
  min-height: 300px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: .9rem;
  padding: 1rem;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: .78rem;
  line-height: 1.6;
  background: #0b1220;
  color: #dbeafe;
  resize: vertical;
}
.admin-json:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(41, 84, 227, .2);
}

/* ============================================================
   Field overrides (admin context)
   ============================================================ */
.admin-body .field-label { color: var(--text); font-weight: 600; font-size: .78rem; }
.admin-body .field-help  { color: var(--muted); font-size: .74rem; }
.admin-body .field-input,
.admin-body .field-textarea,
.admin-body select.field-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: .7rem;
  padding: .6rem .8rem;
  font-size: .88rem;
  font-family: inherit;
  background: var(--panel);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.admin-body .field-input::placeholder { color: var(--muted-soft); }
.admin-body .field-input:focus,
.admin-body .field-textarea:focus,
.admin-body select.field-input:focus,
.admin-body .admin-json:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(41, 84, 227, .18);
}
.admin-body .field-wrap { position: relative; display: flex; align-items: center; }
.admin-body .field-icon {
  position: absolute;
  left: .8rem;
  color: var(--muted);
  pointer-events: none;
  transition: color .15s ease;
}
.admin-body .field-input.has-icon { padding-left: 2.3rem; }
.admin-body .field-wrap:focus-within .field-icon { color: var(--brand); }

/* Helpers */
.space-y-5 > * + * { margin-top: 1.25rem; }
.space-y-6 > * + * { margin-top: 1.5rem; }
.flex { display: flex; }
.gap-2 { gap: .5rem; }
.hidden { display: none !important; }

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

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1100px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    max-width: 84vw;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
  }
  .admin-sidebar.is-open { transform: translateX(0); }
  .sidebar-toggle { display: inline-flex; }
  .admin-topbar { padding-left: 3.6rem; }
  .pages-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .admin-topbar,
  .admin-panel-head,
  .profile-head {
    flex-direction: column;
    align-items: stretch;
  }
  .admin-content { padding: 1rem; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-grid,
  .admin-grid,
  .default-profile-box {
    grid-template-columns: 1fr;
  }
  .top-actions { justify-content: flex-start; }
  .save-indicator { order: -1; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .admin-panel { padding: 1rem; }
  .admin-topbar h1 { font-size: 1.15rem; }
}

/* ============================================================
   Login Modern — Aurora background, glass card, dark mode auto
   ============================================================ */
:root {
  --login-bg:          #f4f7fb;
  --login-bg-2:        #eaf1ff;
  --login-text:        #0f172a;
  --login-muted:       #64748b;
  --login-card:        rgba(255, 255, 255, .78);
  --login-card-border: rgba(255, 255, 255, .9);
  --login-card-shadow: 0 30px 80px rgba(15, 23, 42, .12), 0 2px 8px rgba(15, 23, 42, .04);
  --login-visual-bg:   linear-gradient(135deg, #0b1220 0%, #1a2a5e 55%, #2954e3 120%);
  --login-visual-text: rgba(255,255,255,.92);
  --login-visual-muted:rgba(226,232,240,.7);
  --login-input-bg:    #fff;
  --login-input-border:#e2e8f0;
  --login-input-focus: rgba(41, 84, 227, .35);
  --login-grid:        rgba(15, 23, 42, .045);
  --login-blob-1:      rgba(96, 165, 250, .55);
  --login-blob-2:      rgba(167, 139, 250, .42);
  --login-blob-3:      rgba(16, 185, 129, .35);
  --login-error-bg:    #fef2f2;
  --login-error-fg:    #b91c1c;
  --login-error-bd:    #fecaca;
}

.login-body[data-theme="dark"] {
  --login-bg:          #07101f;
  --login-bg-2:        #0b1730;
  --login-text:        #e2e8f0;
  --login-muted:       #94a3b8;
  --login-card:        rgba(15, 23, 42, .68);
  --login-card-border: rgba(255, 255, 255, .08);
  --login-card-shadow: 0 30px 80px rgba(0, 0, 0, .55), 0 2px 8px rgba(0,0,0,.3);
  --login-input-bg:    rgba(15, 23, 42, .55);
  --login-input-border:rgba(255, 255, 255, .12);
  --login-input-focus: rgba(96, 165, 250, .55);
  --login-grid:        rgba(255, 255, 255, .035);
  --login-blob-1:      rgba(59, 130, 246, .45);
  --login-blob-2:      rgba(139, 92, 246, .38);
  --login-blob-3:      rgba(14, 165, 233, .35);
  --login-error-bg:    rgba(220, 38, 38, .12);
  --login-error-fg:    #fca5a5;
  --login-error-bd:    rgba(248, 113, 113, .25);
}
@media (prefers-color-scheme: dark) {
  .login-body[data-theme="auto"] {
    --login-bg:          #07101f;
    --login-bg-2:        #0b1730;
    --login-text:        #e2e8f0;
    --login-muted:       #94a3b8;
    --login-card:        rgba(15, 23, 42, .68);
    --login-card-border: rgba(255, 255, 255, .08);
    --login-card-shadow: 0 30px 80px rgba(0, 0, 0, .55), 0 2px 8px rgba(0,0,0,.3);
    --login-input-bg:    rgba(15, 23, 42, .55);
    --login-input-border:rgba(255, 255, 255, .12);
    --login-input-focus: rgba(96, 165, 250, .55);
    --login-grid:        rgba(255, 255, 255, .035);
    --login-blob-1:      rgba(59, 130, 246, .45);
    --login-blob-2:      rgba(139, 92, 246, .38);
    --login-blob-3:      rgba(14, 165, 233, .35);
    --login-error-bg:    rgba(220, 38, 38, .12);
    --login-error-fg:    #fca5a5;
    --login-error-bd:    rgba(248, 113, 113, .25);
  }
}

.login-body {
  min-height: 100vh;
  margin: 0;
  color: var(--login-text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background:
    radial-gradient(120% 80% at 50% 0%, var(--login-bg-2), transparent 70%),
    var(--login-bg);
  position: relative;
  overflow-x: hidden;
}

.aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.aurora-blob {
  position: absolute;
  filter: blur(80px);
  border-radius: 50%;
  opacity: .9;
  animation: aurora-float 22s ease-in-out infinite alternate;
  will-change: transform;
}
.aurora-1 { width: 36rem; height: 36rem; left: -8rem;  top: -10rem; background: var(--login-blob-1); }
.aurora-2 { width: 30rem; height: 30rem; right: -6rem; top: 10rem;  background: var(--login-blob-2); animation-delay: -6s; }
.aurora-3 { width: 28rem; height: 28rem; left: 35%;    bottom: -12rem; background: var(--login-blob-3); animation-delay: -12s; }
.aurora-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--login-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--login-grid) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
          mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
}
@keyframes aurora-float {
  0%   { transform: translate3d(0,0,0) scale(1); }
  50%  { transform: translate3d(2rem, -1.5rem, 0) scale(1.08); }
  100% { transform: translate3d(-1.5rem, 2rem, 0) scale(.95); }
}

.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 10;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  border: 1px solid var(--login-card-border);
  background: var(--login-card);
  color: var(--login-text);
  -webkit-backdrop-filter: blur(14px);
          backdrop-filter: blur(14px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
  box-shadow: 0 8px 22px rgba(15, 23, 42, .1);
}
.theme-toggle:hover { transform: translateY(-1px) scale(1.04); }
.theme-toggle .theme-icon-moon { display: none; }
.login-body[data-theme="dark"] .theme-toggle .theme-icon-sun  { display: none; }
.login-body[data-theme="dark"] .theme-toggle .theme-icon-moon { display: inline-block; }
@media (prefers-color-scheme: dark) {
  .login-body[data-theme="auto"] .theme-toggle .theme-icon-sun  { display: none; }
  .login-body[data-theme="auto"] .theme-toggle .theme-icon-moon { display: inline-block; }
}

.login-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(380px, 460px);
  gap: 2rem;
  align-items: stretch;
  max-width: 1220px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

.login-visual {
  position: relative;
  padding: 2.25rem;
  border-radius: 1.5rem;
  color: var(--login-visual-text);
  background: var(--login-visual-bg);
  box-shadow: 0 32px 80px rgba(11, 18, 32, .28);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 2.5rem;
  overflow: hidden;
  isolation: isolate;
}
.login-visual::before,
.login-visual::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  z-index: -1;
}
.login-visual::before {
  width: 32rem; height: 32rem;
  right: -14rem; top: -10rem;
  background: radial-gradient(circle, rgba(96, 165, 250, .35) 0%, transparent 70%);
}
.login-visual::after {
  width: 22rem; height: 22rem;
  left: -8rem; bottom: -8rem;
  background: radial-gradient(circle, rgba(167, 139, 250, .32) 0%, transparent 70%);
}

.login-brand .brand-mark {
  width: 2.85rem;
  height: 2.85rem;
  border-radius: .9rem;
  background: linear-gradient(135deg, #60a5fa 0%, #2954e3 100%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 14px 32px rgba(41, 84, 227, .42), inset 0 1px 0 rgba(255,255,255,.4);
}
.login-brand .brand-text strong {
  display: block;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -.01em;
  color: #fff;
}
.login-brand .brand-text small {
  display: block;
  margin-top: .15rem;
  font-size: .78rem;
  color: var(--login-visual-muted);
  letter-spacing: .04em;
}

.login-copy { animation: card-in .6s ease both; max-width: 32rem; }
.eyebrow-dot {
  width: .45rem;
  height: .45rem;
  border-radius: 50%;
  background: #60a5fa;
  box-shadow: 0 0 0 4px rgba(96, 165, 250, .25);
  animation: pulse-dot 2.4s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 4px rgba(96, 165, 250, .25); }
  50%      { box-shadow: 0 0 0 8px rgba(96, 165, 250, .05); }
}
.login-body .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  margin: 0 0 1rem;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #93c5fd;
}
.login-copy h1 {
  margin: 0;
  font-size: clamp(2rem, 3.6vw, 3rem);
  line-height: 1.1;
  letter-spacing: -.02em;
  font-weight: 800;
  color: #fff;
}
.login-copy .lead {
  margin: 1.1rem 0 0;
  max-width: 36rem;
  color: var(--login-visual-muted);
  line-height: 1.7;
  font-size: .96rem;
}
.login-points {
  list-style: none;
  margin: 1.6rem 0 0;
  padding: 0;
  display: grid;
  gap: .65rem;
}
.login-points li {
  display: flex;
  align-items: center;
  gap: .6rem;
  color: rgba(255,255,255,.85);
  font-size: .9rem;
}
.login-points li svg {
  flex-shrink: 0;
  color: #6ee7b7;
  padding: .3rem;
  background: rgba(110, 231, 183, .14);
  border-radius: 999px;
  box-sizing: content-box;
}

.login-foot {
  display: flex;
  align-items: center;
  gap: .65rem;
  color: rgba(226, 232, 240, .55);
  font-size: .78rem;
}
.login-foot .dot {
  width: 3px; height: 3px; border-radius: 50%;
  background: rgba(226, 232, 240, .35);
}

.login-card {
  align-self: center;
  padding: 2rem;
  border-radius: 1.5rem;
  background: var(--login-card);
  border: 1px solid var(--login-card-border);
  box-shadow: var(--login-card-shadow);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
          backdrop-filter: blur(18px) saturate(1.4);
  animation: card-in .6s .05s ease both;
}
.login-card-head { margin-bottom: 1.5rem; }
.login-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .3rem .65rem;
  border-radius: 999px;
  background: rgba(41, 84, 227, .1);
  color: var(--brand);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.login-card h2 {
  margin: .85rem 0 .25rem;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -.015em;
  color: var(--login-text);
}
.login-card p {
  margin: 0;
  color: var(--login-muted);
  font-size: .92rem;
  line-height: 1.55;
}

.login-form { display: grid; gap: 1.05rem; }
.field-group { display: grid; gap: .4rem; }
.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.login-body .field-label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--login-text);
  letter-spacing: .01em;
}
.login-body .field-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.login-body .field-icon {
  position: absolute;
  left: .85rem;
  display: inline-flex;
  color: var(--login-muted);
  pointer-events: none;
  transition: color .2s ease;
}
.login-body .field-input { padding: .8rem 1rem; border-radius: .85rem; border-color: var(--login-input-border); background: var(--login-input-bg); color: var(--login-text); }
.login-body .field-input::placeholder { color: var(--login-muted); opacity: .65; }
.login-body .field-input.has-icon { padding-left: 2.5rem; }
.login-body .field-input.has-action { padding-right: 2.65rem; }
.login-body .field-input:focus,
.login-body .field-input:focus-visible {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--login-input-focus);
  background: var(--login-input-bg);
}
.login-body .field-input:focus + .field-icon,
.login-body .field-wrap:focus-within .field-icon { color: var(--brand); }

.field-action {
  position: absolute;
  right: .55rem;
  width: 2rem;
  height: 2rem;
  border-radius: .55rem;
  border: 0;
  background: transparent;
  color: var(--login-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}
.field-action:hover {
  background: rgba(15, 23, 42, .06);
  color: var(--login-text);
}
.login-body[data-theme="dark"] .field-action:hover { background: rgba(255, 255, 255, .08); }
@media (prefers-color-scheme: dark) {
  .login-body[data-theme="auto"] .field-action:hover { background: rgba(255, 255, 255, .08); }
}

.caps-warn {
  font-size: .7rem;
  font-weight: 600;
  color: #b45309;
  background: #fef3c7;
  padding: .15rem .5rem;
  border-radius: 999px;
  border: 1px solid #fde68a;
}

.form-error {
  padding: .7rem .85rem;
  border-radius: .8rem;
  background: var(--login-error-bg);
  color: var(--login-error-fg);
  border: 1px solid var(--login-error-bd);
  font-size: .85rem;
  line-height: 1.45;
  animation: shake .35s ease;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-4px); }
  40%      { transform: translateX(4px); }
  60%      { transform: translateX(-2px); }
  80%      { transform: translateX(2px); }
}

.login-submit {
  margin-top: .25rem;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .85rem 1.2rem;
  border-radius: .85rem;
  font-weight: 700;
  font-size: .95rem;
  background: linear-gradient(135deg, var(--brand) 0%, #1e40af 100%);
  color: #fff;
  border: 0;
  cursor: pointer;
  box-shadow: 0 14px 30px rgba(41, 84, 227, .35), inset 0 1px 0 rgba(255,255,255,.18);
  transition: transform .15s ease, box-shadow .2s ease, opacity .2s ease;
}
.login-submit:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 18px 38px rgba(41, 84, 227, .42), inset 0 1px 0 rgba(255,255,255,.22);
}
.login-submit:active:not(:disabled) { transform: translateY(0); }
.login-submit:disabled { opacity: .7; cursor: progress; }
.login-submit .btn-arrow { transition: transform .2s ease; }
.login-submit:hover:not(:disabled) .btn-arrow { transform: translateX(2px); }
.login-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.login-submit.is-loading .btn-arrow { display: none; }

.login-hint {
  margin-top: 1.25rem;
  padding: .85rem .95rem;
  border-radius: .85rem;
  background: rgba(148, 163, 184, .12);
  color: var(--login-muted);
  font-size: .8rem;
  line-height: 1.55;
  border: 1px solid rgba(148, 163, 184, .15);
}

.login-back { margin-top: 1rem; text-align: center; }
.back-link {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  color: var(--login-muted);
  font-size: .82rem;
  text-decoration: none;
  padding: .4rem .65rem;
  border-radius: .55rem;
  transition: color .2s ease, background .2s ease;
}
.back-link:hover {
  color: var(--brand);
  background: rgba(41, 84, 227, .06);
}

.login-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 60;
  padding: .75rem 1rem;
  border-radius: .85rem;
  background: #0f172a;
  color: #f1f5f9;
  font-size: .85rem;
  box-shadow: 0 18px 40px rgba(15, 23, 42, .35);
  max-width: 22rem;
}

@media (max-width: 960px) {
  .login-shell {
    grid-template-columns: 1fr;
    padding: 1.5rem 1rem;
    gap: 1.25rem;
  }
  .login-visual { padding: 1.75rem; gap: 1.75rem; }
  .login-copy h1 { font-size: clamp(1.7rem, 6vw, 2.4rem); }
  .login-points { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 820px) {
  .login-card { padding: 1.5rem; }
  .login-points { grid-template-columns: 1fr; }
  .aurora-grid { background-size: 32px 32px; }
}

@media (max-width: 480px) {
  .login-shell { padding: 1rem .85rem; }
  .login-visual { padding: 1.4rem; border-radius: 1.25rem; }
  .login-card { padding: 1.25rem; border-radius: 1.25rem; }
  .theme-toggle { top: .6rem; right: .6rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
