body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; /* Added Geneva, Verdana for wider sans-serif compatibility */
    background-color: #F8F9FA; /* Cleaner, light background */
    color: #343A40; /* Darker text for better readability */
    padding: 1.5rem; /* Increased padding */
    margin: 0;
    overflow-x: hidden; /* Prevent horizontal scroll */
    line-height: 1.6; /* Improved line spacing */
  }
  
  header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem; /* Increased margin */
  }
  
  .logo {
    height: 50px;
  }
  
  h1 {
    color: #212529; /* Stronger heading color */
    font-weight: 600;
  }
  
  nav {
    margin-bottom: 1.5rem; /* Increased margin */
    display: flex; /* Added for flex-wrap capabilities */
    flex-wrap: wrap; /* Allow nav buttons to wrap */
    gap: 8px; /* Add gap for wrapped buttons */
  }
  
  nav button {
    /* margin-right: 8px; /* Replaced by gap */
    margin-bottom: 8px; /* Add margin for when buttons wrap - this can be part of gap too */
    padding: 12px 18px; /* Increased padding for better touch targets */
    border-radius: 8px; /* Softer corners */
    border: none;
    cursor: pointer;
    background-color: #28a745; /* Primary green */
    color: white;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.08); /* Subtle 3D shadow */
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  }

  nav button:hover {
    background-color: #218838; /* Darker green on hover */
    transform: translateY(-1px); /* Slight lift effect */
    box-shadow: 0 4px 8px rgba(0,0,0,0.12), 0 2px 4px rgba(0,0,0,0.1); /* Enhanced shadow on hover */
  }
  
  form {
    background-color: #FFFFFF; /* Explicit white background */
    padding: 2rem; /* Increased padding */
    border-radius: 12px; /* More rounded corners for a modern card look */
    box-shadow: 0 8px 24px rgba(0,0,0,0.08); /* Softer, more diffused shadow */
    margin-bottom: 1.5rem; /* Consistent margin */
  }

  input[type="file"] {
    border: 1px solid #CED4DA; /* Consistent border with other inputs */
    background-color: #FFFFFF;
    padding: 12px; /* Consistent padding */
    border-radius: 8px; /* Consistent radius */
    display: block; /* Ensure it takes full width if needed or style as inline-block */
    width: 100%;
    box-sizing: border-box;
  }
  
  .map-wrapper {
    width: 100%; /* Make map wrapper responsive */
    max-width: 70vw; /* Limit max width on larger screens */
    margin: 0 auto 1.5rem auto; /* Centered with bottom margin */
    padding: 0;
  }
  
  #map {
    height: 350px; /* Slightly taller map */
    width: 100%;
    border-radius: 12px; /* Consistent with form/card styling */
    background: #E9ECEF; /* Lighter placeholder color */
    box-shadow: 0 4px 12px rgba(0,0,0,0.06); /* Subtle shadow for map */
  }
  
  input, select, textarea { /* General input styling, button styling will be more specific */
    padding: 12px;
    width: 100%;
    margin-bottom: 1rem; /* Consistent margin */
    border: 1px solid #CED4DA; /* Standard border color */
    border-radius: 8px; /* Softer corners */
    box-sizing: border-box;
    background-color: #FFFFFF;
    color: #495057;
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
  }

  /* Specific styling for date input within the data-form on index.html */
  #data-form input[type="date"] { 
    -webkit-appearance: none; 
    appearance: none;
    min-height: 48px; /* Ensure decent tap target size */
    line-height: normal; /* Reset from 1.5 if it causes issues, or adjust padding */
    color: #495057; /* Ensure text color is visible */
    background-image: url('data:image/svg+xml;utf8,<svg fill="%236c757d" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>'); /* Basic dropdown indicator, can be improved */
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px; /* Adjust size of indicator */
    padding-right: 2.5rem; /* Make space for indicator */
  }
  
  #data-form input[type="date"]::-webkit-calendar-picker-indicator { 
    opacity: 0; /* Hide default ugly indicator for data-form date inputs */
  }

  /* General focus styles - ensure date inputs on viewer page get default focus behavior if not overridden by above */
  input:focus, select:focus, textarea:focus {
    border-color: #28a745; /* Primary green focus */
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25); /* Bootstrap-like focus glow */
    outline: none;
  }

  /* Specific styling for general buttons if they exist outside nav/form context */
  /* This also applies to buttons in viewer.html's button bar */
  .general-button { 
    padding: 12px 18px;
    width: auto; 
    margin-bottom: 8px; /* Add margin for when buttons wrap */
    border: 1px solid #CED4DA;
    border-radius: 8px;
    box-sizing: border-box;
    background-color: #6C757D; 
    color: white;
    cursor: pointer;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0,0,0,0.07);
    transition: background-color 0.2s ease, transform 0.2s ease;
  }

  button.general-button:hover {
    background-color: #5a6268;
    transform: translateY(-1px);
  }
  
  table {
    width: 100%;
    border-collapse: separate; /* Changed for border-radius to work on table */
    border-spacing: 0; /* Required with border-collapse: separate */
    background-color: #FFFFFF;
    border-radius: 12px; /* Rounded corners for the table */
    box-shadow: 0 8px 24px rgba(0,0,0,0.08); /* Consistent shadow */
    /* overflow: hidden; /* REMOVED: This can interfere with sticky positioning of thead */
    margin-bottom: 1.5rem;
  }
  
  th, td {
    border-bottom: 1px solid #EAEEF3; /* Lighter, modern row separator */
    padding: 12px 15px; /* Increased padding */
    text-align: left;
    vertical-align: middle;
    /* Add a right border to all th and td except the last one in a row */
    border-right: 1px solid #EAEEF3; 
  }

  th:last-child,
  td:last-child {
    border-right: none; /* No right border for the very last cell in a row */
  }

  tr:last-child td {
    border-bottom: none; /* No border for the last row's cells */
  }
  
  th {
    background-color: #F8F9FA; /* Light background for headers */
    color: #495057; /* Darker text for header */
    font-size: 0.875rem; /* Slightly smaller, standard header size */
    font-weight: 600; /* Bolder header text */
    text-transform: uppercase; /* Optional: uppercase headers */
    letter-spacing: 0.5px; /* Optional: slight letter spacing */
  }
  
  td {
    font-size: 0.9rem; /* Slightly larger body text */
    color: #343A40;
  }
  
  /* Responsive: hide overflow columns on small screens */
  @media only screen and (max-width: 600px) {
    th:nth-child(n+7), td:nth-child(n+7) {
      display: none;
    }
    /* Ensure buttons in flex containers also get bottom margin when wrapped on small screens */
    /* This targets the div holding viewer page buttons */
    div[style*="display: flex"][style*="flex-wrap: wrap"] > button.general-button {
        margin-bottom: 8px;
    }
  }

/* Styles for Viewer Page (Image Thumbnails & Fullscreen Viewer) */
img.thumbnail {
  height: 60px; /* Slightly larger thumbnail */
  width: auto; /* Maintain aspect ratio */
  max-width: 100px; /* Prevent overly wide thumbnails */
  cursor: pointer;
  border-radius: 8px; /* Consistent with other elements */
  border: 1px solid #DEE2E6; /* Subtle border */
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  object-fit: cover; /* Ensure image covers the area well */
}

img.thumbnail:hover {
  transform: scale(1.05); /* Slight zoom on hover */
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.fullscreen-image {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.85); /* Slightly darker overlay */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0; /* Start hidden for transition */
  visibility: hidden; /* Start hidden for transition */
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.fullscreen-image.visible { /* Class to trigger visibility */
  opacity: 1;
  visibility: visible;
}

.fullscreen-image img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 12px; /* Consistent with cards/forms */
  box-shadow: 0 8px 30px rgba(0,0,0,0.3); /* Prominent shadow for the image */
}

.close-btn {
  position: absolute;
  top: 20px;
  right: 30px;
  font-size: 2rem; /* Larger, more touch-friendly */
  font-weight: 300;
  color: white;
  cursor: pointer;
  background-color: rgba(0,0,0,0.3);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.close-btn:hover {
  background-color: rgba(0,0,0,0.5);
  transform: scale(1.1);
}

/* Styles for Filter/Search Panel on Viewer Page */
.controls-panel {
  background-color: #FFFFFF;
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  margin-bottom: 1.5rem;
  border: 1px solid #E9ECEF; /* Subtle frame */
  display: none; /* Hidden by default */
  max-width: 700px; /* Max width for the panel */
}

.controls-panel.visible {
  display: block; /* Show when .visible class is added */
}

.controls-panel .input-group {
  display: flex;
  gap: 1rem; /* Space between input fields */
  flex-wrap: wrap; /* Allow wrapping on smaller screens */
}

.controls-panel .input-group input[type="text"] {
  flex-grow: 1; /* Allow inputs to grow */
  min-width: 200px; /* Minimum width before wrapping */
}

/* Style for the toggle button if it doesn't use .general-button */
#toggle-controls-btn {
  /* Uses .general-button, but we can add specific overrides if needed */
}

/* Main Program Titles on Viewer Page */
.main-titles-container {
  text-align: center;
  margin-bottom: 2rem; /* Increased space below titles */
  padding-bottom: 1rem;
  border-bottom: 1px solid #DEE2E6;
}

.main-program-title {
  margin-bottom: 0.5rem; /* Space between main and sub title */
  font-size: 1.6rem; /* Adjust as needed */
  color: #343A40;
  font-weight: 600;
}

.sub-program-title {
  margin-top: 0;
  font-size: 1.15rem; /* Adjust as needed */
  color: #495057;
  font-weight: 400; /* Lighter than main title */
}

/* Table header specific styles for grouped headers */
#viewer-table thead th {
  text-align: center; /* Center align all header text */
  vertical-align: middle;
  font-weight: 600; /* Ensure group headers are bold */
   z-index: 11; 
}

#viewer-table thead tr:first-child th { 
  background-color: #E9ECEF; 
  color: #343A40;
  border-bottom: 1px solid #CED4DA; 
}

#viewer-table thead tr:last-child th { 
  background-color: #F8F9FA; 
  font-weight: 500; 
}

/* Sticky table headers */
#viewer-table thead tr { 
  position: -webkit-sticky; 
  position: sticky;
  z-index: 10; 
}

#viewer-table thead tr:first-child { 
  top: 0; 
}

#viewer-table thead tr:last-child { 
  top: 45px; /* Approximate height of the first header row, adjust if necessary */
}

.table-responsive-wrapper {
  width: 100%;
  overflow-x: auto; 
  overflow-y: auto; 
  max-height: 70vh; 
  margin-bottom: 1.5rem; 
  -webkit-overflow-scrolling: touch; 
  border: 1px solid #DEE2E6; 
  border-radius: 8px; 
}

.table-responsive-wrapper::-webkit-scrollbar {
  height: 16px; 
  width: 16px;  
}

.table-responsive-wrapper::-webkit-scrollbar-track {
  background: #e9ecef; 
  border-radius: 10px;
}

.table-responsive-wrapper::-webkit-scrollbar-thumb {
  background: #28a745; 
  border-radius: 10px;
  border: 2px solid #e9ecef; 
}

.table-responsive-wrapper::-webkit-scrollbar-thumb:hover {
  background: #218838; 
}

/* Viewer Page Header Styles */
.viewer-header {
  display: flex;
  align-items: center;
  margin-bottom: 1.5rem; 
  padding-bottom: 1rem; 
  border-bottom: 1px solid #DEE2E6; 
}

.viewer-header .header-logo {
  height: 40px; 
  width: 40px; 
  margin-right: 1rem;
}

.viewer-header h1 {
  flex-grow: 1; 
  text-align: center; 
  margin: 0; 
  font-size: 1.75rem; 
}

.viewer-header #logout-viewer-btn {
  /* margin-left: auto; /* This was in inline style, can be moved here if preferred */
}

/* Styles for #fullscreen-img for zooming */
#fullscreen-img {
  transform-origin: center center;
  transition: transform 0.2s ease-out;
  /* Existing styles like max-width, max-height, border-radius will be inherited if not overridden by .fullscreen-image img */
}

/* Styles for Zoom Controls in Fullscreen Viewer */
.zoom-controls {
  position: absolute;
  bottom: 30px; /* Increased from 20px for better spacing from edge */
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(40, 40, 40, 0.7); /* Darker, slightly more opaque background */
  padding: 8px 12px; /* Slightly more padding */
  border-radius: 8px; /* Softer radius */
  display: flex;
  gap: 12px; /* Increased gap */
  z-index: 1001; /* Ensure it's above the image if image has z-index */
  box-shadow: 0 2px 10px rgba(0,0,0,0.3); /* Subtle shadow for depth */
}

.zoom-controls button {
  background-color: #f8f9fa; /* Light background */
  color: #212529; /* Dark text */
  border: 1px solid #ced4da; /* Subtle border */
  border-radius: 5px; /* Consistent radius */
  padding: 6px 12px; /* Adjusted padding */
  font-size: 1.1rem; /* Slightly adjusted font size */
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.zoom-controls button:hover {
  background-color: #e9ecef; /* Slightly darker on hover */
  border-color: #adb5bd;
}

.zoom-controls button:active {
  transform: scale(0.95); /* Click effect */
}

/* Accessibility helper class */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px; /* Negative margin to ensure it's truly out of flow */
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap; /* Prevent line breaks from affecting layout */
  border: 0;
}

/* Styling for date inputs in the viewer's filter panel - to hide native picker */
#filter-search-panel input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  /* Reset any background image that might have been applied from previous attempts */
  background-image: none; 
  /* Adjust padding if necessary, but without an internal icon, default input padding should be fine */
  /* padding-right: 0.75em; /* Or whatever the default padding for other inputs is */
  /* Ensure it inherits general input styling for border, radius, color, min-height */
}

#filter-search-panel input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0; /* Hide the default WebKit picker indicator */
  display: none; /* Also try display none for good measure */
}

/* Styling for the external calendar icon trigger */
.calendar-icon-trigger {
  display: inline-block;
  width: 24px; /* Adjust size as needed */
  height: 24px; /* Adjust size as needed */
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="%23495057" viewBox="0 0 16 16"><path d="M11 6.5a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-1a.5.5 0 0 1-.5-.5v-1z"/><path d="M3.5 0a.5.5 0 0 1 .5.5V1h8V.5a.5.5 0 0 1 1 0V1h1a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h1V.5a.5.5 0 0 1 .5-.5zM1 4v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V4H1z"/></svg>');
  background-repeat: no-repeat;
  background-position: center center;
  background-size: contain; /* Or specific size like 18px 18px */
  cursor: pointer;
  vertical-align: middle; /* Helps align with the input field if they are in a flex container */
}
