:root {
  --bg: #f3f5f9;
  --panel: #ffffff;
  --line: #d9dfeb;
  --text: #1d2a3a;
  --muted: #667085;
  --primary: #fc0c97;
  --primary-soft: #ffe0f2;
  --danger: #dc2626;
  --success: #16a34a;
  --replacement: #fc0c97;
  --reschedule: #3403b4;
  --cancel: #dc2626;
  --extra: #16a34a;
  --shadow: 0 18px 40px rgba(52, 3, 180, 0.12);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "DM Sans", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(252, 12, 151, 0.1), transparent 28%),
    radial-gradient(circle at top right, rgba(52, 3, 180, 0.08), transparent 24%),
    linear-gradient(180deg, #fff8fc 0%, #f5f1ff 100%);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 76px 1fr;
}

.sidebar {
  padding: 18px 12px;
  background: linear-gradient(180deg, #3403b4 0%, #1f0b6c 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.page-header h2 {
  margin: 0;
  line-height: 1.05;
}

.page-header p,
.eyebrow {
  margin: 0;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  font-weight: 700;
  color: #cbbcff;
}

.side-nav {
  display: grid;
  gap: 10px;
  width: 100%;
  justify-items: center;
  margin-top: 4px;
}

.nav-link,
.btn {
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.nav-link {
  width: 48px;
  height: 48px;
  padding: 0;
  background: rgba(255, 255, 255, 0.09);
  color: #f5eefe;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.nav-icon {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-link.is-active,
.nav-link:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.content {
  padding: 24px 28px;
}

.page {
  display: none;
}

.page.is-active {
  display: block;
}

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

.header-actions,
.view-toggle,
.date-controls,
.modal-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.toolbar,
.legend,
.calendar-view,
.settings-card {
  padding: 18px;
  margin-bottom: 18px;
}

.event-form input,
.event-form select,
.event-form textarea,
.inline-form input,
.inline-form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fbfcff;
}

.legend {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  color: var(--muted);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  display: inline-block;
}

.legend-dot.replacement { background: var(--replacement); }
.legend-dot.reschedule { background: var(--reschedule); }
.legend-dot.cancel { background: var(--cancel); }
.legend-dot.extra { background: var(--extra); }

.btn {
  padding: 11px 16px;
  font-weight: 700;
}

.btn:hover,
.nav-link:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 12px 24px rgba(252, 12, 151, 0.24);
}

.btn-secondary {
  background: #efe9ff;
  color: #3403b4;
}

.btn-danger {
  background: #fee2e2;
  color: #991b1b;
}

.btn-success {
  background: #dcfce7;
  color: #166534;
}

.btn-chip,
.btn-icon {
  background: #f3f6fb;
  color: var(--muted);
}

.btn-chip.is-active {
  background: #3403b4;
  color: #fff;
}

.btn-icon {
  width: 42px;
  height: 42px;
  padding: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.date-controls {
  align-items: center;
}

#calendarTitle {
  min-width: 220px;
  text-align: center;
  margin: 0;
}

.calendar-view {
  min-height: 760px;
}

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

.weekday,
.day-cell {
  border-radius: 8px;
}

.weekday {
  padding: 10px;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.day-cell {
  border: 1px solid var(--line);
  padding: 8px;
  min-height: 132px;
  background: linear-gradient(180deg, #fff 0%, #fbfcff 100%);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.day-cell.is-other-month {
  opacity: 0.42;
}

.day-cell.is-today {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(252, 12, 151, 0.14);
}

.day-number {
  font-weight: 700;
  font-size: 0.82rem;
}

.event-stack {
  display: grid;
  gap: 4px;
}

.event-pill {
  border: 0;
  border-left: 3px solid transparent;
  padding: 5px;
  border-radius: 6px;
  text-align: left;
  background: #f8fafc;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.1);
  font-size: 0.72rem;
  line-height: 1.1;
  min-width: 0;
  width: 100%;
}

.event-pill.replacement { border-left-color: var(--replacement); background: rgba(252, 12, 151, 0.08); }
.event-pill.reschedule { border-left-color: var(--reschedule); background: rgba(52, 3, 180, 0.08); }
.event-pill.cancel { border-left-color: var(--cancel); background: rgba(220, 38, 38, 0.08); }
.event-pill.extra { border-left-color: var(--extra); background: rgba(22, 163, 74, 0.08); }

.event-pill small,
.empty-copy,
.muted {
  color: var(--muted);
}

.event-pill strong,
.event-pill span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-time {
  color: var(--text);
  font-weight: 700;
  margin-bottom: 2px;
}

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

.more-toggle {
  border: 0;
  border-radius: 6px;
  padding: 4px 6px;
  background: #f3f0ff;
  color: #3403b4;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 700;
  text-align: left;
}

.list-view {
  display: grid;
  gap: 14px;
}

.list-day {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
}

.list-day h4 {
  margin: 0 0 14px;
}

.list-events {
  display: grid;
  gap: 10px;
}

.list-event {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
}

.event-badge {
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 0.83rem;
  font-weight: 700;
}

.event-badge.replacement { background: rgba(252, 12, 151, 0.12); color: var(--replacement); }
.event-badge.reschedule { background: rgba(52, 3, 180, 0.12); color: var(--reschedule); }
.event-badge.cancel { background: rgba(220, 38, 38, 0.12); color: var(--cancel); }
.event-badge.extra { background: rgba(22, 163, 74, 0.12); color: var(--extra); }

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.inline-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.table-wrap {
  overflow-x: auto;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-height: 36px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.86rem;
}

.pagination button {
  border: 0;
  border-radius: 6px;
  padding: 7px 10px;
  background: #f3f0ff;
  color: #3403b4;
  cursor: pointer;
  font-weight: 700;
}

.pagination button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.text-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.text-btn {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  color: var(--primary);
  font-weight: 700;
}

.text-btn.danger {
  color: var(--danger);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.46);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 50;
}

#eventDetailModal {
  z-index: 60;
}

#confirmModal {
  z-index: 80;
}

.modal.hidden {
  display: none;
}

.modal-panel {
  width: min(720px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: #fff;
  border-radius: 26px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.modal-lg {
  width: min(860px, 100%);
}

.modal-sm {
  width: min(560px, 100%);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.modal-header h3 {
  margin: 4px 0 0;
}

.icon-close {
  border: 0;
  background: #f6efff;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.5rem;
}

.event-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.event-form label,
.detail-grid dt,
.detail-grid dd {
  display: block;
}

.event-form span {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

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

.detail-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px 16px;
  margin-bottom: 20px;
}

.detail-grid dt {
  color: var(--muted);
  font-weight: 700;
}

.detail-grid dd {
  margin: 0;
}

.confirm-copy {
  margin: 0 0 14px;
  color: var(--muted);
}

.confirm-details {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
}

.confirm-details:empty {
  display: none;
}

.conflict-detail {
  border: 0;
  border-radius: 8px;
  padding: 11px 13px;
  background: #f3f0ff;
  color: #25115f;
  text-align: left;
  font-weight: 700;
}

.conflict-detail span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  padding: 14px 18px;
  border-radius: 14px;
  background: #3403b4;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 80;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1200px) {
  .inline-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    align-items: stretch;
    text-align: left;
    padding: 14px 18px;
  }

  .side-nav {
    grid-auto-flow: column;
    justify-content: flex-start;
  }

  .toolbar,
  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

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

  .weekday {
    display: none;
  }

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

@media (max-width: 640px) {
  .content,
  .sidebar {
    padding: 18px;
  }

  .month-grid {
    grid-template-columns: 1fr;
  }

  .event-form,
  .inline-form,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .detail-grid dt {
    margin-top: 10px;
  }

  .header-actions,
  .modal-actions {
    flex-direction: column;
  }
}
