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

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #111118;
  --bg-card: rgba(255, 255, 255, 0.035);
  --bg-card-hover: rgba(255, 255, 255, 0.065);
  --bg-glass: rgba(255, 255, 255, 0.04);
  --bg-input: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(139, 92, 246, 0.4);

  --text-primary: #f0f0f8;
  --text-secondary: #9898b8;
  --text-muted: #5a5a78;

  --accent: #8b5cf6;
  --accent-2: #06b6d4;
  --accent-success: #10b981;
  --accent-warning: #f59e0b;
  --accent-error: #ef4444;
  --accent-idle: #4b5563;

  --gradient-main: linear-gradient(135deg, #8b5cf6 0%, #06b6d4 100%);
  --gradient-card: linear-gradient(145deg, rgba(139, 92, 246, 0.08), rgba(6, 182, 212, 0.04));

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --shadow-sm: 0 2px 12px rgba(0,0,0,0.4);
  --shadow-md: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.15);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  --panel-width: 360px;
  --topbar-height: 72px;
}

/* ─── Base ──────────────────────────────────────────────────── */
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Noise texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.025'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* ─── Layout ────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ─── Top Bar ───────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-height);
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 24px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--gradient-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  color: white;
  box-shadow: var(--shadow-glow);
}

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

.topbar-stats {
  display: flex;
  gap: 8px;
  flex: 1;
  justify-content: center;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.stat-chip .stat-num {
  font-weight: 700;
  font-size: 14px;
}

.stat-chip.applied .stat-num { color: var(--accent-success); }
.stat-chip.pending .stat-num { color: var(--accent-warning); }
.stat-chip.total .stat-num { color: var(--accent); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* ─── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  user-select: none;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--gradient-main);
  color: white;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.35);
}

.btn-primary:hover {
  box-shadow: 0 6px 28px rgba(139, 92, 246, 0.5);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

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

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

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

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  justify-content: center;
}

/* ─── Main content area ─────────────────────────────────────── */
.main-content {
  display: flex;
  flex: 1;
  gap: 0;
}

/* ─── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--panel-width);
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height));
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.sidebar-header {
  padding: 24px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.sidebar-header p {
  font-size: 12px;
  color: var(--text-muted);
}

/* Profile Form */
.profile-form {
  padding: 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 4px 0 2px;
  border-top: 1px solid var(--border);
  margin-top: 2px;
}

.form-section-title:first-child { border-top: none; margin-top: 0; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

input, textarea, select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 13px;
  padding: 9px 12px;
  transition: all 0.2s;
  width: 100%;
  outline: none;
  appearance: none;
}

select option { background: var(--bg-secondary); }

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  background: rgba(139, 92, 246, 0.06);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.profile-complete-bar {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

.progress-track {
  height: 3px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--gradient-main);
  border-radius: 4px;
  transition: width 0.4s ease;
}

/* ─── Grid Area ─────────────────────────────────────────────── */
.grid-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.grid-toolbar {
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 10, 15, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-chip {
  padding: 5px 14px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  transition: all 0.2s;
}

.filter-chip:hover {
  color: var(--text-secondary);
  border-color: rgba(255,255,255,0.15);
}

.filter-chip.active {
  background: var(--accent);
  color: white;
  border-color: transparent;
  box-shadow: 0 2px 12px rgba(139, 92, 246, 0.3);
}

.toolbar-spacer { flex: 1; }

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-wrap input {
  padding-left: 36px;
  width: 200px;
  height: 36px;
}

.search-icon {
  position: absolute;
  left: 11px;
  color: var(--text-muted);
  pointer-events: none;
  font-size: 14px;
}

/* ─── Accelerator Grid ──────────────────────────────────────── */
.acc-grid {
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  flex: 1;
}

/* ─── Accelerator Card ──────────────────────────────────────── */
.acc-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  cursor: default;
}

.acc-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: var(--gradient-main);
  opacity: 0;
  transition: opacity 0.25s;
}

.acc-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255,255,255,0.12);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md), var(--shadow-glow);
}

.acc-card:hover::before { opacity: 1; }

/* Status variants */
.acc-card.status-applying {
  border-color: rgba(139, 92, 246, 0.4);
  box-shadow: 0 0 30px rgba(139, 92, 246, 0.1);
}

.acc-card.status-applied {
  border-color: rgba(16, 185, 129, 0.35);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.08);
}

.acc-card.status-error {
  border-color: rgba(239, 68, 68, 0.35);
}

/* Color accent line left */
.acc-card-accent {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 3px;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  opacity: 0.7;
}

/* Card header */
.card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.acc-logo {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: white;
  letter-spacing: -0.3px;
  flex-shrink: 0;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.card-title-group {
  flex: 1;
  min-width: 0;
}

.card-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 2px;
}

.card-handle {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.card-status {
  flex-shrink: 0;
}

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  transition: all 0.2s;
}

.status-badge.idle {
  background: rgba(75, 85, 99, 0.2);
  color: var(--accent-idle);
  border: 1px solid rgba(75, 85, 99, 0.3);
}

.status-badge.applying {
  background: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
  border: 1px solid rgba(139, 92, 246, 0.3);
  animation: pulse-badge 1.5s ease-in-out infinite;
}

.status-badge.applied {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.error {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-badge.queued {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Dot indicator */
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-badge.applying .status-dot {
  animation: pulse-dot 1s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.5); opacity: 0.7; }
}

/* Deal info */
.card-deal {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.deal-amount {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  line-height: 1;
}

.deal-equity {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.deal-note {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Tags */
.card-tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.tag {
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

/* Progress section */
.card-progress {
  display: none;
  flex-direction: column;
  gap: 8px;
}

.acc-card.status-applying .card-progress,
.acc-card.status-queued .card-progress { display: flex; }

.progress-steps {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.progress-step {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 7px;
  opacity: 0;
  transform: translateX(-6px);
  transition: all 0.3s ease;
}

.progress-step.active {
  color: var(--text-secondary);
  opacity: 1;
  transform: translateX(0);
}

.progress-step.done {
  color: var(--accent-success);
  opacity: 0.7;
  transform: translateX(0);
}

.step-icon { flex-shrink: 0; font-size: 11px; }

.card-progress-bar {
  height: 3px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.card-progress-fill {
  height: 100%;
  background: var(--gradient-main);
  border-radius: 4px;
  width: 0%;
  transition: width 0.5s ease;
}

/* Card footer */
.card-footer {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: auto;
}

.card-apply-btn {
  flex: 1;
}

.card-link-btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: all 0.2s;
}

.card-link-btn:hover {
  color: var(--accent-2);
  border-color: var(--accent-2);
}

/* Applied overlay */
.applied-check {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #34d399;
  font-weight: 600;
  width: 100%;
  justify-content: center;
}

.acc-card.status-applied .applied-check { display: flex; }
.acc-card.status-applied .card-apply-btn { display: none; }

/* ─── Apply All Animation ───────────────────────────────────── */
@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

.btn-apply-all-loading {
  background: linear-gradient(90deg, #8b5cf6 25%, #a78bfa 50%, #8b5cf6 75%);
  background-size: 200%;
  animation: shimmer 1.5s infinite;
}

/* ─── Toast ─────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  animation: toast-in 0.3s ease forwards;
  pointer-events: all;
  max-width: 320px;
  backdrop-filter: blur(16px);
}

.toast.success { border-left: 3px solid var(--accent-success); }
.toast.error { border-left: 3px solid var(--accent-error); }
.toast.info { border-left: 3px solid var(--accent); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-12px) scale(0.95); }
}

/* ─── Empty state ───────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  gap: 12px;
  color: var(--text-muted);
  text-align: center;
  font-size: 14px;
}

.empty-state-icon { font-size: 40px; opacity: 0.4; }

/* ─── Confirm Modal ─────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.visible { display: flex; }

.modal {
  background: var(--bg-secondary);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-xl);
  padding: 32px;
  max-width: 460px;
  width: 100%;
  box-shadow: var(--shadow-md);
  animation: modal-in 0.3s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.94) translateY(16px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.modal p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 24px;
  line-height: 1.6;
}

.modal-highlight {
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 24px;
  font-size: 13px;
  color: var(--text-secondary);
}

.modal-highlight strong { color: var(--text-primary); }

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ─── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --panel-width: 300px; }
  .topbar-stats { display: none; }
}

@media (max-width: 700px) {
  .main-content { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
  }
  .acc-grid { grid-template-columns: 1fr; }
  :root { --panel-width: 100%; }
}
