:root {
  --color-bg: #f3f1f9;
  --color-surface: #ffffff;
  --color-surface-muted: #f2edfc;
  --color-border: #ddd4f0;
  --color-primary: #7c3aed;
  --color-primary-dark: #5b21b6;
  --color-primary-light: #ede9fe;
  --color-primary-soft: #f7f4ff;
  --color-text: #251f33;
  --color-text-muted: #6b6280;
  --color-success: #17915a;
  --color-success-light: #e2f8ee;
  --color-danger: #d63a46;
  --color-danger-light: #fbe9ea;
  --color-warning: #a9781f;
  --color-warning-light: #fbf1de;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(91, 33, 182, 0.06), 0 6px 20px rgba(91, 33, 182, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
}

a { color: var(--color-primary); transition: color 0.15s ease; }
a:hover { color: var(--color-primary-dark); }

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px 48px;
}

/* ---- Nav ---- */
.nav {
  background: linear-gradient(180deg, #ffffff, var(--color-primary-soft));
  border-bottom: 3px solid var(--color-primary);
  margin-bottom: 32px;
}

.nav-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-brand {
  font-weight: 800;
  color: var(--color-primary-dark);
  text-decoration: none;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  margin-right: auto;
}

.nav-links { display: flex; gap: 18px; align-items: center; }
.nav-links a {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.nav-links a:hover { color: var(--color-primary); border-color: var(--color-primary-light); }
.nav-links form { display: inline; }

.nav-user {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.badge-admin {
  background: var(--color-primary);
  color: white;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ---- View-as banner ---- */
.viewing-banner {
  background: linear-gradient(90deg, var(--color-primary-dark), var(--color-primary));
  color: white;
  padding: 10px 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
}

.viewing-banner form { display: inline; }
.viewing-banner button {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: white;
  padding: 4px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s ease;
}
.viewing-banner button:hover { background: rgba(255, 255, 255, 0.25); }

/* ---- Cards / surfaces ---- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-top: 3px solid var(--color-primary);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.card h2, .card h3 { margin-top: 0; color: var(--color-primary-dark); }

/* ---- Auth pages ---- */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--color-bg), var(--color-primary-light) 70%, var(--color-primary) 140%);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--color-surface);
  border-radius: 12px;
  padding: 36px 32px;
  box-shadow: 0 8px 32px rgba(91, 33, 182, 0.18);
  border-top: 4px solid var(--color-primary);
}

.auth-card h1 {
  font-size: 1.4rem;
  margin: 0 0 4px;
  color: var(--color-primary-dark);
  font-weight: 800;
}

.auth-card p.subtitle { color: var(--color-text-muted); margin-top: 0; margin-bottom: 24px; font-size: 0.9rem; }

.auth-footer {
  margin-top: 20px;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  text-align: center;
}

/* ---- Forms ---- */
label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 4px; color: var(--color-text); }

input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="datetime-local"], input[type="url"], textarea, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  background: var(--color-surface);
  color: var(--color-text);
  margin-bottom: 16px;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

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

.btn {
  display: inline-block;
  background: var(--color-primary);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.btn:hover { background: var(--color-primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(91, 33, 182, 0.25); }
.btn:active { transform: translateY(0); }
.btn-block { width: 100%; text-align: center; }
.btn-secondary { background: var(--color-surface-muted); color: var(--color-primary-dark); }
.btn-secondary:hover { background: var(--color-primary-light); box-shadow: none; }
.btn-danger { background: var(--color-danger); }
.btn-danger:hover { background: #b32d38; }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }

.form-row { display: flex; gap: 16px; }
.form-row > div { flex: 1; }
.form-status { font-size: 0.82rem; color: var(--color-text-muted); margin-left: 10px; }

/* ---- Alerts ---- */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 18px;
}
.alert-error { background: var(--color-danger-light); color: var(--color-danger); }
.alert-success { background: var(--color-success-light); color: var(--color-success); }
.alert-info { background: var(--color-primary-light); color: var(--color-primary-dark); }
.alert code {
  display: block;
  margin-top: 8px;
  padding: 8px 10px;
  background: white;
  border-radius: 4px;
  word-break: break-all;
  font-size: 0.82rem;
}

/* ---- Stat cards ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-top: 3px solid var(--color-primary);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-card .stat-value { font-size: 1.8rem; font-weight: 800; color: var(--color-primary-dark); }
.stat-card .stat-label { font-size: 0.78rem; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--color-border); font-size: 0.9rem; }
th { color: var(--color-primary-dark); font-weight: 700; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: var(--color-primary-soft); }
td.actions, th.actions { text-align: right; white-space: nowrap; }

/* ---- Status pills ---- */
.pill {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: capitalize;
}
.pill-saved, .pill-applied { background: var(--color-surface-muted); color: var(--color-primary-dark); }
.pill-online_assessment, .pill-interview { background: var(--color-primary); color: white; }
.pill-offer { background: var(--color-success); color: white; }
.pill-rejected, .pill-withdrawn { background: var(--color-danger); color: white; }

/* ---- Timeline ---- */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline-item {
  padding: 12px 0 12px 20px;
  border-left: 2px solid var(--color-border);
  margin-left: 6px;
  position: relative;
}
.timeline-item::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 17px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}
.timeline .event-meta { font-size: 0.78rem; color: var(--color-text-muted); margin-top: 2px; }
.timeline .event-source-email_scraper, .ev-source.event-source-email_scraper { color: var(--color-primary-dark); font-weight: 700; }

.timeline-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.timeline-actions { font-size: 0.78rem; white-space: nowrap; }
.timeline-actions a { font-weight: 600; }
.ev-description { margin-top: 2px; }

.timeline-edit-form { margin-top: 8px; }
.timeline-edit-form textarea { min-height: 60px; }

.quick-actions { display: flex; align-items: center; gap: 8px; margin: 16px 0 12px; flex-wrap: wrap; }
.quick-actions-label { font-size: 0.82rem; color: var(--color-text-muted); font-weight: 600; }

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.page-header h1 { margin: 0; font-size: 1.5rem; color: var(--color-primary-dark); }

.empty-state { color: var(--color-text-muted); padding: 32px 0; text-align: center; }

.slots-indicator { font-size: 0.85rem; color: var(--color-text-muted); font-weight: 600; }

.filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filters a {
  padding: 5px 13px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.filters a:hover { border-color: var(--color-primary); color: var(--color-primary); }
.filters a.active { background: var(--color-primary); border-color: var(--color-primary); color: white; }
