/* ===== 全局 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body {
    font-family: -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
    color: #2c3e50;
    background: linear-gradient(135deg, #f0f4ff 0%, #fce8f3 50%, #e8f5ff 100%);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}
input, button, select { font-family: inherit; outline: none; }
button { cursor: pointer; border: none; background: none; }

#app {
    max-width: 1280px;
    margin: 0 auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.card {
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(8px);
    border-radius: 18px;
    padding: 18px;
    box-shadow: 0 6px 24px rgba(80, 100, 180, 0.08), 0 2px 6px rgba(80, 100, 180, 0.04);
    border: 1px solid rgba(255,255,255,0.6);
}

/* ===== 顶部 ===== */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
    width: 48px; height: 48px;
    background: linear-gradient(135deg, #FF8C5A, #FF6B9D);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
    box-shadow: 0 6px 16px rgba(255,107,157,0.35);
}
.title { font-size: 22px; font-weight: 700; color: #2c3e50; }
.subtitle { font-size: 13px; color: #7a8ba0; margin-top: 2px; }
.city-select {
    background: #fff;
    border: 1px solid #e0e8f5;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 14px;
    color: #4a5e75;
}

/* ===== 信息行：天气+老黄历 ===== */
.info-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.weather-top {
    display: flex; align-items: center; gap: 14px; margin-bottom: 10px;
}
.weather-icon { font-size: 48px; line-height: 1; }
.weather-temp { font-size: 32px; font-weight: 700; color: #2c3e50; }
.weather-type { font-size: 16px; color: #6b7d92; }
.weather-city {
    margin-left: auto;
    background: linear-gradient(135deg, #4FACFE, #6E8BFF);
    color: #fff;
    padding: 6px 14px;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 500;
}
.weather-detail {
    display: flex; gap: 16px; font-size: 13px; color: #6b7d92;
    margin-bottom: 8px; flex-wrap: wrap;
}
.weather-quality {
    display: inline-block;
    background: linear-gradient(135deg, #43e97b, #38f9d7);
    color: #fff;
    padding: 4px 12px;
    border-radius: 10px;
    font-size: 12px;
    margin-bottom: 8px;
}
.weather-forecast {
    display: flex; gap: 8px; overflow-x: auto; padding-top: 8px;
    border-top: 1px dashed #e0e8f5;
}
.weather-forecast::-webkit-scrollbar { display: none; }
.forecast-item {
    min-width: 56px; text-align: center; font-size: 11px; color: #6b7d92;
}
.forecast-item .f-week { font-weight: 600; color: #4a5e75; margin-bottom: 2px; }
.forecast-item .f-icon { font-size: 20px; margin: 2px 0; }
.forecast-item .f-temp { font-size: 11px; }

.lunar-card {
    background: linear-gradient(135deg, #fff 0%, #fff8f0 100%);
    display: flex; flex-direction: column; gap: 8px;
}
.lunar-date { font-size: 22px; font-weight: 700; color: #b8741a; }
.lunar-gan { font-size: 14px; color: #8c6d4f; }
.lunar-animal { font-size: 12px; color: #a08c70; }
.lunar-yiji { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.yiji-block {
    display: flex; align-items: flex-start; gap: 8px;
    font-size: 13px; line-height: 1.6;
}
.yiji-label {
    flex-shrink: 0;
    width: 22px; height: 22px;
    border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-size: 12px; font-weight: 700;
}
.yiji-label.yi { background: #e74c3c; }
.yiji-label.ji { background: #7f8c8d; }
.yiji-content { color: #4a3d2c; flex: 1; }
.lunar-extra {
    display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px;
    font-size: 12px; color: #a08c70; margin-top: 4px;
    border-top: 1px dashed #ead9c0; padding-top: 8px;
}

/* ===== 汇总行 ===== */
.summary-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}
.summary-card {
    padding: 16px 18px;
    color: #fff;
    position: relative;
    overflow: hidden;
}
.summary-card::before {
    content: ""; position: absolute; right: -20px; top: -20px;
    width: 80px; height: 80px; border-radius: 50%;
    background: rgba(255,255,255,0.18);
}
.summary-card.expense { background: linear-gradient(135deg, #FF6B6B, #FF8E53); }
.summary-card.income  { background: linear-gradient(135deg, #56ab2f, #a8e063); }
.summary-card.balance { background: linear-gradient(135deg, #4FACFE, #6E8BFF); }
.summary-card.total   { background: linear-gradient(135deg, #667eea, #764ba2); }
.summary-label { font-size: 13px; opacity: 0.9; }
.summary-amount { font-size: 26px; font-weight: 700; margin-top: 4px; }
.summary-sub { font-size: 12px; opacity: 0.85; margin-top: 4px; }

/* ===== 主体行：表单+列表 ===== */
.main-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.card-title {
    font-size: 16px; font-weight: 700; color: #2c3e50;
    margin-bottom: 14px;
    display: flex; justify-content: space-between; align-items: center;
}
.history-filter {
    background: #f5f8fc; border: 1px solid #e0e8f5;
    border-radius: 8px; padding: 4px 8px; font-size: 12px; color: #4a5e75;
}

/* 类型 tabs */
.type-tabs {
    display: flex; gap: 8px; margin-bottom: 14px;
    background: #f5f8fc; padding: 4px; border-radius: 12px;
}
.type-tab {
    flex: 1; padding: 8px 0; border-radius: 9px;
    font-size: 14px; font-weight: 600; color: #6b7d92;
    transition: all .2s;
}
.type-tab.active { background: #fff; color: #2c3e50; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.type-tab[data-type="expense"].active { color: #FF6B6B; }
.type-tab[data-type="income"].active  { color: #56ab2f; }

.amount-display {
    text-align: center; margin: 6px 0 16px;
    font-size: 40px; font-weight: 700; color: #2c3e50;
    font-family: -apple-system, "DIN", "Helvetica Neue", sans-serif;
}
.amount-display .currency { font-size: 22px; color: #a0aec0; margin-right: 4px; vertical-align: top; }

/* 分类网格 */
.category-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}
.cat-item {
    padding: 10px 4px;
    border-radius: 12px;
    background: #f5f8fc;
    text-align: center;
    transition: all .15s;
    border: 2px solid transparent;
}
.cat-item .cat-icon { font-size: 22px; display: block; }
.cat-item .cat-name { font-size: 11px; color: #6b7d92; margin-top: 2px; }
.cat-item.selected {
    background: linear-gradient(135deg, #4FACFE, #6E8BFF);
    border-color: #6E8BFF;
    box-shadow: 0 4px 12px rgba(110,139,255,0.35);
}
.cat-item.selected .cat-name { color: #fff; }

/* 输入框 */
.amount-row, .note-row { margin-bottom: 10px; }
#amount-input, #note-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #e0e8f5;
    border-radius: 12px;
    font-size: 16px;
    background: #f5f8fc;
    color: #2c3e50;
    transition: all .2s;
}
#amount-input { font-size: 22px; font-weight: 600; }
#amount-input:focus, #note-input:focus {
    border-color: #6E8BFF;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(110,139,255,0.15);
}

.submit-btn {
    width: 100%;
    padding: 14px;
    border-radius: 14px;
    background: linear-gradient(135deg, #4FACFE, #6E8BFF);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 2px;
    box-shadow: 0 6px 16px rgba(110,139,255,0.35);
    transition: all .15s;
}
.submit-btn:active { transform: scale(0.98); }
.submit-btn.expense { background: linear-gradient(135deg, #FF6B6B, #FF8E53); box-shadow: 0 6px 16px rgba(255,107,107,0.35); }
.submit-btn.income  { background: linear-gradient(135deg, #56ab2f, #a8e063); box-shadow: 0 6px 16px rgba(86,171,47,0.35); }

/* 历史列表 */
.list-card { display: flex; flex-direction: column; }
.history-list {
    overflow-y: auto;
    max-height: 460px;
    margin: 0 -8px;
    padding: 0 8px;
}
.history-list::-webkit-scrollbar { width: 6px; }
.history-list::-webkit-scrollbar-thumb { background: #d0d8e5; border-radius: 3px; }
.history-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 6px;
    border-bottom: 1px solid #eef2f7;
}
.history-item:last-child { border-bottom: none; }
.history-item .h-icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    background: #f5f8fc;
}
.history-item .h-info { flex: 1; min-width: 0; }
.history-item .h-cat { font-size: 14px; font-weight: 600; color: #2c3e50; }
.history-item .h-meta { font-size: 12px; color: #8c9bb0; margin-top: 2px; }
.history-item .h-meta .h-note { color: #6b7d92; margin-left: 6px; }
.history-item .h-amount {
    font-size: 16px; font-weight: 700; font-family: -apple-system, "DIN", sans-serif;
}
.history-item.expense .h-amount { color: #FF6B6B; }
.history-item.income  .h-amount { color: #56ab2f; }
.history-item .h-delete {
    color: #c8d3e0; font-size: 18px; padding: 4px;
    transition: color .15s;
}
.history-item .h-delete:active { color: #e74c3c; }

.empty-tip {
    text-align: center; padding: 40px 0;
    color: #a0aec0; font-size: 14px;
}

/* 图表 */
.chart-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.chart { width: 100%; height: 320px; }

/* 底部 */
.app-footer {
    text-align: center; color: #a0aec0;
    font-size: 12px; padding: 8px 0;
}

/* toast */
.toast {
    position: fixed; left: 50%; top: 24px;
    transform: translateX(-50%);
    background: rgba(44,62,80,0.92);
    color: #fff;
    padding: 10px 20px;
    border-radius: 22px;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s, transform .25s;
    z-index: 999;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(6px); }
.toast.success { background: linear-gradient(135deg, #56ab2f, #a8e063); }
.toast.error { background: linear-gradient(135deg, #FF6B6B, #FF8E53); }

/* ===== 响应式：竖屏平板/手机 ===== */
@media (max-width: 768px) {
    .info-row, .summary-row, .main-row, .chart-row {
        grid-template-columns: 1fr;
    }
    .summary-row { grid-template-columns: 1fr 1fr; }
    .category-grid { grid-template-columns: repeat(5, 1fr); }
    .history-list { max-height: 320px; }
    .chart { height: 260px; }
    #app { padding: 12px; }
    .title { font-size: 18px; }
    .weather-temp { font-size: 26px; }
    .weather-icon { font-size: 36px; }
}
@media (max-width: 480px) {
    .summary-row { grid-template-columns: 1fr 1fr; }
    .category-grid { grid-template-columns: repeat(4, 1fr); }
}
