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

:root {
  --purple: #6c63ff;
  --purple-dark: #574fd6;
  --purple-light: #ede9ff;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #f59e0b;
  --bg: #f0eeff;
  --card-bg: #ffffff;
  --text: #1e1b4b;
  --muted: #6b7280;
  --radius: 18px;
  --shadow: 0 4px 24px rgba(108,99,255,0.10);
}

html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); }

#app { height: 100%; display: flex; flex-direction: column; }

/* Screens */
.screen { flex: 1; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* Login */
.login-box {
  margin: auto;
  width: 100%;
  max-width: 360px;
  padding: 40px 28px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}
.login-box .logo { font-size: 52px; margin-bottom: 8px; }
.login-box h1 { font-size: 28px; font-weight: 800; color: var(--purple); }
.tagline { color: var(--muted); margin: 6px 0 24px; font-size: 15px; }
.login-box input {
  width: 100%; padding: 14px 16px; margin-bottom: 12px;
  border: 2px solid #e5e7eb; border-radius: 12px;
  font-size: 16px; outline: none; transition: border 0.2s;
}
.login-box input:focus { border-color: var(--purple); }
.error { color: var(--red); font-size: 14px; margin-top: 8px; }

/* Buttons */
.btn-primary {
  width: 100%; padding: 14px; background: var(--purple);
  color: white; border: none; border-radius: 12px;
  font-size: 16px; font-weight: 700; cursor: pointer; transition: background 0.2s;
}
.btn-primary:hover { background: var(--purple-dark); }
.btn-secondary {
  padding: 12px 20px; background: #f3f4f6;
  color: var(--text); border: none; border-radius: 12px;
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-secondary:hover { background: #e5e7eb; }

/* Header */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; background: var(--card-bg);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.header-left { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; }
.logo-sm { font-size: 24px; }
.header-right { display: flex; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  border: none; background: var(--purple-light);
  color: var(--purple); font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.icon-btn:hover { background: #d4cfff; }

/* Main task area */
main {
  flex: 1; overflow-y: auto;
  padding: 24px 16px 16px;
  display: flex; flex-direction: column; gap: 16px;
  max-width: 520px; width: 100%; margin: 0 auto;
}

.center-msg { text-align: center; margin: auto; }
.all-done-emoji { font-size: 64px; margin-bottom: 12px; }
.all-done-emoji + h2 { font-size: 26px; font-weight: 800; color: var(--purple); }
.all-done-emoji + h2 + p { color: var(--muted); margin-top: 6px; }

/* Task card */
.task-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
  animation: slideIn 0.25s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

.task-title { font-size: 20px; font-weight: 700; line-height: 1.3; }
.task-meta { font-size: 13px; color: var(--muted); }
.task-actions { display: flex; gap: 10px; }

.btn-done {
  flex: 1; padding: 16px;
  background: var(--green); color: white;
  border: none; border-radius: 14px;
  font-size: 18px; font-weight: 800; cursor: pointer;
  transition: transform 0.1s, background 0.2s;
  box-shadow: 0 4px 12px rgba(34,197,94,0.3);
}
.btn-done:active { transform: scale(0.96); }
.btn-done:hover { background: #16a34a; }

.btn-skip {
  padding: 16px 18px;
  background: #f3f4f6; color: var(--muted);
  border: none; border-radius: 14px;
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-skip:hover { background: #e5e7eb; }

.btn-delete {
  padding: 16px 14px;
  background: #fff0f0; color: var(--red);
  border: none; border-radius: 14px;
  font-size: 16px; cursor: pointer;
}
.btn-delete:hover { background: #fee2e2; }

/* More tasks indicator */
.more-tasks {
  text-align: center; color: var(--muted);
  font-size: 14px; padding: 8px;
}

/* Progress bar */
#progress-bar-wrap {
  padding: 12px 20px 20px;
  display: flex; align-items: center; gap: 12px;
  max-width: 520px; width: 100%; margin: 0 auto;
}
#progress-bar {
  flex: 1; height: 10px; background: #e5e7eb;
  border-radius: 99px; overflow: hidden;
}
#progress-bar::after {
  content: ''; display: block; height: 100%;
  background: var(--purple); border-radius: 99px;
  width: var(--progress, 0%); transition: width 0.4s ease;
}
#progress-label { font-size: 13px; color: var(--muted); white-space: nowrap; }

/* Modal */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100; padding: 0;
}
.modal-box {
  background: var(--card-bg);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 28px 24px 32px;
  width: 100%; max-width: 520px;
  animation: slideUp 0.25s ease;
}
.modal-box-tall { max-height: 80vh; overflow-y: auto; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-box h2 { font-size: 20px; font-weight: 800; margin-bottom: 18px; }
.modal-box input[type="text"], .modal-box input[type="date"] {
  width: 100%; padding: 14px 16px; margin-bottom: 14px;
  border: 2px solid #e5e7eb; border-radius: 12px;
  font-size: 16px; outline: none; transition: border 0.2s;
}
.modal-box input:focus { border-color: var(--purple); }
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; font-size: 16px; font-weight: 600; cursor: pointer;
}
.toggle-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--purple); cursor: pointer; }
.label-sm { font-size: 13px; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.day-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.day-picker label {
  display: flex; align-items: center; gap: 5px;
  background: var(--purple-light); padding: 6px 12px;
  border-radius: 99px; font-size: 14px; font-weight: 600;
  cursor: pointer; color: var(--purple);
}
.day-picker input { accent-color: var(--purple); }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn-primary { flex: 1; width: auto; }

/* All tasks list */
.task-list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid #f3f4f6;
  gap: 10px;
}
.task-list-item:last-child { border-bottom: none; }
.task-list-title { font-size: 15px; font-weight: 600; flex: 1; }
.task-list-title.done { text-decoration: line-through; color: var(--muted); }
.task-list-meta { font-size: 12px; color: var(--muted); }
.badge {
  font-size: 11px; font-weight: 700; padding: 3px 8px;
  border-radius: 99px; white-space: nowrap;
}
.badge-done { background: #dcfce7; color: #16a34a; }
.badge-pending { background: var(--purple-light); color: var(--purple); }
.badge-skipped { background: #f3f4f6; color: var(--muted); }
.badge-recurring { background: #fef3c7; color: #92400e; }

/* Celebration */
#celebration {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.celebration-backdrop {
  position: absolute; inset: 0;
  background: rgba(108,99,255,0.55);
  backdrop-filter: blur(4px);
  animation: fadeInOut 1.4s ease forwards;
}
@keyframes fadeInOut {
  0% { opacity: 0; } 20% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; }
}
.celebration-msg {
  position: relative; z-index: 1;
  text-align: center; animation: popIn 0.3s cubic-bezier(0.34,1.56,0.64,1);
  background: white; border-radius: 24px; padding: 32px 40px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
}
@keyframes popIn { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#celebration-emoji { font-size: 80px; }
#celebration-text { font-size: 22px; font-weight: 800; color: var(--purple); margin-top: 8px; }
.confetti-wrap { position: absolute; inset: 0; overflow: hidden; z-index: 0; }
.confetti {
  position: absolute; width: 10px; height: 10px;
  border-radius: 2px; animation: fall linear forwards;
}
@keyframes fall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* Task notes */
.task-notes { font-size: 14px; color: var(--muted); line-height: 1.5; background: #f9f8ff; border-radius: 10px; padding: 10px 12px; }

/* Assigned-by badge */
.task-assigned-by { font-size: 12px; color: var(--purple); font-weight: 600; }

/* Due time */
.task-due-time { font-size: 13px; font-weight: 700; color: var(--yellow); }
.task-due-time.overdue { color: var(--red); }

/* Interval badge */
.badge-interval { background: #e0f2fe; color: #0369a1; }

/* Add form extras */
textarea {
  width: 100%; padding: 12px 16px; margin-bottom: 14px;
  border: 2px solid #e5e7eb; border-radius: 12px;
  font-size: 15px; font-family: inherit; resize: vertical; outline: none;
  transition: border 0.2s;
}
textarea:focus { border-color: var(--purple); }
select {
  width: 100%; padding: 12px 16px; margin-bottom: 14px;
  border: 2px solid #e5e7eb; border-radius: 12px;
  font-size: 15px; background: white; outline: none;
  transition: border 0.2s; cursor: pointer;
}
select:focus { border-color: var(--purple); }
input[type="number"] {
  width: 100%; padding: 12px 16px; margin-bottom: 14px;
  border: 2px solid #e5e7eb; border-radius: 12px;
  font-size: 15px; outline: none; transition: border 0.2s;
}
input[type="number"]:focus { border-color: var(--purple); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 0; }
.row-2 input { margin-bottom: 14px; }

/* Report */
#report-filters { display: flex; gap: 10px; margin-bottom: 16px; }
#report-filters select { margin-bottom: 0; flex: 1; }
.report-section { margin-bottom: 20px; }
.report-section h3 { font-size: 15px; font-weight: 800; color: var(--purple); margin-bottom: 10px; border-bottom: 2px solid var(--purple-light); padding-bottom: 6px; }
.report-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid #f3f4f6; gap: 10px;
}
.report-row:last-child { border-bottom: none; }
.report-row-left { flex: 1; }
.report-title { font-size: 14px; font-weight: 600; }
.report-title.done { text-decoration: line-through; color: var(--muted); }
.report-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.report-stats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.stat-card { background: var(--purple-light); border-radius: 12px; padding: 12px 16px; flex: 1; min-width: 80px; text-align: center; }
.stat-card .stat-num { font-size: 24px; font-weight: 800; color: var(--purple); }
.stat-card .stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
