:root {
  color-scheme: light;
  --bg: #f8f9fa;
  --surface: #ffffff;
  --surface-soft: #f8f9fa;
  --border: #dee2e6;
  --border-strong: #adb5bd;
  --text: #212529;
  --muted: #6c757d;
  --accent: #0d6efd;
  --accent-strong: #0a58ca;
  --accent-soft: #e7f1ff;
  --deadline: #856404;
  --shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  --radius: 0.375rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.site-header,
main {
  width: min(100% - 32px, 1140px);
  margin: 0 auto;
}

.site-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 0 18px;
  border-bottom: 1px solid var(--border);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
}

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

h1 {
  margin-bottom: 0;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
}

h2 {
  margin-bottom: 0.25rem;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.25;
}

h3 {
  font-size: 1.25rem;
  line-height: 1.3;
}

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

.view-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.nav-button,
.sort-button,
.details-button,
.calendar-count {
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font: inherit;
}

.nav-button {
  padding: 0.375rem 0.75rem;
  background: var(--surface);
  border-color: var(--border);
  color: var(--accent);
  font-weight: 600;
}

.nav-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

main {
  padding: 24px 0 56px;
}

.intro {
  margin: 0 0 28px;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.intro p {
  max-width: 860px;
  margin: 0 0 12px;
}

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

.intro ol {
  max-width: 860px;
  margin: 0 0 12px 1.25rem;
  padding-left: 1rem;
}

.intro li {
  margin-bottom: 8px;
}

.intro li:last-child {
  margin-bottom: 0;
}

.intro em {
  font-style: italic;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.view-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.search-box {
  display: grid;
  gap: 0.375rem;
  width: min(360px, 100%);
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
}

.search-box input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ced4da;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.search-box input:focus {
  border-color: #86b7fe;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
  outline: 0;
}

.table-wrap {
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

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

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

tbody tr:nth-child(even) {
  background: var(--surface-soft);
}

tbody tr:hover {
  background: #eef4ff;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f1f3f5;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 700;
}

.sort-button {
  width: 100%;
  padding: 0;
  background: transparent;
  color: inherit;
  font-weight: 700;
  text-align: left;
}

.sort-button::after {
  content: " Sort";
  color: var(--muted);
  font-weight: 400;
}

.sort-button.sort-asc::after {
  content: " Asc";
  color: var(--accent);
}

.sort-button.sort-desc::after {
  content: " Desc";
  color: var(--accent);
}

a {
  color: var(--accent-strong);
  font-weight: 400;
  text-decoration: underline;
}

a:hover {
  color: #0b0080;
}

.materials {
  max-width: 380px;
}

.materials-preview {
  display: -webkit-box;
  max-height: 4.5em;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.see-more-button {
  display: inline;
  margin-top: 0.25rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}

.month {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.month h3 {
  margin: 0;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: #f1f3f5;
  font-size: 1rem;
}

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

.calendar-weekdays span {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
}

.day {
  min-width: 0;
  min-height: 78px;
  padding: 0.375rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: #ffffff;
  overflow: hidden;
}

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

.day.empty {
  background: #fafafa;
}

.day-number {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.calendar-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  margin: 0.25rem 0 0;
  padding: 0;
  overflow: hidden;
  color: #ffffff;
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
}

.calendar-count:hover {
  color: #ffffff;
  filter: brightness(0.92);
}

.deadline-count-1 {
  background: #f4a3a3;
}

.deadline-count-2 {
  background: #ea6b6b;
}

.deadline-count-3 {
  background: #dc3545;
}

.deadline-count-4 {
  background: #b02a37;
}

.deadline-count-5 {
  background: #842029;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

.map-canvas {
  min-height: 560px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.leaflet-popup-content {
  margin: 12px 14px;
}

.map-popup-title {
  margin: 0 0 4px;
  font-weight: 700;
}

.map-popup-subtitle {
  margin: 0;
  color: var(--muted);
}

.details-panel {
  min-height: 220px;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.detail-list {
  display: grid;
  gap: 9px;
  margin: 0;
}

.detail-list dt {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.detail-list dd {
  margin: 0;
}

.details-button {
  display: inline-flex;
  margin-top: 10px;
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: #ffffff;
  font-weight: 600;
  text-decoration: none;
}

dialog {
  width: min(680px, calc(100vw - 28px));
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.175);
}

dialog::backdrop {
  background: rgba(33, 37, 41, 0.5);
}

.dialog-close {
  float: right;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  cursor: pointer;
}

@media (max-width: 860px) {
  .site-header,
  .view-toolbar,
  .map-layout {
    display: grid;
  }

  .site-header {
    padding-top: 22px;
  }

  .view-nav {
    gap: 12px;
  }

  .map-layout {
    grid-template-columns: 1fr;
  }

  .map-canvas {
    min-height: 420px;
  }
}
