/* ============================================================================
   Design System v2 - Premium UI
   ============================================================================
   Sleek, modern design with proper desktop/mobile separation
   ============================================================================ */

:root {
  /* ========== Color Palette ========== */
  --color-primary: #6366f1;
  --color-primary-hover: #4f46e5;
  --color-primary-light: rgba(99, 102, 241, 0.1);
  --color-secondary: #8b5cf6;
  --color-success: #10b981;
  --color-success-light: rgba(16, 185, 129, 0.1);
  --color-warning: #f59e0b;
  --color-warning-light: rgba(245, 158, 11, 0.1);
  --color-error: #ef4444;
  --color-error-light: rgba(239, 68, 68, 0.1);
  --color-info: #3b82f6;
  --color-info-light: rgba(59, 130, 246, 0.1);

  /* ========== Text Colors ========== */
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --text-inverse: #ffffff;

  /* ========== Backgrounds ========== */
  --bg-body: #f8fafc;
  --bg-surface: #ffffff;
  --bg-elevated: #ffffff;
  --bg-hover: #f1f5f9;
  --bg-active: #e2e8f0;
  --bg-overlay: rgba(0, 0, 0, 0.5);

  /* ========== Borders ========== */
  --border-color: #e2e8f0;
  --border-subtle: #f1f5f9;
  --border-strong: #cbd5e1;

  /* ========== Shadows ========== */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-float: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
  --shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.04);

  /* ========== Spacing (Tighter) ========== */
  --sp-0: 0;
  --sp-1: 0.125rem;  /* 2px */
  --sp-2: 0.25rem;   /* 4px */
  --sp-3: 0.5rem;    /* 8px */
  --sp-4: 0.75rem;   /* 12px */
  --sp-5: 1rem;      /* 16px */
  --sp-6: 1.25rem;   /* 20px */
  --sp-7: 1.5rem;    /* 24px */
  --sp-8: 2rem;      /* 32px */
  --sp-9: 2.5rem;    /* 40px */
  --sp-10: 3rem;     /* 48px */

  /* ========== Border Radius ========== */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* ========== Typography ========== */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  
  --text-xs: 0.6875rem;   /* 11px */
  --text-sm: 0.8125rem;   /* 13px */
  --text-base: 0.875rem;  /* 14px */
  --text-md: 0.9375rem;   /* 15px */
  --text-lg: 1rem;        /* 16px */
  --text-xl: 1.125rem;    /* 18px */
  --text-2xl: 1.375rem;   /* 22px */
  --text-3xl: 1.75rem;    /* 28px */
  --text-4xl: 2.25rem;    /* 36px */

  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;

  /* ========== Transitions ========== */
  --ease-out: cubic-bezier(0.33, 1, 0.68, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --duration-fast: 100ms;
  --duration-base: 150ms;
  --duration-slow: 250ms;

  /* ========== Z-Index ========== */
  --z-base: 1;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-overlay: 300;
  --z-modal: 400;
  --z-popover: 500;
  --z-toast: 600;
  --z-tooltip: 700;

  /* ========== Layout ========== */
  --sidebar-width: 240px;
  --header-height: 56px;
  --mobile-nav-height: 64px;
  --content-max-width: 1200px;
}

/* ========== Dark Mode ========== */
[data-theme="dark"] {
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0f172a;

  --bg-body: #0f172a;
  --bg-surface: #1e293b;
  --bg-elevated: #334155;
  --bg-hover: #334155;
  --bg-active: #475569;
  --bg-overlay: rgba(0, 0, 0, 0.7);

  --border-color: #334155;
  --border-subtle: #1e293b;
  --border-strong: #475569;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.3);
}

/* ============================================================================
   Base Reset & Typography
   ============================================================================ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background: var(--bg-body);
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ============================================================================
   Layout - Desktop Sidebar
   ============================================================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sticky);
  transition: transform var(--duration-slow) var(--ease-out);
}

.sidebar-header {
  padding: var(--sp-5) var(--sp-5);
  border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.sidebar-logo svg {
  width: 24px;
  height: 24px;
}

.sidebar-nav {
  flex: 1;
  padding: var(--sp-3) var(--sp-3);
  overflow-y: auto;
}

.nav-section {
  margin-bottom: var(--sp-4);
}

.nav-section-title {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: var(--sp-3) var(--sp-3) var(--sp-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--duration-fast) var(--ease-out);
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: var(--sp-4);
  border-top: 1px solid var(--border-color);
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-container {
  flex: 1;
  padding: var(--sp-6) var(--sp-7);
  max-width: var(--content-max-width);
  width: 100%;
  margin: 0 auto;
}

/* ============================================================================
   Mobile Layout
   ============================================================================ */
.mobile-header {
  display: none;
}

.mobile-nav {
  display: none;
}

.sidebar-overlay {
  display: none;
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
    z-index: var(--z-modal);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    opacity: 0;
    visibility: hidden;
    transition: all var(--duration-slow) var(--ease-out);
    z-index: calc(var(--z-modal) - 1);
  }

  .sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
  }

  .main-content {
    margin-left: 0;
    padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px));
  }

  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    height: var(--header-height);
    padding: 0 var(--sp-5);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    z-index: var(--z-sticky);
  }

  .mobile-header-title {
    font-size: var(--text-lg);
    font-weight: 600;
  }

  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: background var(--duration-fast);
  }

  .mobile-menu-btn:hover {
    background: var(--bg-hover);
  }

  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--mobile-nav-height);
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    padding: var(--sp-2) var(--sp-3);
    padding-bottom: calc(var(--sp-2) + env(safe-area-inset-bottom, 0px));
    z-index: var(--z-sticky);
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--sp-1);
    color: var(--text-muted);
    font-size: var(--text-xs);
    font-weight: 500;
    transition: color var(--duration-fast);
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-nav-item:hover,
  .mobile-nav-item.active {
    color: var(--color-primary);
  }

  .mobile-nav-item svg {
    width: 22px;
    height: 22px;
  }

  .page-container {
    padding: var(--sp-5);
  }
}

/* ============================================================================
   Cards
   ============================================================================ */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--sp-6);
}

.card-compact {
  padding: var(--sp-4);
}

.card-default {
  padding: var(--sp-5);
}

.card-spacious {
  padding: var(--sp-6);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--sp-4);
}

.card-title {
  font-size: var(--text-md);
  font-weight: 600;
}

.card-clickable {
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.card-clickable:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

/* ============================================================================
   Buttons
   ============================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-4);
  height: 36px;
  font-size: var(--text-sm);
  font-weight: 500;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-sm {
  height: 30px;
  padding: 0 var(--sp-3);
  font-size: var(--text-xs);
}

.btn-lg {
  height: 44px;
  padding: 0 var(--sp-6);
  font-size: var(--text-md);
}

.btn-primary {
  background: var(--color-primary);
  color: white;
}

.btn-primary:hover {
  background: var(--color-primary-hover);
}

.btn-secondary {
  background: var(--bg-hover);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-active);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--color-error);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-icon {
  width: 36px;
  padding: 0;
}

.btn-icon.btn-sm {
  width: 30px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================================================
   Form Controls - Custom Styled
   ============================================================================ */
.form-group {
  margin-bottom: var(--sp-5);
}

.form-label,
.label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: var(--sp-2);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--sp-1);
}

/* Text Input */
.input {
  width: 100%;
  height: 40px;
  padding: 0 var(--sp-4);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  outline: none;
  transition: all var(--duration-fast) var(--ease-out);
}

.input::placeholder {
  color: var(--text-muted);
}

.input:hover {
  border-color: var(--border-strong);
}

.input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.input-sm {
  height: 32px;
  padding: 0 var(--sp-3);
  font-size: var(--text-sm);
}

.input-lg {
  height: 48px;
  padding: 0 var(--sp-5);
  font-size: var(--text-lg);
}

/* Textarea */
textarea.input {
  height: auto;
  min-height: 80px;
  padding: var(--sp-3) var(--sp-4);
  resize: vertical;
  line-height: var(--leading-normal);
}

/* Select - Custom Dropdown */
.select-wrapper {
  position: relative;
}

.select {
  width: 100%;
  height: 40px;
  padding: 0 var(--sp-8) 0 var(--sp-4);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  outline: none;
  cursor: pointer;
  appearance: none;
  transition: all var(--duration-fast) var(--ease-out);
}

.select:hover {
  border-color: var(--border-strong);
}

.select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.select-wrapper::after {
  content: '';
  position: absolute;
  right: var(--sp-4);
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid var(--text-muted);
  pointer-events: none;
}

/* Custom Dropdown */
.custom-select {
  position: relative;
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 40px;
  padding: 0 var(--sp-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.custom-select-trigger:hover {
  border-color: var(--border-strong);
}

.custom-select.open .custom-select-trigger {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.custom-select-options {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all var(--duration-fast) var(--ease-out);
  max-height: 240px;
  overflow-y: auto;
}

.custom-select.open .custom-select-options {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.custom-select-option {
  display: flex;
  align-items: center;
  padding: var(--sp-3) var(--sp-4);
  cursor: pointer;
  transition: background var(--duration-fast);
}

.custom-select-option:hover {
  background: var(--bg-hover);
}

.custom-select-option.selected {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

/* ============================================================================
   Custom Date Picker
   ============================================================================ */
.date-picker {
  position: relative;
}

.date-picker-input {
  width: 100%;
  height: 40px;
  padding: 0 var(--sp-4);
  padding-right: 40px;
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.date-picker-icon {
  position: absolute;
  right: var(--sp-4);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.date-picker-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: var(--sp-4);
  z-index: var(--z-dropdown);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all var(--duration-fast) var(--ease-out);
}

.date-picker.open .date-picker-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.date-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
}

.date-picker-month {
  font-weight: 600;
  font-size: var(--text-md);
}

.date-picker-nav {
  display: flex;
  gap: var(--sp-2);
}

.date-picker-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--duration-fast);
}

.date-picker-nav-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.date-picker-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: var(--sp-2);
}

.date-picker-weekday {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
}

.date-picker-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.date-picker-day {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  font-size: var(--text-sm);
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.date-picker-day:hover {
  background: var(--bg-hover);
}

.date-picker-day.today {
  background: var(--bg-active);
  font-weight: 600;
}

.date-picker-day.selected {
  background: var(--color-primary);
  color: white;
}

.date-picker-day.disabled {
  color: var(--text-muted);
  cursor: not-allowed;
}

.date-picker-day.other-month {
  color: var(--text-muted);
}

/* ============================================================================
   Custom Number Input
   ============================================================================ */
.number-input {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all var(--duration-fast);
}

.number-input:hover {
  border-color: var(--border-strong);
}

.number-input:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.number-input input {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 var(--sp-3);
  font-size: var(--text-base);
  text-align: center;
  border: none;
  background: var(--bg-surface);
  color: var(--text-primary);
  outline: none;
  -moz-appearance: textfield;
}

.number-input input::-webkit-outer-spin-button,
.number-input input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.number-input-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  border: none;
  background: var(--bg-hover);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast);
  user-select: none;
}

.number-input-btn:hover {
  background: var(--bg-active);
  color: var(--text-primary);
}

.number-input-btn:active {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.number-input-field {
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 0;
  background: var(--bg-surface);
}

.number-input-prefix {
  padding-left: var(--sp-3);
  color: var(--text-muted);
  font-size: var(--text-base);
  user-select: none;
}

.number-input-field .input {
  flex: 1;
  border: none;
  background: transparent;
  box-shadow: none;
}

.number-input-field .input:focus {
  box-shadow: none;
}

/* Wrapper classes for form components */
.number-input-wrapper,
.date-picker-wrapper {
  display: block;
  width: 100%;
}

/* ============================================================================
   Context Menu
   ============================================================================ */
.context-menu {
  position: fixed;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  min-width: 180px;
  padding: var(--sp-2);
  z-index: var(--z-popover);
  opacity: 0;
  visibility: hidden;
  transform: scale(0.95);
  transform-origin: top left;
  transition: all var(--duration-fast) var(--ease-out);
}

.context-menu.visible {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-sm);
  color: var(--text-primary);
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background var(--duration-fast);
}

.context-menu-item:hover {
  background: var(--bg-hover);
}

.context-menu-item svg {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.context-menu-item.danger {
  color: var(--color-error);
}

.context-menu-item.danger svg {
  color: var(--color-error);
}

.context-menu-divider {
  height: 1px;
  background: var(--border-color);
  margin: var(--sp-2) 0;
}

/* ============================================================================
   Badges
   ============================================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--text-xs);
  font-weight: 500;
  border-radius: var(--radius-full);
}

.badge-default {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.badge-primary {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.badge-success {
  background: var(--color-success-light);
  color: var(--color-success);
}

.badge-warning {
  background: var(--color-warning-light);
  color: var(--color-warning);
}

.badge-error {
  background: var(--color-error-light);
  color: var(--color-error);
}

/* ============================================================================
   Alerts / Toasts
   ============================================================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}

.alert-success {
  background: var(--color-success-light);
  color: #065f46;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-error {
  background: var(--color-error-light);
  color: #991b1b;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-warning {
  background: var(--color-warning-light);
  color: #92400e;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.alert-info {
  background: var(--color-info-light);
  color: #1e40af;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

[data-theme="dark"] .alert-success { color: #a7f3d0; }
[data-theme="dark"] .alert-error { color: #fca5a5; }
[data-theme="dark"] .alert-warning { color: #fcd34d; }
[data-theme="dark"] .alert-info { color: #93c5fd; }

/* ============================================================================
   Progress Bar
   ============================================================================ */
.progress {
  width: 100%;
  height: 6px;
  background: var(--bg-active);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  transition: width var(--duration-slow) var(--ease-out);
}

.progress-success .progress-bar { background: var(--color-success); }
.progress-warning .progress-bar { background: var(--color-warning); }
.progress-error .progress-bar { background: var(--color-error); }

/* ============================================================================
   Modal
   ============================================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5);
  z-index: var(--z-modal);
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration-slow) var(--ease-out);
}

.modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-float);
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow: hidden;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--duration-slow) var(--ease-out);
}

.modal-overlay.visible .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: var(--text-lg);
  font-weight: 600;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.modal-body {
  padding: var(--sp-6);
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-6);
  border-top: 1px solid var(--border-color);
}

/* ============================================================================
   Toggle Switch
   ============================================================================ */
.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-active);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--duration-base);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration-base) var(--ease-out);
}

.toggle input:checked + .toggle-slider {
  background: var(--color-primary);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

.toggle input:focus-visible + .toggle-slider {
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

/* ============================================================================
   Subscription Card
   ============================================================================ */
.subscription-card {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  user-select: none;
}

.subscription-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

.subscription-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--color-primary-light);
  border-radius: var(--radius-md);
  color: var(--color-primary);
  font-weight: 600;
  font-size: var(--text-md);
  flex-shrink: 0;
}

.subscription-info {
  flex: 1;
  min-width: 0;
}

.subscription-name {
  font-weight: 600;
  font-size: var(--text-md);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subscription-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.subscription-amount {
  text-align: right;
  flex-shrink: 0;
}

.subscription-price {
  font-weight: 600;
  font-size: var(--text-md);
}

.subscription-cycle {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ============================================================================
   Stats Card
   ============================================================================ */
.stat-card {
  padding: var(--sp-5);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}

.stat-label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--sp-2);
}

.stat-value {
  font-size: var(--text-2xl);
  font-weight: 700;
}

.stat-trend {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--text-xs);
  font-weight: 500;
  margin-top: var(--sp-2);
}

.stat-trend.up { color: var(--color-success); }
.stat-trend.down { color: var(--color-error); }

/* ============================================================================
   Empty State
   ============================================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--sp-10) var(--sp-5);
}

.empty-state-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: var(--bg-hover);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  margin-bottom: var(--sp-5);
}

.empty-state-icon svg {
  width: 28px;
  height: 28px;
}

.empty-state-title {
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--sp-2);
}

.empty-state-text {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--sp-5);
  max-width: 300px;
}

/* ============================================================================
   Utilities
   ============================================================================ */
.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;
}

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--color-success); }
.text-error { color: var(--color-error); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-5 { gap: var(--sp-5); }

.mt-auto { margin-top: auto; }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-5 { margin-bottom: var(--sp-5); }
.mb-6 { margin-bottom: var(--sp-6); }

.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
  .md\:grid-cols-1 { grid-template-columns: 1fr; }
  .md\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================================
   Page Headers
   ============================================================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-6);
  flex-wrap: wrap;
  gap: var(--sp-4);
}

.page-title {
  font-size: var(--text-2xl);
  font-weight: 700;
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--sp-1);
}

@media (max-width: 768px) {
  .page-title {
    font-size: var(--text-xl);
  }
}

/* ============================================================================
   Skeleton Loading
   ============================================================================ */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-hover) 25%,
    var(--bg-active) 50%,
    var(--bg-hover) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================================
   Spinner
   ============================================================================ */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================================
   Scrollbar
   ============================================================================ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
