:root {
  --bg: #f3f4ee;
  --surface: #fffefb;
  --ink: #19231f;
  --muted: #6c7771;
  --line: #e5e6dc;
  --line-soft: #efefe7;
  --brand: #14594a;
  --brand-strong: #0d4237;
  --brand-soft: #e8f1ec;
  --gold: #c8a45c;
  --danger: #b04a3f;
  --danger-soft: #faeeeb;
  --shadow: 0 14px 34px rgba(22, 48, 39, 0.06);
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ---------------------------------- 品牌 ---------------------------------- */

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #fff;
}

.brand small {
  display: block;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.42);
  margin-top: 2px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(150deg, #1c6a58, #0c3a30);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #ecd9a8;
  display: grid;
  place-items: center;
  flex: none;
}

/* ---------------------------------- 登录 ---------------------------------- */

.auth-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px 18px;
  background:
    radial-gradient(900px 520px at 12% 8%, #dcebe3 0%, transparent 62%),
    radial-gradient(760px 520px at 92% 94%, #efe6d2 0%, transparent 60%),
    var(--bg);
}

.auth-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 38px 38px 30px;
  box-shadow: 0 30px 80px rgba(18, 46, 36, 0.12);
  animation: rise-in 0.4s ease both;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.brand-auth {
  color: var(--ink);
  margin-bottom: 30px;
}

.brand-auth small {
  color: var(--muted);
}

.auth-card h1 {
  font-size: 26px;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 26px;
  line-height: 1.65;
}

.auth-submit {
  width: 100%;
  padding: 12px;
  margin-top: 8px;
  font-size: 15px;
}

.auth-foot {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin: 20px 0 0;
}

/* ---------------------------------- 布局 ---------------------------------- */

.app {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 236px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  padding: 26px 16px 20px;
  background:
    radial-gradient(320px 260px at 100% 0%, rgba(58, 122, 103, 0.28), transparent 70%),
    linear-gradient(180deg, #123b31 0%, #0b2a23 100%);
  color: #eaf2ee;
}

.sidebar .brand {
  padding: 0 8px 26px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-group-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: rgba(255, 255, 255, 0.33);
  text-transform: uppercase;
  margin: 20px 12px 7px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  border: 0;
  background: transparent;
  color: rgba(238, 246, 242, 0.72);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 12px;
  border-radius: 10px;
  text-align: left;
  transition: background 0.14s ease, color 0.14s ease;
  position: relative;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.11);
  color: #fff;
  font-weight: 600;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 2.5px;
  border-radius: 2px;
  background: var(--gold);
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 12px 0;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #65b795;
  box-shadow: 0 0 0 3px rgba(101, 183, 149, 0.12);
  flex: none;
}

.main {
  margin-left: 236px;
  padding: 26px 36px 48px;
  min-height: 100vh;
}

.content {
  max-width: 1180px;
  margin: 0 auto;
}

.topbar {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 4px 2px 24px;
}

.topbar-title h1 {
  font-size: 26px;
  letter-spacing: -0.015em;
  margin: 0;
  font-weight: 700;
}

.topbar-title p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px 3px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  flex: none;
}

.user-avatar.lg {
  width: 42px;
  height: 42px;
  font-size: 15px;
}

.user-name {
  max-width: 96px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  font-weight: 600;
}

.mobile-brand {
  display: none;
}

.today {
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------- 通用组件 ---------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 17px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  background: transparent;
  color: var(--ink);
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
  white-space: nowrap;
}

.btn.primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 6px 16px rgba(20, 89, 74, 0.18);
}

.btn.primary:hover {
  background: var(--brand-strong);
}

.btn.ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.btn.ghost:hover {
  background: #f7f7f2;
  border-color: #d8dacd;
}

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

.btn.danger:hover {
  background: #963c33;
}

.btn.sm {
  padding: 7px 12px;
  font-size: 13px;
  border-radius: 9px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.link-btn {
  border: 0;
  background: transparent;
  color: var(--brand);
  font-size: 13px;
  font-weight: 500;
  padding: 4px 7px;
  border-radius: 6px;
  white-space: nowrap;
}

.link-btn:hover {
  background: var(--brand-soft);
}

.link-btn.danger-text {
  color: var(--danger);
}

.link-btn.danger-text:hover {
  background: var(--danger-soft);
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.icon-btn:hover {
  background: #f2f2eb;
  color: var(--ink);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
}

.card h3 {
  font-size: 15px;
  font-weight: 650;
  margin: 0;
  letter-spacing: 0.01em;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-note {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.hint {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
  margin: 10px 0 0;
}

.count-note {
  font-size: 12px;
  color: var(--muted);
  margin-left: auto;
  white-space: nowrap;
}

.muted {
  color: var(--muted);
}

/* ---------------------------------- 总览 ---------------------------------- */

.view {
  animation: fade-in 0.22s ease both;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr);
  gap: 20px;
}

.net-card {
  position: relative;
  overflow: hidden;
  min-height: 268px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 30px 32px;
  border-radius: 22px;
  color: #fff;
  background:
    radial-gradient(600px 300px at 100% 0%, rgba(86, 160, 137, 0.28), transparent 65%),
    linear-gradient(135deg, #14594a 0%, #0b392f 58%, #092b24 100%);
  box-shadow: 0 24px 50px rgba(11, 52, 42, 0.22);
}

.net-card::after {
  content: "";
  position: absolute;
  right: -90px;
  top: -130px;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow:
    0 0 0 42px rgba(255, 255, 255, 0.025),
    0 0 0 84px rgba(255, 255, 255, 0.016);
  pointer-events: none;
}

.net-label {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.68);
}

.net-badge {
  font-size: 10.5px;
  letter-spacing: 0.03em;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: rgba(255, 255, 255, 0.6);
}

.net-value {
  margin: 14px 0 8px;
  font-size: clamp(34px, 4.2vw, 50px);
  font-weight: 700;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  position: relative;
  z-index: 1;
}

.net-value.negative {
  color: #ffc4b8;
}

.net-meta {
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.52);
}

.net-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding-top: 20px;
  margin-top: 26px;
  border-top: 1px solid rgba(255, 255, 255, 0.13);
  position: relative;
  z-index: 1;
}

.net-split > div {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.net-split span {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
}

.net-split strong {
  font-size: 20px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.net-split small {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.42);
}

.recent-card {
  display: flex;
  flex-direction: column;
}

.mini-timeline {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  flex: 1;
}

.mini-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line-soft);
}

.mini-item:last-child {
  border-bottom: 0;
}

.mini-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
  margin-top: 7px;
  flex: none;
}

.mini-dot.update {
  background: #c59b4e;
}

.mini-dot.delete {
  background: var(--danger);
}

.mini-main {
  flex: 1;
  min-width: 0;
}

.mini-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-detail {
  font-size: 11.5px;
  color: var(--muted);
  margin: 2px 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mini-time {
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}

.mini-empty {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  padding: 30px 0;
  margin: 0;
}

.recent-card .link-btn {
  align-self: flex-start;
  margin-top: 8px;
  padding-left: 0;
}

.recent-card .link-btn:hover {
  background: transparent;
  color: var(--brand-strong);
}

.breakdown-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 20px;
}

.breakdown {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 18px;
  min-height: 60px;
}

.break-row {
  display: flex;
  flex-direction: column;
}

.break-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  font-size: 14px;
}

.break-top strong {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.bar {
  height: 6px;
  border-radius: 999px;
  background: #eef0e8;
  margin-top: 8px;
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #14594a, #4a9a83);
  transition: width 0.4s ease;
}

#liability-breakdown .bar > span {
  background: linear-gradient(90deg, #a3693f, #d2a46b);
}

.break-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 6px;
}

.breakdown-empty {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 26px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ---------------------------------- 列表页 ---------------------------------- */

.table-card {
  padding: 0;
  overflow: hidden;
}

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  flex: 1;
  min-width: 200px;
  max-width: 340px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafaf5;
  color: var(--muted);
  transition: border-color 0.14s ease, background 0.14s ease;
}

.search-box:focus-within {
  border-color: #9db9ac;
  background: #fff;
}

.search-box svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  flex: none;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 13.5px;
  color: var(--ink);
}

.search-box input::placeholder {
  color: #9aa39d;
}

.select-wrap {
  position: relative;
  display: inline-flex;
}

select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line);
  background-color: #fafaf5;
  color: var(--ink);
  font-size: 13.5px;
  height: 40px;
  padding: 0 32px 0 12px;
  border-radius: 10px;
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236c7771' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  transition: border-color 0.14s ease;
}

select:focus {
  border-color: #9db9ac;
  background-color: #fff;
}

.add-btn {
  margin-left: auto;
}

.table-scroll {
  overflow-x: auto;
}

.mobile-items {
  display: none;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: #fafaf5;
  padding: 11px 20px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.data-table td {
  padding: 15px 20px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover td {
  background: #fcfcf7;
}

.data-table .num {
  text-align: right;
}

.data-table .actions-col {
  text-align: right;
  width: 1%;
}

.item-name {
  font-weight: 600;
  font-size: 14px;
}

.item-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-pill {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  color: #4f5d56;
  background: #f1f2eb;
  border: 1px solid #e8e9df;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.amount-main {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.amount-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.updated-cell {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
}

.empty {
  padding: 54px 24px;
  text-align: center;
}

.empty-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 6px;
}

.empty-text {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 16px;
}

/* ---------------------------------- 修改记录 ---------------------------------- */

.history-list {
  list-style: none;
  margin: 0;
  padding: 4px 20px;
}

.history-item {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line-soft);
}

.history-item:last-child {
  border-bottom: 0;
}

.history-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 7px;
  flex: none;
  background: var(--brand);
}

.history-dot.update {
  background: #c59b4e;
}

.history-dot.delete {
  background: var(--danger);
}

.history-main {
  flex: 1;
  min-width: 0;
}

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

.history-top strong {
  font-size: 14px;
  font-weight: 600;
}

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 600;
  border-radius: 999px;
  padding: 2px 8px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge.create {
  background: var(--brand-soft);
  color: var(--brand);
}

.badge.update {
  background: #f8f0df;
  color: #96682a;
}

.badge.delete {
  background: var(--danger-soft);
  color: var(--danger);
}

.history-detail {
  margin: 5px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.65;
  word-break: break-word;
}

.history-time {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  padding-top: 3px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.history-time > span {
  display: block;
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  padding: 0 20px 20px;
}

.load-more-wrap:empty {
  display: none;
}

/* ---------------------------------- 设置 ---------------------------------- */

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 20px;
  align-items: start;
}

.rate-list {
  margin-top: 18px;
  border-top: 1px solid var(--line-soft);
}

.rate-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}

.rate-name {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.currency-badge {
  width: 42px;
  height: 34px;
  border-radius: 8px;
  background: #f1f2eb;
  border: 1px solid #e8e9df;
  display: grid;
  place-items: center;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #4f5d56;
  flex: none;
}

.rate-name strong {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
}

.rate-name small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}

.rate-eq {
  color: #a0a8a2;
  font-size: 13px;
}

.rate-input {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rate-input input {
  width: 112px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fafaf5;
  text-align: right;
  padding: 0 10px;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  outline: none;
}

.rate-input input:focus {
  border-color: #9db9ac;
  background: #fff;
}

.rate-input input.invalid {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.rate-input span {
  font-size: 11px;
  color: var(--muted);
  width: 28px;
}

.rate-fixed {
  font-size: 12px;
  color: var(--muted);
  width: 148px;
  text-align: right;
}

.settings-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}

.save-note {
  font-size: 12px;
  color: var(--brand);
}

.info-list {
  margin: 18px 0 22px;
}

.info-list > div {
  display: flex;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
}

.info-list > div:last-child {
  border-bottom: 0;
}

.info-list dt {
  width: 74px;
  flex: none;
  font-size: 12.5px;
  color: var(--muted);
}

.info-list dd {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
}

.account-block {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: #fafaf5;
}

.account-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.account-info strong {
  font-size: 15px;
  font-weight: 650;
}

.account-info small {
  font-size: 11.5px;
  color: var(--muted);
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.member-add {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 8px;
}

.member-add-title {
  font-size: 13px;
  font-weight: 650;
  color: #4d5a53;
  margin-bottom: 2px;
}

.member-add-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.member-add-actions .field-help {
  margin-top: 0;
}

.member-list {
  max-height: 42vh;
  overflow-y: auto;
  margin-top: 4px;
}

.member-loading {
  margin: 0;
  padding: 22px 0;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
}

.member-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}

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

.member-info {
  flex: 1;
  min-width: 0;
}

.member-name {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 14px;
  font-weight: 600;
}

.member-role {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: #f1f2eb;
  color: var(--muted);
}

.member-role.admin {
  background: var(--brand-soft);
  color: var(--brand);
}

.member-sub {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}

.member-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.member-self {
  font-size: 11px;
  color: var(--muted);
}

/* ---------------------------------- 弹窗 ---------------------------------- */

dialog.dialog {
  width: min(520px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(12, 38, 30, 0.28);
}

dialog.dialog[open] {
  animation: dialog-in 0.18s ease-out both;
}

dialog.dialog::backdrop {
  background: rgba(9, 30, 24, 0.46);
  backdrop-filter: blur(3px);
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes sheet-in {
  from {
    opacity: 0.4;
    transform: translateY(36px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

dialog.dialog-sm {
  width: min(430px, calc(100vw - 32px));
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 24px 0;
}

.dialog-head h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.dialog-body {
  padding: 18px 24px 4px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px 24px 22px;
}

.confirm-text {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.7;
}

.dialog .hint {
  margin: 0 0 6px;
}

/* ---------------------------------- 表单 ---------------------------------- */

.field {
  display: block;
  margin-top: 16px;
}

.field > span {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: #4d5a53;
  margin-bottom: 7px;
}

.field > span em {
  font-style: normal;
  font-weight: 400;
  color: #9aa39d;
  font-size: 11.5px;
}

.field-help {
  display: block;
  margin-top: 6px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--muted);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafaf5;
  color: var(--ink);
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.field select {
  height: 42px;
  padding: 0 32px 0 12px;
}

.field input {
  height: 42px;
}

.field textarea {
  resize: vertical;
  min-height: 62px;
  line-height: 1.6;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: #9db9ac;
  background: #fff;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #a6ada8;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: #f0f1e9;
  border-radius: 12px;
  padding: 4px;
}

.seg-btn {
  border: 0;
  background: transparent;
  padding: 9px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  transition: background 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
}

.seg-btn.active {
  background: #fff;
  color: var(--brand);
  box-shadow: 0 1px 4px rgba(20, 45, 36, 0.1);
}

.form-error {
  margin: 14px 0 0;
  font-size: 12.5px;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: 8px;
  padding: 8px 11px;
  line-height: 1.6;
}

/* 紧凑历史（单项记录弹窗） */

.history-list.compact {
  padding: 0;
  max-height: 60vh;
  overflow-y: auto;
}

.history-list.compact .history-item {
  padding: 13px 0;
}

.history-list.compact .history-time {
  display: flex;
  align-items: flex-start;
  margin-top: 6px;
  padding: 0;
  text-align: left;
}

.history-list.compact .history-item {
  flex-wrap: wrap;
}

.history-list.compact .history-main {
  flex-basis: calc(100% - 24px);
}

/* ---------------------------------- 提示 ---------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  z-index: 100;
  transform: translate(-50%, 14px);
  background: #123b31;
  color: #fff;
  font-size: 13.5px;
  padding: 11px 18px;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(10, 35, 27, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  max-width: calc(100vw - 32px);
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  background: var(--danger);
}

/* ---------------------------------- 走势 ---------------------------------- */

.asof-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.asof-head .hint {
  margin: 6px 0 0;
}

.asof-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.asof-controls input[type="date"] {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafaf5;
  color: var(--ink);
  padding: 0 12px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
}

.asof-controls input[type="date"]:focus {
  border-color: #9db9ac;
  background: #fff;
}

.asof-quick {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.asof-quick > span {
  font-size: 11.5px;
  color: var(--muted);
}

.asof-quick button {
  border: 1px solid var(--line);
  background: #fafaf5;
  color: #4f5d56;
  font-size: 12px;
  border-radius: 999px;
  padding: 5px 11px;
}

.asof-quick button:hover {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: #d5e4dc;
}

.asof-summary {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 20px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
}

.asof-summary > div {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.asof-summary strong {
  font-size: 19px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.asof-net strong {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.asof-net strong.negative {
  color: var(--danger);
}

.asof-net small {
  font-size: 11.5px;
  color: var(--muted);
}

.chart-card {
  margin-top: 20px;
}

.chart-head {
  flex-wrap: wrap;
  gap: 10px;
}

.range-tabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: #f0f1e9;
}

.range-tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
}

.range-tabs button.active {
  background: #fff;
  color: var(--brand);
  box-shadow: 0 1px 3px rgba(20, 45, 36, 0.12);
}

.chart-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 14px;
  font-size: 11.5px;
  color: var(--muted);
}

.chart-legend span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  padding: 3px 5px;
  border-radius: 6px;
  opacity: 0.55;
}

.legend-toggle.active {
  opacity: 1;
  color: var(--ink);
  font-weight: 600;
}

.legend-toggle:hover {
  background: var(--brand-soft);
  opacity: 1;
}

.chart-legend i {
  display: inline-block;
  width: 14px;
  height: 3px;
  border-radius: 2px;
}

.legend-net {
  background: #14594a;
}

.legend-asset {
  background: #6fb29c;
}

.legend-liability {
  background: #c99a63;
}

.chart-note {
  margin-left: auto;
  font-size: 11px;
  color: #9aa39d;
}

.chart-wrap {
  position: relative;
  margin-top: 10px;
  min-height: 180px;
}

#trend-chart {
  width: 100%;
  overflow: hidden;
}

.trend-svg {
  display: block;
  width: 100%;
  height: auto;
  touch-action: pan-y;
}

.chart-grid-line {
  stroke: #eef0e8;
  stroke-width: 1;
}

.chart-zero-line {
  stroke: #d9ddd2;
  stroke-width: 1;
  stroke-dasharray: 3 4;
}

.chart-axis-text {
  font-family: var(--font);
  font-size: 10.5px;
  fill: #8b958f;
}

.chart-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-line-net {
  stroke: #14594a;
  stroke-width: 2.4;
}

.chart-line-asset {
  stroke: #6fb29c;
  stroke-width: 1.4;
}

.chart-line-liability {
  stroke: #c99a63;
  stroke-width: 1.4;
}

.chart-area {
  stroke: none;
}

.chart-hover-line {
  stroke: #7b8a82;
  stroke-width: 1;
  stroke-dasharray: 3 3;
  opacity: 0;
}

.chart-hover-dot {
  opacity: 0;
  stroke: #fff;
  stroke-width: 1.5;
}

.chart-hover-net {
  fill: #14594a;
}

.chart-hover-assets {
  fill: #6fb29c;
}

.chart-hover-liabilities {
  fill: #c99a63;
}

.chart-hover-line.visible,
.chart-hover-dot.visible {
  opacity: 1;
}

.chart-overlay {
  cursor: crosshair;
}

.chart-tooltip {
  position: absolute;
  z-index: 5;
  min-width: 152px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 254, 251, 0.98);
  box-shadow: 0 10px 28px rgba(20, 48, 39, 0.14);
  pointer-events: none;
}

.chart-tooltip-date {
  margin-bottom: 6px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.chart-tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 12px;
  line-height: 1.8;
}

.chart-tooltip-row span {
  color: var(--muted);
}

.chart-tooltip-row strong {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.chart-empty {
  margin: 0;
  padding: 70px 10px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.asof-detail {
  margin-top: 20px;
}

.asof-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  margin-top: 18px;
}

.asof-column-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.asof-column-head h4 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
}

.asof-column-head span {
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.asof-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}

.asof-item:last-child {
  border-bottom: 0;
}

.asof-item-main {
  min-width: 0;
}

.asof-item-name {
  font-size: 13.5px;
  font-weight: 600;
}

.asof-item-sub {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}

.asof-item-value {
  flex: none;
  text-align: right;
}

.asof-item-value strong {
  display: block;
  font-size: 13.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.asof-item-original {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.asof-list-empty {
  margin: 0;
  padding: 16px 0;
  font-size: 12.5px;
  color: var(--muted);
}

.asof-empty {
  margin: 0;
  padding: 30px 0 10px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* ---------------------------------- 响应式 ---------------------------------- */

@media (max-width: 1080px) {
  .hero-grid {
    grid-template-columns: 1fr;
  }

  .recent-card {
    min-height: 220px;
  }

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

  .settings-grid > article:last-child {
    order: -1;
  }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    inset: auto 0 0 0;
    width: auto;
    height: auto;
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: rgba(255, 254, 251, 0.97);
    border-top: 1px solid var(--line);
    box-shadow: 0 -10px 30px rgba(22, 48, 39, 0.08);
    backdrop-filter: blur(14px);
    overflow: visible;
  }

  .sidebar .brand,
  .sidebar-foot,
  .nav-group-label {
    display: none;
  }

  .nav {
    flex-direction: row;
    flex: 1;
    gap: 0;
    overflow: visible;
  }

  .nav-item {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 3px;
    width: auto;
    min-height: 54px;
    padding: 5px 2px;
    border-radius: 10px;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 500;
    white-space: nowrap;
  }

  .nav-item svg {
    width: 21px;
    height: 21px;
  }

  .nav-item:hover {
    background: transparent;
    color: var(--ink);
  }

  .nav-item.active {
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 650;
  }

  .nav-item.active::before {
    display: none;
  }

  .main {
    margin-left: 0;
    padding: 16px 16px calc(92px + env(safe-area-inset-bottom));
  }

  .topbar {
    align-items: flex-start;
    padding: 2px 0 18px;
    gap: 12px;
  }

  .mobile-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    color: var(--brand);
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: 0.02em;
  }

  .mobile-brand .brand-mark {
    width: 27px;
    height: 27px;
    border-radius: 8px;
  }

  .topbar-title h1 {
    font-size: 24px;
  }

  .topbar-title p {
    font-size: 12.5px;
  }

  .topbar-actions {
    padding-top: 4px;
  }

  .topbar-actions .today {
    display: none;
  }

  .toast {
    bottom: calc(82px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 720px) {
  .breakdown-grid {
    grid-template-columns: 1fr;
  }

  .net-card {
    padding: 26px 22px;
    min-height: 0;
  }

  .col-updated,
  .updated-cell {
    display: none;
  }

  .table-scroll {
    display: none;
  }

  .mobile-items {
    display: block;
  }

  .mobile-items[hidden] {
    display: none;
  }

  .item-card {
    padding: 15px 16px;
    border-bottom: 1px solid var(--line-soft);
  }

  .item-card:last-child {
    border-bottom: 0;
  }

  .item-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
  }

  .item-card-info {
    flex: 1;
    min-width: 0;
  }

  .item-card-info .item-name {
    font-size: 15px;
    line-height: 1.4;
  }

  .item-card-info .item-note {
    max-width: 100%;
    white-space: normal;
    line-height: 1.45;
    margin-top: 3px;
  }

  .item-card-amount {
    flex: none;
    max-width: 48%;
    text-align: right;
  }

  .item-card-amount .amount-main {
    font-size: 15.5px;
    line-height: 1.4;
  }

  .item-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 10px;
  }

  .item-card-time {
    font-size: 11px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
  }

  .item-card-actions {
    display: flex;
    gap: 6px;
    margin-top: 12px;
  }

  .item-card-actions .link-btn {
    flex: 1;
    padding: 8px 6px;
    border-radius: 8px;
    background: #f7f7f2;
    color: var(--brand);
    font-size: 13px;
    text-align: center;
  }

  .item-card-actions .link-btn.danger-text {
    background: var(--danger-soft);
    color: var(--danger);
  }

  .item-card-actions .link-btn:hover {
    background: var(--brand-soft);
  }

  .item-card-actions .link-btn.danger-text:hover {
    background: #f5ddd8;
  }

  .asof-summary {
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }

  .asof-net {
    grid-column: 1 / -1;
  }

  .asof-net strong {
    font-size: 30px;
  }

  .asof-columns {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .mini-detail {
    -webkit-line-clamp: 2;
  }

  #history-list .history-item {
    display: grid;
    grid-template-columns: 8px minmax(0, 1fr);
    column-gap: 12px;
    row-gap: 5px;
  }

  #history-list .history-dot {
    grid-column: 1;
    grid-row: 1;
  }

  #history-list .history-main {
    grid-column: 2;
    grid-row: 1;
  }

  #history-list .history-time {
    grid-column: 2;
    grid-row: 2;
    margin-left: 0;
    padding-top: 0;
    align-items: flex-start;
    text-align: left;
  }
}

@media (max-width: 560px) {
  .auth-screen {
    padding: 18px 14px;
  }

  .auth-card {
    padding: 30px 22px calc(24px + env(safe-area-inset-bottom));
  }

  .net-card {
    padding: 24px 20px;
  }

  .net-value {
    font-size: 33px;
  }

  .net-label {
    font-size: 12px;
  }

  .net-split {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding-top: 16px;
    margin-top: 22px;
  }

  .net-split > div {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .net-split strong {
    font-size: 17px;
  }

  .net-split small {
    margin-left: 0;
  }

  .toolbar {
    padding: 12px 14px;
    gap: 10px;
  }

  .search-box {
    max-width: none;
    flex-basis: 100%;
    height: 44px;
  }

  .search-box input {
    font-size: 16px;
  }

  .toolbar select {
    height: 44px;
    font-size: 16px;
  }

  .asof-head {
    gap: 12px;
  }

  .asof-controls {
    width: 100%;
  }

  .asof-controls input[type="date"] {
    flex: 1;
    height: 44px;
    font-size: 16px;
  }

  .asof-quick {
    gap: 6px;
  }

  .range-tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    width: 100%;
  }

  .range-tabs button {
    padding: 7px 4px;
  }

  .chart-legend {
    gap: 10px;
    font-size: 11px;
  }

  .chart-note {
    display: none;
  }

  .count-note {
    margin-left: 0;
  }

  .add-btn {
    flex: 1;
    height: 44px;
  }

  .history-list {
    padding: 4px 14px;
  }

  .rate-row {
    flex-wrap: nowrap;
    gap: 8px;
  }

  .rate-name {
    flex: 1;
    flex-basis: auto;
    min-width: 0;
  }

  .rate-eq {
    display: none;
  }

  .rate-input {
    margin-left: 0;
    flex: none;
  }

  .rate-input input {
    width: 104px;
    height: 42px;
    font-size: 16px;
  }

  .rate-input span {
    width: 26px;
  }

  .rate-fixed {
    width: auto;
    margin-left: auto;
    font-size: 11.5px;
  }

  .topbar-actions {
    gap: 6px;
  }

  .topbar .btn {
    padding: 7px 10px;
  }

  .user-chip {
    padding-right: 6px;
  }

  .user-name {
    max-width: 52px;
    font-size: 11.5px;
  }

  .account-actions .btn {
    flex: 1;
  }

  .member-row {
    flex-wrap: wrap;
  }

  .member-actions {
    width: 100%;
    justify-content: flex-end;
    margin-top: 2px;
  }

  .member-list {
    max-height: 38vh;
  }

  .member-add-actions .field-help {
    flex-basis: 100%;
  }

  .field-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

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

  .field input,
  .field select {
    height: 46px;
  }

  .field textarea {
    min-height: 70px;
  }

  .dialog-head {
    padding: 18px 20px 0;
  }

  .dialog-body {
    padding: 14px 20px 2px;
  }

  .dialog-actions {
    position: sticky;
    bottom: 0;
    padding: 14px 20px calc(16px + env(safe-area-inset-bottom));
    background: var(--surface);
  }

  .dialog-actions .btn {
    flex: 1;
    height: 44px;
  }

  dialog.dialog {
    width: 100%;
    max-width: 100%;
    margin: 0;
    position: fixed;
    inset: auto 0 0 0;
    border-radius: 22px 22px 0 0;
    border-bottom: 0;
    max-height: calc(100dvh - 18px);
    overflow-y: auto;
  }

  dialog.dialog[open] {
    animation: sheet-in 0.22s ease-out both;
  }
}
