:root {
  --bg: #1a1b26;
  --surface: #24283b;
  --surface-hover: #2d3142;
  --text: #c0caf5;
  --text-muted: #565f89;
  --muted: #565f89;
  --border: #3b4261;
  --accent: #7aa2f7;
  --accent-hover: #8dadff;
  --success: #9ece6a;
  --danger: #f7768e;
  --radius: 8px;
  --page-gap: 1.5rem;
  --section-gap: 1.5rem;
}

* {
  box-sizing: border-box;
}

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

#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

/* Общий контейнер страниц */
.page {
  padding-top: 0.25rem;
}

.page .page-title {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text);
}

.page .page-desc {
  color: var(--muted);
  margin: 0 0 var(--page-gap);
  font-size: 0.9rem;
  line-height: 1.45;
}

.page .rules {
  color: var(--muted);
  margin-bottom: var(--page-gap);
  font-size: 0.95rem;
  line-height: 1.4;
}

.header {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

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

.header h1 {
  margin: 0;
  font-size: 1.5rem;
}

#auth-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#auth-bar span {
  color: var(--muted);
  font-size: 0.9rem;
}

#auth-bar .role {
  background: var(--surface);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
}

#auth-bar button {
  background: var(--muted);
  color: var(--text);
  border: none;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
}

#auth-bar button:hover {
  background: var(--accent);
  color: var(--bg);
}

/* Auth screen */
#auth-screen.hidden {
  display: none !important;
}

#auth-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 0;
}

.auth-box {
  background: var(--surface);
  padding: 1.5rem 2rem;
  border-radius: var(--radius);
  width: 100%;
  max-width: 320px;
  margin-bottom: 1rem;
}

.auth-box.hidden {
  display: none;
}

.auth-box h2 {
  margin: 0 0 1rem;
  font-size: 1.2rem;
}

.auth-box input {
  display: block;
  width: 100%;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

.auth-box button {
  width: 100%;
  padding: 0.65rem;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.auth-box button:hover {
  filter: brightness(1.1);
}

.auth-switch {
  margin: 1rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.auth-switch a {
  color: var(--accent);
}

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

.error {
  color: var(--danger);
  margin-top: 0.5rem;
}

.error.hidden {
  display: none;
}

/* Main */
#main-screen.hidden {
  display: none;
}

#attempts-page.hidden,
#settings-page.hidden,
#table-page.hidden {
  display: none;
}

#recipes-page.hidden {
  display: none;
}


.recipes-filters .recipes-filter-label {
  margin-bottom: 0.5rem;
}

.recipes-filters .autocomplete-wrap {
  position: relative;
  max-width: 24rem;
  margin-bottom: 0.75rem;
}

.recipes-filters .autocomplete-wrap + .autocomplete-wrap {
  margin-bottom: 1rem;
}

.recipes-filters #recipes-search-name,
.recipes-filters #recipes-search-ingredient {
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

.autocomplete-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 2px;
  max-height: 14rem;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 10;
}

.autocomplete-dropdown.hidden {
  display: none;
}

.autocomplete-item {
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font-size: 0.95rem;
}

.autocomplete-item:hover {
  background: var(--bg);
}

.recipes-filter-ingredients {
  margin-top: 0.75rem;
}

.recipes-filter-label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
}

.recipes-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 40px;
  margin-bottom: 0.5rem;
}

.recipes-slot-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--surface);
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
}

.recipes-slot-item img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.recipes-slot-item .qty {
  color: var(--muted);
  font-size: 0.8rem;
}

.recipes-slot-item button.remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0 0.2rem;
  font-size: 1rem;
  line-height: 1;
}

.recipes-slot-item button.remove:hover {
  color: var(--danger);
}

.recipes-slots-hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 1rem;
}

.recipes-results {
  margin-bottom: var(--section-gap);
  background: var(--surface);
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow-x: auto;
}

.recipes-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.recipes-table th,
.recipes-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border: 1px solid var(--border);
}

.recipes-table th {
  font-weight: 600;
  color: var(--muted);
}

.recipes-name-cell {
  vertical-align: middle;
}

.recipe-name-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.recipe-name-cell .recipe-name-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
}

.recipe-name-text {
  font-weight: 500;
}

.recipes-ingredients-cell {
  max-width: 28rem;
  font-size: 0.9rem;
}

.recipes-ingredients-cell .combo-ing {
  margin-right: 0.35rem;
  margin-bottom: 0.2rem;
}

.recipes-more-details {
  margin-top: 0.5rem;
}

.recipes-more-summary {
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border-radius: var(--radius);
  font-size: 0.95rem;
  list-style: none;
  user-select: none;
}

.recipes-more-summary::-webkit-details-marker {
  display: none;
}

.recipes-more-summary::before {
  content: '▶ ';
  font-size: 0.7rem;
  color: var(--muted);
}

.recipes-more-details[open] .recipes-more-summary::before {
  content: '▼ ';
}

.recipes-table-more {
  margin-top: 0.25rem;
}

.recipes-table-more thead {
  display: none;
}

.recipes-items-section {
  margin-top: var(--section-gap);
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.recipes-items-section h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

#recipes-items-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem 0;
}

#recipes-items-grid .recipes-category-group {
  display: block;
}

#recipes-items-grid .recipes-category-label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
  color: var(--text);
}

#recipes-items-grid .recipes-category-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.5rem;
}

#recipes-items-grid .item-card {
  cursor: pointer;
}

/* Страница «Таблица» */
.table-page-selectors {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.table-selector-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.table-selector-label {
  font-weight: 600;
  font-size: 0.9rem;
}

.table-select {
  min-width: 200px;
  padding: 0.4rem 0.5rem;
  font-size: 0.95rem;
}

.table-page-content {
  overflow-x: auto;
  background: var(--surface);
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: var(--section-gap);
}

.combo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.combo-table th,
.combo-table td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  vertical-align: middle;
}

.combo-table th {
  background: var(--surface);
  font-weight: 600;
  text-align: left;
  color: var(--text);
}

.combo-table-th-filter {
  vertical-align: top;
}

.combo-table-th-label {
  display: block;
  margin-bottom: 0.35rem;
}

.combo-table-head-select {
  display: block;
  width: 100%;
  max-width: 180px;
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}

.combo-table-head-select.table-6-col-item-select {
  margin-top: 0.25rem;
}

.table-col-item-combo {
  position: relative;
  margin-top: 0.25rem;
}

.table-col-item-input {
  box-sizing: border-box;
}

.table-col-item-dropdown {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 2px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.table-col-item-dropdown.open {
  display: block;
}

.table-col-item-option {
  padding: 0.35rem 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-col-item-option:hover {
  background: var(--accent);
  color: var(--bg);
}

.table-col-item-option.table-col-item-empty {
  cursor: default;
  color: var(--muted);
}

.table-col-item-option.table-col-item-empty:hover {
  background: transparent;
  color: var(--muted);
}

.combo-table-hide-empty-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: normal;
  font-size: 0.9rem;
  cursor: pointer;
}

.combo-table-hide-empty {
  cursor: pointer;
}

/* Вкладки на странице Таблица */
.table-page-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--muted, #ccc);
}

.table-tab-btn {
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  color: var(--text);
}

.table-tab-btn:hover {
  color: var(--accent);
}

.table-tab-btn.active {
  font-weight: 600;
  border-bottom-color: var(--accent);
  color: var(--accent);
}

.table-tab-pane {
  margin-top: 0.5rem;
}

.table-tab-pane.hidden {
  display: none !important;
}

.table-tab-pane .page-desc {
  margin-bottom: 1rem;
}

.combo-table-cell {
  min-width: 120px;
}

/* Столбцы 1–7: выравнивание по центру по вертикали и горизонтали */
.combo-table-6 th:nth-child(1),
.combo-table-6 th:nth-child(2),
.combo-table-6 th:nth-child(3),
.combo-table-6 th:nth-child(4),
.combo-table-6 th:nth-child(5),
.combo-table-6 th:nth-child(6),
.combo-table-6 th:nth-child(7) {
  text-align: center;
  vertical-align: middle;
}

.combo-table-6 td:nth-child(1),
.combo-table-6 td:nth-child(2),
.combo-table-6 td:nth-child(3),
.combo-table-6 td:nth-child(4),
.combo-table-6 td:nth-child(5),
.combo-table-6 td:nth-child(6),
.combo-table-6 td:nth-child(7) {
  text-align: center;
  vertical-align: middle;
}

.combo-table-6 td:nth-child(1) .table-cell-item,
.combo-table-6 td:nth-child(2) .table-cell-item,
.combo-table-6 td:nth-child(3) .table-cell-item,
.combo-table-6 td:nth-child(4) .table-cell-item,
.combo-table-6 td:nth-child(5) .table-cell-item,
.combo-table-6 td:nth-child(6) .table-cell-item,
.combo-table-6 td:nth-child(7) .table-cell-item {
  margin-left: auto;
  margin-right: auto;
}

/* Столбец 8: по центру по высоте, по левому краю */
.combo-table-6 th:nth-child(8),
.combo-table-6 td:nth-child(8) {
  text-align: left;
  vertical-align: middle;
}

.combo-table-cell-match {
  background: rgba(34, 139, 34, 0.2);
}

.combo-table-row-match td {
  background: rgba(34, 139, 34, 0.2);
}

.combo-table-row-failure td {
  background: rgba(200, 60, 60, 0.35);
}

.combo-table-overflow {
  padding: 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.combo-table-total-rows {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
}

.combo-table-pagination {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.combo-table-pagination-info {
  font-size: 0.9rem;
  color: var(--muted);
}

.combo-table-page-btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.9rem;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}

.combo-table-page-btn:hover:not(:disabled) {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.combo-table-page-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.combo-table-page-num {
  font-size: 0.9rem;
  font-weight: 600;
}

.table-cell-item {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  text-align: center;
}

.table-cell-item img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  display: block;
}

.table-cell-label {
  font-size: 0.75rem;
  line-height: 1.2;
  max-width: 100px;
  word-break: break-word;
}

.table-cell-recipe-ingredients {
  display: flex;
  flex-wrap: nowrap;
  flex-direction: row;
  gap: 0.5rem;
  align-items: flex-start;
}

.table-cell-recipe-ingredients .table-cell-item {
  flex: 0 0 auto;
}

.table-cell-recipe-ingredients .table-cell-item img {
  width: 24px;
  height: 24px;
}

.table-cell-recipe-ingredients .table-cell-label {
  font-size: 0.375rem;
  max-width: 50px;
}

/* 8-й столбец (ингредиенты рецепта): ширина под 6 итемов в ряд без прокрутки (иконка 24px + подпись 50%) */
.combo-table-6 th:nth-child(8),
.combo-table-6 td:nth-child(8) {
  min-width: 30rem;
  width: 30rem;
}

.header-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}

.header-nav-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}

.header-nav-right {
  margin-left: auto;
  padding: 0.35rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.header-nav-right:hover {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  text-decoration: none;
}

.header-nav a {
  color: var(--accent);
  text-decoration: none;
}

.header-nav a:hover {
  text-decoration: underline;
}

#header-nav.hidden {
  display: none !important;
}

.header-nav .nav-admin-only.hidden {
  display: none;
}


.slots,
.items-section,
.recipes-filters {
  background: var(--surface);
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: var(--section-gap);
}

.slots h3,
.items-section h3,
.admin-section h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

#slots-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 48px;
  margin-bottom: 0.75rem;
}

.slot-item {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  background: var(--bg);
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.slot-item-icon-wrap {
  position: relative;
  flex-shrink: 0;
}

.slot-item img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  display: block;
}

.slot-item .slot-remove {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
  background: var(--bg);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--border);
  cursor: pointer;
  color: var(--danger);
}

.slot-item .slot-remove:hover {
  color: #fff;
  background: var(--danger);
}

.slot-item .slot-lock {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: var(--bg);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--border);
  cursor: pointer;
  color: var(--muted);
}

.slot-item .slot-item-name {
  text-align: center;
  max-width: 100px;
  line-height: 1.2;
  word-break: break-word;
}

.slot-item .slot-qty-input {
  width: 3rem;
  padding: 0.2rem 0.35rem;
  font-size: 0.9rem;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.slot-item button.slot-lock:hover {
  color: var(--accent);
}

.slot-item.slot-item-locked {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

.slot-actions-row {
  margin: 0.5rem 0;
}

.btn-check-recipe {
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
}

.btn-check-recipe:hover:not(:disabled) {
  filter: brightness(1.1);
}

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

.slot-hint {
  margin: 0.75rem 0 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.result-buttons {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn-result {
  flex: 1;
  min-width: 140px;
  padding: 1rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
}

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

.btn-result.btn-success {
  background: var(--success);
  color: var(--bg);
}

.btn-result.btn-success:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-result.btn-failure {
  background: var(--danger);
  color: #fff;
}

.btn-result.btn-failure:hover:not(:disabled) {
  filter: brightness(1.1);
}

.slot-actions button {
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
}

.slot-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Result */
.result {
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  margin-bottom: var(--section-gap);
  font-weight: 600;
  border: 1px solid transparent;
}

.result.success {
  background: rgba(158, 206, 106, 0.2);
  color: var(--success);
}

.result.failure {
  background: rgba(247, 118, 142, 0.2);
  color: var(--danger);
}

.result.hidden {
  display: none;
}

/* Items grid */
.items-filters {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.items-filters input,
.items-filters select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

.items-filters input {
  flex: 1;
  max-width: 280px;
}

.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.5rem;
}

.item-card {
  background: var(--surface);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 0.5rem;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, transform 0.1s;
}

.item-card:hover {
  border-color: var(--muted);
}

.item-card.selected {
  border-color: var(--accent);
  background: rgba(122, 162, 247, 0.15);
}

.item-card.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.item-card img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  display: block;
  margin: 0 auto 0.25rem;
}

.item-card .name {
  font-size: 0.7rem;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Admin */
.admin-section,
.admin-panel-section {
  margin-top: var(--section-gap);
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.admin-panel-section h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.admin-panel-link {
  color: var(--accent);
  text-decoration: none;
}

.admin-panel-link:hover {
  text-decoration: underline;
}

.admin-panel-desc {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 1rem;
}

.admin-panel-desc code {
  font-size: 0.85em;
  background: var(--surface);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}

.admin-backup-restore {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.admin-backup-restore h4 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.restore-backup-form {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 0.5rem 0.75rem;
  align-items: stretch;
  margin: 0.75rem 0 0;
}

.restore-backup-file-wrap {
  display: contents;
}

.restore-backup-file-label {
  grid-column: 1;
  grid-row: 1;
  font-size: 0.9rem;
  color: var(--muted);
  align-self: end;
}

.restore-backup-form input[type="file"] {
  grid-column: 1;
  grid-row: 2;
  padding: 0 0.75rem;
  height: 2.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
  box-sizing: border-box;
}

.restore-backup-form input[type="file"]::file-selector-button {
  height: 100%;
  margin: 0 0.75rem 0 -0.25rem;
  padding: 0 0.65rem;
  border: none;
  border-right: 1px solid var(--border);
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}

.restore-backup-form input[type="file"]::file-selector-button:hover {
  background: var(--surface-hover);
}

.restore-backup-form .btn-secondary {
  grid-column: 2;
  grid-row: 2;
  padding: 0 0.75rem;
  height: 2.5rem;
  font-size: 0.95rem;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.restore-backup-status {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
  color: var(--text);
}

.restore-backup-status.success {
  color: var(--success, #2e7d32);
}

.restore-backup-status.error {
  color: var(--danger);
}

.admin-create-user-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1rem;
}

.admin-create-user-field {
  display: flex;
  flex-direction: column;
  min-width: 10rem;
  flex: 1;
  max-width: 16rem;
}

.admin-create-user-label {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.admin-create-user-field input,
.admin-create-user-field select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

.admin-create-user-actions {
  margin-bottom: 0.5rem;
}

.admin-create-user-form .success-msg {
  color: var(--success);
  margin-top: 0.5rem;
}

.admin-users-list-wrap {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.admin-users-list-title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.admin-users-list {
  font-size: 0.95rem;
}

.admin-users-list table {
  width: 100%;
  border-collapse: collapse;
}

.admin-users-list th,
.admin-users-list td {
  padding: 0.4rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.admin-users-list th {
  color: var(--muted);
  font-weight: 600;
}

.admin-users-list .users-table {
  max-width: 100%;
}

.users-table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.users-table-actions .btn-secondary,
.users-table-actions .btn-delete-user {
  white-space: nowrap;
}

.btn-delete-user {
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}

.btn-delete-user:hover {
  filter: brightness(1.15);
}

.users-table-actions .btn-block-user,
.btn-block-user.btn-secondary {
  background: #c9a227 !important;
  color: #1a1b26 !important;
  border-color: #c9a227 !important;
}

.users-table-actions .btn-block-user:hover,
.btn-block-user.btn-secondary:hover {
  background: #d4af37 !important;
  border-color: #d4af37 !important;
  color: #1a1b26 !important;
}

.admin-section.hidden {
  display: none;
}

#attempts-list-page {
  background: var(--surface);
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: var(--section-gap);
  overflow-x: auto;
}

#attempts-list {
  overflow-x: auto;
}

.attempts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.attempts-table th,
.attempts-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border: 1px solid var(--border);
}

.attempts-table th {
  color: var(--muted);
  font-weight: 600;
}

.attempts-table .result-success {
  color: var(--success);
}

.attempts-table .result-failure {
  color: var(--danger);
}

.combo-cell {
  vertical-align: middle;
}

.combo-ing {
  display: inline-flex;
  align-items: center;
  margin-right: 0.5rem;
  margin-bottom: 0.25rem;
  padding: 0.2rem 0.4rem;
  background: var(--surface);
  border-radius: 6px;
  font-size: 0.8rem;
  white-space: nowrap;
}

.combo-ing-wrap {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.combo-ing img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  flex-shrink: 0;
}

.combo-ing-qty {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
}

.btn-delete-attempt {
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}

.btn-delete-attempt:hover {
  filter: brightness(1.15);
}

.deleted-section {
  margin-top: var(--section-gap);
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.deleted-section.hidden {
  display: none;
}

.deleted-section h3,
.deleted-subtitle {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  color: var(--muted);
}

#attempts-deleted-list,
#attempts-deleted-list-main {
  overflow-x: auto;
}

/* Quantity modal / inline */
.qty-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.qty-input-wrap input {
  width: 3.5rem;
  padding: 0.25rem 0.35rem;
  border: 1px solid var(--muted);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  text-align: center;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.hidden {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.modal-box {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-box-wide {
  max-width: 560px;
}

.recipes-actions {
  margin-bottom: var(--section-gap);
}

.recipes-actions.hidden {
  display: none;
}

.recipes-actions .btn-primary {
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
}

.add-recipe-ing-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.add-recipe-ing-row select {
  flex: 1;
  min-width: 0;
}

.add-recipe-ing-row input[type="number"] {
  width: 5rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--muted);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}

.add-recipe-ing-remove {
  padding: 0.35rem 0.5rem;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}

.add-recipe-ing-remove:hover {
  color: var(--danger);
}

.btn-primary {
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-secondary {
  padding: 0.4rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}

.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--muted);
}

.modal-box .required {
  color: var(--danger);
}

.modal-box h3 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
}

.modal-box label {
  display: block;
  margin: 0.75rem 0 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.modal-box label:first-of-type {
  margin-top: 0;
}

.modal-box input[type="text"],
.modal-box input[type="file"],
.modal-box select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

#success-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 2rem;
}

.success-form-slot {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg);
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
}

.success-form-slot img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.success-form-slot input {
  width: 3rem;
  padding: 0.2rem 0.3rem;
  border: 1px solid var(--muted);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  text-align: center;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.modal-actions .btn-primary {
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
}

.modal-actions button[type="button"] {
  padding: 0.5rem 1rem;
  background: var(--muted);
  color: var(--text);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}

.modal-actions button:hover {
  filter: brightness(1.1);
}
