:root {
  --bg: #0f0f13;
  --bg2: #16161d;
  --bg3: #1e1e28;
  --border: #2e2e3e;
  --accent: #00c1d4;
  --accent2: #248fa7;
  --accent3: #34d399;
  --accent4: #f87171;
  --text: #e8e8f0;
  --text2: #9090a8;
  --text3: #5a5a70;
  --selected-glow: rgba(124, 106, 247, 0.15);
  --mono: "Space Mono", monospace;
  --sans: "DM Sans", sans-serif;
  --radius: 10px;
  --slot-height: 64px;
  --hour-start: 8;
  --hour-end: 20;
}
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── HEADER ── */
header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-wrap: wrap;
}
.logo {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--accent);
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.logo span {
  color: var(--accent2);
}
.header-actions {
  display: flex;
  gap: 10px;
  margin-left: auto;
  flex-wrap: wrap;
  align-items: center;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover {
  background: var(--border);
  border-color: var(--text3);
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover {
  filter: brightness(1.15);
}
.btn.danger {
  background: transparent;
  border-color: #f87171;
  color: #f87171;
}
.btn.danger:hover {
  background: rgba(248, 113, 113, 0.1);
}

/* ── LAYOUT ── */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ── SIDEBAR ── */
.sidebar {
  width: 320px;
  min-width: 260px;
  max-width: 380px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s;
}
.sidebar-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sidebar-header h2 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text2);
  font-family: var(--mono);
}
.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-body::-webkit-scrollbar {
  width: 4px;
}
.sidebar-body::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* ── MODULE CARD ── */
.module-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s;
}
.module-card:hover {
  border-color: var(--text3);
}
.module-header {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.module-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.module-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
}
.module-toggle {
  font-size: 11px;
  color: var(--text3);
  transition: transform 0.15s;
}
.module-toggle.open {
  transform: rotate(90deg);
}
.module-body {
  display: none;
  border-top: 1px solid var(--border);
  padding: 8px;
  flex-direction: column;
  gap: 4px;
}
.module-body.open {
  display: flex;
}

/* ── LV ITEM ── */
.lv-item {
  border-radius: 6px;
  background: var(--bg2);
  border: 1px solid transparent;
  padding: 6px 10px;
  cursor: pointer;
  transition: all 0.12s;
}
.lv-item:hover {
  border-color: var(--border);
}
.lv-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 2px;
}
.lv-type {
  font-size: 12px;
  color: var(--text2);
}

/* ── PARALLELGRUPPE ITEM ── */
.pg-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.12s;
  position: relative;
}
.pg-item:hover {
  border-color: var(--border);
  background: var(--bg2);
}
.pg-item.selected {
  border-color: var(--accent);
  background: rgba(124, 106, 247, 0.08);
}
.pg-item.selected .pg-check {
  background: var(--accent);
  border-color: var(--accent);
}
.pg-check {
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  flex-shrink: 0;
  margin-top: 2px;
  transition: all 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pg-check svg {
  display: none;
}
.pg-item.selected .pg-check svg {
  display: block;
}
.pg-info {
  flex: 1;
  min-width: 0;
}
.pg-name {
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 2px;
}
.pg-time {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text2);
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.pg-day-badge {
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
}
.pg-conflict {
  color: var(--accent4);
  font-size: 10px;
  margin-top: 2px;
}

/* ── STATIC LV ── */
.static-lv {
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(52, 211, 153, 0.08);
  border: 1px solid rgba(52, 211, 153, 0.25);
}
.static-lv .pg-day-badge {
  background: rgba(52, 211, 153, 0.15);
  border-color: rgba(52, 211, 153, 0.4);
}

/* ── ADD FORMS ── */
.add-section {
  padding: 12px;
  border-top: 1px solid var(--border);
}
.add-section h3 {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 10px;
  font-family: var(--mono);
}

.form-group {
  margin-bottom: 8px;
}
.form-group label {
  display: block;
  font-size: 11px;
  color: var(--text2);
  margin-bottom: 4px;
  font-weight: 500;
}
.form-group input,
.form-group select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.12s;
}
.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
}
.form-group select option {
  background: var(--bg3);
}
.form-row {
  display: flex;
  gap: 6px;
}
.form-row .form-group {
  flex: 1;
}

/* ── CALENDAR AREA ── */
.calendar-area {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── VIEW CONTROLS ── */
.cal-toolbar {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--bg2);
  position: sticky;
  top: 0;
  z-index: 50;
}
.filter-btns {
  display: flex;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.filter-btn {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text2);
  transition: all 0.12s;
  white-space: nowrap;
}
.filter-btn.active {
  background: var(--accent);
  color: #fff;
}
.filter-btn:hover:not(.active) {
  color: var(--text);
}

/* blocked-by-static indicator in sidebar */
.pg-item.blocked-static {
  opacity: 0.38;
}
.pg-item.blocked-static .pg-day-badge {
  background: rgba(248, 113, 113, 0.15);
  border-color: rgba(248, 113, 113, 0.35);
  color: var(--accent4);
}
.pg-blocked-label {
  font-size: 10px;
  color: var(--accent4);
  margin-top: 2px;
}

.cal-legend {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-left: auto;
  align-items: center;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text2);
}
.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* ── WEEK GRID ── */
.week-grid-wrapper {
  flex: 1;
  overflow: auto;
}
.week-grid {
  display: grid;
  grid-template-columns: 52px repeat(5, 1fr);
  min-width: 600px;
  position: relative;
}

/* Day headers */
.day-header {
  padding: 10px 8px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text3);
  font-family: var(--mono);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.day-header.today {
  color: var(--accent);
}

/* Time gutter */
.time-gutter {
  grid-column: 1;
  position: relative;
}
.time-label {
  height: var(--slot-height);
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding-right: 10px;
  padding-top: 2px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text3);
}

/* Day columns */
.day-col {
  position: relative;
  border-left: 1px solid var(--border);
}
.hour-line {
  height: var(--slot-height);
  border-bottom: 1px solid rgba(46, 46, 62, 0.5);
}
.half-line {
  position: absolute;
  left: 0;
  right: 0;
  border-bottom: 1px dashed rgba(46, 46, 62, 0.3);
}

/* ── EVENTS ── */
.cal-event {
  position: absolute;
  left: 3px;
  right: 3px;
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 11px;
  overflow: hidden;
  cursor: pointer;
  transition:
    filter 0.12s,
    transform 0.1s;
  border: 1.5px solid transparent;
  z-index: 5;
  line-height: 1.35;
}
.cal-event:hover {
  filter: brightness(1.2);
  transform: translateX(1px);
  z-index: 10;
}
.cal-event.static-event {
  border-style: solid;
}
.cal-event.dimmed {
  opacity: 0.2;
}
.cal-event.blocked-cal {
  opacity: 0.18;
  border-color: var(--accent4) !important;
}
.cal-event.conflict-bg {
  border-color: var(--accent4) !important;
}

.event-title {
  font-weight: 600;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.event-sub {
  font-size: 10px;
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.event-time-tag {
  font-family: var(--mono);
  font-size: 9px;
  opacity: 0.7;
  margin-top: 2px;
}

/* ── MODAL ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open {
  display: flex;
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  width: 480px;
  max-width: 95vw;
  max-height: 85vh;
  overflow-y: auto;
}
.modal h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ── UPLOAD DROP ZONE ── */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg3);
}
.dropzone:hover,
.dropzone.drag-over {
  border-color: var(--accent);
  background: rgba(124, 106, 247, 0.07);
}
.dropzone-icon {
  font-size: 24px;
  margin-bottom: 8px;
}
.dropzone-text {
  font-size: 13px;
  color: var(--text2);
}
.dropzone-sub {
  font-size: 11px;
  color: var(--text3);
  margin-top: 4px;
}

/* ── TOAST ── */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideIn 0.2s ease;
  pointer-events: all;
  max-width: 320px;
}
.toast.success {
  border-color: var(--accent3);
}
.toast.error {
  border-color: var(--accent4);
}
@keyframes slideIn {
  from {
    transform: translateX(20px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

/* ── EMPTY STATE ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 12px;
  color: var(--text3);
  padding: 48px;
}
.empty-icon {
  font-size: 40px;
}
.empty-state h3 {
  font-size: 16px;
  color: var(--text2);
}
.empty-state p {
  font-size: 13px;
  text-align: center;
  max-width: 300px;
  line-height: 1.6;
}

/* ── CONFLICT WARNING ── */
.conflict-banner {
  padding: 8px 16px;
  background: rgba(248, 113, 113, 0.1);
  border-bottom: 1px solid rgba(248, 113, 113, 0.3);
  font-size: 12px;
  color: var(--accent4);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── SECTION LABEL in sidebar ── */
.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text3);
  font-family: var(--mono);
  padding: 4px 4px 2px;
}
.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* ── OPTIMIZER ── */
.optimizer-btn {
  background: linear-gradient(135deg, rgba(124, 106, 247, 0.15), rgba(192, 132, 252, 0.15));
  border-color: var(--accent);
  color: var(--accent2);
  font-weight: 600;
}
.optimizer-btn:hover {
  background: linear-gradient(135deg, rgba(124, 106, 247, 0.28), rgba(192, 132, 252, 0.28));
  border-color: var(--accent2);
  color: #fff;
}

/* Priority List */
.priority-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.priority-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: grab;
  user-select: none;
  transition: all 0.15s;
}
.priority-item:hover {
  border-color: var(--text3);
  background: var(--bg2);
}
.priority-item.dragging {
  opacity: 0.4;
  border-color: var(--accent);
}
.priority-item.drag-over-above {
  border-top: 2px solid var(--accent);
  margin-top: -1px;
}
.priority-item.drag-over-below {
  border-bottom: 2px solid var(--accent);
  margin-bottom: -1px;
}
.priority-handle {
  color: var(--text3);
  font-size: 14px;
  cursor: grab;
  line-height: 1;
  flex-shrink: 0;
}
.priority-rank {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: var(--mono);
}
.priority-icon {
  font-size: 18px;
  flex-shrink: 0;
}
.priority-info {
  flex: 1;
  min-width: 0;
}
.priority-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.priority-desc {
  font-size: 11px;
  color: var(--text3);
  margin-top: 1px;
}

/* Optimizer Results */
.opt-error {
  color: var(--accent4);
  font-size: 13px;
  padding: 12px;
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.25);
  border-radius: 8px;
  text-align: center;
}
.opt-stats-header {
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.opt-stats-badge {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  font-family: var(--mono);
}
.opt-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.opt-stat {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 8px;
  text-align: center;
  transition: border-color 0.12s;
}
.opt-stat:hover {
  border-color: var(--text3);
}
.opt-stat-icon {
  font-size: 18px;
  margin-bottom: 4px;
}
.opt-stat-value {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--accent2);
}
.opt-stat-label {
  font-size: 10px;
  color: var(--text3);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.opt-selection-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
  margin-bottom: 6px;
  font-family: var(--mono);
}
.opt-selection-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 160px;
  overflow-y: auto;
}
.opt-selection-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
}
.opt-selection-time {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text2);
}

/* Optimizer result navigation */
.opt-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
}
.opt-nav-btn {
  padding: 4px 10px !important;
  font-size: 12px !important;
}
.opt-nav-btn:disabled {
  opacity: 0.3;
  cursor: default;
}
.opt-nav-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  font-family: var(--mono);
}

/* Dropzone file type indicators */
.dropzone.drag-json {
  border-color: var(--accent);
  background: rgba(124, 106, 247, 0.12);
}
.dropzone.drag-json .dropzone-text::after {
  content: ' (JSON)';
  color: var(--accent);
  font-weight: 600;
}
.dropzone.drag-xhtml {
  border-color: var(--accent3);
  background: rgba(52, 211, 153, 0.08);
}
.dropzone.drag-xhtml .dropzone-text::after {
  content: ' (XHTML)';
  color: var(--accent3);
  font-weight: 600;
}

/* Sidebar toggle buttons */
.sidebar-toggle-btn {
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text3);
}
.sidebar-toggle-btn:hover {
  color: var(--text);
  border-color: var(--text3);
}

/* Color mode label */
.color-mode-btns {
  font-size: 11px;
}
