:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #f9fbff;
  --text: #122033;
  --muted: #6a7688;
  --line: #dbe4f0;
  --primary: #2563eb;
  --primary-soft: #dbeafe;
  --success: #0f9f6e;
  --success-soft: #dcfce7;
  --warning: #d97706;
  --warning-soft: #fff0d4;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --shadow: 0 14px 34px rgba(18, 32, 51, 0.08);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: linear-gradient(180deg, #edf3ff 0%, var(--bg) 20%, var(--bg) 100%);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  max-width: 860px;
  margin: 0 auto;
  padding: 20px 16px 110px;
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.app-header h1,
.panel h2,
.panel h3,
.history-date,
.task-text {
  margin: 0;
}

.eyebrow,
.panel-label,
.helper-text,
.task-index,
.checkout-label {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.page {
  display: grid;
  gap: 14px;
}

.stats-bar {
  position: sticky;
  top: 12px;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.stat-card,
.panel,
.history-card,
.task-card {
  background: var(--panel);
  border: 1px solid rgba(219, 228, 240, 0.95);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 14px 12px;
}

.stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
}

.stat-card.success {
  background: linear-gradient(180deg, #ffffff 0%, var(--success-soft) 165%);
}

.stat-card.pending {
  background: linear-gradient(180deg, #ffffff 0%, #eef5ff 165%);
}

.stat-card.issue {
  background: linear-gradient(180deg, #ffffff 0%, var(--warning-soft) 165%);
}

.panel {
  padding: 18px;
}

.top-panel {
  position: sticky;
  top: 108px;
  z-index: 4;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
}

.panel-row,
.section-title-wrap,
.history-head,
.task-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.date-input,
.raw-input,
.note-input,
.task-note-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-soft);
  color: var(--text);
}

.date-input {
  max-width: 180px;
  min-height: 48px;
  padding: 0 14px;
}

.raw-input,
.note-input,
.task-note-input {
  padding: 14px 16px;
  resize: vertical;
}

.raw-input {
  min-height: 180px;
  margin-top: 14px;
}

.helper-text {
  margin-top: 10px;
}

.view-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.primary-btn,
.ghost-btn,
.tab-btn,
.status-btn {
  min-height: 48px;
  border: 0;
  border-radius: var(--radius-md);
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.primary-btn {
  padding: 0 18px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
}

.ghost-btn,
.tab-btn {
  padding: 0 16px;
  background: #eef4ff;
  color: var(--text);
  font-weight: 700;
}

.ghost-btn.danger {
  background: #fff1f1;
  color: var(--danger);
}

.tab-btn.active {
  background: var(--text);
  color: #ffffff;
}

.primary-btn:active,
.ghost-btn:active,
.tab-btn:active,
.status-btn:active {
  transform: scale(0.98);
}

.view-section.hidden {
  display: none;
}

.task-list,
.history-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.empty-state {
  min-height: 120px;
  place-items: center;
  display: grid;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  color: var(--muted);
  background: var(--panel-soft);
}

.task-card {
  padding: 16px;
}

.task-card[data-status="done"] {
  border-color: #b6e7d4;
  background: linear-gradient(180deg, #ffffff 0%, #f3fff8 160%);
}

.task-card[data-status="issue"] {
  border-color: #f2c98a;
  background: linear-gradient(180deg, #ffffff 0%, #fff8ee 160%);
}

.status-badge {
  padding: 6px 10px;
  border-radius: 999px;
  background: #e9effa;
  color: #37507a;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.task-card[data-status="done"] .status-badge {
  background: var(--success-soft);
  color: var(--success);
}

.task-card[data-status="issue"] .status-badge {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.status-btn {
  background: #edf2fb;
  color: #355074;
  font-weight: 700;
}

.status-btn.active[data-status="pending"] {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-btn.active[data-status="done"] {
  background: var(--success-soft);
  color: var(--success);
}

.status-btn.active[data-status="issue"] {
  background: var(--warning-soft);
  color: var(--warning);
}

.task-note-wrap {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
}

.history-card {
  padding: 16px;
  cursor: pointer;
}

.history-stats {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.history-note {
  margin: 12px 0;
  color: var(--text);
  line-height: 1.6;
}

.history-task-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.history-task-item {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.history-task-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.history-task-note {
  color: var(--muted);
  font-size: 13px;
}

.checkout-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(219, 228, 240, 0.95);
}

.checkout-bar strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
}

@media (max-width: 700px) {
  .app-shell {
    padding: 16px 12px 110px;
  }

  .stats-bar {
    top: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .top-panel {
    top: 138px;
  }

  .panel-row,
  .section-title-wrap,
  .task-card-head,
  .history-head,
  .app-header {
    flex-direction: column;
  }

  .date-input,
  .primary-btn,
  .ghost-btn {
    width: 100%;
    max-width: none;
  }
}
