:root {
  --primary: #4CAF50;
  --primary-dark: #2E7D32;
  --accent: #009688;
  --bg: #f5f7fa;
  --text: #37474f;
  --card-bg: #ffffff;
  --timeline-done: #4CAF50;
  --timeline-todo: #e0e0e0;
  --danger: #ef5350;
}

body {
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 20px;
  padding-bottom: 80px;
  /* Space for fixed buttons if any */
}

.container {
  max-width: 600px;
  margin: 0 auto;
}

/* Header e Status */
header {
  text-align: center;
  margin-bottom: 20px;
}

h1 {
  color: var(--primary-dark);
  margin: 0;
  font-size: 1.8rem;
}

p.subtitle {
  color: #78909c;
  margin: 5px 0 0 0;
  font-size: 0.9rem;
}

/* Connection Bar */
.connection-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  padding: 10px 15px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  margin-bottom: 20px;
}

.status-dot {
  height: 10px;
  width: 10px;
  background-color: #ccc;
  border-radius: 50%;
  display: inline-block;
  margin-right: 5px;
}

.status-dot.connected {
  background-color: var(--primary);
  box-shadow: 0 0 5px var(--primary);
}

.btn-connect {
  background: var(--primary);
  color: white;
  border: none;
  padding: 8px 15px;
  border-radius: 20px;
  font-weight: bold;
  cursor: pointer;
}

.btn-connect:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Dashboard Cards */
.current-status-card {
  background: var(--card-bg);
  border-radius: 15px;
  padding: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  text-align: center;
  border-top: 5px solid var(--primary);
  margin-bottom: 20px;
}

.status-item h3 {
  font-size: 0.8em;
  color: #90a4ae;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.status-item .val {
  font-size: 1.2em;
  font-weight: bold;
  color: var(--text);
}

.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 15px;
  color: white;
  font-weight: bold;
  font-size: 0.8em;
  cursor: pointer;
}

.on {
  background-color: var(--primary);
}

.off {
  background-color: var(--danger);
  opacity: 0.8;
}

/* Timeline */
.timeline-container {
  margin-bottom: 20px;
  padding: 0 5px;
}

.progress-bar {
  height: 8px;
  background: var(--timeline-todo);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
}

.progress-segment {
  height: 100%;
  transition: width 0.5s ease;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  font-size: 0.75em;
  font-weight: bold;
  color: #78909c;
}

/* Phase List & Config */
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  color: var(--text);
}

.btn-add {
  background: var(--primary);
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}

.phase-card {
  background: white;
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 15px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  border-left: 4px solid transparent;
  position: relative;
}

.phase-card.active {
  border-left-color: var(--primary);
  background: #f1f8e9;
}

.phase-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-right: 70px;
  /* Prevent overlap with absolute actions */
}

.phase-name {
  font-weight: bold;
  font-size: 1.1em;
}

.phase-days {
  font-size: 0.9em;
  color: #666;
  background: #eee;
  padding: 2px 8px;
  border-radius: 10px;
}

.phase-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  font-size: 0.9em;
  color: #555;
}

.phase-details .detail-row:first-child {
  grid-column: span 2;
  border-bottom: 1px solid #eee;
  padding-bottom: 5px;
  margin-bottom: 5px;
}

.detail-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.card-actions {
  position: absolute;
  top: 15px;
  right: 15px;
  display: flex;
  gap: 10px;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.6;
  padding: 5px;
}

.icon-btn:hover {
  opacity: 1;
}

/* Forms & Inputs */
.date-input-group {
  background: white;
  padding: 15px;
  border-radius: 12px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

input[type="date"] {
  border: 1px solid #ddd;
  padding: 8px;
  border-radius: 6px;
  font-family: inherit;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: white;
  width: 90%;
  max-width: 500px;
  border-radius: 15px;
  padding: 25px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  font-size: 1.2em;
  font-weight: bold;
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  font-size: 0.9em;
}

.form-group input {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-sizing: border-box;
}

.form-row {
  display: flex;
  gap: 15px;
}

.form-row .form-group {
  flex: 1;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.btn-cancel {
  background: #eee;
  color: #333;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
}

.btn-save {
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
}

/* Loading Spinner */
.spinner {
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top: 3px solid white;
  width: 16px;
  height: 16px;
  animation: spin 1s linear infinite;
  display: inline-block;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* Spinner */
.spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #4CAF50;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}