/* === 钱袋子 — 浅色财务产品设计系统 === */

:root {
  --page: #f4f0e9;
  --surface: #fffdf9;
  --surface-raised: #fffaf4;
  --surface-muted: #faf6f0;
  --primary: #c85f2b;
  --primary-dark: #9f431d;
  --primary-light: #f9e7dc;
  --accent-2: #2e6b63;
  --success: #2f7a55;
  --success-light: #e4f2ea;
  --danger: #b83d35;
  --danger-light: #f9e7e4;
  --warning: #a96e12;
  --warning-light: #f8edcf;
  --info: #2f7180;
  --info-light: #e2f0f2;
  --bg: var(--page);
  --text: #251b14;
  --text-secondary: #58493d;
  --text-muted: #7d6e60;
  --border: rgba(48, 32, 20, .1);
  --border-light: rgba(48, 32, 20, .06);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --shadow: 0 1px 2px rgba(60, 38, 20, .04), 0 8px 26px rgba(60, 38, 20, .035);
  --shadow-md: 0 18px 44px -28px rgba(60, 38, 20, .28);
  --focus-ring: 0 0 0 3px rgba(200, 95, 43, .16);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sidebar-width: 220px;
  --sidebar-bg: #faf6f0;
  --sidebar-hover: #f3e9dd;
  --sidebar-active: var(--primary-light);
  --topbar-height: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--page); }
body {
  min-height: 100vh;
  background:
    radial-gradient(600px 320px at 100% 0, rgba(200, 95, 43, .075), transparent 68%),
    var(--page);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* === App shell === */
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 100;
  width: var(--sidebar-width); height: 100vh;
  display: flex; flex-direction: column; overflow-y: auto;
  background: rgba(250, 246, 240, .94); color: var(--text-secondary);
  border-right: 1px solid var(--border);
  box-shadow: 8px 0 30px rgba(60, 38, 20, .035);
  backdrop-filter: blur(18px); transition: transform .24s cubic-bezier(.16, 1, .3, 1);
}
.sidebar-brand {
  min-height: var(--topbar-height); padding: 0 20px;
  display: flex; align-items: center; gap: 11px;
  border-bottom: 1px solid var(--border-light);
}
.sidebar-brand svg { width: 27px; height: 27px; stroke: var(--primary); fill: none; stroke-width: 1.8; flex-shrink: 0; }
.sidebar-brand span { color: var(--text); font-size: 17px; font-weight: 760; letter-spacing: -.02em; }
.sidebar-nav { flex: 1; padding: 18px 12px; }
.nav-item {
  min-height: 44px; margin: 3px 0; padding: 0 13px;
  display: flex; align-items: center; gap: 11px;
  color: var(--text-muted); border-radius: 12px;
  text-decoration: none; font-size: 13px; font-weight: 590;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--text); transform: translateX(2px); }
.nav-item.active { background: var(--sidebar-active); color: var(--primary-dark); box-shadow: inset 0 0 0 1px rgba(200, 95, 43, .08); }
.nav-item svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.sidebar-footer { padding: 14px 20px 18px; color: var(--text-muted); border-top: 1px solid var(--border-light); font-size: 11px; }

.main-area { min-height: 100vh; margin-left: var(--sidebar-width); display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-height); padding: 0 26px;
  display: flex; align-items: center; justify-content: space-between;
  color: var(--text); background: rgba(231, 221, 210, .94);
  border-bottom: 1px solid rgba(60, 38, 20, .12);
  box-shadow: 0 8px 24px -22px rgba(60, 38, 20, .42);
  backdrop-filter: blur(18px);
}
.topbar-left { min-width: 0; display: flex; align-items: center; gap: 12px; }
.topbar-icon {
  width: 36px; height: 36px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  color: var(--primary); background: var(--primary-light); border-radius: 11px;
  box-shadow: inset 0 0 0 1px rgba(200, 95, 43, .08);
}
.topbar-icon svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.topbar h1 { overflow: hidden; color: var(--text); font-size: 17px; font-weight: 720; letter-spacing: -.02em; text-overflow: ellipsis; white-space: nowrap; }
.topbar-meta { color: #716052; font-size: 12px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.icon-btn, .hamburger {
  width: 40px; height: 40px; padding: 0; border: 1px solid var(--border); border-radius: 12px;
  background: rgba(255, 250, 244, .72); color: var(--text-secondary); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color .18s ease, background .18s ease, border-color .18s ease, transform .12s ease;
}
.icon-btn:hover, .hamburger:hover { color: var(--primary); background: var(--surface); border-color: rgba(200, 95, 43, .24); }
.icon-btn:active, .hamburger:active { transform: scale(.96); }
.icon-btn svg, .hamburger svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.shop-switcher { display: flex; align-items: center; gap: 8px; color: #716052; font-size: 12px; font-weight: 600; }
.shop-switcher select {
  min-width: 180px; height: 40px; padding: 0 34px 0 12px;
  border: 1px solid rgba(60, 38, 20, .12); border-radius: 12px;
  background: rgba(255, 250, 244, .84); color: var(--text); cursor: pointer;
}
.shop-switcher option { color: var(--text); }
.hamburger { display: none; margin-right: 2px; }
.sidebar-overlay { display: none; position: fixed; inset: 0; z-index: 99; background: rgba(37, 27, 20, .32); backdrop-filter: blur(2px); }
.sidebar-overlay.active { display: block; }
.content-area { flex: 1; padding: 24px 26px 40px; }
.container { width: 100%; max-width: 1440px; margin: 0 auto; }

/* === Controls === */
.filters {
  margin-bottom: 18px; padding: 16px 18px;
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  background: rgba(255, 253, 249, .9); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.filter-group { display: flex; flex-direction: column; gap: 6px; }
.filter-group label { color: var(--text-muted); font-size: 11px; font-weight: 680; letter-spacing: .035em; }
.filter-group input, .filter-group select {
  min-width: 140px; height: 40px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 13px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.filter-group input:hover, .filter-group select:hover { border-color: rgba(200, 95, 43, .22); }
.filter-group input:focus, .filter-group select:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }
.btn {
  min-height: 40px; padding: 0 18px; border: 1px solid transparent; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 650; cursor: pointer;
  transition: background .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease, transform .12s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fffaf5; box-shadow: 0 8px 20px rgba(200, 95, 43, .18); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 10px 24px rgba(159, 67, 29, .22); }
.btn-success { background: var(--success); color: #f7fff9; }
.btn-success:hover { background: #286849; }
.btn-danger { background: var(--danger); color: #fff9f8; }
.btn-danger:hover { background: #9e302a; }
.btn-sm { min-height: 32px; padding: 0 11px; font-size: 12px; }

/* === Surfaces & data === */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card, .chart-box, .section, .receipt-section, .table-section {
  background: rgba(255, 253, 249, .94); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card {
  min-height: 126px; padding: 18px 19px; position: relative; overflow: hidden;
  transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease;
}
.card:hover { border-color: rgba(200, 95, 43, .15); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.card::before { content: ''; position: absolute; inset: 0 0 auto; height: 3px; background: var(--border); }
.card.primary::before { background: var(--primary); }
.card.success::before { background: var(--success); }
.card.danger::before { background: var(--danger); }
.card.warning::before { background: var(--warning); }
.card.info::before { background: var(--info); }
.card .label { margin-bottom: 8px; color: var(--text-muted); font-size: 12px; font-weight: 580; }
.card .value { color: var(--text); font-size: 25px; font-weight: 760; font-variant-numeric: tabular-nums; letter-spacing: -.035em; line-height: 1.15; }
.card .sub { margin-top: 7px; color: var(--text-muted); font-size: 11px; }
.card .value.c-primary { color: var(--primary-dark); }
.card .value.c-success { color: var(--success); }
.card .value.c-danger { color: var(--danger); }
.card .value.c-warning { color: var(--warning); }
.card .value.c-info { color: var(--info); }
.card .value.c-text { color: var(--text); }
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.chart-box { padding: 20px; overflow: hidden; }
.chart-box h3, .section h3, .receipt-section h3, .table-section h3 {
  margin-bottom: 16px; color: var(--text-secondary); font-size: 13px; font-weight: 680;
  display: flex; align-items: center; gap: 8px;
}
.chart-box h3::before, .section h3::before, .table-section h3::before {
  content: ''; width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}
.chart-box canvas { max-height: 280px; }
.table-wrap { overflow-x: auto; border-radius: 12px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
th {
  padding: 11px 12px; color: var(--text-secondary); background: var(--surface-muted);
  border-bottom: 1px solid var(--border); font-size: 12px; font-weight: 680; text-align: left; white-space: nowrap;
}
td { padding: 11px 12px; color: var(--text); border-bottom: 1px solid var(--border-light); text-align: left; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tr:hover td { background: rgba(249, 231, 220, .34); }
.amount { font-family: var(--font-mono); font-size: 12px; font-variant-numeric: tabular-nums; }
.loading { padding: 64px 20px; color: var(--text-muted); text-align: center; }
.empty-state { color: var(--text-muted); }
.badge { display: inline-flex; min-height: 24px; padding: 2px 9px; align-items: center; border-radius: 999px; font-size: 11px; font-weight: 650; }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }

/* === Import history === */
.ih-row-deleted td { opacity: .5; }
.ih-row-deleted td:last-child { opacity: 1; }
.ih-row-deleted td:first-child { box-shadow: inset 3px 0 var(--danger); }
.ih-pagination { padding: 16px 0; display: flex; align-items: center; justify-content: center; gap: 12px; }
.ih-page-info { color: var(--text-muted); font-size: 13px; }
.ih-modal.ih-issues-modal { width: min(1080px, 94vw); max-height: 86vh; display: flex; flex-direction: column; }
.ih-issue-meta { margin: -8px 0 14px; overflow: hidden; color: var(--text-muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.ih-issue-body { overflow: auto; border: 1px solid var(--border); border-radius: 12px; }
.ih-issue-body.empty-state { padding: 28px 0; border: 0; }
.ih-issue-table { min-width: 920px; }
.ih-issue-table th, .ih-issue-table td { text-align: left; vertical-align: top; }
.ih-issue-table th:nth-child(7), .ih-issue-table th:nth-child(8), .ih-issue-table td:nth-child(7), .ih-issue-table td:nth-child(8) { text-align: right; }
.ih-issue-table td:last-child { max-width: 320px; line-height: 1.45; white-space: normal; }

@media (max-width: 1024px) {
  :root { --sidebar-width: 204px; }
  .content-area { padding-inline: 20px; }
  .topbar { padding-inline: 20px; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .hamburger { display: inline-flex; }
  .topbar { height: 60px; padding: 0 12px; }
  .topbar-icon { display: none; }
  .topbar-meta, .shop-switcher > span { display: none; }
  .shop-switcher select { min-width: 132px; max-width: 42vw; }
  .content-area { padding: 14px 12px 28px; }
  .charts { grid-template-columns: 1fr; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card { min-height: 112px; padding: 16px 14px; }
  .card .value { font-size: 21px; }
  .filters { padding: 14px; gap: 10px; }
  .filter-group { flex: 1 1 128px; }
  .filter-group input, .filter-group select { width: 100%; min-width: 0; }
  .btn { min-height: 44px; }
}

@media (max-width: 430px) {
  .topbar h1 { font-size: 15px; }
  .cards { grid-template-columns: 1fr; }
  .card { min-height: 104px; }
  .filters > .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
