* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, "Microsoft YaHei", "PingFang SC", sans-serif;
    background: #f4f6f8; color: #222; line-height: 1.6;
}
a { color: #2563eb; text-decoration: none; }

.topbar {
    display: flex; align-items: center; gap: 20px;
    background: #1f2937; color: #fff; padding: 0 20px; height: 56px;
}
.brand { font-weight: 700; font-size: 18px; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { color: #d1d5db; padding: 6px 12px; border-radius: 6px; }
.nav a.on, .nav a:hover { background: #374151; color: #fff; }
.user { display: flex; align-items: center; gap: 10px; color: #d1d5db; font-size: 14px; }
.btn-link { color: #93c5fd; }

.container { max-width: 1000px; margin: 24px auto; padding: 0 16px; }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 15px; }
.flash-success { background: #e6f4ea; color: #1e7e34; }
.flash-error   { background: #fdecea; color: #c62828; }
.flash-warn    { background: #fff8e1; color: #8a6d00; }

.panel { background: #fff; border-radius: 12px; padding: 20px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.panel h2 { font-size: 17px; margin-bottom: 16px; }

.login-box { max-width: 380px; margin: 60px auto; }
.hint { color: #888; font-size: 13px; margin-top: 14px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.card { background: #fff; border-radius: 12px; padding: 18px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.card .label { color: #6b7280; font-size: 13px; }
.card .value { font-size: 24px; font-weight: 700; margin-top: 6px; }
.card .income { color: #1e7e34; }
.card .expense { color: #c62828; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; border-bottom: 1px solid #eee; text-align: left; }
th { color: #6b7280; font-weight: 600; }
tr:hover td { background: #fafafa; }
.amount-in { color: #1e7e34; font-weight: 600; }
.amount-out { color: #c62828; font-weight: 600; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 14px; color: #374151; margin-bottom: 6px; }
.field input, .field select, .field textarea {
    width: 100%; padding: 9px 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 15px; background: #fff;
}
.field textarea { resize: vertical; min-height: 70px; }

.form-actions { display: flex; gap: 12px; margin-top: 8px; }
.btn {
    background: #2563eb; color: #fff; border: none; padding: 10px 18px;
    border-radius: 8px; font-size: 15px; cursor: pointer;
}
.btn:hover { background: #1d4ed8; }
.btn-secondary { background: #e5e7eb; color: #374151; }
.btn-danger { background: #c62828; }
.btn-sm { padding: 5px 10px; font-size: 13px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar input, .toolbar select { padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; }

.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; }
.tag-expense { background: #fdecea; color: #c62828; }
.tag-income { background: #e6f4ea; color: #1e7e34; }

.muted { color: #6b7280; font-size: 13px; }
.empty { text-align: center; color: #9ca3af; padding: 30px 0; }

.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.bar-name { width: 90px; font-size: 14px; color: #374151; }
.bar-track { flex: 1; background: #f1f5f9; border-radius: 999px; height: 14px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 999px; }
.bar-fill.expense { background: #f87171; }
.bar-fill.income { background: #34d399; }
.bar-amount { width: 110px; text-align: right; font-size: 14px; font-weight: 600; }

.pie-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; }
.pie-title { font-size: 15px; margin-bottom: 12px; }
.pie-title.expense { color: #c62828; }
.pie-title.income { color: #1e7e34; }
.pie-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; }
.pie-svg { width: 76px; height: 76px; flex: 0 0 auto; }
.legend { flex: 1; min-width: 160px; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 8px; }
.legend-dot { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto; }
.legend-name { flex: 1; color: #374151; }
.legend-pct { font-weight: 600; color: #111827; }

/* 货品标签与按分类添加 */
.prod-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.prod-tag { display: inline-flex; align-items: center; gap: 5px; background: #f1f5f9; color: #334155; border-radius: 6px; padding: 3px 8px; font-size: 13px; }
.prod-tag a { color: #94a3b8; text-decoration: none; font-weight: 700; }
.prod-tag a:hover { color: #c62828; }
.prod-add { display: flex; gap: 6px; margin-top: 6px; }
.prod-add input { flex: 1; min-width: 90px; padding: 6px 8px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 13px; }

/* 批量记账多行：单行横向排列，字段宽度按内容自适应，小屏自动换行 */
.batch-row { display: flex; flex-wrap: wrap; gap: 12px; padding: 14px 0; border-bottom: 1px dashed #e5e7eb; align-items: end; }
.batch-row .field { margin-bottom: 0; flex: 0 1 auto; }
.batch-row input, .batch-row select { width: 100%; }
.batch-row .b-type { width: 92px; }
.batch-row .b-cat { min-width: 120px; }
.batch-row .b-product { min-width: 130px; }
.batch-row .b-amount { width: 110px; }
.batch-row .b-date { width: 150px; }
.batch-row .b-note { min-width: 120px; flex: 1 1 120px; }
.batch-remove { flex: 0 0 auto; text-align: right; }
#batch-rows { margin-bottom: 16px; }
