/* 作息、饮食、运动管理系统 V1.0 - 视觉规范
 * 风格:简洁、记录优先、低成本输入
 */
:root {
  --bg: #f7f8fa;
  --card: #ffffff;
  --text: #222;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #4f81bd;
  --primary-dark: #3a5f8a;
  --ok-bg: #d1fae5;
  --ok-text: #065f46;
  --err-bg: #fee2e2;
  --err-text: #991b1b;
  --accent: #f59e0b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.navbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
}
.navbar .brand { font-weight: 600; font-size: 18px; }
.navbar .nav-links a { margin-left: 16px; font-size: 14px; }

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

.date-bar {
  text-align: center;
  margin-bottom: 24px;
}
.date-bar h1 { margin: 0; font-size: 28px; }
.date-bar .sub { color: var(--muted); margin-top: 4px; font-size: 14px; }
.date-bar .nav {
  margin-top: 12px;
  font-size: 13px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.card h2 {
  margin: 0 0 12px;
  font-size: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card h2 .left { display: flex; align-items: center; gap: 8px; }
.card h2 a.add { font-size: 13px; }

.row-list { display: flex; flex-direction: column; gap: 10px; }
.row {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  background: #fbfbfc;
}
.row .row-title { font-weight: 600; margin-bottom: 4px; }
.row .row-meta { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.row .row-note { font-size: 13px; white-space: pre-wrap; }
.row .row-actions {
  margin-top: 8px;
  font-size: 13px;
  display: flex;
  gap: 12px;
}

.empty { color: var(--muted); font-size: 13px; padding: 8px 0; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}
.summary-grid .item {
  background: #fbfbfc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}
.summary-grid .item .v { font-size: 20px; font-weight: 600; }
.summary-grid .item .l { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* 表单 */
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.form-row input[type=text],
.form-row input[type=number],
.form-row input[type=datetime-local],
.form-row input[type=date],
.form-row select,
.form-row textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}
.form-row textarea { min-height: 70px; resize: vertical; }
.form-row .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.form-row.inline { display: flex; align-items: center; gap: 8px; }
.form-row.inline label { margin-bottom: 0; }

.radio-group { display: flex; flex-wrap: wrap; gap: 12px; }
.radio-group label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: var(--text);
}

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
  font-family: inherit;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: #ef4444; }
.btn.danger:hover { background: #b91c1c; }
.btn.small { padding: 4px 10px; font-size: 12px; }

.btn-row { display: flex; gap: 10px; margin-top: 12px; }

.flash {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13px;
}
.flash.ok { background: var(--ok-bg); color: var(--ok-text); }
.flash.err { background: var(--err-bg); color: var(--err-text); }

/* 食物动态添加行 */
.food-list .food-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 2fr auto;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}
.food-list .food-row input { padding: 6px 8px; font-size: 13px; }

.range-display { font-size: 12px; color: var(--muted); margin-left: 8px; }

footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 24px 0;
}

/* ===== 生活统计页 ===== */
.stats-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.period-tabs { display: flex; gap: 6px; }
.period-tabs .tab {
  padding: 5px 18px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  color: var(--text);
  background: #fff;
}
.period-tabs .tab:hover { text-decoration: none; border-color: var(--primary); }
.period-tabs .tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.stats-picker { display: flex; align-items: center; gap: 8px; }
.stats-picker input { padding: 5px 8px; font-size: 14px; border: 1px solid var(--border); border-radius: 6px; }
.hint-inline { font-size: 12px; color: var(--muted); }

/* “本次新增”标记 */
.tag-new {
  font-size: 11px;
  font-weight: 400;
  line-height: 1.6;
  color: #fff;
  background: var(--accent);
  border-radius: 10px;
  padding: 1px 8px;
  margin-left: 6px;
  vertical-align: middle;
}

.sub-title {
  font-size: 15px;
  margin: 18px 0 2px;
  padding: 6px 10px;
  background: #f1f5f9;
  border-left: 3px solid var(--primary);
  border-radius: 4px;
}
.chart-caption { font-size: 14px; font-weight: 600; margin: 16px 0 4px; }
.chart-box { position: relative; height: 300px; margin: 4px 0 6px; }
.chart-box-sm { height: 220px; }

/* 统计页明细表(各运动时段明细):宽度始终等于卡片内容区,不产生横向滚动;
   行多时仅纵向滚动 */
.table-wrap { max-height: 420px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.stat-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.stat-table th, .stat-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.stat-table thead th { position: sticky; top: 0; background: #f1f5f9; font-weight: 600; z-index: 1; }
.stat-table tbody tr:hover { background: #f8fafc; }
.stat-table .row-abnormal td { color: #b45309; }

/* 做梦日期列表:行数多时仅纵向滚动,不产生横向滚动 */
.dream-dates {
  margin-top: 6px;
  max-height: 120px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.9;
  color: #334155;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
