/* ============================================================
   花花环游记 · 旅行账本
   ============================================================ */

:root {
  --bg: #fbf8f3;
  --bg-deep: #f4eee4;
  --surface: #ffffff;
  --surface-2: #f8f4ed;
  --surface-3: #f2ece1;
  --line: #ece4d8;
  --line-strong: #ddd2c0;

  --text: #2b2620;
  --text-2: #6d6357;
  --text-3: #9c9184;

  --accent: #c96a38;
  --accent-deep: #a5522a;
  --accent-soft: #fbeee4;
  --accent-line: #f0d5c1;

  --green: #2f7a5f;
  --green-soft: #e7f3ed;
  --red: #c04a34;
  --red-soft: #fbeae5;
  --blue: #46689b;
  --blue-soft: #ecf0f8;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 8px;

  --shadow-sm: 0 1px 2px rgba(43, 38, 32, 0.04), 0 2px 8px -4px rgba(43, 38, 32, 0.08);
  --shadow: 0 1px 2px rgba(43, 38, 32, 0.04), 0 10px 30px -18px rgba(43, 38, 32, 0.22);
  --shadow-lg: 0 24px 60px -24px rgba(43, 38, 32, 0.32), 0 2px 8px rgba(43, 38, 32, 0.06);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Roboto Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.55;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--text); }
svg { display: block; }
.hidden { display: none !important; }
.mobile-only { display: none !important; }

::selection { background: var(--accent-soft); color: var(--accent-deep); }

/* 滚动条 */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; border: 2px solid var(--bg); }
*::-webkit-scrollbar-thumb:hover { background: #c9bca7; }

/* ============================================================ 登录 */

.login-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1000px 560px at 50% -10%, #fdf1e5 0%, rgba(253, 241, 229, 0) 65%),
    var(--bg);
  z-index: 200;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 40px 32px 32px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-card .brand-mark { margin: 0 auto 18px; width: 56px; height: 56px; }
.login-card h1 { font-size: 22px; letter-spacing: 0.02em; }
.login-sub { color: var(--text-3); font-size: 13px; margin-top: 6px; }
.login-card form { margin-top: 24px; display: grid; gap: 12px; }
.login-card input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  outline: none;
  transition: 0.16s;
  text-align: center;
  letter-spacing: 0.2em;
}
.login-card input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.login-error { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ============================================================ 顶栏 */

.topbar {
  position: relative;
  background:
    radial-gradient(900px 420px at 12% -30%, #fdf0e3 0%, rgba(253, 240, 227, 0) 62%),
    radial-gradient(700px 380px at 92% -40%, #eef4ef 0%, rgba(238, 244, 239, 0) 60%),
    var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 22px 0 0;
}

.topbar-inner,
.stats-strip,
.main {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding-left: 28px;
  padding-right: 28px;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 20px;
}

.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark { width: 42px; height: 42px; flex: none; }
.brand-mark svg { width: 100%; height: 100%; border-radius: 12px; }
.brand-text h1 {
  font-size: 19px;
  letter-spacing: 0.01em;
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.brand-dot { color: var(--accent); font-weight: 400; }
.brand-text p { font-size: 12.5px; color: var(--text-3); margin-top: 1px; letter-spacing: 0.02em; }

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

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  transition: 0.16s;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 9px; }
.icon-btn.sm svg { width: 16px; height: 16px; }

/* 统计卡片 */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 17px 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--line-strong);
  opacity: 0.7;
}
.stat-card:nth-child(1)::after { background: var(--red); }
.stat-card:nth-child(2)::after { background: var(--green); }
.stat-card:nth-child(3)::after { background: var(--accent); }
.stat-card:nth-child(4)::after { background: var(--blue); }

.stat-label { font-size: 12px; color: var(--text-3); letter-spacing: 0.04em; }
.stat-value {
  font-size: 24px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.stat-value.expense { color: var(--red); }
.stat-value.income { color: var(--green); }
.stat-foot { font-size: 11.5px; color: var(--text-3); }

/* ============================================================ 工具条 */

.main { padding-bottom: 48px; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 22px 0 16px;
}

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

.select {
  appearance: none;
  height: 36px;
  padding: 0 30px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%239c9184' stroke-width='1.6'%3E%3Cpath d='M3 5l3 3 3-3'/%3E%3C/svg%3E") no-repeat right 10px center/12px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  transition: 0.16s;
  max-width: 160px;
  text-overflow: ellipsis;
}
.select:hover { border-color: var(--accent-line); }
.select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}
.search-box svg {
  position: absolute;
  left: 11px;
  width: 15px;
  height: 15px;
  color: var(--text-3);
  pointer-events: none;
}
.search-box input {
  height: 36px;
  width: 200px;
  padding: 0 12px 0 33px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  background: var(--surface);
  outline: none;
  transition: 0.16s;
  font-size: 13px;
}
.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); width: 240px; }
.search-box input::placeholder { color: var(--text-3); }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 550;
  transition: 0.16s;
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; flex: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(165, 82, 42, 0.2), 0 6px 16px -8px rgba(201, 106, 56, 0.6);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-deep); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }

.btn-ghost {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--text-2);
}
.btn-ghost:hover:not(:disabled) { border-color: var(--accent-line); color: var(--accent-deep); background: var(--accent-soft); }

.btn-danger-ghost { color: var(--red); border-color: #ecd3cc; }
.btn-danger-ghost:hover:not(:disabled) { color: #9c3a28; border-color: #e0b8ae; background: var(--red-soft); }

.btn-block { width: 100%; }

.mini-btn {
  height: 28px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 12px;
  color: var(--text-2);
  transition: 0.16s;
}
.mini-btn:hover { border-color: var(--accent-line); color: var(--accent-deep); background: var(--accent-soft); }
.mini-btn.danger:hover { border-color: #e7c4bb; color: var(--red); background: var(--red-soft); }

/* ============================================================ 表格 */

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

.table-head-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  min-height: 54px;
  flex-wrap: wrap;
}

.table-title { display: flex; align-items: center; gap: 9px; }
.table-title h2 { font-size: 15px; }

.chip {
  display: inline-flex;
  align-items: center;
  height: 21px;
  padding: 0 8px;
  border-radius: 99px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.filter-reset {
  height: 22px;
  padding: 0 9px;
  font-size: 11.5px;
  border-style: dashed;
  color: var(--accent-deep);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}
.filter-reset:hover { background: #f7e2d3; }

.bulk-bar { display: flex; align-items: center; gap: 8px; animation: fadeIn 0.2s ease; }
.bulk-count { font-size: 12.5px; color: var(--text-2); }
.bulk-count b { color: var(--accent-deep); font-variant-numeric: tabular-nums; }

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

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

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-2);
  letter-spacing: 0.02em;
  white-space: nowrap;
  user-select: none;
}
.data-table thead th.sortable { cursor: pointer; }
.data-table thead th.sortable:hover { color: var(--accent-deep); background: var(--surface-3); }
.data-table thead th.sortable::after {
  content: "↕";
  opacity: 0.25;
  margin-left: 4px;
  font-size: 10px;
}
.data-table thead th.sort-asc::after { content: "↑"; opacity: 1; color: var(--accent); }
.data-table thead th.sort-desc::after { content: "↓"; opacity: 1; color: var(--accent); }

.data-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid #f5f0e7;
  vertical-align: middle;
  color: var(--text);
}
.data-table tbody tr { transition: background 0.12s; }
.data-table tbody tr:hover { background: #fdfbf7; }
.data-table tbody tr.selected { background: var(--accent-soft); }
.data-table tbody tr.selected:hover { background: #f9e7da; }

.col-check { width: 40px; text-align: center; }
.col-idx { width: 52px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.col-date { width: 104px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.col-city { width: 96px; }
.col-cat { width: 116px; }
.col-amount { width: 118px; text-align: right; }
.col-method { width: 84px; }
.col-status { width: 90px; }
.col-note { width: 120px; color: var(--text-3); font-size: 12.5px; }
.col-ops { width: 76px; }

td.col-amount, th.col-amount { text-align: right; font-variant-numeric: tabular-nums; }
.data-table thead th.col-amount { text-align: right; }
.data-table thead th.col-ops { text-align: center; }

.amount-cell {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.amount-cell.expense { color: var(--red); }
.amount-cell.income { color: var(--green); }

.desc-cell { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-cell { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 550;
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--text-2);
}
.tag::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.75;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 550;
  white-space: nowrap;
}
.status-pill.s-pending { background: #fdf3e3; color: #a8730f; }
.status-pill.s-done { background: var(--green-soft); color: var(--green); }
.status-pill.s-private { background: var(--surface-3); color: var(--text-3); }

.row-ops { display: flex; gap: 2px; justify-content: center; }
.row-btn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  border-radius: 7px;
  color: var(--text-3);
  transition: 0.14s;
  opacity: 0.45;
}
.data-table tbody tr:hover .row-btn { opacity: 1; }
.row-btn svg { width: 15px; height: 15px; }
.row-btn:hover { background: var(--accent-soft); color: var(--accent-deep); }
.row-btn.del:hover { background: var(--red-soft); color: var(--red); }

.data-table tfoot td {
  padding: 12px;
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--text-2);
}
.total-label { font-weight: 600; color: var(--text); }
.total-amount {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  color: var(--text);
}
.total-detail { color: var(--text-3); font-variant-numeric: tabular-nums; }
.total-detail b { color: var(--text-2); font-weight: 600; }
.total-detail .in { color: var(--green); }
.total-detail .out { color: var(--red); }

/* 移动卡片 */
.card-list { display: none; padding: 10px; gap: 9px; flex-direction: column; }

.t-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
  background: var(--surface);
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  column-gap: 10px;
  gap: 7px;
  transition: 0.15s;
}
.t-card:has(.card-check:checked) { border-color: var(--accent-line); background: var(--accent-soft); }
.card-check {
  appearance: none;
  width: 17px;
  height: 17px;
  margin-top: 2px;
  border: 1.5px solid #c9bda9;
  border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: 0.12s;
}
.card-check:checked { background: var(--accent); border-color: var(--accent); }
.card-check:checked::after {
  content: '';
  width: 9px;
  height: 5px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translate(0.5px, -1px);
}
.t-card-main { display: grid; gap: 7px; min-width: 0; }
.t-card:active { background: var(--surface-2); }
.t-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.t-card-desc { font-weight: 600; font-size: 13.5px; line-height: 1.4; }
.t-card-amt { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; white-space: nowrap; }
.t-card-amt.expense { color: var(--red); }
.t-card-amt.income { color: var(--green); }
.t-card-meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-3); }
.t-card-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--line-strong); }

/* 空状态 */
.table-card.is-empty .table-head-bar,
.table-card.is-empty .table-wrap,
.table-card.is-empty .card-list { display: none; }

.empty-state { padding: 56px 24px 60px; text-align: center; }
.empty-illus { width: 132px; margin: 0 auto 18px; }
.empty-illus svg { width: 100%; height: auto; }
.empty-state h3 { font-size: 16px; margin-bottom: 6px; }
.empty-state p { color: var(--text-3); font-size: 13px; }
.empty-actions { display: flex; gap: 10px; justify-content: center; margin-top: 20px; }

/* ============================================================ 统计区 */

.analytics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px 18px;
  min-width: 0;
}
.panel-wide { grid-column: 1 / -1; }

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.panel-head h3 { font-size: 13.5px; font-weight: 600; }
.panel-hint { font-size: 11.5px; color: var(--text-3); }

.bar-list { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

/* 两行式：第一行「名称 + 金额」，第二行整条条形。
   不用固定列宽、也不依赖媒体查询，任何屏幕宽度都不会溢出或被裁。 */
.bar-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  padding: 6px;
  margin: 0 -6px;
  border-radius: 8px;
  transition: background 0.15s ease;
}
.bar-row:hover { background: var(--surface-2); }

.bar-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.bar-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12.5px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  display: block;
  width: 100%;
  min-width: 0;
  height: 8px;
  border-radius: 99px;
  background: linear-gradient(180deg, rgba(120, 96, 72, 0.11), rgba(120, 96, 72, 0.05));
  box-shadow: inset 0 1px 2px rgba(120, 96, 72, 0.06);
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  min-width: 4px;
  border-radius: 99px;
  background-color: var(--bar-color, var(--accent));
  background-image: linear-gradient(90deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0) 72%);
  box-shadow: 0 1px 3px rgba(120, 96, 72, 0.18);
  transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.bar-val {
  flex: 0 0 auto;
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: nowrap;
}
.bar-val small {
  margin-left: 5px;
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 500;
}

.bar-empty {
  padding: 20px 0;
  text-align: center;
  color: var(--text-3);
  font-size: 12.5px;
}

.trend-chart { width: 100%; overflow-x: auto; }
.trend-chart svg { display: block; }

/* ============================================================ 页脚 */

.foot {
  margin-top: 26px;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex-wrap: wrap;
}
.foot-sep { opacity: 0.5; }

/* ============================================================ 弹窗 */

.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(43, 38, 32, 0.34);
  backdrop-filter: blur(3px);
  animation: fadeIn 0.2s ease;
}

.modal-panel {
  position: relative;
  width: 100%;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  animation: popIn 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}
.modal-sm { max-width: 480px; }
.modal-lg { max-width: 880px; }

/* 分享图预览弹窗 */
.share-panel { max-width: 560px; }
.share-body { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.share-body img {
  max-width: 100%;
  max-height: 56vh;
  border-radius: 10px;
  border: 1px solid var(--line);
  box-shadow: 0 4px 18px rgba(43, 38, 32, 0.12);
}
.share-tip { font-size: 12px; color: var(--text-3); text-align: center; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.modal-head h3 { font-size: 15.5px; }

.modal-body { padding: 20px; overflow-y: auto; flex: 1; }

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  flex: none;
  margin: 20px -20px -20px;
}

.modal-tabs {
  display: flex;
  gap: 4px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex: none;
}
.tab {
  position: relative;
  padding: 12px 4px;
  margin-right: 20px;
  border: none;
  background: none;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--text-3);
  transition: 0.16s;
}
.tab::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  transform: scaleX(0);
  transition: transform 0.2s;
}
.tab.active { color: var(--accent-deep); }
.tab.active::after { transform: scaleX(1); }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* 分段控件 */
.seg-control {
  display: flex;
  gap: 3px;
  padding: 3px;
  background: var(--surface-3);
  border-radius: 10px;
  margin-bottom: 18px;
}
.seg {
  flex: 1;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 550;
  color: var(--text-2);
  transition: 0.16s;
}
.seg.active { background: var(--surface); box-shadow: var(--shadow-sm); color: var(--accent-deep); }
.seg[data-type="income"].active { color: var(--green); }

/* 表单 */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-full { grid-column: 1 / -1; }
.field > span { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.field input,
.field select {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  background: var(--surface);
  outline: none;
  transition: 0.16s;
  width: 100%;
}
.field input:focus,
.field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input::placeholder { color: var(--text-3); }
.field input[type="number"]::-webkit-outer-spin-button,
.field input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.field input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.field-hint { font-size: 11.5px; color: var(--text-3); margin-top: 6px; }

/* 拖拽区 */
.dropzone {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 34px 20px;
  text-align: center;
  background: var(--surface-2);
  cursor: pointer;
  transition: 0.18s;
}
.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone svg { width: 30px; height: 30px; margin: 0 auto 10px; color: var(--accent); }
.dropzone p { font-size: 13.5px; color: var(--text-2); }
.dropzone small { display: block; margin-top: 5px; font-size: 11.5px; color: var(--text-3); }

/* 预览 */
.import-preview { margin-top: 18px; animation: fadeIn 0.24s ease; }

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  flex-wrap: wrap;
}
.preview-head strong { font-size: 13.5px; margin-right: 8px; }
.preview-actions { display: flex; align-items: center; gap: 10px; }

.mini-check { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.mini-check input { accent-color: var(--accent); }

.inline-field { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.inline-field input {
  height: 28px;
  width: 108px;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  outline: none;
  transition: 0.16s;
  font-size: 12.5px;
}
.inline-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.preview-table-wrap {
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.preview-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.preview-table th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 11.5px;
  color: var(--text-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  z-index: 1;
}
.preview-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #f6f1e8;
  vertical-align: middle;
}
.preview-table tr:last-child td { border-bottom: none; }
.preview-table .ta-r { text-align: right; }
.preview-table .num { font-variant-numeric: tabular-nums; font-weight: 600; }
.preview-table .num.expense { color: var(--red); }
.preview-table .num.income { color: var(--green); }

.preview-table.editable td[contenteditable] {
  outline: none;
  border-radius: 5px;
  padding: 5px 7px;
  margin: 1px;
  min-width: 40px;
}
.preview-table.editable td[contenteditable]:focus {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}
.preview-table .dup-row { background: #fdfaf3; }
.preview-table .dup-row td { color: var(--text-3); }

.preview-tip { margin-top: 10px; font-size: 11.5px; color: var(--text-3); }

.raw-box {
  margin-top: 14px;
  max-height: 200px;
  overflow: auto;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-all;
}

/* OCR 进度 */
.ocr-progress { margin-top: 18px; }
.ocr-progress-head {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--text-2);
  margin-bottom: 7px;
  font-variant-numeric: tabular-nums;
}
.progress-track { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #e29a63);
  border-radius: 99px;
  transition: width 0.3s ease;
}
.ocr-thumbs { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.ocr-thumb {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.ocr-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.ocr-thumb.done::after {
  content: "✓";
  position: absolute;
  inset: auto 3px 3px auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 11px;
  display: grid;
  place-items: center;
}

/* 设置 */
.setting-block { margin-bottom: 24px; }
.setting-block:last-child { margin-bottom: 0; }
.setting-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.setting-title h4 { font-size: 13.5px; }
.setting-desc { font-size: 12.5px; color: var(--text-3); line-height: 1.65; margin-bottom: 14px; }
.setting-block .field { margin-bottom: 12px; }
.setting-actions { display: grid; gap: 8px; }

/* 设置 · 类别管理 */
.cat-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.cat-tag {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px 4px 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 12.5px;
  line-height: 1.5;
}
.cat-tag button {
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
  opacity: 0.55;
  font-size: 15px;
  line-height: 1;
  padding: 0 3px;
  border-radius: 50%;
}
.cat-tag button:hover { opacity: 1; background: rgba(201, 106, 56, 0.14); }
.cat-empty { font-size: 12.5px; color: var(--text-3); }
.cat-add { display: flex; gap: 8px; }
.cat-add input {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  background: var(--surface);
  outline: none;
  transition: 0.16s;
}
.cat-add input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cat-add .btn { flex: none; height: 38px; }

.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  inset: 0;
  background: var(--line-strong);
  border-radius: 99px;
  transition: 0.24s;
  cursor: pointer;
}
.slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.24s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.16);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* Toast */
.toast-wrap {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  background: #2b2620;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 10px 30px -10px rgba(43, 38, 32, 0.5);
  animation: toastIn 0.26s cubic-bezier(0.22, 1, 0.36, 1);
  max-width: 90vw;
}
.toast.success { background: #245f4a; }
.toast.error { background: #9c3a28; }
.toast.fade-out { animation: toastOut 0.24s ease forwards; }
.toast svg { width: 15px; height: 15px; flex: none; }

/* 动画 */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }
@keyframes rowIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ============================================================ 响应式 */

@media (max-width: 1080px) {
  .stats-strip { grid-template-columns: repeat(2, 1fr); }
  .analytics { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  /* 兜底：避免任何元素意外把整页撑宽，出现左右晃动 */
  body { overflow-x: hidden; }
  .topbar-inner, .stats-strip, .main { padding-left: 16px; padding-right: 16px; }
  .brand-text h1 { font-size: 16px; }
  .brand-text p { font-size: 11.5px; }
  .brand-mark { width: 36px; height: 36px; }
  .mobile-only { display: grid !important; }

  .toolbar { padding: 16px 0 12px; }
  .filters {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .select { width: 100%; max-width: none; height: 36px; }
  .search-box { grid-column: 1 / -1; }
  .search-box input { width: 100%; height: 36px; }
  .search-box input:focus { width: 100%; }
  .actions { width: 100%; gap: 8px; justify-content: flex-start; }
  .actions .btn { flex: 0 0 44px; padding: 0; }
  .actions .btn span { display: none; }
  .actions .btn-primary { flex: 1 1 auto; padding: 0 14px; }
  .actions .btn-primary span { display: inline; }
  .actions .btn svg { width: 16px; height: 16px; }

  .table-wrap { display: none; }
  .card-list { display: flex; }
  .table-head-bar { padding: 12px 14px; }
  .bulk-bar { flex-wrap: wrap; gap: 6px; }
  .bulk-bar .mini-btn { flex: 1 1 auto; }

  .stat-card { padding: 12px 14px; }
  .stat-value { font-size: 19px; }
  .stat-label { font-size: 11px; }
  .stat-foot { font-size: 10.5px; }

  .modal { padding: 0; place-items: end center; }
  .modal-panel {
    max-height: 92vh;
    border-radius: 20px 20px 0 0;
    max-width: 100%;
    animation: sheetIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .form-grid { grid-template-columns: 1fr; }
  .modal-body { padding: 16px; }
  .modal-foot { padding: 12px 16px; margin: 16px -16px -16px; }
  .modal-head { padding: 16px 16px 12px; }
  .modal-tabs { padding: 0 16px; }
  .empty-state { padding: 40px 20px 46px; }
}

/* 手机上改成两行式：第一行「名称 + 金额」，第二行整条条形。
   三列固定宽度在窄屏会把条形挤爆、金额裁掉，这样彻底避免溢出。 */
@media (max-width: 560px) {
  .analytics { gap: 10px; }
  .panel { padding: 14px 14px 16px; }
  .panel-head { margin-bottom: 10px; }
  .bar-row { padding: 6px; gap: 4px; }
  .bar-name { font-size: 12px; }
  .bar-val { font-size: 12px; }
  .bar-val small { font-size: 10px; padding: 0 4px; margin-left: 4px; }
  .bar-track { height: 7px; }
}

@keyframes sheetIn { from { transform: translateY(100%); } to { transform: none; } }

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