* {
  box-sizing: border-box;
}

:root {
  --bg: #eef2f5;
  --card: #ffffff;
  --line: #d3dbe4;
  --line-soft: #e6edf3;
  --text: #1f2a36;
  --muted: #6d7c8c;
  --blue: #006ca0;
  --blue-dark: #00527a;
  --green: #2c7c31;
  --orange: #9c6a00;
  --red: #b73a3a;
  --gray: #738497;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  --radius: 14px;
  --hour-height: 56px;
  --time-col-width: 86px;
  --status-row-height: 64px;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body {
  padding: 20px;
}

h1 {
  margin: 0;
  color: var(--blue);
  font-size: 38px;
  line-height: 1.1;
}

.subline {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.panel-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 13px;
  color: var(--muted);
}

input,
button,
select {
  font: inherit;
}

input,
select {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  background: #fff;
}

input[type="color"] {
  width: 100%;
  height: 42px;
  padding: 3px;
  min-width: 0;
  border-radius: 10px;
  cursor: pointer;
}

.btn {
  height: 42px;
  border: none;
  border-radius: 10px;
  background: var(--blue);
  color: #fff;
  padding: 0 16px;
  cursor: pointer;
}

.btn:hover {
  background: var(--blue-dark);
}

.btn-secondary {
  background: var(--gray);
}

.btn-secondary:hover {
  background: #5f6f80;
}

.btn-danger {
  background: var(--red);
}

.btn-danger:hover {
  background: #952d2d;
}

.hidden {
  display: none !important;
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
}

.sidebar,
.main {
  min-width: 0;
}

.side-panel {
  padding-bottom: 12px;
}

.selected-day-panel {
  padding-bottom: 14px;
}

.selected-day-label {
  font-size: 20px;
  font-weight: 700;
  color: var(--blue);
  line-height: 1.2;
}

.selected-day-hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.pool {
  min-height: 64px;
  border: 2px dashed #dce5ed;
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: flex-start;
  background: #f9fbfd;
}

.pool.drop-hover,
.status-dropzone.drop-hover,
.day-column.drop-hover,
.job-block.drop-hover {
  outline: 2px dashed var(--blue);
  outline-offset: -4px;
  background: #eef8fd;
}

.resource-chip {
  min-width: 74px;
  max-width: 100%;
  border-radius: 8px;
  color: #fff;
  padding: 6px 8px;
  cursor: grab;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
  user-select: none;
}

.resource-chip:active {
  cursor: grabbing;
}

.resource-chip-name {
  font-weight: 700;
  font-size: 12px;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.resource-chip-meta {
  display: none;
}

.type-mitarbeiter {
  background: var(--blue);
}

.type-fahrzeug {
  background: var(--green);
}

.type-anhaenger {
  background: var(--orange);
}

.timeline-panel {
  overflow: auto;
}

.week-shell {
  width: max-content;
  min-width: 980px;
  max-width: 100%;
}

.week-header-grid {
  display: grid;
  grid-template-columns: var(--time-col-width) repeat(5, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
  align-items: stretch;
}

.week-header-spacer {
  min-height: 1px;
}

.week-day-header {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f4f8fb;
  padding: 10px 12px;
  min-height: 56px;
}

.week-day-header.active {
  border-color: #7fbce2;
  background: #eaf5fb;
}

.week-day-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.week-day-date {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}

.status-board-grid {
  display: grid;
  grid-template-columns: var(--time-col-width) repeat(5, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
  align-items: stretch;
}

.status-axis {
  display: grid;
  grid-template-rows: repeat(2, var(--status-row-height));
  gap: 8px;
}

.status-axis-label {
  height: var(--status-row-height);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-day-column {
  display: grid;
  grid-template-rows: repeat(2, var(--status-row-height));
  gap: 8px;
}

.status-dropzone {
  min-height: var(--status-row-height);
  max-height: var(--status-row-height);
  border: 1px dashed #d5e1ea;
  border-radius: 12px;
  padding: 6px 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-content: flex-start;
  overflow: auto;
  background: #fbfdff;
}

.status-dropzone-auto {
  border-style: solid;
  background: #f6fafc;
}

.status-info-chip {
  max-width: 100%;
  border-radius: 999px;
  background: #dfeef7;
  color: #20536a;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.week-body {
  display: grid;
  grid-template-columns: var(--time-col-width) 1fr;
  gap: 10px;
  align-items: start;
}

.time-column {
  position: relative;
}

.time-slot-label {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  text-align: right;
  padding-right: 8px;
  padding-top: 2px;
  transform: translateY(-1px);
  background: transparent;
}

.time-slot-label-end {
  transform: translateY(-100%);
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(180px, 1fr));
  gap: 10px;
}

.day-column {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
  min-height: calc(9.25 * var(--hour-height));
}

.hour-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--line);
  pointer-events: none;
}

.half-hour-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: #edf2f6;
  pointer-events: none;
}

.offtime-overlay {
  position: absolute;
  left: 0;
  right: 0;
  background: rgba(115, 132, 151, 0.08);
  border-top: 1px dashed rgba(115, 132, 151, 0.35);
  pointer-events: none;
}

.job-block {
  position: absolute;
  left: 8px;
  right: 8px;
  border-radius: 12px;
  background: linear-gradient(180deg, #0588ca 0%, #006ca0 100%);
  color: #fff;
  box-shadow: 0 8px 18px rgba(0, 108, 160, 0.2);
  padding: 10px 12px 28px;
  overflow: hidden;
  cursor: move;
  user-select: none;
}

.job-block.dragging {
  opacity: 0.94;
  box-shadow: 0 14px 28px rgba(0, 108, 160, 0.32);
}

.job-block-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 4px;
}

.job-block-time {
  font-size: 12px;
  opacity: 0.95;
}

.job-block-meta {
  margin-top: 4px;
  font-size: 11px;
  opacity: 0.92;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.job-block-link {
  margin-top: 4px;
  font-size: 11px;
  opacity: 0.95;
}

.job-resource-list {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.job-resource-pill {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  line-height: 1;
  backdrop-filter: blur(2px);
  cursor: grab;
}

.resize-handle {
  position: absolute;
  left: 0;
  right: 0;
  height: 18px;
  cursor: ns-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.resize-handle::before {
  content: "";
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
}

.resize-handle-top {
  top: 0;
}

.resize-handle-bottom {
  bottom: 0;
}

.job-resource-picker {
  display: grid;
  gap: 12px;
}

.job-resource-group {
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 12px;
  background: #f9fbfd;
}

.job-resource-group-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.job-resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.job-resource-option {
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  text-align: left;
  cursor: pointer;
}

.job-resource-option:hover {
  border-color: #8bbfdb;
  background: #f4fbff;
}

.job-resource-option.selected {
  border-color: var(--blue);
  background: #eaf6fc;
  color: var(--blue);
}

.job-resource-option.blocked {
  opacity: 0.58;
  cursor: not-allowed;
  background: #f4f6f8;
}

.job-resource-option[data-type="fahrzeug"].selected {
  border-color: var(--green);
  background: #eef8ef;
  color: var(--green);
}

.job-resource-option[data-type="anhaenger"].selected {
  border-color: var(--orange);
  background: #fff6e8;
  color: var(--orange);
}

.job-resource-option-name {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.15;
}

.job-resource-option-status {
  font-size: 11px;
  line-height: 1.25;
  color: var(--muted);
}

.job-resource-option.selected .job-resource-option-status {
  color: inherit;
}

.job-resource-hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(31, 42, 54, 0.38);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 1000;
}

.modal-card {
  width: min(760px, 100%);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
  padding: 18px;
}

.modal-card-small {
  width: min(560px, 100%);
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 14px;
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.modal-grid .full {
  grid-column: 1 / -1;
}

.resource-grid {
  grid-template-columns: minmax(0, 1fr) 120px 74px;
  align-items: end;
}

.resource-grid .field {
  min-width: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

@media (max-width: 1200px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: 2;
  }

  .main {
    order: 1;
  }
}

@media (max-width: 860px) {
  body {
    padding: 12px;
  }

  h1 {
    font-size: 30px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .modal-grid,
  .resource-grid {
    grid-template-columns: 1fr;
  }

  .week-shell {
    min-width: 900px;
  }
}

.outlook-sync-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}

.outlook-status-text {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}

.job-lock-hint {
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid #c9d7e5;
  border-radius: 10px;
  background: #f4f8fb;
  color: #456070;
  font-size: 13px;
  line-height: 1.35;
}

.job-block-locked {
  border: 1px solid rgba(255,255,255,0.45);
}

.job-block-source {
  display: inline-block;
  margin-top: 4px;
  margin-bottom: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.25);
  font-size: 11px;
  font-weight: 700;
}
