:root {
  --bg: #f0f4f8;
  --card: #fff;
  --primary: #0d9488;
  --primary-dark: #0f766e;
  --accent: #f59e0b;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Noto Sans SC', system-ui, sans-serif;
  background: linear-gradient(160deg, #ecfdf5 0%, var(--bg) 45%, #fef3c7 100%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary-dark);
}

header p {
  color: var(--muted);
  margin-top: 0.5rem;
  font-size: 0.95rem;
}

.server-hint {
  margin-top: 0.75rem;
  padding: 0.65rem 1rem;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  color: #9a3412;
  font-size: 0.85rem;
  text-align: left;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

.server-hint code {
  background: #ffedd5;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(15, 118, 110, 0.08);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
}

.card h2 {
  font-size: 1.1rem;
  margin-bottom: 1.25rem;
  color: var(--primary-dark);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
}

label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

input,
select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
}

input:focus,
select:focus {
  outline: 2px solid rgba(13, 148, 136, 0.35);
  border-color: var(--primary);
}

.btn-row {
  margin-top: 1.5rem;
  text-align: center;
}

button.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border: none;
  padding: 0.85rem 2.5rem;
  font-size: 1.05rem;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 4px 14px rgba(13, 148, 136, 0.35);
}

button.primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#result {
  display: none;
}

#result.visible {
  display: block;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat {
  background: #f8fafc;
  border-radius: 12px;
  padding: 0.85rem;
  text-align: center;
}

.stat .v {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.stat .l {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.meal-block {
  margin-bottom: 1.25rem;
}

.meal-block h3 {
  font-size: 1rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid #fef3c7;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 0.5rem 0.4rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.8rem;
}

td.num {
  text-align: right;
}

.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
}

.tag.ok {
  background: #d1fae5;
  color: #065f46;
}

.tag.low {
  background: #fee2e2;
  color: #991b1b;
}

.tag.high {
  background: #fef3c7;
  color: #92400e;
}

.err {
  background: #fef2f2;
  color: #b91c1c;
  padding: 1rem;
  border-radius: 10px;
  margin-top: 1rem;
  display: none;
}

.err.show {
  display: block;
}

.disclaimer {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
}

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