:root {
  --bg: #0f1115;
  --card: #1a1d24;
  --card2: #232733;
  --text: #f2f4f8;
  --muted: #9aa3b2;
  --accent: #4ade80;
  --accent-d: #22c55e;
  --danger: #f87171;
  --border: #2a2f3a;
  --radius: 16px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 16px;
}

.screen {
  max-width: 520px;
  margin: 0 auto;
  padding: max(env(safe-area-inset-top), 16px) 16px calc(env(safe-area-inset-bottom) + 32px);
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.error {
  color: var(--danger);
}

/* Header */
header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 8px 0 16px;
}
header h1 {
  font-size: 28px;
  margin: 0;
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

/* Dagtotaal */
.totals {
  text-align: center;
}
.kcal {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
}
.kcal .big {
  font-size: 52px;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--accent);
}
.kcal .unit {
  font-size: 18px;
  color: var(--muted);
}
.macros {
  display: flex;
  justify-content: space-around;
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.macro {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.macro span {
  font-size: 22px;
  font-weight: 700;
}
.macro label {
  font-size: 12px;
  color: var(--muted);
}
.macro span::after {
  content: " g";
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}

/* Buttons */
button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 12px;
}
.primary {
  background: var(--accent-d);
  color: #04210f;
  font-weight: 700;
}
.primary:active {
  background: var(--accent);
}
.big-btn {
  width: 100%;
  padding: 18px;
  font-size: 18px;
  margin-bottom: 20px;
}
.big-btn:disabled {
  opacity: 0.6;
}
.link {
  background: none;
  color: var(--muted);
  text-decoration: underline;
  padding: 8px;
}

/* Resultaatkaart */
#result h3 {
  margin: 0 0 4px;
  font-size: 20px;
}
.result-portion {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 14px;
}
.result-macros {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.rm {
  background: var(--card2);
  border-radius: 12px;
  padding: 10px 4px;
  text-align: center;
}
.rm b {
  display: block;
  font-size: 20px;
}
.rm.kcal-cell b {
  color: var(--accent);
}
.rm small {
  color: var(--muted);
  font-size: 11px;
}
.portion-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 14px;
}
.portion-row button {
  width: 44px;
  height: 44px;
  font-size: 24px;
  background: var(--card2);
  color: var(--text);
}
.portion-row .mult {
  min-width: 86px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.portion-row .mult b {
  font-size: 20px;
}
.portion-row .mult small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.result-actions {
  display: flex;
  gap: 10px;
}
.result-actions button {
  flex: 1;
  padding: 14px;
  font-size: 16px;
}
.result-actions .cancel {
  background: var(--card2);
  color: var(--text);
}
.note {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 12px;
}
.conf {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--card2);
  color: var(--muted);
  margin-left: 8px;
  vertical-align: middle;
}

/* Spinner */
.spinner {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  padding: 8px;
}
.spinner .dot {
  width: 12px;
  height: 12px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Lijst */
.section-title {
  font-size: 16px;
  color: var(--muted);
  margin: 22px 0 10px;
  font-weight: 600;
}
.list,
.history {
  list-style: none;
  margin: 0;
  padding: 0;
}
.list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
.list .info {
  min-width: 0;
}
.list .name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list .sub {
  font-size: 12px;
  color: var(--muted);
}
.list .kc {
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}
.del {
  background: none;
  color: var(--muted);
  font-size: 20px;
  padding: 4px 6px;
}
.empty {
  text-align: center;
  padding: 12px;
}

/* Geschiedenis */
.history li {
  display: flex;
  justify-content: space-between;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}
.history .h-day {
  color: var(--text);
}
.history .h-val {
  color: var(--muted);
}
.history .h-val b {
  color: var(--accent);
}

footer {
  text-align: center;
  margin-top: 28px;
}

/* Login */
.login-card {
  max-width: 320px;
  margin: 18vh auto 0;
  text-align: center;
}
.login-card .logo {
  font-size: 48px;
}
.login-card h1 {
  margin: 8px 0 4px;
}
.login-card form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}
.login-card input {
  padding: 16px;
  font-size: 18px;
  text-align: center;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
}
.login-card button {
  padding: 16px;
  font-size: 17px;
  background: var(--accent-d);
  color: #04210f;
  font-weight: 700;
}
