/* Premium Theme Variables */
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --primary-10: rgba(99,102,241,.10);
  --secondary: #ec4899;
  --accent: #10b981;
  --bg: #ffffff;
  --bg-secondary: #f8fafc;
  --text: #0f172a;
  --text-muted: #64748b;
  --subtext: #94a3b8;
  --card: rgba(255,255,255,0.9);
  --border: rgba(148,163,184,0.2);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
  --glass: rgba(255,255,255,0.7);
  --glass-border: rgba(255,255,255,0.18);
  --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --gradient-3: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --gradient-4: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --bg-gradient: 
    radial-gradient(circle at 10% 20%, rgba(99,102,241,0.05) 0%, transparent 20%),
    radial-gradient(circle at 80% 80%, rgba(236,72,153,0.05) 0%, transparent 50%),
    radial-gradient(circle at 40% 40%, rgba(16,185,129,0.05) 0%, transparent 50%),
    linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

body.theme-dark {
  --primary: #818cf8;
  --primary-dark: #6366f1;
  --primary-light: #a5b4fc;
  --primary-10: rgba(129,140,248,.15);
  --secondary: #f472b6;
  --accent: #34d399;
  --bg: #0f172a;
  --bg-secondary: #1e293b;
  --text: #f1f5f9;
  --text-muted: #cbd5e1;
  --subtext: #94a3b8;
  --card: rgba(30,41,59,0.8);
  --border: rgba(71,85,105,0.3);
  --glass: rgba(15,23,42,0.6);
  --glass-border: rgba(148,163,184,0.1);
  --bg-gradient:
    radial-gradient(circle at 10% 20%, rgba(129,140,248,0.1) 0%, transparent 20%),
    radial-gradient(circle at 80% 80%, rgba(244,114,182,0.1) 0%, transparent 50%),
    radial-gradient(circle at 40% 40%, rgba(52,211,153,0.1) 0%, transparent 50%),
    linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
}

* { 
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body { 
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  position: relative;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Premium Scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 5px;
  transition: background 0.3s;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-dark);
}

/* Selection Color */
::selection {
  background: var(--primary);
  color: white;
}

/* Animated Background Orbs */
.bg-animation {
  position: fixed;
  width: 100%;
  height: 100vh;
  top: 0;
  left: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.bg-animation span {
  position: absolute;
  display: block;
  width: 20px;
  height: 20px;
  background: rgba(99,102,241,0.1);
  animation: float-up 25s infinite;
  bottom: 0;
}

.bg-animation span:nth-child(1) {
  left: 10%;
  width: 80px;
  height: 80px;
  animation-delay: 0;
  background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(236,72,153,0.1));
}

.bg-animation span:nth-child(2) {
  left: 20%;
  width: 20px;
  height: 20px;
  animation-delay: 2s;
  animation-duration: 12s;
  background: rgba(16,185,129,0.1);
}

.bg-animation span:nth-child(3) {
  left: 35%;
  width: 60px;
  height: 60px;
  animation-delay: 4s;
  background: linear-gradient(135deg, rgba(236,72,153,0.1), rgba(16,185,129,0.1));
}

.bg-animation span:nth-child(4) {
  left: 50%;
  width: 40px;
  height: 40px;
  animation-delay: 0s;
  animation-duration: 18s;
  background: rgba(99,102,241,0.1);
}

.bg-animation span:nth-child(5) {
  left: 70%;
  width: 100px;
  height: 100px;
  animation-delay: 3s;
  background: linear-gradient(135deg, rgba(16,185,129,0.1), rgba(99,102,241,0.1));
}

.bg-animation span:nth-child(6) {
  left: 85%;
  width: 30px;
  height: 30px;
  animation-delay: 6s;
  animation-duration: 20s;
  background: rgba(236,72,153,0.1);
}

@keyframes float-up {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
    border-radius: 0;
  }
  100% {
    transform: translateY(-1000px) rotate(720deg);
    opacity: 0;
    border-radius: 50%;
  }
}

/* Layout */
.wrapper { 
  margin-left: 280px;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow-x: hidden;
  background: var(--bg-gradient);
  position: relative;
  transition: margin-left 0.3s ease;
}

/* Notification Badge */
.notification-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  font-size: 10px;
  font-weight: bold;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

/* User Menu Dropdown */
.user-menu {
  position: relative;
}

.user-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 12px;
  min-width: 200px;
  background: var(--card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  box-shadow: var(--shadow-xl);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
}

.user-menu:hover .user-dropdown,
.user-dropdown:hover {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.user-info {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-name {
  font-weight: 600;
  color: var(--text);
}

.user-role {
  font-size: 12px;
  color: var(--subtext);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition);
}

.dropdown-item:hover {
  background: var(--primary-10);
  color: var(--primary);
}

.dropdown-item.text-danger {
  color: #ef4444;
}

.dropdown-item.text-danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

/* Brand Text */
.brand-text {
  display: flex;
  flex-direction: column;
  margin-left: 12px;
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--subtext);
  opacity: 0.8;
}

/* Premium Sidebar */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 280px;
  background: var(--glass);
  backdrop-filter: blur(10px) saturate(180%);
  -webkit-backdrop-filter: blur(10px) saturate(180%);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.theme-dark .sidebar {
  background: var(--glass);
}

.brand {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  position: relative;
  overflow: hidden;
}

.brand::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(99,102,241,0.2), transparent);
  animation: shine 3s infinite;
}

@keyframes shine {
  0% { left: -100%; }
  50%, 100% { left: 100%; }
}

.brand-banner {
  height: 36px;
  display: block;
  filter: drop-shadow(0 4px 10px rgba(99,102,241,0.3));
  transition: transform 0.3s ease;
}

.brand:hover .brand-banner {
  transform: scale(1.05);
}

.menu {
  padding: 16px;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

.menu-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--subtext);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 16px 12px 8px;
  position: relative;
}

.menu-title::after {
  content: '';
  position: absolute;
  left: 12px;
  bottom: 0;
  width: 30px;
  height: 2px;
  background: var(--primary);
  border-radius: 2px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin: 4px 0;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.menu-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: var(--gradient);
  transition: left 0.5s ease;
  opacity: 0.1;
}

.menu-item:hover {
  color: var(--primary);
  background: var(--primary-10);
  transform: translateX(5px);
}

.menu-item:hover::before {
  left: 0;
}

.menu-item.active {
  background: var(--gradient);
  color: white;
  box-shadow: var(--shadow-lg);
  transform: scale(1);
}

.menu-item.active::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 14px;
  width: 6px;
  height: 6px;
  background: white;
  border-radius: 50%;
  transform: translateY(-50%);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255,255,255,0.7);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(255,255,255,0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255,255,255,0);
  }
}

.menu-item.logout {
  margin-top: auto;
  background: var(--gradient-2);
  color: white;
}

.menu-item.logout:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-xl);
}

.menu-spacer {
  flex: 1;
}

.icon {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: transform 0.3s ease;
}

/* Font Awesome Icon Adjustments */
.icon-btn i,
.menu-item i,
.dropdown-item i {
  font-size: 16px;
  transition: transform 0.3s ease;
}

.icon-btn:hover i {
  transform: scale(1.1);
}

.menu-item:hover .icon {
  transform: rotate(10deg) scale(1.1);
}

/* Edge fix removed - not needed with new design */

.topbar { display:flex; align-items:center; gap:16px; padding: 12px 20px; background:linear-gradient(180deg, rgba(123,54,246,0.06) 0%, #f9fafb 100%); border-bottom:1px solid var(--border); position: sticky; top:0; z-index: 10; backdrop-filter: saturate(140%) blur(6px); box-shadow: 0 1px 0 rgba(0,0,0,.04); }
.icon-btn { border:1px solid var(--border); background:#fff; border-radius:10px; padding:8px 10px; cursor:pointer; transition: box-shadow .15s ease, transform .1s ease; }
.icon-btn:hover{ box-shadow: 0 0 0 3px var(--primary-10); }
.search input { width: 360px; max-width: 40vw; border:1px solid var(--border); padding:10px 12px; border-radius: 10px; }
.badge { background: var(--primary-10); color: var(--primary-dark); font-weight:600; padding: 8px 10px; border-radius: 10px; }

.content { padding: 20px; overflow-x: hidden; }
.footer { padding: 16px 20px; color: var(--subtext); display:flex; align-items:center; gap:10px; }
.footer .footer-banner{ height: 18px; opacity:.9; }

/* Cards, grid */
.grid { display:grid; gap: 16px; }
.grid.cards-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (max-width: 1024px) {
  .wrapper { margin-left: 0; width: 100%; }
  .sidebar { transform: translateX(-101%); transition: transform .25s ease; }
  .sidebar.open { transform: translateX(0); box-shadow: 0 30px 50px rgba(0,0,0,.16); }
  .grid.cards-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two { grid-template-columns: 1fr; }
  .search input { max-width: 60vw; }
}

/* Dark theme variants for sidebar/topbar background harmony */
body.theme-dark .sidebar{
  background: #131a26;
}
body.theme-dark .topbar{
  background: linear-gradient(180deg, rgba(123,54,246,0.12) 0%, #121826 100%);
}

.card { background: var(--card); border:1px solid var(--border); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .15s ease; }
.card:hover { transform: translateY(-2px); box-shadow: 0 12px 36px rgba(10, 37, 64, .12); }
.card-title { font-weight: 600; margin-bottom: 8px; }
.placeholder { height: 220px; border:1px dashed var(--border); border-radius: 12px; display:grid; place-items:center; color: var(--subtext); }

/* KPI */
.kpi-label{ color: var(--subtext); font-size: 13px; }
.kpi-value{ font-size: 28px; font-weight: 700; margin-top: 6px; }
.kpi-sub{ color: var(--subtext); font-size: 12px; margin-top: 8px; }

/* Forms */
.input{ border:1px solid var(--border); padding:10px 12px; border-radius: 12px; width: 100%; background: var(--card); color: var(--text); box-shadow: 0 1px 0 rgba(0,0,0,.02) inset; }
.input:focus{ outline:none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-10); }
.menu-item:focus-visible, .icon-btn:focus-visible, .btn:focus-visible { outline:none; box-shadow: 0 0 0 3px var(--primary-10); }
.input::-ms-expand { display:none; }
select.input{ appearance:none; -webkit-appearance:none; -moz-appearance:none; background-image: linear-gradient(45deg, transparent 50%, var(--subtext) 50%), linear-gradient(135deg, var(--subtext) 50%, transparent 50%); background-position: calc(100% - 20px) calc(1em + 2px), calc(100% - 15px) calc(1em + 2px); background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.form-grid { display:grid; gap:12px; grid-template-columns: repeat(2, minmax(0,1fr)); align-items: end; }
.form-grid label span { display:block; font-size:12px; color: var(--subtext); margin-bottom: 6px; }
.price-grid{ display:grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
.switch{ display:flex; align-items:center; gap: 10px; }

/* Buttons */
.btn{ border:1px solid var(--border); background:#fff; padding:10px 14px; border-radius:12px; cursor:pointer; transition: background .15s ease, transform .06s ease; }
.btn:hover{ background: #f3f4f6; }
.btn:active{ transform: translateY(1px); }
.btn.primary{ background: var(--primary); border-color: var(--primary); color:#fff; }
.btn.primary:hover{ background: var(--primary-dark); }
.btn.danger{ border-color:#fecaca; background:#fee2e2; color:#991b1b; }
.btn-group{ display:flex; gap:8px; flex-wrap: wrap; }

/* Premium Tables */
.table-responsive {
  width: 100%;
  overflow: auto;
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--card);
}

.table thead {
  background: var(--bg-secondary);
}

.table th,
.table td {
  text-align: left;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  transition: var(--transition);
}

.table thead th {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  z-index: 10;
}

.table tbody tr {
  transition: var(--transition);
}

.table tbody tr:hover {
  background: var(--primary-10);
}

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

.table thead th[data-sort] {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 30px;
}

.table thead th[data-sort]::after {
  content: '⇕';
  position: absolute;
  right: 12px;
  opacity: 0.5;
}

.table thead th[data-sort]:hover {
  color: var(--primary);
}

.col-hidden {
  display: none !important;
}

/* Status Badges */
.status {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status.ok {
  color: #065f46;
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  box-shadow: 0 2px 4px rgba(16,185,129,0.2);
}

.status.warn {
  color: #92400e;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  box-shadow: 0 2px 4px rgba(251,191,36,0.2);
}

.status.error {
  color: #991b1b;
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  box-shadow: 0 2px 4px rgba(239,68,68,0.2);
}

/* Page Header */
.page-header {
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.page-header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100px;
  height: 3px;
  background: var(--gradient);
  border-radius: 3px;
}

.page-title {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 8px;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-subtitle {
  color: var(--subtext);
  font-size: 16px;
}

/* Premium Toast Notifications */
.toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: var(--glass);
  backdrop-filter: blur(10px);
  color: var(--text);
  padding: 16px 20px;
  border-radius: 14px;
  box-shadow: var(--shadow-xl);
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 100;
  border: 1px solid var(--glass-border);
  max-width: 400px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.toast::before {
  content: 'ℹ️';
  font-size: 20px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  animation: toast-slide 0.3s ease;
}

.toast.success {
  background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
  color: white;
  border: none;
}

.toast.success::before {
  content: '✅';
}

.toast.error {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  border: none;
}

.toast.error::before {
  content: '❌';
}

.toast.warning {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  border: none;
}

.toast.warning::before {
  content: '⚠️';
}

@keyframes toast-slide {
  0% {
    transform: translateX(400px);
  }
  100% {
    transform: translateX(0);
  }
}

/* Premium Charts */
.chart-box {
  position: relative;
  height: clamp(250px, 35vh, 400px);
  padding: 20px;
  background: var(--card);
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
}

.chart-box canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.chart-header {
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chart-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.chart-legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chart-legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

/* Premium Avatars */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  object-fit: cover;
  background: var(--gradient);
  position: relative;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow);
}

.avatar:hover {
  transform: scale(1.1);
  box-shadow: 0 0 0 4px var(--primary-10);
}

.avatar::after {
  content: '';
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  background: #10b981;
  border: 2px solid var(--bg);
  border-radius: 50%;
}

.avatar-lg {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 3px solid var(--primary);
  object-fit: cover;
  background: var(--gradient);
  box-shadow: var(--shadow-lg);
  transition: var(--transition);
}

.avatar-lg:hover {
  transform: scale(1.05) rotate(5deg);
  box-shadow: var(--shadow-xl);
}

.avatar-group {
  display: flex;
  align-items: center;
}

.avatar-group .avatar {
  margin-left: -10px;
  border: 2px solid var(--bg);
}

.avatar-group .avatar:first-child {
  margin-left: 0;
}

.avatar-group .avatar:hover {
  z-index: 10;
}

/* Premium Skeleton Loaders */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--bg-secondary);
  border-radius: 8px;
  height: 14px;
}

.skeleton::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(99,102,241,0.1),
    transparent
  );
  animation: shimmer 1.5s infinite;
}

.skeleton-lg {
  height: 24px;
}

.skeleton-xl {
  height: 40px;
}

.skeleton-cell {
  padding: 12px;
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.skeleton-card {
  height: 200px;
  border-radius: 20px;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* Secret icon + menu */
.secret-icon{ opacity: 0; pointer-events: none; transform: scale(.92); transition: opacity .25s ease, transform .2s ease; }
.secret-icon.shown{ opacity: 1; pointer-events: auto; transform: scale(1); }
.secret-menu{ display: none; }
.secret-menu.open{ display: block; }

/* Glitch effect */
body.glitch-active .wrapper{ animation: glitch-shake var(--glitch-dur) steps(20, end); }
#glitchLayer{ position: fixed; inset: 0; pointer-events: none; z-index: 999; opacity: 0; }
#glitchLayer.active{ opacity: 1; animation: glitch-flicker var(--glitch-dur) linear both; background:
  repeating-linear-gradient(0deg, rgba(255,255,255,.05), rgba(255,255,255,.05) 2px, rgba(0,0,0,0) 3px, rgba(0,0,0,0) 6px);
}
#glitchLayer.active::before,
#glitchLayer.active::after{ content:''; position:absolute; inset:0; mix-blend-mode: screen; }
#glitchLayer.active::before{ background: linear-gradient(0deg, rgba(255,0,0,.12), rgba(255,0,0,0)); transform: translate(-2px,0); animation: glitch-rgb var(--glitch-dur) steps(15) both; filter: blur(1px); }
#glitchLayer.active::after{ background: linear-gradient(180deg, rgba(0,255,255,.12), rgba(0,255,255,0)); transform: translate(2px,0); animation: glitch-rgb var(--glitch-dur) steps(15) reverse both; filter: blur(1px); }

@keyframes glitch-flicker{
  0%,100%{ opacity: 0; }
  10%,90%{ opacity: .9; }
  20%{ opacity: .4; }
  30%{ opacity: .8; }
  40%{ opacity: .5; }
  50%{ opacity: 1; }
  60%{ opacity: .6; }
  70%{ opacity: .9; }
  80%{ opacity: .5; }
}
@keyframes glitch-rgb{
  0%{   clip-path: inset(10% 0 30% 0); }
  20%{  clip-path: inset(40% 0 5% 0); }
  40%{  clip-path: inset(15% 0 45% 0); }
  60%{  clip-path: inset(60% 0 12% 0); }
  80%{  clip-path: inset(20% 0 35% 0); }
  100%{ clip-path: inset(8% 0 60% 0); }
}
@keyframes glitch-shake{
  0%{ transform: translate(0,0); }
  10%{ transform: translate(-2px,2px); }
  20%{ transform: translate(2px,-2px); }
  30%{ transform: translate(-3px,3px); }
  40%{ transform: translate(3px,-3px); }
  50%{ transform: translate(-1px,2px); }
  60%{ transform: translate(1px,-1px); }
  70%{ transform: translate(-2px,1px); }
  80%{ transform: translate(2px,-2px); }
  90%{ transform: translate(-1px,1px); }
  100%{ transform: translate(0,0); }
}
@media (prefers-reduced-motion: reduce){
  body.glitch-active .wrapper{ animation: none; }
  #glitchLayer.active{ animation: none; opacity: .4; }
  #glitchLayer.active::before, #glitchLayer.active::after{ animation: none; }
}

/* Modal (Secret, namespaced) */
.secret-modal{ position: fixed; inset: 0; display: none; z-index: 1001; }
.secret-modal.open{ display: flex; align-items: center; justify-content: center; }
.secret-modal-backdrop{ position: absolute; inset: 0; background: rgba(0,0,0,.45); backdrop-filter: blur(2px); }
.secret-modal-content{ position: relative; z-index: 1; background: var(--card); border:1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow), 0 20px 60px rgba(0,0,0,.18); width: min(560px, 92vw); max-height: 85vh; overflow: auto; animation: modal-in .18s ease; }
.secret-modal-header{ display:flex; align-items:center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom:1px solid var(--border); }
.secret-modal-title{ font-weight: 600; }
.secret-modal-body{ padding: 16px; }
body.modal-open{ overflow: hidden; }
@keyframes modal-in{ from{ transform: translateY(6px) scale(.98); opacity:0; } to{ transform: translateY(0) scale(1); opacity:1; } }
@media (prefers-reduced-motion: reduce){ .secret-modal-content{ animation: none; } }

/* LeftCaps welcome popup (centered red text only) */
#leftcaps{ position: fixed; top: 0; right: 0; bottom: 0; left: 0; display: flex; align-items: center; justify-content: center; z-index: 1002; pointer-events: none; opacity: 0; transition: opacity .25s ease; }
#leftcaps.show{ opacity: 1; }
@supports (display: grid){
  #leftcaps{ display: grid; place-items: center; }
}
#leftcaps .leftcaps-pill{ background: transparent; box-shadow: none; padding: 0; overflow: visible; display: grid; justify-items: center; position: fixed; left: 50%; top: 50%; transform-origin: center; --lc-center: translate(-50%, -50%); transform: var(--lc-center) scale(1); }
#leftcaps.enter .leftcaps-pill{ animation: lc-in 700ms cubic-bezier(.2,.9,.2,1) both; }
#leftcaps.leave .leftcaps-pill{ animation: lc-out 600ms ease both; }
#leftcaps .leftcaps-title{ font-weight: 900; font-size: clamp(32px, 6vw, 56px); line-height: 1.1; color: #ef4444; letter-spacing: .3px; text-align: center; text-shadow: 0 0 0 rgba(0,0,0,0); }
#leftcaps.show .leftcaps-title{ animation: glitch-txt 1200ms steps(16, end) infinite; }
.leftcaps-sub{ margin-top: 6px; font-size: clamp(12px, 1.8vw, 14px); color: #ef4444; opacity: .95; text-align: center; letter-spacing: .2px; }
@keyframes lc-in{ 0%{ transform: var(--lc-center) scale(.85); filter: blur(2px); opacity: 0; } 60%{ transform: var(--lc-center) scale(1.08); filter: blur(0); opacity: 1; } 100%{ transform: var(--lc-center) scale(1); } }
@keyframes lc-out{ 0%{ transform: var(--lc-center) scale(1); opacity: 1; } 100%{ transform: var(--lc-center) scale(.86); opacity: 0; } }
@keyframes glitch-txt{
  0%, 100%{ text-shadow: 0 0 transparent, 0 0 transparent, 0 0 transparent; }
  10%{ text-shadow: -2px 0 rgba(255,0,0,.35), 2px 0 rgba(0,255,255,.35), 0 0 8px rgba(239,68,68,.25); }
  20%{ text-shadow: 2px 0 rgba(255,0,0,.35), -2px 0 rgba(0,255,255,.35), 0 0 12px rgba(239,68,68,.3); }
  30%{ text-shadow: -1px 0 rgba(255,0,0,.4), 1px 0 rgba(0,255,255,.4), 0 0 10px rgba(239,68,68,.35); }
  40%{ text-shadow: 3px 0 rgba(255,0,0,.25), -3px 0 rgba(0,255,255,.25), 0 0 6px rgba(239,68,68,.2); }
  50%{ text-shadow: -3px 0 rgba(255,0,0,.35), 3px 0 rgba(0,255,255,.35), 0 0 14px rgba(239,68,68,.35); }
  60%{ text-shadow: 1px 0 rgba(255,0,0,.35), -1px 0 rgba(0,255,255,.35), 0 0 8px rgba(239,68,68,.25); }
  70%{ text-shadow: -2px 0 rgba(255,0,0,.35), 2px 0 rgba(0,255,255,.35), 0 0 12px rgba(239,68,68,.35); }
  80%{ text-shadow: 2px 0 rgba(255,0,0,.35), -2px 0 rgba(0,255,255,.35), 0 0 6px rgba(239,68,68,.2); }
  90%{ text-shadow: -1px 0 rgba(255,0,0,.4), 1px 0 rgba(0,255,255,.4), 0 0 10px rgba(239,68,68,.3); }
}
@media (prefers-reduced-motion: reduce){
  #leftcaps.enter .leftcaps-pill, #leftcaps.leave .leftcaps-pill{ animation: none; }
  #leftcaps.show .leftcaps-title{ animation: none; }
}
