* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family: Arial, sans-serif;
  background: #f0f2f5;
  padding: 20px;
}
h1 {
  text-align: center;
  margin-bottom: 10px;
  font-size: 1.4em;
}
#toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  background: #fff;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}
button {
  padding: 5px 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85em;
  background: #4a90d9;
  color: #fff;
}
button:hover {
  background: #357abd;
}
button.danger {
  background: #e05;
}
button.danger:hover {
  background: #c00;
}
button.success {
  background: #27ae60;
}
button.success:hover {
  background: #1e8449;
}
button.neutral {
  background: #888;
}
button.neutral:hover {
  background: #666;
}
button.warn {
  background: #e67e22;
}
button.warn:hover {
  background: #ca6f1e;
}
#grid-wrapper {
  overflow-x: auto;
}
table {
  border-collapse: collapse;
  width: 100%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  table-layout: fixed;
}
col.time-col {
  width: 52px;
}
col.day-col {
  width: calc((100% - 52px) / 6);
}
th {
  background: #2c3e50;
  color: #fff;
  padding: 5px 4px;
  font-size: 0.82em;
  text-align: center;
}
th.time-col {
  background: #1a252f;
}

th small {
  font-weight: normal;
  opacity: 0.8;
}
td.time-cell {
  background: #ecf0f1;
  color: #555;
  font-size: 0.75em;
  text-align: center;
  font-weight: bold;
  border: 1px solid #ddd;
  height: 28px;
}
td.slot {
  border: 1px solid #ddd;
  height: 28px;
  position: relative;
  cursor: pointer;
}
tr.full-hour td {
  border-top: 2px solid #bbb;
}
.ev-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 2;
}
.event {
  position: absolute;
  left: 2px;
  right: 2px;
  border-radius: 5px;
  padding: 3px 5px;
  font-size: 0.78em;
  overflow: hidden;
  cursor: grab;
  pointer-events: auto;
  user-select: none;
}
.event:active {
  cursor: grabbing;
}
.event.dragging {
  opacity: 0.25;
  pointer-events: none;
}
.ev-title {
  font-weight: bold;
}
.ev-note {
  font-size: 0.88em;
  opacity: 0.82;
}
.ev-actions {
  display: none;
  position: absolute;
  top: 2px;
  right: 2px;
  gap: 3px;
}
.event:hover .ev-actions {
  display: flex;
}
.ev-actions span {
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 0.8em;
  cursor: pointer;
  line-height: 1.6;
}
#drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  display: none;
  border-radius: 5px;
  padding: 4px 10px;
  font-size: 0.8em;
  opacity: 0.9;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
}
.ev-preview {
  position: absolute;
  left: 2px;
  right: 2px;
  border-radius: 5px;
  z-index: 5;
  pointer-events: none;
  border: 2px dashed;
}
#modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
#modal-overlay.open {
  display: flex;
}
#modal {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  width: 340px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}
#modal h2 {
  margin-bottom: 14px;
  font-size: 1.1em;
  color: #2c3e50;
}
#modal label {
  display: block;
  font-size: 0.82em;
  color: #555;
  margin: 8px 0 3px;
}
#modal input[type="text"],
#modal textarea,
#modal select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.88em;
}
#modal textarea {
  height: 60px;
  resize: vertical;
}
.color-row {
  display: flex;
  gap: 12px;
}
.color-row > div {
  flex: 1;
}
#modal-btns {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  justify-content: flex-end;
}
@media print {
  @page {
    size: A4 landscape;
    margin: 8mm;
  }
  body {
    background: #fff;
    padding: 0;
  }
  #no-print,
  #modal-overlay {
    display: none !important;
  }
  table {
    box-shadow: none;
  }
  .ev-actions {
    display: none !important;
  }
  .event {
    font-size: 6.5px;
    padding: 1px 2px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  td.slot,
  td.time-cell,
  th {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
