body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  margin: 1.5rem;
  background: #fafafa;
  color: #222;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.5rem;
}
header h1 { margin: 0 0 0.25rem; font-size: 1.4rem; }
header .subtitle { color: #666; margin-bottom: 1rem; font-size: 0.9rem; }
.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.header-right #user-name { color: #666; font-size: 0.9rem; }

button {
  background: white;
  border: 1px solid #ccc;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  border-radius: 3px;
  font-size: 0.85rem;
}
button:hover { background: #eee; }

#pending {
  background: #fff3cd;
  border: 1px solid #e0c878;
  border-radius: 4px;
  padding: 0.4rem 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}

.cards {
  display: flex; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.card {
  background: white; padding: 0.5rem 0.75rem;
  border: 1px solid #ddd; border-radius: 4px;
  min-width: 7rem;
}
.card .label {
  color: #666; font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 0.05em;
}
.card .value { font-size: 1.05rem; font-weight: 600; margin-top: 0.15rem; }
.card .sub { color: #888; font-size: 0.75rem; margin-top: 0.15rem; }
.up { color: #0a8a3a; }
.down { color: #c0392b; }

.controls {
  display: flex; gap: 1.5rem; margin-bottom: 0.5rem; flex-wrap: wrap;
  align-items: center;
}
.button-group { display: flex; gap: 0.25rem; }
.button-group .group-label {
  color: #666; font-size: 0.75rem; align-self: center; margin-right: 0.4rem;
}
.button-group button.active {
  background: #1f6feb; color: white; border-color: #1f6feb;
}
.relative-toggle {
  font-size: 0.85rem; color: #444;
  display: flex; align-items: center; gap: 0.35rem;
}

#chart {
  background: white; padding: 0.5rem;
  border: 1px solid #ddd; border-radius: 4px;
}
#empty-state {
  background: white; padding: 2rem;
  border: 1px dashed #bbb; border-radius: 4px;
  color: #666; text-align: center;
}

.legend-note {
  margin-top: 0.5rem; color: #888; font-size: 0.8rem; max-width: 60rem;
}

.bmi-scale {
  margin-top: 1rem;
  background: white;
  padding: 0.6rem 0.85rem 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  position: relative;
}
.bmi-scale-title {
  font-size: 0.7rem; color: #666;
  text-transform: uppercase; letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}
.bmi-scale-track {
  position: relative;
  height: 64px;
  margin: 0 0.6rem;
}
.bmi-scale-bar {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 24px;
  display: flex;
  border: 1px solid #999;
  border-radius: 3px;
  overflow: hidden;
}
.bmi-scale-segment {
  height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; color: #333;
  white-space: nowrap; overflow: hidden;
}
.bmi-scale-ticks {
  position: absolute;
  left: 0; right: 0; top: 30px;
  height: 32px;
}
.bmi-scale-tick {
  position: absolute;
  transform: translateX(-50%);
  text-align: center;
  font-size: 0.7rem; line-height: 1.15;
}
.bmi-scale-tick .tick-bmi { color: #444; font-weight: 600; }
.bmi-scale-tick .tick-weight { color: #888; }
.bmi-scale-indicator-wrap {
  position: absolute;
  top: -2px; height: 32px;
  pointer-events: none;
}
.bmi-scale-indicator {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: #000;
  transform: translateX(-1px);
}
.bmi-scale-indicator-label {
  position: absolute;
  top: -22px;
  background: #000; color: white;
  padding: 2px 6px;
  font-size: 0.7rem;
  border-radius: 3px;
  white-space: nowrap;
  transform: translateX(-50%);
}

.panels {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.panel {
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 0.75rem 1rem 1rem;
  flex: 1;
  min-width: 16rem;
}
.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.panel form label {
  display: block;
  font-size: 0.8rem;
  color: #444;
  margin: 0.5rem 0 0.2rem;
}
.panel input[type="date"],
.panel input[type="text"] {
  padding: 0.35rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.9rem;
  box-sizing: border-box;
}
.panel form button { margin-top: 0.75rem; }
.form-error { color: #c0392b; font-size: 0.85rem; min-height: 1.2em; margin: 0.5rem 0 0; }

.height-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.height-row #height-display { font-weight: 600; }
.height-row #height-input { width: 5rem; }

.panel input[type="url"],
.panel input[type="password"] {
  padding: 0.35rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.9rem;
  box-sizing: border-box;
  width: 100%;
}
#sync-form input[type="text"] { width: 100%; }
#sync-status { font-size: 0.9rem; }
#sync-status .sync-line { margin: 0.15rem 0; }
#sync-status .sync-remote { font-weight: 600; word-break: break-all; }
#sync-status .sync-error-line { color: #c0392b; }
.sync-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
/* The display:flex above would otherwise beat the UA's [hidden] rule. */
.sync-actions[hidden] { display: none; }

.measurements-panel { margin-top: 1rem; }
#measurement-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 24rem;
  overflow-y: auto;
}
#measurement-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.3rem 0.25rem;
  border-bottom: 1px solid #eee;
  font-size: 0.9rem;
}
#measurement-list li:last-child { border-bottom: none; }
#measurement-list .m-date { color: #666; min-width: 6.5rem; }
#measurement-list .m-weight { font-weight: 600; min-width: 5rem; }
#measurement-list .m-spacer { flex: 1; }
#measurement-list .m-edit-date { width: 9.5rem; }
#measurement-list .m-edit-weight { width: 5rem; }
#measurement-list button { font-size: 0.75rem; padding: 0.2rem 0.5rem; }
#measurement-list .m-delete { color: #c0392b; }
