:root {
  color-scheme: light;
  --bg: #fff2f7;
  --surface: #fffdfd;
  --surface-subtle: #fce8f1;
  --ink: #542947;
  --muted: #9a6984;
  --line: #efbdd1;
  --accent: #e44f8e;
  --accent-dark: #b92d6d;
  --accent-soft: #ffe0ec;
  --partner: #8a65b8;
  --gold: #e7b74d;
  --gold-soft: #fff4ca;
  --danger: #b83b58;
  --radius: 18px;
  --shadow: 0 14px 36px rgba(157, 63, 112, 0.14);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; min-height: 100dvh; color: var(--ink); background: var(--bg); }
body::before { content: "✦　✿　·　✧　❀　✦　·　✿"; position: fixed; top: 88px; left: 2vw; z-index: -1; color: #efb3cc; font-size: clamp(15px, 2.2vw, 28px); letter-spacing: 1.6vw; transform: rotate(-4deg); opacity: 0.62; }
body::after { content: "♡　✧　✿　✦"; position: fixed; right: 3vw; bottom: 3vh; z-index: -1; color: #d5b1e9; font-size: clamp(18px, 2.5vw, 32px); letter-spacing: 1vw; transform: rotate(7deg); opacity: 0.55; }
body.entry-open { overflow: hidden; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(228, 79, 142, 0.24); outline-offset: 2px; }

.app-shell { max-width: 1320px; margin: 0 auto; padding: 0 32px; }
.topbar { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 2px solid var(--line); }
.brand-block { display: flex; align-items: center; gap: 11px; }
.brand-mark { width: 42px; height: 42px; border: 2px solid #fff; border-radius: 50%; display: grid; place-items: center; color: #fff6c9; background: var(--accent); font-weight: 800; font-size: 20px; box-shadow: 0 0 0 3px var(--gold), 0 7px 16px rgba(185, 45, 109, 0.22); animation: starPulse 3s ease-in-out infinite; }
.brand-block h1 { margin: 0; color: var(--accent-dark); font-size: 19px; letter-spacing: -0.03em; }
.brand-block p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.topbar-actions { display: flex; gap: 8px; }

.button { border: 0; border-radius: 999px; min-height: 40px; padding: 0 17px; font-weight: 700; color: var(--ink); transition: background 160ms ease, border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease; }
.button:active { transform: translateY(1px); }
.button-primary { border: 2px solid #fff; background: var(--accent); color: #fff; box-shadow: 0 0 0 1px var(--accent), 0 6px 14px rgba(185, 45, 109, 0.18); }
.button-primary:hover { background: var(--accent-dark); box-shadow: 0 0 0 1px var(--accent-dark), 0 8px 17px rgba(185, 45, 109, 0.25); }
.button-secondary { border: 1px solid var(--line); background: var(--surface); }
.button-secondary:hover { border-color: var(--accent); background: var(--accent-soft); }
.button-quiet { color: var(--muted); background: transparent; }
.button-danger { color: var(--danger); background: #f7e8e6; margin-right: auto; }

.month-toolbar { min-height: 68px; display: flex; align-items: center; gap: 9px; }
.month-arrow { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--accent-dark); font-size: 22px; line-height: 1; }
.month-arrow:hover { background: var(--surface-subtle); }
.month-picker-wrap { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.month-picker-wrap input { color: var(--ink); font-weight: 800; }
.month-toolbar input, .record-filters input, .record-filters select { border: 1px solid var(--line); border-radius: 9px; background: var(--surface); min-height: 38px; padding: 0 11px; color: var(--ink); }
.text-button { border: 0; background: transparent; color: var(--accent-dark); font-weight: 700; font-size: 12px; }

.income-overview { margin-bottom: 14px; }
.income-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 10px; padding: 0 4px; }
.income-heading h2 { margin: 4px 0 0; color: var(--accent-dark); font-size: 21px; letter-spacing: -0.035em; }
.income-heading > p { margin: 0; color: var(--muted); font-size: 10px; }
.income-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.income-card { position: relative; overflow: hidden; min-height: 155px; padding: 20px 21px 17px; border: 2px solid var(--line); border-radius: 22px; background: var(--surface); box-shadow: 0 8px 24px rgba(157, 63, 112, 0.09); }
.income-card::after { position: absolute; right: -8px; bottom: -25px; color: var(--accent-soft); font-size: 92px; line-height: 1; transform: rotate(-12deg); }
.income-card-a::after { content: "♡"; }
.income-card-b::after { content: "✦"; color: #eee2f8; }
.income-card-top { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.income-card-top > div { display: flex; align-items: center; gap: 8px; }
.income-avatar { width: 40px; height: 40px; flex: 0 0 auto; border: 2px solid #fff; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px var(--gold), 0 4px 10px rgba(157, 63, 112, 0.2); }
.income-card-top small { color: var(--muted); font-size: 11px; font-weight: 800; }
.income-add-button { min-height: 32px; padding: 0 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--accent-dark); background: #fff9fc; font-size: 10px; font-weight: 800; }
.income-add-button:hover { border-color: var(--accent); background: var(--accent-soft); }
.income-card > strong { position: relative; z-index: 1; display: block; margin-top: 12px; font-size: 25px; letter-spacing: -0.045em; }
.income-card > p { position: relative; z-index: 1; margin: 3px 0 0; color: var(--muted); font-size: 9px; }
.income-list { position: relative; z-index: 1; display: grid; gap: 5px; margin-top: 12px; }
.income-empty { margin: 0; color: #bd91a8; font-size: 9px; }
.income-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 24px; align-items: center; gap: 9px; padding-top: 7px; border-top: 1px dashed var(--line); }
.income-row > div { min-width: 0; }
.income-row strong, .income-row span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.income-row strong { font-size: 10px; }
.income-row span { color: var(--muted); font-size: 8px; }
.income-row b { font-size: 10px; }
.income-row button { width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; color: var(--muted); background: var(--surface-subtle); }
.income-row button:hover { color: #fff; background: var(--danger); }

.overview { position: relative; overflow: hidden; border: 2px solid var(--line); border-radius: 24px; background: var(--surface); padding: 25px 27px 22px; box-shadow: var(--shadow); }
.overview::before { content: "✦"; position: absolute; top: -24px; right: 30px; color: var(--gold-soft); font-size: 112px; line-height: 1; transform: rotate(14deg); }
.overview::after { content: "WISH • HOPE • LOVE"; position: absolute; right: 28px; bottom: 8px; color: #e9abc6; font-size: 8px; font-weight: 800; letter-spacing: 0.22em; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; }
.section-heading h2, .entry-panel h2, dialog h2 { margin: 4px 0 0; font-size: 26px; letter-spacing: -0.045em; line-height: 1.12; }
.compact-heading > p { margin: 0; color: var(--muted); font-size: 11px; }
.eyebrow { margin: 0; color: var(--accent-dark); font-size: 9px; font-weight: 900; letter-spacing: 0.18em; }

.summary-strip { display: grid; grid-template-columns: 1.12fr repeat(3, 1fr); gap: 10px; margin-top: 20px; }
.summary-item { position: relative; min-width: 0; padding: 18px 18px 17px; border: 1px solid var(--line); border-radius: 16px; background: #fff9fc; box-shadow: 0 5px 13px rgba(173, 74, 124, 0.07); }
.summary-item::after { content: "✧"; position: absolute; top: 9px; right: 11px; color: var(--gold); font-size: 14px; }
.summary-item span, .summary-item small { display: block; color: var(--muted); }
.summary-item span { font-size: 11px; font-weight: 700; }
.summary-label-row { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.summary-label-row button { padding: 2px 7px; border: 1px solid #e9b4ca; border-radius: 999px; color: var(--accent-dark); background: #fff; font-size: 8px; font-weight: 800; }
.summary-label-row button:hover { border-color: var(--accent); background: var(--accent-soft); }
.summary-item strong { display: block; overflow: hidden; margin: 8px 0 5px; font-size: clamp(20px, 2.25vw, 28px); letter-spacing: -0.045em; text-overflow: ellipsis; white-space: nowrap; }
.summary-item small { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.primary-summary { border-color: #ee9dbf; background: var(--accent-soft); }
.primary-summary strong { color: var(--accent-dark); }
.settlement-summary strong { font-size: clamp(17px, 1.8vw, 23px); }
.budget-track { height: 6px; margin-top: 17px; border: 1px solid #f0c2d5; background: #fff7fa; border-radius: 99px; overflow: hidden; }
.budget-track span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width 400ms ease; }

.insights-grid { display: grid; grid-template-columns: 1.08fr 0.92fr; gap: 14px; margin-top: 14px; }
.insight-panel { position: relative; border: 2px solid var(--line); border-radius: 22px; background: var(--surface); padding: 23px 24px; box-shadow: 0 8px 22px rgba(157, 63, 112, 0.08); }
.insight-panel::after { content: "❀"; position: absolute; right: 17px; bottom: 12px; color: #f2c1d5; font-size: 20px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.panel-heading h3 { margin: 4px 0 0; font-size: 18px; letter-spacing: -0.025em; }
.panel-heading > span { color: var(--muted); font-size: 10px; text-align: right; }
.category-chart-layout { display: grid; grid-template-columns: 126px 1fr; align-items: center; gap: 25px; margin-top: 19px; }
.donut { width: 122px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--surface-subtle) 0 100%); position: relative; }
.donut { border: 3px solid #fff; box-shadow: 0 0 0 2px var(--gold), 0 7px 17px rgba(167, 74, 125, 0.13); }
.donut::after { content: ""; position: absolute; inset: 17px; border-radius: 50%; background: var(--surface); }
.donut > div { z-index: 1; display: grid; text-align: center; }
.donut strong { font-size: 16px; letter-spacing: -0.04em; }
.donut span { color: var(--muted); font-size: 9px; }
.category-legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px 17px; }
.legend-row { display: grid; grid-template-columns: 9px 1fr auto; align-items: center; gap: 7px; font-size: 11px; }
.legend-row i { width: 7px; height: 7px; border-radius: 50%; }
.legend-row span { color: var(--muted); }
.payer-comparison { display: grid; gap: 17px; margin-top: 28px; }
.payer-label { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; }
.payer-label span { font-weight: 700; font-size: 12px; }
.payer-label strong { font-size: 12px; }
.payer-track { height: 8px; border-radius: 99px; overflow: hidden; background: var(--surface-subtle); }
.payer-track span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width 400ms ease; }
.secondary-payer .payer-track span { background: var(--partner); }
.settlement-note { margin: 20px 0 0; padding-top: 15px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; line-height: 1.65; }

.workspace-grid { margin-top: 14px; }
.records-section { min-height: 390px; border: 2px solid var(--line); border-radius: 22px; background: var(--surface); padding: 24px 26px; box-shadow: 0 8px 24px rgba(157, 63, 112, 0.08); }
.records-heading { align-items: center; }
.records-heading h2 { font-size: 23px; }
.record-filters { display: flex; gap: 7px; }
.record-filters input { width: 200px; }
.records-list { margin-top: 18px; }
.record-row { display: grid; grid-template-columns: 72px minmax(170px, 1fr) 140px 115px 82px; gap: 14px; align-items: center; padding: 14px 8px; border-top: 1px dashed var(--line); }
.record-row:hover { background: #fff5fa; }
.record-row:last-child { border-bottom: 1px solid var(--line); }
.record-date { color: var(--muted); font-size: 11px; }
.record-main strong { display: block; font-size: 13px; }
.record-main span, .record-meta span { color: var(--muted); font-size: 10px; }
.record-meta { display: grid; gap: 2px; }
.record-amount { text-align: right; font-weight: 800; font-size: 13px; font-variant-numeric: tabular-nums; }
.record-actions { display: flex; justify-content: flex-end; gap: 2px; }
.record-actions button { border: 0; padding: 5px; background: transparent; color: var(--muted); font-size: 10px; }
.record-actions button:hover { color: var(--accent-dark); }
.empty-state { text-align: center; padding: 54px 20px 44px; }
.empty-number { display: block; color: #f1c2d5; font-size: 48px; font-weight: 900; letter-spacing: -0.08em; text-shadow: 2px 2px 0 var(--gold-soft); }
.empty-state h3 { margin: 3px 0 7px; font-size: 17px; }
.empty-state p { margin: 0 auto; color: var(--muted); max-width: 360px; font-size: 11px; }
.empty-add-button { margin-top: 18px; min-height: 38px; }

.entry-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(77, 31, 66, 0.42); backdrop-filter: blur(3px); }
.entry-panel { position: fixed; z-index: 31; top: 0; right: 0; width: min(440px, 100%); height: 100dvh; overflow-y: auto; padding: 31px 31px 36px; color: var(--ink); background: #fff8fc; border-left: 4px double var(--gold); box-shadow: -20px 0 55px rgba(117, 42, 87, 0.2); transform: translateX(102%); transition: transform 180ms ease; }
.entry-panel::before { content: "✦  S A K U R A  ✦"; display: block; margin-bottom: 22px; padding: 9px 12px; border: 1px solid var(--gold); border-radius: 999px; color: var(--accent-dark); background: var(--gold-soft); text-align: center; font-size: 9px; font-weight: 900; letter-spacing: 0.16em; }
.entry-panel.is-open { transform: translateX(0); }
.entry-panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.entry-panel h2 { font-size: 26px; }
.entry-panel-header p:last-child { margin: 9px 0 0; color: var(--muted); font-size: 11px; line-height: 1.65; }
.drawer-close { border: 0; background: transparent; color: var(--muted); font-size: 26px; line-height: 1; padding: 2px 3px; }
.entry-panel form { display: grid; gap: 15px; margin-top: 25px; }
label > span, legend { display: block; margin-bottom: 7px; color: inherit; font-size: 11px; font-weight: 700; }
.fixed-expense-presets { padding: 13px; border: 1px solid var(--gold); border-radius: 15px; background: var(--gold-soft); }
.fixed-expense-presets legend { padding: 0 6px; color: var(--accent-dark); }
.fixed-expense-presets small { display: block; margin-top: 8px; color: var(--muted); font-size: 9px; }
.preset-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.preset-grid button { min-width: 0; padding: 8px 3px; border: 1px solid #edc8d8; border-radius: 11px; color: var(--ink); background: #fffafd; font-size: 10px; font-weight: 700; }
.preset-grid button span { display: grid; width: 23px; height: 23px; margin: 0 auto 5px; place-items: center; border-radius: 50%; color: var(--accent-dark); background: var(--accent-soft); font-size: 11px; }
.preset-grid button:hover, .preset-grid button.is-selected { border-color: var(--accent); color: var(--accent-dark); background: #fff; box-shadow: 0 3px 9px rgba(185, 45, 109, 0.13); }
.entry-panel input, .entry-panel select, dialog input, dialog select { width: 100%; min-height: 43px; border: 1px solid var(--line); border-radius: 12px; padding: 0 11px; background: #fffdfd; color: var(--ink); }
.entry-panel input::placeholder { color: #9aa4a8; }
.form-row.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.currency-input { position: relative; }
.currency-input b { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 500; }
.currency-input input { padding-left: 27px; }
fieldset { margin: 0; padding: 0; border: 0; }
.segmented-control { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-subtle); }
.segmented-control label { position: relative; }
.segmented-control input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-control span { display: grid; min-height: 36px; place-items: center; border-radius: 7px; color: var(--muted); font-size: 11px; font-weight: 700; }
.segmented-control input:checked + span { color: var(--accent-dark); background: var(--surface); box-shadow: 0 1px 5px rgba(157, 63, 112, 0.18); }
.form-actions { display: flex; gap: 8px; padding-top: 5px; }
.form-actions .button-primary { flex: 1; }
.form-error { margin: 0; color: var(--danger); font-size: 11px; }

dialog { width: min(540px, calc(100% - 32px)); border: 0; border-radius: var(--radius); padding: 0; color: var(--ink); background: var(--surface); box-shadow: 0 35px 100px rgba(25, 39, 45, 0.25); }
dialog { border: 3px double var(--gold); background: #fff8fc; }
dialog::backdrop { background: rgba(77, 31, 66, 0.44); backdrop-filter: blur(3px); }
dialog form { display: grid; gap: 19px; padding: 27px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; }
.dialog-heading h2 { font-size: 26px; }
.dialog-close { border: 0; background: transparent; font-size: 27px; color: var(--muted); }
.split-setting output { display: block; margin-top: 7px; color: var(--muted); font-size: 11px; }
.split-setting input { padding: 0; accent-color: var(--accent); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; padding-top: 4px; }
.income-dialog { width: min(500px, calc(100% - 28px)); }
.income-dialog .dialog-actions .button { min-width: 140px; }
.toast { position: fixed; left: 50%; bottom: 22px; z-index: 50; transform: translate(-50%, 16px); opacity: 0; pointer-events: none; padding: 11px 18px; border: 2px solid #fff; border-radius: 999px; color: #fff; background: var(--accent-dark); box-shadow: 0 0 0 1px var(--gold), var(--shadow); font-size: 12px; transition: opacity 160ms ease, transform 160ms ease; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
footer { padding: 25px 0 32px; color: var(--muted); font-size: 10px; text-align: center; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 900px) {
  .summary-strip { grid-template-columns: repeat(2, 1fr); }
  .insights-grid { grid-template-columns: 1fr; }
  .record-row { grid-template-columns: 68px minmax(150px, 1fr) 100px 82px; }
  .record-meta { display: none; }
}

@media (max-width: 650px) {
  .app-shell { padding: 0 14px; }
  .topbar { min-height: 64px; padding: 10px 0; }
  .brand-block p, #exportButton { display: none; }
  .brand-mark { width: 33px; height: 33px; border-radius: 9px; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .button { min-height: 36px; padding: 0 10px; font-size: 11px; }
  .month-toolbar { min-height: 59px; flex-wrap: wrap; gap: 7px; }
  .month-picker-wrap span { display: none; }
  .income-heading { align-items: flex-start; }
  .income-heading > p { display: none; }
  .income-grid { grid-template-columns: 1fr; gap: 9px; }
  .income-card { min-height: 145px; padding: 17px 16px 15px; }
  .income-card > strong { font-size: 23px; }
  .overview { padding: 18px 14px 14px; }
  .compact-heading { align-items: flex-start; }
  .compact-heading > p { display: none; }
  .section-heading h2 { font-size: 22px; }
  .summary-strip { gap: 7px; margin-top: 16px; }
  .summary-item { padding: 14px 12px; }
  .summary-label-row { align-items: flex-start; }
  .summary-label-row button { padding: 2px 5px; }
  .summary-item strong { font-size: 19px; }
  .summary-item.settlement-summary strong { font-size: 15px; }
  .insights-grid { gap: 10px; margin-top: 10px; }
  .insight-panel { padding: 18px 15px; }
  .category-chart-layout { grid-template-columns: 102px 1fr; gap: 15px; }
  .donut { width: 98px; }
  .donut::after { inset: 14px; }
  .category-legend { grid-template-columns: 1fr; gap: 7px; }
  .workspace-grid { margin-top: 10px; }
  .records-section { min-height: 330px; padding: 18px 14px; }
  .records-heading { display: block; }
  .record-filters { margin-top: 13px; }
  .record-filters label:first-child { flex: 1; }
  .record-filters input { width: 100%; }
  .record-row { grid-template-columns: 52px minmax(0, 1fr) 85px; gap: 9px; }
  .record-actions { grid-column: 2 / 4; justify-content: flex-start; }
  .entry-panel { top: auto; bottom: 0; width: 100%; height: min(90dvh, 760px); border-left: 0; border-top: 4px double var(--gold); border-radius: 22px 22px 0 0; padding: 23px 18px 28px; transform: translateY(102%); }
  .entry-panel.is-open { transform: translateY(0); }
  .form-row.two-columns { grid-template-columns: 1fr; }
  .dialog-actions { flex-wrap: wrap; }
  .dialog-actions .button { flex: 1; }
}

@keyframes starPulse {
  0%, 100% { transform: rotate(-7deg) scale(1); }
  50% { transform: rotate(7deg) scale(1.06); }
}

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