:root{
  --bg:#0b1220;
  --text:#e7ecff;
  --muted:#b8c1e6;
  --line:rgba(255,255,255,.12);
  --accent:#4da3ff;

  --pad-x: clamp(10px, 1.0vw, 16px);
  --pad-y: clamp(8px, .8vw, 12px);
  --gap:   clamp(8px, .9vw, 12px);

  --fs-12: clamp(11px, .8vw, 12px);
  --fs-14: clamp(12px, .95vw, 14px);
  --fs-20: clamp(16px, 1.35vw, 20px);

  --radius: 14px;
  --driver-col: 220px;

  --main-top-gap: 0px;
}

*{ box-sizing:border-box; }

body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: linear-gradient(180deg, var(--bg), #070b14);
  color: var(--text);
  font-size: var(--fs-14);
}

/* Header */
.header{
  padding: var(--pad-y) var(--pad-x);
  border-bottom: 0;
  background: rgba(10, 16, 30, .72);
  backdrop-filter: blur(6px);
  position: sticky;
  top:0;
  z-index:10;
}

/*  Rechte Spalte deutlich größer: bis ca. Bildschirmmitte (~50/50) */
.header-top{
  display: grid;
  grid-template-columns: minmax(520px, 1fr) minmax(520px, 1fr);
  gap: var(--gap);
  align-items: start;
}

.header-left h1{
  margin:0 0 6px;
  font-size: var(--fs-20);
}

.toolbar{
  display:flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items:center;
}

.week-label{
  color: var(--muted);
  font-size: var(--fs-14);
  display:flex;
  gap:8px;
  align-items:center;
}

input[type="date"]{
  background:#0f1930;
  border:1px solid var(--line);
  color:var(--text);
  padding:6px 9px;
  border-radius: 8px;
}

.btn{
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #122041;
  color: var(--text);
  cursor:pointer;
  line-height: 1;
}
.btn:hover{ border-color: rgba(255,255,255,.25); }

.btn-secondary{ background:#1a1f33; }

.btn-accent{
  background: #16305c;
  border-color: rgba(77,163,255,.35);
}
.btn-accent:hover{
  border-color: rgba(77,163,255,.6);
}

.header-right{
  background: rgba(17,26,46,.70);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
}

/* Allgemeine Infos (einzeilig, aber optisch "kräftiger") */
.general-info{
  width: 100%;
  padding: 7px 9px;
  border-radius: 10px;
  background: #0f1930;
  border: 1px solid rgba(255,255,255,.12);
  color: var(--text);
  outline: none;
  font-size: var(--fs-14);

  /* optional: wirkt präsenter ohne mehrzeilig zu werden */
  min-height: 42px;
}

.general-info:focus{
  border-color: rgba(77,163,255,.55);
  box-shadow: 0 0 0 3px rgba(77,163,255,.12);
}

.last-updated{
  margin-top: 6px;
  font-size: var(--fs-12);
  color: var(--muted);
}

.edit-status{ margin-top: 6px;
  font-size: var(--fs-12);
  color: var(--muted);
}
.edit-status span{
  color: var(--text);
  font-weight: 650;
}

/* Pickers */
.header-pickers{ margin-top: 8px; }

.top-pickers{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
}

.picker-inline{
  background: rgba(17,26,46,.70);
  border:1px solid var(--line);
  border-radius: var(--radius);
  overflow:hidden;
}

.picker summary{
  padding: 7px 10px;
  cursor:pointer;
  font-weight: 650;
  color: var(--text);
  user-select:none;
}

.picker-body{
  padding: 8px 10px 10px;
  border-top:1px solid var(--line);
}

.picker-search{
  width:100%;
  padding: 7px 9px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.12);
  background:#0f1930;
  color: var(--text);
  outline:none;
  margin-bottom: 8px;
  font-size: var(--fs-14);
}
.picker-search:focus{
  border-color: rgba(77,163,255,.55);
  box-shadow: 0 0 0 3px rgba(77,163,255,.12);
}

.picker-list{
  display:grid;
  gap: 8px;
  max-height: 180px;
  overflow:auto;
  padding-right: 4px;
}

.draggable-item{
  display:flex;
  align-items:center;
  gap: 8px;
  padding: 8px 9px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  background: rgba(17,26,46,.75);
  cursor: grab;
  user-select:none;
}
.draggable-item:active{ cursor: grabbing; }

.draggable-badge{
  font-size: var(--fs-12);
  color:#071018;
  background: var(--accent);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
}

.draggable-text{
  color: var(--text);
  font-size: var(--fs-14);
  line-height: 1.2;
}

/* Sticky head merged with table */
.sticky-table-head{
  margin-top: 8px;
  display: grid;
  grid-template-columns: var(--driver-col) repeat(7, minmax(0, 1fr));
  gap: 0;

  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;

  background: rgba(17,26,46,.95);
  backdrop-filter: blur(6px);
}

.sth-cell{
  padding: clamp(8px, .8vw, 12px);
  font-weight: 700;
  font-size: var(--fs-12);
  color: var(--text);
  text-align: left;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.sth-cell:last-child{ border-right:none; }

/* Main */
.container{
  padding: var(--main-top-gap) var(--pad-x) var(--pad-y) var(--pad-x);
  width: 100%;
  margin: 0;
}

.table-wrap{
  background: rgba(17,26,46,.75);
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}

.planning-table{
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

/* semantic thead (screenreader), visually hidden */
.sr-only-thead{
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.planning-table th,
.planning-table td{
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: clamp(8px, .8vw, 12px);
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.planning-table th:last-child,
.planning-table td:last-child{
  border-right:none;
}

.driver-link{
  color: var(--accent);
  text-decoration:none;
  font-weight: 700;
  cursor:pointer;
}
.driver-link:hover{ text-decoration: underline; }

/* Dropzone */
.dropzone{
  border: 1px dashed rgba(255,255,255,.20);
  border-radius: 12px;
  padding: 8px;
  background: rgba(15,25,48,.45);
}
.dropzone.dragover{
  border-color: rgba(139,209,124,.7);
  box-shadow: 0 0 0 3px rgba(139,209,124,.14);
}

.assigned-group{
  display:grid;
  gap: 6px;
  margin-bottom: 10px;
}
.assigned-group:last-child{ margin-bottom:0; }

.assigned-title{
  font-size: var(--fs-12);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* Vehicle chips */
.chips{
  display:flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip{
  display:inline-flex;
  align-items:center;
  gap: 6px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 999px;
  padding: 5px 8px;
  font-size: var(--fs-12);
  background: rgba(17,26,46,.75);
}
.chip.vehicle{ border-color: rgba(139,209,124,.35); }
.chip button{
  border:none;
  background:transparent;
  color: var(--muted);
  cursor:pointer;
  padding:0 2px;
  font-size: 14px;
  line-height: 1;
}
.chip button:hover{ color:#fff; }

.vehicles-grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.vehicles-grid .chip{
  width: 100%;
  justify-content: space-between;
}

/* Customer rows */
.customer-rows{
  display:grid;
  gap: 6px;
}
.customer-row{
  display:grid;
  grid-template-columns: minmax(0, 1fr) 14ch auto;
  gap: 8px;
  align-items:center;
  padding: 6px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 12px;
  background: rgba(17,26,46,.55);
}
.customer-name{
  font-size: var(--fs-12);
  font-weight: 650;
  color: var(--text);
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.customer-text{
  width: 14ch;
  max-width: 14ch;
  padding: 6px 7px;
  border-radius: 10px;
  background: #0f1930;
  border: 1px solid rgba(255,255,255,.10);
  color: var(--text);
  outline:none;
  font-size: var(--fs-12);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  letter-spacing: 0.02em;
}
.customer-text:focus{
  border-color: rgba(77,163,255,.55);
  box-shadow: 0 0 0 3px rgba(77,163,255,.12);
}

.remove-row{
  border:none;
  background:transparent;
  color: var(--muted);
  cursor:pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 6px;
}
.remove-row:hover{ color:#fff; }

/* LOCKED mode */
body.locked .remove-row,
body.locked .chip button{
  pointer-events: none;
  opacity: .35;
}
body.locked .customer-text{
  opacity: .75;
}

/* PDF Overlay */
.pdf-overlay{
  position: fixed;
  inset: 0;
  display: none;
  background: rgba(0,0,0,.6);
  z-index: 9999;
}
.pdf-overlay.open{
  display: flex;
  align-items: center;
  justify-content: center;
}
.pdf-modal{
  width: min(1200px, 96vw);
  height: min(900px, 92vh);
  background: rgba(17,26,46,.98);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
}
.pdf-toolbar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(17,26,46,.95);
}
.pdf-title{
  font-weight: 700;
  font-size: var(--fs-14);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pdf-actions{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.pdf-frame{
  width: 100%;
  height: 100%;
  border: 0;
  background: #0f1930;
}

/* Desktop breakpoints */
@media (max-width: 1200px){
  :root{ --driver-col: 200px; }

  /* ✅ bei kleineren Screens immer noch breiter, aber stabil */
  .header-top{
    grid-template-columns: minmax(480px, 1fr) minmax(380px, 1fr);
  }

  .customer-row{ grid-template-columns: minmax(0, 1fr) 13ch auto; }
  .customer-text{ width: 13ch; max-width: 13ch; }
}

@media (max-width: 1050px){
  .header-top{ grid-template-columns: 1fr; }
  .top-pickers{ grid-template-columns: 1fr; }
}