body {
  margin: 0;
  font-family: "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  background: #f8f4ec;
  color: #2d2d2d;
}

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 16px 16px 112px;
}

.topbar {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
}

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

.region-select {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(204, 224, 236, 0.72);
  background: rgba(63, 104, 126, 0.12);
  font-size: 14px;
  color: #2d2d2d;
  cursor: pointer;
}

.actions {
  position: fixed;
  left: 18px;
  top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 20;
}
.actions button {
  border: 1px solid rgba(204, 224, 236, 0.72);
  border-radius: 10px;
  background: rgba(63, 104, 126, 0.64);
  backdrop-filter: blur(5px);
  color: #fff;
  width: 44px;
  min-height: 44px;
  padding: 10px 8px;
  font-size: 0.92rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.actions button:hover {
  background: rgba(48, 84, 103, 0.75);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  border: 1px solid #ddd3c3;
  padding: 4px 8px;
  border-radius: 999px;
  background: #fff;
}

.type-edit-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 80px 140px;
  gap: 8px;
  align-items: center;
  width: 100%;
}

.type-edit-grid input,
.type-edit-grid select {
  width: 100%;
  padding: 7px 8px;
  border-radius: 8px;
  border: 1px solid #d5cdc0;
  box-sizing: border-box;
}

.type-actions {
  display: flex;
  gap: 8px;
  margin-left: 10px;
}

.save-btn {
  border: 0;
  border-radius: 6px;
  padding: 6px 10px;
  background: rgba(46, 125, 83, 0.72);
  color: #fff;
  cursor: pointer;
}

.legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.gantt-wrap {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.08);
  overflow-x: auto;
  overflow-y: visible;
}

.gantt-head {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #f0ece2;
  font-weight: 700;
  border-bottom: 1px solid #e6dfd2;
  overflow: visible;
}

.gantt-head > div,
.gantt-row > div {
  padding: 10px;
}

.col-timeline {
  position: relative;
  height: 56px;
  min-width: 760px;
}

.month-mark {
  position: absolute;
  top: 2px;
  bottom: 0;
  border-left: 1px dashed #d8d0c1;
  font-size: 12px;
  color: #6b675f;
  padding-left: 4px;
}

.day-mark {
  position: absolute;
  top: 24px;
  bottom: 0;
  border-left: 1px solid #e7e0d2;
  font-size: 10px;
  color: #857d70;
  padding-left: 2px;
}

.gantt-row {
  border-bottom: 1px solid #f1ece3;
}

.timeline {
  position: relative;
  height: 44px;
  background: repeating-linear-gradient(
    to right,
    #faf8f4,
    #faf8f4 39px,
    #f0ece4 40px
  );
  border-radius: 6px;
}

/* ── Bar: layered structure ─────────────────────────────── */
.bar-wrap {
  position: absolute;
  top: 6px;
  height: 32px;
  min-width: 40px;
  cursor: grab;
  border-radius: 10px;
  overflow: hidden;         /* clips overlays to bar shape */
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  box-sizing: border-box;
  user-select: none;
}

.bar-wrap:active { cursor: grabbing; }

/* Base layer — fills entire bar in status color */
.bar-base {
  position: absolute;
  inset: 0;
  border-radius: 10px;
}

/* Overlay layer — fully covers the segment date range, sits on top */
.bar-overlay {
  position: absolute;
  top: 0;
  bottom: 0;
  min-width: 4px;
  pointer-events: none;
  z-index: 1;
  box-sizing: border-box;
}

/* Label — sits above everything */
.bar-label {
  position: absolute;
  inset: 0;
  z-index: 2;
  color: #fff;
  font-size: 12px;
  line-height: 32px;
  padding: 0 10px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-shadow: 0 1px 3px rgba(0,0,0,0.35);
  pointer-events: none;
}

.bar-wrap.dragging { opacity: 0.45; }

/* Drag-over highlight */
.gantt-lane-timeline.drag-over {
  background: rgba(63, 125, 221, 0.12) !important;
  outline: 2px dashed #3f7ddd;
  outline-offset: -2px;
}

/* Lane header */
.gantt-lane-header {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 140px;
  min-width: 140px;
  padding: 6px 8px;
  background: #f8f5ef;
  border-right: 1px solid #e6dfd2;
  cursor: pointer;
  transition: background 0.15s;
  overflow: hidden;
}

.gantt-lane-header:hover { background: #eee9de; }

.gantt-lane-num {
  font-size: 11px;
  font-weight: 700;
  color: #8a8070;
  min-width: 16px;
  text-align: center;
}

.gantt-lane-empty {
  font-size: 11px;
  color: #aaa;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gantt-lane-assigned {
  font-size: 11px;
  color: #3a5f56;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Lane picker modal */
.lane-picker-item {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #e4ddcf;
  background: #fff;
  cursor: pointer;
  transition: background 0.12s;
}

.lane-picker-item:hover { background: #f0ece2; }

.lane-picker-item.lane-picker-assigned { border-color: #f0ad4e; background: #fffbf0; }

.lane-picker-item-name {
  font-size: 14px;
  font-weight: 600;
  color: #2d2d2d;
}

.lane-picker-item-meta {
  font-size: 12px;
  color: #777;
  margin-top: 2px;
}

.empty {
  padding: 26px;
  text-align: center;
  color: #777;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.hidden {
  display: none !important;
}

.modal-card {
  width: min(760px, 100%);
  max-height: 86vh;
  overflow: auto;
  background: #fff;
  border-radius: 12px;
  border: 1px solid #ddd;
  padding: 14px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.modal-head h2 {
  margin: 0;
  font-size: 20px;
}

.modal-head button {
  border: 0;
  background: rgba(210, 219, 214, 0.65);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  cursor: pointer;
}

.type-form,
.bar-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.bar-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.type-form input,
.type-form select,
.type-form button,
.bar-form input,
.bar-form select,
.bar-form button {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #d5cdc0;
  box-sizing: border-box;
}

.type-form button,
.bar-form button {
  background: rgba(53, 93, 86, 0.7);
  color: #fff;
  border: 0;
  cursor: pointer;
}

.bar-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.type-list,
.segment-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.type-item,
.segment-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid #e4ddcf;
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.chip-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.danger-btn {
  border: 0;
  border-radius: 6px;
  padding: 6px 10px;
  background: rgba(217, 83, 79, 0.72);
  color: #fff;
  cursor: pointer;
}

@media (max-width: 900px) {
  .page {
    padding: 16px;
  }

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

  .actions {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .actions button {
    width: 44px;
    min-height: 44px;
    font-size: 0.92rem;
  }

  .type-form,
  .bar-form {
    grid-template-columns: 1fr;
  }

  .type-item,
  .segment-item {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .type-edit-grid {
    grid-template-columns: 1fr;
  }

  .type-actions {
    margin-left: 0;
    justify-content: flex-end;
  }
}

/* 未填日期訂單面板 */
.no-date-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 60vh;
  overflow-y: auto;
}

.no-date-item {
  border: 1px solid #e4ddcf;
  border-radius: 10px;
  padding: 12px 14px;
  background: #fffef7;
}

.no-date-item-title {
  font-weight: 600;
  font-size: 15px;
  color: #3a5f56;
  margin-bottom: 8px;
}

.no-date-item-sub {
  font-size: 12px;
  color: #888;
  margin-bottom: 10px;
}

.no-date-date-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: center;
}

.no-date-date-row input[type="date"] {
  padding: 7px 8px;
  border-radius: 8px;
  border: 1px solid #d5cdc0;
  font-size: 13px;
  width: 100%;
  box-sizing: border-box;
}

.no-date-date-row button {
  padding: 7px 14px;
  border-radius: 8px;
  border: 0;
  background: rgba(46, 125, 83, 0.72);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  font-size: 13px;
}

.no-date-date-row button:hover {
  background: rgba(36, 105, 68, 0.9);
}

/* 6-row Gantt: fixed-height lanes */
.gantt-body {
  min-height: calc(6 * 56px);
}

.gantt-row-group {
  border-bottom: 2px solid #e0d8c8;
}

.gantt-region-label {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  color: #6b675f;
  background: #f0ece2;
  border-bottom: 1px solid #e6dfd2;
  letter-spacing: 0.5px;
}

.gantt-lane {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid #f1ece3;
  min-height: 56px;
}

/* gantt-lane-header is styled in the bar section above */

.gantt-lane-timeline {
  flex: 1;
  position: relative;
  min-height: 56px;
  background: repeating-linear-gradient(
    to right,
    #faf8f4,
    #faf8f4 39px,
    #f0ece4 40px
  );
}

/* no-date-item header */
.no-date-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.nd-toggle-btn {
  padding: 5px 10px;
  border-radius: 7px;
  border: 1px solid #d5cdc0;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Bar status row (quick save) */
.bar-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  background: #f8f4ec;
  border: 1px solid #e4ddcf;
  border-radius: 8px;
  padding: 10px 12px;
}

.bar-status-row select,
.bar-status-row input[type="date"] {
  padding: 6px 8px;
  border-radius: 7px;
  border: 1px solid #d5cdc0;
  font-size: 13px;
  background: #fff;
}

.bar-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
