:root {
  color-scheme: light;
  --bg: #f6f5ef;
  --surface: #ffffff;
  --ink: #252220;
  --muted: #6e675e;
  --line: #e4ddcd;
  --olive: #5b7056;
  --olive-deep: #384a36;
  --olive-soft: #dde5d8;
  --aegean: #2c4c63;
  --aegean-soft: #e3ecf2;
  --terra: #b5654d;
  --terra-deep: #894633;
  --gold: #b68d40;
  --shadow: 0 12px 32px rgba(42, 36, 28, 0.06);
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
}

h1, h2, h3 {
  font-family: 'EB Garamond', Georgia, serif;
  font-weight: 500;
}

h1 { font-size: 1.8rem; margin: 0 0 20px; }
h2 { font-size: 1.55rem; margin: 0 0 16px; color: var(--olive-deep); }
h3 { font-size: 1.15rem; margin: 0 0 10px; color: var(--ink); }

p { margin: 0 0 12px; color: var(--muted); }
.muted { color: var(--muted); }
a { color: var(--aegean); }
.hidden { display: none !important; }

/* Login */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background:
    radial-gradient(circle at 20% 10%, rgba(221, 229, 216, 0.6), transparent 60%),
    radial-gradient(circle at 90% 80%, rgba(227, 236, 242, 0.6), transparent 55%),
    var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 36px;
  max-width: 390px;
  width: 100%;
  box-shadow: var(--shadow);
}

.login-card .brand {
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--terra-deep);
  margin: 0 0 10px;
  font-weight: 600;
}

.login-card h1 { margin-bottom: 20px; color: var(--olive-deep); }

#loginForm label { display: grid; gap: 6px; margin-bottom: 14px; }
#loginForm label span { font-size: 0.8rem; color: var(--muted); }
#loginForm input, #loginForm button { width: 100%; }

.status { margin: 10px 0 0; font-size: 0.88rem; min-height: 18px; }
.status.is-err { color: var(--terra-deep); }
.status.is-ok { color: var(--olive-deep); }

/* App */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 14px 24px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 20px;
  align-items: center;
}

.brand-row { display: flex; flex-direction: column; gap: 2px; }
.brand-row .brand { font-family: 'EB Garamond', serif; font-size: 1.15rem; color: var(--olive-deep); font-weight: 600; }
.brand-row .user { font-size: 0.78rem; color: var(--muted); }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button {
  background: transparent;
  border: none;
  padding: 8px 14px;
  border-radius: 999px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
  transition: all 150ms;
}
.tabs button:hover { background: var(--olive-soft); color: var(--olive-deep); }
.tabs button.active { background: var(--olive-deep); color: #fff; }

.content { flex: 1; width: min(1200px, calc(100% - 32px)); margin: 24px auto; }
.panel { display: none; }
.panel.active { display: block; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.spread { justify-content: space-between; margin-bottom: 18px; }

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  min-height: 38px;
  border-radius: 8px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: transform 150ms, border-color 150ms;
}
.btn:hover { transform: translateY(-1px); }
.btn--primary { background: var(--olive-deep); color: #fff; border-color: var(--olive-deep); }
.btn--primary:hover { background: var(--ink); }
.btn--ghost { background: #fff; color: var(--olive-deep); }
.btn--danger { background: #fff; color: var(--terra-deep); border-color: #f0d0c7; }

input, select, textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  padding: 8px 12px;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--aegean);
  box-shadow: 0 0 0 3px rgba(44, 76, 99, 0.14);
}

/* Dashboard */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px;
  box-shadow: var(--shadow);
}
.stat-card span {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.stat-card strong {
  display: block;
  font-family: 'EB Garamond', serif;
  font-size: 1.8rem;
  color: var(--olive-deep);
  line-height: 1;
}

.dash-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
@media (max-width: 820px) { .dash-grid { grid-template-columns: 1fr; } }

.dash-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.budget-summary {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.budget-line {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 0.92rem;
}
.budget-line.total {
  border-bottom: none;
  font-weight: 600;
  color: var(--aegean);
  font-size: 1.05rem;
  padding-top: 10px;
}

.invite-links {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.invite-link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: #faf9f4;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.86rem;
}
.invite-link-row code {
  color: var(--aegean);
  font-size: 0.84rem;
  word-break: break-all;
}

/* Responses */
.response-list { display: grid; gap: 10px; }
.response-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1.4fr 1.1fr 1.4fr auto;
  gap: 16px;
  align-items: center;
  cursor: pointer;
  transition: border-color 150ms;
}
.response-row:hover { border-color: var(--olive); }
.response-row h4 { margin: 0 0 4px; font-family: 'Inter', sans-serif; font-size: 0.95rem; }
.response-row p { margin: 0; font-size: 0.85rem; }

.tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  margin-right: 4px;
}
.tag--both { background: var(--olive-soft); color: var(--olive-deep); }
.tag--church { background: var(--aegean-soft); color: var(--aegean); }
.tag--party { background: #f6edd9; color: #7c5c17; }
.tag--no { background: #f9e0d9; color: var(--terra-deep); }
.tag--lang { background: #efede6; color: var(--ink); }
.tag--gift { background: #f1d6cc; color: var(--terra-deep); }

@media (max-width: 720px) { .response-row { grid-template-columns: 1fr; } }

/* Tables */
.seating { display: grid; grid-template-columns: 280px 1fr; gap: 18px; align-items: start; }
.unseated {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  position: sticky;
  top: 16px;
  max-height: 75vh;
  overflow-y: auto;
}
.party-card {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  margin-bottom: 8px;
  font-size: 0.88rem;
  cursor: grab;
}
.tables-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.table-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  min-height: 180px;
}
.table-card.is-over { border-color: var(--olive); box-shadow: 0 0 0 3px rgba(91, 112, 86, 0.16); }
.table-card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.table-card__head h3 { margin: 0; }
.table-card__head .meta { font-size: 0.78rem; color: var(--muted); }
.seat-bar { height: 5px; background: var(--line); border-radius: 999px; overflow: hidden; margin-bottom: 10px; }
.seat-bar > i { display: block; height: 100%; background: var(--olive); }
.seat-bar.full > i { background: var(--terra); }
.assigned-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  margin-bottom: 5px;
  font-size: 0.86rem;
}
.assigned-row button { background: transparent; border: none; color: var(--terra-deep); cursor: pointer; font-size: 1rem; }

@media (max-width: 800px) {
  .seating { grid-template-columns: 1fr; }
  .unseated { position: static; }
}

/* Checklist */
.progress-bar-wrap {
  width: 100%;
  height: 10px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 18px;
}
.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--olive-deep);
  transition: width 250ms ease;
}

.checklist-add-form {
  display: grid;
  grid-template-columns: 180px 1.6fr 1fr 1fr auto;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 18px;
}
@media (max-width: 820px) { .checklist-add-form { grid-template-columns: 1fr; } }

.checklist-groups { display: grid; gap: 16px; }
.checklist-group {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.checklist-group h3 { color: var(--aegean); margin-bottom: 10px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.checklist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px;
  border-bottom: 1px dashed var(--line);
}
.checklist-item:last-child { border-bottom: none; }
.checklist-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  cursor: pointer;
}
.checklist-left input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 18px;
  flex-shrink: 0;
  accent-color: var(--olive-deep);
}
.checklist-item.is-done .cl-title { text-decoration: line-through; color: var(--muted); }
.cl-meta { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }

/* Settings */
.settings-form {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  max-width: 980px;
}
.settings-form label { display: grid; gap: 6px; font-size: 0.86rem; }
.settings-form label > span { color: var(--muted); font-size: 0.78rem; }
.settings-form label.full { grid-column: 1 / -1; }
.settings-form .section-title {
  grid-column: 1 / -1;
  font-family: 'EB Garamond', serif;
  font-size: 1.25rem;
  color: var(--olive-deep);
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  margin-top: 8px;
}
.settings-form .actions { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; }
@media (max-width: 720px) { .settings-form { grid-template-columns: 1fr; } }

.schedule-editor { grid-column: 1 / -1; }
.schedule-row { display: grid; grid-template-columns: 90px 1fr 1.5fr auto; gap: 8px; margin-bottom: 6px; }
.schedule-row input { min-height: 36px; }
.schedule-row button {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  width: 36px;
  cursor: pointer;
  color: var(--terra-deep);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(37, 34, 32, 0.55);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 100;
}
.modal__card {
  width: min(740px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.25);
}
.modal__card header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal__close { background: transparent; border: none; font-size: 1.6rem; cursor: pointer; color: var(--muted); }
.modal__card .grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.modal__card label { display: grid; gap: 4px; font-size: 0.86rem; }
.modal__card label > span { color: var(--muted); font-size: 0.78rem; }
.modal__card label.full { grid-column: 1 / -1; }
.modal__card label.inline { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.modal__card label.inline input { width: 18px; height: 18px; min-height: 18px; }
.modal__actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

@media (max-width: 800px) {
  .topbar { grid-template-columns: 1fr; gap: 12px; padding: 12px 16px; }
  .topbar-actions { justify-self: end; }
}
@media (max-width: 540px) {
  .modal__card .grid { grid-template-columns: 1fr; }
}
