:root {
  color-scheme: light;
  --bg: #f2f5f8;
  --panel: #ffffff;
  --line: #d9e1ea;
  --text: #172033;
  --muted: #607080;
  --primary: #1769aa;
  --shadow: 0 10px 28px rgba(31, 50, 72, 0.08);
}

* { box-sizing: border-box; }

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

button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid rgba(23, 105, 170, .22); outline-offset: 2px; }

.public-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px max(24px, calc((100vw - 1320px) / 2));
  color: #fff;
  background: linear-gradient(130deg, #17283d, #24587e);
  box-shadow: 0 8px 24px rgba(20, 40, 60, .18);
}
.public-header h1 { margin: 4px 0 0; font-size: clamp(27px, 4vw, 38px); line-height: 1.15; }
.public-header p { margin: 7px 0 0; color: #d7e4ef; }
.readonly-badge {
  display: inline-block;
  padding: 3px 9px;
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  color: inherit;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
}
.header-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.header-actions form { margin: 0; }
.header-actions button, .header-actions a, .login-form button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 9px 15px;
  font-weight: 700;
  line-height: 1.45;
  text-decoration: none;
}
.secondary-button { background: #fff; color: #174b70; }
.ghost-button { border-color: rgba(255, 255, 255, .45) !important; background: transparent; color: #fff; }

.wrap { width: min(1320px, calc(100% - 32px)); margin: 22px auto 36px; }
.panel {
  margin-bottom: 16px;
  padding: 20px;
  border: 1px solid #e1e6ec;
  border-radius: 11px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 13px; font-size: 21px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.panel-head h2 { margin-bottom: 4px; }
.section-note { margin: 0; color: var(--muted); font-size: 13px; }
.heading-note { font-size: 12px; font-weight: 400; }
.muted { color: var(--muted); }
.calibration-note { margin-bottom: 8px; }

.temp-date-controls { display: grid; grid-template-columns: auto minmax(150px, 190px) auto; align-items: center; gap: 9px; margin: 0; }
.temp-date-controls label { color: #455a64; font-size: 13px; font-weight: 700; }
.temp-date-controls input {
  width: 100%;
  min-height: 39px;
  padding: 7px 10px;
  border: 1px solid #b9c6d3;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}
.temp-date-controls button {
  min-height: 39px;
  padding: 7px 13px;
  border: 1px solid #1769aa;
  border-radius: 6px;
  background: #1769aa;
  color: #fff;
  font-weight: 700;
}
.temp-run-status { min-height: 18px; margin-top: 7px; line-height: 1.6; }
.temp-run-status.running { color: #856404; }
.temp-run-status.warning { color: #a96100; }
.temp-run-status.success { color: #2e7d32; }
.temp-run-status.error, .temp-null { color: #c62828; }
.temp-source-status { margin-top: 5px; line-height: 1.6; }

.temp-score { font-size: 46px; font-weight: 800; line-height: 1; }
.temp-very-cold { color: #0d47a1; }
.temp-cold { color: #1976d2; }
.temp-neutral { color: #616161; }
.temp-warm { color: #ef6c00; }
.temp-hot { color: #c62828; }
.temp-heat-band {
  display: inline-block;
  min-width: 34px;
  padding: 2px 7px;
  border-radius: 10px;
  text-align: center;
  font-size: 12px;
  line-height: 1.4;
  font-weight: 800;
  white-space: nowrap;
}
.temp-heat-band-very-cold { color: #fff; background: #0d47a1; }
.temp-heat-band-cold { color: #0d47a1; background: #dbeeff; border: 1px solid #90caf9; }
.temp-heat-band-middle { color: #424242; background: #eee; border: 1px solid #c7c7c7; }
.temp-heat-band-hot { color: #a84300; background: #fff0dc; border: 1px solid #ffb85c; }
.temp-heat-band-very-hot { color: #fff; background: #c62828; }
.temp-heat-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin: 12px 0 2px;
  padding: 9px 11px;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  background: #f8fafc;
  font-size: 12px;
}

.temp-intuitive-summary {
  margin: 10px 0;
  padding: 9px 11px;
  border-left: 4px solid #78909c;
  border-radius: 4px;
  background: #fff;
  font-size: 13px;
  line-height: 1.65;
}
.temp-intuitive-facts, .temp-state-subs { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 5px 0 2px; }
.temp-market-facts {
  margin: 9px 0;
  padding: 9px 11px;
  border-radius: 6px;
  background: #f4f7fa;
  color: #455a64;
  font-size: 13px;
  line-height: 1.7;
}
.temp-market-conclusion { margin-top: 4px; color: #8a5a00; }
.temp-strategy-context {
  margin: 10px 0;
  padding: 9px 11px;
  border: 1px dashed #b0bec5;
  border-radius: 6px;
  background: #fafafa;
  color: #455a64;
  font-size: 12px;
  line-height: 1.65;
}
.temp-badge { display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.temp-badge-ok { background: #e8f5e9; color: #2e7d32; }
.temp-badge-warn { background: #fff3e0; color: #e65100; }
.temp-parts { width: 100%; margin-top: 12px; border-collapse: collapse; font-size: 13px; }
.temp-parts th, .temp-parts td { padding: 5px 7px; border-bottom: 1px solid #e8edf2; text-align: right; }
.temp-parts th:first-child, .temp-parts td:first-child { text-align: left; }
.temp-parts tr.selected { background: #f5f9ff; font-weight: 700; }

.temp-decision-grid, .temp-calibration-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.temp-decision-card, .temp-calibration-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}
.temp-calibration-card { padding: 12px; background: #fbfcfd; }
.temp-decision-card h3, .temp-calibration-card h3 { margin: 0 0 5px; font-size: 17px; }
.temp-decision-rule { margin-bottom: 12px; color: #546e7a; font-size: 12px; }
.temp-decision-warning, .temp-state-not-forecast {
  margin-top: 10px;
  padding: 7px 9px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 800;
}
.temp-decision-warning { color: #b71c1c; background: #ffebee; }
.temp-state-not-forecast { border: 1px solid #ffe0a3; color: #8a5a00; background: #fff8e1; }
.temp-tomorrow-section { margin-top: 14px; padding-top: 14px; border-top: 2px solid var(--line); }
.temp-tomorrow-section h4 { margin: 0 0 5px; }
.temp-action-box { padding: 10px 12px; border: 1px solid var(--line); border-left-width: 5px; border-radius: 7px; background: #f6f7f8; }
.temp-action-box.temp-action-observe { border-left-color: #78909c; background: #f5f7f8; }
.temp-action-box.temp-action-warning { border-left-color: #d49a18; background: #fff8e1; }
.temp-action-box.temp-action-open { border-left-color: #2e7d32; background: #edf7ee; }
.temp-action-box.temp-action-reduce { border-left-color: #ef8c00; background: #fff5e6; }
.temp-action-box.temp-action-no-new { border-left-color: #d66a00; background: #fff0e3; }
.temp-action-box.temp-action-clear { border-left-color: #c62828; background: #ffebee; }
.temp-action-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.temp-action-label { font-size: 16px; font-weight: 800; }
.temp-action-status { color: #607d8b; font-size: 12px; }
.temp-action-facts, .temp-action-evidence { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 12px; margin-top: 9px; font-size: 12px; }
.temp-action-reason { margin-top: 9px; color: #5f4b20; font-size: 12px; line-height: 1.55; }
.temp-action-disclaimer { margin-top: 8px; color: #607d8b; font-size: 11px; }
.temp-history-edge { margin-top: 12px; padding-top: 11px; border-top: 1px solid #e1e5ea; }
.temp-history-edge h4 { margin: 0 0 5px; }
.temp-retrospective-note { color: #8a5a00; font-size: 12px; font-weight: 800; }
.temp-next-actual, .temp-drawdown { margin-top: 8px; padding: 8px 10px; border-radius: 6px; background: #f4f6f8; font-size: 12px; line-height: 1.65; }
.temp-hit-yes, .temp-calibration-ok { color: #2e7d32; font-weight: 800; }
.temp-hit-no { color: #c62828; font-weight: 800; }
.temp-calibration-warning { padding: 7px 9px; border-radius: 5px; color: #8a5a00; background: #fff8e1; line-height: 1.55; }
.temp-calibration-stats { margin-top: 8px; line-height: 1.65; }
.temp-signal-line { margin-top: 8px; color: #455a64; font-size: 13px; }

.temp-day-scroll {
  width: 100%;
  max-width: 100%;
  min-height: 420px;
  max-height: calc(100vh - 270px);
  overflow: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: #94a3b8 #e8edf2;
}
.temp-day-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.temp-day-scroll::-webkit-scrollbar-track { background: #e8edf2; border-radius: 999px; }
.temp-day-scroll::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 999px; }
.temp-day-list { display: grid; gap: 10px; padding-right: 4px; }
.temp-day-card { overflow: hidden; border: 1px solid #e1e5ea; border-radius: 8px; background: #fff; }
.temp-day-card[open] { border-color: #b9c8da; box-shadow: 0 2px 8px rgba(32, 61, 90, .08); }
.temp-day-card > summary {
  display: grid;
  grid-template-columns: 220px 90px 120px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}
.temp-day-card > summary::-webkit-details-marker { display: none; }
.temp-day-card > summary::after { content: "展开"; color: #607d8b; font-size: 12px; }
.temp-day-card[open] > summary::after { content: "收起"; }
.temp-day-date, .temp-day-dates { font-weight: 800; }
.temp-day-dates { display: grid; gap: 2px; }
.temp-day-dates small { color: #607d8b; font-weight: 500; }
.temp-day-score { font-size: 24px; font-weight: 800; }
.temp-day-meta { color: #607d8b; font-size: 12px; }
.temp-day-body { padding: 0 14px 12px; border-top: 1px solid #edf0f2; }
.temp-day-card.temp-row-warn { background: #fffde7; }
.temp-day-card.temp-row-invalid { border-color: #ef9a9a; }

footer { padding: 0 20px 30px; color: #64748b; text-align: center; font-size: 12px; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(145deg, #edf3f8, #dfeaf2); }
.login-card { width: min(440px, 100%); padding: 30px; border: 1px solid #d7e0e8; border-radius: 14px; background: #fff; box-shadow: 0 20px 50px rgba(34, 55, 76, .15); }
.login-card .readonly-badge { border-color: #9cb4c8; color: #24587e; background: #edf5fb; }
.login-card h1 { margin: 10px 0 4px; font-size: 29px; }
.login-form { display: grid; gap: 9px; margin-top: 22px; }
.login-form label { font-weight: 700; }
.login-form input { width: 100%; min-height: 44px; padding: 9px 11px; border: 1px solid #aebdca; border-radius: 7px; }
.login-form button { margin-top: 5px; background: #1769aa; color: #fff; }
.login-error { padding: 9px 11px; border-left: 4px solid #c62828; border-radius: 5px; color: #8d1d1d; background: #ffebee; font-size: 13px; }

.loading-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(145deg, #edf3f8, #dfeaf2);
}
.loading-card {
  width: min(460px, 100%);
  padding: 34px 30px;
  border: 1px solid #d7e0e8;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 20px 50px rgba(34, 55, 76, .15);
  text-align: center;
}
.loading-card .readonly-badge { border-color: #9cb4c8; color: #24587e; background: #edf5fb; }
.loading-card h1 { margin: 18px 0 7px; font-size: 27px; line-height: 1.25; }
.loading-spinner {
  width: 54px;
  height: 54px;
  margin: 25px auto 0;
  border: 5px solid #dce8f1;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: public-temperature-spin .85s linear infinite;
}
.loading-hint { margin: 15px 0 0; color: #718096; font-size: 13px; }
.loading-continue {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
  border: 1px solid #b7cad9;
  border-radius: 7px;
  padding: 8px 13px;
  background: #edf5fb;
  color: #174b70;
  font-weight: 700;
  text-decoration: none;
}

@keyframes public-temperature-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .loading-spinner { animation: none; }
}

@media (max-width: 900px) {
  .public-header { align-items: flex-start; padding: 20px; }
  .wrap { width: min(100% - 20px, 1320px); margin-top: 12px; }
  .panel { padding: 14px; }
  .panel-head { display: grid; }
  .temp-date-controls { justify-self: stretch; }
  .temp-decision-grid, .temp-calibration-grid { grid-template-columns: 1fr; }
  .temp-action-facts, .temp-action-evidence { grid-template-columns: 1fr; }
  .temp-day-card > summary { grid-template-columns: 100px 70px 1fr auto; }
  .temp-day-meta { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
  body { font-size: 14px; }
  .public-header { display: grid; gap: 16px; }
  .header-actions { width: 100%; }
  .header-actions button, .header-actions a { flex: 1; }
  .header-actions form { display: flex; flex: 1; }
  .header-actions form button { width: 100%; }
  .temp-date-controls { grid-template-columns: 1fr; }
  .temp-day-scroll { min-height: 360px; }
  .temp-day-card > summary { grid-template-columns: 1fr auto; gap: 7px; }
  .temp-day-score { font-size: 21px; }
  .temp-day-meta { grid-column: 1 / -1; }
}
