:root {
  --bg: #0b1020;
  --card: #151b2e;
  --card-border: #232b45;
  --text: #e6e9f2;
  --text-dim: #8b93ab;
  --green: #2ecc71;
  --yellow: #f1c40f;
  --orange: #e67e22;
  --red: #e74c3c;
  --gray: #4a5570;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Noto Sans TC", sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 16px;
  line-height: 1.4;
  max-width: 800px;
  margin: 0 auto;
}

/* ================= 頁首 ================= */
.header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 20px;
}

.header h1 {
  margin: 0;
  font-size: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-logo {
  height: 28px;
  width: auto;
}

.header .meta {
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.header .version {
  font-size: 11px;
  padding: 2px 6px;
  background: var(--card-border);
  border-radius: 4px;
  font-family: monospace;
  align-self: flex-start;
}

/* ================= 卡片區 ================= */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.card {
  background: linear-gradient(145deg, #151b2e, #111626);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 130px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.card:hover {
  border-color: var(--text-dim);
  transform: translateY(-2px);
}

.card:active {
  transform: scale(0.98);
}

.card .label {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
}

.card .value {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin: 4px 0;
  color: #ffffff;
  word-break: break-all;
}

.card .value.unavailable {
  font-size: 15px;
  color: var(--text-dim);
  font-style: italic;
  font-weight: 400;
}

.card .status {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.card .footer {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: auto;
  border-top: 1px solid var(--card-border);
  padding-top: 8px;
  word-break: break-all;
}

/* ================= 狀態圓點 ================= */
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot.green { background: var(--green); }
.dot.yellow { background: var(--yellow); }
.dot.orange { background: var(--orange); }
.dot.red { background: var(--red); }
.dot.gray { background: var(--gray); }

/* ================= 健康小知識 ================= */
.health-tips {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-left: 4px solid var(--gray);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  transition: border-color 0.3s ease;
}

.health-tips.level-green { border-left-color: var(--green); }
.health-tips.level-yellow { border-left-color: var(--yellow); }
.health-tips.level-orange { border-left-color: var(--orange); }
.health-tips.level-red { border-left-color: var(--red); }

.health-tips h2 {
  margin: 0 0 12px;
  font-size: 16px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.health-tips p {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.6;
}

.health-tips p:last-child {
  margin-bottom: 0;
}

.health-tips .advice {
  color: var(--text);
  font-weight: 500;
}

.health-tips .disclaimer {
  font-size: 12px;
  color: var(--text-dim);
  font-style: italic;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--card-border);
}

/* ================= 底部提示 ================= */
.note {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 8px;
}

/* ================= 模態框 ================= */
.hidden {
  display: none !important;
}

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 16px;
}

.modal-content {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  width: 100%;
  max-width: 400px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--card-border);
}

.modal-header h3 {
  margin: 0;
  font-size: 16px;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-body {
  padding: 16px;
}

.level-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--card-border);
  font-size: 14px;
}

.level-row:last-child {
  border-bottom: none;
}

.level-range {
  color: var(--text-dim);
  font-family: monospace;
}

.level-label {
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 13px;
}

.level-label.green { background: rgba(46, 204, 113, 0.2); color: var(--green); }
.level-label.yellow { background: rgba(241, 196, 15, 0.2); color: var(--yellow); }
.level-label.orange { background: rgba(230, 126, 34, 0.2); color: var(--orange); }
.level-label.red { background: rgba(231, 76, 60, 0.2); color: var(--red); }