@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --color-bg: #3a3a3a;
  --color-surface: #ffffff;
  --color-text: #1a1a1a;
  --color-text-secondary: #666666;
  --color-border: #e0e0e0;
  --color-blue-primary: #1f4e79;
  --color-blue-light: #e8f0f7;
  --color-gold: #c8a759;
  --color-gold-light: #f9f5eb;
  --color-error: #b00020;
  --color-success: #2e7d32;
  --color-locked: #595959;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --color-bg: #1a1a1a;
    --color-surface: #2a2a2a;
    --color-text: #f0f0f0;
    --color-text-secondary: #aaaaaa;
    --color-border: #404040;
    --color-blue-light: #1a3a52;
  }
}

:root[data-theme='dark'] {
  --color-bg: #1a1a1a;
  --color-surface: #2a2a2a;
  --color-text: #f0f0f0;
  --color-text-secondary: #aaaaaa;
  --color-border: #404040;
  --color-blue-light: #1a3a52;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family:
    'Inter',
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
  max-width: 700px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
  background-color: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
}

body.wide {
  max-width: 900px;
}

body.hr-page {
  max-width: none;
  width: 100%;
  padding-left: 2rem;
  padding-right: 2rem;
  background-color: #0a1f3d;
}

body.hr-page h1 {
  color: var(--color-gold);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 1.5rem 1rem;
  margin-left: -1rem;
  margin-right: -1rem;
  margin-top: -1.5rem;
  padding-left: 1rem;
  padding-right: 1rem;
}

.site-header a {
  display: inline-flex;
}

.logout-form {
  margin: 0;
}

.logout-form[hidden] {
  display: none;
}

.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  padding: 0.75rem 1.5rem;
  background: var(--color-blue-primary);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.action-button:hover {
  background: #0d2e4a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.action-button:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-blue-light);
}

button.secondary {
  background: var(--color-border);
  color: var(--color-text);
}

button.secondary:hover {
  background: #d0d0d0;
}

button.danger {
  background: var(--color-error);
  color: white;
}

button.danger:hover {
  background: #8b0015;
}

.action-button:active {
  transform: translateY(1px);
}

.action-button[hidden] {
  display: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logout-button {
  background: var(--color-border);
  color: var(--color-text);
  border: none;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.logout-button:hover {
  background: #d0d0d0;
}

.site-logo {
  height: clamp(40px, 10vw, 64px);
  width: auto;
  display: block;
  background: var(--color-blue-primary);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  object-fit: contain;
}

.card {
  background: var(--color-surface);
  color: var(--color-text);
  padding: 2rem;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.page-shell {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.page-shell .site-header {
  margin: 0;
  padding: 1.5rem 1rem;
  border-radius: 0;
  box-shadow: none;
}

.page-shell .card {
  border: none;
  border-radius: 0;
  box-shadow: none;
  margin-top: 0;
}

.back-link {
  margin: 0 0 1rem;
}

.back-link a {
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.back-link a:hover {
  color: var(--color-blue-primary);
  text-decoration: underline;
}

form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

form[hidden] {
  display: none;
}

label {
  font-weight: 500;
  font-size: 14px;
  display: block;
  margin-bottom: 0.5rem;
  color: var(--color-text);
}

input,
select,
textarea {
  padding: 0.75rem;
  font-size: 15px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
  transition: all 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-blue-primary);
  box-shadow: 0 0 0 3px var(--color-blue-light);
}

input:disabled,
select:disabled {
  background: #f0f0f0;
  color: var(--color-text-secondary);
}

button {
  padding: 0.75rem 1.5rem;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  border: none;
  font-family: inherit;
  transition: all 0.2s ease;
  background: var(--color-blue-primary);
  color: white;
}

button:hover {
  background: #0d2e4a;
}

button:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-blue-light);
}

button.secondary {
  background: var(--color-border);
  color: var(--color-text);
}

button.secondary:hover {
  background: #d0d0d0;
}

button.danger {
  background: var(--color-error);
  color: white;
}

button.danger:hover {
  background: #8b0015;
}

.error {
  color: var(--color-error);
  font-weight: 500;
}

.save-confirmation {
  color: var(--color-text);
  background: #e8f5e9;
  border: 1px solid #c8e6c9;
  border-left: 3px solid var(--color-success);
  border-radius: 6px;
  padding: 1rem;
  margin: 1rem 0;
  font-size: 14px;
}

.save-confirmation p {
  margin: 0 0 0.5rem;
  font-weight: 600;
}

.save-confirmation ul {
  margin: 0;
  padding-left: 1.2rem;
}

.km-monthly {
  margin-top: 1rem;
}

.profile-action-button {
  display: block;
  width: 100%;
}

.kfz-input-row {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
}

.kfz-input-row .field {
  flex: 1 1 auto;
}

.kfz-action-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 8rem;
  flex-shrink: 0;
}

.kfz-action-buttons button {
  width: 100%;
}

.profile-section--centered .profile-centered-content {
  max-width: 320px;
  margin: 0 auto;
}

.profile-section--centered h2 {
  text-align: center;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 0.25rem 0.5rem;
}

.data-table th:first-child,
.data-table td:first-child {
  text-align: left;
}

.data-table th:nth-child(2),
.data-table td:nth-child(2) {
  width: 1.5rem;
}

.data-table th:last-child,
.data-table td:last-child {
  text-align: right;
}

@media (max-width: 600px) {
  .kfz-input-row {
    flex-wrap: wrap;
  }

  .kfz-action-buttons {
    width: 100%;
  }
}

.hint {
  color: var(--color-text-secondary);
  font-size: 13px;
  margin: 0.5rem 0 0;
}

.field-label-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.autocomplete-wrapper {
  position: relative;
}

.autocomplete-list {
  position: absolute;
  z-index: 1000;
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-top: none;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.autocomplete-list li {
  padding: 0.75rem;
  cursor: pointer;
  font-size: 14px;
  border-bottom: 1px solid var(--color-border);
  transition: background-color 0.15s ease;
}

.autocomplete-list li:last-child {
  border-bottom: none;
}

.autocomplete-list li:hover,
.autocomplete-list li.active {
  background: var(--color-blue-light);
  color: var(--color-text);
}

#map {
  height: 400px;
  margin-top: 1rem;
  border-radius: 4px;
}

.trip-result {
  margin-top: 1rem;
  font-weight: bold;
}

.trip-result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.waypoint-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: var(--color-blue-light);
  border-left: 3px solid var(--color-blue-primary);
  padding: 1rem;
  border-radius: 6px;
  margin-bottom: 0.75rem;
}

#start {
  width: 50%;
  box-sizing: border-box;
}

.waypoint-row .autocomplete-wrapper {
  flex: 0 1 50%;
}

.waypoint-row .autocomplete-wrapper input {
  width: 100%;
  box-sizing: border-box;
}

.poi-select {
  max-width: 12rem;
  padding: 0.3rem;
  font-size: 0.9rem;
}

.remove-waypoint {
  background: none;
  border: none;
  padding: 0.25rem 0.5rem;
  font-size: 1.2rem;
  line-height: 1;
  color: #b00020;
}

.waypoint-block {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.waypoint-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.field-row[hidden],
.field[hidden] {
  display: none;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.field-checkbox {
  justify-content: flex-end;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 400;
  padding: 0.5rem 0;
}

.field-row .field {
  flex: 1 1 auto;
}

.field-row input,
.field-row select {
  width: 100%;
  box-sizing: border-box;
}

.field-row input:disabled,
.field-row select:disabled {
  background: #f0f0f0;
  color: var(--color-text-secondary);
}

input[readonly],
select[readonly] {
  background: #f0f0f0;
  color: var(--color-text-secondary);
}

#trip-details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 1rem;
}

#trip-details dt {
  font-weight: bold;
}

#trip-details dd {
  margin: 0;
}

#submit-trip-button {
  margin-top: 1rem;
}

.hr-layout {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
}

.hr-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 180px;
  flex-shrink: 0;
}

.hr-nav-item {
  display: block;
  text-align: left;
  text-decoration: none;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.hr-nav-item:hover {
  border-color: var(--color-blue-primary);
  background: var(--color-blue-light);
}

.hr-nav-item.active {
  background: var(--color-blue-primary);
  color: white;
  border-color: var(--color-blue-primary);
  font-weight: 600;
}

.hr-nav-item[hidden] {
  display: none;
}

#admin-nav-link,
#personal-nav-link {
  background: #bfdcf2;
  color: var(--color-gold);
  font-weight: 700;
}

#admin-nav-link:hover,
#personal-nav-link:hover {
  background: #bfdcf2;
  color: var(--color-gold);
}

.hr-content {
  flex: 1;
  min-width: 0;
}

.hr-panel h2 {
  margin-top: 0;
}

.profile-section {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

.profile-section h2 {
  margin-top: 0;
}

.profile-section h3 {
  margin-bottom: 0.5rem;
}

.profile-info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem 1.5rem;
  margin-bottom: 1.25rem;
}

.profile-info-grid .field {
  gap: 0.25rem;
}

.profile-info-grid label {
  margin-bottom: 0;
  color: var(--color-text-secondary);
}

@media (max-width: 600px) {
  .profile-info-grid {
    grid-template-columns: 1fr;
  }
}

.hr-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.hr-filters .field {
  min-width: 140px;
}

.hr-table-scroll-top {
  overflow-x: auto;
  overflow-y: hidden;
  height: 14px;
  margin-top: 1rem;
}

.hr-table-scroll-top > div {
  height: 1px;
}

.hr-table-wrapper {
  overflow-x: auto;
  margin-top: 0.25rem;
}

.hr-table-wrapper table {
  width: 100%;
  border-collapse: collapse;
}

.hr-table-wrapper th,
.hr-table-wrapper td {
  padding: 0.5rem;
  border-bottom: 1px solid #ddd;
  text-align: left;
  white-space: nowrap;
}

.hr-table-wrapper tfoot td {
  font-weight: bold;
  border-bottom: none;
  border-top: 2px solid #999;
}

.confirm-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}

.confirm-table th,
.confirm-table td {
  padding: 0.5rem;
  border-bottom: 1px solid #ddd;
  text-align: left;
}

#user-table.hide-roles th:nth-child(2),
#user-table.hide-roles th:nth-child(3),
#user-table.hide-roles td:nth-child(2),
#user-table.hide-roles td:nth-child(3) {
  display: none;
}

.hr-table-wrapper th[data-sort-key] {
  cursor: pointer;
  user-select: none;
}

.hr-table-wrapper th[data-sort-key]::after {
  content: ' \21C5';
  opacity: 0.4;
  font-size: 0.85em;
}

.hr-table-wrapper th.sort-asc::after {
  content: ' \25B2';
  opacity: 1;
}

.hr-table-wrapper th.sort-desc::after {
  content: ' \25BC';
  opacity: 1;
}

.hr-table-wrapper tbody tr:hover {
  background: var(--color-blue-light);
}

.hr-table-wrapper .hr-destinations {
  white-space: normal;
  min-width: 220px;
}

.locked-row,
.locked-row td {
  color: var(--color-locked);
}

#detail-table th,
#detail-table td {
  color: #000;
}

#detail-table tr.locked-row td {
  color: var(--color-locked);
}

.detour-alarm-row,
.detour-alarm-row td {
  background: #f8d7da;
}

.hr-table-wrapper tbody tr.detour-alarm-row:hover {
  background: #f3c2c6;
}

.hr-panel h3 {
  margin-bottom: 0.5rem;
}

.hr-panel hr {
  margin: 1.5rem 0;
  border: none;
  border-top: 1px solid #ddd;
}

#billing-button {
  margin-top: 0.5rem;
}

.hr-table-wrapper input.edit-field {
  padding: 0.3rem;
  font-size: 0.9rem;
}

.hr-table-wrapper input[type='number'].edit-field {
  width: 5.5rem;
}

@media (max-width: 800px) {
  .hr-layout {
    flex-direction: column;
  }

  .hr-sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
  }
}

@media (max-width: 600px) {
  body {
    padding: 1rem 0.75rem 2rem;
  }

  .card {
    padding: 1rem;
  }

  .field-row {
    flex-direction: column;
    gap: 0.75rem;
  }

  #start,
  .waypoint-row .autocomplete-wrapper {
    width: 100%;
    flex: 1 1 100%;
  }

  .waypoint-row {
    flex-wrap: wrap;
  }

  .field-label-row {
    flex-wrap: wrap;
  }

  .poi-select {
    max-width: none;
    flex: 1 1 auto;
  }

  #map {
    height: 280px;
  }
}

.hr-map-link,
.map-link {
  white-space: nowrap;
}

.delete-trip-link {
  color: var(--color-error);
  font-weight: 600;
  font-size: 1.1rem;
  text-decoration: none;
  margin-left: 0.5rem;
  transition: all 0.2s ease;
}

.delete-trip-link:hover {
  text-decoration: underline;
}

a {
  color: var(--color-blue-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-box {
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: 8px;
  border: 1px solid var(--color-border);
  padding: 2rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  max-width: 90vw;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 2rem;
}

.modal-actions button {
  padding: 0.75rem 1.5rem;
}

.danger-button {
  background: var(--color-error);
  color: white;
  font-weight: 600;
}

.danger-button:hover {
  background: #8b0015;
}

.detour-modal-box {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 340px;
}

.detour-modal-box h2 {
  margin: 0;
}

.detour-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.detour-section[hidden] {
  display: none;
}

.user-modal-box {
  width: 600px;
}

.user-modal-box h2 {
  margin: 0 0 0.75rem;
}

.map-modal-box {
  position: relative;
  width: 500px;
  max-width: 90vw;
  padding: 0.5rem;
}

.modal-close {
  position: absolute;
  top: 0.25rem;
  right: 0.5rem;
  z-index: 1;
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.25rem;
  color: var(--color-text);
}

#map-modal-map {
  width: 100%;
  height: 320px;
  border-radius: 6px;
}

#yearly-content[hidden],
#yearly-error[hidden] {
  display: none;
}

@media (max-width: 600px) {
  .map-modal-box {
    width: 100%;
  }

  #map-modal-map {
    height: 260px;
  }
}
