:root {
  --bg: #f7fae8;
  --bg-soft: #eef6dc;
  --card: #ffffff;
  --primary: #8bc34a;
  --primary-dark: #689f38;
  --primary-light: #dcedc8;
  --accent: #cddc39;
  --accent-soft: #f0f4c3;
  --text: #2e3b1f;
  --text-secondary: #5e7045;
  --muted: #8d9e74;
  --border: #dcedc8;
  --danger: #e57373;
  --danger-bg: #ffebee;
  --shadow: rgba(139, 195, 74, 0.18);
  --radius: 16px;
  --radius-sm: 10px;
  --header-h: 64px;
  --sidebar-w: 200px;
  --max-w: 680px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}

#app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #f1f8e9 0%, #ffffff 100%);
  border-right: 1px solid var(--border);
  box-shadow: 4px 0 18px var(--shadow);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transform: translateX(-110%);
  transition: transform .28s ease;
}
.sidebar.open { transform: translateX(0); }

.brand {
  padding: 22px 16px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px dashed var(--border);
}
.avatar {
  width: 46px; height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid; place-items: center;
  font-size: 24px;
  box-shadow: 0 4px 10px var(--shadow);
}
.brand-name { font-size: 18px; font-weight: 700; color: var(--primary-dark); }
.brand-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.nav { flex: 1; overflow-y: auto; padding: 10px 10px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px;
  margin-bottom: 6px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .15s ease;
  border: 1px solid transparent;
}
.nav-item:hover { background: var(--bg-soft); color: var(--text); }
.nav-item.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  border-color: var(--primary);
  box-shadow: inset 3px 0 0 var(--primary);
  font-weight: 600;
}
.nav-icon { width: 22px; text-align: center; font-size: 18px; }
.nav-label { font-size: 14px; }
.nav-handle {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: -2px;
  opacity: 0;
  transition: opacity .15s ease;
}
.nav-item:hover .nav-handle,
.nav-item.nav-grab .nav-handle { opacity: .6; }
.nav-item.nav-grab {
  background: var(--primary-light);
  color: var(--primary-dark);
  border-color: var(--primary);
  box-shadow: 0 6px 16px var(--shadow);
  transform: scale(1.02);
  opacity: .92;
}
.sidebar-actions {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px dashed var(--border);
}
.sidebar-actions .btn-sm {
  flex: 1;
  text-align: center;
  padding: 9px 4px;
  font-size: 12px;
}

.sidebar-footer {
  padding: 14px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  border-top: 1px dashed var(--border);
}

.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.18);
  z-index: 90;
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
}
.overlay.show { opacity: 1; pointer-events: auto; }

/* Content */
.content {
  flex: 1;
  margin-left: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  position: sticky; top: 0;
  height: var(--header-h);
  background: rgba(247, 250, 232, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 14px;
  gap: 12px;
  z-index: 50;
}
.greeting { flex: 1; min-width: 0; }
.greeting h1 { margin: 0; font-size: 18px; color: var(--text); }
.greeting p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

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

.icon-btn, .btn-sm, .btn, .btn-primary, .btn-danger, .btn-ghost {
  border: none; outline: none; cursor: pointer;
  font-family: inherit;
}
.icon-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 18px;
  display: grid; place-items: center;
  box-shadow: 0 2px 6px var(--shadow);
}
.btn-sm {
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  box-shadow: 0 2px 6px var(--shadow);
}
.btn-sm:active, .icon-btn:active { transform: translateY(1px); }

main { flex: 1; padding: 14px; max-width: var(--max-w); width: 100%; margin: 0 auto; }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 14px var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}
.card-header {
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--bg-soft);
}
.card-title { margin: 0; font-size: 16px; font-weight: 700; color: var(--primary-dark); }
.card-body { padding: 14px 16px; }

/* Buttons */
.btn {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  box-shadow: 0 2px 6px var(--shadow);
}
.btn-primary {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(139,195,74,.35);
}
.btn-danger {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--danger);
  color: #fff;
  font-size: 14px;
}
.btn-ghost {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
}
.btn-primary:active { filter: brightness(1.05); }

/* Form */
.form-group { margin-bottom: 12px; }
.form-label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 5px;
  font-weight: 600;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--primary); background: #fff; }
.form-textarea { min-height: 80px; resize: vertical; }
.date-trigger { cursor: pointer; user-select: none; -webkit-user-select: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 420px) { .form-row { grid-template-columns: 1fr; } }

/* Tags / chips */
.chip {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 12px;
  margin: 0 6px 6px 0;
  cursor: pointer;
  border: 1px solid transparent;
}
.chip.active { background: var(--primary); color: #fff; }
.chip .remove { margin-left: 5px; opacity: .7; }
.chip.draggable { touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.sub-chip { touch-action: pan-y; }
.tag-chip { touch-action: none; }
.chip.dragging { opacity: .35; }
body.chips-dragging { cursor: grabbing; }
.sub-chip-wrap { display: flex; flex-wrap: wrap; align-items: center; }
.tag-add-row { display: flex; gap: 8px; margin-top: 8px; }
.tag-add-row .form-input { flex: 1; }
.link-list { display: flex; flex-direction: column; gap: 8px; }
.link-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  background: var(--primary-light); color: var(--primary-dark);
  border: 1px solid var(--primary); font-size: 14px; text-align: left;
}
.link-btn:active { transform: scale(.98); }

/* Calendar */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  text-align: center;
}
.cal-cell {
  aspect-ratio: 1;
  display: grid; place-items: center;
  border-radius: 12px;
  font-size: 13px;
  cursor: pointer;
  background: var(--bg);
  color: var(--text);
}
.cal-cell:hover { background: var(--primary-light); }
.cal-cell.today { background: var(--primary); color: #fff; font-weight: 700; }
.cal-cell.selected { box-shadow: inset 0 0 0 2px var(--primary-dark); }
.cal-cell.muted { color: var(--muted); }
.cal-cell .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); position: absolute; bottom: 3px; }
.cal-cell { position: relative; }
.cal-weekday { font-size: 12px; color: var(--muted); padding: 4px 0; }

/* Date Picker */
.date-picker { overflow: hidden; border-radius: 12px; }
.dp-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; padding: 16px 18px 14px; border-radius: 12px 12px 0 0;
}
.dp-year { font-size: 15px; opacity: .9; margin-bottom: 4px; cursor: pointer; display: inline-block; }
.dp-display { font-size: 26px; font-weight: 700; display: flex; gap: 8px; align-items: baseline; }
.dp-month-part { cursor: pointer; }
.dp-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; font-size: 15px; font-weight: 600; color: var(--text);
}
.dp-monthyear { cursor: pointer; color: var(--primary-dark); }
.dp-arrow {
  background: transparent; border: none; color: var(--primary-dark);
  font-size: 14px; width: 32px; height: 32px; border-radius: 50%;
  cursor: pointer; touch-action: manipulation;
}
.dp-arrow:active { background: var(--primary-light); }
.dp-calendar { padding: 0 12px 12px; }
.dp-weekdays, .dp-days {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
}
.dp-weekday { font-size: 12px; color: var(--muted); text-align: center; padding: 6px 0; }
.dp-cell {
  aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%;
  font-size: 14px; cursor: pointer; color: var(--text); background: transparent;
}
.dp-cell:active { background: var(--primary-light); }
.dp-cell.today { color: var(--primary-dark); font-weight: 700; }
.dp-cell.selected { background: var(--primary); color: #fff; font-weight: 700; }
.dp-cell.muted { color: var(--muted); }
.dp-wheels { padding: 12px; }
.dp-wheel-header { font-size: 14px; color: var(--muted); text-align: center; margin-bottom: 8px; }
.dp-wheel-picker .wheel-col { width: 50%; }

/* Lists */
.list-item {
  background: var(--bg-soft);
  border: 1px solid #eef4e8;
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-bottom: 8px;
  display: flex; align-items: flex-start; gap: 10px;
}
.list-item.done { opacity: .55; }
.list-thumb {
  width: 44px; height: 44px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--primary-light);
  flex-shrink: 0;
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
}
.list-thumb:active { cursor: grabbing; }
.recipe-hint { font-size: 12px; color: var(--muted); margin-top: 8px; text-align: center; }
.list-content { flex: 1; min-width: 0; }
.list-title { font-size: 13px; font-weight: 400; color: var(--text); margin-bottom: 1px; }
.list-meta { font-size: 11px; color: var(--muted); }
.list-actions { display: flex; gap: 6px; margin-top: 8px; }

/* Todos */
.todo-check {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  flex-shrink: 0;
  margin-top: 2px;
  display: grid; place-items: center;
  cursor: pointer;
}
.todo-check.done { background: var(--primary); color: #fff; }
.priority-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.priority-high { background: var(--danger); }
.priority-normal { background: var(--accent); }
.priority-low { background: var(--primary); }

/* Progress */
.progress-wrap {
  height: 10px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width .3s ease;
}

/* Empty */
.empty {
  text-align: center;
  padding: 34px 16px;
  color: var(--muted);
}
.empty-icon { font-size: 42px; margin-bottom: 8px; }

/* Modal */
.modal {
  position: fixed; inset: 0;
  z-index: 200;
  display: flex; align-items: flex-end; justify-content: center;
  pointer-events: none;
}
.modal[aria-hidden="true"] { visibility: hidden; }
#datePicker { z-index: 250; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.28);
  opacity: 0; transition: opacity .2s ease;
}
.modal-card {
  position: relative;
  background: var(--card);
  width: 100%; max-width: 560px;
  max-height: 88vh;
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -6px 24px rgba(0,0,0,.12);
  display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform .28s ease;
  pointer-events: auto;
}
.modal.show .modal-card { transform: translateY(0); }
.modal.show .modal-backdrop { opacity: 1; }
.modal-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-body { flex: 1; overflow-y: auto; padding: 14px 16px; }
.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: rgba(46,59,31,.9);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 300;
  opacity: 0;
  transition: all .3s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Stats row */
.stats-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin-bottom: 14px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
  box-shadow: 0 2px 8px var(--shadow);
}
.stat-value { font-size: 18px; font-weight: 700; color: var(--primary-dark); }
.stat-label { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* Photo grid */
.photo-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.photo-grid img, .photo-grid video {
  width: 100%; aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--bg);
}

/* 猫咪记录分类筛选 */
.cat-filter-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 7px 16px; border-radius: 18px;
  background: var(--primary); color: #fff;
  font-size: 14px; font-weight: 600; border: none; cursor: pointer;
}
.cat-filter-arrow { font-size: 11px; opacity: .85; }
.cat-wheel { width: 100%; padding: 14px 0 6px; }
.cat-wheel .wheel-col { width: 100%; height: 276px; }
.cat-wheel .wheel-frame { height: 46px; }
.cat-wheel .wheel-item { height: 46px; line-height: 46px; font-size: 18px; }
.cat-wheel .wheel-item.active { font-size: 21px; }
.cat-wheel-actions { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 2px; }
.cat-add-btn {
  padding: 8px 16px; border-radius: 18px; border: 1px dashed var(--primary);
  background: transparent; color: var(--primary); font-size: 14px; cursor: pointer;
}
.cat-wheel-hint { font-size: 11px; color: var(--muted); }

/* 多媒体预览单元 */
.media-cell { position: relative; }
.media-cell img, .media-cell video {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: var(--radius-sm); background: var(--bg); display: block;
}
.media-cell .media-x {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--danger); color: #fff; font-size: 11px;
  display: grid; place-items: center; cursor: pointer;
}

/* Recipe detail */
.recipe-hero {
  width: 100%; height: 180px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
}
.step-card {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
  display: flex; gap: 10px;
}
.step-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  display: grid; place-items: center;
  flex-shrink: 0;
}

/* Period calendar */
.period-dot { background: #ef9a9a; }
.predict-dot { background: #90caf9; }
.ovulation-dot { background: #fff176; }

/* Toggle switch */
.toggle {
  display: inline-flex; align-items: center;
  background: var(--bg);
  border-radius: 999px;
  padding: 3px;
  border: 1px solid var(--border);
}
.toggle span {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-secondary);
}
.toggle span.active { background: var(--primary); color: #fff; }

/* Desktop */
@media (min-width: 900px) {
  .sidebar { transform: translateX(0); position: relative; }
  .overlay { display: none; }
  .content { margin-left: 0; }
  #menuBtn { display: none; }
  main { max-width: 820px; }
}

@media (max-width: 899px) {
  .header-actions .btn-sm span { display: none; }
}

/* Recipe layout */
.recipe-layout { display: flex; gap: 12px; }
.recipe-mains { display: flex; flex-direction: column; gap: 8px; min-width: 72px; }
.recipe-main {
  padding: 10px 6px;
  border-radius: 12px;
  background: var(--bg-soft);
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all .15s ease;
}
.recipe-main.active { background: var(--primary); color: #fff; font-weight: 600; box-shadow: 0 3px 8px rgba(139,195,74,.3); }
.recipe-content { flex: 1; min-width: 0; }

/* Utility */
.text-right { text-align: right; }
.text-center { text-align: center; }
.flex { display: flex; }
.flex-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.mt-8 { margin-top: 8px; }
.mb-8 { margin-bottom: 8px; }
.w-full { width: 100%; }

/* Daily Plan */
.daily-header { display: flex; justify-content: space-between; align-items: center; padding: 0 2px 10px; }
.daily-title { font-size: 20px; font-weight: 700; color: var(--primary-dark); }
.calendar-wrap { display: none; margin-bottom: 12px; }
.calendar-wrap.expanded { display: block; animation: fadeIn .25s ease; }
.dot-pink { color: #e91e63; margin-right: 6px; }

.habit-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.habit-card {
  background: linear-gradient(135deg, #e8f5e9 0%, #ffffff 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  transition: all .15s ease;
  position: relative;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
  cursor: grab;
}
.habit-card:active { transform: scale(.98); }
.habit-card.done { background: linear-gradient(135deg, #c8e6c9 0%, #e8f5e9 100%); border-color: var(--primary); }
.habit-icon { font-size: 28px; margin-bottom: 6px; }
.habit-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.habit-card.done .habit-label { color: var(--primary-dark); }
.habit-check {
  position: absolute; top: 6px; right: 8px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: 11px; display: grid; place-items: center;
}

.todo-list { display: flex; flex-direction: column; gap: 8px; }
.todo-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .15s ease;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
  cursor: grab;
}
.todo-row:active { background: var(--primary-light); }
.todo-row.done { opacity: .65; }
.todo-row.done .todo-text .list-title { text-decoration: line-through; color: var(--muted); }
.todo-radio {
  width: 20px; height: 20px; min-width: 20px;
  border: 2px solid var(--primary);
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px; color: #fff;
  margin-top: 2px;
}
.todo-radio.done { background: var(--primary); }
.todo-text { flex: 1; }

.cal-dot {
  display: inline-block; width: 5px; height: 5px; border-radius: 50%;
  margin-left: 2px; vertical-align: middle;
}
.cal-dot.todo { background: var(--danger); }
.cal-dot.done { background: var(--primary); }

/* Finance */
.finance-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 2px 12px;
}
.finance-title { font-size: 20px; font-weight: 700; color: var(--primary-dark); }
.month-picker { display: flex; align-items: center; gap: 8px; }
.month-btn {
  width: 28px; height: 28px;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--card); color: var(--text-secondary);
  display: grid; place-items: center; font-size: 12px;
  cursor: pointer; touch-action: manipulation;
}
.month-label {
  font-size: 16px; font-weight: 700; color: var(--text);
  cursor: pointer; display: inline-flex; align-items: center; gap: 2px;
}

.finance-month-side {
  display: flex; flex-direction: column; gap: 2px;
  align-items: flex-end; text-align: right;
}
.finance-year-label { font-size: 12px; color: var(--muted); }
.finance-month-side .month-label { padding: 0; }

/* Wheel picker */
.wheel-picker {
  display: flex; justify-content: center; gap: 20px;
  padding: 10px 0 20px; user-select: none;
}
.wheel-col {
  position: relative; width: 110px; height: 210px;
  overflow: hidden; touch-action: none;
}
.wheel-mask {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: linear-gradient(
    to bottom,
    rgba(255,255,255,.92) 0%,
    rgba(255,255,255,.55) 34%,
    rgba(255,255,255,0) 42%,
    rgba(255,255,255,0) 58%,
    rgba(255,255,255,.55) 66%,
    rgba(255,255,255,.92) 100%
  );
}
.wheel-frame {
  position: absolute; top: 50%; left: 0; right: 0;
  height: 42px; transform: translateY(-50%);
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  z-index: 1; pointer-events: none;
}
.wheel-items {
  position: absolute; top: 0; left: 0; right: 0;
  padding-top: 84px; /* (210 - 42) / 2 */
}
.wheel-item {
  height: 42px; line-height: 42px; text-align: center;
  font-size: 18px; color: var(--text-secondary); cursor: pointer;
  transition: color .15s;
}
.wheel-item.active { color: var(--text); font-weight: 700; font-size: 20px; }

.finance-summary-bar {
  display: flex; gap: 8px; margin-bottom: 14px;
}
.summary-col {
  flex: 1; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 4px;
  text-align: center; box-shadow: 0 4px 14px var(--shadow);
}
.summary-label { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.summary-value { font-size: 14px; font-weight: 700; color: var(--text); }
.summary-value.income { color: #43a047; }
.summary-value.expense { color: var(--danger); }

.finance-list-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 4px 14px var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}
.finance-day-group { padding: 14px 16px; border-bottom: 1px solid var(--bg-soft); }
.finance-day-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.finance-day-left {
  position: relative; width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
}
.finance-day-dot {
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--primary); background: #fff;
}
.finance-day-line {
  position: absolute; left: 50%; top: 16px; bottom: -22px;
  width: 2px; background: var(--border); transform: translateX(-50%);
}
.finance-day-title { flex: 1; font-size: 14px; font-weight: 600; color: var(--text); }
.finance-day-amount { font-size: 12px; color: var(--muted); }

.finance-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0 8px 28px;
  position: relative;
  cursor: pointer;
}
.finance-item:active { background: var(--bg-soft); }
.finance-item-icon {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary-light);
  display: grid; place-items: center; font-size: 14px;
  flex-shrink: 0;
}
.finance-item-body { flex: 1; min-width: 0; }
.finance-item-title { font-size: 14px; font-weight: 400; color: var(--text); }
.finance-item-amount { font-size: 13px; font-weight: 400; white-space: nowrap; }
.finance-item-amount.income { color: #43a047; }
.finance-item-amount.expense { color: var(--danger); }
.finance-item-del {
  width: 24px; height: 24px; border-radius: 50%;
  border: none; background: var(--danger-bg); color: var(--danger);
  font-size: 12px; display: grid; place-items: center;
  margin-left: 6px; cursor: pointer; touch-action: manipulation;
}

.finance-tabs {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 8px; margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--border);
}
.finance-divider {
  height: 1px; background: var(--border); margin: 14px 0;
}
.finance-tab {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 4px;
  text-align: center; font-size: 14px; font-weight: 600;
  color: var(--text-secondary); cursor: pointer;
  user-select: none; -webkit-user-select: none; touch-action: none;
  box-shadow: 0 2px 6px var(--shadow);
}
.finance-tab:active { transform: scale(.98); }
.finance-tab.dragging { opacity: .4; }

/* Transaction modal */
.txn-amount {
  font-size: 42px; font-weight: 700; text-align: center;
  padding: 10px 0 16px; color: var(--text);
}
.txn-type-toggle {
  display: flex; justify-content: center; gap: 6px; margin-bottom: 14px;
}
.txn-type-toggle span {
  padding: 6px 18px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text-secondary); font-size: 14px; cursor: pointer;
}
.txn-type-toggle span.active { background: var(--primary); color: #fff; }

.txn-category-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  margin-bottom: 14px;
}
.txn-cat-card {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 4px; text-align: center;
  cursor: pointer; touch-action: none; user-select: none;
  transition: all .15s ease;
}
.txn-cat-card.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.txn-cat-card.add-cat { border-style: dashed; color: var(--muted); }
.txn-cat-icon { font-size: 24px; margin-bottom: 4px; }
.txn-cat-label { font-size: 12px; }
.txn-cat-card.dragging { opacity: .35; }

.txn-meta-row { display: grid; gap: 10px; margin-bottom: 14px; }
.txn-meta {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px;
}
.txn-meta span { font-size: 13px; color: var(--muted); white-space: nowrap; }
.txn-meta input { flex: 1; border: none; background: transparent; font-size: 14px; outline: none; color: var(--text); font-family: inherit; }

.txn-note-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
}
.txn-date-pill {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px; font-size: 13px; color: var(--text);
  cursor: pointer; font-family: inherit; white-space: nowrap;
}
.txn-note-bar {
  flex: 1; display: flex; align-items: center; gap: 6px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px;
}
.txn-note-bar span { font-size: 13px; color: var(--muted); white-space: nowrap; }
.txn-note-bar input {
  flex: 1; border: none; background: transparent; font-size: 14px;
  outline: none; color: var(--text); font-family: inherit;
}
.txn-note-bar input::placeholder { color: var(--muted); opacity: .7; }

.txn-numpad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.txn-numpad.four-col { grid-template-columns: repeat(4, 1fr); }
.txn-numpad button {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 0;
  font-size: 20px; font-weight: 600; color: var(--text);
  cursor: pointer; touch-action: manipulation;
  font-family: inherit;
}
.txn-numpad button:active { background: var(--primary-light); }
.txn-numpad button.op { background: var(--bg-soft); color: var(--primary-dark); }
.txn-numpad button.clear { background: #fdecea; color: #e53935; border-color: #f6c9c4; font-weight: 700; }
.txn-numpad button.clear:active { background: #f9b8b2; }
.txn-numpad .numpad-save {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; border-color: var(--primary);
  font-size: 16px;
}

/* Summary / savings */
.summary-total { text-align: center; font-size: 15px; color: var(--muted); margin-bottom: 12px; }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 2px 18px;
}
.page-back {
  background: transparent; border: none; color: var(--primary-dark);
  font-size: 15px; font-weight: 600; cursor: pointer; padding: 6px 0;
  font-family: inherit;
}
.page-title { font-size: 18px; font-weight: 700; color: var(--text); }

.savings-top-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 4px 14px var(--shadow);
  padding: 16px; margin-bottom: 14px;
}
.savings-date-bar {
  display: flex; align-items: center; justify-content: space-between;
}
.savings-date-label {
  font-size: 15px; font-weight: 600; color: var(--text);
  cursor: pointer; background: var(--bg-soft);
  padding: 6px 12px; border-radius: 10px;
}
.savings-total { font-size: 16px; font-weight: 700; color: var(--primary-dark); }

.savings-list-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 4px 14px var(--shadow);
  overflow: hidden;
}
.savings-cat-list { display: flex; flex-direction: column; }
.savings-cat-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--bg-soft);
  cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: none;
}
.savings-cat-row:last-child { border-bottom: none; }
.savings-cat-row:active { background: var(--bg-soft); }
.savings-cat-row.dragging { opacity: .4; background: var(--bg-soft); }
.savings-cat-info {
  display: flex; align-items: center; gap: 10px;
}
.savings-cat-drag {
  color: var(--muted); font-size: 16px; line-height: 1;
}
.savings-cat-label { font-size: 15px; font-weight: 600; color: var(--text); }
.savings-cat-amt {
  font-size: 16px; font-weight: 700; color: var(--text);
  min-width: 80px; text-align: right;
}
.savings-add-cat {
  width: 100%; padding: 14px;
  background: transparent; border: none; border-top: 1px dashed var(--border);
  color: var(--primary-dark); font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.savings-hint {
  text-align: center; font-size: 12px; color: var(--muted);
  padding: 14px 10px;
}

.savings-history { margin-top: 6px; }
.savings-history-title {
  font-size: 14px; font-weight: 700; color: var(--text-secondary);
  padding: 8px 4px 10px;
}
.savings-history-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 4px 14px var(--shadow);
  padding: 14px 16px; margin-bottom: 12px;
}
.savings-history-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 10px; margin-bottom: 8px;
  border-bottom: 1px solid var(--bg-soft);
}
.savings-history-date { font-size: 14px; font-weight: 600; color: var(--text); }
.savings-history-total { font-size: 15px; font-weight: 700; color: var(--primary-dark); }
.savings-history-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 6px; font-size: 14px; color: var(--text-secondary);
  border-radius: 8px; cursor: pointer; touch-action: manipulation;
}
.savings-history-item:active { background: var(--bg-soft); }
.summary-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  margin-bottom: 14px;
}
.summary-grid.three-cols { grid-template-columns: repeat(3, 1fr); }
.summary-box {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px; text-align: center;
}
.summary-box.income { color: #43a047; }
.summary-box.expense { color: var(--danger); }
.summary-box-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.summary-box-value { font-size: 16px; font-weight: 700; }
.summary-section { margin-bottom: 14px; }
.summary-section-title { font-size: 14px; font-weight: 700; color: var(--primary-dark); margin-bottom: 8px; }

.summary-range-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 0 12px;
}
.summary-range-segs { display: flex; gap: 6px; }
.summary-range-item {
  font-size: 13px; color: var(--text-secondary); text-align: center;
  padding: 5px 14px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  background: var(--bg-soft); border: 1px solid var(--border); font-family: inherit; touch-action: manipulation;
}
.summary-range-item.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; border-color: var(--primary); font-weight: 600;
}
.summary-period-trigger {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 5px 12px; font-size: 13px; color: var(--text-secondary);
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 999px;
  font-family: inherit; touch-action: manipulation; max-width: 50%;
}
.summary-period-trigger .spt-value { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.summary-period-trigger .spt-caret { font-size: 10px; color: var(--muted); flex: 0 0 auto; }
.summary-wheel .wheel-col { width: 186px; }

.rank-item { display: flex; align-items: center; padding: 9px 0; gap: 0; }
.rank-icon { font-size: 18px; width: 24px; text-align: center; flex: 0 0 auto; margin-right: 8px; }
.rank-label {
  font-size: 14px; color: var(--text); max-width: 5em; flex: 0 0 auto; margin-right: 1em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rank-bar {
  flex: 1; min-width: 36px; position: relative; height: 8px; margin-right: 8px;
  background: var(--bg-soft); border-radius: 999px;
}
.rank-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  border-radius: 999px;
}
.rank-pct {
  flex: 0 0 auto; font-size: 11px; color: var(--muted);
  white-space: nowrap;
}
.rank-amt {
  font-size: 13px; font-weight: 600; color: var(--text);
  text-align: right; flex: 0 0 auto; margin-left: 1em;
}
.summary-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border); }

.summary-year-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 2px 0 14px;
}
.summary-year-trigger {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 20px; font-weight: 700; color: var(--text);
  cursor: pointer; font-family: inherit; touch-action: manipulation;
}
.summary-year-trigger .spt-caret { font-size: 12px; color: var(--muted); }

.summary-bill-toggle {
  display: inline-flex; background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 999px; overflow: hidden;
}
.summary-bill-toggle span {
  padding: 6px 16px; font-size: 13px; color: var(--text-secondary);
  cursor: pointer; font-family: inherit; touch-action: manipulation; white-space: nowrap;
}
.summary-bill-toggle span.active {
  background: var(--text); color: #fff; font-weight: 600;
}

.year-card {
  background: linear-gradient(135deg, #dcedc8, #c5e1a5);
  border-radius: var(--radius); padding: 20px 18px; margin-bottom: 16px;
  color: var(--text); box-shadow: 0 6px 18px rgba(139, 195, 74, 0.22);
}
.year-card-label { font-size: 13px; opacity: 0.85; margin-bottom: 4px; }
.year-card-balance {
  font-size: 18px; font-weight: 700; line-height: 1.3; margin-bottom: 12px;
}
.year-card-balance.income { color: #1b5e20; }
.year-card-balance.expense { color: #b71c1c; }
.year-card-sub {
  display: flex; gap: 16px; font-size: 13px; opacity: 0.92;
}

.month-table-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 4px 14px var(--shadow);
  overflow: hidden;
}
.month-table-head, .month-table-row,
.year-table-row {
  display: grid; grid-template-columns: 1fr 1.3fr 1.3fr 1.3fr;
  align-items: center; padding: 12px 14px; gap: 6px;
}
.month-table-head {
  font-size: 12px; color: var(--muted); background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
}
.month-table-row,
.year-table-row {
  font-size: 14px; color: var(--text); border-bottom: 1px solid var(--bg-soft);
  cursor: pointer; touch-action: manipulation;
}
.month-table-row:last-child,
.year-table-row:last-child { border-bottom: none; }
.month-table-row:active,
.year-table-row:active { background: var(--bg-soft); }
.month-table-row span:first-child,
.year-table-row span:first-child { color: var(--text); }
.month-table-row .income,
.year-table-row .income { color: #43a047; }
.month-table-row .expense,
.year-table-row .expense { color: var(--danger); }

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