/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:       #1a7a4a;
  --green-dark:  #155c38;
  --green-light: #e8f5ef;
  --green-mid:   #c1e0cf;
  --orange:      #f4a261;
  --orange-dark: #e07b30;
  --red:         #e63946;
  --red-dark:    #c0303b;
  --bg:          #f0f4f1;
  --card:        #ffffff;
  --text:        #1d3124;
  --text2:       #5a7065;
  --border:      #d4e6da;
  --shadow:      0 2px 12px rgba(26,122,74,.10);
  --shadow-lg:   0 8px 32px rgba(26,122,74,.18);
  --radius:      12px;
  --radius-sm:   8px;
  font-size: 15px;
}

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

/* ===== HEADER ===== */
header {
  background: var(--green);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,.15);
}
.header-inner {
  max-width: 1300px;
  margin: 0 auto;
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.logo { display: flex; align-items: center; gap: .75rem; }
.logo-title {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -.3px;
  color: #fff;
}
.logo-sub {
  display: block;
  font-size: .75rem;
  opacity: .75;
  letter-spacing: .3px;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex: 1;
  justify-content: flex-end;
}
.header-actions input {
  background: rgba(255,255,255,.15);
  border: 1.5px solid rgba(255,255,255,.3);
  border-radius: 8px;
  color: #fff;
  padding: .5rem 1rem;
  width: 230px;
  font-size: .9rem;
  transition: background .2s, border-color .2s;
}
.header-actions input::placeholder { color: rgba(255,255,255,.6); }
.header-actions input:focus {
  outline: none;
  background: rgba(255,255,255,.25);
  border-color: rgba(255,255,255,.6);
}

/* ===== BUTTONS ===== */
.btn-primary {
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: .55rem 1.25rem;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .18s, transform .1s;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--orange-dark); }
.btn-primary:active { transform: scale(.97); }

.btn-ghost {
  background: transparent;
  color: var(--text2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .55rem 1.25rem;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .18s, color .18s;
}
.btn-ghost:hover { border-color: var(--green); color: var(--green); }

.btn-danger {
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: .55rem 1.25rem;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .18s;
}
.btn-danger:hover { background: var(--red-dark); }
.btn-sm { padding: .35rem .85rem; font-size: .82rem; }

/* ===== STATS ===== */
.stats-bar {
  display: flex;
  gap: 1rem;
  max-width: 1300px;
  margin: 1.5rem auto 0;
  padding: 0 1.5rem;
  flex-wrap: wrap;
}
.stat-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  flex: 1 1 160px;
  display: flex;
  flex-direction: column;
  gap: .2rem;
  box-shadow: var(--shadow);
}
.stat-num {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--green);
  line-height: 1;
}
.stat-lbl {
  font-size: .78rem;
  color: var(--text2);
  font-weight: 500;
  letter-spacing: .3px;
  text-transform: uppercase;
}

/* ===== FILTER BAR ===== */
.filter-bar {
  max-width: 1300px;
  margin: 1.25rem auto 0;
  padding: 0 1.5rem;
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}
.filter-btn {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: .4rem 1rem;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text2);
  cursor: pointer;
  transition: all .18s;
}
.filter-btn:hover, .filter-btn.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

/* ===== MAIN / GRID ===== */
main {
  max-width: 1300px;
  margin: 1.25rem auto 3rem;
  padding: 0 1.5rem;
}
.recipes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

/* ===== LIST VIEW ===== */
.recipes-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.list-row {
  display: flex;
  align-items: center;
  gap: .85rem;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .9rem;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.list-row:hover { border-color: var(--green-mid); box-shadow: var(--shadow); }
.list-thumb {
  width: 52px; height: 52px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
}
.list-thumb--empty {
  display: flex; align-items: center; justify-content: center;
  background: var(--green-light);
  font-size: 1.4rem;
}
.list-main { flex: 1; min-width: 0; }
.list-title {
  font-weight: 700;
  font-size: .95rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  align-items: center;
  margin-top: .2rem;
}
.list-date { font-size: .75rem; color: var(--text2); }
.list-badges { display: flex; flex-wrap: wrap; gap: .25rem; flex-shrink: 0; max-width: 160px; }
.list-actions { display: flex; gap: .4rem; flex-shrink: 0; }

/* ===== VIEW TOGGLE BUTTONS ===== */
.view-toggle {
  display: flex;
  gap: .2rem;
  align-items: center;
}
.view-btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .25rem .55rem;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text2);
  line-height: 1;
  transition: background .15s, color .15s;
}
.view-btn.active {
  background: var(--green-dark);
  color: #fff;
  border-color: var(--green-dark);
}

/* ===== LANGUAGE TOGGLE ===== */
.lang-btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .3rem .65rem;
  font-size: .82rem;
  cursor: pointer;
  color: var(--text2);
  white-space: nowrap;
  transition: background .15s, color .15s;
  font-family: inherit;
}
.lang-btn:hover {
  background: var(--green-light);
  color: var(--green-dark);
  border-color: var(--green-mid);
}

/* ===== SCROLL TO TOP ===== */
.scroll-top-btn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 2.6rem; height: 2.6rem;
  border-radius: 50%;
  background: var(--green-dark);
  color: #fff;
  border: none;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  z-index: 999;
  transition: opacity .2s, transform .2s;
  display: flex; align-items: center; justify-content: center;
}
.scroll-top-btn:hover { background: var(--green-mid); transform: translateY(-2px); }
.scroll-top-btn.hidden { opacity: 0; pointer-events: none; }

/* ===== RECIPE CARD ===== */
.recipe-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
.recipe-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--green-mid);
}
.card-photo {
  width: 100%;
  height: 185px;
  object-fit: cover;
  background: var(--green-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
  color: var(--green-mid);
  flex-shrink: 0;
  overflow: hidden;
}
.card-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-body {
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .45rem;
}
.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .5rem;
}
.card-title { font-size: 1.05rem; font-weight: 700; color: var(--text); line-height: 1.2; }
.card-date { font-size: .78rem; color: var(--text2); white-space: nowrap; flex-shrink: 0; }

.card-badges { display: flex; gap: .4rem; flex-wrap: wrap; }
.badge {
  background: var(--green-light);
  color: var(--green-dark);
  border-radius: 999px;
  padding: .2rem .65rem;
  font-size: .75rem;
  font-weight: 600;
}

.card-ingredients {
  display: flex;
  gap: .35rem;
  flex-wrap: wrap;
  margin-top: .1rem;
}
.ing-tag {
  background: #f0f4f1;
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: 999px;
  padding: .15rem .55rem;
  font-size: .72rem;
  font-weight: 500;
}
.ing-more {
  background: var(--green-light);
  color: var(--green-dark);
  border-color: var(--green-mid);
}

.card-workflow {
  font-size: .82rem;
  color: var(--text2);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-actions {
  display: flex;
  gap: .5rem;
  padding: .75rem 1rem;
  border-top: 1px solid var(--border);
  background: #fafcfb;
}
.card-actions button {
  flex: 1;
  padding: .4rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: transparent;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.card-actions .btn-edit { color: var(--green); }
.card-actions .btn-edit:hover { background: var(--green-light); border-color: var(--green); }
.card-actions .btn-del  { color: var(--red); }
.card-actions .btn-del:hover  { background: #fde8ea; border-color: var(--red); }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 4rem 1rem; color: var(--text2); }
.empty-icon { font-size: 4rem; margin-bottom: .75rem; }
.empty-state h2 { font-size: 1.4rem; color: var(--text); margin-bottom: .5rem; }
.empty-state p { margin-bottom: 1.5rem; }
.hidden { display: none !important; }

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 1000002;
  padding: var(--modal-top-offset, 1.5rem) 1rem 2rem;
  overflow-y: auto;
  backdrop-filter: blur(2px);
}
.modal-box {
  background: var(--card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 660px;
  flex-shrink: 0;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
}
.modal-box--wide { max-width: 900px; }
.modal-box--sm   { max-width: 420px; }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1.5px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 1;
}
.modal-header h2 { font-size: 1.15rem; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text2);
  cursor: pointer;
  line-height: 1;
  transition: color .15s;
}
.modal-close:hover { color: var(--text); }
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .75rem;
  padding: 1.25rem 1.5rem;
  border-top: 1.5px solid var(--border);
}
.autosave-status {
  margin-right: auto;
  font-size: .8rem;
  color: var(--text2);
  min-width: 6rem;
}
.autosave-status.saving { color: var(--text2); }
.autosave-status.saved  { color: var(--green-dark); font-weight: 600; }

/* ===== FORM ===== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 1.5rem;
}
.field { display: flex; flex-direction: column; gap: .4rem; position: relative; }
.field.full { grid-column: 1 / -1; }
label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.field-hint {
  text-transform: none;
  font-weight: 400;
  font-size: .8rem;
  color: #9ab8a8;
  letter-spacing: 0;
  margin-left: .3rem;
}
.req { color: var(--red); }

input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .55rem .85rem;
  font-size: .95rem;
  color: var(--text);
  background: #fff;
  width: 100%;
  transition: border-color .18s, box-shadow .18s;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(26,122,74,.1);
}
textarea { resize: vertical; min-height: 120px; }

.input-unit-wrap {
  display: flex;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color .18s, box-shadow .18s;
}
.input-unit-wrap:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(26,122,74,.1);
}
.input-unit-wrap input,
.input-unit-wrap select { border: none; border-radius: 0; box-shadow: none; }
.input-unit-wrap input { flex: 1; }
.input-unit-wrap input[type="text"] { flex: 2; }
.input-unit-wrap select {
  width: auto;
  background: var(--green-light);
  color: var(--green-dark);
  font-weight: 600;
  border-left: 1.5px solid var(--border);
  padding-left: .5rem;
  padding-right: .5rem;
}

/* ===== INGREDIENT ROWS ===== */
.ingredient-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-bottom: .5rem;
}
.ingredient-row {
  display: grid;
  grid-template-columns: 22px 2fr 100px 90px 80px 36px;
  gap: .4rem;
  align-items: center;
}
.drag-handle {
  cursor: grab;
  color: var(--text2);
  font-size: 1.1rem;
  line-height: 1;
  user-select: none;
  text-align: center;
  padding: 0 2px;
  opacity: .5;
  transition: opacity .15s;
}
.drag-handle:hover { opacity: 1; }
.drag-handle:active { cursor: grabbing; }
.ingredient-row-ghost { opacity: .4; background: var(--green-light); border-radius: var(--radius-sm); }
.ing-remove {
  width: 36px;
  height: 36px;
  border: 1.5px solid #f5c0c4;
  background: #fff0f0;
  color: var(--red);
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}
.ing-remove:hover { background: #fde8ea; border-color: var(--red); }

.btn-add-ingredient {
  background: var(--green-light);
  color: var(--green-dark);
  border: 1.5px dashed var(--green-mid);
  border-radius: var(--radius-sm);
  padding: .5rem 1rem;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  width: 100%;
  text-align: center;
}
.btn-add-ingredient:hover { background: #d4f0e2; border-color: var(--green); }

/* ===== PHOTO UPLOAD ===== */
.photo-drop {
  border: 2px dashed var(--green-mid);
  border-radius: var(--radius);
  min-height: 140px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: border-color .18s, background .18s;
  background: var(--green-light);
}
.photo-drop:hover { border-color: var(--green); background: #ddf0e6; }
.photo-drop.drag-over { border-color: var(--green); background: #d0ecdf; }

.photo-placeholder {
  text-align: center;
  color: var(--text2);
  pointer-events: none;
  padding: 1.5rem;
}
.photo-placeholder span { font-size: 2rem; display: block; margin-bottom: .4rem; }
.photo-placeholder p    { font-size: .9rem; margin-bottom: .2rem; font-weight: 500; }
.photo-placeholder small { font-size: .75rem; }

.photo-preview { width: 100%; height: 220px; }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }

.photo-actions {
  position: absolute;
  bottom: .6rem;
  right: .6rem;
  display: flex;
  gap: .4rem;
}
.btn-camera {
  background: rgba(26,122,74,.85);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: .35rem .75rem;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-camera:hover { background: var(--green-dark); }
.btn-remove-photo {
  background: rgba(230,57,70,.85);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: .35rem .75rem;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-remove-photo:hover { background: var(--red-dark); }

/* ===== DETAIL MODAL ===== */
.detail-photo {
  width: 100%;
  height: 260px;
  background: var(--green-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5rem;
  overflow: hidden;
}
.detail-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.detail-meta {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1rem 1.5rem .5rem;
  flex-wrap: wrap;
}
.detail-name {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
  flex: 1;
}
.detail-date {
  font-size: .85rem;
  color: var(--text2);
  white-space: nowrap;
}

/* ===== SCALER ===== */
.scaler-section {
  background: var(--green-light);
  border-top: 1.5px solid var(--green-mid);
  border-bottom: 1.5px solid var(--green-mid);
  padding: .85rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.scaler-label {
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--green-dark);
  white-space: nowrap;
}
.scaler-base {
  font-size: .9rem;
  color: var(--text2);
  white-space: nowrap;
}
.scaler-arrow {
  font-size: 1.1rem;
  color: var(--green);
}
.scaler-input-wrap {
  display: flex;
  align-items: center;
  gap: .4rem;
}
.scaler-input-wrap input {
  width: 80px;
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
  border-color: var(--green-mid);
}
.scaler-unit {
  font-size: .9rem;
  color: var(--text2);
  font-weight: 500;
}

/* ===== DETAIL CONTENT ===== */
.detail-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.detail-col {
  padding: 1.25rem 1.5rem;
}
.detail-col:first-child {
  border-right: 1.5px solid var(--border);
}
.detail-col h3 {
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text2);
  margin-bottom: .75rem;
  padding-bottom: .4rem;
  border-bottom: 1.5px solid var(--border);
}

/* Ingredient table in detail */
.ing-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.ing-table tr { border-bottom: 1px solid var(--border); }
.ing-table tr:last-child { border-bottom: none; }
.ing-table td { padding: .4rem .25rem; color: var(--text); }
.ing-table .ing-name-cell { font-weight: 500; }
.ing-table .ing-amount-cell {
  text-align: right;
  font-weight: 700;
  color: var(--green-dark);
  white-space: nowrap;
  padding-left: .75rem;
}
.ing-table .ing-cost-cell {
  text-align: right;
  font-size: .82rem;
  color: var(--text2);
  white-space: nowrap;
  padding-left: .5rem;
}
.ing-table .ing-total-row td {
  border-top: 1.5px solid var(--green-mid);
  padding-top: .5rem;
  font-weight: 700;
}
.ing-table .ing-total-row .ing-cost-cell {
  color: var(--green-dark);
  font-size: .95rem;
}

/* Workflow steps */
.workflow-steps {
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.workflow-steps li {
  font-size: .9rem;
  color: var(--text);
  line-height: 1.5;
  padding-left: .25rem;
}

/* Notes in detail */
.detail-notes {
  padding: 0 1.5rem 1rem;
  border-top: 1.5px solid var(--border);
}
.detail-notes h3 {
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text2);
  margin: 1rem 0 .5rem;
}
.detail-notes p {
  font-size: .9rem;
  color: var(--text2);
  line-height: 1.6;
}

/* Changelog timeline in detail */
.detail-changelog {
  padding: 0 1.5rem 1rem;
  border-top: 1.5px solid var(--border);
}
.detail-changelog h3 {
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text2);
  margin: 1rem 0 .75rem;
}
.changelog-entry {
  display: flex;
  gap: .75rem;
  align-items: center;
  padding: .35rem 0 .35rem 1rem;
  border-left: 2px solid var(--green-mid);
  margin-bottom: .4rem;
  font-size: .88rem;
}
.changelog-date {
  color: var(--green-dark);
  font-weight: 600;
  white-space: nowrap;
  min-width: 80px;
  flex-shrink: 0;
}
.changelog-text {
  color: var(--text);
  line-height: 1.5;
  flex: 1;
}
.changelog-del-btn {
  background: none;
  border: none;
  color: #aaa;
  cursor: pointer;
  font-size: .85rem;
  padding: .1rem .35rem;
  line-height: 1;
  flex-shrink: 0;
  border-radius: 4px;
  transition: background .15s, color .15s;
}
.changelog-del-btn:hover { background: #fde8ea; color: #e63946; }

.detail-actions {
  display: flex;
  gap: .75rem;
  padding: 1rem 1.5rem 1.5rem;
  border-top: 1.5px solid var(--border);
}

/* ===== HEADER USER BAR ===== */
.header-user {
  display: flex;
  align-items: center;
  gap: .45rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.user-badge {
  display: flex;
  align-items: center;
  gap: .4rem;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px;
  padding: .3rem .8rem;
  font-size: .83rem;
  color: #fff;
  font-weight: 500;
  white-space: nowrap;
}
.user-role-badge {
  font-size: .68rem;
  font-weight: 700;
  border-radius: 999px;
  padding: .1rem .45rem;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.role-admin  { background: var(--orange); color: #fff; }
.role-staff  { background: var(--green-light); color: var(--green-dark); }

.btn-header {
  background: rgba(255,255,255,.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: var(--radius-sm);
  padding: .33rem .8rem;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .18s;
  white-space: nowrap;
  font-family: inherit;
}
.btn-header:hover { background: rgba(255,255,255,.28); }
.btn-header--logout { background: rgba(230,57,70,.35); border-color: rgba(230,57,70,.5); }
.btn-header--logout:hover { background: rgba(230,57,70,.6); }

/* ===== USER MANAGEMENT ===== */
.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .65rem 0;
  border-bottom: 1px solid var(--border);
  gap: .75rem;
}
.user-row:last-child { border-bottom: none; }
.users-divider {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text2);
  margin: 1rem 0 .6rem;
  padding-bottom: .4rem;
  border-bottom: 1.5px solid var(--border);
}

/* ===== EXPORT BUTTONS ===== */
.export-btns {
  display: flex;
  gap: .4rem;
  margin-left: auto;
}
.btn-export {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .38rem .85rem;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text2);
  cursor: pointer;
  transition: all .18s;
  white-space: nowrap;
  font-family: inherit;
}
.btn-export:hover {
  background: var(--green-light);
  border-color: var(--green);
  color: var(--green-dark);
}

/* ===== SCALE PRESET BUTTONS ===== */
.scaler-presets {
  display: flex;
  gap: .35rem;
  flex-wrap: wrap;
}
.preset-btn {
  background: #fff;
  border: 1.5px solid var(--green-mid);
  border-radius: 999px;
  padding: .28rem .7rem;
  font-size: .8rem;
  font-weight: 700;
  color: var(--green-dark);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  font-family: inherit;
}
.preset-btn:hover   { background: var(--green); border-color: var(--green); color: #fff; }
.preset-btn.active  { background: var(--green); border-color: var(--green); color: #fff; }

/* ===== INLINE CATEGORY BUTTONS (inside main filter bar) ===== */
.category-inline {
  display: contents; /* children appear as direct flex children of .filter-bar */
}
.filter-separator {
  display: inline-block;
  width: 1.5px;
  height: 20px;
  background: var(--border);
  border-radius: 999px;
  flex-shrink: 0;
  margin: auto .1rem;
}

/* ===== CATEGORY FILTER BAR (kept for legacy, not used) ===== */
.category-filter-bar {
  display: none; /* replaced by inline version */
}
.cat-btn {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: .32rem .85rem;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text2);
  cursor: pointer;
  transition: all .18s;
}
.cat-btn:hover, .cat-btn.active {
  background: var(--green-dark);
  border-color: var(--green-dark);
  color: #fff;
}

/* ===== CATEGORY BADGE (on cards) ===== */
.category-badge {
  background: var(--green-dark);
  color: #fff;
  border-radius: 999px;
  padding: .2rem .65rem;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .2px;
  white-space: nowrap;
}

/* ===== ALLERGEN BADGES ===== */
.allergen-badge {
  border-radius: 999px;
  padding: .18rem .58rem;
  font-size: .7rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  letter-spacing: .1px;
}
.detail-allergens {
  padding: .6rem 1.5rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  align-items: center;
}
.detail-allergens-label {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text2);
  margin-right: .25rem;
}

/* ===== ALLERGEN CHECKBOXES (in form) ===== */
.allergen-checks {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem .65rem;
  margin-top: .35rem;
}
.allergen-check {
  display: flex;
  align-items: center;
  gap: .35rem;
  cursor: pointer;
  font-size: .85rem;
  color: var(--text);
  user-select: none;
}
.allergen-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  accent-color: var(--green);
  flex-shrink: 0;
}
.allergen-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

/* ===== SEASON BADGES ===== */
.season-badge {
  border-radius: 999px;
  padding: .18rem .58rem;
  font-size: .72rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  letter-spacing: .1px;
}
.detail-seasons {
  padding: .5rem 1.5rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  align-items: center;
}

/* ===== STAR RATINGS ===== */
.rating-stars {
  display: inline-flex;
  align-items: center;
  gap: .15rem;
  font-size: .75rem;
  font-weight: 700;
  color: #f39c12;
  background: #fff8e1;
  border-radius: 999px;
  padding: .15rem .5rem;
  border: 1px solid #ffe082;
}
.star-picker {
  display: flex;
  gap: .2rem;
  margin-bottom: .4rem;
  font-size: 1.6rem;
  line-height: 1;
}
.star-filled { color: #f39c12; cursor: pointer; }
.star-empty  { color: #ccc;    cursor: pointer; }
.star-picker .star:hover,
.star-picker .star:hover ~ .star { color: #ccc; }
.star-picker .star { transition: color .1s; }
.star-picker .star:hover { color: #f39c12; }
.rating-comment-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .4rem .65rem;
  font-size: .88rem;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  box-sizing: border-box;
}
.ratings-list {
  margin-top: .75rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  border-top: 1px solid var(--border);
  padding-top: .75rem;
}
.rating-entry {
  display: flex;
  gap: .6rem;
  align-items: flex-start;
}
.rating-avatar {
  width: 2rem; height: 2rem;
  border-radius: 50%;
  background: var(--green-mid);
  color: var(--green-dark);
  font-weight: 700;
  font-size: .85rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.rating-body { flex: 1; }
.rating-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: .1rem;
}
.rating-name { font-weight: 700; font-size: .85rem; color: var(--text); }
.rating-date { font-size: .75rem; color: var(--text2); }
.rating-stars-row { font-size: .9rem; margin-bottom: .1rem; }
.rating-comment { font-size: .82rem; color: var(--text2); font-style: italic; }
.detail-ratings {
  padding: 1rem 1.5rem .5rem;
  border-top: 1.5px solid var(--border);
}
.detail-ratings h3 { margin-bottom: .6rem; font-size: .95rem; color: var(--green-dark); }

/* ===== RESPONSIVE ===== */
@media (max-width: 700px) {
  .header-inner { flex-wrap: wrap; }
  .header-actions { width: 100%; }
  .header-actions input { flex: 1; }
  .stats-bar { gap: .75rem; }
  .stat-card { flex: 1 1 130px; padding: .75rem 1rem; }
  .stat-num { font-size: 1.35rem; }
  .form-grid { grid-template-columns: 1fr; }
  .detail-body { grid-template-columns: 1fr; }
  .detail-col:first-child { border-right: none; border-bottom: 1.5px solid var(--border); }
  .recipes-grid { grid-template-columns: 1fr; }
  .ingredient-row { grid-template-columns: 20px 1.5fr 70px 70px 65px 36px; }
  .scaler-section { gap: .6rem; }
  .view-btn { padding: .45rem .85rem; font-size: 1.2rem; min-width: 2.5rem; min-height: 2.5rem; }
}

/* ===== MEAL PLANNER ===== */
.mealplan-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: .85rem 1.5rem .5rem;
}
.mealplan-week-label {
  font-weight: 700;
  font-size: 1rem;
  color: var(--green-dark);
  min-width: 200px;
  text-align: center;
}
.mealplan-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: .65rem;
  padding: .75rem 1.5rem 0;
  overflow-x: auto;
}
.mealplan-day {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .65rem .5rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  min-height: 110px;
}
.mealplan-day-header {
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text2);
}
.mealplan-day-date {
  font-size: .7rem;
  color: var(--text2);
  margin-top: -.2rem;
  margin-bottom: .2rem;
}
.mealplan-slot-empty {
  flex: 1;
  border: 1.5px dashed var(--green-mid);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  color: var(--text2);
  text-align: center;
  padding: .5rem;
  transition: background .15s, border-color .15s;
  cursor: default;
}
.mealplan-slot-empty.drag-over {
  background: #fff4ed;
  border-color: var(--orange);
  color: var(--orange-dark);
}
.mealplan-slot-filled {
  flex: 1;
  background: var(--green-light);
  border: 1.5px solid var(--green-mid);
  border-radius: var(--radius-sm);
  padding: .45rem .5rem;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.mealplan-slot-name {
  font-size: .82rem;
  font-weight: 700;
  color: var(--green-dark);
  line-height: 1.3;
  padding-right: 1.2rem;
}
.mealplan-slot-yield {
  font-size: .72rem;
  color: var(--text2);
}
.mealplan-slot-remove {
  position: absolute;
  top: .25rem;
  right: .25rem;
  background: none;
  border: none;
  color: var(--red);
  font-size: .85rem;
  cursor: pointer;
  line-height: 1;
  padding: .1rem .2rem;
  border-radius: 4px;
}
.mealplan-slot-remove:hover { background: #fdecea; }

/* ===== MEAL PLANNER — TWO-PANEL LAYOUT ===== */
.mealplan-body {
  display: flex;
  gap: 0;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.mealplan-left {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.mealplan-right {
  width: 270px;
  flex-shrink: 0;
  border-left: 1.5px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.mealplan-browser-header {
  padding: .7rem .85rem .45rem;
  display: flex;
  flex-direction: column;
  gap: .45rem;
  border-bottom: 1px solid var(--border);
}
.mealplan-browser-header input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .4rem .7rem;
  font-size: .88rem;
  font-family: inherit;
  color: var(--text);
  outline: none;
  background: var(--bg);
  box-sizing: border-box;
}
.mealplan-browser-header input:focus { border-color: var(--green); }

/* Category tabs */
.mealplan-cat-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
}
.mealplan-cat-tab {
  padding: .18rem .55rem;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  font-size: .73rem;
  cursor: pointer;
  background: none;
  color: var(--text2);
  font-family: inherit;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.mealplan-cat-tab.active {
  background: var(--green-light);
  color: var(--green-dark);
  border-color: var(--green-mid);
  font-weight: 600;
}
.mealplan-cat-tab:hover:not(.active) { background: #f0f0f0; }

/* Recipe cards */
.mealplan-chips {
  flex: 1;
  overflow-y: auto;
  padding: .5rem .85rem .85rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.mealplan-chip {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .4rem .5rem;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: grab;
  user-select: none;
  transition: border-color .12s, background .12s;
}
.mealplan-chip:hover { border-color: var(--green-mid); background: var(--green-light); }
.mealplan-chip:active { cursor: grabbing; }
.mealplan-chip-img {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}
.mealplan-chip-no-img {
  width: 38px;
  height: 38px;
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--green-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
}
.mealplan-chip-info { flex: 1; min-width: 0; }
.mealplan-chip-name {
  font-size: .83rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mealplan-chip-meta {
  font-size: .7rem;
  color: var(--text2);
  margin-top: .05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Modal fills height for meal planner */
#mealPlanModal .modal-box {
  max-height: 90vh;
  height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (max-width: 900px) {
  .mealplan-body { flex-direction: column; }
  .mealplan-right { width: 100%; border-left: none; border-top: 1.5px solid var(--border); max-height: 280px; }
  .mealplan-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 480px) {
  .mealplan-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── PWA Install Banner ──────────────────────────────────────── */
.install-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 1200;
  background: var(--green-dark);
  color: #fff;
  padding: .75rem 1rem;
  box-shadow: 0 -2px 16px rgba(0,0,0,.18);
  animation: slideUp .35s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.install-banner-inner {
  max-width: 700px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: .85rem;
}

.install-banner-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  flex-shrink: 0;
  background: rgba(255,255,255,.12);
  padding: 3px;
}

.install-banner-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .15rem;
  font-size: .88rem;
  line-height: 1.3;
}

.install-banner-text strong {
  font-size: .97rem;
  font-weight: 700;
}

.install-banner-text span {
  opacity: .85;
}

.install-banner-btn {
  background: #fff;
  color: var(--green-dark);
  border: none;
  border-radius: 20px;
  padding: .45rem 1.15rem;
  font-weight: 700;
  font-size: .88rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background .15s;
}
.install-banner-btn:hover { background: #e8f5ec; }

.install-banner-dismiss {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.7);
  font-size: 1.1rem;
  cursor: pointer;
  padding: .3rem .4rem;
  flex-shrink: 0;
  line-height: 1;
  border-radius: 50%;
  transition: color .15s, background .15s;
}
.install-banner-dismiss:hover {
  color: #fff;
  background: rgba(255,255,255,.15);
}

/* WordPress admin bar offset — modals stay below the sticky bar */
body.admin-bar .modal-overlay {
  --modal-top-offset: 58px;
}

/* ===== PRINT ===== */
@media print {
  /* Hide everything except the detail panel */
  header, #filterBar, #recipesGrid, #emptyState, #mealPlanModal,
  .detail-actions, .detail-scaler, #detailRatings, #detailChangelog,
  .btn-ghost, .modal-overlay:not(#detailModal), #detailModal .modal-close { display: none !important; }

  #detailModal {
    position: static !important;
    background: none !important;
    padding: 0 !important;
  }
  #detailModal .modal-box {
    box-shadow: none !important;
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
    border-radius: 0 !important;
  }

  /* Constrain photo so it doesn't stretch across the page */
  .detail-photo {
    height: 220px !important;
    width: 100% !important;
    page-break-after: avoid;
  }
  .detail-photo img {
    width: auto !important;
    max-width: 100% !important;
    height: 220px !important;
    object-fit: contain !important;
    margin: 0 auto !important;
    display: block !important;
  }

  body { background: #fff !important; color: #000 !important; font-size: 12pt; }
  .detail-title { font-size: 18pt; }
}
