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

:root {
  --bg: #fdf6ee;
  --card: #fff;
  --primary: #6b8e6b;
  --text: #3a3a3a;
  --muted: #888;
  --border: #e8e0d8;
  --shadow: 0 2px 12px rgba(0,0,0,0.07);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  gap: 8px;
}

header h1 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
}

nav {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 2px;
}

nav a, .nav-logout {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 6px 10px;
  border-radius: 20px;
  transition: background 0.2s;
  white-space: nowrap;
}

@media (max-width: 400px) {
  header {
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
  }

  nav a, .nav-logout {
    font-size: 0.82rem;
    padding: 5px 8px;
  }
}

nav a:hover, nav a.active {
  background: var(--bg);
  color: var(--primary);
}

.nav-logout {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.nav-logout:hover {
  background: var(--bg);
  color: #b91c1c;
}

main {
  padding: 24px 20px;
  max-width: 480px;
  margin: 0 auto;
}

.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 14px;
}

/* Tracking buttons */
.track-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 32px;
}

.track-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow);
  transition: transform 0.1s, box-shadow 0.1s;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
}

.track-btn:active {
  transform: scale(0.97);
  box-shadow: none;
}

.track-btn .icon {
  line-height: 1;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
}

.icon--small  { font-size: 1.4rem; }
.icon--medium { font-size: 2rem;   }
.icon--large  { font-size: 2.6rem; }

.track-btn .label {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
}

.track-btn .sublabel {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}

/* Feedback toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--primary);
  color: white;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
  z-index: 100;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Recent entries */
.entries-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.entry-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.9rem;
}

.entry-item .entry-icon {
  font-size: 1.2rem;
  margin-right: 10px;
}

.entry-item .entry-info {
  flex: 1;
}

.entry-item .entry-time {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 2px;
}

.entry-delete {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.2s;
}

.entry-delete:hover {
  background: #fee2e2;
  color: #dc2626;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 32px 0;
  font-size: 0.9rem;
}

/* Stats page */
.stats-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.stats-card h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.totals-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.total-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 12px;
  text-align: center;
  box-shadow: var(--shadow);
}

.total-item .total-icon {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 2.8rem;
  margin-bottom: 6px;
}

.total-icon--small  { font-size: 1.2rem; }
.total-icon--medium { font-size: 1.8rem; }
.total-icon--large  { font-size: 2.4rem; }

.total-item .total-count {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.total-item .total-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}

.period-select {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.period-btn {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--card);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--muted);
  transition: background 0.2s;
}

.period-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

canvas {
  max-width: 100%;
}

.medical-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.medical-item {
  text-align: center;
}

.medical-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
}

.medical-label {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.3;
}

.medical-alert {
  margin-top: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  background: #fee2e2;
  color: #b91c1c;
}

.medical-card.warning .medical-value {
  color: #b91c1c;
}

.export-btn {
  display: block;
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 24px;
  transition: opacity 0.2s;
}

.export-btn:active {
  opacity: 0.8;
}
