:root {
  color-scheme: light;
  font-family: system-ui, sans-serif;
  line-height: 1.5;
  background: #f7f8fa;
  color: #18202a;
}

body {
  margin: 0;
}

header {
  padding: 1rem 1.5rem;
  background: #173b57;
  color: white;
}

main {
  width: min(56rem, calc(100% - 2rem));
  margin: 4rem auto;
}

a,
button {
  color: #075e94;
}

button {
  padding: 0.65rem 1rem;
  border: 1px solid #075e94;
  border-radius: 0.35rem;
  background: white;
  cursor: pointer;
}

input[type="search"] {
  width: min(30rem, 100%);
  padding: 0.65rem 0.75rem;
  border: 1px solid #9aa8b4;
  border-radius: 0.35rem;
  font: inherit;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}

.card {
  display: grid;
  gap: 0.35rem;
  padding: 1.25rem;
  border: 1px solid #d8e0e6;
  border-radius: 0.6rem;
  background: white;
  text-decoration: none;
}

.card span {
  color: #4b5c68;
}

.breadcrumb {
  margin-bottom: 1.5rem;
}

.search {
  display: grid;
  gap: 0.35rem;
  margin: 2rem 0;
}

.search div {
  display: flex;
  gap: 0.5rem;
}

.entity-list {
  padding: 0;
  border: 1px solid #d8e0e6;
  border-radius: 0.6rem;
  background: white;
  list-style: none;
}

.entity-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid #e8edf0;
}

.entity-list li:last-child {
  border-bottom: 0;
}

.entity-list small {
  color: #687986;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid #d8e0e6;
  border-radius: 0.6rem;
  background: #d8e0e6;
}

.profile-grid div {
  padding: 1rem;
  background: white;
}

.profile-grid dt {
  color: #536672;
  font-size: 0.85rem;
  font-weight: 700;
}

.profile-grid dd {
  margin: 0.35rem 0 0;
  white-space: pre-wrap;
}

.panel {
  margin: 1.5rem 0 2.5rem;
  padding: 1rem;
  border: 1px solid #d8e0e6;
  border-radius: 0.6rem;
  background: white;
}

.panel summary {
  cursor: pointer;
  font-weight: 700;
}

.activity-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.activity-form label {
  display: grid;
  gap: 0.3rem;
}

.activity-form label:has(textarea),
.activity-form label:first-child,
.activity-form .hint {
  grid-column: 1 / -1;
}

.activity-form input,
.activity-form select,
.activity-form textarea {
  box-sizing: border-box;
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid #9aa8b4;
  border-radius: 0.35rem;
  background: white;
  font: inherit;
}

.activity-form textarea {
  min-height: 5rem;
  resize: vertical;
}

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

.hint {
  margin: -0.5rem 0 0;
  color: #536672;
  font-size: 0.9rem;
}

.notice {
  padding: 0.75rem 1rem;
  border: 1px solid #74a882;
  border-radius: 0.4rem;
  background: #edf8f0;
}

.records {
  display: grid;
  gap: 1rem;
}

.records article {
  padding: 1rem 1.25rem;
  border: 1px solid #d8e0e6;
  border-radius: 0.6rem;
  background: white;
}

.records article p:last-child {
  margin-bottom: 0;
}

.record-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.record-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.record-tags span {
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: #eef3f6;
  color: #415560;
  font-size: 0.8rem;
}

.record-action {
  margin-top: 1rem;
  border-top: 1px solid #e8edf0;
  padding-top: 0.75rem;
}

.record-action summary {
  cursor: pointer;
  font-weight: 650;
}

.compact-form {
  margin-bottom: 1rem;
}

.cancel-form {
  display: flex;
  align-items: end;
  gap: 0.75rem;
  border-top: 1px solid #e8edf0;
  padding-top: 1rem;
}

.cancel-form label {
  display: grid;
  flex: 1;
  gap: 0.3rem;
}

.cancel-form input {
  box-sizing: border-box;
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid #9aa8b4;
  border-radius: 0.35rem;
  font: inherit;
}

.cancel-form button {
  border-color: #9d302b;
  color: #8b2823;
}

.event-history {
  display: grid;
  gap: 0.6rem;
  padding-left: 1.25rem;
}

.status {
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: #e8edf0;
  font-size: 0.8rem;
  text-transform: capitalize;
}

.status-completed {
  background: #dff3e5;
  color: #245a32;
}

.status-missed,
.status-cancelled {
  background: #fbe7e5;
  color: #7b2e28;
}

.dashboard-heading,
.month-nav,
.metrics {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.month-nav {
  flex-wrap: wrap;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 2rem 0;
}

.metrics article {
  display: grid;
  gap: 0.25rem;
  padding: 1rem;
  border: 1px solid #d8e0e6;
  border-radius: 0.6rem;
  background: white;
}

.metrics strong {
  font-size: 1.8rem;
}

.metrics span {
  color: #536672;
}

.metric-alert strong {
  color: #8b2823;
}

.calendar-wrap {
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.calendar {
  display: grid;
  min-width: 64rem;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border-top: 1px solid #d8e0e6;
  border-left: 1px solid #d8e0e6;
  background: white;
}

.weekday {
  padding: 0.55rem;
  border-right: 1px solid #d8e0e6;
  border-bottom: 1px solid #d8e0e6;
  background: #eef3f6;
  font-weight: 700;
  text-align: center;
}

.calendar-day {
  min-height: 8.5rem;
  padding: 0.45rem;
  border-right: 1px solid #d8e0e6;
  border-bottom: 1px solid #d8e0e6;
}

.calendar-day > time {
  display: inline-grid;
  width: 1.8rem;
  height: 1.8rem;
  place-items: center;
  font-weight: 650;
}

.calendar-day.today > time {
  border-radius: 50%;
  background: #173b57;
  color: white;
}

.outside-month {
  background: #f5f7f8;
  color: #7c8992;
}

.calendar-event {
  display: grid;
  margin-top: 0.35rem;
  padding: 0.35rem 0.45rem;
  border-left: 0.25rem solid #5484a1;
  border-radius: 0.2rem;
  background: #eaf3f8;
  color: inherit;
  font-size: 0.75rem;
  line-height: 1.3;
  text-decoration: none;
}

.calendar-event:hover,
.calendar-event:focus-visible {
  outline: 2px solid #075e94;
  outline-offset: 1px;
}

.calendar-event span,
.calendar-event small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visit-report {
  padding: 1rem 1.25rem;
  border: 1px solid #d8e0e6;
  border-radius: 0.6rem;
  background: white;
}

.event-interaction {
  border-color: #3c7a4d;
  background: #e8f5ec;
}

.event-next-action {
  border-color: #976b20;
  background: #fff4dc;
}

.calendar-event.status-missed,
.calendar-event.status-cancelled {
  border-color: #9d302b;
  background: #fbe7e5;
}

@media (max-width: 42rem) {
  main {
    margin-top: 2rem;
  }

  .activity-form {
    grid-template-columns: 1fr;
  }

  .activity-form label,
  .activity-form label:has(textarea),
  .activity-form label:first-child,
  .activity-form .hint {
    grid-column: 1;
  }

  .search div {
    align-items: stretch;
    flex-direction: column;
  }

  .dashboard-heading,
  .cancel-form {
    align-items: stretch;
    flex-direction: column;
  }

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