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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a1a;
  color: #e0e0e0;
  line-height: 1.4;
  min-height: 100vh;
}

.container {
  max-width: 500px;
  margin: 0 auto;
  padding: 15px;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* Login screen */
.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
}

.login-screen h1 {
  font-size: 2.5rem;
  font-weight: 300;
  margin-bottom: 40px;
}

.login-screen form {
  width: 100%;
  max-width: 300px;
}

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

.login-screen input {
  width: 100%;
  padding: 15px;
  border: 2px solid #404040;
  border-radius: 10px;
  font-size: 16px;
  background: #1a1a1a;
  color: #e0e0e0;
  text-align: center;
}

.login-screen input:focus {
  outline: none;
  border-color: #4CAF50;
}

.login-screen .submit-btn {
  width: 100%;
  padding: 15px;
  font-size: 18px;
}

.password-error {
  color: #f44336;
  margin-top: 10px;
  font-size: 14px;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding: 10px 0;
}

.header h1 {
  flex: 1;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 500;
}

.nav-btn {
  background: #2d2d2d;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  color: #e0e0e0;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.2s;
}

.nav-btn:hover {
  background: #404040;
}

.nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.icon-btn {
  background: #2d2d2d;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  color: #e0e0e0;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.icon-btn:hover {
  background: #404040;
}

/* Budget section */
.budget-section {
  margin-bottom: 20px;
}

.budget-bar {
  height: 24px;
  background: #2d2d2d;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 8px;
}

.budget-fill {
  height: 100%;
  background: #4CAF50;
  border-radius: 12px;
  transition: width 0.3s, background 0.3s;
  min-width: 0;
}

.budget-fill.warning {
  background: #FF9800;
}

.budget-fill.over {
  background: #f44336;
}

.budget-info {
  text-align: center;
  font-size: 14px;
  color: #888;
}

.remaining {
  color: #4CAF50;
}

.remaining.warning {
  color: #FF9800;
}

.remaining.over {
  color: #f44336;
}

/* Add section */
.add-section {
  background: #2d2d2d;
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 20px;
}

.quick-add-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-row {
  display: flex;
  gap: 10px;
}

.form-group {
  position: relative;
}

.food-input-group {
  flex: 1;
}

.food-input-group input {
  width: 100%;
  padding: 12px;
  border: 2px solid #404040;
  border-radius: 8px;
  font-size: 16px;
  background: #1a1a1a;
  color: #e0e0e0;
}

.food-input-group input:focus {
  outline: none;
  border-color: #4CAF50;
}

.quantity-group {
  display: flex;
  gap: 5px;
  flex: 1;
}

.quantity-group input {
  width: 60px;
  padding: 12px 8px;
  border: 2px solid #404040;
  border-radius: 8px;
  font-size: 16px;
  background: #1a1a1a;
  color: #e0e0e0;
  text-align: center;
}

.quantity-group select {
  flex: 1;
  padding: 12px 8px;
  border: 2px solid #404040;
  border-radius: 8px;
  font-size: 14px;
  background: #1a1a1a;
  color: #e0e0e0;
}

.calories-group {
  width: 80px;
}

.calories-group input {
  width: 100%;
  padding: 12px 8px;
  border: 2px solid #404040;
  border-radius: 8px;
  font-size: 16px;
  background: #1a1a1a;
  color: #e0e0e0;
  text-align: center;
}

.calories-group input:focus,
.quantity-group input:focus,
.quantity-group select:focus {
  outline: none;
  border-color: #4CAF50;
}

.submit-btn {
  padding: 12px 20px;
  background: #4CAF50;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
}

.submit-btn:hover {
  background: #45a049;
}

.submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Suggestions dropdown */
.suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #2d2d2d;
  border: 1px solid #404040;
  border-radius: 8px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.suggestion-item {
  padding: 12px;
  cursor: pointer;
  border-bottom: 1px solid #404040;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item:hover,
.suggestion-item.highlighted {
  background: #404040;
}

.suggestion-item .name {
  font-weight: 500;
}

.suggestion-item .info {
  font-size: 12px;
  color: #888;
}

/* AI button */
.ai-btn {
  width: 100%;
  padding: 12px;
  margin-top: 10px;
  background: #6366f1;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.ai-btn:hover {
  background: #4f46e5;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: #2d2d2d;
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  max-width: 400px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-content h2 {
  margin-bottom: 15px;
  font-weight: 500;
}

.modal-content textarea {
  width: 100%;
  height: 100px;
  padding: 12px;
  border: 2px solid #404040;
  border-radius: 8px;
  font-size: 16px;
  background: #1a1a1a;
  color: #e0e0e0;
  resize: none;
  font-family: inherit;
}

.modal-content textarea:focus {
  outline: none;
  border-color: #6366f1;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

.modal-buttons button {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
}

.cancel-btn {
  background: #404040;
  color: #e0e0e0;
  border: none;
}

.cancel-btn:hover {
  background: #505050;
}

/* AI Results */
.ai-results {
  margin-top: 15px;
  border-top: 1px solid #404040;
  padding-top: 15px;
}

.ai-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: #1a1a1a;
  border-radius: 8px;
  margin-bottom: 8px;
}

.ai-result-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
}

.ai-result-item .details {
  flex: 1;
}

.ai-result-item .name {
  font-weight: 500;
}

.ai-result-item .info {
  font-size: 12px;
  color: #888;
}

.ai-result-item .new-badge {
  font-size: 10px;
  background: #6366f1;
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
}

.ai-confirm-btn {
  width: 100%;
  padding: 12px;
  background: #4CAF50;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 10px;
}

.ai-error {
  background: #3d2020;
  border: 1px solid #d32f2f;
  color: #ff6b6b;
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  text-align: center;
}

/* Entries section */
.entries-section {
  background: #2d2d2d;
  border-radius: 12px;
  padding: 15px;
}

.entries-section h2 {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 15px;
  color: #888;
}

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

.empty-state {
  text-align: center;
  color: #666;
  padding: 30px;
}

.entry-item {
  display: flex;
  align-items: center;
  padding: 12px;
  background: #1a1a1a;
  border-radius: 8px;
  gap: 12px;
}

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

.entry-item .name {
  font-weight: 500;
  margin-bottom: 2px;
}

.entry-item .details {
  font-size: 12px;
  color: #888;
}

.entry-item .calories {
  font-size: 18px;
  font-weight: 600;
  color: #4CAF50;
}

.entry-item .delete-btn {
  background: none;
  border: none;
  color: #666;
  font-size: 18px;
  cursor: pointer;
  padding: 5px;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.entry-item .delete-btn:hover {
  opacity: 1;
  color: #f44336;
}

/* Foods page */
.page-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.page-header h1 {
  flex: 1;
  font-size: 1.5rem;
}

.back-btn {
  background: #2d2d2d;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  color: #e0e0e0;
  font-size: 20px;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.foods-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.food-item {
  display: flex;
  align-items: center;
  padding: 15px;
  background: #2d2d2d;
  border-radius: 8px;
  gap: 12px;
}

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

.food-item .name {
  font-weight: 500;
  margin-bottom: 2px;
}

.food-item .details {
  font-size: 12px;
  color: #888;
}

.food-item .edit-btn,
.food-item .delete-btn {
  background: none;
  border: none;
  color: #888;
  font-size: 16px;
  cursor: pointer;
  padding: 8px;
}

.food-item .edit-btn:hover {
  color: #4CAF50;
}

.food-item .delete-btn:hover {
  color: #f44336;
}

/* Add food form */
.add-food-form {
  background: #2d2d2d;
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 20px;
}

.add-food-form h2 {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 15px;
}

.add-food-form .form-group {
  margin-bottom: 12px;
}

.add-food-form label {
  display: block;
  font-size: 12px;
  color: #888;
  margin-bottom: 4px;
}

.add-food-form input,
.add-food-form select {
  width: 100%;
  padding: 12px;
  border: 2px solid #404040;
  border-radius: 8px;
  font-size: 16px;
  background: #1a1a1a;
  color: #e0e0e0;
}

.add-food-form input:focus,
.add-food-form select:focus {
  outline: none;
  border-color: #4CAF50;
}

.add-food-form .row {
  display: flex;
  gap: 10px;
}

.add-food-form .row .form-group {
  flex: 1;
}

/* Weight page */
.weight-form {
  background: #2d2d2d;
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 20px;
}

.weight-form h2 {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 15px;
}

.weight-form .input-row {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.weight-form input {
  flex: 1;
  padding: 12px;
  border: 2px solid #404040;
  border-radius: 8px;
  font-size: 16px;
  background: #1a1a1a;
  color: #e0e0e0;
}

.weight-form input:focus {
  outline: none;
  border-color: #4CAF50;
}

.weight-form select {
  flex: 1;
  padding: 12px;
  border: 2px solid #404040;
  border-radius: 8px;
  font-size: 16px;
  background: #1a1a1a;
  color: #e0e0e0;
  -webkit-appearance: none;
  appearance: none;
}

.weight-form label {
  display: block;
  margin-bottom: 5px;
}

.weight-stats {
  background: #2d2d2d;
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 20px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #404040;
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-label {
  color: #888;
}

.stat-value {
  font-weight: 500;
}

.stat-value.positive {
  color: #4CAF50;
}

.stat-value.negative {
  color: #f44336;
}

.weight-chart {
  background: #2d2d2d;
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 20px;
}

.weight-chart h2 {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 15px;
}

.chart-container {
  height: 200px;
  position: relative;
}

.chart-container canvas {
  width: 100%;
  height: 100%;
}

.weight-history {
  background: #2d2d2d;
  border-radius: 12px;
  padding: 15px;
}

.weight-history h2 {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 15px;
  color: #888;
}

.weight-log-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #404040;
}

.weight-log-item:last-child {
  border-bottom: none;
}

.weight-log-item .date {
  color: #888;
}

.weight-log-item .weight {
  font-weight: 500;
}

/* Settings page */
.settings-form {
  background: #2d2d2d;
  border-radius: 12px;
  padding: 15px;
}

.settings-form .form-group {
  margin-bottom: 20px;
}

.settings-form label {
  display: block;
  font-size: 14px;
  color: #888;
  margin-bottom: 8px;
}

.settings-form input,
.settings-form select {
  width: 100%;
  padding: 12px;
  border: 2px solid #404040;
  border-radius: 8px;
  font-size: 16px;
  background: #1a1a1a;
  color: #e0e0e0;
}

.settings-form input:focus,
.settings-form select:focus {
  outline: none;
  border-color: #4CAF50;
}

.settings-form .save-btn {
  width: 100%;
  padding: 15px;
  background: #4CAF50;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
}

.settings-form .save-btn:hover {
  background: #45a049;
}

/* Mobile optimizations */
@media (max-width: 400px) {
  .container {
    padding: 10px;
  }

  .header {
    gap: 5px;
  }

  .form-row {
    flex-wrap: wrap;
  }

  .quantity-group {
    flex: none;
    width: 100%;
  }

  .calories-group {
    flex: 1;
    width: auto;
  }
}
