:root {
  color-scheme: light;
  --bg: #f4f7f3;
  --panel: #ffffff;
  --ink: #18211d;
  --muted: #667067;
  --line: #d9e2d8;
  --green: #2d7d59;
  --red: #c24a3a;
  --blue: #276b9f;
  --gold: #a26d16;
  --shadow: 0 16px 45px rgba(31, 47, 37, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.68), rgba(244, 247, 243, 0.85)),
    url("https://images.unsplash.com/photo-1581595220892-b0739db3ba8c?auto=format&fit=crop&w=1800&q=80") center/cover fixed;
  color: var(--ink);
  font-family:
    "Segoe UI",
    "Hiragino Kaku Gothic ProN",
    Meiryo,
    sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  min-height: 118px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.2rem, 7vw, 4.8rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 0;
  font-size: 1.08rem;
}

.today {
  color: var(--muted);
  font-weight: 700;
  text-align: right;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 22px 0;
}

.app-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 0;
}

.app-switch a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-weight: 800;
  padding: 0 14px;
  text-decoration: none;
}

.app-switch a.active {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.metric,
.panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(217, 226, 216, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.metric {
  min-height: 130px;
  padding: 18px;
  border-radius: 8px;
}

.metric span,
.metric small {
  display: block;
  color: var(--muted);
}

.metric strong {
  display: block;
  margin: 10px 0 6px;
  font-size: clamp(1.5rem, 3vw, 2.3rem);
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.78fr) minmax(420px, 1.22fr);
  gap: 16px;
  align-items: stretch;
}

.panel {
  border-radius: 8px;
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.entry-form {
  display: grid;
  gap: 14px;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field-row.numbers {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

label span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfdfb;
  color: var(--ink);
  outline: none;
}

input {
  height: 44px;
  padding: 0 12px;
}

select {
  height: 44px;
  padding: 0 36px 0 12px;
}

textarea {
  min-height: 86px;
  resize: vertical;
  padding: 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(45, 125, 89, 0.14);
}

.primary-button,
.actions button,
.icon-button,
.member-form button,
.member-tab,
.delete-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.primary-button {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.icon-button {
  width: 40px;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
}

.actions {
  display: flex;
  gap: 8px;
}

.actions button {
  padding: 0 14px;
}

.family-panel {
  margin: 18px 0 0;
}

.compact-label {
  min-width: min(240px, 48vw);
}

.member-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-bottom: 14px;
}

.member-form button {
  padding: 0 18px;
}

.member-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.member-tab {
  padding: 0 14px;
}

.member-tab.active {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.medical-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.55;
}

.chart-panel {
  min-width: 0;
}

canvas {
  display: block;
  width: 100%;
  height: 300px;
  border-radius: 6px;
  background: #fbfdfb;
  border: 1px solid var(--line);
}

.legend {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend i {
  width: 18px;
  height: 4px;
  border-radius: 999px;
}

.legend .sys {
  background: var(--red);
}

.legend .dia {
  background: var(--blue);
}

.records-panel {
  margin-top: 16px;
}

.record-list {
  display: grid;
  gap: 10px;
}

.empty {
  padding: 26px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.record-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

.record-main {
  display: block;
  font-size: 1.28rem;
}

.record-date {
  color: var(--muted);
  font-size: 0.88rem;
}

.record-note {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.body-record-card {
  grid-template-columns: 1fr auto;
}

.body-details {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 4px 0 0;
}

.body-details div {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 10px;
}

.body-details dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.body-details dd {
  margin: 4px 0 0;
  font-size: 1.02rem;
  font-weight: 800;
}

.weight-line {
  background: var(--green);
}

.fat-line {
  background: var(--gold);
}

.delete-button {
  padding: 0 12px;
}

.status-normal {
  color: var(--green);
}

.status-caution {
  color: var(--gold);
}

.status-high {
  color: var(--red);
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    min-height: 92px;
  }

  .today {
    text-align: left;
  }

  .summary-grid,
  .workspace {
    grid-template-columns: 1fr;
  }

  .field-row,
  .field-row.numbers,
  .member-form {
    grid-template-columns: 1fr;
  }

  .compact-label {
    width: 100%;
  }

  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .record-card {
    grid-template-columns: 1fr;
  }

  .body-details {
    grid-template-columns: 1fr 1fr;
  }

  .delete-button {
    width: 100%;
  }
}

@media (max-width: 460px) {
  .body-details {
    grid-template-columns: 1fr;
  }
}
