:root {
  color-scheme: light;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --bg: #f6f6f9;
  --surface: #fff;
  --primary: #2f80ed;
  --primary-dark: #2766ba;
  --border: #e0e3eb;
  --text: #1f2937;
  --muted: #6b7280;
  --success: #22c55e;
  --danger: #f43f5e;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.max-width {
  width: min(1100px, 100% - 2rem);
  margin-left: auto;
  margin-right: auto;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .max-width {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
}

.brand {
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: 0.05em;
}

nav a {
  margin-left: 1rem;
  text-decoration: none;
  color: var(--muted);
  font-weight: 500;
}

nav a:hover,
nav a:focus {
  color: var(--primary);
}

.user-nav {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.user-nav form {
  margin: 0;
}

.link-button {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  font-weight: 500;
}

.link-button:hover,
.link-button:focus {
  color: var(--primary);
}

main {
  padding: 2rem 0 3rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.04);
}

.grid {
  display: grid;
  gap: 1.5rem;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.align-end {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.heading {
  margin: 0 0 1rem;
  font-size: 1.8rem;
}

.subheading {
  margin-top: 0;
  margin-bottom: 1rem;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--primary);
  color: white;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.button.secondary {
  background: white;
  color: var(--primary);
  border-color: var(--primary);
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.badge {
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-block;
}

.badge.draft { background: #e0f2fe; color: #0369a1; }
.badge.scheduled { background: #fef3c7; color: #b45309; }
.badge.running { background: #ede9fe; color: #5b21b6; }
.badge.sent { background: #dcfce7; color: #047857; }
.badge.error { background: #fee2e2; color: #b91c1c; }

.form-grid {
  display: grid;
  gap: 1rem;
}

label {
  font-weight: 600;
  display: block;
  margin-bottom: 0.4rem;
}

input[type="text"],
input[type="email"],
input[type="datetime-local"],
textarea, select {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 0.65rem 0.8rem;
  font-size: 1rem;
  background: white;
}

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

input[type="file"] {
  border: 1px dashed var(--border);
  padding: 1rem;
  width: 100%;
}

.section-title {
  margin-top: 2rem;
  margin-bottom: 1rem;
  font-size: 1.2rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-size: 0.9rem;
}

.toast-stack {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: grid;
  gap: 0.6rem;
}

.toast {
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 0.8rem 1rem;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.toast.success { border-color: #bbf7d0; }
.toast.error { border-color: #fecaca; }

.progress {
  width: 100%;
  height: 10px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--primary);
}

@media (max-width: 720px) {
  .topbar .max-width {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.8rem;
  }

  nav a {
    margin-left: 0;
    margin-right: 1rem;
  }

  .user-nav {
    margin-top: 0.5rem;
  }
}
