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

:root {
  --bg: #faf8f5;
  --card: #ffffff;
  --primary: #7a4f2e;
  --accent: #e76f51;
  --text: #2c2c2c;
  --muted: #7a7065;
  --border: #e5e0d8;
  --radius: 12px;
  --teal: #2a9d8f;
}

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

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--accent);
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Header */
header {
  background: linear-gradient(135deg, #fff8f4 0%, #ffffff 100%);
  border-bottom: 2px solid var(--accent);
  padding: 0.75rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(231,111,81,0.08);
}

.header-logo {
  width: 36px;
  height: auto;
  margin-right: 0.5rem;
  vertical-align: middle;
  position: relative;
  top: -2px;
}

header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

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

header h1 a {
  color: inherit;
}

nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

nav a {
  color: var(--muted);
  font-size: 0.95rem;
}

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

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.5rem 1.1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: #d4623e;
  color: white;
}

.btn-secondary {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

.btn-secondary:hover {
  background: var(--primary);
  color: white;
}

.btn-danger {
  background: #dc3545;
  color: white;
}

.btn-danger:hover {
  background: #b02a37;
  color: white;
}

.hidden {
  display: none !important;
}

/* Main content */
main {
  padding: 2rem 1.5rem;
}

/* Search bar */
.search-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.search-bar input,
.search-bar select {
  padding: 0.6rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  background: var(--card);
  color: var(--text);
  outline: none;
}

.search-bar input {
  flex: 1;
  min-width: 200px;
}

.search-bar input:focus,
.search-bar select:focus {
  border-color: var(--accent);
}

/* Hero banner */
.hero {
  background: linear-gradient(135deg, #fff3ee 0%, #fdf6f0 50%, #f0faf9 100%);
  border-bottom: 1px solid var(--border);
  padding: 1.75rem 0;
}

.hero-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.hero-text h2 {
  font-size: 1.4rem;
  color: var(--primary);
  margin-bottom: 0.35rem;
}

.hero-text p {
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 480px;
}

.hero-icons {
  font-size: 1.6rem;
  letter-spacing: 0.1em;
  opacity: 0.85;
  white-space: nowrap;
}

@media (max-width: 560px) {
  .hero-icons { display: none; }
}

/* Footer */
.site-footer {
  margin-top: 4rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer .container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

/* Recipe grid */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.recipe-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: box-shadow 0.2s, transform 0.2s;
  cursor: pointer;
}

.recipe-card:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  transform: translateY(-2px);
}

.recipe-card .category {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: white;
  background: var(--accent);
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  margin-bottom: 0.65rem;
}

.cat-breakfast { background: #e67e22; }
.cat-lunch     { background: #27ae60; }
.cat-dinner    { background: #2980b9; }
.cat-dessert   { background: #8e44ad; }
.cat-snack     { background: #d35400; }
.cat-drink     { background: #16a085; }
.cat-other     { background: #7f8c8d; }

.recipe-card h2 {
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.recipe-card .description {
  font-size: 0.9rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.recipe-card .meta {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.recipe-card .meta span::before {
  margin-right: 0.25rem;
}

/* Recipe detail */
.recipe-detail {
  max-width: 750px;
  margin: 0 auto;
}

.recipe-detail .back-link {
  display: inline-block;
  margin-bottom: 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.recipe-detail .back-link:hover {
  color: var(--primary);
}

.recipe-header {
  margin-bottom: 2rem;
}

.recipe-header .category {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.recipe-header h1 {
  font-size: 2rem;
  color: var(--primary);
  margin-bottom: 0.75rem;
}

.recipe-header .description {
  color: var(--muted);
  font-size: 1rem;
  margin-bottom: 1rem;
}

.recipe-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  padding: 1rem 1.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 2rem;
  font-size: 0.9rem;
}

.recipe-meta .meta-item {
  display: flex;
  flex-direction: column;
}

.recipe-meta .meta-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

.recipe-meta .meta-value {
  font-weight: 600;
  color: var(--text);
}

.recipe-admin {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.recipe-sections {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 640px) {
  .recipe-sections {
    grid-template-columns: 1fr;
  }
}

.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 0.4rem;
  margin-bottom: 1rem;
}

.ingredients-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ingredients-list li {
  padding: 0.5rem 0.75rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
}

.instructions-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  counter-reset: step;
}

.instructions-list li {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  counter-increment: step;
}

.instructions-list li::before {
  content: counter(step);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

/* Forms */
.form-page {
  max-width: 700px;
  margin: 0 auto;
}

.form-page h1 {
  font-size: 1.75rem;
  color: var(--primary);
  margin-bottom: 1.75rem;
}

.form-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.65rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 540px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

.dynamic-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.dynamic-item {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.dynamic-item input,
.dynamic-item textarea {
  flex: 1;
  margin-bottom: 0;
}

.dynamic-item textarea {
  min-height: 60px;
}

.btn-remove {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  color: var(--muted);
  font-size: 1.1rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
}

.btn-remove:hover {
  border-color: #dc3545;
  color: #dc3545;
}

.btn-add-item {
  background: none;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
  width: 100%;
  transition: border-color 0.15s, color 0.15s;
}

.btn-add-item:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.75rem;
  justify-content: flex-end;
}

/* Login */
.login-page {
  max-width: 380px;
  margin: 4rem auto;
  padding: 0 1.5rem;
}

.login-page h1 {
  font-size: 1.5rem;
  color: var(--primary);
  margin-bottom: 1.5rem;
  text-align: center;
}

/* Alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-error {
  background: #fde8e8;
  color: #9b1c1c;
  border: 1px solid #fca5a5;
}

.alert-success {
  background: #e8f5e9;
  color: #1b5e20;
  border: 1px solid #a5d6a7;
}

/* Nutrition table */
.nutrition-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.nutrition-table th {
  background: var(--primary);
  color: white;
  padding: 0.55rem 0.75rem;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.nutrition-table td {
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.nutrition-table tbody tr:last-child td {
  border-bottom: none;
}

.nutrition-table input {
  width: 100%;
  border: none;
  background: transparent;
  padding: 0.2rem 0.25rem;
  font-size: 0.88rem;
  color: var(--text);
  font-family: inherit;
  min-width: 60px;
}

.nutrition-table input:focus {
  outline: 2px solid var(--accent);
  border-radius: 3px;
  background: #fff8f5;
}

.nutrition-totals td {
  font-weight: 700;
  background: var(--bg);
  border-top: 2px solid var(--border);
  border-bottom: none !important;
  padding: 0.5rem 0.75rem;
}

.nutrition-table--view td {
  padding: 0.45rem 0.75rem;
}

.btn-sync {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.75rem;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--muted);
  transition: border-color 0.15s, color 0.15s;
}

.btn-sync:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Empty / loading states */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--muted);
  grid-column: 1 / -1;
}

.empty-state p {
  margin-bottom: 1rem;
}

.loading {
  color: var(--muted);
  grid-column: 1 / -1;
  padding: 2rem 0;
}
