:root {
    --bg-color: #F4ECE1; 
    --primary-color: #2C4C3B; 
    --primary-light: #4A7C59;
    --text-color: #333;
    --meat-color: #C62828; 
    --veg-color: #2E7D32; 
    --warning-bg: #FFE0B2;
    --warning-border: #F57C00;
}

* { box-sizing: border-box; font-family: "PMingLiU", "BiauKai", "Microsoft JhengHei", serif; }
body { margin: 0; background-color: var(--bg-color); color: var(--text-color); }

header { background-color: var(--primary-color); color: white; padding: 15px 20px; }
.header-container { max-width: 1200px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
header h1 { margin: 0; font-size: 1.5rem; letter-spacing: 2px; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.header-actions input { padding: 8px; border: none; border-radius: 4px; }
button { background-color: var(--primary-light); color: white; border: none; padding: 8px 15px; border-radius: 4px; cursor: pointer; font-size: 1rem; transition: 0.2s; }
button:hover { opacity: 0.9; }
.btn-calc { background-color: #F57C00; font-weight: bold; }
.btn-calc:hover { background-color: #E65100; }

main { max-width: 1200px; margin: 20px auto; padding: 0 10px; }
.calendar-controls { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; background: white; padding: 10px 20px; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.calendar-header { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-weight: bold; padding: 10px 0; background-color: var(--primary-color); color: white; border-radius: 8px 8px 0 0; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background-color: #ccc; border: 1px solid #ccc; }
.calendar-cell { background: white; min-height: 120px; padding: 5px; cursor: pointer; position: relative; transition: 0.2s; }
.calendar-cell:hover { background: #f0f0f0; }
.calendar-cell.over-limit { background-color: var(--warning-bg); border: 2px solid var(--warning-border); }
.date-top { display: flex; justify-content: space-between; font-size: 0.9rem; margin-bottom: 5px; }
.gregorian { font-weight: bold; font-size: 1.1rem; }
.lunar { color: #666; font-size: 0.85rem; }
.day-stats { font-size: 0.95rem; line-height: 1.4; }
.meat-text { color: var(--meat-color); font-weight: bold; }
.veg-text { color: var(--veg-color); font-weight: bold; }

/* Modal 樣式 */
.modal { display: none; position: fixed; z-index: 10; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); overflow-y: auto; }
.modal-content { background-color: white; margin: 5% auto; padding: 20px; width: 90%; max-width: 500px; border-radius: 8px; position: relative; }
.modal-content.large { max-width: 900px; }
.close { position: absolute; right: 20px; top: 15px; font-size: 28px; cursor: pointer; }

table { width: 100%; border-collapse: collapse; margin-top: 10px; }
table, th, td { border: 1px solid #ddd; }
th, td { padding: 10px; text-align: left; }
th { background-color: var(--primary-light); color: white; }
.table-responsive { overflow-x: auto; margin-bottom: 15px;}

.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: bold; }
.form-group input, .form-group select { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; }
.btn-submit { width: 100%; font-size: 1.1rem; padding: 10px; background-color: var(--primary-color); }
.stat-card { border: 1px solid #ddd; padding: 15px; margin-top: 10px; border-radius: 8px; background: #fafafa; }

/* 成本分析專屬樣式 */
.cost-summary-box { background: #E8F5E9; border: 1px solid #C8E6C9; padding: 15px; border-radius: 8px; margin-bottom: 20px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; }
.price-settings { display: flex; gap: 15px; }
.price-settings input { width: 80px; padding: 5px; border: 1px solid #aaa; border-radius: 4px; }
.tabs { display: flex; gap: 10px; margin-bottom: 15px; border-bottom: 2px solid #ddd; }
.tab-btn { background: none; color: #666; border: none; padding: 10px 20px; font-size: 1rem; cursor: pointer; border-bottom: 3px solid transparent; border-radius: 0; }
.tab-btn.active { color: var(--primary-color); font-weight: bold; border-bottom: 3px solid var(--primary-color); }
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.3s; }
.cost-table input { width: 80px; padding: 4px; border: 1px solid #ccc; }
.cost-table th { background-color: #6c757d; }
.total-row { background-color: #FFF3CD !important; font-weight: bold; }

.profit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 15px; margin-top: 15px; }
.profit-card { background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 8px; padding: 15px; text-align: center; }
.profit-card .label { color: #666; font-size: 0.9rem; margin-bottom: 5px; }
.profit-card .value { font-size: 1.4rem; font-weight: bold; color: var(--primary-color); }
.profit-card .value.negative { color: var(--meat-color); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 600px) {
    .calendar-cell { min-height: 80px; padding: 2px; }
    .date-top { flex-direction: column; align-items: flex-end; }
    .lunar { font-size: 0.75rem; }
    .day-stats { font-size: 0.8rem; }
    .header-container { flex-direction: column; text-align: center; }
    .cost-summary-box { flex-direction: column; align-items: flex-start; gap: 10px; }
    .price-settings { flex-direction: column; gap: 5px; }
    .tabs { flex-wrap: wrap; }
    .tab-btn { flex: 1; text-align: center; padding: 8px; font-size: 0.9rem; }
}