:root {
  --bg: #f4f5f7;
  --toolbar-bg: #ffffff;
  --border: #e0e2e6;
  --accent: #4262ff;
  --text: #1a1a1a;
  --danger: #e5484d;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  user-select: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

.text-btn {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}
.text-btn:hover { background: var(--bg); }
.text-btn.danger { color: var(--danger); }

[contenteditable="true"] {
  user-select: text;
  cursor: text;
}

/* ---------- Gantt / Cronograma widget (the whole app) ---------- */
.el-gantt {
  position: fixed;
  inset: 0;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  cursor: default;
  font-size: 12px;
}
.gantt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.gantt-title {
  font-weight: 700;
  font-size: 14px;
  outline: none;
  padding: 2px 4px;
  border-radius: 4px;
}
.gantt-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.gantt-add-btn {
  background: var(--accent);
  color: #fff;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.gantt-header-btn {
  background: #eef0f2;
  color: var(--text);
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.gantt-header-btn:hover { background: #e2e4e8; }
.gantt-content {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}
.gantt-names-wrap {
  position: relative;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.gantt-names-resize {
  position: absolute;
  right: -3px;
  top: 0; bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 5;
}
.gantt-names-resize:hover { background: rgba(66,98,255,0.25); }
.gantt-names {
  position: relative;
  z-index: 1;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  scrollbar-width: none; /* Firefox — mirrors the timeline's scroll instead of showing its own */
}
.gantt-names::-webkit-scrollbar { display: none; }
.gantt-names-footer {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px;
  border-top: 1px solid var(--border);
  background: var(--toolbar-bg);
}
.gantt-names-footer .gantt-add-btn,
.gantt-names-footer .gantt-add-blank-btn {
  width: 100%;
  text-align: center;
}
.gantt-add-blank-btn {
  background: none;
  border: 1px dashed #c4c8ce;
  color: #6b7280;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.gantt-add-blank-btn:hover { background: var(--bg); border-color: var(--accent); color: var(--accent); }
/* Empty placeholder at the bottom of the dates/timeline columns, sized in JS
   to match .gantt-names-footer's real height so all three columns share the
   same scrollable range and stay aligned down to the last row. */
.gantt-footer-spacer { flex-shrink: 0; }
.gantt-names-spacer {
  height: 26px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  padding-left: 8px;
  background: #3f4450;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--border);
}
.gantt-name-row-blank { opacity: 0.6; }
.gantt-blank-label { font-style: italic; }
.gantt-row-blank { position: relative; }
.gantt-row-blank::after {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 50%;
  border-top: 1px dashed #d8dae0;
}
.gantt-name-row {
  height: 32px;
  min-height: 32px;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  border-bottom: 1px solid #f0f1f3;
  cursor: grab;
}
.gantt-row-dragging { background: #e7ebff; opacity: 0.75; }
.gantt-name-row.gantt-task-selected { background: #e7ebff; }
.gantt-row.gantt-task-selected .gantt-bar { box-shadow: 0 0 0 2px var(--accent); }
.gantt-name-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  outline: none;
  cursor: move;
}
.gantt-del-btn {
  flex-shrink: 0;
  font-size: 11px;
  color: #b0b4bb;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.gantt-del-btn:hover { background: #fde2e2; color: var(--danger); }
.gantt-name-row:hover .gantt-del-btn { opacity: 1; }
.gantt-name-row-child { padding-left: 22px; }
.gantt-group-toggle {
  flex-shrink: 0;
  width: 14px;
  font-size: 9px;
  color: #6b7280;
  cursor: pointer;
  padding: 2px;
}
.gantt-group-toggle:hover { color: var(--accent); }
.gantt-ungroup-btn {
  flex-shrink: 0;
  font-size: 11px;
  color: #b0b4bb;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.gantt-ungroup-btn:hover { background: #eef0f2; color: var(--accent); }
.gantt-name-row:hover .gantt-ungroup-btn { opacity: 1; }
.gantt-name-row.gantt-group-drop-target,
.gantt-row.gantt-group-drop-target {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: rgba(66,98,255,0.12);
}
/* Plain reorder preview — a line rather than a filled highlight, so it
   reads as "insert here" instead of "group into this". */
.gantt-name-row.gantt-reorder-target {
  box-shadow: inset 0 3px 0 0 var(--accent);
}
.gantt-timeline {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-x: auto;
  overflow-y: auto;
  position: relative;
}
.gantt-ruler {
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}
.gantt-ruler-months {
  position: relative;
  height: 20px;
  border-bottom: 1px solid var(--border);
  background: #f0f2f5;
}
.gantt-ruler-month-cell {
  position: absolute;
  top: 0; bottom: 0;
  border-right: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  color: #4b5563;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  white-space: nowrap;
}
.gantt-ruler-days {
  position: relative;
  height: 22px;
}
.gantt-day-cell {
  position: absolute;
  top: 0; bottom: 0;
  border-right: 1px solid #eef0f2;
  font-size: 11px;
  color: #8a8f98;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gantt-day-cell.today { color: var(--accent); font-weight: 700; }
.gantt-day-cell.weekend { background: #e4e7ec; }
.gantt-day-cell.weekend.today { background: transparent; }
.gantt-ruler-weekdays {
  position: relative;
  height: 16px;
  background: #3f4450;
}
.gantt-weekday-cell {
  position: absolute;
  top: 0; bottom: 0;
  border-right: 1px solid rgba(255,255,255,0.08);
  font-size: 9px;
  color: #d7dae0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gantt-weekday-cell.weekend { background: #262a30; color: #b9bec8; }
.gantt-rows-area { position: relative; flex: 1 0 auto; }
.gantt-weekend-band {
  position: absolute;
  top: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.045);
}
.gantt-grid-line {
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: #eef0f2;
}
.gantt-grid-line-month { background: #dcdfe4; }
.gantt-today-line {
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: var(--accent);
  z-index: 1;
}
.gantt-row {
  height: 32px;
  min-height: 32px;
  position: relative;
  border-bottom: 1px solid #f0f1f3;
}
.gantt-bar {
  position: absolute;
  top: 4px;
  height: 24px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  cursor: grab;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  z-index: 2;
}
/* A collapsed group's rolled-up bar — no resize handles, drags the row
   (reorders the group) instead of the bar itself, so it reads as a
   summary rather than a single editable task. */
.gantt-bar-summary {
  opacity: 0.85;
  border: 1px dashed rgba(0,0,0,0.35);
  background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.3) 0 6px, transparent 6px 12px);
  cursor: grab;
}
.gantt-bar-label {
  font-size: 11px;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
.gantt-bar-handle {
  position: absolute;
  top: 0; bottom: 0;
  width: 8px;
  cursor: ew-resize;
  z-index: 3;
}
.gantt-bar-handle-start { left: 0; border-radius: 5px 0 0 5px; }
.gantt-bar-handle-end { right: 0; border-radius: 0 5px 5px 0; }
.gantt-bar-handle:hover { background: rgba(0,0,0,0.15); }
.gantt-link-handle {
  position: absolute;
  right: -8px;
  top: 50%;
  width: 14px; height: 14px;
  margin-top: -7px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  cursor: crosshair;
  opacity: 0;
  transition: opacity 0.12s ease;
  z-index: 4;
}
.gantt-bar:hover .gantt-link-handle,
.gantt-link-handle:hover {
  opacity: 1;
  transform: scale(1.15);
}
.gantt-links-svg { overflow: visible; z-index: 1; }
.gantt-link-path {
  cursor: pointer;
  pointer-events: stroke;
}
.gantt-link-path:hover { stroke: var(--danger) !important; stroke-width: 3; }
.gantt-link-path.selected { stroke: var(--accent) !important; stroke-width: 3; }

.gantt-zoom-controls {
  position: absolute;
  right: 16px; bottom: 16px;
  background: var(--toolbar-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  z-index: 20;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}
.gantt-zoom-controls button {
  width: 26px; height: 26px;
  border-radius: 6px;
  font-size: 14px;
}
.gantt-zoom-controls button:hover { background: var(--bg); }
.gantt-zoom-controls .text-btn { width: auto; padding: 0 10px; font-size: 12px; }
.gantt-zoom-label { font-size: 12px; width: 44px; text-align: center; }

#readonly-banner {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 700;
  background: #3f4450;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
  pointer-events: none;
}

/* ---------- Gantt dates side panel (collapsible) ---------- */
.gantt-dates-panel {
  flex-shrink: 0;
  display: flex;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  min-height: 0;
}
.gantt-dates-toggle {
  box-sizing: border-box;
  flex-shrink: 0;
  width: 22px;
  border: none;
  border-right: 1px solid var(--border);
  background: #eef0f2;
  color: #6b7280;
  cursor: pointer;
  font-size: 10px;
}
.gantt-dates-toggle:hover { background: #e2e4e8; color: var(--accent); }
.gantt-dates-col {
  width: 228px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: none; /* Firefox — mirrors the timeline's scroll instead of showing its own */
}
.gantt-dates-col::-webkit-scrollbar { display: none; }
.gantt-dates-header {
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  background: #3f4450;
}
.gantt-dates-h-cell {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-right: 1px solid rgba(255,255,255,0.12);
  text-align: center;
}
.gantt-dates-h-cell:last-child { border-right: none; }
.gantt-dates-h-cell-responsible { flex: 1.6; justify-content: flex-start; padding-left: 8px; text-align: left; }
.gantt-dates-row {
  flex-shrink: 0;
  height: 32px;
  display: flex;
  overflow: hidden;
  border-bottom: 1px solid #f0f1f3;
}
.gantt-dates-cell {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #333;
  border-right: 1px solid rgba(0,0,0,0.06);
}
.gantt-dates-cell:last-child { border-right: none; }
.gantt-dates-cell { cursor: text; outline: none; }
.gantt-dates-cell-responsible {
  flex: 1.6;
  min-width: 0;
  justify-content: flex-start;
  padding-left: 8px;
  text-align: left;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.gantt-dates-cell:hover { background: rgba(0,0,0,0.04); }
.gantt-dates-cell[contenteditable="true"] { background: #fff; box-shadow: inset 0 0 0 2px var(--accent); }
input.gantt-dates-cell-responsible {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0 8px;
  line-height: normal;
  border: none;
  background: transparent;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
input.gantt-dates-cell-responsible:hover { background: rgba(0,0,0,0.04); }
input.gantt-dates-cell-responsible:focus { background: #fff; box-shadow: inset 0 0 0 2px var(--accent); cursor: text; }
input.gantt-dates-cell-responsible::placeholder { color: #b6bac2; }
.gantt-dates-row-blank { background: #e6f4ea; }

/* ---------- Gantt task color popover ---------- */
.gantt-color-popover {
  position: fixed;
  z-index: 650;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
  padding: 8px;
}
.gantt-color-popover-swatches {
  display: grid;
  grid-template-columns: repeat(4, 22px);
  gap: 8px;
}
.gantt-color-popover-swatches button {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.15);
  padding: 0;
  cursor: pointer;
}
.gantt-color-popover-swatches button.selected { box-shadow: 0 0 0 2px var(--accent); }
.gantt-color-popover-add {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff !important;
  color: #6b7280;
  font-size: 14px;
  font-weight: 700;
  border-style: dashed !important;
  border-color: #c4c8ce !important;
}
.gantt-color-popover-add:hover { border-color: var(--accent) !important; color: var(--accent); }

.gantt-responsibles-popover {
  position: fixed;
  z-index: 600;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
  padding: 10px;
  width: 240px;
}
.gantt-responsibles-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
  margin-bottom: 8px;
}
.gantt-responsible-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.gantt-responsible-swatch {
  width: 20px; height: 20px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.2);
  padding: 0;
  cursor: pointer;
}
.gantt-responsible-name-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 12px;
  font: inherit;
  color: var(--text);
}
.gantt-responsible-name-input:focus { outline: none; border-color: var(--accent); }
.gantt-responsible-del-btn {
  flex-shrink: 0;
  font-size: 11px;
  color: #b0b4bb;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
}
.gantt-responsible-del-btn:hover { background: #fde2e2; color: var(--danger); }
.gantt-responsibles-add-btn {
  width: 100%;
  text-align: center;
  background: none;
  border: 1px dashed #c4c8ce;
  color: #6b7280;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.gantt-responsibles-add-btn:hover { background: var(--bg); border-color: var(--accent); color: var(--accent); }

/* ---------- Printable report: tasks grouped by responsible ---------- */
#gantt-print-report {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: #fff;
  overflow-y: auto;
  padding: 24px 32px;
}
.print-report-toolbar {
  position: sticky;
  top: -24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 12px 32px;
  margin: -24px -32px 16px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.print-report-toolbar-actions { display: flex; gap: 8px; flex-shrink: 0; }
.print-report-daterange {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
  flex-shrink: 0;
}
.print-report-daterange input[type="date"] {
  font-size: 13px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
}
.print-report-daterange-clear {
  font-size: 12px;
  color: #6b7280;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 6px;
}
.print-report-daterange-clear:hover { background: var(--bg); color: var(--accent); }
.print-report-filter { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 14px; }
.print-report-filter-all { font-weight: 600; }
.print-report-filter label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.print-report-filter-swatch {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.25);
}
.print-report-content, .print-report-content * {
  color: #1a1a1a !important;
  text-decoration: none !important;
  background: none;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif !important;
}
.print-report-table th { background: #f2f2f2 !important; }
.print-report-content h1 { font-size: 20px; margin: 0 0 20px; font-weight: 700; }
.print-report-person { margin-bottom: 32px; break-inside: avoid; }
.print-report-person:not(:last-child) { break-after: page; }
.print-report-person h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 10px;
  border-bottom: 2px solid #333;
  padding-bottom: 6px;
}
.print-report-swatch {
  width: 14px; height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.25);
}
.print-report-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-weight: 400; }
.print-report-table th, .print-report-table td {
  border: 1px solid #ccc;
  padding: 6px 10px;
  text-align: left;
  font-size: 13px;
  word-wrap: break-word;
}
.print-report-table th:nth-child(1), .print-report-table td:nth-child(1) { width: 60%; }
.print-report-table th:nth-child(2), .print-report-table td:nth-child(2),
.print-report-table th:nth-child(3), .print-report-table td:nth-child(3) { width: 20%; }
.print-report-table th { background: #f2f2f2; font-weight: 700; }

@media print {
  body * { visibility: hidden; }
  #gantt-print-report, #gantt-print-report * { visibility: visible; }
  #gantt-print-report {
    position: absolute;
    inset: 0;
    padding: 0 16px;
    overflow: visible;
  }
  .print-report-toolbar { display: none; }
}

/* Temporary preview line while dragging a dependency link */
#gantt-link-preview {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 550;
  overflow: visible;
}
#gantt-link-preview-line {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 6,4;
}

/* Marquee selection box (Alt+drag multi-select of tasks) */
#marquee {
  position: fixed;
  border: 1px solid var(--accent);
  background: rgba(66, 98, 255, 0.1);
  pointer-events: none;
  z-index: 40;
}

/* ---------- Custom confirm/alert modal ---------- */
.app-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}
.app-modal {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  padding: 20px;
  width: min(360px, calc(100vw - 32px));
}
.app-modal-message {
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-line;
}
.app-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.app-modal-actions .text-btn.primary {
  background: var(--accent);
  color: #fff;
}
.app-modal-actions .text-btn.primary:hover { background: #324fd6; }
.app-modal-actions .text-btn.primary.danger { background: var(--danger); }
.app-modal-actions .text-btn.primary.danger:hover { background: #c53f43; }
