* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #eff6ff;
  color: #1e293b;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: #eff6ff;
  padding: 12px 12px 10px;
  border-bottom: 1px solid #bfdbfe;
}
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
h1 { font-size: 22px; margin: 0; }
.sync-pill { font-size: 12px; padding: 4px 8px; border-radius: 999px; background: #dbeafe; color: #1d4ed8; white-space: nowrap; }
.sync-pill.warn { background: #fef3c7; color: #92400e; }
.sync-pill.hidden { display: none; }

.daynav { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.nav-btn {
  width: 48px; height: 44px; border-radius: 12px; border: 1px solid #93c5fd;
  background: #fff; font-size: 16px; color: #1d4ed8;
}
.nav-btn:disabled { opacity: .35; }
.day-label { font-size: 18px; font-weight: 700; text-align: center; }
.day-label small { display: block; font-size: 12px; font-weight: 400; color: #64748b; }

.totals { display: flex; gap: 8px; margin-top: 10px; }
.total {
  flex: 1; background: #fff; border: 1px solid #bfdbfe; border-radius: 14px;
  padding: 8px 4px; text-align: center;
}
.total-icon { font-size: 18px; }
.total-num { display: block; font-size: 26px; font-weight: 800; line-height: 1.1; }
.total-unit { font-size: 12px; color: #64748b; }
.total-eq { display: block; font-size: 12px; color: #64748b; min-height: 14px; }

.last-feed { margin-top: 8px; font-size: 14px; color: #334155; text-align: center; min-height: 18px; }

.actions { display: flex; gap: 8px; margin-top: 8px; }
.btn {
  border: 1px solid #93c5fd; background: #fff; color: #1d4ed8;
  border-radius: 12px; padding: 11px 10px; font-size: 15px; font-weight: 600;
}
.btn-primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.btn-danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: #64748b; }
.btn-big { padding: 13px 18px; font-size: 16px; }
.btn-small { padding: 9px 12px; font-size: 14px; }
.actions .btn { flex: 1; }
.btn:disabled { opacity: .5; }

/* Entry form (one form, everything in it) */
.day-view { padding: 12px 12px 20px; }
.day-view[hidden] { display: none; }
.entry-form {
  background: #fff; border: 1px solid #bfdbfe; border-radius: 16px;
  padding: 14px 14px 16px; display: flex; flex-direction: column; gap: 10px;
}
.form-row { display: flex; gap: 8px; align-items: flex-end; }
.form-field { flex: 1; font-size: 13px; font-weight: 600; color: #475569; min-width: 0; }
.form-field input {
  display: block; width: 100%; margin-top: 4px; padding: 12px 10px; font-size: 18px;
  border: 1px solid #93c5fd; border-radius: 12px; background: #fff; color: #1e293b;
}
.steppers { display: flex; gap: 6px; flex: none; }
.step-btn {
  width: 48px; height: 48px; border-radius: 12px; border: 1px solid #93c5fd;
  background: #fff; font-size: 22px; font-weight: 700; color: #1d4ed8; line-height: 1;
}
.form-oz-eq { font-size: 14px; color: #64748b; min-height: 18px; margin-top: -6px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 2px; }
.chip { border: 1px solid #93c5fd; background: #eff6ff; color: #1d4ed8; border-radius: 999px; padding: 10px 16px; font-size: 16px; font-weight: 700; }
.form-actions { display: flex; gap: 8px; margin-top: 2px; }
.form-actions .btn-big { flex: 1; }
.form-actions[hidden] { display: none; }

/* Saved entries list (builds itself as entries are saved) */
.entries { margin-top: 14px; }
.entry-row {
  width: 100%; display: flex; align-items: baseline; gap: 8px;
  background: #fff; border: 1px solid #bfdbfe; border-radius: 14px;
  padding: 13px 12px; margin-bottom: 8px; text-align: left; font-size: 16px; color: #1e293b;
}
.entry-time { font-weight: 800; white-space: nowrap; }
.entry-parts { flex: 1; min-width: 0; }
.entry-by { font-size: 13px; color: #64748b; white-space: nowrap; }
.entry-empty { color: #64748b; text-align: center; padding: 20px 8px; font-size: 15px; }

.past-view { padding: 14px 12px 20px; }
.past-view h2 { margin: 4px 0; font-size: 20px; }
.past-note { color: #64748b; font-size: 14px; margin: 0 0 12px; }
.past-row {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: #fff; border: 1px solid #bfdbfe; border-radius: 14px; padding: 14px 12px;
  margin-bottom: 8px; text-align: left; font-size: 15px;
}
.past-row b { font-size: 16px; }
.past-row .past-totals { color: #475569; font-size: 14px; white-space: nowrap; }
.past-empty { color: #64748b; }
.back-today { width: 100%; margin-top: 6px; }
.foot { text-align: center; color: #94a3b8; font-size: 12px; padding: 8px 12px 20px; }

/* Sheets (sync sheet) */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-wrap[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .45); }
.sheet {
  position: relative; width: 100%; max-width: 520px; background: #fff;
  border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(15, 23, 42, .25);
}
.sheet h2 { margin: 0 0 4px; font-size: 20px; }
.sheet-actions { display: flex; gap: 8px; margin-top: 10px; }
.sheet-actions .btn-big { flex: 1; }
.sync-note { color: #64748b; font-size: 14px; margin: 0 0 12px; }
.name-field { display: block; font-size: 14px; font-weight: 600; margin: 12px 0 4px; }
.name-field input {
  display: block; width: 100%; margin-top: 6px; padding: 12px; font-size: 16px;
  border: 1px solid #93c5fd; border-radius: 12px;
}
.code-big {
  font-size: 30px; font-weight: 800; letter-spacing: 2px; text-align: center;
  background: #eff6ff; border: 1px dashed #93c5fd; border-radius: 14px; padding: 14px; margin: 8px 0;
}
.code-row { display: flex; gap: 8px; margin: 8px 0; }
.code-row input {
  flex: 1; padding: 12px; font-size: 18px; text-transform: uppercase; letter-spacing: 1px;
  border: 1px solid #93c5fd; border-radius: 12px; min-width: 0;
}
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 80;
  background: #1e293b; color: #fff; padding: 11px 16px; border-radius: 999px;
  font-size: 14px; max-width: 92vw; text-align: center;
}
.toast[hidden] { display: none; }
