/* 海哥民宿记账系统 — 样式
   配色：海青主色 + 暖木辅色，兼顾报表可读性与民宿气质 */

:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f1efea;
  --line: #e5e2db;
  --line-soft: #eeece6;
  --brand: #2f7d8f;
  --brand-dk: #256474;
  --brand-lt: #e3eff1;
  --wood: #c49a6c;
  --wood-lt: #f2e8da;
  --ink: #25292b;
  --ink-2: #6d7477;
  --ink-3: #9aa1a4;
  --pos: #4a7c59;
  --pos-lt: #eaf2ec;
  --neg: #b5533f;
  --neg-lt: #fbeeeb;
  --warn: #c08a2e;
  --shadow: 0 1px 2px rgba(37, 41, 43, .05);
  --shadow-lg: 0 10px 30px rgba(37, 41, 43, .13);
  --radius: 12px;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --serif: Georgia, "Songti SC", "Noto Serif SC", serif;
  --sidebar-w: 216px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

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

.hidden { display: none !important; }

.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.muted { color: var(--ink-2); }
.dim { color: var(--ink-3); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }

/* ══════════ 口令遮罩 ══════════ */

.lock-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 460px at 50% -8%, #dfeaec 0%, transparent 62%),
    var(--bg);
}

.lock-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px 28px 24px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.lock-mark {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 22px;
  margin: 0 auto 14px;
}

.lock-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
}

.lock-sub {
  margin: 4px 0 18px;
  font-size: 12.5px;
  color: var(--ink-3);
}

.lock-error {
  background: var(--neg-lt);
  border: 1px solid #f0cdc5;
  color: var(--neg);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
  margin-bottom: 10px;
}

.lock-card .input { margin-bottom: 12px; }

/* ══════════ 布局 ══════════ */

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.sidebar-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 19px;
  flex: none;
}

.sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.sidebar-brand-text strong { font-size: 14.5px; font-weight: 600; }
.sidebar-brand-text span { font-size: 11.5px; color: var(--ink-3); }

.nav {
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  transition: background .15s, color .15s;
}

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

.nav-item.active {
  background: var(--brand-lt);
  color: var(--brand-dk);
  font-weight: 600;
}

.nav-item svg { flex: none; }

.sidebar-foot {
  padding: 12px 18px 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.7;
}

.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 56px;
  flex: none;
  background: rgba(246, 245, 242, .88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .01em;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.content {
  flex: 1;
  padding: 20px;
  max-width: 1280px;
  width: 100%;
}

.menu-btn { display: none !important; }
.sidebar-mask { display: none; }

/* ══════════ 按钮 / 表单 ══════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 15px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s, background .15s, opacity .15s;
  white-space: nowrap;
}

.btn:hover { border-color: #d3cfc6; background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn.primary:hover { background: var(--brand-dk); border-color: var(--brand-dk); }

.btn.danger {
  background: var(--neg);
  border-color: var(--neg);
  color: #fff;
}
.btn.danger:hover { opacity: .88; background: var(--neg); }

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

.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn.block { width: 100%; }
.btn.lg { padding: 11px 20px; font-size: 14px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

.input, .select {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.input:focus, .select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(47, 125, 143, .12);
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='14' height='14' fill='none' stroke='%236d7477' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 12px; color: var(--ink-2); font-weight: 500; }

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: all .15s;
}

.chip:hover { border-color: var(--brand); color: var(--brand-dk); }

.chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 500;
}

/* 类型选择芯片（记账页） */
.type-chips { display: flex; flex-wrap: wrap; gap: 7px; }

.type-chip {
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.type-chip:hover { border-color: var(--brand); color: var(--brand-dk); }

.type-chip.active {
  background: var(--brand-lt);
  border-color: var(--brand);
  color: var(--brand-dk);
  font-weight: 600;
}

.type-chip.active.expense { background: var(--neg-lt); border-color: #e0b3a8; color: var(--neg); }
.type-chip.active.income { background: var(--pos-lt); border-color: #b7d3bf; color: var(--pos); }

.type-chip .chip-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .55; }

.tag-last {
  font-size: 10px;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--wood-lt);
  color: #8a6b42;
  font-weight: 500;
}

/* ══════════ 卡片 / 栅格 ══════════ */

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

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.card-title { font-size: 14px; font-weight: 600; }
.card-sub { font-size: 12px; color: var(--ink-3); }
.card-body { padding: 16px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }

.stack { display: flex; flex-direction: column; gap: 14px; }

.toolbar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.toolbar .field { min-width: 140px; }
.toolbar-spacer { flex: 1; }

/* ══════════ KPI ══════════ */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px;
  box-shadow: var(--shadow);
}

.kpi-label { font-size: 12px; color: var(--ink-2); }

.kpi-value {
  font-size: 25px;
  font-weight: 650;
  letter-spacing: -.01em;
  margin: 4px 0 2px;
  line-height: 1.25;
}

.kpi-value small { font-size: 14px; font-weight: 500; margin-right: 1px; opacity: .65; }
.kpi-foot { font-size: 12px; color: var(--ink-3); }
.kpi-note { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }

/* ══════════ 图表 ══════════ */

.chart { width: 100%; height: auto; display: block; }

.chart-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 10px;
  margin-top: 6px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  color: var(--ink-2);
}

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

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  display: inline-block;
}

.donut-wrap { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }

.donut-center-value {
  font-size: 17px;
  font-weight: 650;
  fill: var(--ink);
  font-variant-numeric: tabular-nums;
}

.donut-center-label { font-size: 11px; fill: var(--ink-3); }

.bars { display: flex; flex-direction: column; gap: 11px; flex: 1; min-width: 200px; }

.bar-row { display: flex; flex-direction: column; gap: 4px; }

.bar-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  color: var(--ink-2);
}

.bar-label .num { color: var(--ink); font-weight: 500; }

.bar-track {
  height: 7px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.bar-fill { height: 100%; border-radius: 999px; }

/* ══════════ 表格 ══════════ */

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

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

.table th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--ink-2);
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  white-space: nowrap;
}

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

.table tbody tr:hover { background: #faf9f6; }
.table tbody tr:last-child td { border-bottom: none; }
.table tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--line); }

.cell-title { font-weight: 500; }
.cell-sub { font-size: 11.5px; color: var(--ink-3); }

.kind-pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
}

.kind-pill.income { background: var(--pos-lt); color: var(--pos); }
.kind-pill.expense { background: var(--neg-lt); color: var(--neg); }

.scene-pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  background: var(--surface-2);
  color: var(--ink-2);
}

.scene-pill.room { background: var(--brand-lt); color: var(--brand-dk); }
.scene-pill.restaurant { background: var(--wood-lt); color: #8a6b42; }

/* ══════════ 记账页 ══════════ */

.entry-layout { display: grid; grid-template-columns: minmax(320px, 400px) 1fr; gap: 14px; align-items: start; }

.amount-input {
  width: 100%;
  padding: 10px 12px 10px 30px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 26px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.amount-wrap { position: relative; }
.amount-wrap::before {
  content: "¥";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-52%);
  font-size: 19px;
  color: var(--ink-3);
  pointer-events: none;
}

.amount-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(47, 125, 143, .12);
}

.kind-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: 10px;
}

.kind-switch button {
  padding: 8px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}

.kind-switch button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.kind-switch button.active.income { color: var(--pos); }
.kind-switch button.active.expense { color: var(--neg); }

.form-actions { display: flex; gap: 8px; }
.form-actions .btn { flex: 1; }

.quick-dates { display: flex; gap: 6px; flex-wrap: wrap; }

.daily-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line-soft);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
}

.daily-summary > div { background: var(--surface); padding: 10px 12px; }
.daily-summary .ds-label { font-size: 11.5px; color: var(--ink-3); }
.daily-summary .ds-value { font-size: 16px; font-weight: 600; margin-top: 1px; font-variant-numeric: tabular-nums; }

/* ══════════ 设置页 ══════════ */

.setting-block { padding: 16px; border-bottom: 1px solid var(--line-soft); }
.setting-block:last-child { border-bottom: none; }
.setting-block-title { font-size: 14px; font-weight: 600; margin-bottom: 3px; }
.setting-block-desc { font-size: 12.5px; color: var(--ink-2); margin-bottom: 12px; line-height: 1.65; }

.cat-group { margin-bottom: 16px; }
.cat-group:last-child { margin-bottom: 0; }
.cat-group-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cat-group-title { font-size: 13px; font-weight: 600; }
.cat-list { display: flex; flex-wrap: wrap; gap: 6px; }

.cat-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 12.5px;
  color: var(--ink);
}

.cat-item.inactive { opacity: .45; text-decoration: line-through; }
.cat-item .cat-actions { display: flex; gap: 1px; }
.cat-item .mini-btn {
  border: none;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  display: inline-flex;
}
.cat-item .mini-btn:hover { color: var(--brand-dk); background: var(--surface-2); }
.cat-item .mini-btn.danger:hover { color: var(--neg); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--ink-2);
}

/* 类型变更日志 */
.type-log { display: flex; flex-direction: column; gap: 5px; }

.type-log-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 9px;
  background: var(--surface-2);
  border-radius: 7px;
  font-size: 12px;
}

.type-log-act {
  flex: none;
  padding: 0 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.act-create { background: var(--pos-lt); color: var(--pos); }
.act-update { background: var(--brand-lt); color: var(--brand-dk); }
.act-delete { background: var(--neg-lt); color: var(--neg); }
.act-restore { background: var(--wood-lt); color: #8a6b42; }

/* 名称可压缩并省略：一次恢复多个类型时名称很长，不能把整行撑破 */
.type-log-name {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.type-log-detail {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
}

.type-log-time { flex: none; font-size: 11px; }

.badge.warn { background: #fbf2e0; color: #8a6b42; }
.badge.brand { background: var(--brand-lt); color: var(--brand-dk); }

.danger-zone { border: 1px dashed #e6c6bf; border-radius: 10px; padding: 14px; background: #fdfaf9; }

/* ══════════ 弹窗 / Toast ══════════ */

.toast-host {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.toast {
  background: var(--ink);
  color: #fff;
  padding: 9px 15px;
  border-radius: 9px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: toast-in .18s ease-out;
  max-width: 340px;
}

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

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

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(30, 34, 36, .38);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  animation: fade-in .14s ease-out;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: 14px;
  width: 100%;
  max-width: 440px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modal-in .18s ease-out;
}

.modal.wide { max-width: 620px; }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.modal-title { font-size: 14.5px; font-weight: 600; }
.modal-body { padding: 16px; overflow-y: auto; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line-soft);
}

/* ══════════ 空状态 / 骨架 ══════════ */

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--ink-3);
}

.empty p { margin: 10px 0 0; font-size: 13px; }
.empty .empty-tip { font-size: 12px; color: var(--ink-3); margin-top: 4px; }

.skeleton {
  background: linear-gradient(90deg, #efece6 25%, #f7f5f1 50%, #efece6 75%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  border-radius: 8px;
}

.skeleton-kpi { height: 96px; }
.skeleton-block { height: 220px; border-radius: var(--radius); }

@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: 0 0; }
}

.error-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background: var(--neg-lt);
  border: 1px solid #f0cdc5;
  border-radius: 9px;
  color: var(--neg);
  font-size: 13px;
}

/* ══════════ 响应式 ══════════ */

@media (max-width: 900px) {
  .entry-layout { grid-template-columns: 1fr; }
}

/* ── 手机端适配（≤720px） ──
   目标：单手可录、拇指可达、表格变卡片 */

@media (max-width: 720px) {
  /* 触控尺寸与 iOS 防缩放（输入框字号 ≥16px） */
  .input, .select { font-size: 16px; padding: 10px 12px; }
  .btn { min-height: 40px; }
  .icon-btn { width: 38px; height: 38px; }
  .chip { padding: 7px 13px; }
  .type-chip { padding: 9px 13px; font-size: 13.5px; }

  /* 顶栏 */
  .topbar { height: 52px; padding: 0 12px; gap: 8px; }
  .topbar-title { font-size: 14.5px; }
  .topbar-right > .muted { display: none; }

  /* 内容与卡片 */
  .content { padding: 12px 12px 0; }
  .card-head { padding: 12px 13px; }
  .card-body { padding: 13px; }
  .setting-block { padding: 14px 13px; }

  /* KPI 两列 */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi { padding: 12px 13px; }
  .kpi-label { font-size: 11.5px; }
  .kpi-value { font-size: 19px; }
  .kpi-value small { font-size: 12px; }
  .kpi-foot, .kpi-note { font-size: 11px; }

  /* ── 录入页 ── */
  .entry-layout { padding-bottom: 76px; }
  .amount-input { font-size: 30px; padding: 12px 12px 12px 34px; min-height: 56px; }
  .amount-wrap::before { font-size: 21px; left: 13px; }
  .kind-switch button { padding: 11px; font-size: 14.5px; }
  .type-chip.is-last { order: -1; }
  .quick-dates { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .quick-dates .chip { width: 100%; }
  .daily-summary { grid-template-columns: 1fr; }
  .daily-summary > div { display: flex; align-items: baseline; justify-content: space-between; padding: 9px 13px; }
  .daily-summary .ds-value { font-size: 15px; margin-top: 0; }

  /* 底部固定记账按钮：拇指可达，录完一笔不用滚回顶部 */
  .form-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    gap: 10px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: rgba(246, 245, 242, .95);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
    box-shadow: 0 -3px 14px rgba(37, 41, 43, .07);
  }

  .form-actions .btn { height: 48px; font-size: 15px; }

  /* ── 明细表 → 卡片列表 ── */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  /* tr 必须是定位父级，否则卡片右上角的编辑/删除按钮会脱离卡片乱飘 */
  .table tr { padding: 10px 13px; border-bottom: 1px solid var(--line-soft); position: relative; }
  .table tbody tr:hover { background: transparent; }
  .table td {
    border: none;
    padding: 2px 0;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .table td::before {
    content: attr(data-label);
    flex: none;
    width: 38px;
    color: var(--ink-3);
    font-size: 12px;
    text-align: left; /* 不继承 td.right 的右对齐，保证标签左对齐 */
  }

  .table td:not([data-label])::before { content: none; }
  .table td[data-label="类型"] { font-size: 14px; }
  .table td[data-label="金额"] { font-size: 17px; font-weight: 650; }
  .table td[data-label="备注"] { font-size: 12.5px; color: var(--ink-3); }
  .table td.cell-actions {
    position: absolute;
    right: 6px;
    top: 6px;
    width: auto;
  }

  .table tfoot { display: block; background: var(--surface-2); }
  .table tfoot tr { border-bottom: none; }
  .table tfoot td { display: inline-flex; width: auto; margin-right: 14px; }

  /* ── 工具栏（报表页） ── */
  .toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .toolbar .field { min-width: 0; width: 100%; }
  .toolbar .chip-group { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
  .toolbar .chip { flex: none; }
  .toolbar-spacer { display: none; }

  /* ── 图表 ── */
  .chart { min-height: 190px; }
  .donut-wrap { flex-direction: column; align-items: stretch; }
  .donut-wrap svg { align-self: center; }
  .bars { min-width: 0; }

  /* ── 弹窗：从底部弹出 ── */
  .modal-mask { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: 92vh;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .modal-body { padding: 14px; }
  .modal-foot { position: sticky; bottom: 0; background: var(--surface); }
  .modal-foot .btn { flex: 1; }

  /* ── 设置页 ── */
  .field-row { grid-template-columns: 1fr; }
  .cat-item { font-size: 12px; padding: 4px 5px 4px 10px; }

  /* 类型变更日志：名称独占一行完整显示，不截断 */
  .type-log-row { flex-wrap: wrap; row-gap: 3px; }
  .type-log-name {
    flex: 1 1 100%;
    white-space: normal;
    overflow: visible;
    word-break: break-all;
    line-height: 1.5;
  }
  .cat-group-title { font-size: 12.5px; }

  /* Toast 上移，避开底部记账条 */
  .toast-host { left: 12px; right: 12px; bottom: 84px; align-items: center; }
  .toast { max-width: 100%; }

  /* 侧栏抽屉 */
  .menu-btn { display: inline-flex !important; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-mask {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(30, 34, 36, .35);
    z-index: 35;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
  }

  .sidebar-mask.show { opacity: 1; pointer-events: auto; }

  .main { margin-left: 0; }
}

/* 超窄屏（≤360px）微调 */
@media (max-width: 360px) {
  .content { padding: 10px 10px 0; }
  .kpi-value { font-size: 17px; }
  .amount-input { font-size: 26px; }
  .type-chip { padding: 8px 10px; font-size: 12.5px; }
}
