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

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
}

/* Auth */

.auth-container {
  max-width: 400px;
  margin: 100px auto;
  background: #fff;
  padding: 40px;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.auth-container h1 {
  text-align: center;
  color: #333;
  margin-bottom: 30px;
}

.auth-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

.auth-tab.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
}

.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  color: #555;
  font-weight: 500;
}

.form-group input {
  width: 100%;
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1em;
}

.auth-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-size: 1em;
}

.auth-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.error-message {
  color: #dc3545;
  font-size: 0.9em;
  margin-top: 10px;
  text-align: center;
}

/* Main layout */

.container {
  max-width: 1108px;
  margin: 0 auto;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  padding: 30px;
  display: none;
}

.container.show {
  display: block;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-brand img {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
}

.header-titles h1 {
  color: #333;
  font-size: 2em;
  line-height: 1.1;
}

.header-tagline {
  color: #667eea;
  font-size: 0.95em;
  font-weight: 600;
  margin-top: 2px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 15px;
}

.user-email {
  color: #666;
  font-size: 0.9em;
}

.logout-btn {
  padding: 8px 16px;
  background: #dc3545;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}

/* Calendar */

.calendar-section {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 15px;
  margin-bottom: 20px;
}

.date-nav {
  width: 100%;
}

.about-today {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 12px;
}

.selected-date {
  font-weight: 600;
  color: #333;
  font-size: 1.1em;
}

.today-btn {
  padding: 8px 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}

.today-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.calendar-nav {
  display: flex;
  gap: 10px;
  align-items: center;
}

.calendar-nav button {
  padding: 8px 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}

.calendar-nav button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

input[type="date"] {
  padding: 10px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1em;
}

/* Stats */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  padding: 20px;
  border-radius: 15px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.stat-card h3 {
  font-size: 0.9em;
  margin-bottom: 15px;
  opacity: 0.9;
  text-align: center;
}

.circles-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 10px;
}

.circle {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: transparent;
  transition: background 0.3s;
}

.circle.filled {
  background: #fff;
}

.stat-text {
  text-align: center;
  font-size: 0.85em;
  opacity: 0.9;
  margin-top: 10px;
}

.stat-count {
  text-align: center;
  font-size: 1.5em;
  font-weight: bold;
  margin-top: 5px;
}

/* Inputs / sections */

.input-section {
  background: #f8f9fa;
  padding: 25px;
  border-radius: 15px;
  margin-bottom: 20px;
}

.input-section h2 {
  color: #333;
  margin-bottom: 20px;
  font-size: 1.3em;
}

.input-section h3 {
  color: #333;
  margin-top: 20px;
  margin-bottom: 10px;
  font-size: 1.1em;
}

.input-group {
  margin-bottom: 15px;
  position: relative;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

label {
  display: block;
  margin-bottom: 5px;
  color: #555;
  font-weight: 500;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1em;
  transition: border-color 0.3s;
  background: #fff;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: #667eea;
}

/* USDA search */

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 2px solid #667eea;
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.search-results.show {
  display: block;
}

.search-item {
  padding: 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.2s;
}

.search-item:hover {
  background: #f8f9fa;
}

.search-item-name {
  font-weight: 600;
  color: #333;
  margin-bottom: 3px;
}

.search-item-details {
  font-size: 0.85em;
  color: #666;
}

.per100-note {
  font-size: 0.78em;
  color: #999;
  margin-left: 4px;
}

.api-note {
  font-size: 0.85em;
  color: #666;
  margin-bottom: 10px;
  font-style: italic;
}

/* Buttons */

.btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}

.btn-secondary {
  background: #6c757d;
  color: #fff;
  margin-top: 10px;
}

/* Tabs */

.tab-container {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tab {
  flex: 1;
  min-width: 100px;
  padding: 12px;
  background: #e0e0e0;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.3s;
}

.tab.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Entries */

.entries-section {
  margin-top: 30px;
}

.entries-section h2 {
  color: #333;
  margin-bottom: 15px;
  font-size: 1.3em;
}

.entry-list {
  margin-top: 10px;
}

.entry-item {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 10px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.entry-info {
  flex: 1;
}

.entry-name {
  font-weight: 600;
  color: #333;
  margin-bottom: 5px;
}

.entry-details {
  color: #666;
  font-size: 0.9em;
}

.entry-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.edit-btn,
.delete-btn,
.share-btn {
  color: #fff;
  border: none;
  padding: 8px 15px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9em;
}

.edit-btn {
  background: #007bff;
}

.delete-btn {
  background: #dc3545;
}

.share-btn {
  background: #28a745;
}

/* Sub-recipe list */

.sub-recipe-pill {
  background: #fff9e6;
  border-radius: 8px;
  padding: 6px 10px;
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9em;
}

.sub-recipe-pill button {
  margin-left: 10px;
}

/* Weight */

canvas {
  max-width: 100%;
  cursor: pointer;
}

.weight-chart {
  background: #fff;
  padding: 20px;
  border-radius: 10px;
  margin-top: 20px;
  border: 2px solid #e0e0e0;
}

.chart-instructions {
  text-align: center;
  color: #666;
  font-size: 0.9em;
  margin-top: 10px;
  font-style: italic;
}

/* Footer */

.footer {
  margin-top: 20px;
  text-align: center;
  color: #888;
  font-size: 0.8em;
}

/* Mobile */

@media (max-width: 768px) {
  body {
    padding: 0;
  }

  .container {
    width: 100%;
    max-width: 100%;
    margin: 0;
    border-radius: 0;
    padding: 12px;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .header-brand img {
    width: 36px;
    height: 36px;
  }

  .header-titles h1 {
    font-size: 1.4em;
  }

  .header-tagline {
    font-size: 0.85em;
  }

  .calendar-section {
    padding: 12px;
  }

  .about-today {
    width: 100%;
    margin-bottom: 10px;
  }

  .selected-date {
    font-size: 1em;
  }

  .calendar-nav {
    width: 100%;
    gap: 6px;
  }

  .calendar-nav button,
  .calendar-nav input[type="date"] {
    flex: 1 1 0;
    min-width: 0;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stat-card {
    padding: 12px;
  }

  .tab-container {
    gap: 6px;
  }

  .tab {
    flex: 1 1 48%;
    padding: 8px;
    font-size: 0.9em;
    text-align: center;
  }

  .input-section {
    padding: 12px;
  }

  .entries-section h2 {
    font-size: 1.05em;
  }

  .input-row {
    grid-template-columns: 1fr;
  }
}
