:root {
  --accent: #2f6f4e;
  --accent-dark: #234f38;
  --bg: #f6f7f5;
  --card-bg: #ffffff;
  --border: #e0e2de;
  --text: #22271f;
  --muted: #6b7268;
  --danger: #b3401f;
  --warn: #b98900;
}

* { box-sizing: border-box; }

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

a { color: var(--accent-dark); }

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

header.site {
  background: var(--accent-dark);
  color: #fff;
  padding: 16px 0;
}
header.site .wrap { display: flex; justify-content: space-between; align-items: center; padding-top: 0; padding-bottom: 0; }
header.site .site-header-inner { justify-content: space-between; gap: 12px; flex-wrap: wrap; }
header.site .site-header-left { display: flex; align-items: center; gap: 12px; }
header.site h1 { font-size: 1.25rem; margin: 0; }
header.site .site-logo { height: 36px; width: auto; max-width: 140px; object-fit: contain; }
header.site a { color: #fff; text-decoration: none; }
header.site nav a { margin-left: 16px; font-size: 0.9rem; opacity: 0.85; }
header.site nav a:hover { opacity: 1; text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}

.event-card h2 { margin-top: 0; margin-bottom: 4px; }
.event-meta { color: var(--muted); font-size: 0.92rem; margin-bottom: 14px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge.full { background: #e4f2e8; color: var(--accent-dark); }
.badge.needs { background: #fbeee2; color: var(--warn); }

.volunteer-list { margin: 0; padding: 0; list-style: none; }
.volunteer-list li { padding: 2px 0; }
.volunteer-list .empty-slot { color: var(--muted); font-style: italic; }

form.inline { display: inline; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 6px;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--accent-dark); }
.btn.secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: #f0f1ee; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #8f331a; }
.btn.small { padding: 5px 10px; font-size: 0.82rem; }

.actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

label { display: block; font-weight: 600; margin-bottom: 4px; margin-top: 14px; font-size: 0.92rem; }
input[type=text], input[type=email], input[type=tel], input[type=date], input[type=datetime-local], input[type=number], input[type=password], textarea, select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
}
textarea { resize: vertical; }
.field-hint { color: var(--muted); font-size: 0.82rem; margin-top: 3px; }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 0.92rem; }
.flash.success { background: #e4f2e8; color: var(--accent-dark); }
.flash.error { background: #fbe4e0; color: var(--danger); }

.login-box { max-width: 360px; margin: 60px auto; }

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

.shift-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.shift-row:last-child { border-bottom: none; }
.shift-role { font-weight: 600; }
.shift-time { color: var(--muted); font-size: 0.88rem; }

.breadcrumb { font-size: 0.88rem; color: var(--muted); margin-bottom: 10px; }
.breadcrumb a { color: var(--muted); }

.shift-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 6px 14px;
  margin-top: 6px;
}
.shift-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
  font-size: 0.88rem;
  margin: 0;
  padding: 4px 0;
}
.shift-checkbox input { width: auto; }
.shift-checkbox.disabled { color: var(--muted); }

.theme-swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
  margin-top: 6px;
}
.theme-swatch {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}
.theme-swatch.selected { border-color: var(--accent); background: #f4f8f5; }
.theme-swatch input[type=radio] { width: auto; margin: 0; }
.swatch-dot { display: inline-block; width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; }
.swatch-color-input {
  width: 28px !important;
  height: 22px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
}

/* Public rota grid: shift times as columns, volunteer slots as rows */
.rota-grid-wrap { overflow-x: auto; margin-top: 10px; padding-bottom: 10px; }
table.rota-grid { width: 100%; border-collapse: separate; border-spacing: 4px; }
table.rota-grid th, table.rota-grid td { border-bottom: none; padding: 0; }
table.rota-grid thead th {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  padding: 6px 8px;
  white-space: nowrap;
  background: #eef0ec;
  border-radius: 6px;
}
table.rota-grid .grid-time-sep { color: var(--muted); margin: 0 1px; }
table.rota-grid .grid-notes { font-weight: 400; color: var(--muted); font-size: 0.75rem; white-space: normal; margin-top: 2px; }
table.rota-grid .slot-col { width: 28px; text-align: center; color: var(--muted); font-size: 0.8rem; }
table.rota-grid .grid-cell {
  min-width: 96px;
  height: 40px;
  text-align: center;
  vertical-align: middle;
  border-radius: 6px;
  font-size: 0.85rem;
  padding: 4px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
table.rota-grid .grid-cell.filled { font-weight: 600; }
table.rota-grid .grid-cell.open {
  background: #fbeee2;
  color: var(--warn);
  font-style: italic;
  font-size: 0.76rem;
  white-space: normal;
  line-height: 1.2;
  height: auto;
  min-height: 40px;
}
table.rota-grid .grid-cell.na { background: transparent; }

.label-short { display: none; }

.history-link { text-align: center; margin-top: 10px; }
.history-link a { font-size: 0.9rem; color: var(--muted); text-decoration: none; }
.history-link a:hover { color: var(--accent-dark); text-decoration: underline; }

.past-events { margin-top: 24px; }
.past-events summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 1.05rem;
  padding: 10px 0;
  color: var(--muted);
}
.past-events summary:hover { color: var(--text); }
.past-events[open] summary { margin-bottom: 6px; }

.month-heading {
  margin: 28px 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--border);
  color: var(--accent-dark);
  font-size: 1.1rem;
}
.month-heading:first-child { margin-top: 0; }

/* Shrink the grid on narrow screens so more time columns fit before
   horizontal scrolling kicks in. */
@media (max-width: 640px) {
  .wrap { padding: 14px 10px 40px; }
  .card { padding: 12px; }
  .rota-grid-wrap { padding-bottom: 14px; }
  header.site .site-logo { height: 28px; }
  header.site h1 { font-size: 1.05rem; }

  .event-card h2 { font-size: 1.02rem; }
  .event-card .event-meta { font-size: 0.8rem; margin-bottom: 10px; }
  .event-card p { font-size: 0.85rem; }
  .month-heading { font-size: 0.95rem; margin: 20px 0 8px; }

  table.rota-grid { border-spacing: 3px; }
  table.rota-grid thead th {
    font-size: 0.68rem;
    padding: 4px 3px;
  }
  table.rota-grid .grid-notes { display: none; }
  table.rota-grid .slot-col { width: 16px; font-size: 0.68rem; }
  table.rota-grid .grid-cell {
    min-width: 56px;
    height: 32px;
    font-size: 0.7rem;
    padding: 2px 3px;
  }
  table.rota-grid .grid-cell.open {
    font-size: 0.62rem;
    min-height: 32px;
  }
  .label-full { display: none; }
  .label-short { display: inline; }
}
