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

:root {
  --bg: #f0f4f8;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1a202c;
  --text-muted: #718096;
  --primary: #4361ee;
  --primary-dark: #3451d1;
  --feed: #3b82f6;
  --nappy: #f97316;
  --sleep: #8b5cf6;
  --success: #10b981;
  --radius: 14px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 2rem;
}

/* Header */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow);
}
.header-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
}
.header-baby {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.header-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}
.header-link {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
}
.header-link:hover { color: var(--primary); }

/* Container */
.container { max-width: 480px; margin: 0 auto; padding: 1.25rem; }

/* Status cards */
.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.status-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--border);
}
.status-card.feed { border-left-color: var(--feed); }
.status-card.nappy { border-left-color: var(--nappy); }
.status-card.sleep { border-left-color: var(--sleep); grid-column: 1 / -1; }
.status-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}
.status-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.status-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}
.status-time {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}
.sleeping-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--sleep);
  border-radius: 50%;
  margin-right: 6px;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Quick actions */
.quick-actions { margin-bottom: 1.5rem; }
.quick-actions-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}
.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
}
.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.25rem 0.5rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  min-height: 90px;
  transition: transform 0.1s, opacity 0.1s;
  color: white;
  gap: 0.4rem;
}
.action-btn:active { transform: scale(0.96); opacity: 0.9; }
.action-btn .icon { font-size: 1.6rem; }
.action-btn.feed { background: var(--feed); }
.action-btn.nappy { background: var(--nappy); }
.action-btn.sleep { background: var(--sleep); }
.action-btn.sleep-end { background: var(--success); }

/* Nappy quick buttons */
.nappy-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.nappy-btn {
  padding: 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  color: white;
  background: var(--nappy);
  cursor: pointer;
  min-height: 72px;
  transition: transform 0.1s, opacity 0.1s;
}
.nappy-btn:active { transform: scale(0.96); opacity: 0.9; }
.nappy-btn.dry { background: #64748b; }

/* History nav */
.history-nav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.history-tab {
  padding: 0.5rem 1rem;
  border-radius: 99px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.history-tab.active { background: var(--primary); color: white; border-color: var(--primary); }

/* Log list */
.log-list { display: flex; flex-direction: column; gap: 0.5rem; }
.log-item {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  box-shadow: var(--shadow);
  border-left: 3px solid var(--border);
}
.log-item.feed { border-left-color: var(--feed); }
.log-item.nappy { border-left-color: var(--nappy); }
.log-item.sleep { border-left-color: var(--sleep); }
.log-item.sleep.active { border-left-color: var(--success); }
.log-main { font-weight: 600; font-size: 0.95rem; }
.log-detail { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.log-time { font-size: 0.8rem; color: var(--text-muted); text-align: right; white-space: nowrap; }

/* Forms */
.form-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.form-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}
.form-group { margin-bottom: 1rem; }
label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}
input, select, textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  background: white;
}
textarea { resize: vertical; min-height: 80px; }

/* Feed type selector */
.feed-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.feed-type-btn {
  padding: 1rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  text-align: center;
  transition: all 0.15s;
}
.feed-type-btn.selected,
.feed-type-btn:hover {
  border-color: var(--feed);
  background: #eff6ff;
  color: var(--feed);
}

/* Buttons */
.btn {
  display: block;
  width: 100%;
  padding: 0.9rem;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: opacity 0.15s;
}
.btn:active { opacity: 0.85; }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-ghost {
  background: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 0.7rem;
  font-weight: 500;
}

/* Baby list */
.baby-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-decoration: none;
  color: var(--text);
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
}
.baby-card:hover, .baby-card:focus { border-color: var(--primary); }
.baby-name { font-weight: 700; font-size: 1.05rem; }
.baby-dob { font-size: 0.82rem; color: var(--text-muted); }
.baby-arrow { font-size: 1.2rem; color: var(--text-muted); }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem 1.75rem;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.1);
}
.login-logo {
  font-size: 2rem;
  text-align: center;
  margin-bottom: 0.5rem;
}
.login-title {
  font-size: 1.3rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 1.5rem;
  color: var(--text);
}
.error-msg {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 0.7rem 1rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

/* Empty state */
.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.empty-text { font-size: 0.95rem; }

/* Section header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.section-link {
  font-size: 0.8rem;
  color: var(--primary);
  text-decoration: none;
}

@media (max-width: 700px) {
  input, select, textarea { font-size: 16px; }
}
