/* Base layout */
html, body {
  height: 100%;
  margin: 0;
  overflow-x: hidden; /* prevent body from scrolling left/right */
}

body {
  display: flex;
  flex-direction: column;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: #f4f4f4;
  min-height: 100vh; /* ensure full viewport height */
}

/* Header / branding */
.site-header {
  background-color: #7ea253;
}
.site-header .header-inner {
  width: 100%;
  margin: 0 auto;
  padding: 10px 16px;
  min-height: 64px;
  position: relative;
  display: flex;
  align-items: center;
}
.site-header .brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.site-header .logo {
  height: 40px;
  width: auto;
  display: block;
}
.site-header .header-text {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  line-height: 1.2;
}
.site-header .site-title {
  color: #fff;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.1px;
  margin: 0 8px 2px;
}
.site-header .site-link a {
  color: #cce8c1;
  font-size: 0.94rem;
  font-weight: 500;
  text-decoration: none;
  opacity: 0.95;
}
.site-header .site-link a:hover {
  text-decoration: underline;
  opacity: 1;
}

/* Print button */
.print-btn {
  display: none;            /* default hidden, we enable on desktop widths */
  margin-left: 10px;
  padding: 4px 10px;
  font-size: 0.85rem;
  border-radius: 999px;
  border: 1px solid #4b5563;
  background: #ffffff;
  color: #111827;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.print-btn:hover { background: #f3f4f6; }

/* show on desktop widths only */
@media (min-width: 900px) {
  .print-btn { display: inline-block; }
}

@media (max-width: 720px) {
  .site-header .header-inner {
    flex-direction: column;
    align-items: center;
    padding: 10px 12px;
    min-height: unset;
  }
  .site-header .header-text {
    position: static;
    transform: none;
    margin-top: 6px;
  }
  .site-header .logo { height: 34px; }
  .site-header .site-title { font-size: 1.15rem; }
  .site-header .site-link a { font-size: 0.9rem; }
}

/* legacy map bits (fine to leave for other tools) */
#map {
  flex: 1;
  width: 100%;
}

/* Legend */
.legend {
  position: static;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  padding: 12px 18px;
  width: 320px;
  font-size: 1rem;
  color: #333;
  line-height: 1.4;
  margin: 0 0 8px 0;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
}
.legend-dot {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.4);
  display: inline-block;
}
@media (max-width: 600px) {
  .legend {
    width: 260px;
    padding: 10px 14px;
    font-size: 0.9rem;
  }
  .legend-dot {
    width: 14px;
    height: 14px;
  }
}

.legend-toggle {
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  padding: 6px 10px;
  font-size: 0.95rem;
  color: #333;
}
.legend-toggle label {
  cursor: pointer;
  user-select: none;
}
.legend-toggle input[type="checkbox"] {
  margin-right: 6px;
  accent-color: #7ea253;
}

/* Hamburger control */
.leaflet-control.menu-control {
  position: relative;
  background: transparent;
  border: 0;
}
.menu-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #ddd;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,.1);
  line-height: 1;
}
.menu-button:focus,
.menu-button:active {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59,130,246,.25), 0 2px 10px rgba(0,0,0,.1);
  transform: none;
}

.menu-panel {
  position: absolute;
  top: 44px;
  right: 0;
  width: 280px;
  max-height: 70vh;
  overflow: auto;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,.18);
  padding: 10px 12px;
  display: none;
  z-index: 1000;
}
.menu-panel.open { display: block; }
.menu-title {
  font: 700 14px/1.2 Inter, system-ui, sans-serif;
  margin: 6px 0 8px;
}
.menu-section { margin-bottom: 12px; }
.menu-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
}
.menu-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
}
.menu-help {
  color: #6b7280;
  font-size: 12px;
  margin-top: 4px;
}
.menu-divider {
  height: 1px;
  background: linear-gradient(90deg,#0000,#dcdcdc,#0000);
  margin: 8px 0;
}
.menu-legend .legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
}
.menu-legend .legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* ====== PAGE LAYOUT FOR MISSING TABLE (full-viewport) ====== */

.page-main {
  flex: 1 1 auto;              /* take all remaining space below header */
  display: flex;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  width: 100%;
  overflow-x: hidden;           /* keep main layout from scrolling horizontally */
  min-height: 0;                /* allow children to size/scroll properly */
}

.content-shell {
  width: 100%;
  max-width: none;
  margin: 0;  

  /* Make it a flex column so the table can fill remaining height */
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;                /* critical for the child to use the space */
}

.page-intro {
  margin-bottom: 10px;
  color: #444;
  font-size: 0.95rem;
  line-height: 1.45;
  text-align: center;
}

/* place print button under text when visible */
.page-intro .print-btn {
  margin-top: 8px;
  margin-left: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  background: #ecf3e3;
  color: #3f6212;
  border: 1px solid #c4d7a3;
  margin-left: 4px;
}

/* TABLE CARD – fills remaining height and scrolls internally */
.table-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
  border: 1px solid #d1d5db;
  padding: 12px 16px 8px;

  flex: 1 1 auto;               /* fill remaining space in column */
  height: auto;
  max-height: none;             /* no fixed caps; use available viewport */
  max-width: 100%;              /* never wider than viewport */
  box-sizing: border-box;

  overflow-x: auto;             /* table can scroll horizontally */
  overflow-y: auto;             /* vertical scroll inside the card */
}

.table-card table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
  font-size: 0.9rem;
}

.table-card thead {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.table-card th,
.table-card td {
  padding: 6px 8px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.table-card th {
  font-weight: 600;
  font-size: 0.78rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #f9fafb;
}

.table-card tbody tr:nth-child(even) { background: #fafafa; }
.table-card tbody tr:hover { background: #eef5e6; }

.photo-cell { white-space: normal; }

/* Label/value spans inside table cells */
.table-card .cell-label {
  display: none; /* included for possible future layouts; hidden in standard table */
}

/* Thumbnails */
.thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 999px;
  margin-right: 4px;
  cursor: pointer;
  border: 2px solid #7ea253;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.9);
  background: #fff;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.thumb:hover {
  transform: scale(1.08);
  box-shadow: 0 0 0 2px rgba(126,162,83,0.5);
}

.status-bar {
  margin-top: 8px;
  font-size: 0.83rem;
  color: #6b7280;
}
.status-bar span {
  color: #111827;
  font-weight: 600;
}

/* Modal */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0,0,0,0.8);
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop.open { display: flex; }

.modal-shell {
  max-width: 800px;
  width: 100%;
  background: #ffffff;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  box-shadow: 0 22px 45px rgba(0,0,0,0.4);
  padding: 8px 10px 10px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 4px;
}
.modal-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #111827;
  margin-right: 0.5rem;
}
.modal-close {
  cursor: pointer;
  border: none;
  background: transparent;
  font-size: 1.3rem;
  line-height: 1;
  color: #6b7280;
}
.modal-close:hover { color: #b91c1c; }
.modal-image-wrap { text-align: center; margin-top: 2px; }
.modal-image-wrap img {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 6px;
}
.modal-caption {
  margin-top: 6px;
  font-size: 0.8rem;
  color: #6b7280;
  text-align: center;
}

/* MOBILE TWEAKS – keep full-height behavior */
@media (max-width: 640px) {
  .page-main { padding: 12px; }
  .page-intro { font-size: 0.9rem; }

  .table-card {
    padding: 8px 8px 6px;
    flex: 1 1 auto;
    max-height: none;
  }

  .table-card table { font-size: 0.8rem; }
  .table-card th {
    font-size: 0.7rem;
    padding: 4px 6px;
  }
  .table-card td { padding: 4px 6px; }
}

/* Sortable table headers */
.table-card th.sortable {
  cursor: pointer;
  user-select: none;
}
.table-card th.sortable::after {
  content: "";
  margin-left: 4px;
  font-size: 0.7rem;
  opacity: 0.35;
}
.table-card th.sortable.sorted-asc::after {
  content: "▲";
  opacity: 0.8;
}
.table-card th.sortable.sorted-desc::after {
  content: "▼";
  opacity: 0.8;
}

/* Print: page setup */
@page {
  size: landscape;
  margin: 0.5in;
}

/* Print layout – only show the table/list */
@media print {
  html, body {
    height: auto;
    margin: 0;
    padding: 0;
    overflow: visible;
    background: #ffffff;
  }

  /* Hide site chrome and non-table stuff */
  .site-header,
  .page-intro,
  .status-bar,
  .print-btn,
  .modal-backdrop,
  .legend,
  .legend-toggle,
  .menu-panel,
  .menu-button {
    display: none !important;
  }

  .page-main { padding: 0; }
  .content-shell {
    max-width: none;
    margin: 0;
    display: block;  /* flatten for print */
    height: auto;
  }

  .table-card {
    box-shadow: none;
    border: none;
    padding: 0;
    max-height: none;
    overflow: visible;   /* show whole table, no clipped scroll area */
  }

  .table-card table {
    min-width: 0;        /* let it shrink to fit the page width */
    width: 100%;
    font-size: 10pt;
    border-collapse: collapse;
  }

  .table-card th,
  .table-card td {
    white-space: nowrap; /* keep fields on one line each */
  }
}
