body {
  font-family: "Arial", sans-serif;
  margin: 0;
  padding: 10px;
  background: linear-gradient(135deg, #f0f8f0 0%, #e0f0e0 100%);
  color: #333;
}

h1 {
  text-align: center;
  color: #003366;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 1.6em;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  margin-bottom: 20px;
}

#loginScreen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #f0f8f0, #e0f0e0);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

#loginBox {
  background: white;
  border: 2px solid #004d00;
  border-radius: 12px;
  padding: 40px 32px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 280px;
  text-align: center;
}

#loginBox h2 {
  color: #004d00;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 1px;
}

#passwordInput {
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1em;
  text-align: center;
}

#loginBtn {
  padding: 10px;
  background: linear-gradient(145deg, #004d00, #006600);
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: bold;
  font-size: 1em;
  cursor: pointer;
  transition: all 0.2s ease;
}

#loginBtn:hover {
  background: linear-gradient(145deg, #006600, #008800);
}

#loginError {
  color: #dc3545;
  font-size: 0.9em;
  margin: 0;
  min-height: 1.2em;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  background: linear-gradient(145deg, #002200, #003300);
  padding: 10px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.tab-btn {
  flex: 1;
  padding: 14px 20px;
  border: 2px solid transparent;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.7);
  font-weight: bold;
  font-size: 1em;
  letter-spacing: 0.5px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.tab-btn:hover {
  background: rgba(255,255,255,0.15);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.tab-btn.active {
  background: linear-gradient(145deg, #ffcb2d, #e6b800);
  color: #002200;
  border-color: #e6b800;
  box-shadow: 0 4px 14px rgba(255,203,45,0.4);
  transform: translateY(-2px);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.container {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.hierarchy,
.people-table {
  min-width: 0;
  width: 100%;
  background: linear-gradient(145deg, #ffffff 0%, #f0f8f0 100%);
  padding: 15px;
  border-radius: 12px;
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.15),
    0 4px 10px rgba(0, 77, 0, 0.1);
  border: 2px solid #004d00;
  box-sizing: border-box;
}

.hierarchy {
  flex: 1 1 280px;
}

.people-table {
  flex: 2 1 320px;
  overflow-x: auto;
}

.hierarchy h2,
.people-table h2 {
  margin-top: 0;
  color: #004d00; /* Tummanvihreä */
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 1.4em;
  border-bottom: 3px solid #003366;
  padding-bottom: 10px;
}

.hierarchyActions {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.hierarchyActions button {
  flex: 1;
  padding: 8px 6px;
  border: none;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
  font-size: 0.85em;
  transition: all 0.2s ease;
}

#autoAssignBtn, #autoAssignVehicleBtn {
  background: linear-gradient(145deg, #004d00, #006600);
  color: white;
}

#autoAssignBtn:hover, #autoAssignVehicleBtn:hover {
  background: linear-gradient(145deg, #006600, #008800);
  transform: scale(1.03);
}

#clearAllBtn, #clearAllVehicleBtn {
  background: linear-gradient(145deg, #dc3545, #c82333);
  color: white;
}

#clearAllBtn:hover, #clearAllVehicleBtn:hover {
  background: linear-gradient(145deg, #c82333, #a02622);
  transform: scale(1.03);
}


#exportPersonnelCsvBtn, #exportPersonnelXlsxBtn,
#exportVehicleCsvBtn, #exportVehicleXlsxBtn {
  background: linear-gradient(145deg, #003366, #004488);
  color: white;
}

#exportPersonnelCsvBtn:hover, #exportPersonnelXlsxBtn:hover,
#exportVehicleCsvBtn:hover, #exportVehicleXlsxBtn:hover {
  background: linear-gradient(145deg, #004488, #0055aa);
  transform: scale(1.03);
}


#vehicleTree {
  list-style-type: none;
  padding-left: 0;
}

#tree ul,
#vehicleTree ul {
  padding-left: 20px;
  display: none; /* Oletuksena piilotettu */
}

#tree li,
  #vehicleTree li {
  margin: 5px 0;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 6px;
  transition: all 0.3s ease;
  background: linear-gradient(145deg, #f9f9f9 0%, #e0f0e0 100%);
  border: 1px solid #ccc;
}

#tree li:hover,
#vehicleTree li:hover {
  background: linear-gradient(145deg, #e0f0e0 0%, #c0e0c0 100%);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  transform: translateX(5px);
}

#tree li.task,
#vehicleTree li.task {
  cursor: grab;
  border: 2px solid #004d00;
  background: linear-gradient(145deg, #f9f9f9 0%, #e0f0e0 100%);
  transition: all 0.3s ease;
  font-weight: bold;
  color: #004d00;
}

#tree li.task:hover,
#vehicleTree li.task:hover {
  background: linear-gradient(145deg, #cce7ff 0%, #a0c0ff 100%);
  border-color: #007bff;
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.tree-pct {
  font-size: 0.8em;
  color: #666;
  font-weight: normal;
}

#tree li.task .tree-pct,
#vehicleTree li.task .tree-pct {
  color: #004d00;
}

#tree li.task.assigned .tree-pct,
#vehicleTree li.task.assigned .tree-pct {
  color: #155724;
}


  background-color: #d4edda !important;
  border-color: #28a745 !important;
  opacity: 0.7;
  color: #155724;
  font-style: italic;
}

.task.selected {
  background-color: #cce7ff;
  border-color: #007bff;
}

table {
  width: 100%;
  border-collapse: collapse;
  border: 2px solid #004d00;
  font-size: 0.8em;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

th,
td {
  padding: 8px 4px;
  text-align: left;
  border-bottom: 1px solid #ddd;
  background-color: #ffffff;
  white-space: nowrap;
}

td:hover {
  background-color: #f0f8f0;
}

th {
  background: linear-gradient(145deg, #004d00 0%, #006600 100%);
  color: white;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 5px;
  border-bottom: 2px solid #003366;
  cursor: pointer;
}

#filterRow input {
  width: 100%;
  padding: 5px;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
}

tr:hover {
  background-color: #f0f8f0; /* Vaalea vihreä hover */
}

.person-row {
  cursor: grab;
}

.person-row:active {
  cursor: grabbing;
}

.person-row.assigned {
  background-color: #e0e0e0;
  color: #666;
  font-style: italic;
}

.drag-over {
  background-color: #ffeaa7;
}

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

.modal.open {
  display: flex;
}

.modal-content {
  background: linear-gradient(145deg, #ffffff 0%, #f0f8f0 100%);
  border-radius: 15px;
  max-width: 600px;
  width: 100%;
  padding: 25px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  position: relative;
  border: 3px solid #004d00;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  border: none;
  background: #dc3545;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  color: white;
  transition: all 0.3s ease;
}

.modal-close:hover {
  background: #c82333;
  transform: scale(1.1);
}

.modal-content h3 {
  color: #003366;
  margin-top: 0;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 2px solid #004d00;
  padding-bottom: 10px;
}

.modal-content p {
  margin: 10px 0;
  line-height: 1.6;
  color: #333;
}

.modal-content strong {
  display: inline-block;
  min-width: 160px;
  color: #004d00;
  font-weight: bold;
}

#taskDetails,
#personDetails {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
}

#taskDetails p,
#personDetails p {
  margin: 6px 0;
}

#portraitContainer {
  text-align: center;
  margin-bottom: 15px;
  position: relative;
  display: inline-block;
  left: 50%;
  transform: translateX(-50%);
}

#detailPortrait {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 4px solid #004d00;
  background: #3d4a35;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  display: block;
}

#portraitContainer.unknown::after {
  content: "?";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 3em;
  font-weight: bold;
  color: white;
  text-shadow: 0 2px 6px rgba(0,0,0,0.6);
  pointer-events: none;
}

#personPortraitContainer {
  text-align: center;
  margin-bottom: 15px;
  position: relative;
  display: inline-block;
  left: 50%;
  transform: translateX(-50%);
}

#personPortrait {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 4px solid #004d00;
  background: #3d4a35;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  display: block;
}

#vehiclePortraitContainer {
  text-align: center;
  margin-bottom: 15px;
  position: relative;
  display: inline-block;
  left: 50%;
  transform: translateX(-50%);
}

#vehiclePortrait {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 4px solid #004d00;
  background: #3d4a35;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  display: block;
}

.candidate-card {
  background: linear-gradient(145deg, #f0f8f0 0%, #ffffff 100%);
  border: 2px solid #004d00;
  border-radius: 10px;
  padding: 15px;
  margin: 10px 0;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.candidate-card:hover {
  background: linear-gradient(145deg, #e0f0e0 0%, #cce7ff 100%);
  transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
  border-color: #007bff;
}

.candidate-card.assigned {
  background: linear-gradient(145deg, #d4edda 0%, #c3e6cb 100%);
  cursor: not-allowed;
  opacity: 0.7;
  color: #155724;
  font-style: italic;
}

.rank-icon {
  height: 1.4em;
  width: auto;
  vertical-align: middle;
  margin-right: 4px;
}

.unassign-btn {
  background: linear-gradient(145deg, #dc3545 0%, #c82333 100%);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s ease;
  margin-top: 10px;
}

.unassign-btn:hover {
  background: linear-gradient(145deg, #c82333 0%, #a02622 100%);
  transform: scale(1.05);
}

#pagination,
#vehiclePagination {
  margin-top: 20px;
  text-align: center;
}

#pagination button,
#vehiclePagination button {
  margin: 0 5px;
  padding: 8px 12px;
  border: 1px solid #004d00;
  background: linear-gradient(145deg, #ffffff 0%, #f0f8f0 100%);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.3s ease;
}

#pagination button.active,
#vehiclePagination button.active {
  background: linear-gradient(145deg, #004d00 0%, #006600 100%);
  color: white;
  border-color: #004d00;
}

#pagination button:hover:not(:disabled),
#vehiclePagination button:hover:not(:disabled) {
  background: linear-gradient(145deg, #e0f0e0 0%, #cce7ff 100%);
  transform: scale(1.05);
}

#pagination button:disabled,
#vehiclePagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 600px) {
  body {
    padding: 6px;
  }

  h1 {
    font-size: 0.95em;
    letter-spacing: 0;
    margin-bottom: 8px;
  }

  .tabs {
    gap: 4px;
    padding: 6px;
    margin-bottom: 10px;
  }

  .tab-btn {
    font-size: 0.75em;
    padding: 8px 4px;
    gap: 4px;
  }

  .container {
    gap: 8px;
  }

  .hierarchy,
  .people-table {
    padding: 8px;
    border-radius: 8px;
  }

  .hierarchy h2,
  .people-table h2 {
    font-size: 1em;
    padding-bottom: 6px;
    margin-bottom: 8px;
  }

  .hierarchyActions {
    gap: 4px;
    margin-bottom: 8px;
    flex-wrap: wrap;
  }

  .hierarchyActions button {
    font-size: 0.7em;
    padding: 6px 4px;
  }

  #tree li,
  #vehicleTree li {
    padding: 6px 8px;
    margin: 3px 0;
  }

  .modal {
    padding: 6px;
    align-items: flex-start;
    padding-top: 20px;
  }

  .modal-content {
    padding: 12px;
    max-height: 92vh;
    border-radius: 10px;
  }

  .modal-content h3 {
    font-size: 1em;
    padding-bottom: 6px;
    margin-bottom: 6px;
  }

  .modal-content p {
    margin: 5px 0;
  }

  .modal-content strong {
    min-width: 0;
    display: block;
    margin-bottom: 1px;
  }

  #portraitContainer,
  #personPortraitContainer,
  #vehiclePortraitContainer {
    margin-bottom: 8px;
  }

  #detailPortrait,
  #personPortrait,
  #vehiclePortrait {
    width: 80px;
    height: 80px;
  }

  th {
    font-size: 0.65em;
    padding: 6px 2px;
  }

  td {
    font-size: 0.7em;
    padding: 5px 2px;
  }

  #filterRow input,
  #vehicleFilterRow input {
    font-size: 0.65em;
    padding: 2px;
  }

  #pagination,
  #vehiclePagination {
    margin-top: 10px;
  }

  #pagination button,
  #vehiclePagination button {
    padding: 5px 7px;
    margin: 0 1px;
    font-size: 0.75em;
  }

  .candidate-card {
    padding: 10px;
    margin: 6px 0;
  }
}
