:root {
  --green: #1f6b45;
  --green-dark: #154a30;
  --green-light: #eaf5ee;
  --green-mid: #cfe9d9;
  --gold: #c9a227;
  --gold-light: #fbf1d4;
  --white: #ffffff;
  --text: #1f2a24;
  --muted: #637167;
  --border: #d8e6dc;
  --danger: #b3261e;
  --danger-light: #fdecea;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 40, 30, 0.06), 0 8px 24px rgba(20, 40, 30, 0.06);
  --shadow-hover: 0 4px 10px rgba(20, 40, 30, 0.08), 0 14px 32px rgba(20, 40, 30, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: linear-gradient(180deg, var(--green-light) 0%, #f5faf6 320px, #f5faf6 100%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
}

/* Soft decorative blobs behind content, fixed so they don't disturb layout */
body::before,
body::after {
  content: "";
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  pointer-events: none;
}

body::before {
  top: -120px;
  right: -140px;
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, rgba(201, 162, 39, 0.16), rgba(201, 162, 39, 0) 70%);
}

body::after {
  bottom: -160px;
  left: -160px;
  width: 480px;
  height: 480px;
  background: radial-gradient(circle, rgba(31, 107, 69, 0.12), rgba(31, 107, 69, 0) 70%);
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 2.5rem;
  background: linear-gradient(135deg, var(--green-dark), var(--green) 60%, #2f8a5c);
  color: var(--white);
  box-shadow: 0 2px 16px rgba(20, 60, 40, 0.18);
  position: relative;
  overflow: hidden;
}

.app-header::before {
  content: "";
  position: absolute;
  top: -60%;
  right: -6%;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0) 70%);
  pointer-events: none;
}

.app-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), transparent 60%);
}

.app-header h1 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.reset-control {
  position: relative;
  z-index: 1;
}

.reset-confirm {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.8rem;
  color: var(--white);
}

.reset-confirm[hidden] {
  display: none;
}

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2rem 2.5rem 3.5rem;
  display: flex;
  flex-direction: column;
  gap: 2.25rem;
}

/* Totals bar */
.totals-bar {
  display: flex;
  gap: 1.5rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.75rem;
  box-shadow: var(--shadow);
}

.totals-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding-right: 1.5rem;
  border-right: 1px solid var(--border);
}

.totals-item:last-child {
  border-right: none;
  padding-right: 0;
}

.totals-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.totals-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--green);
  letter-spacing: -0.01em;
}

.totals-combined .totals-value {
  color: var(--gold);
}

/* Completed events summary */
.completed-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.75rem;
  box-shadow: var(--shadow);
}

.completed-summary-label {
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.completed-summary-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--green);
  letter-spacing: -0.01em;
}

/* Section headings */
h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 1rem;
  color: var(--green-dark);
}

h4 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 0.6rem;
  color: var(--green-dark);
}

/* Forms */
.add-event-section {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  box-shadow: var(--shadow);
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

/* .field's own display:flex has the same specificity as the UA [hidden] rule, so it must be restated here. */
.field[hidden] {
  display: none;
}

.field label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.field input,
.field select {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  min-width: 150px;
  background: var(--white);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:hover,
.field select:hover {
  border-color: var(--green-mid);
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.2);
}

/* Buttons */
.btn {
  padding: 0.6rem 1.15rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 700;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.btn:active {
  transform: tlinear-gradient(135deg, var(--green), var(--green-dark));
  color: var(--white);
  box-shadow: 0 2px 6px rgba(31, 107, 69, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--green-dark), var(--green-dark));
  box-shadow: 0 4px 12px rgba(31, 107, 69, 0.351, 107, 69, 0.25);
}

.btn-primary:hover {
  background: var(--green-dark);
}

.btn-secondary {
  background: var(--white);
  color: var(--green);
  border: 1px solid var(--green);
}

.btn-secondary:hover {
  background: var(--green-light);
}

.btn-danger {
  background: transparent;
  color: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.45rem 0.9rem;
}

.btn-danger:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
  border-color: rgba(255, 255, 255, 0.5);
}

.btn-icon {
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
}

.btn-icon:hover {
  color: var(--danger);
  background: var(--danger-light);
}

.error-message {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 0.6rem 0 0;
  font-weight: 600;
}

.empty-state {
  color: var(--muted);
  font-style: italic;
  text-align: center;
  padding: 2.5rem 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--white);
}

/* Event list: card grid */
.event-list-section h2 {
  margin-bottom: 1.25rem;
}

.event-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
  align-items: start;
}

.event-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 4px solid var(--green-mid);
  border-radius: var(--radius);
  padding: 1.5rem 1.6rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s ease, transform 0.15s ease, border-left-color 0.15s ease;
}

.event-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.event-card:has(.status-planning) {
  border-left-color: var(--gold);
}

.event-card:has(.status-active) {
  border-left-color: var(--green);
}

.event-card:has(.status-incomplete) {
  border-left-color: var(--danger);
}

.event-card:has(.status-done) {
  border-left-color: #3b4fb0;
}

.event-card:has(.event-detail:not([hidden])) {
  grid-column: 1 / -1;
}

.event-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.event-card-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.event-card-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.event-delete-confirm {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  flex-basis: 100%;
  justify-content: flex-end;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text);
  white-space: nowrap;
}

.event-delete-confirm[hidden] {
  display: none;
}

/* .btn-danger is styled for the dark header; give it solid contrast on the white card. */
.event-delete-confirm .btn-danger {
  background: var(--danger);
  color: var(--white);
  border-color: var(--danger);
}

.event-delete-confirm .btn-danger:hover {
  background: #8f1e18;
  border-color: #8f1e18;
}

.event-name {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.event-status-select {
  font-size: 0.72rem;
  padding: 0.25rem 1.6rem 0.25rem 0.7rem;
  border: none;
  border-radius: 999px;
  background: var(--green-light);
  color: var(--green);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 12px) 55%, calc(100% - 8px) 55%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}

.event-status-select:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.3);
}

.status-planning {
  background-color: var(--gold-light);
  color: #8a6d1a;
}

.status-active {
  background-color: var(--green-light);
  color: var(--green);
}

.status-incomplete {
  background-color: var(--danger-light);
  color: var(--danger);
}

.status-done {
  background-color: #e4e9ff;
  color: #3b4fb0;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.progress-bar {
  flex: 1;
  height: 10px;
  background: var(--green-light);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--gold));
  width: 0%;
  border-radius: 999px;
  transition: width 0.25s ease;
}

.progress-bar-fill.all-done {
  background: var(--green);
}

.progress-fraction {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  font-weight: 600;
}

.tasks-done-badge {
  font-size: 0.72rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--green-light);
  color: var(--green);
  font-weight: 700;
  white-space: nowrap;
}

.spend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-top: 0.85rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.spend-total {
  font-weight: 700;
  color: var(--text);
}

.event-detail {
  margin-top: 1.4rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.75rem;
}

.details-section {
  grid-column: 1 / -1;
}

.event-detail[hidden] {
  display: none;
}

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

/* Task rows */
.task-list {
  list-style: none;
  margin: 0 0 0.9rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.task-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
}

.task-row:hover {
  background: var(--green-light);
}

.task-done-checkbox {
  appearance: none;
  width: 18px;
  height: 18px;
  flex: none;
  border: 2px solid var(--green-mid);
  border-radius: 999px;
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.task-done-checkbox:checked {
  background: var(--green);
  border-color: var(--green);
}

.task-done-checkbox:checked::after {
  content: "\2713";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 0.7rem;
}

.task-done .task-name {
  text-decoration: line-through;
  color: var(--muted);
}

.task-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.task-name {
  font-size: 0.92rem;
  font-weight: 600;
}

.task-meta {
  font-size: 0.75rem;
  color: var(--muted);
}

.task-section,
.budget-section,
.details-section {
  background: var(--green-light);
  border-radius: var(--radius-sm);
  padding: 1.1rem 1.2rem;
}

.details-notes-input {
  width: 100%;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  resize: vertical;
}

.details-link-list {
  list-style: none;
  margin: 0.9rem 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.link-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--white);
}

.link-row:hover {
  background: var(--green-mid);
}

.link-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.link-anchor {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--green-dark);
  overflow-wrap: anywhere;
}

.link-label {
  font-size: 0.75rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* Budget rows */
.budget-list {
  list-style: none;
  margin: 0 0 0.9rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.budget-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--white);
}

.budget-row:hover {
  background: var(--green-mid);
}

.budget-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.budget-amount {
  font-size: 0.92rem;
  font-weight: 600;
}

.budget-meta {
  font-size: 0.75rem;
  color: var(--muted);
}

@media (max-width: 640px) {
  main {
    padding: 1.25rem 1.25rem 2.5rem;
  }

  .totals-bar {
    flex-direction: column;
  }

  .totals-item {
    border-right: none;
    padding-right: 0;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.75rem;
  }

  .totals-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
  }

  .app-header {
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 1.25rem 1.5rem;
  }

  .event-list {
    grid-template-columns: 1fr;
  }
}
