:root {
  --primary: #0056b3;
  --aquisitivo: #3b82f6;
  --concessivo: #10b981;
  --atencao: #f59e0b;
  --alerta: #ef4444;
  --ultimo-gozo: #a855f7;
  --proximo: #6366f1;

  --bg-aquisitivo: #eff6ff;
  --bg-concessivo: #ecfdf5;
  --bg-atencao: #fffbeb;
  --bg-alerta: #fef2f2;
  --bg-proximo: #eef2ff;

  --bg-color: #f1f5f9;
  --text-color: #1e293b;
  --border: #e2e8f0;
}

* {
  box-sizing: border-box;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}
body {
  background-color: var(--bg-color);
  color: var(--text-color);
  margin: 0;
  padding: 20px;
}
.container.wide {
  max-width: 98%;
  margin: 0 auto;
  background: white;
  padding: 30px;
  border-radius: 10px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
header {
  text-align: center;
  margin-bottom: 30px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 10px;
}

/* Controles Estruturados */
.controls-section {
  display: flex;
  flex-direction: column;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 30px;
}
.controls-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 30px;
  width: 100%;
  flex-wrap: wrap;
}

.input-group label,
.fracionamento-group label {
  font-weight: 600;
  margin-bottom: 5px;
  display: block;
  font-size: 14px;
}
.input-with-action {
  display: flex;
  align-items: center;
  gap: 8px;
}
input[type="date"],
input[type="number"] {
  padding: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  font-size: 15px;
  outline: none;
}
.btn-clear {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  padding: 8px 10px;
  border-radius: 5px;
  cursor: pointer;
  color: #64748b;
  transition: 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-clear:hover {
  background: #fee2e2;
  color: var(--alerta);
  border-color: #fca5a5;
}

.fracionamento-group {
  display: flex;
  flex-direction: column;
}
.frac-inputs {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}
.frac-inputs input {
  width: 85px;
  text-align: center;
}
.badge {
  font-size: 12px;
  font-weight: bold;
  color: var(--primary);
  background: #e0e7ff;
  padding: 4px 10px;
  border-radius: 12px;
  align-self: flex-start;
}
.badge.alert {
  color: var(--alerta);
  background: #fee2e2;
}
.hidden {
  display: none !important;
}

/* Switches em geral */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 20px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: 0.4s;
  border-radius: 20px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: #059669;
}
input:checked + .slider:before {
  transform: translateX(20px);
}

.toggle-group-sm {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
}
.pdf-toggle {
  background: transparent;
  border: none;
  padding: 0;
}

.segmented-control {
  display: inline-flex;
  border: 1px solid var(--primary);
  border-radius: 6px;
  overflow: hidden;
  background: white;
  align-self: flex-end;
  margin-bottom: 4px;
}
.segmented-control input[type="radio"] {
  display: none;
}
.segmented-control label {
  padding: 8px 25px;
  cursor: pointer;
  font-weight: 600;
  color: var(--primary);
  border-right: 1px solid var(--primary);
  transition: 0.2s;
}
.segmented-control label:last-child {
  border-right: none;
}
.segmented-control input[type="radio"]:checked + label {
  background: var(--primary);
  color: white;
}
.segmented-control label:hover:not(:active) {
  background: #e0e7ff;
}

/* Status Banner (Movido para dentro dos Controles) */
.status-banner {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 15px 20px;
  margin-top: 20px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}
.status-banner .hoje-text {
  font-size: 15px;
  color: #475569;
  font-weight: 600;
}
.status-banner .countdown {
  font-size: 15px;
  font-weight: 500;
  color: #1e3a8a;
  text-align: right;
  line-height: 1.4;
}
.status-banner.alert-banner {
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  border-color: #a7f3d0;
}
.status-banner.alert-banner .countdown {
  color: #065f46;
  text-align: left;
}
.concomitante-list {
  margin: 8px 0 0 20px;
  padding: 0;
  list-style-type: square;
  font-size: 14px;
}
.concomitante-list li {
  margin-bottom: 4px;
  font-weight: 600;
}

/* Header Resultado e PNG */
.header-resultado {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin: 10px 15px 0 15px;
}
.btn-download {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #334155;
  color: white;
  border: none;
  padding: 8px 15px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: 0.2s;
}
.btn-download:hover {
  background: #0f172a;
}
#areaCaptura {
  background: white;
  padding: 20px;
  border-radius: 8px;
  border: 1px solid transparent;
}

/* Timeline Global e Markers */
.timeline {
  position: relative;
  margin: 10px 0 20px 0;
}
.timeline-item.aquisitivo .marker {
  background: var(--aquisitivo);
  box-shadow: 0 0 0 2px var(--aquisitivo);
}
.timeline-item.concessivo .marker {
  background: var(--concessivo);
  box-shadow: 0 0 0 2px var(--concessivo);
}
.timeline-item.atencao .marker {
  background: var(--atencao);
  box-shadow: 0 0 0 2px var(--atencao);
}
.timeline-item.alerta .marker {
  background: var(--alerta);
  box-shadow: 0 0 0 2px var(--alerta);
}
.timeline-item.proximo .marker {
  background: var(--primary);
  box-shadow: 0 0 0 2px var(--primary);
}
.timeline-item.proximo-concessivo .marker {
  background: var(--proximo);
  box-shadow: 0 0 0 2px var(--proximo);
}

.timeline-item.aquisitivo .content {
  border-top: 4px solid var(--aquisitivo);
  background: var(--bg-aquisitivo);
}
.timeline-item.concessivo .content {
  border-top: 4px solid var(--concessivo);
  background: var(--bg-concessivo);
}
.timeline-item.atencao .content {
  border-top: 4px solid var(--atencao);
  background: var(--bg-atencao);
}
.timeline-item.alerta .content {
  border-top: 4px solid var(--alerta);
  background: var(--bg-alerta);
}
.timeline-item.proximo .content {
  border-top: 4px solid var(--primary);
  background: var(--bg-proximo);
}
.timeline-item.proximo-concessivo .content {
  border-top: 4px solid var(--proximo);
  background: var(--bg-proximo);
}

.content {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-left: 1px solid var(--border);
  padding: 15px;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.content h3 {
  margin: 0 0 5px 0;
  font-size: 14px;
  text-transform: uppercase;
  color: #475569;
}
.content p {
  margin: 0;
  font-weight: 700;
  color: #0f172a;
  font-size: 15px;
}
.content small {
  display: block;
  margin-top: 5px;
  color: #64748b;
  font-size: 12px;
  line-height: 1.2;
}

/* Timeline Vertical */
.timeline.vertical {
  display: flex;
  flex-direction: column;
  padding-left: 10px;
  margin-left: 20px;
}
.timeline.vertical::before {
  display: none;
}
.timeline.vertical .timeline-item {
  position: relative;
  padding-bottom: 20px;
  padding-left: 40px;
  border-left: 4px solid #cbd5e1;
  margin-bottom: 0;
  width: 100%;
}
.timeline.vertical .timeline-item:last-child {
  border-left-color: transparent;
  padding-bottom: 0;
}
.timeline.vertical .marker {
  position: absolute;
  left: -12px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 3px solid white;
  top: 15px;
  z-index: 2;
}
.timeline.vertical .content {
  margin-top: 0;
  max-width: 600px;
  position: relative;
}
.timeline.vertical .content::before {
  content: "";
  position: absolute;
  left: -40px;
  top: 22px;
  width: 40px;
  height: 4px;
  background: #cbd5e1;
  z-index: -1;
}

/* Timeline Horizontal */
.timeline.horizontal {
  display: flex;
  flex-direction: row;
  gap: 15px;
  padding-left: 0;
  flex-wrap: nowrap;
}
.timeline.horizontal::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  width: 100%;
  height: 4px;
  background: #cbd5e1;
  z-index: 1;
}
.timeline.horizontal .timeline-item {
  flex: 1;
  position: relative;
  min-width: 150px;
}
.timeline.horizontal .marker {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: -4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 3px solid white;
  z-index: 2;
}
.timeline.horizontal .content {
  margin-top: 35px;
  text-align: center;
}

/* Swimlane / Raias */
.swimlane-wrapper {
  margin: 10px 0 0 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.lanes-container {
  display: flex;
  flex-direction: column;
  position: relative;
}
.lane {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.lane:last-child {
  border-bottom: none;
}
.lane-header {
  width: 160px;
  background: #f8fafc;
  padding: 15px;
  font-weight: bold;
  font-size: 13px;
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #334155;
  z-index: 30;
}
.lane-body {
  flex: 1;
  position: relative;
  padding: 25px 0;
  min-height: 90px;
  background: #fafafa;
}
.lane-body::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background-image: linear-gradient(90deg, transparent 99%, #e2e8f0 100%);
  background-size: 10% 100%;
}
.gantt-block {
  position: absolute;
  height: 36px;
  top: 50%;
  transform: translateY(-50%);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 10px;
  z-index: 10;
  cursor: help;
}

.swimlane-overlay {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 160px;
  pointer-events: none;
  z-index: 20;
}
.hoje-line {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 2px dashed #2563eb;
}
.hoje-line-label {
  position: absolute;
  top: 2px;
  left: -18px;
  background: #2563eb;
  color: white;
  font-size: 10px;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 4px;
}

.swimlane-info-cards {
  margin: 15px;
  border-top: 1px solid var(--border);
  padding-top: 15px;
}
.swimlane-info-cards::before {
  display: none;
}
.swimlane-info-cards .marker {
  display: none;
}
.swimlane-info-cards .content {
  margin-top: 0;
}

/* Expanders */
.expander {
  margin-bottom: 15px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
}
summary {
  padding: 15px;
  background: #f8fafc;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  font-size: 15px;
  border-radius: 6px;
}
summary:hover {
  background: #f1f5f9;
}

/* Calendário */
.header-calendario {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 15px;
  border-bottom: 1px solid var(--border);
  background: #fdfdfd;
  flex-wrap: wrap;
  gap: 15px;
}
.legenda-calendario {
  font-size: 13px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.leg-item {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
}
.leg-pa {
  background: #dbeafe;
  color: #1e3a8a;
}
.leg-pc {
  background: #d1fae5;
  color: #065f46;
}
.leg-atencao {
  background: #1e293b;
  color: white;
  font-weight: bold;
}
.leg-ultimo-gozo {
  background: #f3e8ff;
  color: #6b21a8;
  font-weight: bold;
}
.leg-limite {
  background: #fee2e2;
  color: #991b1b;
  font-weight: bold;
}
.leg-hoje {
  border: 2px solid #2563eb;
  color: #1e3a8a;
  font-weight: bold;
}

.calendars-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 15px;
  padding: 15px;
}
.month {
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 10px;
  text-align: center;
}
.month-name {
  font-weight: bold;
  margin-bottom: 10px;
  background: #334155;
  color: white;
  padding: 5px;
  border-radius: 3px;
  font-size: 14px;
}
.weekdays-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  font-size: 12px;
  font-weight: bold;
  margin-bottom: 5px;
  color: #64748b;
}
.weekday {
  padding: 4px 0;
}
.days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  font-size: 12px;
}
.day {
  padding: 6px 0;
  background: #f8fafc;
  border-radius: 2px;
  transition: 0.1s;
}
.day.empty {
  background: transparent;
  border: none;
}
.day.pa {
  background: #dbeafe;
  color: #1e3a8a;
}
.day.pc {
  background: #d1fae5;
  color: #065f46;
}
.day.ultimo-gozo {
  background: #f3e8ff;
  color: #6b21a8;
  font-weight: bold;
}
.day.limite {
  background: #fee2e2;
  color: #991b1b;
  font-weight: bold;
}
.day.atencao {
  background: #1e293b;
  color: white;
  font-weight: bold;
  border: 1px solid #0f172a;
}
.day.hoje {
  border: 2px solid #2563eb;
  font-weight: 900;
  color: #1e3a8a;
  box-shadow: inset 0 0 0 1px #bfdbfe;
}

/* Despacho */
.despacho-container {
  padding: 15px;
  background: #fafafa;
}
.despacho-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  margin-bottom: 15px;
  flex-wrap: wrap;
  gap: 15px;
}
.despacho-tabs {
  display: flex;
}
.tab-btn {
  background: none;
  border: none;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: #64748b;
  border-bottom: 3px solid transparent;
}
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.editor-box {
  width: 100%;
  min-height: 400px;
  background: white;
  padding: 35px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 14px;
  line-height: 1.6;
  color: #333;
  outline: none;
}
textarea.editor-box {
  font-family: "Courier New", Courier, monospace;
  resize: vertical;
}

.acoes-despacho {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 15px;
}
.btn-copy {
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: 0.2s;
}
.btn-copy:hover {
  background: #004494;
}

/* PDF Controls Formatados */
.pdf-controls {
  display: flex;
  align-items: center;
  gap: 18px;
  background: white;
  padding: 8px 15px;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.btn-pdf {
  background: #ef4444;
  color: white;
  border: none;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: bold;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: 0.2s;
  margin-left: 10px;
}
.btn-pdf:hover {
  background: #b91c1c;
}
