/* =========================================================
   DeBuenaFe Social — Premium Design System
   Dark mode • Glassmorphism • Micro-animations
   ========================================================= */

/* ---------- Google Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---------- CSS Custom Properties ---------- */
:root {
  /* Core palette */
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-card-solid: #1a2236;
  --bg-elevated: rgba(30, 41, 69, 0.5);
  --bg-input: rgba(15, 23, 42, 0.8);

  /* Borders */
  --border-subtle: rgba(148, 163, 184, 0.1);
  --border-medium: rgba(148, 163, 184, 0.15);
  --border-focus: rgba(124, 58, 237, 0.5);

  /* Text */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0f172a;

  /* Accent — Violet */
  --accent: #7c3aed;
  --accent-light: #a78bfa;
  --accent-glow: rgba(124, 58, 237, 0.25);
  --gradient-accent: linear-gradient(135deg, #7c3aed, #a855f7);

  /* Accent — Teal */
  --teal: #14b8a6;
  --teal-light: #5eead4;
  --teal-glow: rgba(20, 184, 166, 0.2);

  /* Status Colors */
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.12);
  --success-border: rgba(34, 197, 94, 0.3);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --warning-border: rgba(245, 158, 11, 0.3);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.12);
  --error-border: rgba(239, 68, 68, 0.3);

  /* Glass */
  --glass-bg: rgba(15, 23, 42, 0.6);
  --glass-border: rgba(148, 163, 184, 0.08);
  --glass-blur: 20px;

  /* Sizing */
  --sidebar-width: 260px;
  --header-height: 64px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 30px var(--accent-glow);

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;
}

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

html {
  font-size: 15px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--accent-light);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}
a:hover { color: #c4b5fd; }

img { max-width: 100%; height: auto; }

::selection {
  background: var(--accent);
  color: white;
}

/* ---------- Layout Shell ---------- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--duration-normal) var(--ease-out);
}

.sidebar-brand {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-brand .brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--gradient-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.sidebar-brand h1 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}
.sidebar-brand small {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
  display: block;
  -webkit-text-fill-color: var(--text-muted);
}

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

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 1rem 0.75rem 0.4rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--duration-fast) var(--ease-out);
  position: relative;
}
.nav-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity var(--duration-fast);
}
.nav-link:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}
.nav-link:hover svg { opacity: 1; }

.nav-link.active {
  background: var(--accent-glow);
  color: var(--accent-light);
}
.nav-link.active svg { opacity: 1; }
.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

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

.sidebar-footer .user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--gradient-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}

.user-info span {
  font-size: 0.8rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: transparent;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--duration-fast);
  font-family: inherit;
}
.btn-logout:hover {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--error);
}

/* Mobile toggle */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 110;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-card-solid);
  border: 1px solid var(--border-medium);
  color: var(--text-primary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

/* ---------- Main Content ---------- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  padding: 2rem 2.5rem;
  max-width: 100%;
}

/* ---------- Page Header ---------- */
.page-header {
  margin-bottom: 2rem;
}
.page-header h2 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}
.page-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ---------- Cards ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  transition: all var(--duration-normal) var(--ease-out);
}
.card:hover {
  border-color: var(--border-medium);
  box-shadow: var(--shadow-md);
}

/* ---------- Stat Cards ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  transition: all var(--duration-normal) var(--ease-out);
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.15;
  pointer-events: none;
}
.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-medium);
  box-shadow: var(--shadow-md);
}

.stat-card .stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
  font-size: 1.1rem;
}

.stat-card .stat-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}

/* Stat card color variants */
.stat-card.purple .stat-icon { background: var(--accent-glow); color: var(--accent-light); }
.stat-card.purple .stat-value { color: var(--accent-light); }
.stat-card.purple::after { background: var(--accent); }

.stat-card.teal .stat-icon { background: var(--teal-glow); color: var(--teal-light); }
.stat-card.teal .stat-value { color: var(--teal-light); }
.stat-card.teal::after { background: var(--teal); }

.stat-card.blue .stat-icon { background: rgba(59,130,246,0.15); color: #93bbfd; }
.stat-card.blue .stat-value { color: #93bbfd; }
.stat-card.blue::after { background: #3b82f6; }

.stat-card.pink .stat-icon { background: rgba(236,72,153,0.15); color: #f9a8d4; }
.stat-card.pink .stat-value { color: #f9a8d4; }
.stat-card.pink::after { background: #ec4899; }

.stat-card.amber .stat-icon { background: rgba(245,158,11,0.15); color: #fcd34d; }
.stat-card.amber .stat-value { color: #fcd34d; }
.stat-card.amber::after { background: #f59e0b; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--duration-fast) var(--ease-out);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}
.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: var(--gradient-accent);
  color: white;
  box-shadow: 0 2px 12px var(--accent-glow);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow);
  color: white;
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
}
.btn-secondary:hover {
  background: rgba(30, 41, 69, 0.8);
  border-color: var(--border-focus);
  color: var(--text-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}
.btn-ghost:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid var(--error-border);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

.btn-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.btn-lg {
  padding: 0.75rem 1.75rem;
  font-size: 0.95rem;
  border-radius: var(--radius-md);
}

.btn-sm {
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
}

/* ---------- Forms ---------- */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.form-input,
.form-select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.9rem;
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  transition: all var(--duration-fast) var(--ease-out);
  outline: none;
}
.form-input:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-input::placeholder,
input::placeholder { color: var(--text-muted); }

.input-group {
  display: flex;
  gap: 0;
}
.input-group .form-input,
.input-group input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  flex: 1;
}
.input-group .btn {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  flex-shrink: 0;
}

label:has(input[type="checkbox"]) {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  margin-right: 1rem;
  margin-bottom: 0.25rem;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

fieldset {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1rem;
}
legend {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0 0.5rem;
}

/* ---------- Tables ---------- */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  backdrop-filter: blur(var(--glass-blur));
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
}
.table-header h3 {
  font-size: 1rem;
  font-weight: 600;
}
.table-header small {
  color: var(--text-muted);
  font-size: 0.8rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}
thead th {
  padding: 0.75rem 1rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.3);
}
tbody td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}
tbody tr {
  transition: background var(--duration-fast);
}
tbody tr:hover {
  background: rgba(124, 58, 237, 0.04);
}
tbody tr:last-child td {
  border-bottom: none;
}
td a {
  font-weight: 500;
}

/* ---------- Badges / Chips ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.badge-wp {
  background: rgba(59, 130, 246, 0.15);
  color: #93bbfd;
}
.badge-url {
  background: var(--warning-bg);
  color: var(--warning);
}

/* Status indicators */
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 500;
}
.status-dot::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.status-dot.ok::before { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.ok { color: var(--success); }
.status-dot.fail::before { background: var(--text-muted); }
.status-dot.fail { color: var(--text-muted); }
.status-dot.error::before { background: var(--error); box-shadow: 0 0 6px var(--error); }
.status-dot.error { color: var(--error); }
.status-dot.partial::before { background: var(--warning); box-shadow: 0 0 6px var(--warning); }
.status-dot.partial { color: var(--warning); }

/* Legacy compat */
.ok { color: var(--success); font-weight: 600; }
.fail { color: var(--text-muted); }
.error { color: var(--error); }

/* ---------- Filter Bar ---------- */
.filter-bar {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.filter-btn {
  padding: 0.4rem 1rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-medium);
  background: transparent;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}
.filter-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-focus);
}
.filter-btn.active {
  background: var(--accent-glow);
  color: var(--accent-light);
  border-color: var(--accent);
}

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 1rem 1.25rem;
  font-size: 0.85rem;
  border-top: 1px solid var(--border-subtle);
}
.pagination a {
  font-weight: 600;
  color: var(--accent-light);
}
.pagination a:hover { color: #c4b5fd; }
.pagination .disabled {
  color: var(--text-muted);
}
.pagination span {
  color: var(--text-secondary);
}

/* ---------- Notices ---------- */
.notice {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}
.notice.success {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success-border);
}
.notice.error {
  background: var(--error-bg);
  color: var(--error);
  border-color: var(--error-border);
}

/* ---------- Platform Cards ---------- */
.platforms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.platform-card {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  backdrop-filter: blur(var(--glass-blur));
  transition: all var(--duration-normal) var(--ease-out);
}
.platform-card:hover {
  border-color: var(--border-medium);
}

.platform-card.success {
  border-color: var(--success-border);
  background: linear-gradient(135deg, var(--success-bg), transparent);
}
.platform-card.error-card {
  border-color: var(--error-border);
  background: linear-gradient(135deg, var(--error-bg), transparent);
}

.platform-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.platform-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
}

.platform-name svg {
  width: 20px;
  height: 20px;
}

.copy-text {
  white-space: pre-wrap;
  word-wrap: break-word;
  background: var(--bg-input);
  color: var(--text-secondary);
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  line-height: 1.5;
  margin-top: 0.5rem;
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
}

/* ---------- Log Terminal ---------- */
#log-output {
  background: #0c0c14;
  color: #4ade80;
  padding: 1.25rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  line-height: 1.7;
  border-radius: var(--radius-md);
  max-height: 72vh;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
}

.terminal-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.terminal-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: rgba(15, 23, 42, 0.5);
  border-bottom: 1px solid var(--border-subtle);
}
.terminal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.terminal-dot.red { background: #ef4444; }
.terminal-dot.yellow { background: #f59e0b; }
.terminal-dot.green { background: #22c55e; }

.terminal-title {
  flex: 1;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.terminal-wrapper #log-output {
  border: none;
  border-radius: 0;
}

/* ---------- HTMX Loading ---------- */
.htmx-indicator {
  display: none;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: block;
}

.loading-skeleton {
  background: linear-gradient(90deg, var(--bg-card-solid) 25%, var(--bg-elevated) 50%, var(--bg-card-solid) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s infinite;
  border-radius: var(--radius-sm);
  height: 1rem;
  margin-bottom: 0.5rem;
}

@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

[aria-busy="true"] {
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

[aria-busy="true"]::before {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-medium);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ---------- Login Page ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-glow), transparent 70%);
  top: -200px;
  right: -200px;
  pointer-events: none;
}
.login-page::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--teal-glow), transparent 70%);
  bottom: -150px;
  left: -100px;
  pointer-events: none;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 2.5rem 2rem;
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
  animation: fadeInUp 0.5s var(--ease-out);
}

.login-card .brand {
  text-align: center;
  margin-bottom: 2rem;
}
.login-card .brand-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  background: var(--gradient-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin: 0 auto 1rem;
}
.login-card .brand h2 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}
.login-card .brand p {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.login-card .form-group {
  margin-bottom: 1.25rem;
}

.login-card button[type="submit"] {
  width: 100%;
  padding: 0.75rem;
  background: var(--gradient-accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  box-shadow: 0 2px 12px var(--accent-glow);
}
.login-card button[type="submit"]:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 24px var(--accent-glow);
}

.login-error {
  background: var(--error-bg);
  color: var(--error);
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--error-border);
  margin-bottom: 1rem;
  font-size: 0.85rem;
  text-align: center;
}

/* ---------- Config Table ---------- */
.config-table code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  background: var(--bg-input);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  color: var(--accent-light);
}

/* ---------- Section Divider ---------- */
.section-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
}
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}
.section-divider h3,
.section-divider h4 {
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- Action Bar ---------- */
.action-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state svg {
  width: 48px;
  height: 48px;
  opacity: 0.3;
  margin-bottom: 1rem;
}
.empty-state p {
  font-size: 0.9rem;
}

/* ---------- Detail Page ---------- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}
.breadcrumb a { color: var(--accent-light); }
.breadcrumb svg { width: 14px; height: 14px; }

.post-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}
.post-meta small {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.detail-image {
  border-radius: var(--radius-md);
  max-height: 280px;
  object-fit: cover;
  border: 1px solid var(--border-subtle);
  margin-top: 0.75rem;
}

/* ---------- Animations ---------- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.animate-in {
  animation: fadeInUp 0.4s var(--ease-out) both;
}

.stats-grid .stat-card:nth-child(1) { animation: fadeInUp 0.4s var(--ease-out) 0.05s both; }
.stats-grid .stat-card:nth-child(2) { animation: fadeInUp 0.4s var(--ease-out) 0.1s both; }
.stats-grid .stat-card:nth-child(3) { animation: fadeInUp 0.4s var(--ease-out) 0.15s both; }
.stats-grid .stat-card:nth-child(4) { animation: fadeInUp 0.4s var(--ease-out) 0.2s both; }
.stats-grid .stat-card:nth-child(5) { animation: fadeInUp 0.4s var(--ease-out) 0.25s both; }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-toggle {
    display: flex;
  }
  .sidebar-overlay.active {
    display: block;
  }
  .main-content {
    margin-left: 0;
    padding: 1.25rem;
    padding-top: 4.5rem;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .platforms-grid {
    grid-template-columns: 1fr;
  }
  .page-header h2 {
    font-size: 1.35rem;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .filter-bar {
    gap: 0.3rem;
  }
  .filter-btn {
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
  }
}

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

/* ---------- PicoCSS Override & Compat ---------- */
/* Remove any Pico defaults that might leak through */
article {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1rem;
  backdrop-filter: blur(var(--glass-blur));
}
article header {
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}
article footer {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.85rem;
}

figure {
  margin: 0;
  overflow-x: auto;
}

details {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 0.75rem;
}
summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
  padding: 0.25rem 0;
}
summary:hover { color: var(--text-primary); }

hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 1rem 0;
}

code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  background: var(--bg-input);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  color: var(--accent-light);
}

pre {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 1rem;
  overflow-x: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* Contrast button compat (used in HTMX responses) */
button.outline.contrast,
.btn-outline-contrast {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent-light);
  padding: 0.4rem 1rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast);
}
button.outline.contrast:hover {
  background: var(--accent-glow);
}

/* Contrast button for publish */
button.contrast {
  background: var(--gradient-accent);
  color: white;
  border: none;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast);
  box-shadow: 0 2px 12px var(--accent-glow);
}
button.contrast:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow);
}

/* Default button style */
button[type="submit"]:not(.btn):not(.contrast):not(.outline):not(.btn-logout):not(.sidebar-toggle) {
  background: var(--gradient-accent);
  color: white;
  border: none;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast);
  box-shadow: 0 2px 12px var(--accent-glow);
}
button[type="submit"]:not(.btn):not(.contrast):not(.outline):not(.btn-logout):not(.sidebar-toggle):hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow);
}

/* fieldset role=group override */
fieldset[role="group"] {
  display: flex;
  gap: 0;
  border: none;
  padding: 0;
  margin: 0;
}
fieldset[role="group"] input {
  flex: 1;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
fieldset[role="group"] button {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  flex-shrink: 0;
}
