:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2f6fed;
  --hot: #e0523f;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.page-header {
  text-align: center;
  padding: 32px 16px 8px;
}
.page-header h1 { font-size: 28px; letter-spacing: 1px; }
.subtitle { color: var(--muted); margin-top: 6px; font-size: 14px; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  max-width: 1080px;
  margin: 24px auto 0;
  padding: 0 16px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-card .label { color: var(--muted); font-size: 12px; }
.stat-card .value { font-size: 22px; font-weight: 700; }

.controls {
  max-width: 1080px;
  margin: 20px auto 0;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 14px;
  cursor: pointer;
  transition: opacity .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: var(--card); color: var(--text); border: 1px solid var(--border); }

.progress {
  flex: 1;
  min-width: 220px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.progress-bar { flex: 1; height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width .3s; }
#progress-text { font-size: 13px; color: var(--muted); white-space: nowrap; }
.calc-msg { font-size: 13px; color: #16a34a; }

main {
  max-width: 1080px;
  margin: 24px auto;
  padding: 0 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
}
.calendar-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
}
.month-label { font-size: 18px; font-weight: 700; }
.range-label { font-size: 13px; color: var(--muted); }

.week-head {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.calendar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.day-cell {
  position: relative;
  min-height: 92px;
  border-radius: 10px;
  background: #fafbfc;
  border: 1px solid var(--border);
  padding: 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: default;
  transition: box-shadow .15s, transform .1s;
}
.day-cell.clickable { cursor: pointer; }
.day-cell.clickable:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); transform: translateY(-1px); }

.day-cell .day-top { display: flex; justify-content: space-between; align-items: baseline; }
.day-cell .day-num { font-size: 13px; font-weight: 600; color: var(--muted); }
.day-cell .day-week { font-size: 11px; color: var(--muted); }
.day-cell .count { font-size: 24px; font-weight: 800; text-align: center; line-height: 1.1; }
.day-cell .day-note { font-size: 11px; text-align: center; color: var(--muted); min-height: 14px; }

.day-cell.placeholder { background: transparent; border-color: transparent; }
.day-cell.holiday { background: #f3f4f6; }
.day-cell.holiday .count { color: #c4c9d0; }
.day-cell.empty .count { color: var(--muted); }

.day-cell.today { border: 2px solid var(--accent); box-shadow: 0 0 0 3px rgba(47,111,237,.12); }
.day-cell.today .day-num { color: var(--accent); }

.day-cell.no-data { background: #e8f1fb; }
.day-cell.today .count.is-undefined { color: var(--muted); }

.month-tag {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 10px;
  color: #9aa3af;
}

.footer { padding-bottom: 40px; }
.legend {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px 40px;
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.swatch { width: 18px; height: 18px; border-radius: 5px; display: inline-block; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal.hidden { display: none; }
.modal-box {
  background: #fff; border-radius: 14px; width: min(560px, 92vw); max-height: 80vh;
  display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.2);
  transition: width .15s;
}
.modal-box.wide { width: min(880px, 96vw); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-close { border: none; background: none; font-size: 24px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { overflow-y: auto; padding: 12px 20px 20px; }
.stock-head { display: flex; justify-content: space-between; padding: 4px 6px 8px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); }
.stock-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 6px; border-bottom: 1px dashed var(--border); font-size: 14px; cursor: pointer; border-radius: 6px; transition: background .12s; }
.stock-row:hover { background: #f0f5ff; }
.stock-row:last-child { border-bottom: none; }
.stock-row .code { color: var(--muted); font-family: monospace; margin-left: 4px; }
.stock-row .stock-right { display: flex; align-items: center; gap: 12px; }
.stock-row .current-price { font-weight: 700; font-family: monospace; }
.stock-row .pct { font-family: monospace; font-size: 12px; min-width: 58px; text-align: left; }
.stock-row .close { font-weight: 600; font-family: monospace; color: var(--muted); }
.stock-row .rsi { font-weight: 700; color: var(--hot); }
.stock-row .arrow { color: var(--muted); font-size: 12px; }
.modal-empty { text-align: center; color: var(--muted); padding: 30px 0; }

.chart-box { min-height: 560px; position: relative; }
.chart-box.hidden { display: none; }
.stock-list.hidden { display: none; }
#chart { width: 100%; height: 560px; }
.chart-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; }
.chart-loading.hidden { display: none; }
