/* ==========================================================================
   个人气候适应与穿衣决策系统 —— 全局样式
   浅色主题 / 卡片式布局 / 无外部依赖
   ========================================================================== */

:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-alt: #fafbfc;
  --border: #e3e8ee;
  --border-strong: #cfd6dc;
  --text: #1f2933;
  --text-soft: #5b6670;
  --text-muted: #8a939c;
  --primary: #3a6fb5;
  --primary-dark: #2f5c99;
  --primary-soft: #eaf1fa;
  --green: #6BC28B;
  --green-soft: #e9f7ee;
  --amber: #e0a020;
  --amber-soft: #fdf4e3;
  --red: #c0463a;
  --red-soft: #fbeae7;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(31, 41, 51, .06), 0 4px 14px rgba(31, 41, 51, .04);
  --shadow-hover: 0 2px 6px rgba(31, 41, 51, .09), 0 10px 26px rgba(31, 41, 51, .07);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Segoe UI", system-ui, sans-serif;
  font-size: 14.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.3; }
p { margin: 0 0 8px; }
small { font-size: 12px; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.topbar-inner {
  max-width: 1320px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-icon { font-size: 26px; line-height: 1; }
.brand-text { display: flex; flex-direction: column; }
.brand-text strong { font-size: 15px; }
.brand-text small { color: var(--text-muted); font-size: 11px; letter-spacing: .2px; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; margin-left: auto; }
.nav a {
  padding: 6px 11px; border-radius: var(--radius-sm); color: var(--text-soft);
  font-size: 13.5px; white-space: nowrap;
}
.nav a:hover { background: var(--surface-alt); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }
.nav-toggle {
  display: none; margin-left: auto; background: none; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 18px; padding: 2px 10px; cursor: pointer; color: var(--text);
}

/* ---------------- 容器 ---------------- */
.container { max-width: 1320px; margin: 0 auto; padding: 22px 20px 60px; }
.footer {
  max-width: 1320px; margin: 0 auto; padding: 18px 20px 40px;
  color: var(--text-muted); font-size: 12px; text-align: center;
}
.footer .sep { margin: 0 6px; }

/* ---------------- Flash ---------------- */
.flash-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash {
  padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13.5px;
  border-left: 3px solid var(--primary); background: var(--primary-soft); color: var(--primary-dark);
}
.flash-success { border-color: var(--green); background: var(--green-soft); color: #2f7a4d; }
.flash-warning { border-color: var(--amber); background: var(--amber-soft); color: #97670f; }
.flash-error { border-color: var(--red); background: var(--red-soft); color: #9c3428; }
.flash-info { border-color: var(--border-strong); background: var(--surface-alt); color: var(--text-soft); }

/* ---------------- 页头 ---------------- */
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
.page-header h1 { font-size: 21px; display: flex; align-items: center; gap: 8px; }
.ph-icon { font-size: 20px; }
.page-sub { color: var(--text-muted); font-size: 13px; margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px;
  overflow: hidden;
}
.card-head {
  padding: 13px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--surface-alt);
}
.card-head h2 { font-size: 15px; }
.card-sub { color: var(--text-muted); font-size: 12px; }
.card-body { padding: 18px; }
.card-body > :last-child { margin-bottom: 0; }
.card-flush .card-body { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(268px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid-narrow { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row-between { display: flex; gap: 12px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-size: 13.5px; cursor: pointer;
  font-family: inherit; line-height: 1.4; transition: all .12s ease; white-space: nowrap;
}
.btn:hover { background: var(--surface-alt); border-color: var(--text-muted); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.btn-green:hover { background: #5aae7b; border-color: #5aae7b; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: var(--surface-alt); }
.btn-danger { color: var(--red); border-color: #eccdc7; }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-xs { padding: 2px 8px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------------- 徽章 / 标签 ---------------- */
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 20px;
  font-size: 12px; font-weight: 500; background: #f1f3f5; color: var(--text-soft);
  white-space: nowrap;
}
.badge-primary { background: var(--primary-soft); color: var(--primary-dark); }
.badge-green { background: var(--green-soft); color: #2f7a4d; }
.badge-amber { background: var(--amber-soft); color: #97670f; }
.badge-red { background: var(--red-soft); color: #9c3428; }
.badge-neutral { background: #f1f3f5; color: var(--text-soft); }
/* 节气等「非当日」的淡色标记，与当日节气的 badge-primary 区分 */
.badge-soft { background: #f5f7fa; color: var(--text-muted); border: 1px solid var(--border); }

.day-tags { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.day-tags .pill { background: #f5f7fa; border: 1px solid var(--border); }

.pill {
  display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px;
  background: #f1f3f5; color: var(--text-soft);
}
.pill-ok { background: var(--green-soft); color: #2f7a4d; }
.pill-todo { background: var(--amber-soft); color: #97670f; }

.muted { color: var(--text-muted); }
.warn { color: var(--red); }
.soft { color: var(--text-soft); }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }

/* ---------------- 空状态 ---------------- */
.empty { text-align: center; padding: 26px 16px; color: var(--text-muted); }
.empty-icon { font-size: 30px; margin-bottom: 6px; }
.empty p { margin: 0; font-size: 13.5px; }
.empty-hint { font-size: 12px !important; color: var(--text-muted); margin-top: 4px !important; }

/* ---------------- 首页三层布局 ---------------- */
.today-strip {
  background: linear-gradient(135deg, #eef4fc 0%, #f7fbf9 100%);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 22px; margin-bottom: 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
}
.today-date { font-size: 22px; font-weight: 600; }
.today-meta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.today-meta span {
  background: rgba(255,255,255,.8); border: 1px solid var(--border);
  border-radius: 20px; padding: 2px 11px; font-size: 12.5px; color: var(--text-soft);
}
.today-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- 天气卡片 ---------------- */
.wcard-list { list-style: none; margin: 0; padding: 0; }
.wcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; display: flex; flex-direction: column;
  transition: box-shadow .15s ease, transform .15s ease;
}
.wcard:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.wcard-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.wcard-head h3 { font-size: 16px; }
.wcard-sub { font-size: 11.5px; color: var(--text-muted); }
.wcard-icon { font-size: 30px; line-height: 1; }
.wcard-main { display: flex; align-items: baseline; gap: 14px; margin: 10px 0 4px; }
.wcard-temp { display: flex; align-items: baseline; gap: 2px; }
.wcard-temp .tmax { font-size: 30px; font-weight: 600; }
.wcard-temp .tmin { font-size: 18px; color: var(--text-muted); }
.wcard-type { color: var(--text-soft); font-size: 13px; }
.wcard-list li {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 4px 0; font-size: 12.8px; border-bottom: 1px dashed #f0f3f6;
}
.wcard-list li:last-child { border-bottom: none; }
.wcard-list span { color: var(--text-muted); }
.wcard-list b { font-weight: 500; }
.wcard-warn { margin-top: 8px; font-size: 12px; color: var(--red); }
.wcard-foot {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}

/* ---------------- 指标网格 ---------------- */
.metrics {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 10px;
}
.metrics.compact { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.metric {
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 12px;
}
.metric .m-label { display: block; font-size: 11.5px; color: var(--text-muted); }
.metric .m-value { display: block; font-size: 15px; font-weight: 600; margin-top: 2px; }
.metric .m-value small { font-size: 11.5px; font-weight: 400; color: var(--text-muted); margin-left: 1px; }
.metric .m-value em { font-style: normal; font-size: 11.5px; color: var(--text-muted); font-weight: 400; }
.metric-warn { background: var(--red-soft); border-color: #eccdc7; }
.metric-warn .m-value.warn { font-size: 12.5px; font-weight: 500; }

/* ---------------- 趋势条 ---------------- */
.trend-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.trend-day {
  min-width: 92px; flex: 1; background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 8px; text-align: center;
}
.trend-day .td-dow { font-size: 11.5px; color: var(--text-muted); }
.trend-day .td-date { font-size: 11px; color: var(--text-muted); }
.trend-day .td-icon { font-size: 20px; margin: 3px 0; }
.trend-day .td-temp { font-size: 12.5px; font-weight: 600; }
.trend-day .td-type { font-size: 11.5px; color: var(--text-soft); }
.trend-day .td-term { font-size: 11px; color: var(--primary-dark); margin-top: 2px; }

/* ---------------- 图表 ---------------- */
.chart-wrap { overflow-x: auto; }
.chart { display: flex; align-items: flex-end; gap: 10px; min-width: 320px; }
.chart-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end;
  align-items: center; height: 100%; min-width: 34px; }
.chart-val { font-size: 11.5px; color: var(--text-soft); margin-bottom: 4px; white-space: nowrap; }
.chart-bar { width: 100%; max-width: 46px; min-height: 2px; border-radius: 4px 4px 0 0; }
.chart-label { font-size: 11px; color: var(--text-muted); margin-top: 5px; text-align: center; }

.hchart { display: flex; flex-direction: column; gap: 7px; }
.hchart-row { display: grid; grid-template-columns: 132px 1fr 82px; gap: 10px; align-items: center; }
.hc-label { font-size: 12.5px; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hc-track { height: 14px; background: #f0f3f6; border-radius: 7px; overflow: hidden; }
.hc-track i { display: block; height: 100%; border-radius: 7px; min-width: 2px; }
.hc-value { font-size: 12.5px; text-align: right; color: var(--text-soft); }

.scatter, .line-chart { width: 100%; height: auto; display: block; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td {
  padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.data-table th {
  background: var(--surface-alt); font-weight: 600; font-size: 12.5px;
  color: var(--text-soft); white-space: nowrap; position: sticky; top: 0;
}
.data-table tbody tr:hover { background: #fbfcfd; }
.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.card-flush .data-table th { background: var(--surface-alt); }

/* ---------------- 表单 ---------------- */
form .form-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field-wide { grid-column: 1 / -1; }
.field-label { font-size: 12.5px; color: var(--text-soft); font-weight: 500; }
.field-label .req { color: var(--red); font-style: normal; margin-left: 3px; }
.field input, .field select, .field textarea, .inline-field input, .inline-field select {
  padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 13.5px; font-family: inherit; background: var(--surface); color: var(--text);
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(58, 111, 181, .12);
}
.field-hint { font-size: 11.5px; color: var(--text-muted); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.check input { width: auto; }

.filter-bar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 11px 14px; margin-bottom: 16px;
}
.inline-field { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-soft); }
.inline-field input, .inline-field select { width: auto; }

.form-actions {
  display: flex; gap: 10px; margin-top: 18px; padding-top: 16px;
  border-top: 1px solid var(--border); flex-wrap: wrap;
}

/* ---------------- 穿衣记录 ---------------- */
.outfit-role-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.role-box {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 13px; background: var(--surface-alt);
}
.role-box > header {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.role-box > header strong { font-size: 13.5px; }
.role-box .role-cat { font-size: 11.5px; color: var(--text-muted); }
.role-box select { width: 100%; }
.role-box .sub-row { display: flex; gap: 8px; margin-top: 7px; align-items: center; }

.item-chip {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); margin-bottom: 7px;
}
.item-chip .ic-name { font-size: 13.5px; font-weight: 500; }
.item-chip .ic-meta { font-size: 11.5px; color: var(--text-muted); }
.item-chip .ic-role {
  font-size: 11.5px; background: var(--primary-soft); color: var(--primary-dark);
  border-radius: 20px; padding: 1px 9px; white-space: nowrap;
}

.pick-list { list-style: none; margin: 0; padding: 0; }
.pick-list li {
  display: flex; gap: 10px; align-items: flex-start; padding: 8px 0;
  border-bottom: 1px dashed #eef1f4; font-size: 13px;
}
.pick-list li:last-child { border-bottom: none; }
.pick-role { flex: 0 0 74px; color: var(--text-soft); font-size: 12.5px; }
.pick-body { flex: 1; }
.pick-reason { display: block; font-size: 11.5px; color: var(--text-muted); }

.reason-list { list-style: none; margin: 0; padding: 0; font-size: 12.8px; }
.reason-list li { padding: 4px 0 4px 18px; position: relative; color: var(--text-soft); }
.reason-list li::before {
  content: '›'; position: absolute; left: 5px; color: var(--primary); font-weight: 700;
}

/* ---------------- 时间线 ---------------- */
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item {
  display: grid; grid-template-columns: 96px 1fr; gap: 14px;
  padding: 11px 0; border-bottom: 1px solid var(--border);
}
.tl-item:last-child { border-bottom: none; }
.tl-date { font-size: 12.5px; color: var(--text-soft); }
.tl-date b { display: block; font-size: 13.5px; color: var(--text); }
.tl-body { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tl-loc { font-size: 13px; font-weight: 500; }
.tl-temp { font-size: 14px; font-weight: 600; }
.tl-type { font-size: 12.5px; color: var(--text-soft); }
.tl-missing { font-size: 12.5px; color: var(--amber); }

/* ---------------- 步骤/统计小卡 ---------------- */
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.stat .s-label { font-size: 12px; color: var(--text-muted); display: block; }
.stat .s-value { font-size: 23px; font-weight: 600; margin-top: 3px; display: block; }
.stat .s-value small { font-size: 13px; font-weight: 400; color: var(--text-muted); }
.stat .s-hint { font-size: 11.5px; color: var(--text-muted); }

/* ---------------- 权限/提示条 ---------------- */
.notice {
  border-radius: var(--radius-sm); padding: 11px 14px; font-size: 13px;
  background: var(--amber-soft); border: 1px solid #f0dcb4; color: #8a5f10; margin-bottom: 14px;
}
.notice-info { background: var(--primary-soft); border-color: #cfdff2; color: var(--primary-dark); }
.notice-green { background: var(--green-soft); border-color: #cbe8d6; color: #2f7a4d; }
.notice-red { background: var(--red-soft); border-color: #eccdc7; color: #9c3428; }

/* ---------------- 错误页 ---------------- */
.error-page { text-align: center; padding: 60px 20px; }
.error-page .code { font-size: 56px; font-weight: 700; color: var(--primary); line-height: 1; }
.error-page h2 { margin: 12px 0 8px; font-size: 18px; }
.error-page p { color: var(--text-soft); }

/* ---------------- 响应式 ---------------- */
@media (max-width: 900px) {
  .nav-toggle { display: block; }
  .nav { display: none; width: 100%; margin-left: 0; }
  .nav-open .nav { display: flex; }
  .topbar-inner { align-items: flex-start; }
  .container { padding: 16px 14px 50px; }
  .hchart-row { grid-template-columns: 96px 1fr 66px; }
  .tl-item { grid-template-columns: 1fr; gap: 6px; }
  .today-strip { padding: 14px 16px; }
  .today-date { font-size: 19px; }
}

/* ---------------- 穿衣时间线（同一天多条记录） ---------------- */
.outfit-timeline { display: flex; flex-direction: column; gap: 10px; }
.outfit-timeline .timeline-entry {
  display: grid; grid-template-columns: 120px 1fr auto; gap: 12px; align-items: start;
  padding: 12px 14px;
}
.outfit-timeline .timeline-time { font-size: 14px; color: var(--primary-dark); }
.outfit-timeline .timeline-actions { display: flex; gap: 6px; align-items: center; }
@media (max-width: 900px) {
  .outfit-timeline .timeline-entry { grid-template-columns: 1fr; }
}
