@font-face { font-family: "Geist"; src: url("/fonts/geist-latin-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("/fonts/geist-mono-latin-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --page: #F3F5F8;
  --paper: #FFFFFF;
  --ink: #0E1A2B;
  --ink-2: #4A5568;
  --ink-3: #6B7486;
  --rule: #E3E7EE;
  --rule-2: #EEF1F5;
  --navy: #0E1A2B;
  --on-navy: #FFFFFF;
  --on-navy-2: #A9B6CB;
  --blue: #1F5EFF;
  --blue-press: #1748C7;
  --blue-tint: #EAF0FF;
  --green: #12805C;
  --red: #C93A2E;
  --red-tint: #FBEDEB;
  --red-hover: #A82E24;
  --red-on-navy: #FF9B90;
  --blue-text: #1F5EFF;
  --on-blue: #FFFFFF;
  --rule-hover: #C9D0DB;
  --band: #FAFBFC;
  --row-hover: #F7F9FC;
  --bar: #768196;
  --scrollbar: #C5CCD8;
  --shadow: 14, 26, 43;
  --backdrop: rgba(14, 26, 43, .42);
  --sans: "Geist", -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, "PingFang SC", "Microsoft YaHei", monospace;
  --r: 6px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light;
}
/* 深色：跟随系统设置 */
@media (prefers-color-scheme: dark) {
  :root {
    --page: #0B111B;
    --paper: #151D29;
    --ink: #E6EAF0;
    --ink-2: #B4BDCA;
    --ink-3: #8E98A8;
    --rule: #283345;
    --rule-2: #1E2734;
    --navy: #111E33;
    --blue-tint: #1C2B4F;
    --blue-text: #8BAAFF;
    --green: #45C995;
    --red: #FF7B6F;
    --red-tint: #3A1E1F;
    --red-hover: #FF9B90;
    --rule-hover: #3B4759;
    --band: #19222F;
    --row-hover: #1A2431;
    --bar: #7B879B;
    --scrollbar: #3B4759;
    --shadow: 0, 0, 0;
    --backdrop: rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  caret-color: var(--blue);
}
::selection { background: var(--blue); color: var(--on-blue); }
[hidden] { display: none !important; }
h1, h2 { margin: 0; font-weight: 600; }
button, input { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
* { scrollbar-width: thin; scrollbar-color: var(--scrollbar) transparent; }
.wrap { --gut: 32px; width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 var(--gut); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 16px; border-radius: var(--r);
  border: 1px solid var(--rule); background: var(--paper); color: var(--ink);
  font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { border-color: var(--rule-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: progress; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: var(--on-blue); }
.btn-primary:hover { background: var(--blue-press); border-color: var(--blue-press); }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-tint); border-color: var(--red-tint); color: var(--red-hover); }
.btn-block { width: 100%; height: 44px; }
.btn kbd {
  font: 500 11px/1 var(--mono); padding: 3px 5px; border-radius: 4px;
  background: rgba(14,26,43,.32); margin-left: 4px;
}
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 0; border-radius: var(--r); background: transparent; color: inherit; cursor: pointer;
  transition: background .15s;
}
.icon-btn:hover { background: rgba(127,140,160,.16); }

/* ---------- 表单 ---------- */
.field { display: grid; gap: 6px; font-size: 13px; color: var(--ink-2); }
.field input {
  height: 44px; padding: 0 12px; border: 1px solid var(--rule); border-radius: var(--r);
  background: var(--paper); color: var(--ink); font-size: 15px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.field input::placeholder, .amount input::placeholder { color: var(--ink-3); }
.field input:hover { border-color: var(--rule-hover); }
.field input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-tint); }
.form-error { margin: 0; color: var(--red); font-size: 13px; }
.form-error:empty { display: none; }

.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--rule-2); border-radius: 8px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span {
  display: block; padding: 5px 14px; border-radius: 6px; font-size: 13px; font-weight: 500; color: var(--ink-2);
  transition: background .15s, color .15s;
}
.seg input:checked + span { background: var(--paper); color: var(--blue-text); box-shadow: 0 1px 2px rgba(var(--shadow), .12); }
.seg input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 1px; }

/* ---------- 品牌 ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; letter-spacing: .02em; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 5px; background: #fff; position: relative;
}
.brand-mark::before, .brand-mark::after {
  content: ""; position: absolute; left: 5px; right: 5px; height: 2px; background: var(--navy); border-radius: 1px;
}
.brand-mark::before { top: 7px; }
.brand-mark::after { top: 13px; right: 9px; }

/* ---------- 登录 ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-side {
  background: var(--navy); color: var(--on-navy);
  padding: 48px clamp(32px, 6vw, 88px); display: flex; flex-direction: column; justify-content: center; gap: 24px;
}
.auth-side .brand { position: absolute; top: 40px; }
.auth-side { position: relative; }
.auth-title { font-size: clamp(28px, 3.2vw, 40px); line-height: 1.25; letter-spacing: -0.02em; max-width: 14em; text-wrap: balance; }
.auth-lead { margin: 0; color: var(--on-navy-2); font-size: 16px; }
.sample {
  margin: 16px 0 0; max-width: 360px; padding: 20px 24px; border-radius: 10px;
  background: var(--paper); color: var(--ink); box-shadow: 0 12px 32px rgba(0, 0, 0, .28);
}
.sample figcaption { font-size: 12px; color: var(--ink-3); padding-bottom: 12px; border-bottom: 1px solid var(--rule); }
.sample dl { margin: 0; }
.sample dl div { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px dashed var(--rule); font-size: 14px; }
.sample dt { color: var(--ink-2); }
.sample dd { margin: 0; }
.sample .sample-total { border-bottom: 0; padding-top: 14px; font-weight: 600; }
.sample .sample-total dd { font-size: 20px; }
.auth-main { display: grid; place-items: center; padding: 48px 24px; background: var(--paper); }
.auth-form { width: 100%; max-width: 360px; display: grid; gap: 18px; }
.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--rule); margin-bottom: 8px; }
.tabs button {
  border: 0; background: none; padding: 0 0 12px; font-size: 20px; font-weight: 600; color: var(--ink-3); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .15s, border-color .15s;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-color: var(--ink); }

/* ---------- 抬头 ---------- */
.letterhead { background: var(--navy); color: var(--on-navy); padding-bottom: 32px; }
.lh-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 68px; }
.month-nav { display: flex; align-items: center; gap: 4px; }
.period { display: flex; align-items: baseline; gap: 10px; font-size: 17px; min-width: 170px; justify-content: center; }
.period-label { font-size: 13px; font-weight: 400; color: var(--on-navy-2); }
.lh-actions { display: flex; align-items: center; gap: 4px; }
.account { color: var(--on-navy-2); font-size: 13px; margin-right: 8px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lh-add { margin-left: 8px; }

.summary {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 2fr); gap: 32px; align-items: start;
  padding-top: 28px; position: relative;
}
.summary::before { content: ""; position: absolute; top: 0; left: var(--gut); right: var(--gut); border-top: 1px solid rgba(169,182,203,.18); }
.sum-main { display: grid; gap: 4px; }
.sum-label, .sum-figs dt { font-size: 13px; color: var(--on-navy-2); }
.sum-big { font-size: clamp(40px, 5vw, 60px); font-weight: 500; line-height: 1.05; letter-spacing: -0.035em; }
.sum-big.neg { color: var(--red-on-navy); }
.sum-period { font-size: 12px; color: var(--on-navy-2); font-family: var(--mono); }
.sum-figs { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sum-figs > div { padding: 0 24px; border-left: 1px solid rgba(169,182,203,.22); display: grid; gap: 4px; align-content: start; }
.sum-figs dd { margin: 0; font-size: 24px; font-weight: 500; }
.sum-budget dd.over { color: var(--red-on-navy); }
.sum-budget dd.unset { font-family: var(--sans); font-size: 16px; color: var(--on-navy-2); }
.budget-rule { height: 3px; border-radius: 2px; background: rgba(169,182,203,.25); overflow: hidden; margin-top: 6px; }
.budget-rule i { display: block; height: 100%; width: 0; background: var(--on-navy); border-radius: 2px; }
.budget-rule i.over { background: var(--red-on-navy); }
.budget-note { font-size: 12px; color: var(--on-navy-2); }

/* ---------- 明细 ---------- */
.sheet {
  display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 24px; align-items: start;
  margin-top: -16px; padding-bottom: 64px;
}
.paper { background: var(--paper); border-radius: 3px; box-shadow: 0 1px 2px rgba(var(--shadow), .08), 0 8px 24px rgba(var(--shadow), .05); }
.st-head { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px 16px; }
.st-head h2, .panel h2 { font-size: 16px; }
.st-table { width: 100%; border-collapse: collapse; }
.st-table th {
  font-size: 12px; font-weight: 500; color: var(--ink-3); text-align: left;
  padding: 8px 24px; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); background: var(--band);
}
.st-table .r { text-align: right; }
.st-table td { padding: 0 24px; height: 56px; border-bottom: 1px solid var(--rule-2); vertical-align: middle; }
.st-table .day th { background: transparent; border-top: 0; padding-top: 20px; padding-bottom: 8px; font-size: 13px; color: var(--ink); }
.st-table tbody:first-child .day th { padding-top: 12px; }
.day-row { display: flex; justify-content: space-between; gap: 12px; }
.day-row small { font-weight: 400; color: var(--ink-3); margin-left: 8px; }
.day-sub { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 400; color: var(--ink-3); }
.tx { cursor: pointer; transition: background .15s; }
.tx:hover { background: var(--row-hover); }
.tx.flash { animation: flash 1.6s var(--ease); }
@keyframes flash { from { background: var(--blue-tint); } to { background: transparent; } }
.tx-item { display: flex; flex-direction: column; justify-content: center; }
.tx-btn {
  border: 0; background: none; padding: 0; text-align: left; cursor: pointer; font-weight: 500; font-size: 15px;
}
.tx-note { font-size: 13px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 36ch; }
.tx-amt { font-size: 15px; font-weight: 500; white-space: nowrap; }
.tx-amt.in { color: var(--green); }
.col-run { color: var(--ink-3); width: 140px; white-space: nowrap; }
td.col-run { font-size: 13px; }
.st-total td { height: 48px; padding-top: 10px; padding-bottom: 10px; font-size: 13px; color: var(--ink-2); background: var(--band); border-bottom: 3px double var(--ink); }
.st-total .num { color: var(--ink); font-weight: 500; }
.st-total .tot-figs { display: flex; gap: 16px; flex-wrap: wrap; }
.st-total .tot-figs span { white-space: nowrap; }
.st-open td { height: 44px; font-size: 13px; color: var(--ink-3); border-bottom: 0; border-top: 1px solid var(--rule); }
.st-msg { text-align: center; color: var(--ink-3); height: 120px !important; }
.empty { display: grid; justify-items: center; gap: 12px; padding: 48px 24px 56px; text-align: center; color: var(--ink-2); }
.empty strong { color: var(--ink); font-size: 16px; font-weight: 600; }

/* ---------- 侧栏 ---------- */
.side { display: grid; }
.panel { padding: 20px 24px 24px; }
.panel + .panel { border-top: 1px solid var(--rule); }
.panel h2 { margin-bottom: 16px; }
.cats { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.cats li { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 14px; }
.cats .cat-amt { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.cats .cat-amt small { color: var(--ink-3); margin-left: 8px; font-size: 12px; }
.cats .bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--rule-2); overflow: hidden; }
.cats .bar i { display: block; height: 100%; background: var(--ink); border-radius: 3px; }
.panel-empty { color: var(--ink-3); font-size: 14px; margin: 0; }

.days { position: relative; display: flex; align-items: flex-end; gap: 2px; height: 120px; border-bottom: 1px solid var(--rule); }
.days button {
  flex: 1; height: 100%; border: 0; padding: 0; background: none; cursor: pointer;
  display: flex; align-items: flex-end; position: relative;
}
.days button i { display: block; width: 100%; min-height: 0; background: var(--bar); border-radius: 3px 3px 0 0; transition: background .15s; }
.days button.today i { background: var(--ink); }
.days button:hover i, .days button:focus-visible i { background: var(--blue); }
.days button:hover::after, .days button:focus-visible::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); font: 500 12px/1 var(--mono); padding: 6px 8px; border-radius: 4px; white-space: nowrap; z-index: 2; pointer-events: none;
}
.days button:first-child:hover::after, .days button:first-child:focus-visible::after { left: 0; transform: none; }
.days button:last-child:hover::after, .days button:last-child:focus-visible::after { left: auto; right: 0; transform: none; }
.days-ref { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--ink-3); pointer-events: none; }
.days-ref span { position: absolute; right: 0; bottom: 3px; font: 11px/1 var(--mono); color: var(--ink-3); background: var(--paper); padding-left: 4px; }
.days button.cut i { position: relative; }
.days button.cut i::before { content: ""; position: absolute; left: -1px; right: -1px; top: 10px; height: 3px; background: var(--paper); transform: skewY(-20deg); }
.days-note { margin: 8px 0 0; font-size: 12px; color: var(--ink-3); }
.days-axis { display: flex; justify-content: space-between; font: 12px var(--mono); color: var(--ink-3); padding-top: 6px; }

.budget-form { display: flex; gap: 8px; }
.field-inline { position: relative; flex: 1; display: block; }
.field-inline .prefix { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-family: var(--mono); }
.field-inline input { padding-left: 28px; font-family: var(--mono); }
.hint { margin: 8px 0 0; font-size: 12px; color: var(--ink-3); }

/* ---------- 记一笔 ---------- */
.entry {
  width: min(480px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 14px;
  background: var(--paper); color: var(--ink); box-shadow: 0 24px 64px rgba(var(--shadow), .28);
}
.entry::backdrop { background: var(--backdrop); }
.entry[open] { animation: rise .32s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.entry form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 20px 24px 24px; }
.entry form > * { min-width: 0; }
.entry-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: -4px; }
.entry-head h2 { font-size: 18px; }
.seg-type { width: 100%; }
.seg-type label { flex: 1; }
.seg-type span { text-align: center; padding: 8px; font-size: 14px; }
.amount { display: flex; align-items: baseline; gap: 8px; border-bottom: 2px solid var(--ink); padding-bottom: 6px; }
.amount:focus-within { border-color: var(--blue); }
.amount-cur { font: 500 24px var(--mono); color: var(--ink-3); }
.amount input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font: 500 40px/1.15 var(--mono); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.cat-pick { border: 0; padding: 0; margin: 0; min-inline-size: 0; }
.cat-pick legend { font-size: 13px; color: var(--ink-2); margin-bottom: 8px; padding: 0; }
.cat-pick > div { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-pick label { position: relative; }
.cat-pick input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.cat-pick span {
  display: block; padding: 7px 14px; border: 1px solid var(--rule); border-radius: 999px; font-size: 14px;
  transition: background .15s, border-color .15s, color .15s;
}
.cat-pick label:hover span { border-color: var(--rule-hover); }
.cat-pick input:checked + span { background: var(--blue); border-color: var(--blue); color: var(--on-blue); }
.cat-pick input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }
.entry-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 12px; }
.entry .form-error { margin-top: -12px; }
.entry-actions { display: flex; justify-content: flex-end; gap: 8px; }
.entry-actions .btn-primary { min-width: 120px; height: 44px; }
.entry-actions .btn-danger { margin-right: auto; height: 44px; }
.btn-danger.armed { background: #C93A2E; border-color: #C93A2E; color: #FFFFFF; }

.mobile-add { display: none; }

.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 8px; font-size: 14px;
  box-shadow: 0 8px 24px rgba(var(--shadow), .24); transition: opacity .2s, transform .3s var(--ease); z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #C93A2E; color: #FFFFFF; }

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
  .sheet { grid-template-columns: 1fr; }
  .side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .side .panel:last-child { grid-column: 1 / -1; }
  .side .panel:nth-child(2) { border-top: 0; border-left: 1px solid var(--rule); }
  .account { display: none; }
}
@media (max-width: 720px) {
  .wrap { --gut: 16px; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { padding: 88px 24px 32px; gap: 12px; }
  .auth-side .brand { top: 28px; }
  .sample { display: none; }
  .auth-main { place-items: start center; padding: 32px 24px 48px; }

  .letterhead { padding-bottom: 24px; }
  .lh-bar { height: 56px; }
  .lh-bar > .brand { display: none; }
  .month-nav { margin-left: -8px; }
  .period { min-width: 0; font-size: 16px; }
  .lh-add { display: none; }
  .summary { grid-template-columns: 1fr; gap: 20px; padding-top: 20px; }
  .sum-figs { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 16px; }
  .sum-figs > div { padding: 0 16px; }
  .sum-figs > div:first-child { padding-left: 0; border-left: 0; }
  .sum-figs > .sum-budget { grid-column: 1 / -1; padding: 16px 0 0; border-left: 0; border-top: 1px solid rgba(169,182,203,.22); grid-template-columns: auto 1fr; column-gap: 12px; align-items: baseline; }
  .sum-budget dt { grid-column: 1; }
  .sum-budget dd { grid-column: 2; justify-self: end; }
  .sum-budget .budget-rule, .sum-budget .budget-note { grid-column: 1 / -1; }
  .sum-figs dd { font-size: 17px; }
  .sum-budget dd.unset { font-size: 14px; }
  .sheet { margin-top: -12px; padding-bottom: 104px; gap: 16px; }
  .side { grid-template-columns: 1fr; }
  .side .panel:nth-child(2) { border-left: 0; border-top: 1px solid var(--rule); }
  .st-head { padding: 16px; }
  .st-table th, .st-table td { padding-left: 16px; padding-right: 16px; }
  .col-run { width: auto; }
  td.col-run { font-size: 12px; }
  .st-total td { height: auto; }
  .st-total .tot-figs { gap: 2px 12px; }
  .st-total .tot-figs strong { flex-basis: 100%; }
  .tx-note { max-width: 14ch; }
  .panel { padding: 16px; }
  .mobile-add {
    display: inline-flex; position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
    height: 52px; font-size: 16px; border: 0; border-radius: 12px; box-shadow: 0 8px 24px rgba(var(--shadow), .28); z-index: 5;
  }
  .entry {
    width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 16px 16px 0 0; max-height: 92vh;
  }
  .entry[open] { animation: sheet .36s var(--ease); }
  @keyframes sheet { from { transform: translateY(100%); } }
  .entry form { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .entry-row { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 380px) {
  .st-table .col-run { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
