:root {
  --cream: #faf8f4;
  --cream-2: #f0ede6;
  --ink: #2a2847;
  --ink-soft: #6b6888;
  --ink-faint: #9e9cb8;
  --border: #e2dfd8;
  --white: #ffffff;
  --green: #2d7a4f;
  --green-bg: #e8f5ee;
  --red: #b6293f;
  --red-bg: #fce8ec;
  --amber: #b87a1a;
  --amber-bg: #fef6e6;
  --font-display: 'Caveat', cursive;
  --font-body: 'Sora', sans-serif;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(42, 40, 71, 0.06), 0 1px 2px rgba(42, 40, 71, 0.04);
  --shadow-md: 0 4px 12px rgba(42, 40, 71, 0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--cream);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Login ─────────────────────────────────────────────────── */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-brand {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 0.25rem;
}

.login-sub {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--ink-soft);
  margin-bottom: 2rem;
}

.login-card input[type="password"] {
  width: 100%;
  padding: 0.75rem 1rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--cream);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}

.login-card input[type="password"]:focus {
  border-color: var(--ink);
}

.login-card button {
  width: 100%;
  margin-top: 1rem;
  padding: 0.75rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: var(--ink);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity 0.15s;
}

.login-card button:hover { opacity: 0.85; }

.error { font-size: 0.8rem; color: var(--red); margin-top: 0.5rem; display: none; }
.error.visible { display: block; }

/* ── Dashboard layout ──────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.6rem;
  text-decoration: none;
  color: var(--ink);
}

.topbar-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--ink-faint);
  margin-left: 0.75rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

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

/* ── Stats row ─────────────────────────────────────────────── */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
}

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  margin-top: 0.25rem;
}

.stat-card.attending .stat-value { color: var(--green); }
.stat-card.declined .stat-value { color: var(--red); }
.stat-card.plus-ones .stat-value { color: var(--amber); }

/* ── Toolbar ───────────────────────────────────────────────── */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toolbar h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.9rem;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn:hover { background: var(--cream-2); }

.btn-danger {
  color: var(--red);
  border-color: var(--red);
  background: var(--white);
}

.btn-danger:hover {
  background: var(--red-bg);
}

.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.72rem;
}

.btn svg { width: 14px; height: 14px; flex-shrink: 0; }

/* ── Table ─────────────────────────────────────────────────── */

.table-wrap {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

thead {
  position: sticky;
  top: 0;
}

th {
  text-align: left;
  padding: 0.7rem 1rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  background: var(--cream);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

th:hover { color: var(--ink); }

th .sort-arrow {
  display: inline-block;
  margin-left: 0.25rem;
  opacity: 0.3;
  font-size: 0.65rem;
}

th.sorted .sort-arrow { opacity: 1; }

td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(42, 40, 71, 0.015); }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-yes { background: var(--green-bg); color: var(--green); }
.badge-no { background: var(--red-bg); color: var(--red); }

.plus-one-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.plus-one-list li {
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.plus-one-list li::before {
  content: "+ ";
  color: var(--ink-faint);
}

.notes-text {
  max-width: 200px;
  font-size: 0.78rem;
  color: var(--ink-soft);
  word-break: break-word;
}

.td-actions { text-align: right; white-space: nowrap; }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

/* ── Confirm dialog ────────────────────────────────────────── */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(42, 40, 71, 0.3);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 2rem;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.modal h3 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.modal p {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-bottom: 1.5rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.modal-actions .btn { min-width: 100px; justify-content: center; }

.btn-danger-fill {
  background: var(--red);
  color: var(--white);
  border-color: var(--red);
}

.btn-danger-fill:hover {
  opacity: 0.85;
  background: var(--red);
}

/* ── Loading / toast ───────────────────────────────────────── */

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

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

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  z-index: 200;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-success { background: var(--green-bg); color: var(--green); border: 1px solid var(--green); }
.toast-error { background: var(--red-bg); color: var(--red); border: 1px solid var(--red); }

/* ── Responsive ────────────────────────────────────────────── */

@media (max-width: 640px) {
  .container { padding: 1rem; }
  .stats { grid-template-columns: 1fr 1fr; }
  .toolbar { flex-direction: column; align-items: flex-start; }
  th, td { padding: 0.5rem 0.6rem; }
  .topbar { padding: 0.6rem 1rem; }
  .topbar-label { display: none; }
}
