/* ============================================================
   PostWing Pro - Global Design System
   Dark mode glassmorphism with electric purple/blue accents
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=Plus+Jakarta+Sans:wght@400;600;700;800&display=swap');

/* ============================================================
   CSS Custom Properties (Design Tokens)
   ============================================================ */
:root,
[data-theme="midnight"],
[data-theme="dark"] {
  /* Default Midnight Theme (Dark Purple/Indigo Glow) */
  --bg-primary: #0A0A14;
  --bg-secondary: #0F0F1E;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.07);
  --bg-input: rgba(255, 255, 255, 0.06);

  --primary: #6C63FF;
  --primary-hover: #5A52E0;
  --primary-glow: rgba(108, 99, 255, 0.35);
  --secondary: #FF6B9D;
  --accent: #00D9FF;
  --accent-green: #00E5A0;
  --accent-orange: #FF8C42;
  --accent-yellow: #FFD23F;

  --gradient-main: linear-gradient(135deg, #6C63FF 0%, #FF6B9D 100%);
  --gradient-card: linear-gradient(135deg, rgba(108, 99, 255, 0.15) 0%, rgba(255, 107, 157, 0.08) 100%);
  --gradient-dark: linear-gradient(180deg, #0A0A14 0%, #0F0F1E 100%);
  --gradient-mesh: radial-gradient(ellipse at 20% 50%, rgba(108, 99, 255, 0.15) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 10%, rgba(255, 107, 157, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 90%, rgba(0, 217, 255, 0.08) 0%, transparent 50%);

  /* Text Colors */
  --text-primary: #F0F0FF;
  --text-secondary: #9898C0;
  --text-muted: #5A5A80;
  --text-inverse: #0A0A14;

  /* Borders */
  --border: rgba(255, 255, 255, 0.08);
  --border-active: rgba(108, 99, 255, 0.5);
  --border-glow: rgba(108, 99, 255, 0.3);

  /* Status Colors */
  --success: #00E5A0;
  --success-bg: rgba(0, 229, 160, 0.12);
  --warning: #FFD23F;
  --warning-bg: rgba(255, 210, 63, 0.12);
  --error: #FF5757;
  --error-bg: rgba(255, 87, 87, 0.12);
  --info: #00D9FF;
  --info-bg: rgba(0, 217, 255, 0.12);

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;
  --space-4xl: 96px;

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px rgba(108, 99, 255, 0.25);
  --shadow-card: 0 4px 32px rgba(0, 0, 0, 0.35);

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'Plus Jakarta Sans', 'Inter', sans-serif;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;

  /* Layout */
  --sidebar-width: 260px;
  --header-height: 72px;
  --container-max: 1280px;
}

/* ============================================================
   ☀️ Pure Light Theme (Clean Studio)
   ============================================================ */
[data-theme="light"] {
  --bg-primary: #F8FAFC;
  --bg-secondary: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F1F5F9;
  --bg-input: #F1F5F9;

  --primary: #6366F1;
  --primary-hover: #4F46E5;
  --primary-glow: rgba(99, 102, 241, 0.25);
  --secondary: #EC4899;
  --accent: #06B6D4;
  --accent-green: #10B981;
  --accent-orange: #F97316;
  --accent-yellow: #F59E0B;

  --gradient-main: linear-gradient(135deg, #6366F1 0%, #EC4899 100%);
  --gradient-card: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(236, 72, 153, 0.04) 100%);
  --gradient-dark: linear-gradient(180deg, #F8FAFC 0%, #FFFFFF 100%);
  --gradient-mesh: radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 10%, rgba(236, 72, 153, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 90%, rgba(6, 182, 212, 0.05) 0%, transparent 50%);

  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --text-inverse: #FFFFFF;

  --border: #E2E8F0;
  --border-active: rgba(99, 102, 241, 0.6);
  --border-glow: rgba(99, 102, 241, 0.25);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 4px 20px rgba(99, 102, 241, 0.15);
  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.05);
}

/* ============================================================
   🌿 Cyber Emerald Theme (Dark Mint Neon)
   ============================================================ */
[data-theme="emerald"] {
  --bg-primary: #05130E;
  --bg-secondary: #0A1C15;
  --bg-card: rgba(0, 229, 160, 0.04);
  --bg-card-hover: rgba(0, 229, 160, 0.08);
  --bg-input: rgba(0, 229, 160, 0.06);

  --primary: #00E5A0;
  --primary-hover: #00C788;
  --primary-glow: rgba(0, 229, 160, 0.35);
  --secondary: #00D9FF;
  --accent: #FFD23F;

  --gradient-main: linear-gradient(135deg, #00E5A0 0%, #00D9FF 100%);
  --gradient-card: linear-gradient(135deg, rgba(0, 229, 160, 0.14) 0%, rgba(0, 217, 255, 0.06) 100%);
  --gradient-dark: linear-gradient(180deg, #05130E 0%, #0A1C15 100%);

  --text-primary: #E6FFF6;
  --text-secondary: #8AD4BE;
  --text-muted: #497A6B;

  --border: rgba(0, 229, 160, 0.15);
  --border-active: rgba(0, 229, 160, 0.6);
  --border-glow: rgba(0, 229, 160, 0.35);
  --shadow-glow: 0 0 40px rgba(0, 229, 160, 0.25);
}

/* ============================================================
   🌅 Sunset Crimson Theme (Rose & Coral Velvet)
   ============================================================ */
[data-theme="sunset"] {
  --bg-primary: #14080E;
  --bg-secondary: #1E0C15;
  --bg-card: rgba(255, 65, 108, 0.04);
  --bg-card-hover: rgba(255, 65, 108, 0.08);
  --bg-input: rgba(255, 65, 108, 0.06);

  --primary: #FF416C;
  --primary-hover: #E62A55;
  --primary-glow: rgba(255, 65, 108, 0.35);
  --secondary: #FF4B2B;
  --accent: #FFA07A;

  --gradient-main: linear-gradient(135deg, #FF416C 0%, #FF4B2B 100%);
  --gradient-card: linear-gradient(135deg, rgba(255, 65, 108, 0.14) 0%, rgba(255, 75, 43, 0.06) 100%);
  --gradient-dark: linear-gradient(180deg, #14080E 0%, #1E0C15 100%);

  --text-primary: #FFF0F5;
  --text-secondary: #D49EA9;
  --text-muted: #80535C;

  --border: rgba(255, 65, 108, 0.15);
  --border-active: rgba(255, 65, 108, 0.6);
  --border-glow: rgba(255, 65, 108, 0.35);
  --shadow-glow: 0 0 40px rgba(255, 65, 108, 0.25);
}

/* ============================================================
   🌊 Sapphire Ocean Theme (Deep Navy & Electric Cyan)
   ============================================================ */
[data-theme="sapphire"] {
  --bg-primary: #060B18;
  --bg-secondary: #0B132B;
  --bg-card: rgba(0, 132, 255, 0.04);
  --bg-card-hover: rgba(0, 132, 255, 0.08);
  --bg-input: rgba(0, 132, 255, 0.06);

  --primary: #0084FF;
  --primary-hover: #006ED6;
  --primary-glow: rgba(0, 132, 255, 0.35);
  --secondary: #00F0FF;
  --accent: #7000FF;

  --gradient-main: linear-gradient(135deg, #0084FF 0%, #00F0FF 100%);
  --gradient-card: linear-gradient(135deg, rgba(0, 132, 255, 0.14) 0%, rgba(0, 240, 255, 0.06) 100%);
  --gradient-dark: linear-gradient(180deg, #060B18 0%, #0B132B 100%);

  --text-primary: #F0F6FF;
  --text-secondary: #8DA4C4;
  --text-muted: #4B607D;

  --border: rgba(0, 132, 255, 0.15);
  --border-active: rgba(0, 132, 255, 0.6);
  --border-glow: rgba(0, 132, 255, 0.35);
  --shadow-glow: 0 0 40px rgba(0, 132, 255, 0.25);
}

/* ============================================================
   👑 Royal Amethyst Theme (Deep Violet & Gold)
   ============================================================ */
[data-theme="amethyst"] {
  --bg-primary: #0F0818;
  --bg-secondary: #170C26;
  --bg-card: rgba(168, 85, 247, 0.04);
  --bg-card-hover: rgba(168, 85, 247, 0.08);
  --bg-input: rgba(168, 85, 247, 0.06);

  --primary: #A855F7;
  --primary-hover: #9333EA;
  --primary-glow: rgba(168, 85, 247, 0.35);
  --secondary: #F59E0B;
  --accent: #EC4899;

  --gradient-main: linear-gradient(135deg, #A855F7 0%, #F59E0B 100%);
  --gradient-card: linear-gradient(135deg, rgba(168, 85, 247, 0.14) 0%, rgba(245, 158, 11, 0.06) 100%);
  --gradient-dark: linear-gradient(180deg, #0F0818 0%, #170C26 100%);

  --text-primary: #FAF5FF;
  --text-secondary: #C084FC;
  --text-muted: #6B409E;

  --border: rgba(168, 85, 247, 0.15);
  --border-active: rgba(168, 85, 247, 0.6);
  --border-glow: rgba(168, 85, 247, 0.35);
  --shadow-glow: 0 0 40px rgba(168, 85, 247, 0.25);
}

/* Quick Theme Toggle & Theme Switcher Card UI */
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 1.15rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.theme-toggle-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  transform: scale(1.05);
}

.theme-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 14px;
}

.theme-card {
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  cursor: pointer;
  transition: all var(--transition-normal);
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}

.theme-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.theme-card.active {
  border-color: var(--primary);
  background: var(--primary-glow);
  box-shadow: 0 0 16px var(--primary-glow);
}

.theme-swatches {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.theme-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.theme-card-title {
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.theme-card-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Light Theme Overrides for optimal readability */
[data-theme="light"] table thead {
  background: #F1F5F9;
}

[data-theme="light"] .form-control {
  background: #FFFFFF;
  border-color: #CBD5E1;
  color: #0F172A;
}

[data-theme="light"] .form-control:focus {
  border-color: #6366F1;
  background: #FFFFFF;
}

[data-theme="light"] select.form-control option {
  background: #FFFFFF;
  color: #0F172A;
}

[data-theme="light"] .modal {
  background: #FFFFFF;
  border-color: #E2E8F0;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .sidebar {
  background: #FFFFFF;
  border-right-color: #E2E8F0;
}

[data-theme="light"] .nav {
  background: rgba(255, 255, 255, 0.88);
  border-bottom-color: #E2E8F0;
}

[data-theme="light"] .app-header {
  background: #FFFFFF;
  border-bottom-color: #E2E8F0;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  color-scheme: dark;
  max-width: 100vw;
  overflow-x: clip;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  max-width: 100vw;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
   Typography
   ============================================================ */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
}

h2 {
  font-size: clamp(1.5rem, 3vw, 2.25rem);
}

h3 {
  font-size: clamp(1.2rem, 2vw, 1.5rem);
}

h4 {
  font-size: 1.125rem;
}

h5 {
  font-size: 1rem;
}

p {
  color: var(--text-secondary);
  line-height: 1.75;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent);
}

img,
video {
  max-width: 100%;
  display: block;
}

/* ============================================================
   Layout Utilities
   ============================================================ */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.flex-center {
  align-items: center;
  justify-content: center;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-sm {
  gap: var(--space-sm);
}

.gap-md {
  gap: var(--space-md);
}

.gap-lg {
  gap: var(--space-lg);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-lg);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-lg);
}

.grid-2 > *, .grid-3 > *, .grid-4 > *, .stat-grid > * {
  min-width: 0;
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background var(--transition-normal), border-color var(--transition-normal), transform var(--transition-normal);
}

.card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-glow);
  transform: translateY(-2px);
}

.card-glow {
  box-shadow: var(--shadow-card), 0 0 0 1px var(--border-glow) inset;
}

.card-gradient {
  background: var(--gradient-card);
  border-color: var(--border-glow);
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  outline: none;
  white-space: nowrap;
  user-select: none;
  position: relative;
  overflow: hidden;
  text-decoration: none;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0);
  transition: background var(--transition-fast);
}

.btn:hover::before {
  background: rgba(255, 255, 255, 0.08);
}

.btn-primary {
  background: var(--gradient-main);
  color: #fff;
  box-shadow: 0 4px 20px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 28px var(--primary-glow);
  color: #fff;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-active);
  color: var(--text-primary);
}

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

.btn-ghost:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border);
}

.btn-danger {
  background: rgba(255, 87, 87, 0.15);
  color: var(--error);
  border: 1px solid rgba(255, 87, 87, 0.3);
}

.btn-danger:hover {
  background: rgba(255, 87, 87, 0.25);
  border-color: var(--error);
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

.btn-xl {
  padding: 18px 36px;
  font-size: 1.1rem;
  border-radius: var(--radius-lg);
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-md);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Loading spinner in button */
.btn.loading .btn-text {
  opacity: 0;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ============================================================
   Form Elements
   ============================================================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 16px;
  color: #97979f;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

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

textarea.form-control {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
}

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239898C0' fill='none' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

.form-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.form-error {
  font-size: 0.8rem;
  color: var(--error);
}

/* Toggle Switch */
.toggle-switch {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
}

.toggle-switch input[type="checkbox"] {
  display: none;
}

.toggle-track {
  width: 44px;
  height: 24px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  position: relative;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.toggle-switch input:checked+.toggle-track {
  background: var(--primary);
  border-color: var(--primary);
}

.toggle-switch input:checked+.toggle-track::after {
  transform: translateX(20px);
  background: #fff;
}

/* ============================================================
   Badges & Status Tags
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge-error {
  background: var(--error-bg);
  color: var(--error);
}

.badge-info {
  background: var(--info-bg);
  color: var(--info);
}

.badge-primary {
  background: var(--primary-glow);
  color: var(--primary);
}

.badge-muted {
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.dot-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot-success {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

.dot-warning {
  background: var(--warning);
  box-shadow: 0 0 6px var(--warning);
}

.dot-error {
  background: var(--error);
  box-shadow: 0 0 6px var(--error);
}

.dot-muted {
  background: var(--text-muted);
}

/* ============================================================
   Tables
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead {
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border);
}

th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

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

tbody tr {
  transition: background var(--transition-fast);
}

tbody tr:hover {
  background: var(--bg-card);
}

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

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: #13132A;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.97);
  transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--error-bg);
  border-color: var(--error);
  color: var(--error);
}

/* ============================================================
   Alerts / Toasts
   ============================================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
  border: 1px solid;
}

.alert-success {
  background: var(--success-bg);
  border-color: rgba(0, 229, 160, 0.3);
  color: var(--success);
}

.alert-warning {
  background: var(--warning-bg);
  border-color: rgba(255, 210, 63, 0.3);
  color: var(--warning);
}

.alert-error {
  background: var(--error-bg);
  border-color: rgba(255, 87, 87, 0.3);
  color: var(--error);
}

.alert-info {
  background: var(--info-bg);
  border-color: rgba(0, 217, 255, 0.3);
  color: var(--info);
}

/* Toast notifications */
#toast-container {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 14px 20px;
  background: #1A1A35;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  min-width: 300px;
  max-width: 400px;
  pointer-events: all;
  animation: slideInRight 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
}

.toast-success {
  border-color: rgba(0, 229, 160, 0.4);
}

.toast-success .toast-icon {
  color: var(--success);
}

.toast-error {
  border-color: rgba(255, 87, 87, 0.4);
}

.toast-error .toast-icon {
  color: var(--error);
}

.toast-info {
  border-color: rgba(0, 217, 255, 0.4);
}

.toast-info .toast-icon {
  color: var(--info);
}

@keyframes slideInRight {
  from {
    transform: translateX(120%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

/* ============================================================
   Navigation (Public Header)
   ============================================================ */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 var(--space-xl);
  transition: all var(--transition-normal);
}

.nav.scrolled {
  background: rgba(10, 10, 20, 0.9);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-primary);
  text-decoration: none;
}

.nav-logo-icon {
  width: 36px;
  height: 36px;
  background: var(--gradient-main);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  list-style: none;
  margin: 0 auto;
}

.nav-links a {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.nav-links a:hover {
  color: var(--text-primary);
}

.nav-links a.active {
  color: var(--primary);
}

.nav-cta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* Mobile Menu Toggle */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 4px;
  margin-left: auto;
}

.nav-toggle span {
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all var(--transition-fast);
}

/* ============================================================
   App Sidebar (Dashboard)
   ============================================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: #0C0C1E;
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 201;
  transition: transform var(--transition-normal);
}

.sidebar-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}
.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

.mobile-sidebar-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 5px;
  margin-right: 15px;
}

.sidebar-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.sidebar-logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-md);
  overflow-y: auto;
}

.sidebar-section {
  margin-bottom: var(--space-lg);
}

.sidebar-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 var(--space-sm);
  margin-bottom: var(--space-xs);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition-fast);
  margin-bottom: 2px;
  position: relative;
}

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

.sidebar-link.active {
  background: var(--primary-glow);
  color: var(--primary);
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
}

.sidebar-link-icon {
  width: 20px;
  text-align: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.sidebar-link-badge {
  margin-left: auto;
  font-size: 0.7rem;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-full);
  padding: 1px 6px;
  font-weight: 700;
}

.sidebar-footer {
  padding: var(--space-md);
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-sm);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
  cursor: pointer;
}

.sidebar-user:hover {
  background: var(--bg-card);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--gradient-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-plan {
  font-size: 0.75rem;
  color: var(--primary);
}

/* ============================================================
   App Main Content Area
   ============================================================ */
.app-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  padding-top: var(--header-height);
}

.app-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-xl);
  border-bottom: 1px solid var(--border);
  background: rgba(10, 10, 20, 0.8);
  backdrop-filter: blur(12px);
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  z-index: 100;
}

.page-title-area {
  display: flex;
  flex-direction: column;
}

.page-title {
  font-size: 1.3rem;
  font-weight: 700;
}

.page-breadcrumb {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.app-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.app-content {
  padding: var(--space-xl);
  flex: 1;
}

/* ============================================================
   Stat Cards
   ============================================================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-normal), border-color var(--transition-normal);
}

.stat-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-glow);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 80px;
  height: 80px;
  background: var(--gradient-main);
  opacity: 0.06;
  border-radius: 50%;
  transform: translate(25%, -25%);
}

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

.stat-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 4px;
}

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

.stat-change {
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: var(--space-sm);
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-change.up {
  color: var(--success);
}

.stat-change.down {
  color: var(--error);
}

/* ============================================================
   Empty States
   ============================================================ */
.empty-state {
  text-align: center;
  padding: var(--space-4xl) var(--space-xl);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.2rem;
  margin-bottom: var(--space-sm);
}

.empty-state p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
}

/* ============================================================
   Loading Skeleton
   ============================================================ */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* ============================================================
   Pagination
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  justify-content: center;
  margin-top: var(--space-xl);
}

.page-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.page-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ============================================================
   Section Headers
   ============================================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.section-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.section-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ============================================================
   Progress Bars
   ============================================================ */
.progress-bar {
  height: 6px;
  background: var(--bg-card);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--gradient-main);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

/* ============================================================
   Animations
   ============================================================ */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-10px);
  }
}

.animate-fade-in {
  animation: fadeIn 0.5s ease forwards;
}

.animate-fade-in-up {
  animation: fadeInUp 0.5s ease forwards;
}

.animate-pulse {
  animation: pulse 2s ease infinite;
}

.animate-float {
  animation: float 4s ease-in-out infinite;
}

/* Stagger children */
.stagger>* {
  opacity: 0;
  animation: fadeInUp 0.4s ease forwards;
}

.stagger>*:nth-child(1) {
  animation-delay: 0.05s;
}

.stagger>*:nth-child(2) {
  animation-delay: 0.10s;
}

.stagger>*:nth-child(3) {
  animation-delay: 0.15s;
}

.stagger>*:nth-child(4) {
  animation-delay: 0.20s;
}

.stagger>*:nth-child(5) {
  animation-delay: 0.25s;
}

.stagger>*:nth-child(6) {
  animation-delay: 0.30s;
}

/* ============================================================
   Scrollbar
   ============================================================ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

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

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1200px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    /* Removed overflow-y: auto to keep footer fixed at the bottom */
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .mobile-sidebar-toggle {
    display: block;
  }

  .app-main {
    margin-left: 0;
  }
  
  .app-header {
    left: 0;
  }
  
  .sidebar-nav {
    flex: none;
  }

  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .container {
    padding: 0 var(--space-md);
  }

  .app-content {
    padding: var(--space-md);
  }
  
  .card {
    padding: var(--space-md);
  }
  
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
  }
  
  .app-header-actions {
    flex-wrap: wrap;
    gap: var(--space-xs);
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }

  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .nav-links,
  .nav-cta {
    display: none;
  }

  .nav-toggle {
    display: flex;
  }

  #toast-container {
    bottom: var(--space-md);
    right: var(--space-md);
    left: var(--space-md);
  }

  .toast {
    min-width: unset;
    width: 100%;
  }
}
