body {
  font-family: 'Helvetica', 'Arial', sans-serif; /* Clean, professional sans-serif font */
  font-size: 16px; /* Base font size for readability */
  background: #f4f4f4;
  padding: 2vw;
  margin: 0;
  transition: background-color 0.3s;
}

body.dark-mode {
  background: #1a1a1a;
  color: #f4f4f4;
}

.container {
  width: 90%;
  max-width: 1200px;
  margin: 0 auto;
  background: white;
  padding: 2vw;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0,0,0,0.1);
  transition: background-color 0.3s, color 0.3s;
  overflow-x: auto;
}

body.dark-mode .container {
  background: #2d2d2d;
  color: #f4f4f4;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1vw;
}

.title-section {
  flex: 1;
}

h1 {
  text-align: left;
  color: #000000; /* Black */
  font-size: 28px; /* Larger for emphasis */
  font-weight: bold;
  margin: 0 0 0.5vw 0;
  cursor: pointer;
}

body.dark-mode h1 {
  color: #f4f4f4;
}

#inspectors input {
  width: 100%;
  max-width: 300px;
  padding: 0.5vw;
  margin: 0.25vw 0;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px; /* Smaller for secondary text */
  box-sizing: border-box;
  background: white;
  color: #333;
}

body.dark-mode #inspectors input {
  background: #3d3d3d;
  color: #f4f4f4;
  border-color: #555;
}

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5vw;
}

#inspectionDate {
  padding: 0.5vw;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
  background: white;
  color: #333;
}

body.dark-mode #inspectionDate {
  background: #3d3d3d;
  color: #f4f4f4;
  border-color: #555;
}

#themeToggle {
  background: #333333; /* Grey */
  color: white;
  border: none;
  padding: 0.5vw 1vw;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px; /* Button font size */
  font-weight: bold;
  text-transform: uppercase;
}

#themeToggle:hover {
  background: #666666; /* Lighter grey on hover */
}

h2 {
  color: #000000; /* Black */
  font-size: 20px; /* Smaller than h1 */
  font-weight: bold;
}

body.dark-mode h2 {
  color: #f4f4f4;
}

.step {
  margin: 2vw 0;
}

input, textarea {
  width: 100%;
  padding: 1vw;
  margin: 0.5vw 0;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 16px; /* Consistent with body text */
  box-sizing: border-box;
  background: white;
  color: #333;
}

body.dark-mode input,
body.dark-mode textarea {
  background: #3d3d3d;
  color: #f4f4f4;
  border-color: #555;
}

input.error, textarea.error {
  border-color: #d9534f; /* Red for errors */
}

#hazardPictureUpload, #hazardPictureCamera {
  margin-bottom: 1vw;
}

#previewImages {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5vw;
}

#previewImages .image-container {
  position: relative;
  display: inline-block;
}

#previewImages img {
  max-width: 100%;
  max-height: 20vh;
  border: 1px solid #ccc;
  border-radius: 4px;
}

body.dark-mode #previewImages img {
  border-color: #555;
}

#previewImages .delete-btn {
  position: absolute;
  top: 0;
  right: 0;
  background: #d9534f; /* Red for delete */
  color: white;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
  cursor: pointer;
  padding: 0;
}

#previewImages .delete-btn:hover {
  background: #c9302c;
}

.hazard-picture {
  max-width: 100%;
  max-height: 15vh;
  margin: 0.25vw;
}

button {
  background: #000000; /* Black */
  color: white;
  border: none;
  padding: 0.75vw 1.5vw;
  margin: 0.5vw;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  text-transform: uppercase;
  transition: background-color 0.2s;
}

button:hover {
  background: #333333; /* Darker grey on hover */
}

body.dark-mode button {
  background: #666666; /* Lighter grey in dark mode */
}

body.dark-mode button:hover {
  background: #999999;
}

button.selected {
  background: #FFC107; /* Yellow for selected state */
  color: #000000;
}

.button-container {
  text-align: center;
  margin-top: 1.5vw;
}

.action-btn {
  padding: 1vw 2vw;
  font-size: 16px;
  margin: 0 1vw;
}

.back-btn {
  background: #666666; /* Secondary grey */
}

.back-btn:hover {
  background: #999999;
}

body.dark-mode .back-btn {
  background: #999999;
}

body.dark-mode .back-btn:hover {
  background: #cccccc;
}

.save-btn {
  background: #FFC107; /* Yellow for save */
  color: #000000;
}

.save-btn:hover {
  background: #ffca2c; /* Lighter yellow on hover */
}

body.dark-mode .save-btn {
  background: #ffca2c;
}

body.dark-mode .save-btn:hover {
  background: #ffd659;
}

.hrn-red { background-color: #ffcccc; color: #d9534f; }
.hrn-yellow { background-color: #fff3cd; color: #856404; }
.hrn-green { background-color: #d4edda; color: #155724; }

body.dark-mode .hrn-red { background-color: #660000; }
body.dark-mode .hrn-yellow { background-color: #665500; }
body.dark-mode .hrn-green { background-color: #004d00; }

.hazard-link {
  color: #000000; /* Black */
  cursor: pointer;
  text-decoration: underline;
}

body.dark-mode .hazard-link {
  color: #f4f4f4;
}

.hazard-link:hover {
  color: #333333;
}

body.dark-mode .hazard-link:hover {
  color: #cccccc;
}

.sort-buttons {
  text-align: center;
  margin-bottom: 1vw;
}

.sort-btn {
  background: #333333; /* Dark grey for sort buttons */
  padding: 0.75vw 1.5vw;
  margin: 0 0.5vw;
}

.sort-btn:hover {
  background: #666666;
}

body.dark-mode .sort-btn {
  background: #666666;
}

body.dark-mode .sort-btn:hover {
  background: #999999;
}

.log {
  margin-top: 3vw;
  width: 100%;
  overflow-x: auto;
  background: inherit;
  padding: 0;
  position: relative;
}

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  background: inherit;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px; /* Smaller for table readability */
}

th, td {
  border: 1px solid #ddd;
  padding: 1vw;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

th:nth-child(9), td:nth-child(9) {
  max-width: 200px;
}

body.dark-mode th,
body.dark-mode td {
  border-color: #555;
}

th {
  background: #000000; /* Black */
  color: white;
}

body.dark-mode th {
  background: #333333;
}

tr:nth-child(even) {
  background: #f2f2f2;
}

body.dark-mode tr:nth-child(even) {
  background: #3d3d3d;
}

.delete-btn {
  background: #d9534f;
}

.delete-btn:hover {
  background: #c9302c;
}

body.dark-mode .delete-btn {
  background: #ff6666;
}

body.dark-mode .delete-btn:hover {
  background: #ff3333;
}

#progressBar {
  width: 100%;
  background-color: #ddd;
  border-radius: 4px;
  margin-bottom: 1vw;
  height: 10px;
}

#progressFill {
  height: 100%;
  background-color: #FFC107; /* Yellow */
  border-radius: 4px;
  transition: width 0.3s;
}

body.dark-mode #progressFill {
  background-color: #ffca2c;
}

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.8);
  justify-content: center;
  align-items: center;
}

.modal-content {
  max-width: 90%;
  max-height: 90%;
}

.close {
  position: absolute;
  top: 10px;
  right: 20px;
  color: white;
  font-size: 30px;
  cursor: pointer;
}

.log::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 10px;
  height: 100%;
  background: linear-gradient(to left, rgba(0,0,0,0.1), transparent);
  pointer-events: none;
  display: none;
}

body.dark-mode .log::after {
  background: linear-gradient(to left, rgba(255,255,255,0.1), transparent);
}

.log.overflow::after {
  display: block;
}

@media (max-width: 600px) {
  .log {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    min-width: 600px;
  }
  th, td {
    min-width: 100px;
    max-width: 100px;
  }
  th:nth-child(9), td:nth-child(9) {
    max-width: 150px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 3vw;
  }
  input, textarea, button {
    padding: 2vw;
    margin: 1vw 0;
  }
  .action-btn {
    padding: 2vw 4vw;
    width: 100%;
    margin: 1vw 0;
  }
  .button-container {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .sort-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
  }
  .sort-btn {
    width: 45%;
    margin: 1vw;
  }
  header {
    flex-direction: column;
    align-items: flex-start;
  }
  .header-right {
    align-items: flex-start;
    margin-top: 1vw;
  }
  #themeToggle {
    margin-top: 0.5vw;
  }
}