:root {
  --ink: #2b2420;
  --soft: #7a7068;
  --surface: #f7f2ec;
  --accent: #c0572c;
  --border: #e7ddd1;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: #fff;
}

.hidden { display: none !important; }

/* Login */
#login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
}

.login-card {
  background: #fff;
  border-radius: 20px;
  padding: 32px;
  width: 320px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-card h1 { margin: 0; font-size: 20px; }
.subtitle { margin: 0 0 8px; color: var(--soft); font-size: 14px; }

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--soft);
  font-weight: 600;
}

input, select, textarea {
  font: inherit;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
}

button {
  font: inherit;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

button:hover { opacity: 0.9; }

.ghost-btn {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border);
}

.error { color: #b3261e; font-size: 13px; min-height: 16px; margin: 0; }

.password-row { display: flex; gap: 8px; }
.password-row input { flex: 1; }
.password-row button { padding: 10px 12px; font-size: 12px; }

/* App shell */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.topbar h1 { font-size: 18px; margin: 0; flex-shrink: 0; }
.topbar nav { display: flex; gap: 8px; flex: 1; }

.tab-btn {
  background: transparent;
  color: var(--soft);
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 10px;
}

.tab-btn.active { background: var(--surface); color: var(--ink); }

.tab-panel { padding: 20px 24px; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar input[type="search"] { min-width: 260px; }
.spacer { flex: 1; }
.muted { color: var(--soft); font-size: 13px; }

.checkbox-label {
  flex-direction: row;
  align-items: center;
  gap: 6px;
}
.checkbox-label input { width: auto; padding: 0; }

.table-wrap {
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: auto;
  max-height: 65vh;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }

th, td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  color: var(--soft);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.badge.live { background: #e4f3e6; color: #2a6b35; }
.badge.hidden-badge { background: #f3e4e4; color: #8a2d2d; }

/* Actions stay pinned to the right edge so Edit / Hide / Delete are always
   visible without scrolling the wide table. */
.row-actions {
  position: sticky;
  right: 0;
  background: #fff;
  box-shadow: -6px 0 6px -6px rgba(0, 0, 0, 0.15);
}
.row-actions button { padding: 6px 10px; font-size: 12px; margin-right: 4px; }
.row-actions .delete-btn,
.danger-btn { color: #b3261e; border-color: #e7b9b5; }
thead th:last-child { position: sticky; right: 0; background: var(--surface); }

#recipes-load-more, #users-load-more { margin-top: 12px; }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow: auto;
}

.modal-card {
  background: #fff;
  border-radius: 20px;
  padding: 28px;
  width: 560px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-card h2 { margin: 0; }

.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
/* min-width: 0 overrides flexbox's default min-width:auto, which sizes a
   flex item to its content's natural width (an <input>'s default ~20-char
   intrinsic size) - without it, 4 inputs in one row refuse to shrink below
   that and spill past the modal's edge instead of fitting it. */
.field-row label { flex: 1 1 110px; min-width: 0; }
.field-row input, .field-row select { width: 100%; }

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-grid label {
  flex-direction: row;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 500;
}
.chip-grid input { width: auto; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

textarea { resize: vertical; font-family: inherit; }

.import-card { width: 640px; }
.import-preview { max-height: 40vh; }
.badge.error-badge { background: #f3e4e4; color: #8a2d2d; }
.badge.ready-badge { background: #e4f3e6; color: #2a6b35; }

.row-thumb {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  display: block;
  background: var(--surface);
}
.row-thumb-clickable { cursor: zoom-in; }
.row-thumb-placeholder {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.page-form {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.page-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

#recipe-page .topbar { gap: 16px; }
#recipe-page .topbar h1 { flex: 1; }

.recipe-id { font-size: 11px; margin-top: 2px; }
.recipe-link { color: var(--accent); text-decoration: none; font-weight: 600; }
.recipe-link:hover { text-decoration: underline; }

.photo-preview {
  position: relative;
  width: 140px;
}

.photo-remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  padding: 0;
  line-height: 1;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-weight: 700;
}

.photo-preview img {
  width: 140px;
  height: 140px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--border);
  margin-bottom: 8px;
}

.festival-add-row { display: flex; gap: 8px; margin-top: 8px; }
.festival-add-row input { flex: 1; }

/* Page navigation under the recipe list. */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
}
.pager button:disabled { opacity: 0.4; cursor: default; }
