:root {
  --bg: #f4fbf2;
  --panel: rgba(255, 255, 255, 0.92);
  --line: #c9e1cf;
  --text: #173128;
  --muted: #61746a;
  --accent: #18a66f;
  --accent-strong: #0d6f52;
  --warn: #c94840;
  --shadow: 0 18px 45px rgba(42, 93, 70, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Hiragino Sans", sans-serif;
  color: var(--text);
  background:
    linear-gradient(150deg, rgba(228, 248, 220, 0.86) 0%, rgba(240, 252, 246, 0.96) 42%, rgba(255, 247, 226, 0.9) 100%);
}

button,
input {
  font: inherit;
}

.app {
  width: min(960px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 64px;
}

.hero {
  margin-bottom: 24px;
}

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

h1 {
  margin-bottom: 12px;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1.05;
  color: #0d6f52;
}

.lead {
  max-width: 42rem;
  color: var(--muted);
  font-size: 1.05rem;
}

.panel,
.card {
  border: 1px solid rgba(69, 143, 102, 0.18);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.panel {
  padding: 24px;
  margin-bottom: 20px;
}

.form {
  display: grid;
  grid-template-columns: minmax(0, 150px) minmax(0, 240px) minmax(0, 150px) auto;
  gap: 16px;
  align-items: end;
}

.form label {
  display: grid;
  gap: 8px;
}

.form span,
.label {
  color: var(--muted);
  font-size: 0.95rem;
}

.weight-steppers {
  display: grid;
  grid-template-columns: repeat(4, minmax(48px, 1fr));
  gap: 8px;
}

.step-button {
  min-width: 0;
  padding: 12px 10px;
  border: 1px solid rgba(24, 166, 111, 0.18);
  background: #e9f7e8;
  color: var(--accent-strong);
  font-weight: 700;
  -webkit-tap-highlight-color: transparent;
}

input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  text-align: right;
}

input:focus,
button:focus {
  outline: 3px solid rgba(24, 166, 111, 0.2);
  outline-offset: 2px;
}

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

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button[type="submit"] {
  min-width: 96px;
  background: linear-gradient(135deg, #18a66f, #72bf44);
  color: #fff;
}

.secondary {
  background: #e6f3e6;
  color: var(--text);
}

.footer-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 24px 0 8px;
}

.footer-actions button {
  min-width: 140px;
  box-shadow: 0 12px 24px rgba(31, 42, 36, 0.12);
}

.page-footer {
  padding: 28px 0 32px;
  text-align: center;
}

.page-footer a {
  color: var(--muted);
  text-decoration: none;
}

.page-footer a:hover {
  text-decoration: underline;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.card {
  padding: 20px;
}

.card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.35rem, 2vw, 2rem);
}

.hero-card {
  background: linear-gradient(135deg, #18a66f, #78bd3f);
  color: #fff;
}

.hero-card .label,
.hero-card .subvalue {
  color: rgba(255, 255, 255, 0.82);
}

.hero-card strong {
  font-size: clamp(2rem, 5vw, 3.3rem);
}

.subvalue {
  display: block;
  margin-top: 10px;
  font-size: 0.95rem;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-bottom: 14px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.weight-swatch {
  background: var(--accent);
}

.standard-lower-swatch {
  background: #44b8d4;
}

.standard-upper-swatch {
  background: #a9c23f;
}

#chart {
  width: 100%;
  height: auto;
  display: none;
  overflow: visible;
}

.empty {
  margin-bottom: 0;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 8px;
  border-bottom: 1px solid rgba(69, 143, 102, 0.14);
  text-align: left;
  white-space: nowrap;
}

.time-button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
  touch-action: manipulation;
}

.time-button:hover {
  transform: none;
  color: var(--accent-strong);
}

.time-edit {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.time-edit input {
  width: auto;
  min-width: 210px;
  padding: 8px 10px;
}

.mini-button {
  padding: 8px 12px;
  border-radius: 999px;
  touch-action: manipulation;
}

th:last-child,
td:last-child {
  text-align: right;
}

.icon-button {
  padding: 8px 12px;
  background: rgba(201, 72, 64, 0.1);
  color: var(--warn);
}

.grid-line {
  stroke: rgba(97, 116, 106, 0.18);
  stroke-width: 1;
}

.axis-label {
  fill: var(--muted);
  font-size: 12px;
}

.axis-sub-label {
  fill: var(--muted);
  font-size: 11px;
}

.weight-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.weight-point {
  fill: #fff;
  stroke: var(--accent);
  stroke-width: 3;
}

.standard-line {
  stroke-width: 2;
  stroke-dasharray: 3 5;
}

.standard-lower-line {
  stroke: #44b8d4;
}

.standard-upper-line {
  stroke: #a9c23f;
}

.standard-label {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 720px) {
  .app {
    width: min(100% - 20px, 960px);
    padding-top: 24px;
  }

  .form,
  .stats {
    grid-template-columns: 1fr;
  }

  .weight-steppers {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .panel {
    padding: 18px;
  }

  .footer-actions {
    gap: 8px;
  }

  .footer-actions button {
    min-width: 0;
    padding: 10px 14px;
    font-size: 0.95rem;
  }
}
