:root {
  color-scheme: light;
  --bg: #f6f7f2;
  --panel: #ffffff;
  --ink: #20251f;
  --muted: #667066;
  --line: #d9ded3;
  --accent: #2f6f5e;
  --accent-strong: #1f5548;
  --warn: #9a5a12;
  --danger: #9e2f3a;
  --blue: #2e5d83;
  --shadow: 0 8px 24px rgba(32, 37, 31, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

body {
  margin: 0;
  min-height: 100vh;
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
.small-button,
.pill-link {
  align-items: center;
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 700;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  text-decoration: none;
}

button:hover,
.small-button:hover,
.pill-link:hover {
  background: var(--accent-strong);
  text-decoration: none;
}

.ghost-button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  min-height: 36px;
}

.danger {
  background: var(--danger);
}

input,
textarea,
select {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  min-height: 42px;
  padding: 10px 12px;
  width: 100%;
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.app-header {
  align-items: center;
  background: rgba(246, 247, 242, 0.96);
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 10px;
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 900;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.top-nav a {
  background: #e9efe7;
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.92rem;
  padding: 7px 10px;
}

.logout-form {
  justify-self: start;
}

.page {
  margin: 0 auto;
  max-width: 1080px;
  padding: 18px 16px 56px;
}

.app-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.86rem;
  padding: 16px;
  text-align: center;
}

.auth-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin: 8vh auto 0;
  max-width: 440px;
  padding: 22px;
}

.stack {
  display: grid;
  gap: 14px;
}

.page-title {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.page-title h1 {
  font-size: 2rem;
  line-height: 1.05;
  margin-bottom: 4px;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
}

.help-text {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
  margin: 4px 0 0;
}

.notice,
.flash,
.warning-band,
.text-band,
.form-band {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 18px;
  padding: 16px;
}

.notice {
  background: #eef6f1;
}

.flash-list {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.flash {
  margin: 0;
}

.flash.success {
  background: #eaf5ee;
  border-color: #b7d8c1;
}

.flash.error {
  background: #fbecee;
  border-color: #e6b8c0;
}

.flash.warning,
.warning-band {
  background: #fff4df;
  border-color: #e8c88c;
}

.summary-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 20px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 0.8rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.metric strong {
  display: block;
  font-size: clamp(1.2rem, 8vw, 2rem);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.section-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin: 22px 0 10px;
}

.section-head h2,
.form-band h2,
.warning-band h2 {
  font-size: 1.1rem;
  margin-bottom: 0;
}

.section-head .help-text {
  margin-top: 4px;
}

.calendar-head {
  align-items: end;
}

.calendar-head .muted {
  margin: 4px 0 0;
}

.calendar-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.calendar-board {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

.calendar-weekdays,
.calendar-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-weekdays {
  background: #e9efe7;
  border-bottom: 1px solid var(--line);
}

.calendar-weekdays span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  padding: 8px 6px;
  text-align: center;
}

.calendar-day {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  display: grid;
  gap: 6px;
  grid-template-rows: auto 1fr;
  height: 116px;
  min-width: 0;
  padding: 8px;
}

.calendar-day-top {
  align-items: center;
  display: flex;
  gap: 4px;
  justify-content: space-between;
  min-width: 0;
}

.calendar-date-link {
  border-radius: 999px;
  color: inherit;
  display: inline-flex;
}

.calendar-date-link:hover {
  text-decoration: none;
}

.calendar-add {
  align-items: center;
  background: #e9efe7;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 900;
  height: 24px;
  justify-content: center;
  min-width: 24px;
  text-decoration: none;
}

.calendar-add:hover {
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

.calendar-week:last-child .calendar-day {
  border-bottom: 0;
}

.calendar-day:nth-child(7n) {
  border-right: 0;
}

.calendar-day time {
  align-items: center;
  border-radius: 999px;
  color: var(--ink);
  display: inline-flex;
  font-size: 0.8rem;
  font-weight: 900;
  height: 24px;
  justify-content: center;
  justify-self: start;
  min-width: 24px;
  padding: 0 6px;
}

.calendar-day.today time {
  background: var(--accent);
  color: #fff;
}

.calendar-day.outside-month {
  background: #f3f5ef;
}

.calendar-day.outside-month time {
  color: var(--muted);
}

.calendar-events {
  align-content: start;
  display: grid;
  gap: 4px;
  min-width: 0;
  overflow: auto;
}

.calendar-event {
  background: #eef4f9;
  border-left: 4px solid var(--blue);
  border-radius: 6px;
  color: var(--ink);
  display: grid;
  gap: 1px;
  min-width: 0;
  padding: 5px 6px;
}

.calendar-event.status-proposal {
  background: #fff4df;
  border-left-color: var(--warn);
}

.calendar-event.status-confirmed {
  background: #eef4f9;
  border-left-color: var(--blue);
}

.calendar-event span,
.calendar-event strong {
  display: block;
  line-height: 1.15;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-event span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.calendar-event strong {
  font-size: 0.76rem;
}

.item-list {
  display: grid;
  gap: 12px;
}

.item-card {
  align-items: start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
  padding: 14px;
}

.item-card h3 {
  margin-bottom: 6px;
}

.card-actions {
  align-items: stretch;
  display: grid;
  gap: 8px;
}

.quick-response {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.quick-response button {
  background: #e9efe7;
  border: 1px solid var(--line);
  color: var(--ink);
  flex: 1 1 72px;
  min-height: 36px;
  padding: 0 10px;
  width: auto;
}

.quick-response button.active {
  background: var(--accent);
  color: #fff;
}

.status-proposal {
  border-left-color: var(--warn);
}

.status-confirmed {
  border-left-color: var(--blue);
}

.status-cancelled {
  opacity: 0.65;
}

.grid-form {
  display: grid;
  gap: 12px;
}

.grid-form.compact {
  align-items: end;
}

.full {
  grid-column: 1 / -1;
}

.inline-form {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.wide-form {
  justify-content: flex-start;
}

.checkline {
  align-items: center;
  display: inline-flex;
  font-weight: 700;
  gap: 6px;
}

.checkline input,
.segmented input {
  min-height: auto;
  width: auto;
}

.action-strip {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.copy-field {
  flex: 1 1 260px;
  min-width: 0;
}

.copy-button {
  flex: 0 0 auto;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  background: #e9efe7;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 10px;
}

.invite-chip {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex: 1 1 320px;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
}

.invite-chip div {
  display: grid;
  flex: 1 1 160px;
  gap: 2px;
  min-width: 0;
}

.invite-chip small,
.compact-row small,
.availability-row small {
  color: var(--muted);
}

.segmented {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.segmented label {
  align-items: center;
  background: #e9efe7;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  justify-content: center;
  min-height: 44px;
}

.empty {
  color: var(--muted);
  margin: 0;
  padding: 14px 0;
}

.empty-action {
  align-items: center;
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  padding: 14px;
}

.empty-action .empty {
  padding: 0;
}

.availability-panel,
.admin-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}

.availability-row {
  align-items: center;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(120px, 1fr) minmax(96px, auto) minmax(120px, 1.2fr);
  padding: 10px 12px;
}

.availability-row:first-child {
  border-top: 0;
}

.availability-row div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.availability-row p {
  margin: 0;
  overflow-wrap: anywhere;
}

.availability-head {
  background: #e9efe7;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.response-badge {
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
  justify-self: start;
  padding: 6px 9px;
}

.response-yes {
  background: #eaf5ee;
  color: #24583a;
}

.response-maybe {
  background: #fff4df;
  color: var(--warn);
}

.response-no {
  background: #fbecee;
  color: var(--danger);
}

.response-open {
  background: #e9efe7;
  color: var(--muted);
}

.admin-grid {
  display: grid;
  gap: 14px;
}

.filter-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.admin-panel {
  padding: 14px;
}

.panel-head {
  margin: 0 0 10px;
}

.compact-row {
  align-items: center;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto;
  padding: 10px 0;
}

.compact-row div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.compact-row strong,
.compact-row small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-row span {
  color: var(--muted);
  font-size: 0.84rem;
  white-space: nowrap;
}

.member-card {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(140px, 1fr);
  padding: 10px;
}

.member-card div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.member-card strong,
.member-card small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 720px) {
  .app-header {
    grid-template-columns: auto 1fr auto;
  }

  .logout-form {
    justify-self: end;
  }

  .grid-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-form button {
    justify-self: start;
  }

  .item-card {
    align-items: center;
    grid-template-columns: 1fr auto;
  }

  .admin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .member-card {
    grid-template-columns: minmax(160px, 1fr) auto auto;
  }
}

@media (max-width: 520px) {
  .summary-grid,
  .segmented {
    grid-template-columns: 1fr;
  }

  .calendar-head {
    align-items: stretch;
    display: grid;
  }

  .calendar-nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
    justify-content: stretch;
  }

  .calendar-nav .small-button {
    min-height: 38px;
    padding: 0 8px;
    width: auto;
  }

  .calendar-weekdays span {
    font-size: 0.66rem;
    padding: 7px 2px;
  }

  .calendar-day {
    gap: 4px;
    height: 88px;
    padding: 5px;
  }

  .calendar-day time {
    font-size: 0.72rem;
    height: 21px;
    min-width: 21px;
    padding: 0 4px;
  }

  .calendar-event {
    border-left-width: 3px;
    padding: 4px;
  }

  .calendar-event span {
    font-size: 0.62rem;
  }

  .calendar-event strong {
    font-size: 0.68rem;
  }

  .page-title {
    display: grid;
  }

  button,
  .small-button,
  .pill-link {
    width: 100%;
  }

  .availability-row {
    align-items: start;
    grid-template-columns: 1fr;
  }

  .availability-head {
    display: none;
  }

  .compact-row {
    grid-template-columns: 1fr;
  }
}
