/* jz.ouuoo.com — 记账 PWA (mobile-first, 褐色系呼应 ouuoo 品牌) */
:root {
  --bg:         #f8f0e5;
  --bg-card:    #fffaf0;
  --primary:    #8b4b2f;
  --primary-lt: #efe1cf;
  --danger:     #c53030;
  --success:    #38a169;
  --text:       #2c2118;
  --text-mute:  #7f6b56;
  --border:     #e8dccb;
  --radius:     14px;
  --shadow:     0 8px 24px rgba(80, 50, 20, .08);
  --tap-min:    48px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: linear-gradient(180deg, var(--primary-lt), var(--bg));
  color: var(--text);
  min-height: 100vh;
  overscroll-behavior-y: contain;
  -webkit-font-smoothing: antialiased;
}
input, button, select { font-family: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
a { color: var(--primary); text-decoration: none; }

/* ============ Layout ============ */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 90px;    /* space for bottom tabbar */
  position: relative;
}
.safe-top    { padding-top: env(safe-area-inset-top); }
.safe-bottom { padding-bottom: env(safe-area-inset-bottom); }

/* ============ Login screen ============ */
.login {
  min-height: 100vh;
  display: flex; flex-direction: column;
  justify-content: center; padding: 30px;
}
.login h1 { font-size: 28px; margin: 0 0 8px; color: var(--primary); text-align: center; }
.login p  { text-align: center; color: var(--text-mute); margin: 0 0 32px; }
.login .field {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.login .field label { display: block; font-size: 12px; color: var(--text-mute); margin-bottom: 4px; }
.login .field input {
  width: 100%; border: 0; background: transparent;
  font-size: 16px; outline: none;
}
.login button {
  width: 100%; padding: 14px;
  background: var(--primary); color: #fff;
  border-radius: 12px; font-size: 16px; font-weight: 600;
  margin-top: 8px;
  min-height: var(--tap-min);
}
.login .err { color: var(--danger); text-align: center; font-size: 13px; margin-top: 12px; min-height: 20px; }

/* ============ Top bar ============ */
.topbar {
  position: sticky; top: 0; z-index: 90;
  padding: 14px 18px 10px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: linear-gradient(180deg, var(--primary-lt) 60%, rgba(239, 225, 207, 0));
  display: flex; align-items: center; gap: 10px;
}
.book-switch {
  flex: 1;
  display: flex; align-items: center; gap: 6px;
  font-size: 17px; font-weight: 700; color: var(--text);
  padding: 8px 12px; min-height: 40px;
  background: rgba(255, 250, 240, .8);
  border-radius: 20px;
  border: 1px solid var(--border);
}
.book-switch .icon { font-size: 20px; }
.book-switch .arrow { color: var(--text-mute); font-size: 12px; margin-left: auto; }

.topbar .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 700;
}

/* ============ Summary card (home) ============ */
.hero {
  margin: 0 16px 12px;
  padding: 22px 20px;
  background: linear-gradient(135deg, #a05a37, #6d3820);
  color: #fff;
  border-radius: 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.hero .label { font-size: 12px; opacity: .85; margin-bottom: 6px; letter-spacing: 1px; }
.hero .amount { font-size: 34px; font-weight: 800; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.hero .amount .cur { font-size: 20px; font-weight: 500; opacity: .8; margin-right: 4px; }
.hero .foot { display: flex; margin-top: 14px; gap: 20px; font-size: 12px; opacity: .9; }
.hero .foot b { display: block; font-size: 15px; font-weight: 700; margin-top: 2px; }

.hero-lit {
  margin: 0 16px 14px;
  padding: 16px 18px;
  background: var(--bg-card);
  border-radius: 16px;
  border: 1.5px solid #f0d68a;
  box-shadow: var(--shadow);
}
.hero-lit .title { font-size: 12px; color: #8b6b2f; letter-spacing: .5px; font-weight: 700; }
.hero-lit .amount { font-size: 26px; font-weight: 800; color: var(--primary); margin-top: 4px; font-variant-numeric: tabular-nums; }
.hero-lit .amount .cur { font-size: 15px; opacity: .7; margin-right: 4px; }
.hero-lit .breakdown { margin-top: 8px; font-size: 12px; color: var(--text-mute); }
.hero-lit .breakdown span { margin-right: 12px; }

/* ============ Section title ============ */
.section-title {
  font-size: 13px; font-weight: 700; color: var(--text-mute);
  margin: 18px 20px 8px; letter-spacing: 1px;
}

/* ============ Transaction list ============ */
.txlist {
  margin: 0 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}
.tx-day {
  padding: 10px 16px 6px;
  font-size: 12px; color: var(--text-mute);
  display: flex; justify-content: space-between;
  background: rgba(239, 225, 207, .3);
  border-top: 1px solid var(--border);
}
.tx-day:first-child { border-top: 0; }
.tx-day .sum { font-family: monospace; }

.tx-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid #f2ebde;
  min-height: 60px;
}
.tx-item:active { background: var(--primary-lt); }
.tx-icon {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; font-size: 20px;
  background: var(--primary-lt); color: var(--primary);
  flex-shrink: 0;
}
.tx-info { flex: 1; min-width: 0; }
.tx-info .name { font-size: 15px; font-weight: 600; }
.tx-info .meta { font-size: 12px; color: var(--text-mute); margin-top: 2px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tx-info .meta .tag {
  padding: 1px 6px; border-radius: 5px; font-size: 10.5px;
  background: var(--primary-lt); color: var(--primary);
}
.tx-info .meta .tag.support-medical  { background: #fef3c7; color: #92400e; }
.tx-info .meta .tag.support-refund   { background: #dcfce7; color: #166534; }
.tx-info .meta .tag.support-caregiver{ background: #dbeafe; color: #1e40af; }
.tx-info .meta .tag.lawyer           { background: #e0e7ff; color: #3730a3; }
.tx-info .meta .tag.unsupported      { background: #fee2e2; color: #991b1b; }
.tx-amt {
  font-size: 16px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tx-amt.out { color: var(--text); }
.tx-amt.in  { color: var(--success); }

/* ============ FAB (floating action button) ============ */
.fab {
  position: fixed; bottom: 90px; right: 24px;
  bottom: calc(90px + env(safe-area-inset-bottom));
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: grid; place-items: center;
  font-size: 30px; font-weight: 300;
  box-shadow: 0 6px 20px rgba(139, 75, 47, .5);
  z-index: 95;
  transition: transform .15s;
}
.fab:active { transform: scale(.9); }

/* ============ Bottom tabbar ============ */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-width: 480px; margin: 0 auto;
  display: flex;
  background: rgba(255, 250, 240, .95);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 90;
}
.tabbar button {
  flex: 1; padding: 10px 4px 8px;
  color: var(--text-mute); font-size: 11px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-height: var(--tap-min);
}
.tabbar button.active { color: var(--primary); }
.tabbar button .ic { font-size: 22px; line-height: 1; }

/* ============ Modal / bottom sheet ============ */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(30, 20, 15, .5);
  z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-width: 480px; margin: 0 auto;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  z-index: 201;
  transform: translateY(100%);
  transition: transform .25s cubic-bezier(.4, 0, .2, 1);
  max-height: 92vh;
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet.open { transform: translateY(0); }
.sheet .grip {
  width: 40px; height: 4px; background: #d9c8ad;
  border-radius: 2px; margin: 8px auto 4px;
}
.sheet-title {
  padding: 10px 20px 12px;
  font-size: 17px; font-weight: 700;
  display: flex; justify-content: space-between; align-items: center;
}
.sheet-title .close {
  color: var(--text-mute); font-size: 20px; padding: 4px 8px;
}

/* ============ Book picker ============ */
.book-list { padding: 4px 12px 16px; }
.book-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 12px;
  min-height: var(--tap-min);
  border-radius: 12px;
}
.book-row:active, .book-row.active { background: var(--primary-lt); }
.book-row .icon { font-size: 26px; }
.book-row .name { flex: 1; font-size: 16px; font-weight: 600; }
.book-row .check { color: var(--primary); font-size: 18px; }

/* ============ Loading / empty ============ */
.loading, .empty {
  text-align: center; padding: 40px 20px;
  color: var(--text-mute); font-size: 14px;
}
.empty .ic { font-size: 48px; margin-bottom: 12px; }

/* ============ Utility ============ */
.mono { font-family: -apple-system-monospace, monospace; }
.mute { color: var(--text-mute); }
.center { text-align: center; }

/* ============ Quick add sheet ============ */
.qa-sheet .sheet-title { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.qa-sheet .sheet-title .save {
  color: var(--primary); font-weight: 700; font-size: 16px;
  padding: 6px 12px;
}
.qa-sheet .sheet-title .save:disabled { opacity: .35; }

.qa-amount {
  padding: 24px 20px 20px;
  text-align: right;
  font-size: 44px; font-weight: 800;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
  background: linear-gradient(180deg, #fffaf0, var(--bg));
  border-bottom: 1px solid var(--border);
}
.qa-amount .cur { font-size: 22px; opacity: .6; margin-right: 6px; }
.qa-amount.zero { color: #bfa080; }
.qa-amount.income { color: var(--success); }

.qa-dir {
  display: flex; gap: 8px;
  padding: 10px 16px;
  background: var(--bg);
}
.qa-dir button {
  flex: 1; padding: 8px 0;
  border-radius: 10px;
  font-size: 13px; font-weight: 600;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  color: var(--text-mute);
  min-height: 38px;
}
.qa-dir button.on {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.qa-dir button.on.income { background: var(--success); border-color: var(--success); }

.qa-meta {
  padding: 8px 16px 4px;
  display: flex; gap: 6px; flex-wrap: wrap;
  font-size: 12.5px;
}
.qa-meta .chip {
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text-mute);
  min-height: 32px;
  display: inline-flex; align-items: center; gap: 4px;
}
.qa-meta .chip.filled { color: var(--text); font-weight: 600; }

.qa-cats {
  padding: 8px 12px 4px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.qa-cats button {
  min-height: 62px;
  padding: 8px 4px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11.5px;
  color: var(--text);
}
.qa-cats button .ic { font-size: 22px; line-height: 1; }
.qa-cats button.on {
  background: var(--primary-lt);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 700;
}

.qa-pad {
  padding: 8px 8px 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.qa-pad button {
  height: 52px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 22px; font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.qa-pad button:active { background: var(--primary-lt); }
.qa-pad button.ok {
  background: var(--primary); color: #fff; border-color: var(--primary);
  grid-row: span 2;
  height: auto;
  font-size: 18px;
}
.qa-pad button.ok.income { background: var(--success); border-color: var(--success); }
.qa-pad button.ok:disabled { opacity: .4; }
.qa-pad button.wide { font-size: 20px; }

/* Picker generic sub-sheet */
.picker {
  padding: 8px 12px 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}
.picker .row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px;
  min-height: var(--tap-min);
  border-radius: 10px;
}
.picker .row:active, .picker .row.active { background: var(--primary-lt); }
.picker .row .ic { font-size: 22px; }
.picker .row .name { flex: 1; font-size: 15px; }
.picker input.text {
  width: 100%; padding: 14px 16px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 16px;
  outline: none;
}
.picker input.text:focus { border-color: var(--primary); }

.picker .actions {
  display: flex; gap: 10px; margin-top: 14px;
}
.picker .actions button {
  flex: 1; padding: 14px;
  border-radius: 12px;
  font-size: 15px; font-weight: 600;
  min-height: var(--tap-min);
}
.picker .actions .cancel {
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-mute);
}
.picker .actions .confirm {
  background: var(--primary); color: #fff;
}

/* Tx detail action row */
.tx-detail-actions {
  display: flex; gap: 10px; padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.tx-detail-actions button {
  flex: 1; padding: 12px;
  border-radius: 10px; font-size: 14px; font-weight: 600;
  min-height: var(--tap-min);
}
.tx-detail-actions .del { background: #fee2e2; color: #991b1b; }
.tx-detail-actions .edit { background: var(--primary); color: #fff; }

.toast {
  position: fixed; bottom: 110px; left: 50%; transform: translateX(-50%);
  background: rgba(30, 20, 15, .9); color: #fff;
  padding: 12px 22px; border-radius: 24px;
  font-size: 14px; z-index: 300;
  animation: toast-in .2s;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 20px); } }

