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

:root {
  --bg: #f8fafc;
  --card-bg: #fff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

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

.container { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem; }

/* Nav */
.nav {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.nav-brand a { font-weight: 700; font-size: 1.25rem; color: var(--primary); text-decoration: none; }
.nav-links { display: flex; align-items: center; gap: 1.25rem; font-size: 0.9rem; }
.nav-user { color: var(--text-muted); }
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 0.9rem; }

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
}
.card h3 { margin-bottom: 1rem; font-size: 1rem; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.card-actions { margin-top: 1rem; display: flex; gap: 0.5rem; }

/* Grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 768px) { .grid-2 { grid-template-columns: 1fr; } }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th, .table td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
.table th { font-weight: 600; color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.table tr:hover td { background: #f1f5f9; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 0.875rem;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: #f1f5f9; text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }

/* Badges */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #e2e8f0;
  color: #475569;
}
.badge-sm { font-size: 0.65rem; padding: 0.1rem 0.4rem; }
/* Paid channels */
.badge-paid_search { background: #dbeafe; color: #1e40af; }
.badge-paid_social { background: #fce7f3; color: #9d174d; }
.badge-paid_video { background: #fae8ff; color: #86198f; }
.badge-paid_shopping { background: #fff7ed; color: #9a3412; }
.badge-paid_other { background: #f5f5f4; color: #57534e; }
.badge-display { background: #fce7f3; color: #831843; }
.badge-cross_network { background: #ecfccb; color: #3f6212; }
/* Organic channels */
.badge-organic_search { background: #d1fae5; color: #065f46; }
.badge-organic_social { background: #ede9fe; color: #5b21b6; }
.badge-organic_video { background: #f3e8ff; color: #7c3aed; }
.badge-organic_shopping { background: #ffedd5; color: #c2410c; }
/* Other channels */
.badge-email { background: #fef3c7; color: #92400e; }
.badge-referral { background: #e0e7ff; color: #3730a3; }
.badge-direct { background: #f1f5f9; color: #475569; }
.badge-affiliates { background: #ccfbf1; color: #134e4a; }
.badge-audio { background: #fef9c3; color: #854d0e; }
.badge-sms { background: #cffafe; color: #155e75; }
.badge-mobile_push { background: #ffe4e6; color: #9f1239; }
.badge-unassigned { background: #f1f5f9; color: #94a3b8; }
/* Event types */
.badge-conversion { background: #d1fae5; color: #065f46; font-weight: 700; }
.badge-pageview { background: #f1f5f9; color: #475569; }

/* Timeline */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before {
  content: '';
  position: absolute;
  left: 0.5rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.timeline-item { position: relative; margin-bottom: 1.5rem; }
.timeline-dot {
  position: absolute;
  left: -1.75rem;
  top: 0.25rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--border);
  border: 2px solid var(--bg);
}
.timeline-form_submission .timeline-dot { background: var(--success); }
.timeline-content { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 1rem; }
.timeline-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.25rem; }
.timeline-header time { font-size: 0.8rem; color: var(--text-muted); }

/* UTM tags */
.utm-tags { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-top: 0.25rem; }
.tag {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  background: #f1f5f9;
  border-radius: 4px;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Misc */
.text-muted { color: var(--text-muted); }
.truncate { max-width: 400px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.breadcrumb { font-size: 0.85rem; margin-bottom: 1rem; color: var(--text-muted); }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb strong { color: var(--text); }
h1 { margin-bottom: 0.5rem; }
h2 { margin: 1.5rem 0 1rem; }
.alert { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.pagination { display: flex; gap: 0.25rem; margin-top: 1rem; }

/* Login */
.login-container { max-width: 400px; margin: 4rem auto; }
.login-form label { display: block; margin-bottom: 1rem; font-weight: 500; }
.login-form input { display: block; width: 100%; margin-top: 0.25rem; padding: 0.5rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: 1rem; }
.login-form button { width: 100%; margin-top: 0.5rem; }

/* Admin forms */
.form-inline { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.form-inline label { font-weight: 500; font-size: 0.85rem; }
.form-inline input, .form-inline select { display: block; margin-top: 0.25rem; padding: 0.4rem 0.5rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.9rem; }

code { background: #f1f5f9; padding: 0.15rem 0.35rem; border-radius: 4px; font-size: 0.85rem; }
pre { background: #f1f5f9; padding: 1rem; border-radius: var(--radius); overflow-x: auto; }
pre code { background: none; padding: 0; }
