* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0d0d0d;
  color: #e0e0e0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

.app { width: 100%; max-width: 420px; padding: 0; }

.phone {
  padding: 56px 20px 32px;
  min-height: 100vh;
}

/* ─── HEADER ─── */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.header h1 {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
}
.header-icon { margin-right: 4px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.time {
  font-size: 14px;
  color: #666;
  background: #1a1a1a;
  padding: 6px 14px;
  border-radius: 20px;
  font-variant-numeric: tabular-nums;
}

/* ─── CALENDÁRIO ─── */
.calendar {
  background: #1a1a1a;
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 8px;
}
.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.calendar-header h3 { font-size: 15px; color: #ccc; }
.nav-btn {
  background: none;
  border: none;
  color: #555;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s;
}
.nav-btn:hover { background: #252525; }
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}
.day-name { color: #444; font-size: 11px; padding: 6px 0; font-weight: 600; }
.day {
  padding: 8px 0;
  border-radius: 8px;
  color: #888;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}
.day:hover { background: #252525; }
.day.other-month { color: #2a2a2a; cursor: default; }
.day.other-month:hover { background: transparent; }
.day.today {
  background: #2a6df4;
  color: #fff;
  font-weight: 600;
}
.day.today:hover { background: #1e5ad4; }
.day.selected {
  outline: 2px solid #2a6df4;
  outline-offset: -2px;
}
.day.has-task { color: #e0e0e0; }
.day.has-task:not(.today)::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  background: #2a6df4;
  border-radius: 50%;
}
.day.today.has-task::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  background: rgba(255,255,255,0.7);
  border-radius: 50%;
}

/* ─── ESTATÍSTICAS ─── */
.stats {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.stat-card {
  flex: 1;
  background: #1a1a1a;
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
  cursor: pointer;
  transition: background 0.2s;
}
.stat-card:hover { background: #222; }
.stat-card .num { font-size: 20px; font-weight: 700; color: #fff; }
.stat-card .label { font-size: 10px; color: #555; margin-top: 2px; }
.stat-card.done .num { color: #4caf50; }
.stat-card.overdue .num { color: #ef5350; }
.stat-card.today-count .num { color: #ffa726; }
.stat-card.active-filter { background: #222; outline: 1px solid #333; }

/* ─── VIEW TOGGLE ─── */
.view-toggle {
  display: flex;
  gap: 4px;
  background: #1a1a1a;
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 12px;
}
.view-btn {
  flex: 1;
  background: none;
  border: none;
  color: #555;
  font-size: 12px;
  padding: 8px 4px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}
.view-btn.active {
  background: #2a6df4;
  color: #fff;
}
.view-btn:hover:not(.active) { color: #888; }

/* ─── SECTION LABEL ─── */
.section-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.section-label h2 { font-size: 16px; font-weight: 600; color: #fff; }
.section-label .count { font-size: 11px; color: #666; background: #1a1a1a; padding: 2px 10px; border-radius: 10px; }

/* ─── TASK LIST ─── */
.task-list { display: flex; flex-direction: column; gap: 4px; }
.task-list.view-today .task { background: rgba(255, 167, 38, 0.06); }
.task-list.view-done .task { background: rgba(76, 175, 80, 0.06); }
.task-list.view-overdue .task { background: rgba(239, 83, 80, 0.06); }
.task {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #1a1a1a;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
  touch-action: manipulation;
}
.task:hover { background: #1f1f1f; }
.task .cb {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 2px solid #333;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: transparent;
  transition: all 0.2s;
}
.task .cb.done {
  background: #2a6df4;
  border-color: #2a6df4;
  color: #fff;
}
.task .info { flex: 1; min-width: 0; }
.task .info .name { font-size: 14px; color: #e0e0e0; }
.task .info .meta {
  font-size: 11px;
  color: #555;
  margin-top: 2px;
}
.task.done .info .name {
  text-decoration: line-through;
  color: #444;
}

.task .del-btn {
  background: none;
  border: none;
  color: #555;
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  opacity: 0.4;
  flex-shrink: 0;
}
.task .del-btn:hover { color: #ef5350; opacity: 1; }

/* ─── CATEGORY TAGS ─── */
.tag {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 500;
  flex-shrink: 0;
  white-space: nowrap;
}
.tag.saude { background: #2d1b2e; color: #e040a0; }
.tag.estudo { background: #1a2e1b; color: #66bb6a; }
.tag.lazer { background: #2e2a1a; color: #ffa726; }
.tag.investimentos { background: #1a2a2e; color: #4fc3f7; }
.tag.pessoal { background: #1a1e3a; color: #7c8df0; }
.tag.trabalho { background: #2e1e1e; color: #ef5350; }

/* ─── ADD BUTTON ─── */
.add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 12px;
  margin-top: 8px;
  background: none;
  border: 2px dashed #2a2a2a;
  border-radius: 12px;
  color: #555;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.add-btn:hover { border-color: #3a3a3a; color: #888; }

/* ─── UPCOMING LIST ─── */
.upcoming-list { display: flex; flex-direction: column; gap: 4px; }
.upcoming-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #161616;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.upcoming-item:hover { background: #1c1c1c; }
.upcoming-item .date {
  color: #555;
  font-size: 11px;
  min-width: 48px;
  flex-shrink: 0;
}
.upcoming-item .name { flex: 1; color: #ccc; }
.upcoming-item .count-badge {
  font-size: 10px;
  color: #666;
  background: #1a1a1a;
  padding: 2px 6px;
  border-radius: 6px;
}

/* ─── ALL LIST ─── */
.all-group { margin-bottom: 8px; }
.all-group .group-title {
  font-size: 12px;
  color: #555;
  padding: 4px 8px;
  margin-bottom: 4px;
}

/* ─── LEGEND ─── */
.legend {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #1a1a1a;
}
.legend-item { font-size: 11px; color: #444; }


/* ─── MODAL ─── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.15s ease;
}
.modal {
  background: #1a1a1a;
  width: 100%;
  max-width: 420px;
  border-radius: 20px 20px 0 0;
  padding: 20px;
  animation: slideUp 0.2s ease;
  max-height: 90vh;
  overflow-y: auto;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.modal-header h3 { font-size: 18px; color: #fff; }
.modal-close {
  background: none;
  border: none;
  color: #555;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}
.field { display: block; margin-bottom: 14px; }
.field span {
  display: block;
  font-size: 12px;
  color: #666;
  margin-bottom: 4px;
  font-weight: 500;
}
.field input, .field select {
  width: 100%;
  background: #121212;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 10px 12px;
  color: #e0e0e0;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.field input:focus, .field select:focus { border-color: #2a6df4; }
.field select { cursor: pointer; }
.repeat-extras { display: none; }
.repeat-extras.show { display: block; }
.dias-semana { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.dow-label { display: flex; align-items: center; gap: 3px; font-size: 12px; color: #aaa; background: #1a1a1a; padding: 4px 8px; border-radius: 6px; cursor: pointer; }
.dow-label input { width: 14px; height: 14px; accent-color: #2a6df4; cursor: pointer; }
#diasSemanaGroup { display: none; }
#diasSemanaGroup.show { display: block; }
.field-row {
  display: flex;
  gap: 10px;
}
.field-row .field { flex: 1; }
.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #ccc;
  margin-bottom: 14px;
  cursor: pointer;
}
.checkbox-field input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #2a6df4;
  cursor: pointer;
}
.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.2s;
}
.btn:hover { opacity: 0.85; }
.btn-save { background: #2a6df4; color: #fff; }
.btn-cancel { background: #252525; color: #888; }

/* ─── FOOTER ─── */
.footer-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  padding-top: 12px;
}
.sync-icon { font-size: 14px; cursor: default; transition: color 0.3s; }
.footer-note {
  text-align: center;
  font-size: 11px;
  color: #2a2a2a;
}

/* ─── EDIT BUTTON ─── */
.edit-btn {
  background: none;
  border: none;
  font-size: 13px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0.5;
  flex-shrink: 0;
  line-height: 1;
}
.edit-btn:hover { opacity: 1; }

/* ─── EMPTY STATE ─── */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: #444;
  font-size: 14px;
}
.empty-state .icon { font-size: 40px; margin-bottom: 8px; }

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 4px; }

/* ─── RESPONSIVE ─── */
@media (max-width: 440px) {
  .phone { padding: 48px 16px 24px; }
}
@media (min-width: 441px) {
  body { align-items: center; }
  .phone { border-radius: 0; min-height: 100vh; }
}
