/* ==========================================================================
   极简待办 · 优雅紧凑版
   ========================================================================== */

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

:root {
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #1a1a2e;
  --text2: #6b7280;
  --text3: #9ca3af;
  --primary: #10b981;
  --primary-light: #d1fae5;
  --primary-dark: #059669;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --border: #e5e7eb;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-hover: 0 4px 12px rgba(0,0,0,0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  font-size: 15px;
}

.page { display: none; }
.page.active { display: block; }

/* ====== 登录 ====== */
.login-container {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #d1fae5 0%, #e0e7ff 50%, #fce7f3 100%);
  padding: 20px;
}
.login-card {
  background: var(--card);
  border-radius: 20px;
  padding: 44px 36px 36px;
  width: 100%; max-width: 380px;
  box-shadow: 0 25px 80px rgba(0,0,0,0.1);
  text-align: center;
}
.login-logo { font-size: 44px; margin-bottom: 6px; }
.login-title { font-size: 26px; font-weight: 700; letter-spacing: 2px; }
.login-subtitle {
  font-size: 12px; color: var(--text3);
  letter-spacing: 4px; margin-bottom: 32px;
}
.login-card .form-group { text-align: left; margin-bottom: 18px; }
.login-card label {
  display: block; font-size: 13px; color: var(--text2);
  margin-bottom: 6px; font-weight: 500;
}
.login-card input {
  width: 100%; padding: 11px 16px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 15px; transition: .2s; background: var(--bg);
}
.login-card input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.15);
}
.form-error { color: var(--danger); font-size: 13px; min-height: 20px; margin-bottom: 8px; }

/* ====== 按钮 ====== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  padding: 9px 18px; border: none; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; cursor: pointer; transition: all .2s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 2px 8px rgba(16,185,129,0.3); }
.btn-full { width: 100%; padding: 13px; font-size: 16px; letter-spacing: 2px; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-ghost {
  background: transparent; color: var(--text2);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

/* ====== 主应用容器 ====== */
.app-container {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
}

/* ====== 头部 ====== */
.app-header {
  background: var(--card);
  padding: 16px 20px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.app-title { font-size: 20px; font-weight: 700; color: var(--text); }

/* ====== 统计栏 ====== */
.stats-bar {
  display: flex;
  background: var(--card);
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.stat-item {
  flex: 1;
  text-align: center;
  padding: 10px 0;
  border-radius: var(--radius-sm);
  background: var(--bg);
  transition: .2s;
}
.stat-item:hover { background: #e8f5e9; }
.stat-num {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.3;
}
.stat-label {
  font-size: 12px;
  color: var(--text2);
  font-weight: 500;
}

/* ====== 标签栏 ====== */
.tab-bar {
  display: flex;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
}
.tab {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 0;
  border: none; background: transparent;
  font-size: 15px; font-weight: 500; color: var(--text2); cursor: pointer;
  transition: .2s; position: relative;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); }
.tab.active::after {
  content: ''; position: absolute; bottom: 0;
  left: 20%; right: 20%; height: 2.5px;
  background: var(--primary); border-radius: 2.5px;
}
.tab-badge {
  background: var(--border); color: var(--text2);
  font-size: 11px; padding: 1px 8px; border-radius: 10px;
  font-weight: 600;
}
.tab.active .tab-badge {
  background: var(--primary-light); color: var(--primary);
}

/* ====== 面板 ====== */
.tab-panel { display: none; padding: 16px 20px; max-width: 520px; margin: 0 auto; }
.tab-panel.active { display: block; }

/* ====== 输入框 ====== */
.todo-input-bar {
  display: flex; gap: 8px; margin-bottom: 14px;
}
.todo-input-bar input {
  flex: 1; padding: 11px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 15px; transition: .2s; background: var(--card);
}
.todo-input-bar input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.12);
}
.todo-input-bar input::placeholder { color: var(--text3); }
.btn-add {
  padding: 11px 18px;
  font-size: 18px;
  font-weight: 600;
  min-width: 48px;
  border-radius: var(--radius-sm);
}

/* ====== 待办列表 ====== */
.todo-list { min-height: 100px; }

.todo-item {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 14px;
  margin-bottom: 8px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: all .2s;
  animation: fadeIn .25s ease;
  border: 1px solid transparent;
}
.todo-item:hover {
  box-shadow: var(--shadow-hover);
  border-color: var(--border);
  transform: translateY(-1px);
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* 序号 */
.todo-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text3);
  flex-shrink: 0;
  line-height: 1;
}

/* 勾选框 */
.todo-check {
  width: 22px; height: 22px; flex-shrink: 0;
  border: 2px solid #d1d5db;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s;
  color: transparent;
}
.todo-check:hover { border-color: var(--primary); background: #f0fdf4; }
.todo-check.checked {
  background: var(--primary); border-color: var(--primary);
  color: #fff;
}
.todo-check.checked svg { stroke: #fff; }

.todo-content { flex: 1; min-width: 0; }
.todo-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
  word-break: break-word;
}
.todo-title.done {
  text-decoration: line-through;
  color: var(--text3);
}

.todo-actions { display: flex; gap: 2px; flex-shrink: 0; opacity: 0; transition: opacity .2s; }
.todo-item:hover .todo-actions { opacity: 1; }

.btn-action {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 16px;
  color: var(--text3);
  transition: all .15s;
}
.btn-action:hover {
  background: var(--bg);
  color: var(--text2);
}
.btn-del:hover {
  background: var(--danger-bg) !important;
  color: var(--danger) !important;
}

/* 历史项 */
.todo-item.history-item { opacity: 0.7; }
.todo-item.history-item:hover { opacity: 1; }

.history-item .todo-num {
  background: var(--primary-light);
  color: var(--primary);
}

/* ====== 空状态 ====== */
.empty-state { text-align: center; padding: 50px 20px; color: var(--text3); }
.empty-icon { font-size: 40px; margin-bottom: 10px; }
.empty-state p { font-size: 15px; }

/* ====== 弹窗 ====== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: overlayIn .2s ease;
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--card); border-radius: 16px;
  padding: 28px; width: 100%; max-width: 400px;
  box-shadow: 0 25px 80px rgba(0,0,0,0.2);
  animation: modalIn .25s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.modal-header h3 { font-size: 17px; font-weight: 600; }
.modal-close {
  width: 30px; height: 30px;
  border: none; background: transparent;
  font-size: 22px; cursor: pointer;
  border-radius: 50%; display: flex;
  align-items: center; justify-content: center;
  color: var(--text3); transition: .2s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-input {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 15px; transition: .2s;
}
.modal-input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.12);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.form-group { margin-bottom: 18px; }

/* ====== 分页 ====== */
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 20px 0 10px;
}
.page-btn {
  padding: 8px 16px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card); color: var(--text2);
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: all .2s;
}
.page-btn:hover:not(:disabled) {
  border-color: var(--primary); color: var(--primary);
  background: var(--primary-light);
}
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.page-info {
  font-size: 13px; color: var(--text3);
  white-space: nowrap;
}

/* ====== 滚动条 ====== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }

/* ====== 响应式 ====== */
@media (max-width: 480px) {
  .tab-panel { padding: 12px 14px; }
  .stats-bar { padding: 10px 14px; }
  .app-header { padding: 12px 14px; }
  .todo-item { padding: 11px 12px; }
  .modal { padding: 20px; }
}
