:root {
  --orange: #C0541E;
  --orange-light: #F4DCC6;
  --orange-bg: #FBF1E6;
  --brown: #3B2418;
  --grey: #6B6B6B;
  --green: #2E7D32;
  --green-bg: #E8F5E9;
  --blue: #1565C0;
  --blue-bg: #E3F2FD;
  --purple-bg: #EDE7F6;
  --purple: #512DA8;
  --teal-bg: #E0F2F1;
  --teal: #00695C;
  --red: #C62828;
  --red-bg: #FDECEA;
  --white: #FFFFFF;
  --bg: #F7F3EF;
  --border: #E0D5CC;
  --card-shadow: 0 1px 3px rgba(60,36,24,0.08);
  --app-max: 880px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--brown);
  min-height: 100vh;
}
@media (min-width: 900px) {
  body { background: #ECE4DC; }
}

/* Coluna central (mobile-first, centralizada no desktop) */
.hwrap, .nwrap, main {
  max-width: var(--app-max);
  margin-left: auto; margin-right: auto; width: 100%;
}
@media (min-width: 900px) {
  main { background: var(--bg); box-shadow: 0 0 0 1px var(--border); min-height: calc(100vh - 56px); }
}

/* ÍCONES (SVG de linha) */
svg.ic {
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  width: 1.2em; height: 1.2em; display: inline-block; vertical-align: middle;
}
.bicon svg.ic { width: 23px; height: 23px; }
.nav-btn svg.ic { width: 20px; height: 20px; }
.fab svg.ic { width: 26px; height: 26px; }
.modal-close svg.ic { width: 18px; height: 18px; }
.chip.add svg.ic, .co-tab.add svg.ic { width: 14px; height: 14px; margin-right: 2px; }
.tag-atrasada svg.ic { width: 12px; height: 12px; margin-right: 2px; }

/* HEADER */
header {
  background: var(--brown);
  color: white;
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
.hwrap { display: flex; align-items: center; justify-content: space-between; padding: 0 20px; }
header .logo { font-size: 15px; font-weight: 600; letter-spacing: 0.02em; }
header .logo span { color: var(--orange-light); }
header .subtitle { font-size: 12px; color: rgba(255,255,255,0.55); margin-top: 2px; }
.logout-link { color: rgba(255,255,255,0.8); font-size: 13px; text-decoration: none; }

/* DATE NAV */
.date-bar {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.date-bar .date-text { font-size: 15px; font-weight: 600; color: var(--brown); flex: 1; text-align: center; }
.date-bar .date-sub { font-size: 11px; color: var(--grey); display: block; font-weight: 400; }
.nav-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--orange-bg); border: 1px solid var(--orange-light);
  color: var(--orange); font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.nav-btn:active { background: var(--orange-light); }

/* TEAM CHIPS */
.team-bar {
  background: white;
  padding: 10px 20px 8px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--orange-light) transparent;
}
.team-bar::-webkit-scrollbar { height: 6px; }
.team-bar::-webkit-scrollbar-thumb { background: var(--orange-light); border-radius: 3px; }
.team-bar::-webkit-scrollbar-track { background: transparent; }
.chip {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 20px;
  border: 1.5px solid var(--border);
  background: white; cursor: pointer;
  font-size: 13px; font-weight: 500;
  color: var(--grey); white-space: nowrap;
  transition: all 0.15s;
  flex-shrink: 0;
}
.chip.active { border-color: var(--orange); color: var(--orange); background: var(--orange-bg); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip.add, .co-tab.add { color: var(--orange); border-style: dashed; font-weight: 700; }

/* COMPANY TABS */
.company-bar {
  padding: 10px 20px 8px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  background: var(--bg);
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--orange-light) transparent;
}
.company-bar::-webkit-scrollbar { height: 6px; }
.company-bar::-webkit-scrollbar-thumb { background: var(--orange-light); border-radius: 3px; }
.company-bar::-webkit-scrollbar-track { background: transparent; }
.co-tab {
  padding: 5px 12px; border-radius: 16px;
  border: 1px solid var(--border);
  background: white; cursor: pointer;
  font-size: 12px; color: var(--grey);
  white-space: nowrap; flex-shrink: 0;
}
.co-tab.active { background: var(--brown); color: white; border-color: var(--brown); }
.co-tag {
  font-size: 10px; padding: 1px 5px; border-radius: 8px;
  margin-left: 3px; vertical-align: middle;
}
.co-tag.pacote_completo { background: var(--green-bg); color: var(--green); }
.co-tag.trafego { background: var(--blue-bg); color: var(--blue); }

/* PROGRESS */
.progress-wrap { padding: 12px 20px 0; }
.progress-stats {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--grey); margin-bottom: 6px;
}
.progress-stats strong { color: var(--brown); }
.progress-bar {
  height: 6px; background: var(--border); border-radius: 3px; overflow: hidden;
}
.progress-fill { height: 100%; background: var(--green); border-radius: 3px; transition: width 0.4s; }

/* TASK LIST */
.task-list { padding: 12px 16px 80px; }
.section-head {
  font-size: 11px; font-weight: 600; color: var(--grey);
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 12px 4px 6px;
}
.task-card {
  background: white;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: var(--card-shadow);
  transition: opacity 0.2s;
}
.task-card.done { opacity: 0.5; }
.task-card .task-open { flex: 1; min-width: 0; cursor: pointer; }
.check-btn {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--border); background: white;
  cursor: pointer; flex-shrink: 0; margin-top: 1px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  transition: all 0.15s;
}
.check-btn.checked { background: var(--green); border-color: var(--green); }
.check-btn.checked::after { content: '✓'; color: white; font-size: 12px; font-weight: 700; }
.task-info { flex: 1; min-width: 0; }
.task-title {
  font-size: 14px; font-weight: 500; color: var(--brown); line-height: 1.4;
}
.task-card.done .task-title { text-decoration: line-through; color: var(--grey); }
.task-desc { font-size: 12px; color: var(--grey); margin-top: 3px; }
.task-bottom { display: flex; align-items: center; gap: 6px; margin-top: 5px; flex-wrap: wrap; }
.avatar-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--grey);
}
.avatar {
  width: 20px; height: 20px; border-radius: 50%; color: white;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700;
}
.status-tag {
  margin-left: auto; flex-shrink: 0;
  font-size: 11px; padding: 2px 8px; border-radius: 10px;
}
.status-pendente { background: var(--bg); color: var(--grey); }
.status-em_andamento { background: var(--blue-bg); color: var(--blue); }
.status-concluida { background: var(--green-bg); color: var(--green); }
.tag-prazo { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--orange-bg); color: var(--orange); display: inline-flex; align-items: center; gap: 3px; }
.tag-prazo svg.ic { width: 12px; height: 12px; }
.rec-badge { color: var(--grey); display: inline-flex; align-items: center; }
.rec-badge svg.ic { width: 14px; height: 14px; }
.tag-atrasada { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--red-bg); color: var(--red); font-weight: 600; }

/* EMPTY */
.empty {
  text-align: center; padding: 3rem 1rem; color: var(--grey);
}
.empty .icon { font-size: 40px; margin-bottom: 10px; }
.empty p { font-size: 14px; }

/* PLANNING ALERT */
.alert-banner {
  margin: 12px 16px 0;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1.5px solid;
}
.alert-banner.urgent { background: #FFF3E0; border-color: #FFB74D; }
.alert-banner.warning { background: #FFF8E1; border-color: #FFD54F; }
.alert-banner .alert-icon { font-size: 22px; flex-shrink: 0; display: flex; }
.alert-banner .alert-icon svg.ic { width: 24px; height: 24px; }
.alert-banner.urgent .alert-icon { color: #E65100; }
.alert-banner.warning .alert-icon { color: #B26A00; }
.empty .icon svg.ic { width: 46px; height: 46px; }
.alert-banner .alert-text { flex: 1; }
.alert-banner .alert-title { font-size: 13px; font-weight: 600; color: var(--brown); }
.alert-banner .alert-sub { font-size: 12px; color: var(--grey); margin-top: 2px; }
.alert-banner .alert-btn {
  font-size: 12px; font-weight: 600;
  color: var(--orange); background: none; border: 1.5px solid var(--orange);
  border-radius: 8px; padding: 4px 10px; cursor: pointer; flex-shrink: 0;
}

/* PLANNING VIEW */
.plan-header { padding: 16px 16px 0; }
.plan-month-title { font-size: 16px; font-weight: 600; color: var(--brown); margin-bottom: 4px; }
.plan-month-sub { font-size: 12px; color: var(--grey); margin-bottom: 12px; }
.plan-card {
  background: white; border-radius: 12px; border: 1px solid var(--border);
  padding: 14px; margin-bottom: 8px; box-shadow: var(--card-shadow);
}
.plan-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 10px;
}
.plan-card-name { font-size: 14px; font-weight: 600; color: var(--brown); }
.plan-card-type { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--bg); color: var(--grey); }
.plan-steps { list-style: none; }
.plan-step {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 6px 0; border-bottom: 1px solid var(--bg);
  font-size: 13px; color: var(--brown);
}
.plan-step:last-child { border-bottom: none; }
.plan-step-check {
  width: 18px; height: 18px; border-radius: 50%;
  border: 1.5px solid var(--border); background: white;
  cursor: pointer; flex-shrink: 0; margin-top: 1px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.plan-step-check.checked { background: var(--green); border-color: var(--green); }
.plan-step-check.checked::after { content: '✓'; color: white; font-size: 10px; font-weight: 700; }
.plan-step.done-step { opacity: 0.45; }
.plan-step.done-step span { text-decoration: line-through; color: var(--grey); }
.plan-overall {
  background: var(--orange-bg); border-radius: 10px;
  padding: 10px 14px; margin: 0 16px 12px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px;
}
.plan-overall strong { color: var(--orange); font-size: 15px; }

/* CLOSED / INFO BANNER */
.closed-banner {
  margin: 16px; background: var(--orange-bg);
  border: 1px solid var(--orange-light);
  border-radius: 12px; padding: 20px; text-align: center;
}
.closed-banner .icon { font-size: 32px; margin-bottom: 8px; }
.closed-banner p { font-size: 14px; color: var(--brown); font-weight: 500; }
.closed-banner small { font-size: 12px; color: var(--grey); }

/* TODAY HIGHLIGHT */
.today-dot {
  display: inline-block; width: 6px; height: 6px;
  background: var(--orange); margin-left: 4px;
  vertical-align: middle; border-radius: 50%;
}

/* BOTTOM NAV */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: white; border-top: 1px solid var(--border);
  z-index: 100;
}
.nwrap { display: flex; }
.bottom-btn {
  flex: 1; padding: 10px 8px; cursor: pointer;
  background: none; border: none;
  font-size: 11px; color: var(--grey);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.bottom-btn.active { color: var(--orange); }
.bottom-btn .bicon { font-size: 20px; }

/* FAB (criar tarefa) */
.fab {
  position: fixed; bottom: 70px; right: max(18px, calc(50% - 422px)); z-index: 90;
  width: 54px; height: 54px; border-radius: 50%; border: none;
  background: var(--orange); color: white; font-size: 28px; line-height: 1;
  box-shadow: 0 4px 12px rgba(192,84,30,0.4); cursor: pointer;
}
.fab:active { transform: scale(0.95); }

/* ============================================================
   ANIMAÇÕES / INTERAÇÕES
   ============================================================ */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pop {
  0% { transform: scale(0.7); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Entrada escalonada dos itens da lista ao navegar */
.task-list > *, .plan-card, .plan-header, .plan-overall {
  animation: cardIn 0.32s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}
.task-list > *:nth-child(1) { animation-delay: 0.02s; }
.task-list > *:nth-child(2) { animation-delay: 0.05s; }
.task-list > *:nth-child(3) { animation-delay: 0.08s; }
.task-list > *:nth-child(4) { animation-delay: 0.11s; }
.task-list > *:nth-child(5) { animation-delay: 0.14s; }
.task-list > *:nth-child(6) { animation-delay: 0.17s; }
.task-list > *:nth-child(7) { animation-delay: 0.20s; }
.task-list > *:nth-child(8) { animation-delay: 0.23s; }
.task-list > *:nth-child(n+9) { animation-delay: 0.26s; }
.alert-banner { animation: cardIn 0.3s ease both; }

/* Check ao concluir "estoura" suavemente */
.check-btn.checked { animation: pop 0.28s ease; }

/* Feedback de toque/clique */
.task-card { transition: transform 0.12s ease, opacity 0.2s, box-shadow 0.15s; }
.task-card:active { transform: scale(0.985); }
.check-btn { transition: transform 0.12s ease, background 0.15s, border-color 0.15s; }
.check-btn:active { transform: scale(0.85); }
.chip, .co-tab { transition: all 0.15s ease; }
.chip:active, .co-tab:active { transform: scale(0.94); }
.bottom-btn { transition: color 0.15s, transform 0.1s; }
.bottom-btn:active { transform: scale(0.9); }
.bottom-btn .bicon { transition: transform 0.2s ease; }
.bottom-btn.active .bicon { transform: translateY(-2px); }
.nav-btn { transition: transform 0.12s ease, background 0.15s; }
.nav-btn:active { transform: scale(0.88); }
.modal-close:active { transform: scale(0.85); }

/* Respeita quem prefere menos movimento */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- LOGIN ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  background: white; border-radius: 16px; border: 1px solid var(--border);
  box-shadow: var(--card-shadow); padding: 32px 24px; width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: 14px;
}
.login-logo { font-size: 22px; font-weight: 700; color: var(--brown); text-align: center; }
.login-logo span { color: var(--orange); }
.login-sub { font-size: 13px; color: var(--grey); text-align: center; margin-top: -8px; }
.login-card input { padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 10px; font-size: 15px; }
.login-card input:focus { outline: none; border-color: var(--orange); }
.login-card button {
  padding: 12px; background: var(--orange); color: white; border: none; border-radius: 10px;
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.login-erro { background: var(--red-bg); color: var(--red); font-size: 13px; padding: 8px 12px; border-radius: 8px; text-align: center; }

/* ---------- MODAL / FORM ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(40,24,16,0.45); z-index: 200;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-overlay[hidden] { display: none; }
.modal-card {
  background: white; width: 100%; max-width: 480px;
  border-radius: 18px 18px 0 0; max-height: 92vh; overflow-y: auto;
  animation: slideUp 0.18s ease;
}
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@media (min-width: 481px) {
  .modal-overlay { align-items: center; }
  .modal-card { border-radius: 18px; max-height: 88vh; margin: 16px; }
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: white; font-size: 16px; font-weight: 600;
}
.modal-close { background: none; border: none; font-size: 18px; color: var(--grey); cursor: pointer; }
.modal-body { padding: 18px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-group input[type=text], .form-group input[type=date],
.form-group textarea, .form-group select {
  width: 100%; padding: 11px 12px; border: 1.5px solid var(--border);
  border-radius: 10px; font-size: 14px; font-family: inherit; color: var(--brown);
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { outline: none; border-color: var(--orange); }
.form-group textarea { resize: vertical; min-height: 70px; }
.radio-row { display: flex; gap: 8px; }
.radio-row label {
  flex: 1; text-align: center; padding: 9px; border: 1.5px solid var(--border);
  border-radius: 10px; font-size: 13px; cursor: pointer; font-weight: 500; color: var(--grey);
}
.radio-row input { display: none; }
.radio-row label:has(input:checked) { border-color: var(--orange); background: var(--orange-bg); color: var(--orange); }
.chips-select { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-toggle {
  font-size: 13px; padding: 7px 12px; border-radius: 18px;
  border: 1.5px solid var(--border); background: white; cursor: pointer; color: var(--grey);
}
.chip-toggle.on { border-color: var(--orange); background: var(--orange-bg); color: var(--orange); font-weight: 600; }
.btn-primary {
  width: 100%; padding: 13px; background: var(--orange); color: white; border: none;
  border-radius: 10px; font-size: 15px; font-weight: 600; cursor: pointer; margin-top: 4px;
}
.btn-primary:active { opacity: 0.85; }
.btn-danger-text { width: 100%; background: none; border: none; color: var(--red); font-size: 13px; padding: 12px; cursor: pointer; }

/* ---------- TOAST ---------- */
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: var(--brown); color: white; padding: 10px 18px; border-radius: 20px;
  font-size: 13px; z-index: 300; box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}
