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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  margin: 0;
  padding: 0;
  background: #f5f5f5;
  color: #222;
}

header {
  background: #2e7d32;
  color: #fff;
  padding: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

.breadcrumb-bar {
  font-size: 0.8rem;
  opacity: 0.8;
  margin-bottom: 0.5rem;
}

.breadcrumb-bar a {
  color: #fff;
  text-decoration: none;
}

.breadcrumb-bar a:hover { text-decoration: underline; }

.breadcrumb-bar span { opacity: 0.6; margin: 0 0.3rem; }

header h1 {
  margin: 0 0 0.6rem 0;
  font-size: 1.25rem;
}

#search-wrap {
  display: flex;
  gap: 0.5rem;
}

#search {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
}

#count {
  font-size: 0.85rem;
  opacity: 0.85;
  margin-top: 0.4rem;
}

main {
  padding: 1rem;
  max-width: 960px;
  margin: 0 auto;
}

body.show-nutr main {
  max-width: 1200px;
}

.diet-card {
  background: #fff;
  border-radius: 10px;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  overflow: hidden;
}

.diet-title {
  background: #e8f5e9;
  padding: 0.75rem 0rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: #1b5e20;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 520px;
  font-size: 0.88rem;
}

th {
  background: #388e3c;
  color: #fff;
  padding: 0.5rem 0.75rem;
  text-align: left;
  white-space: nowrap;
}

th.num { text-align: right; }

td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}

td.num { text-align: right; font-variant-numeric: tabular-nums; }

input.g-input { width: 60px; text-align: right; font-variant-numeric: tabular-nums; display: none; }

.g-val { cursor: pointer; font-variant-numeric: tabular-nums; display: inline-block; width: 60px; text-align: right; }
.g-val:hover { text-decoration: underline dotted; }
.g-val--modified { font-weight: bold; }

.ingr-name.ingr-zero { color: #aaa; text-decoration: line-through; }
.ingr-name.ingr-added { font-weight: bold; }

.nutr-delta { display: block; font-size: 0.72em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.nutr-delta.delta-pos { color: #c0392b; }
.nutr-delta.delta-neg { color: #27ae60; }

tr:last-child td { border-bottom: none; }

td.meal-name {
  font-weight: 700;
  color: #2e7d32;
  white-space: nowrap;
  vertical-align: top;
  padding-top: 0.55rem;
}

tr:nth-child(even) { background: #fafafa; }

/* summary table */
.summary-table {
  margin-top: 0;
}

.summary-table th {
  background: #1b5e20;
}

.summary-table td {
  font-weight: 600;
}

.notes {
  padding: 0.75rem 1rem;
  background: #fffde7;
  border-top: 1px solid #f9e200;
}

.notes ul {
  margin: 0;
  padding-left: 1.2rem;
}

.notes li {
  font-size: 0.85rem;
  line-height: 1.5;
  color: #555;
}

.no-results {
  text-align: center;
  padding: 3rem 1rem;
  color: #888;
  font-size: 1rem;
}

td.nutr {
  display: none;
  background: #e8f4fd;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

th.nutr {
  display: none;
  background: #1565c0;
}

body.show-nutr td.nutr,
body.show-nutr th.nutr {
  display: table-cell;
}

.nutr-incomplete {
  color: #c62828;
  font-weight: 700;
}

#btn-nutr {
  padding: 0.4rem 0.85rem;
  border: none;
  border-radius: 6px;
  background: #1b5e20;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

#btn-nutr.active {
  background: #0d47a1;
}

mark {
  background: #fff176;
  border-radius: 2px;
  padding: 0 1px;
}

.diet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: #e8f5e9;
  border-left: 4px solid #2e7d32;
  padding: 0.6rem 1rem;
}

.diet-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1b5e20;
  flex: 1;
}

.btn-reset {
  flex-shrink: 0;
  padding: 0.35rem 0.75rem;
  border: 2px solid #c0392b;
  border-radius: 6px;
  background: transparent;
  color: #c0392b;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-reset:hover { background: #c0392b; color: #fff; }
.btn-reset:active { opacity: 0.75; }

.btn-today {
  flex-shrink: 0;
  padding: 0.35rem 0.75rem;
  border: 2px solid #2e7d32;
  border-radius: 20px;
  background: transparent;
  color: #2e7d32;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.btn-today.is-today {
  background: #2e7d32;
  color: #fff;
}

.btn-today:active {
  opacity: 0.75;
}

#oggi-banner {
  background: #fff8e1;
  border-bottom: 2px solid #f9a825;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#oggi-banner a {
  color: #1b5e20;
  font-weight: 600;
  text-decoration: underline;
}

.btn-add-item {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border: 2px solid #1565c0;
  border-radius: 50%;
  background: transparent;
  color: #1565c0;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-add-item:hover { background: #1565c0; color: #fff; }
.btn-add-item:active { opacity: 0.75; }

.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 1000; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal-dialog { background: #fff; border-radius: 10px; padding: 1.5rem; min-width: 320px; max-width: 90vw; box-shadow: 0 4px 24px rgba(0,0,0,0.22); }
.modal-title { margin: 0 0 1rem; font-size: 1.1rem; }
.modal-field { margin-bottom: 0.75rem; display: flex; flex-direction: column; gap: 0.3rem; }
.modal-field label { font-size: 0.82rem; font-weight: 600; color: #555; }
.modal-field select, .modal-field input { padding: 0.4rem 0.6rem; border: 1px solid #ccc; border-radius: 6px; font-size: 0.95rem; }
.modal-error { color: #c0392b; font-size: 0.82rem; min-height: 1.1em; margin-bottom: 0.4rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.25rem; }
.btn-modal-cancel { padding: 0.4rem 0.9rem; border: 1px solid #ccc; border-radius: 6px; background: #f5f5f5; cursor: pointer; font-size: 0.9rem; }
.btn-modal-confirm { padding: 0.4rem 0.9rem; border: none; border-radius: 6px; background: #1565c0; color: #fff; cursor: pointer; font-size: 0.9rem; }
.btn-modal-confirm:hover { background: #0d47a1; }
