:root {
  --primary: #E11D48;
  --primary-hover: #BE123C;
  --secondary: #9333EA;
  --bg-main: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-input: #F1F5F9;
  --text-main: #0F172A;
  --text-muted: #64748B;
  --border: #E2E8F0;
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 8px 20px rgba(0, 0, 0, 0.1);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-main: #0B1120;
    --bg-card: #1E293B;
    --bg-input: #334155;
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --border: #334155;
    --shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 8px 20px rgba(0, 0, 0, 0.5);
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  user-select: none;
  overflow-x: hidden;
  min-height: 100vh;
}

#app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 500px;
  margin: 0 auto;
  position: relative;
  background-color: var(--bg-main);
}

.mobile-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: #FFFFFF;
  padding: env(safe-area-inset-top, 12px) 16px 12px 16px;
  box-shadow: 0 2px 12px rgba(225, 29, 72, 0.25);
}

.header-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-avatar {
  font-size: 26px;
  background: rgba(255, 255, 255, 0.2);
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.header-info {
  flex: 1;
}

.header-info h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  opacity: 0.9;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.online { background-color: #4ADE80; box-shadow: 0 0 6px #4ADE80; }
.status-dot.syncing { background-color: #FACC15; box-shadow: 0 0 6px #FACC15; }
.status-dot.offline { background-color: #F87171; }

.header-actions {
  display: flex;
  gap: 6px;
}

.btn-header-icon {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #FFFFFF;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-header-icon:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.35);
}

.profile-switch-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  background: rgba(0, 0, 0, 0.15);
  padding: 4px 10px;
  border-radius: 20px;
}

.profile-switch-label {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.9;
}

.profile-pill-group {
  display: flex;
  gap: 4px;
}

.profile-pill {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #FFFFFF;
  padding: 3px 10px;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.profile-pill.active {
  background: #FFFFFF;
  color: var(--primary);
  border-color: #FFFFFF;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.pin-lock-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
  flex: 1;
}

.pin-lock-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 18px;
  text-align: center;
  box-shadow: var(--shadow);
  width: 100%;
}

.pin-lock-icon {
  font-size: 44px;
  margin-bottom: 12px;
}

.pin-lock-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.pin-lock-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.pin-inputs-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}

.pin-box {
  width: 42px;
  height: 52px;
  font-size: 24px;
  text-align: center;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--bg-input);
  color: var(--text-main);
  outline: none;
  transition: all 0.2s;
}

.pin-box:focus {
  border-color: var(--primary);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.2);
}

.pin-box.filled {
  border-color: var(--primary);
}

.pin-error-msg {
  color: #EF4444;
  font-size: 12px;
  font-weight: 600;
  min-height: 18px;
  margin-bottom: 14px;
}

.btn-unlock {
  width: 100%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: #FFFFFF;
  border: none;
  padding: 13px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(225, 29, 72, 0.3);
}

.btn-unlock:active {
  transform: scale(0.98);
}

.shake-anim {
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.main-content {
  flex: 1;
  padding: 14px 14px 90px 14px;
}

.tab-view {
  display: none;
}

.tab-view.active {
  display: block;
}

.search-bar-wrap {
  position: relative;
  margin-bottom: 12px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--text-muted);
}

.search-input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 13px;
  outline: none;
}

.search-input:focus {
  border-color: var(--primary);
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.task-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  transition: all 0.2s;
}

.task-card.status-pendente { border-left: 4px solid #F59E0B; }
.task-card.status-aguardando_aprovacao { border-left: 4px solid #3B82F6; }
.task-card.status-concluida { border-left: 4px solid #10B981; opacity: 0.85; }

.task-card.status-concluida .task-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.task-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.task-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}

.task-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 2px 0;
}

.badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 12px;
}

.badge-prio-alta { background: #FEE2E2; color: #991B1B; }
.badge-prio-media { background: #FEF3C7; color: #92400E; }
.badge-prio-baixa { background: #ECFDF5; color: #065F46; }

.badge-assignee { background: rgba(147, 51, 234, 0.12); color: var(--secondary); }
.badge-due { background: var(--bg-input); color: var(--text-muted); }
.badge-due.overdue { background: #FEE2E2; color: #DC2626; font-weight: 800; }

.task-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
  white-space: pre-wrap;
}

.task-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.btn-card {
  border: none;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-card:active { transform: scale(0.95); }
.btn-advance { background: #3B82F6; color: #FFFFFF; }
.btn-approve { background: #10B981; color: #FFFFFF; }
.btn-reopen { background: var(--bg-input); color: var(--text-muted); }
.btn-delete { background: transparent; color: #EF4444; font-size: 13px; }

.task-comments-section {
  background: var(--bg-input);
  border-radius: 8px;
  padding: 8px;
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.comment-bubble {
  font-size: 12px;
  line-height: 1.3;
}

.comment-author {
  font-weight: 700;
  color: var(--primary);
  margin-right: 4px;
}

.comment-input-wrap {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.comment-input {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 12px;
  outline: none;
}

.btn-send-comment {
  background: var(--primary);
  color: #FFFFFF;
  border: none;
  border-radius: 6px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.completed-box {
  margin-top: 14px;
  border-top: 1px dashed var(--border);
  padding-top: 12px;
}

.btn-toggle-completed {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  color: #059669;
  cursor: pointer;
}

.btn-toggle-completed.open .toggle-arrow {
  transform: rotate(180deg);
}

.toggle-arrow {
  font-size: 10px;
  transition: transform 0.2s;
}

.completed-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.shopping-add-box {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.shopping-input {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 14px;
  outline: none;
}

.btn-add-shopping {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: #FFFFFF;
  border: none;
  padding: 0 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.shopping-summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding: 0 4px;
}

.btn-clear-shopping {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  text-decoration: underline;
  cursor: pointer;
}

.shopping-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shopping-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.shopping-checkbox {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  cursor: pointer;
}

.shopping-title {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.shopping-item.done .shopping-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.btn-del-shopping {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 4px;
}

.new-task-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
}

.form-input, .form-textarea, .form-select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 14px;
  outline: none;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--primary);
  background: var(--bg-card);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.priority-options {
  display: flex;
  gap: 8px;
}

.priority-options input[type="radio"] {
  display: none;
}

.prio-label {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  background: var(--bg-input);
  color: var(--text-muted);
}

.priority-options input[type="radio"]:checked + .prio-label {
  border-color: var(--primary);
  background: var(--bg-card);
  color: var(--text-main);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.btn-submit-task {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: #FFFFFF;
  border: none;
  padding: 14px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
  box-shadow: 0 4px 14px rgba(225, 29, 72, 0.3);
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 500px;
  margin: 0 auto;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px)) 12px;
  z-index: 50;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.nav-btn {
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  padding: 4px 12px;
  border-radius: 8px;
}

.nav-btn.active {
  color: var(--primary);
}

.nav-icon {
  font-size: 20px;
}

.nav-label {
  font-size: 11px;
  font-weight: 700;
}

.nav-badge {
  position: absolute;
  top: 0;
  right: 6px;
  background: var(--primary);
  color: #FFFFFF;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(3px);
}

.modal-overlay.open {
  display: flex;
}

.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn-action {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  border: none;
  cursor: pointer;
}

.btn-cancel { background: var(--bg-input); color: var(--text-muted); }
.btn-confirm { background: var(--primary); color: #FFFFFF; }

.empty-state {
  text-align: center;
  padding: 30px 10px;
  color: var(--text-muted);
}
.empty-icon { font-size: 32px; margin-bottom: 6px; }
.empty-text { font-size: 13px; font-weight: 600; }
