/* ============================================
   PROTON — Dark Theme
   ============================================ */

:root {
  --bg: #0f0f14;
  --surface: #1a1a24;
  --surface-hover: #22222e;
  --border: #2a2a3a;
  --border-light: #333346;
  --text: #e4e4ef;
  --text-secondary: #8888a0;
  --text-muted: #5a5a72;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --success: #22c55e;
  --success-dim: rgba(34, 197, 94, 0.15);
  --warning: #f59e0b;
  --warning-dim: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-dim: rgba(239, 68, 68, 0.15);
  --gold: #eab308;
  --purple: #a855f7;
  --blue: #3b82f6;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace;
  --sidebar-width: 200px;
  --header-height: 48px;
  --radius: 6px;
}

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

html, body {
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

/* ============================================
   LAYOUT
   ============================================ */

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 1px;
  border-bottom: 1px solid var(--border);
}

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}

.sidebar-nav a:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.sidebar-nav a.active {
  color: var(--accent);
  background: rgba(99, 102, 241, 0.08);
  border-right: 2px solid var(--accent);
}

.sidebar-nav .nav-icon {
  width: 18px;
  text-align: center;
  font-size: 14px;
}

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

.sidebar-bottom button {
  width: 100%;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 8px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
}

.sidebar-bottom button:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-title {
  font-size: 14px;
  font-weight: 600;
}

.page-content {
  padding: 20px 24px;
}

/* ============================================
   LOGIN
   ============================================ */

.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 40px;
  width: 360px;
}

.login-box h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.login-box p {
  color: var(--text-secondary);
  margin-bottom: 24px;
  font-size: 13px;
}

/* ============================================
   FORMS
   ============================================ */

input, select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}

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

input[type="color"] {
  padding: 2px;
  height: 36px;
  cursor: pointer;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.form-group {
  margin-bottom: 16px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row > * {
  flex: 1;
}

.form-error {
  color: var(--danger);
  font-size: 12px;
  margin-top: 4px;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.checkbox-group input[type="checkbox"] {
  width: auto;
  cursor: pointer;
  accent-color: var(--accent);
}

.checkbox-group label {
  margin-bottom: 0;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle input[type="checkbox"] {
  width: auto;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  font-family: var(--font-sans);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover {
  border-color: var(--border-light);
  background: var(--surface-hover);
}

.btn-danger {
  background: var(--danger-dim);
  color: var(--danger);
  border-color: transparent;
}
.btn-danger:hover {
  background: var(--danger);
  color: white;
}

.btn-success {
  background: var(--success-dim);
  color: var(--success);
}
.btn-success:hover {
  background: var(--success);
  color: white;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 11px;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

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

/* ============================================
   TABS
   ============================================ */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: var(--font-sans);
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ============================================
   TABLE
   ============================================ */

.table-container {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

thead th {
  background: var(--surface);
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

thead th:hover {
  color: var(--text);
}

thead th.sorted-asc::after { content: ' \u2191'; }
thead th.sorted-desc::after { content: ' \u2193'; }

tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

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

tbody tr.expandable {
  cursor: pointer;
}

tbody tr.sub-row td {
  padding-left: 32px;
  font-size: 11px;
  color: var(--text-secondary);
}

tbody tr.sub-row:hover td {
  color: var(--text);
}

tbody tr.total-row {
  background: var(--surface);
  font-weight: 600;
}

tbody tr.total-row td {
  border-top: 2px solid var(--border);
}

.num {
  font-family: var(--font-mono);
  text-align: right;
}

.positive { color: var(--success); }
.negative { color: var(--danger); }

/* ============================================
   CARDS
   ============================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

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

.card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text);
}

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

/* ============================================
   FILTERS
   ============================================ */

.filters {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.date-btn {
  padding: 5px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: var(--font-sans);
}

.date-btn:hover {
  border-color: var(--border-light);
  color: var(--text);
}

.date-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.filter-select {
  width: auto;
  min-width: 160px;
}

/* ============================================
   MODAL
   ============================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 90%;
  max-width: 640px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.modal-large {
  max-width: 800px;
}

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

.modal-header h2 {
  font-size: 15px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

/* ============================================
   WIZARD STEPS
   ============================================ */

.wizard-steps {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
}

.wizard-step {
  flex: 1;
  padding: 8px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}

.wizard-step.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.wizard-step.done {
  color: var(--success);
  border-bottom-color: var(--success);
}

/* ============================================
   URL PREVIEW
   ============================================ */

.url-preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  word-break: break-all;
  margin-top: 12px;
}

.url-copy {
  display: flex;
  gap: 8px;
  align-items: start;
  margin-bottom: 12px;
}

.url-copy input {
  font-family: var(--font-mono);
  font-size: 11px;
}

/* ============================================
   FUNNEL
   ============================================ */

.funnel-table {
  width: 100%;
}

.funnel-step {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.funnel-arrow {
  color: var(--text-muted);
  font-size: 11px;
  padding: 4px 0 4px 20px;
}

.funnel-summary {
  margin-top: 16px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 13px;
}

/* ============================================
   DEBUG TIMELINE
   ============================================ */

.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding: 8px 0 16px 16px;
}

.timeline-dot {
  position: absolute;
  left: -20px;
  top: 12px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg);
}

.timeline-dot.page_view { border-color: var(--blue); background: var(--blue); }
.timeline-dot.cta_click { border-color: var(--warning); background: var(--warning); }
.timeline-dot.return_visit { border-color: var(--success); background: var(--success); }
.timeline-dot.registration { border-color: var(--purple); background: var(--purple); }
.timeline-dot.ftd, .timeline-dot.qftd { border-color: var(--gold); background: var(--gold); }
.timeline-dot.bounce { border-color: var(--danger); background: var(--danger); }
.timeline-dot.conversion { border-color: var(--gold); background: var(--gold); }
.timeline-dot.capi { border-color: var(--accent); background: var(--accent); }

.timeline-time {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.timeline-type {
  font-size: 12px;
  font-weight: 600;
  margin: 2px 0;
}

.timeline-meta {
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 8px;
  margin-top: 4px;
  font-family: var(--font-mono);
  word-break: break-all;
}

/* ============================================
   VISITOR CARD
   ============================================ */

.visitor-card {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.visitor-field {
  font-size: 12px;
}

.visitor-field dt {
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.visitor-field dd {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ============================================
   TAGS
   ============================================ */

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.tag-active { background: var(--success-dim); color: var(--success); }
.tag-paused { background: var(--warning-dim); color: var(--warning); }
.tag-archived, .tag-dead { background: var(--danger-dim); color: var(--danger); }
.tag-cpa { background: rgba(99, 102, 241, 0.15); color: var(--accent); }
.tag-qftd { background: rgba(168, 85, 247, 0.15); color: var(--purple); }
.tag-revshare { background: rgba(59, 130, 246, 0.15); color: var(--blue); }

/* ============================================
   MAPPING LIST
   ============================================ */

.mapping-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.mapping-row input, .mapping-row select {
  flex: 1;
}

.mapping-row button {
  flex-shrink: 0;
}

/* ============================================
   LAUNCH RESULT
   ============================================ */

.launch-result {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.launch-result h4 {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  margin-top: 12px;
}

.launch-result h4:first-child {
  margin-top: 0;
}

/* ============================================
   UTILITIES
   ============================================ */

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-right { text-align: right; }
.font-mono { font-family: var(--font-mono); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.hidden { display: none; }

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-secondary);
  gap: 8px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

.empty-state p {
  margin-bottom: 12px;
}
