* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f6f7f9;
  color: #222;
}
header {
  background: #2e3b4e;
  color: white;
  padding: 1rem 1.5rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
header h1 { margin: 0 0 0.5rem 0; font-size: 1.5rem; }
nav { display: flex; gap: 0.5rem; }
.tab {
  background: transparent;
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
  padding: 0.4rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
}
.tab.active, .tab:hover { background: rgba(255,255,255,0.15); }
main { padding: 1.5rem; max-width: 1400px; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.inline-note {
  margin: -0.25rem 0 1rem;
  padding: 0.65rem 0.85rem;
  background: #eef5ff;
  border: 1px solid #cfe0ff;
  border-radius: 6px;
  color: #36527a;
  font-size: 0.9rem;
}
.inline-note #participants-status {
  margin-left: 0.75rem;
  font-weight: 600;
}
.spacer { flex: 1; }
.muted { color: #667; font-size: 0.9rem; }

input[type=text], input[type=number], input[type=email], select {
  padding: 0.4rem 0.6rem;
  border: 1px solid #ccd;
  border-radius: 4px;
  font-size: 0.9rem;
}
#search { width: 300px; }
#filter-table { width: 100px; }
.toolbar-check {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: #556;
  font-size: 0.9rem;
}

button, a.primary, #btn-export {
  background: #4a6fa5;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
  display: inline-block;
}
button:hover, a.primary:hover, #btn-export:hover { background: #3a5a8c; }
button.primary { background: #2e7d32; }
button.primary:hover { background: #1b5e20; }
button.danger { background: #c62828; }

.table-wrap { overflow-x: auto; background: white; border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { padding: 0.5rem 0.75rem; text-align: left; border-bottom: 1px solid #eee; }
th { background: #f0f2f5; font-weight: 600; position: sticky; top: 0; }
tr:hover { background: #fafbfd; }
td[contenteditable=true] { background: #fffde7; outline: 1px dashed #d4c900; }
td.captain-cell { text-align: center; }

.rules-form {
  background: white;
  padding: 1.5rem;
  border-radius: 6px;
  max-width: 600px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.rules-form label {
  display: block;
  margin-bottom: 1rem;
  font-weight: 500;
}
.rules-form label input[type=number] {
  display: block;
  margin-top: 0.25rem;
  width: 150px;
}
.rules-form label.check {
  font-weight: normal;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.actions { margin-top: 1rem; display: flex; gap: 1rem; align-items: center; }

#warnings .warning {
  background: #fff3cd;
  border-left: 4px solid #ffa000;
  padding: 0.6rem 1rem;
  margin-bottom: 0.5rem;
  border-radius: 4px;
  font-size: 0.9rem;
}
#warnings .warning.strong {
  background: #ffebee;
  border-left-color: #c62828;
  font-weight: 500;
}

.tables-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}
.table-card {
  background: white;
  border-radius: 6px;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border-top: 4px solid #4a6fa5;
}
.table-card.no-captain { border-top-color: #c62828; }
.table-card.singles-table { border-top-color: #8e44ad; background: #faf5ff; }
.badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.1rem 0.5rem;
  background: #8e44ad;
  color: white;
  border-radius: 10px;
  vertical-align: middle;
  margin-left: 0.3rem;
}
.table-card h3 { margin: 0 0 0.3rem 0; }
.table-card .captain-label {
  font-size: 0.85rem;
  color: #555;
  margin-bottom: 0.5rem;
}
.table-card .captain-label strong { color: #2e7d32; }
.table-card .headcount {
  font-size: 0.8rem;
  color: #667;
  margin-bottom: 0.75rem;
}
.party {
  border-top: 1px dashed #e0e4ea;
  padding: 0.4rem 0;
  font-size: 0.88rem;
}
.party:first-of-type { border-top: none; }
.party-header {
  font-size: 0.75rem;
  color: #889;
  text-transform: uppercase;
  margin-bottom: 0.2rem;
}
.party-split { color: #c62828; font-weight: 600; }
.party ul { list-style: none; padding: 0; margin: 0; }
.party li { padding: 0.1rem 0; }
.party li.captain-person { font-weight: 600; color: #2e7d32; }
.party li.captain-person::before { content: "👑 "; }

.del-btn {
  background: transparent;
  color: #c62828;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0 0.5rem;
}

/* ---- Progress bars on table cards ---- */
.progress-wrap {
  margin: 0.5rem 0 0.75rem;
  font-size: 0.85rem;
}
.progress-bar {
  background: #e0e0e0;
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
  margin-bottom: 0.25rem;
}
.progress-fill {
  background: linear-gradient(90deg, #4caf50, #81c784);
  height: 100%;
  transition: width 0.3s;
}
.progress-label {
  color: #555;
  margin-right: 0.5rem;
}
.signup-link {
  color: #1565c0;
  text-decoration: none;
  font-weight: 500;
}
.signup-link:hover { text-decoration: underline; }

/* ---- Menu tab ---- */
#menu-table td[contenteditable] {
  background: #fafafa;
  cursor: text;
}
#menu-table td[contenteditable]:focus {
  background: #fff;
  outline: 2px solid #1565c0;
}

/* ---- Email templates & drafts ---- */
.email-template-editor {
  background: #f5f7fa;
  border: 1px solid #d5dbe3;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.email-template-editor h3 { margin-top: 0; }
.email-template-editor label {
  display: block;
  margin-bottom: 0.75rem;
}
.email-mode-tabs {
  display: flex;
  gap: 0.5rem;
  margin: 0.5rem 0 0.75rem;
  flex-wrap: wrap;
}
.email-mode-btn {
  background: #eef3fb;
  color: #37557e;
  border: 1px solid #cddbf1;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
}
.email-mode-btn.active {
  background: #37557e;
  color: white;
  border-color: #37557e;
}
.email-mode-btn .mode-hint {
  opacity: 0.8;
  font-weight: 400;
}
.email-mode-panel { display: none; }
.email-mode-panel.active { display: block; }
.email-template-editor input[type=text],
.email-template-editor textarea {
  width: 100%;
  font-family: inherit;
  padding: 0.5rem;
  border: 1px solid #bbb;
  border-radius: 4px;
}

.draft-card {
  background: #fff;
  border: 1px solid #d5dbe3;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.draft-card.singles-table { border-color: #9c27b0; background: #faf5fc; }
.draft-card h3 { margin-top: 0; }
.draft-block {
  border-top: 1px solid #eee;
  padding-top: 0.75rem;
  margin-top: 0.75rem;
}
.draft-block h4 { margin: 0 0 0.5rem; }
.draft-block label {
  display: block;
  margin-bottom: 0.5rem;
}
.draft-block input[type=text],
.draft-block textarea {
  width: 100%;
  font-family: inherit;
  padding: 0.5rem;
  border: 1px solid #bbb;
  border-radius: 4px;
}
.draft-block textarea { font-family: ui-monospace, monospace; font-size: 0.9rem; }

/* ---- Signup page ---- */
.signup-body {
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem;
}
.signup-main { padding: 0 0.5rem; }
#attendees {
  columns: 2;
  list-style: disc;
  padding-left: 1.25rem;
}
.signup-category {
  background: #fff;
  border: 1px solid #d5dbe3;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.signup-category.full { background: #f0f4f0; border-color: #a5d6a7; }
.signup-cat-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}
.signup-cat-head h3 { margin: 0 0 0.25rem; }
.signup-claims {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
}
.signup-claims li {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px dashed #eee;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.signup-claims li:last-child { border-bottom: none; }
.signup-claims .del-signup {
  margin-left: auto;
  background: transparent;
  color: #c62828;
  border: none;
  cursor: pointer;
  font-size: 1rem;
}
.signup-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}
.signup-form input[type=text] {
  flex: 1 1 180px;
  padding: 0.5rem;
  border: 1px solid #bbb;
  border-radius: 4px;
}
.signup-form button {
  background: #1565c0;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0.5rem 1rem;
  cursor: pointer;
}
.signup-form button:hover { background: #0d47a1; }

/* ---- Admin overview ---- */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1rem;
}
.admin-card {
  background: #fff;
  border: 1px solid #d5dbe3;
  border-radius: 8px;
  padding: 1rem;
}
.admin-card.admin-at-risk {
  border-left: 4px solid #ef6c00;
  background: #fffaf3;
}
.admin-card.admin-good {
  border-left: 4px solid #2e7d32;
  background: #f6fbf7;
}
.admin-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}
.admin-head h3 {
  margin: 0;
}
.admin-cats {
  margin-top: 0.75rem;
}
.admin-cat {
  border-top: 1px dashed #e1e6ed;
  padding-top: 0.55rem;
  margin-top: 0.55rem;
}
.admin-cat-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}
.admin-cat ul {
  margin: 0.4rem 0 0;
  padding-left: 1rem;
}
