* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #F5F3EF;
  color: #2C3E2D;
  line-height: 1.6;
  min-height: 100vh;
}

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

h1 {
  color: #2D5F3F;
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}

h2 {
  color: #2D5F3F;
  font-size: 1.3rem;
  margin: 2rem 0 1rem;
}

.tagline {
  color: #C49A6C;
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.description {
  color: #555;
  margin-bottom: 1rem;
}

.meta {
  color: #888;
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

.hint {
  color: #888;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.optional {
  color: #aaa;
  font-weight: normal;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.6rem 1.5rem;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.2s;
}

.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.primary {
  background: #2D5F3F;
  color: #fff;
}

.btn.secondary {
  background: #e8e4de;
  color: #2C3E2D;
}

.btn-icon {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: #C0392B;
  padding: 0 0.5rem;
  line-height: 1;
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: #2D5F3F;
}

input[type="text"],
input[type="email"],
input[type="date"],
input[type="time"],
textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
}

input:focus, textarea:focus {
  outline: none;
  border-color: #2D5F3F;
  box-shadow: 0 0 0 2px rgba(45, 95, 63, 0.15);
}

/* Slot rows */
.slot-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.slot-row input[type="date"] { flex: 1; width: auto; }
.slot-row input[type="time"] { flex: 0.7; width: auto; }

#add-slot {
  margin-top: 0.25rem;
  margin-bottom: 1.5rem;
}

/* Vote checkboxes */
.slot-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.slot-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.slot-option:hover {
  border-color: #2D5F3F;
}

.slot-option input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: #2D5F3F;
}

.slot-option input[type="checkbox"]:checked + .slot-label {
  font-weight: 600;
}

.slot-label {
  font-size: 0.95rem;
}

/* Results grid */
.results-grid-wrapper {
  overflow-x: auto;
  margin: 1rem 0;
}

.results-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.results-grid th,
.results-grid td {
  padding: 0.6rem 0.75rem;
  text-align: center;
  border: 1px solid #ddd;
}

.results-grid th {
  background: #2D5F3F;
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
}

.results-grid th small {
  font-weight: 400;
  opacity: 0.85;
}

.results-grid th.best {
  background: #27AE60;
}

.voter-name {
  text-align: left;
  font-weight: 500;
  white-space: nowrap;
}

.vote-cell.yes {
  color: #27AE60;
  font-size: 1.1rem;
}

.vote-cell.best-col {
  background: rgba(39, 174, 96, 0.08);
}

.vote-cell.best {
  background: rgba(39, 174, 96, 0.15);
  color: #27AE60;
}

.totals td {
  border-top: 2px solid #2D5F3F;
}

/* Link box */
.link-box {
  display: flex;
  gap: 0.5rem;
  margin: 0.75rem 0 1.5rem;
}

.link-box input {
  flex: 1;
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
}

/* Badge */
.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.badge.closed {
  background: #f0d0d0;
  color: #C0392B;
}

/* States */
.error {
  color: #C0392B;
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

.result {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
}

.result h3 {
  color: #27AE60;
  margin-bottom: 0.5rem;
}

.hidden { display: none; }
.loading { color: #888; text-align: center; padding: 3rem 0; }

/* Home */
.home {
  text-align: center;
  padding-top: 4rem;
}

.home h1 { font-size: 2.5rem; }
.home .description { font-size: 1.1rem; margin: 1rem 0 2rem; }

/* Poll header */
.poll-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.btn-sm {
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
}

/* Window vote form */
.window-vote-form {
  margin-bottom: 1.5rem;
}

.window-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid #eee;
}

.window-date {
  min-width: 110px;
  font-weight: 600;
  color: #2D5F3F;
}

.window-time-label {
  color: #888;
  font-size: 0.85rem;
}

.window-time {
  width: 110px;
  padding: 0.4rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.9rem;
}

.window-tz {
  color: #888;
  font-size: 0.8rem;
  min-width: 45px;
}

.tz-select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
}

.tz-select:focus {
  outline: none;
  border-color: #2D5F3F;
  box-shadow: 0 0 0 2px rgba(45, 95, 63, 0.15);
}

.results-tz {
  font-size: 0.85rem;
  font-weight: 400;
  color: #888;
}

.voter-tz-label {
  color: #999;
  font-size: 0.75rem;
}

.clear-window {
  color: #999;
  font-size: 1.1rem;
}

/* Timeline visualization */
.date-result {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
}

.date-result.best-date {
  border-color: #27AE60;
  border-width: 2px;
}

.date-result h3 {
  font-size: 1rem;
  color: #2D5F3F;
  margin-bottom: 0.75rem;
}

.best-date h3::after {
  content: " — Best match";
  color: #27AE60;
  font-weight: 400;
  font-size: 0.85rem;
}

.timeline {
  position: relative;
}

.timeline-axis {
  position: relative;
  height: 1.5rem;
  margin-bottom: 0.25rem;
  border-bottom: 1px solid #ddd;
}

.tick {
  position: absolute;
  font-size: 0.7rem;
  color: #999;
  transform: translateX(-50%);
}

.timeline-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.timeline-name {
  min-width: 80px;
  font-size: 0.85rem;
  text-align: right;
  color: #555;
}

.timeline-track {
  flex: 1;
  height: 22px;
  background: #f0ede8;
  border-radius: 4px;
  position: relative;
}

.timeline-bar {
  position: absolute;
  top: 2px;
  height: 18px;
  background: #C49A6C;
  border-radius: 3px;
  opacity: 0.7;
}

.overlap-bar {
  background: #27AE60;
  opacity: 0.85;
}

.overlap-summary {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: #2D5F3F;
}

.overlap-summary.muted {
  color: #999;
}

.muted {
  color: #999;
  font-size: 0.9rem;
}

/* Edit form */
.edit-form {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.edit-form h2 {
  margin-top: 0;
}

.edit-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

/* Responsive */
@media (max-width: 600px) {
  .container { padding: 1.5rem 1rem; }
  h1 { font-size: 1.5rem; }
  .home h1 { font-size: 2rem; }
  .slot-row { flex-wrap: wrap; }
  .slot-row input[type="date"],
  .slot-row input[type="time"] { flex: 1 1 45%; }
  .results-grid { font-size: 0.8rem; }
  .results-grid th, .results-grid td { padding: 0.4rem; }
}
