:root {
  --primary: #2d6a4f;
  --primary-light: #40916c;
  --primary-dark: #1b4332;
  --accent: #d4a373;
  --accent-light: #e9c89b;
  --danger: #e63946;
  --danger-light: #fce4e6;
  --warning: #f4a261;
  --warning-light: #fef0db;
  --success: #2d6a4f;
  --success-light: #d8f3dc;
  --bg: #fefae0;
  --bg-card: #ffffff;
  --bg-section: #f4f1de;
  --text: #2b2d42;
  --text-secondary: #6c757d;
  --text-muted: #adb5bd;
  --border: #dee2e6;
  --border-light: #e9ecef;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
}

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

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

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 60px;
}

.header {
  text-align: center;
  padding: 24px 0 16px;
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
}

.header-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary-dark);
  letter-spacing: -0.5px;
}

.header-sub {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-name {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.logout-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.logout-btn:hover {
  background: var(--danger-light);
  color: var(--danger);
  border-color: var(--danger);
}

.login-btn {
  padding: 12px 32px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.login-btn:hover {
  background: var(--primary-light);
}

.loading {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  font-size: 15px;
}

/* Stats Bar */
.stats-bar {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--shadow);
  border-left: 4px solid transparent;
}

.stat-remaining {
  border-left-color: var(--primary);
}

.stat-high {
  border-left-color: var(--danger);
}

.stat-completed {
  border-left-color: var(--success);
}

.stat-number {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
}

.stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* Add Task Form */
.add-task-form {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.form-row {
  margin-bottom: 10px;
}

.form-row:last-child {
  margin-bottom: 0;
}

.task-input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 15px;
  transition: border-color 0.2s;
  outline: none;
  background: var(--bg);
}

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

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

.select-area,
.select-priority {
  flex: 1;
  min-width: 100px;
  padding: 10px 12px;
  border: 2px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  cursor: pointer;
}

.select-area:focus,
.select-priority:focus {
  border-color: var(--primary);
}

.add-btn {
  padding: 10px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.add-btn:hover:not(:disabled) {
  background: var(--primary-light);
}

.add-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Filter Bar */
.filter-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
  -webkit-overflow-scrolling: touch;
}

.filter-btn {
  padding: 8px 14px;
  border: 2px solid var(--border-light);
  border-radius: 20px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.filter-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.filter-active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.filter-active:hover {
  color: white;
}

/* Task List */
.task-list {
  margin-bottom: 16px;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-text {
  font-size: 15px;
}

.task-section {
  margin-bottom: 20px;
}

.section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary-dark);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  padding-left: 4px;
}

.section-title-done {
  color: var(--text-muted);
}

/* Task Item */
.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary-light);
  transition: all 0.2s;
}

.task-item:hover {
  box-shadow: var(--shadow-lg);
}

.task-item.task-done {
  opacity: 0.6;
  border-left-color: var(--text-muted);
}

.task-item.priority-high {
  border-left-color: var(--danger);
}

.task-item.priority-low {
  border-left-color: var(--accent);
}

.task-item.task-done.priority-high,
.task-item.task-done.priority-low {
  border-left-color: var(--text-muted);
}

.check-btn {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: white;
  transition: all 0.2s;
}

.check-btn:hover {
  border-color: var(--primary);
  background: var(--success-light);
}

.check-done {
  background: var(--primary);
  border-color: var(--primary);
}

.check-done:hover {
  background: var(--primary-light);
  border-color: var(--primary-light);
}

.task-details {
  flex: 1;
  min-width: 0;
}

.task-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.task-meta {
  display: flex;
  gap: 10px;
  margin-top: 4px;
  font-size: 12px;
}

.task-area {
  color: var(--text-secondary);
  text-transform: capitalize;
}

.task-priority {
  font-weight: 600;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 10px;
}

.priority-badge-high {
  background: var(--danger-light);
  color: var(--danger);
}

.priority-badge-medium {
  background: var(--warning-light);
  color: var(--warning);
}

.priority-badge-low {
  background: var(--success-light);
  color: var(--success);
}

.task-time {
  color: var(--text-muted);
}

.delete-btn {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.2s;
}

.delete-btn:hover {
  background: var(--danger-light);
  color: var(--danger);
}

/* Sync Bar */
.sync-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  font-size: 12px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-light);
}

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

.sync-connected .sync-dot {
  background: var(--success);
}

.sync-disconnected .sync-dot {
  background: var(--warning);
  animation: pulse 1.5s infinite;
}

.sync-connected .sync-text {
  color: var(--success);
}

.sync-disconnected .sync-text {
  color: var(--warning);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@media (max-width: 480px) {
  .app {
    padding: 10px;
    padding-bottom: 56px;
  }

  .header-title {
    font-size: 22px;
  }

  .stats-bar {
    gap: 6px;
  }

  .stat-card {
    padding: 10px 6px;
  }

  .stat-number {
    font-size: 22px;
  }

  .form-options {
    flex-direction: column;
  }

  .select-area,
  .select-priority {
    min-width: auto;
  }

  .filter-bar {
    gap: 4px;
  }

  .filter-btn {
    padding: 6px 10px;
    font-size: 12px;
  }
}