/**
 * Transmiz Design System — Build 1E
 * Single source of truth for tokens, components, utilities
 */

/* ─── TOKENS ─────────────────────────────────────────────────────────────── */
:root {
  /* Colors */
  --color-primary:        #6366f1;
  --color-primary-hover:  #4f46e5;
  --color-primary-light:  rgba(99, 102, 241, 0.08);
  --color-primary-glow:   rgba(99, 102, 241, 0.15);
  --color-secondary:      #1e293b;
  --color-accent:         #f59e0b;
  --color-accent-bg:      #fffbeb;
  --color-success:        #10b981;
  --color-success-bg:     #ecfdf5;
  --color-error:          #f43f5e;
  --color-error-bg:       #fff1f2;
  --color-warning:        #f59e0b;
  --color-warning-bg:     #fffbeb;
  --color-info:           #3b82f6;
  --color-info-bg:        #eff6ff;

  /* Slate scale */
  --slate-50:  #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  /* Semantic colors */
  --bg:               #ffffff;
  --bg-alt:           #f8fafc;
  --bg-dark:          #0b1120;
  --text:             #111827;
  --text-secondary:   #6b7280;
  --text-muted:       #9ca3af;
  --text-on-dark:     #f1f5f9;
  --text-muted-dark:  #94a3b8;
  --border:           #e5e7eb;
  --border-dark:      rgba(255,255,255,0.08);

  /* Aliases for backward compat */
  --accent:           var(--color-primary);
  --accent-hover:     var(--color-primary-hover);
  --accent-light:     var(--color-primary-light);
  --accent-glow:      var(--color-primary-glow);
  --green:            var(--color-success);
  --green-bg:         var(--color-success-bg);
  --orange:           var(--color-accent);
  --orange-bg:        var(--color-accent-bg);
  --red:              var(--color-error);
  --red-bg:           var(--color-error-bg);

  /* Typography */
  --font-sans:   'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-heading: 'Space Grotesk', sans-serif;
  --font-mono:   'JetBrains Mono', 'Fira Code', monospace;

  /* Font sizes */
  --text-xs:    11px;
  --text-sm:    13px;
  --text-base:  15px;
  --text-md:    16px;
  --text-lg:    18px;
  --text-xl:    20px;
  --text-2xl:   24px;
  --text-3xl:   32px;
  --text-4xl:   40px;

  /* Line heights */
  --lh-tight:  1.2;
  --lh-snug:   1.4;
  --lh-body:   1.6;
  --lh-loose:  1.8;

  /* Spacing */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Radii */
  --radius-sm:  6px;
  --radius:     12px;
  --radius-lg:  20px;
  --radius-xl:  28px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm:  0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:  0 4px 24px rgba(0,0,0,0.06);
  --shadow-lg:  0 20px 60px rgba(0,0,0,0.08);
  --shadow-xl:  0 24px 80px rgba(0,0,0,0.12);
  --shadow-primary: 0 8px 24px rgba(99, 102, 241, 0.3);

  /* Layout */
  --max-w:     1200px;
  --nav-h:     64px;
  --mobile-nav-h: 60px;

  /* Transitions */
  --transition-fast:   0.1s ease;
  --transition:        0.2s ease;
  --transition-slow:   0.35s ease;
  --transition-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ─── RESET ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text);
  background: var(--bg);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }

/* Focus visible — accessibility */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Skip to content */
.skip-to-content {
  position: absolute;
  top: -100px;
  left: 16px;
  padding: 8px 16px;
  background: var(--color-primary);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: var(--text-sm);
  z-index: 9999;
  transition: top 0.2s;
}
.skip-to-content:focus { top: 16px; }

/* ─── LAYOUT ─────────────────────────────────────────────────────────────── */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
}
@media (min-width: 768px) { .container { padding: 0 48px; } }

/* Bottom-nav padding on mobile */
@media (max-width: 767px) {
  body.has-bottom-nav main,
  body.has-bottom-nav .page-content {
    padding-bottom: calc(var(--mobile-nav-h) + 16px);
  }
}

/* ─── TYPOGRAPHY ─────────────────────────────────────────────────────────── */
h1,h2,h3,h4,h5,h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: var(--lh-tight);
  letter-spacing: -0.03em;
  color: var(--text);
}

.mono { font-family: var(--font-mono); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--color-primary); }
.text-success { color: var(--color-success); }
.text-error { color: var(--color-error); }
.text-warning { color: var(--color-warning); }

/* ─── BUTTONS ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  min-height: 44px; /* accessibility — touch target */
  user-select: none;
  -webkit-user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled, .btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-primary);
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
}
.btn-ghost:hover {
  background: var(--bg-alt);
  color: var(--text);
}

.btn-danger {
  background: var(--color-error);
  color: #fff;
}
.btn-danger:hover {
  background: #e11d3c;
  transform: translateY(-1px);
}

.btn-success {
  background: var(--color-success);
  color: #fff;
}

.btn-sm {
  font-size: var(--text-xs);
  padding: 6px 14px;
  min-height: 32px;
}

.btn-lg {
  font-size: var(--text-base);
  padding: 14px 28px;
  min-height: 52px;
}

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

.btn-block { width: 100%; }

/* Loading state */
.btn.loading {
  pointer-events: none;
  opacity: 0.7;
}
.btn.loading::after {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ─── CARDS ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
}
.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--color-primary-glow);
}

.card-stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}
.card-stat .stat-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: var(--space-2);
}
.card-stat .stat-value {
  font-size: var(--text-3xl);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text);
  font-family: var(--font-mono);
}
.card-stat .stat-change {
  font-size: var(--text-xs);
  font-weight: 600;
  margin-top: var(--space-1);
}
.card-stat .stat-change.up { color: var(--color-success); }
.card-stat .stat-change.down { color: var(--color-error); }

/* ─── BADGES ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge-primary  { background: var(--color-primary-light); color: var(--color-primary); }
.badge-success  { background: var(--color-success-bg); color: var(--color-success); }
.badge-error    { background: var(--color-error-bg); color: var(--color-error); }
.badge-warning  { background: var(--color-accent-bg); color: #b45309; }
.badge-info     { background: var(--color-info-bg); color: var(--color-info); }
.badge-neutral  { background: var(--slate-100); color: var(--slate-600); }

.badge-bronze   { background: #fef3c7; color: #92400e; }
.badge-silver   { background: #f1f5f9; color: #475569; }
.badge-gold     { background: #fef3c7; color: #b45309; }
.badge-platinum { background: var(--color-primary-light); color: var(--color-primary); }

/* Score badge */
.badge-score {
  font-family: var(--font-mono);
  font-size: var(--text-md);
  padding: 6px 14px;
  border-radius: var(--radius);
}

/* ─── FORMS ──────────────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
}
.form-label .required { color: var(--color-error); margin-left: 2px; }

.form-input,
.form-select,
.form-textarea {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  width: 100%;
  min-height: 44px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}
.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-muted); }
.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--bg-alt);
}

.form-input.error,
.form-select.error,
.form-textarea.error {
  border-color: var(--color-error);
}
.form-input.error:focus,
.form-textarea.error:focus {
  box-shadow: 0 0 0 3px var(--color-error-bg);
}

.form-textarea { resize: vertical; min-height: 100px; line-height: var(--lh-body); }

.form-error {
  font-size: var(--text-xs);
  color: var(--color-error);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}
.form-error::before { content: '⚠'; }

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.form-checkbox,
.form-radio {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  user-select: none;
}
.form-checkbox input,
.form-radio input {
  width: 18px;
  height: 18px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

/* ─── MODALS ─────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.15s ease;
}
.modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.2s var(--transition-spring);
  position: relative;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-6);
}
.modal-title {
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.modal-close {
  background: var(--bg-alt);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 18px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  flex-shrink: 0;
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-6);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border);
}

/* ─── TOASTS ─────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 80px;
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: all;
  background: var(--slate-900);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-xl);
  animation: slideInRight 0.25s var(--transition-spring);
  max-width: 340px;
  min-width: 240px;
}
.toast.success { border-left: 3px solid var(--color-success); }
.toast.error   { border-left: 3px solid var(--color-error); }
.toast.warning { border-left: 3px solid var(--color-warning); }
.toast.info    { border-left: 3px solid var(--color-primary); }
.toast-icon { font-size: 16px; flex-shrink: 0; }
.toast-msg  { flex: 1; line-height: 1.4; }
.toast-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
  padding: 0 2px;
}
.toast-close:hover { color: #fff; }
.toast.fade-out { animation: slideOutRight 0.2s ease forwards; }

/* ─── TABS ───────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
}
.tab {
  flex: 1;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ─── ACCORDION ─────────────────────────────────────────────────────────── */
.accordion-item {
  border-bottom: 1px solid var(--border);
}
.accordion-trigger {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-5) 0;
  font-size: var(--text-base);
  font-weight: 600;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text);
  text-align: left;
  transition: color var(--transition);
}
.accordion-trigger:hover { color: var(--color-primary); }
.accordion-icon {
  font-size: 20px;
  transition: transform var(--transition);
  color: var(--text-secondary);
  flex-shrink: 0;
}
.accordion-trigger[aria-expanded="true"] .accordion-icon { transform: rotate(180deg); }
.accordion-panel {
  display: none;
  padding-bottom: var(--space-5);
  font-size: var(--text-base);
  color: var(--text-secondary);
  line-height: var(--lh-loose);
}
.accordion-panel.open { display: block; }

/* ─── TOOLTIPS ───────────────────────────────────────────────────────────── */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--slate-900);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: 500;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ─── LOADING SKELETONS ──────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--slate-100) 25%, var(--slate-200) 50%, var(--slate-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius);
}
.skeleton-text { height: 16px; margin-bottom: 8px; }
.skeleton-text:last-child { width: 65%; }
.skeleton-title { height: 24px; margin-bottom: 12px; }
.skeleton-card {
  height: 180px;
  border-radius: var(--radius-lg);
}

/* ─── EMPTY STATES ───────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 64px 24px;
  gap: var(--space-4);
}
.empty-state-icon {
  font-size: 48px;
  line-height: 1;
  opacity: 0.4;
}
.empty-state-title {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text);
}
.empty-state-desc {
  font-size: var(--text-base);
  color: var(--text-secondary);
  max-width: 340px;
  line-height: var(--lh-body);
}

/* ─── MOBILE BOTTOM NAV ──────────────────────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--mobile-nav-h);
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  z-index: 900;
  padding: 0 env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}
@media (max-width: 767px) { .bottom-nav { display: flex; } }

.bottom-nav-items {
  display: flex;
  align-items: stretch;
  width: 100%;
  height: 100%;
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: color var(--transition);
  cursor: pointer;
  background: none;
  border: none;
  padding: 6px 4px;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.bottom-nav-item:hover,
.bottom-nav-item.active { color: var(--color-primary); }
.bottom-nav-icon {
  font-size: 22px;
  line-height: 1;
}
.bottom-nav-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 16px);
  background: var(--color-error);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  border: 2px solid #fff;
}

/* ─── NOTIFICATIONS ──────────────────────────────────────────────────────── */
.notif-btn {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 22px;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.notif-btn:hover {
  background: var(--bg-alt);
  color: var(--text);
}
.notif-count {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--color-error);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  border: 2px solid var(--bg);
  line-height: 1;
}

.notif-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 360px;
  max-height: 480px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 500;
  overflow: hidden;
  animation: slideDown 0.2s var(--transition-spring);
}
@media (max-width: 640px) {
  .notif-dropdown {
    width: calc(100vw - 32px);
    right: -8px;
  }
}
.notif-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.notif-header-title {
  font-size: var(--text-sm);
  font-weight: 700;
}
.notif-mark-all {
  font-size: var(--text-xs);
  color: var(--color-primary);
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 600;
}
.notif-list {
  overflow-y: auto;
  max-height: 380px;
}
.notif-item {
  display: flex;
  gap: var(--space-3);
  padding: 12px 16px;
  cursor: pointer;
  transition: background var(--transition-fast);
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg-alt); }
.notif-item.unread { background: var(--color-primary-light); }
.notif-item.unread:hover { background: rgba(99, 102, 241, 0.12); }
.notif-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  flex-shrink: 0;
  margin-top: 6px;
}
.notif-item-icon {
  font-size: 20px;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-alt);
  border-radius: var(--radius);
}
.notif-item-body { flex: 1; min-width: 0; }
.notif-item-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 2px;
}
.notif-item-msg {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: 1.4;
}
.notif-item-time {
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.notif-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.notif-footer a {
  font-size: var(--text-xs);
  color: var(--color-primary);
  font-weight: 600;
  text-decoration: none;
}

/* ─── COMMAND PALETTE ────────────────────────────────────────────────────── */
.cmd-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 3000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  animation: fadeIn 0.1s ease;
}
.cmd-palette {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 560px;
  max-width: calc(100vw - 32px);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: slideDown 0.15s var(--transition-spring);
}
.cmd-search {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.cmd-search-icon { font-size: 20px; color: var(--text-muted); }
.cmd-input {
  flex: 1;
  font-size: var(--text-lg);
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
}
.cmd-input::placeholder { color: var(--text-muted); }
.cmd-results {
  max-height: 360px;
  overflow-y: auto;
  padding: 8px;
}
.cmd-result {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.cmd-result:hover,
.cmd-result.focused { background: var(--bg-alt); }
.cmd-result-icon {
  width: 32px;
  height: 32px;
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.cmd-result-text { flex: 1; }
.cmd-result-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
}
.cmd-result-desc {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}
.cmd-shortcut {
  font-size: var(--text-xs);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  color: var(--text-secondary);
}
.cmd-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 16px;
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.cmd-footer .hint { display: flex; align-items: center; gap: 6px; }
.cmd-footer .key {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
}

/* ─── AUTOSAVE INDICATOR ─────────────────────────────────────────────────── */
.autosave-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  color: var(--text-muted);
  transition: color var(--transition);
}
.autosave-indicator.saving { color: var(--color-warning); }
.autosave-indicator.saved  { color: var(--color-success); }
.autosave-indicator.error  { color: var(--color-error); }
.autosave-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.autosave-indicator.saving .autosave-dot {
  animation: pulse 1s infinite;
}

/* ─── PWA INSTALL BANNER ─────────────────────────────────────────────────── */
.pwa-banner {
  position: fixed;
  bottom: 72px;
  left: 16px;
  right: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  z-index: 800;
  animation: slideUp 0.3s var(--transition-spring);
}
.pwa-banner-icon {
  width: 48px;
  height: 48px;
  background: var(--color-primary-light);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}
.pwa-banner-text { flex: 1; }
.pwa-banner-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text);
}
.pwa-banner-desc {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}
.pwa-banner-actions { display: flex; gap: 8px; }

/* ─── OFFLINE BANNER ─────────────────────────────────────────────────────── */
.offline-banner {
  position: fixed;
  top: var(--nav-h);
  left: 0;
  right: 0;
  background: var(--slate-800);
  color: #fff;
  padding: 10px 24px;
  text-align: center;
  font-size: var(--text-sm);
  font-weight: 600;
  z-index: 800;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.offline-banner.visible { display: flex; }
.offline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-error);
  animation: pulse 1.5s infinite;
}

/* ─── SPLASH SCREEN ──────────────────────────────────────────────────────── */
#splash-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}
.splash-logo {
  font-size: 48px;
  font-weight: 800;
  letter-spacing: -2px;
  color: var(--text);
  animation: logoPulse 0.8s var(--transition-spring) forwards;
}
.splash-logo span { color: var(--color-primary); }
.splash-bar {
  width: 80px;
  height: 3px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.splash-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), #a855f7);
  border-radius: var(--radius-full);
  animation: loadBar 0.8s ease forwards;
}

/* ─── SECTION ANIMATIONS ─────────────────────────────────────────────────── */
.fade-in {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ─── SECTION LABELS ─────────────────────────────────────────────────────── */
.section-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--color-primary);
  margin-bottom: 12px;
}
.section-title {
  font-size: clamp(26px, 3.5vw, 40px);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.15;
  margin-bottom: 16px;
}
.section-desc {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  max-width: 560px;
  line-height: var(--lh-loose);
  margin-bottom: 56px;
}

/* ─── CONFETTI ───────────────────────────────────────────────────────────── */
.confetti-particle {
  position: fixed;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  z-index: 9998;
  pointer-events: none;
  animation: confettiFall 1.2s ease-in forwards;
}

/* ─── KEYFRAMES ──────────────────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideOutRight {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
@keyframes logoPulse {
  0%   { opacity: 0; transform: scale(0.8); }
  60%  { opacity: 1; transform: scale(1.05); }
  100% { transform: scale(1); }
}
@keyframes loadBar {
  from { width: 0; }
  to   { width: 100%; }
}
@keyframes confettiFall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}
@keyframes countUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── TABLE → CARD RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 767px) {
  .table-responsive {
    display: none;
  }
  .card-list {
    display: block;
  }
}
@media (min-width: 768px) {
  .table-responsive {
    display: block;
  }
  .card-list {
    display: none;
  }
}

/* ─── KEYBOARD SHORTCUTS MODAL ───────────────────────────────────────────── */
.shortcuts-modal .shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.shortcuts-modal .shortcut-row:last-child { border-bottom: none; }
.shortcut-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.shortcut-keys {
  display: flex;
  gap: 4px;
}
.shortcut-key {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--text);
}
