:root {
  --mint-50: #F6FBF8;
  --mint-100: #EDF7F1;
  --mint-200: #DDEEE4;
  --mint-300: #C8E2D2;
  --mint-500: #4D9A72;
  --green: #17613F;
  --green-deep: #0F4930;
  --green-soft: #E3F2E8;
  --surface: #FFFFFF;
  --surface-soft: #F9FCFA;
  --text: #173025;
  --muted: #6A7C73;
  --line: #D4E4DA;
  --coral: #E36550;
  --coral-soft: #FFF0EC;
  --yellow: #E7AE2D;
  --yellow-soft: #FFF7DD;
  --blue: #527C8A;
  --blue-soft: #EDF5F7;
  --shadow: 0 6px 18px rgba(25, 73, 49, 0.06);
  --rail: 82px;
  --radius: 8px;
}

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

[hidden] {
  display: none !important;
}

html {
  background: var(--mint-100);
  color-scheme: light;
}

body {
  min-width: 320px;
  min-height: 100vh;
  background: var(--mint-100);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* 启动页 */
.splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 100dvh;
  overflow: hidden;
  background: var(--mint-100);
  padding:
    max(32px, env(safe-area-inset-top))
    max(24px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(24px, env(safe-area-inset-left));
}

.splash-copy {
  position: relative;
  z-index: 2;
  max-width: 620px;
  width: 100%;
  margin: 0 auto;
}

.splash-date {
  display: block;
  margin-bottom: 22px;
  color: var(--green);
  font-size: 14px;
  font-weight: 600;
}

.splash h1 {
  color: var(--green-deep);
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(40px, 11vw, 72px);
  font-weight: 600;
  line-height: 1.1;
}

.splash-copy p {
  margin-top: 14px;
  max-width: 480px;
  color: #375B49;
  font-size: 16px;
}

.splash-cat {
  align-self: end;
  justify-self: center;
  width: min(100%, 640px);
  max-height: 58vh;
  object-fit: contain;
  object-position: center bottom;
  mix-blend-mode: multiply;
}

.enter-button {
  position: relative;
  z-index: 2;
  width: min(100%, 620px);
  min-height: 54px;
  justify-self: center;
  border: 0;
  border-radius: var(--radius);
  background: var(--green);
  color: #FFFFFF;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(23, 97, 63, 0.16);
  transition: background .16s ease, transform .16s ease;
}

.enter-button:hover {
  background: var(--green-deep);
}

.enter-button:active {
  transform: translateY(1px);
}

/* 常驻侧栏 */
.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: var(--rail);
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.96);
  border-right: 1px solid var(--line);
  padding: max(12px, env(safe-area-inset-top)) 7px max(10px, env(safe-area-inset-bottom));
}

.brand {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  margin: 0 auto 10px;
  border: 1px solid var(--green);
  border-radius: var(--radius);
  background: var(--green);
  color: #FFFFFF;
  font-family: Georgia, serif;
  font-size: 25px;
  font-weight: 700;
}

.side-nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  scrollbar-width: none;
}

.side-nav::-webkit-scrollbar {
  display: none;
}

.side-item {
  min-height: 54px;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: #426352;
  cursor: pointer;
  transition: color .15s ease, background .15s ease, border-color .15s ease;
}

.side-item svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.side-item span {
  width: 100%;
  overflow: hidden;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
}

.side-item:hover {
  background: var(--mint-100);
  color: var(--green);
}

.side-item.active {
  background: var(--green);
  color: #FFFFFF;
}

.workspace {
  width: calc(100% - var(--rail));
  min-height: 100vh;
  margin-left: var(--rail);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px clamp(16px, 3vw, 34px);
  background: rgba(237, 247, 241, 0.94);
  border-bottom: 1px solid rgba(212, 228, 218, 0.8);
  backdrop-filter: blur(12px);
}

.topbar h1 {
  color: var(--green-deep);
  font-size: 20px;
  line-height: 1.25;
}

.topbar time {
  color: var(--muted);
  font-size: 12px;
}

.save-state {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.save-state.saving {
  color: var(--yellow);
}

.save-state.error {
  color: var(--coral);
}

.view-root {
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 24px clamp(16px, 3vw, 34px) 80px;
}

.page {
  animation: page-in .18s ease;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: none; }
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-heading h2 {
  color: var(--green-deep);
  font-size: 24px;
  line-height: 1.25;
}

.page-heading p {
  margin-top: 4px;
  color: var(--muted);
}

.page-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.summary-chip {
  min-width: 86px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}

.summary-chip strong {
  display: block;
  color: var(--green);
  font-size: 18px;
  line-height: 1.1;
}

.summary-chip span {
  color: var(--muted);
  font-size: 11px;
}

/* 首页 */
.home-greeting {
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.home-greeting time {
  color: var(--green);
  font-weight: 600;
}

.home-greeting h2 {
  margin-top: 10px;
  color: var(--green-deep);
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(30px, 4vw, 46px);
  font-weight: 600;
}

.home-greeting p {
  color: var(--muted);
}

.home-metrics {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metric-section {
  display: grid;
  grid-template-columns: minmax(170px, 0.65fr) minmax(240px, 1fr);
  gap: 30px;
  padding: 24px;
  border-bottom: 1px solid var(--line);
}

.metric-section:last-child {
  border-bottom: 0;
}

.metric-title {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
}

.metric-title .accent {
  color: var(--yellow);
  font-size: 20px;
}

.metric-number {
  margin-top: 12px;
  color: var(--green);
  font-size: 46px;
  font-weight: 750;
  line-height: 1;
}

.metric-number small {
  margin-left: 4px;
  font-size: 15px;
  font-weight: 600;
}

.metric-label {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.metric-detail {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
}

.metric-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.metric-status.done {
  color: var(--green);
}

.metric-status.pending {
  color: var(--coral);
}

.progress {
  width: 100%;
  height: 7px;
  overflow: hidden;
  border-radius: 4px;
  background: #E8EEE9;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.metric-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
}

/* 通用内容模块 */
.section {
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.section-head {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.section-head h3 {
  color: var(--green-deep);
  font-size: 16px;
}

.section-body {
  padding: 16px;
}

.notice {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-left: 3px solid var(--coral);
  background: var(--coral-soft);
  color: #824437;
  font-size: 13px;
}

.notice.good {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green-deep);
}

.notice.warn {
  border-color: var(--yellow);
  background: var(--yellow-soft);
  color: #725513;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}

.field.full {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--text);
  padding: 9px 10px;
  font-size: 14px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

textarea {
  min-height: 84px;
  resize: vertical;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  outline: 0;
  border-color: var(--green);
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(23, 97, 63, 0.09);
}

input::placeholder,
textarea::placeholder {
  color: #9CAAA2;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--green);
  padding: 8px 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.button svg,
.icon-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.button:hover {
  border-color: var(--mint-500);
  background: var(--mint-50);
}

.button.primary {
  border-color: var(--green);
  background: var(--green);
  color: #FFFFFF;
}

.button.primary:hover {
  border-color: var(--green-deep);
  background: var(--green-deep);
}

.button.coral {
  border-color: #F0B8AE;
  background: var(--coral-soft);
  color: var(--coral);
}

.button.small {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 12px;
}

.button:disabled {
  opacity: .55;
  cursor: default;
}

.icon-button {
  width: 36px;
  height: 36px;
  flex: none;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--line);
  background: var(--mint-50);
  color: var(--green);
}

.icon-button.danger:hover {
  background: var(--coral-soft);
  color: var(--coral);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar input,
.toolbar select {
  width: auto;
  min-width: 140px;
}

.list {
  list-style: none;
}

.list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.list-row:first-child {
  padding-top: 0;
}

.list-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.row-main {
  min-width: 0;
}

.row-title {
  color: var(--text);
  font-weight: 650;
  word-break: break-word;
}

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

.row-meta,
.row-copy {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.row-copy {
  color: #4E685B;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.tag {
  display: inline-block;
  margin-right: 5px;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--mint-50);
  color: var(--muted);
  font-size: 11px;
}

.tag.high,
.tag.over {
  border-color: #F0B8AE;
  background: var(--coral-soft);
  color: var(--coral);
}

.tag.success {
  border-color: var(--mint-300);
  background: var(--green-soft);
  color: var(--green);
}

.tag.gold {
  border-color: #EED794;
  background: var(--yellow-soft);
  color: #765A17;
}

.empty {
  padding: 28px 12px;
  color: var(--muted);
  text-align: center;
}

.check-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.check-control input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--green);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--mint-50);
}

.segment {
  min-height: 34px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  padding: 5px 12px;
  cursor: pointer;
}

.segment.active {
  background: var(--surface);
  color: var(--green);
  box-shadow: 0 1px 5px rgba(25, 73, 49, 0.08);
  font-weight: 650;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, .82fr) minmax(300px, 1.18fr);
  gap: 16px;
  align-items: start;
}

/* 日历 */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.calendar-weekday {
  padding: 8px 3px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.calendar-day {
  min-height: 86px;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #FFFFFF;
  padding: 7px;
  text-align: left;
  cursor: pointer;
}

.calendar-day:hover {
  background: var(--mint-50);
}

.calendar-day.blank {
  background: #F7FAF8;
  cursor: default;
}

.calendar-day.today {
  box-shadow: inset 0 0 0 2px var(--green);
}

.calendar-num {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.calendar-day.today .calendar-num {
  color: var(--green);
  font-weight: 700;
}

.calendar-event {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: var(--green);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 图文记录 */
.record-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.record-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.record-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: block;
  object-fit: cover;
  background: var(--mint-100);
}

.record-card-body {
  padding: 12px;
}

.record-card .row-actions {
  justify-content: flex-end;
  margin-top: 8px;
}

.book-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
}

.book-progress .progress {
  flex: 1;
}

.book-progress span {
  flex: none;
  color: var(--muted);
  font-size: 11px;
}

.budget-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.budget-stat {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.budget-stat span {
  color: var(--muted);
  font-size: 12px;
}

.budget-stat strong {
  display: block;
  margin-top: 4px;
  color: var(--green);
  font-size: 24px;
}

.budget-stat.negative strong {
  color: var(--coral);
}

.review-history {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.review-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.review-card h3 {
  color: var(--green-deep);
  font-size: 15px;
}

.review-card dl {
  margin-top: 10px;
}

.review-card dt {
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
}

.review-card dd {
  white-space: pre-wrap;
  word-break: break-word;
}

.review-card .row-actions {
  justify-content: flex-end;
  margin-top: 10px;
}

.toast {
  position: fixed;
  z-index: 120;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100vw - 40px));
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--green-deep);
  color: #FFFFFF;
  box-shadow: 0 12px 28px rgba(15, 73, 48, 0.2);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity .2s ease, transform .2s ease;
}

.toast.show {
  opacity: 1;
  transform: none;
}

.toast.error {
  background: #9D3E30;
}

@media (max-width: 760px) {
  :root {
    --rail: 66px;
  }

  .sidebar {
    padding-left: 5px;
    padding-right: 5px;
  }

  .brand {
    width: 36px;
    height: 36px;
    margin-bottom: 7px;
    font-size: 22px;
  }

  .side-item {
    min-height: 50px;
  }

  .side-item svg {
    width: 19px;
    height: 19px;
  }

  .side-item span {
    font-size: 9px;
  }

  .topbar {
    min-height: 62px;
    padding: 9px 12px;
  }

  .topbar h1 {
    font-size: 18px;
  }

  .view-root {
    padding: 16px 12px 70px;
  }

  .page-heading {
    display: block;
    margin-bottom: 14px;
  }

  .page-heading h2 {
    font-size: 21px;
  }

  .page-stats {
    margin-top: 10px;
  }

  .summary-chip {
    flex: 1;
    min-width: 74px;
  }

  .metric-section {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 16px;
  }

  .metric-number {
    font-size: 40px;
  }

  .metric-form,
  .form-grid,
  .form-grid.cols-3,
  .two-column,
  .record-grid,
  .review-history {
    grid-template-columns: 1fr;
  }

  .field.full,
  .form-actions {
    grid-column: auto;
  }

  .form-actions {
    flex-wrap: wrap;
  }

  .form-actions .button {
    flex: 1;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar {
    width: 100%;
  }

  .toolbar input,
  .toolbar select {
    min-width: 0;
    flex: 1;
  }

  .list-row {
    align-items: start;
  }

  .calendar-day {
    min-height: 56px;
    padding: 4px;
  }

  .calendar-event {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    color: transparent;
  }

  .budget-grid {
    grid-template-columns: 1fr;
  }

  .splash {
    padding-left: 22px;
    padding-right: 22px;
  }

  .splash-date {
    margin-bottom: 16px;
  }

  .splash h1 {
    font-size: 44px;
  }

  .splash-copy p {
    font-size: 15px;
  }

  .splash-cat {
    width: calc(100% + 44px);
    height: min(56vh, 500px);
    max-height: none;
    margin-inline: -22px;
    object-fit: cover;
    object-position: center 72%;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 12%, #000 100%);
    mask-image: linear-gradient(to bottom, transparent 0%, #000 12%, #000 100%);
  }

  .toast {
    right: 12px;
    bottom: 12px;
    max-width: calc(100vw - 24px);
  }
}

@media (max-width: 390px) {
  .save-state {
    max-width: 56px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .segment {
    padding-inline: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
