:root {
  --navy: #1f3864;
  --navy-dark: #14264a;
  --border: #dfe3ea;
  --bg: #f6f7fb;
  --text: #1c2333;
  --muted: #6b7280;
  --danger-bg: #f8d7da;
  --danger-text: #842029;
  --success-bg: #d1e7dd;
  --success-text: #0f5132;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }

.navbar {
  background: var(--navy);
  color: white;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar .brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: white;
}

.navbar nav a {
  color: #d8def0;
  margin-left: 1rem;
  font-size: 0.92rem;
}

.navbar nav a:hover { color: white; }

.container {
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 2.5rem;
  box-sizing: border-box;
}

.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.card.narrow {
  max-width: 420px;
  margin: 3rem auto;
}

.hidden-form { display: none; }

.inline-field {
  padding: 0.3rem 0.4rem;
  font-size: 0.82rem;
  min-width: 8rem;
}

h1 { font-size: 1.5rem; margin-top: 0; }
h2 { font-size: 1.15rem; }

.flash {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.92rem;
}
.flash.error { background: var(--danger-bg); color: var(--danger-text); }
.flash.success { background: var(--success-bg); color: var(--success-text); }

label { display: block; font-size: 0.85rem; font-weight: 600; margin: 0.75rem 0 0.25rem; }

input[type=text], input[type=email], input[type=password], input[type=date], input[type=tel],
select, textarea {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.92rem;
  font-family: inherit;
}

textarea { min-height: 70px; resize: vertical; }

button, .btn {
  display: inline-block;
  background: var(--navy);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  margin-top: 1rem;
}
button:hover, .btn:hover { background: var(--navy-dark); text-decoration: none; }

.btn.secondary { background: white; color: var(--navy); border: 1px solid var(--navy); }
.btn.secondary:hover { background: #eef1f8; }

.btn.danger { background: white; color: var(--danger-text); border: 1px solid var(--danger-text); }
.btn.danger:hover { background: var(--danger-bg); }

.btn.small { padding: 0.3rem 0.6rem; font-size: 0.8rem; margin-top: 0; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

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

th { background: #eef1f8; font-weight: 700; white-space: nowrap; }

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

/* Keep the Save/Details actions reachable without horizontal scrolling —
   on a long, unfiltered table the scrollbar for .table-wrap only appears
   once you've scrolled all the way to the bottom of the page, which made
   the action buttons practically undiscoverable. */
.table-wrap table td:last-child,
.table-wrap table th:last-child {
  position: sticky;
  right: 0;
  z-index: 1;
  box-shadow: -2px 0 4px rgba(0, 0, 0, 0.08);
  white-space: nowrap;
}
.table-wrap table td:last-child { background: #fff; }
.table-wrap table th:last-child { background: #eef1f8; }

.pill {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}
.pill.status-not-contacted { background: #e5e7eb; color: #374151; }
.pill.status-contacted { background: #dbeafe; color: #1e40af; }
.pill.status-awaiting-response { background: #fef3c7; color: #92400e; }
.pill.status-accepted { background: #d1e7dd; color: #0f5132; }
.pill.status-declined { background: #f8d7da; color: #842029; }
.pill.status-no-donations-accepted { background: #e5e7eb; color: #6b7280; }

.pill.tier-1 { background: #ede9fe; color: #5b21b6; }
.pill.tier-2 { background: #e0e7ff; color: #3730a3; }
.pill.tier-3 { background: #f1f5f9; color: #475569; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
}
.filters .field { min-width: 160px; }
.filters label { margin-top: 0; }

/* Dashboard-only: a taller form with its own fields row + buttons row,
   since an open multi-select panel needs a dedicated buttons row it can
   push down clear of (see .filters-card.ms-open below) rather than sharing
   .filters' single flex-wrap row like the simpler filter forms elsewhere
   (resources.html, admin_volunteers.html) do. */
.dashboard-filters { margin-bottom: 1rem; }
.filters-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
}
.filters-fields .field { min-width: 160px; }
.filters-fields label { margin-top: 0; }
.filters-buttons {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.75rem;
  transition: margin-top 0.15s ease;
}

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.stat {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
}
.stat strong { display: block; font-size: 1.2rem; color: var(--navy); }

.muted { color: var(--muted); font-size: 0.85rem; }

.help-text { color: var(--muted); font-size: 0.82rem; margin-top: 0.15rem; }

.top-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.sticky-heading {
  position: sticky;
  top: var(--navbar-height, 60px);
  z-index: 40;
  background: var(--bg);
  padding: 0.75rem 0;
  margin-bottom: 0;
  box-shadow: 0 4px 6px -6px rgba(0, 0, 0, 0.2);
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
}
@media (max-width: 640px) {
  .two-col { grid-template-columns: 1fr; }
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 1rem;
  padding: 0.75rem 1rem 1rem;
}
legend { font-weight: 700; font-size: 0.85rem; color: var(--navy); padding: 0 0.3rem; }

.nav-dropdown {
  position: relative;
  display: inline-block;
  margin-left: 1rem;
}
.nav-dropdown-toggle {
  background: none;
  border: none;
  color: #d8def0;
  font-size: 0.92rem;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  margin: 0;
}
.nav-dropdown-toggle:hover { color: white; }

.nav-dropdown-panel {
  display: none;
  position: absolute;
  top: calc(100% + 0.9rem);
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  padding: 0.6rem 0;
  min-width: 200px;
  z-index: 200;
}
.nav-dropdown.open .nav-dropdown-panel { display: block; }

.nav-dropdown-section { padding: 0.3rem 1rem; }
.nav-dropdown-section + .nav-dropdown-section {
  border-top: 1px solid var(--border);
  margin-top: 0.3rem;
  padding-top: 0.7rem;
}
.nav-dropdown-heading {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}
.navbar .nav-dropdown-panel a {
  display: block;
  padding: 0.25rem 0;
  margin: 0;
  color: var(--text);
  font-size: 0.88rem;
}
.navbar .nav-dropdown-panel a:hover { color: var(--navy); }

/* An open multi-select panel is absolutely positioned and would otherwise
   float on top of the Filter/Reset buttons below it (making them
   unclickable, since the panel — not the button — receives the click) and
   the table further down. JS toggles .ms-open on the filter card while any
   panel is open; push the button row down clear of the tallest possible
   panel instead of leaving buttons stranded underneath it. */
.filters-card.ms-open .filters-buttons { margin-top: 320px; }

.ms { position: relative; }
.ms-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  font-size: 0.92rem;
  font-family: inherit;
  cursor: pointer;
  color: var(--text);
}
.ms-toggle:hover { border-color: var(--navy); }
.ms-caret { color: var(--muted); font-size: 0.7rem; margin-left: 0.4rem; }

.ms-panel {
  display: none;
  position: absolute;
  top: calc(100% + 0.3rem);
  left: 0;
  z-index: 150;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  padding: 0.6rem;
  width: max-content;
  min-width: 220px;
  max-width: 300px;
}
.ms-panel.open { display: block; }

.ms-mode {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  padding-bottom: 0.5rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.ms-mode label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 400;
  margin: 0;
}
.ms-mode input { width: auto; }

.ms-actions { display: flex; gap: 0.75rem; margin-bottom: 0.4rem; }
.ms-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--navy);
  font-size: 0.78rem;
  cursor: pointer;
  text-decoration: underline;
  margin: 0;
}

.ms-options {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.ms-option {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 400;
  font-size: 0.86rem;
  margin: 0;
}
.ms-option input { width: auto; }

.video-embed {
  position: relative;
  width: 100%;
  max-width: 640px;
  aspect-ratio: 16 / 9;
  margin-top: 0.75rem;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}
.video-embed iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.material-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}
.material-card {
  display: flex;
  flex-direction: column;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  color: var(--text);
}
.material-card:hover { text-decoration: none; border-color: var(--navy); }
.material-card-cover {
  aspect-ratio: 3 / 4;
  background: #eef1f8;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.material-card-cover img { width: 100%; height: 100%; object-fit: cover; }
.material-card-cover-placeholder { color: var(--muted); font-size: 0.82rem; }
.material-card-body {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.material-card-body strong { font-size: 0.95rem; }

.page-viewer { margin-top: 0.75rem; }
.page-viewer-frame {
  position: relative;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #eef1f8;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.page-viewer-img { display: none; width: 100%; height: auto; }
.page-viewer-img.active { display: block; }
.page-viewer-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.5rem;
}
