:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: #172b22;
  background: #f3f4ec;
  font-synthesis: none;
  --ink: #172b22;
  --muted: #526359;
  --line: #dce4da;
  --surface: #fffefa;
  --green: #245c45;
  --deep: #183e30;
  --leaf: #e8f0e4;
  --danger: #a03d34;
  --radius: 18px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { min-width: 280px; min-height: 100vh; margin: 0; font-size: 1rem; line-height: 1.5; }
h1, h2, p, figure { margin: 0; }
h1, h2 { line-height: 1.2; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled, select:disabled { cursor: default; }
button:disabled { opacity: .58; }
a { color: inherit; text-decoration: none; }
input, textarea, select { color: var(--ink); }
fieldset { min-inline-size: 0; margin: 0; padding: 0; border: 0; }
:focus-visible { outline: 2px solid #347f5a; outline-offset: 3px; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.frame { width: min(1120px, calc(100% - 64px)); margin-inline: auto; }
.masthead { background: #fffefa; border-bottom: 1px solid #e4e8de; }
.masthead-inner { display: flex; min-height: 66px; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: .65rem; font-size: .95rem; font-weight: 720; }
.brand-mark {
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  width: 33px;
  height: 33px;
  border-radius: 10px;
  background: #245c45;
}
.brand-mark::before {
  position: absolute;
  top: 9px;
  left: 8px;
  width: 17px;
  height: 15px;
  border: 1.5px solid #f4f9ea;
  border-radius: 5px;
  content: "";
}
.brand-mark::after {
  position: absolute;
  top: 12px;
  left: 16px;
  width: 1.5px;
  height: 6px;
  border-radius: 2px;
  background: #f4f9ea;
  transform: rotate(35deg);
  transform-origin: bottom;
  content: "";
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: .25em;
  padding: .5rem .9rem;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--green);
  background: transparent;
  font-size: .9rem;
  font-weight: 650;
  line-height: 1.25;
  white-space: nowrap;
}
.button-quiet:hover:not(:disabled) { background: var(--leaf); }
.button-outline { border-color: #cddbcc; background: #fbfcf6; }
.button-outline:hover:not(:disabled) { background: var(--leaf); }
.button-primary { color: #fffefa; background: var(--green); }
.button-primary:hover:not(:disabled) { background: #194b36; }
.button-danger { color: #fff; background: var(--danger); }
.button-danger:hover:not(:disabled) { background: #873027; }

.dashboard { padding-block: 33px 56px; }
.overview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 276px;
  align-items: center;
  gap: 22px;
  margin-bottom: 22px;
}
.overview h1 { font-size: clamp(2rem, 4vw, 3rem); font-weight: 750; letter-spacing: -.045em; }
.people-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 18px; }
.people-bar > label { color: var(--muted); font-size: .9rem; font-weight: 650; }
.people-actions { display: flex; flex-wrap: wrap; gap: 2px; }
.people-actions .button { padding-inline: .6rem; }
.select-wrap { position: relative; flex: 0 1 174px; min-width: 102px; }
.select-wrap::after {
  position: absolute;
  top: calc(50% - 5px);
  right: 15px;
  width: 7px;
  height: 7px;
  transform: rotate(45deg);
  border-right: 1.5px solid var(--green);
  border-bottom: 1.5px solid var(--green);
  pointer-events: none;
  content: "";
}
.select-wrap select {
  display: block;
  width: 100%;
  min-height: 42px;
  padding: .45rem 2rem .45rem .75rem;
  appearance: none;
  border: 1px solid #cddbcf;
  border-radius: 8px;
  background: #fffefa;
  font-weight: 650;
  text-overflow: ellipsis;
}
.latest {
  position: relative;
  isolation: isolate;
  display: grid;
  min-height: 136px;
  align-content: center;
  row-gap: 3px;
  overflow: hidden;
  padding: 17px 23px;
  border: 1px solid #24513d;
  border-radius: 15px;
  color: #f6f9e9;
  background: #204936;
}
.latest::after {
  position: absolute;
  z-index: -1;
  top: -13px;
  right: -39px;
  width: 162px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: repeating-radial-gradient(circle, transparent 0 12px, rgb(219 241 210 / 13%) 13px 14px, transparent 15px 19px);
  content: "";
  pointer-events: none;
}
.latest-label, .latest-date { color: #d9e9d7; font-size: .875rem; }
.latest-value { line-height: 1.1; font-size: 2.1rem; font-weight: 730; letter-spacing: -.055em; overflow-wrap: anywhere; }
.latest-unit { color: #d9e9d7; font-size: 1rem; font-weight: 520; letter-spacing: 0; }
.latest-date { min-height: 1.25em; }

.notice-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin: 0 0 16px;
  padding: .65rem 1rem;
  border: 1px solid #cbdcc9;
  border-radius: 10px;
  color: #244d36;
  background: #e9f2e5;
  font-size: .9rem;
  overflow-wrap: anywhere;
}
.notice-bar[data-tone="error"] { border-color: #efc9c3; color: #8a352d; background: #fff1ee; }
.notice-bar .button { min-height: 36px; }

.work-area { display: grid; grid-template-columns: minmax(310px, .53fr) minmax(0, 1fr); gap: 18px; }
.card { min-width: 0; border: 1px solid #e0e6dc; border-radius: var(--radius); background: var(--surface); }
.entry, .trend, .history { padding: 23px; }
.card-heading { margin-bottom: 19px; }
.card h2, .dialog h2 { font-size: 1.25rem; font-weight: 730; letter-spacing: -.025em; }
.card-caption { margin-top: .4rem; color: var(--muted); font-size: .875rem; }
.entry-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 14px 10px; }
.note-field { grid-column: 1 / -1; }
.field { display: grid; gap: .4rem; min-width: 0; }
.field label { color: #32473b; font-size: .9rem; font-weight: 650; }
.optional { margin-left: .3em; color: var(--muted); font-size: .8rem; font-weight: 400; }
.field input, .field textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 45px;
  padding: .5rem .65rem;
  border: 1px solid #d5dfd2;
  border-radius: 8px;
  background: #fafbf6;
}
.field input:focus, .field textarea:focus { background: #fff; }
.field input::placeholder, .field textarea::placeholder { color: #5d6e61; opacity: 1; }
.field input:disabled, .field textarea:disabled { opacity: .7; }
.field input[type="date"] { font-variant-numeric: tabular-nums; }
.field textarea { min-height: 85px; resize: vertical; }
.unit-field { position: relative; }
.unit-field input { padding-right: 2.4rem; appearance: textfield; }
.unit-field input::-webkit-inner-spin-button, .unit-field input::-webkit-outer-spin-button { appearance: none; }
.unit-field > span { position: absolute; top: 50%; right: .65rem; translate: 0 -50%; color: var(--muted); pointer-events: none; }
.entry-actions { display: flex; gap: 6px; margin-top: 15px; }
.entry-actions .button-primary { flex: 1; }
.field-hint { margin-top: .55rem; color: var(--muted); font-size: .83rem; }

.trend-heading { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.range-switch {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid #dde6d9;
  border-radius: 9px;
  background: #f2f5ed;
}
.range-switch label { position: relative; display: flex; min-width: 0; cursor: pointer; }
.range-switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.range-switch span {
  display: grid;
  min-height: 34px;
  place-items: center;
  padding-inline: .65rem;
  border-radius: 6px;
  color: #455b4e;
  font-size: .84rem;
  font-weight: 650;
  white-space: nowrap;
}
.range-switch input:checked + span { color: #fff; background: var(--green); }
.range-switch input:focus-visible + span { outline: 2px solid #347f5a; outline-offset: 2px; }
.range-switch label:hover input:not(:checked) + span { background: #e5eee1; }
.plot { position: relative; }
.plot canvas { display: block; width: 100%; height: 225px; border-radius: 5px; }
.chart-empty {
  position: absolute;
  inset: 18px 18px 25px 38px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: .9rem;
  text-align: center;
  pointer-events: none;
}
.chart-caption {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 4px 15px;
  min-height: 24px;
  color: var(--muted);
  font-size: .86rem;
}
.chart-key { display: inline-flex; align-items: center; gap: .45rem; }
.chart-key::before { width: 16px; height: 2px; border-radius: 1px; background: #2d7653; content: ""; }
.chart-readout { font-variant-numeric: tabular-nums; }

.history { margin-top: 18px; }
.history-heading, .history-title { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; }
.history-heading { justify-content: space-between; gap: .75rem; margin-bottom: 14px; }
.history-count { color: var(--muted); font-size: .87rem; }
.history-body { border: 1px solid #e2e8de; border-radius: 11px; overflow: hidden; }
.history-empty { padding: 1.25rem 1rem; color: var(--muted); text-align: center; }
.history table { width: 100%; border-collapse: collapse; table-layout: fixed; text-align: left; }
.history th, .history td { padding: .55rem .9rem; vertical-align: top; overflow-wrap: anywhere; }
.history th { color: #415749; background: #f0f4eb; font-size: .875rem; font-weight: 680; }
.history th:nth-child(1) { width: 19%; }
.history th:nth-child(2) { width: 17%; }
.history th:nth-child(4) { width: 116px; text-align: right; }
.history tbody tr + tr { border-top: 1px solid #e9ede5; }
.history tbody tr:hover { background: #f8fbf5; }
.history td { color: #3c5043; font-size: .95rem; }
.history td:nth-child(1), .history td:nth-child(2) { font-variant-numeric: tabular-nums; }
.history td:nth-child(2) { color: var(--ink); font-weight: 700; }
.history td:nth-child(3) { white-space: pre-wrap; }
.history td:last-child { padding-block: .25rem; }
.history .row-actions { display: flex; justify-content: flex-end; gap: 3px; }
.history .row-actions .button { min-height: 36px; padding: .35rem .4rem; font-size: .85rem; }
.history .delete-action { color: var(--danger); }
.history .delete-action:hover:not(:disabled) { background: #faedea; }
.history .kg { color: var(--muted); font-size: .8rem; font-weight: 500; }

.dialog {
  width: min(390px, calc(100% - 30px));
  padding: 25px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 18px 50px rgb(29 49 38 / 18%);
}
.dialog::backdrop { background: rgb(19 36 27 / 45%); }
.dialog h2 { margin-bottom: 1rem; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem; }
.dialog-error { margin-top: .9rem; color: #94372f; font-size: .9rem; overflow-wrap: anywhere; }

.login-page { display: grid; min-height: 100svh; place-items: center; padding: 24px; }
.login-shell {
  display: grid;
  grid-template-columns: .7fr 1fr;
  width: min(660px, 100%);
  overflow: hidden;
  border: 1px solid #e0e6dc;
  border-radius: 21px;
  background: var(--surface);
  box-shadow: 0 14px 46px rgb(39 63 47 / 9%);
}
.login-brand { position: relative; isolation: isolate; overflow: hidden; padding: 26px; color: #f4f9ea; background: var(--deep); }
.login-brand .brand-mark { background: #346b50; }
.login-pattern {
  position: absolute;
  z-index: -1;
  right: -59px;
  bottom: -96px;
  width: 300px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: repeating-radial-gradient(circle, transparent 0 15px, rgb(213 235 204 / 24%) 16px 17px, transparent 18px 24px);
}
.login-panel { padding: clamp(1.5rem, 5vw, 2.6rem); }
.login-panel h1 { font-size: clamp(1.6rem, 4vw, 2rem); letter-spacing: -.04em; }
.login-panel > p { margin-top: .6rem; color: var(--muted); font-size: .95rem; }
.login-panel form { margin-top: 1.5rem; }
.login-panel .button { width: 100%; margin-top: 1.1rem; }

@media (max-width: 900px) {
  .frame { width: calc(100% - 40px); }
  .work-area { grid-template-columns: minmax(275px, .75fr) minmax(0, 1fr); }
  .entry, .trend, .history { padding: 18px; }
}

@media (max-width: 690px) {
  .frame { width: calc(100% - 28px); }
  .masthead-inner { min-height: 56px; }
  .dashboard { padding-block: 20px 35px; }
  .overview { grid-template-columns: minmax(0, 1fr); gap: 13px; margin-bottom: 14px; }
  .people-bar { margin-top: 13px; }
  .latest { grid-template-columns: minmax(0, 1fr) auto; min-height: 82px; align-items: center; padding: 12px 16px; }
  .latest-label { grid-row: 1; grid-column: 1; }
  .latest-date { grid-row: 2; grid-column: 1; }
  .latest-value { grid-row: 1 / 3; grid-column: 2; font-size: 1.95rem; text-align: end; }
  .work-area { grid-template-columns: minmax(0, 1fr); gap: 13px; }
  .history { margin-top: 13px; }
  .history th, .history td { padding-inline: .5rem; font-size: .84rem; }
  .history th:nth-child(1) { width: 30%; }
  .history th:nth-child(2) { width: 21%; }
  .history th:nth-child(4) { width: 86px; }
  .history .row-actions .button { padding-inline: .25rem; }
}

@media (max-width: 440px) {
  .select-wrap { flex-basis: min(36vw, 144px); }
  .people-bar { gap: 5px 7px; }
  .people-actions .button { padding-inline: .32rem; }
  .entry, .trend, .history { padding: 15px; }
  .range-switch { flex: 0 1 auto; }
  .range-switch span { padding-inline: .55rem; }
  .history th, .history td { padding-inline: .35rem; }
  .login-page { padding: 17px; }
  .login-shell { grid-template-columns: minmax(0, 1fr); }
  .login-brand { min-height: 76px; padding: 20px 24px; }
  .login-pattern { right: -30px; bottom: -120px; width: 220px; }
}
