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

:root {
  --bg: #f7f5f2;
  --card: #ffffff;
  --ink: #2b2b2b;
  --muted: #777;
  --accent: #2f7d4f;
  --accent-soft: #e3f0e8;
  --border: #e2ddd6;
}

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

header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 5;
}

header h1 { font-size: 20px; }

#header-menu { display: flex; align-items: center; gap: 24px; flex: 1; }

.hamburger {
  display: none;
  margin-left: auto;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 18px;
  cursor: pointer;
  color: var(--ink);
}

nav { display: flex; gap: 8px; }

.user-chip { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }

@media (max-width: 720px) {
  header { flex-wrap: wrap; position: relative; }
  .hamburger { display: block; }
  #header-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px 16px 18px;
    z-index: 20;
  }
  #header-menu.open { display: flex; }
  #header-menu nav { flex-direction: column; }
  #header-menu nav .tab { width: 100%; text-align: left; border-radius: 8px; }
  .user-chip {
    margin-left: 0;
    flex-wrap: wrap;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
  }
}
.user-chip button {
  border: 1px solid var(--border); background: var(--card); border-radius: 6px;
  padding: 4px 10px; font-size: 12px; cursor: pointer; color: var(--ink);
}
.owner-tag { font-size: 11px; color: var(--muted); }

.token-row { display: flex; gap: 8px; margin-bottom: 8px; }
.token-row.hidden { display: none; }
.token-row input { flex: 1; padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; font-family: monospace; }
.token-row button, .pw-form button, #token-regen, .pw-reset {
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--card); cursor: pointer; font-size: 12px; color: var(--ink);
}
.pw-form { display: flex; flex-direction: column; gap: 8px; max-width: 320px; }
.pw-form input { padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.temp-pass {
  margin-top: 14px; padding: 12px; border-radius: 8px;
  background: var(--accent-soft); border: 1px solid var(--accent); font-size: 13px;
}
.temp-pass code { background: var(--card); padding: 2px 8px; border-radius: 4px; font-size: 13px; }
.admin-table { width: 100%; margin-bottom: 6px; }

.tab {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 20px;
  padding: 8px 18px;
  font-size: 14px;
  cursor: pointer;
}
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

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

.panel { display: none; }
.panel.active { display: block; }

.hint { color: var(--muted); font-size: 14px; margin-bottom: 16px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.card-remove {
  display: none;
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.card.selected .card-remove { display: block; }
.card-remove:hover { background: #c62828; }
.card img { width: 100%; height: 140px; object-fit: cover; background: #eee; }
.card .no-img { width: 100%; height: 140px; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; font-size: 40px; }
.card-body { padding: 12px 14px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.card-title { font-size: 15px; font-weight: 600; cursor: pointer; }
.card-title:hover { color: var(--accent); }
.card-meta { font-size: 12px; color: var(--muted); }
.card-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 8px; }
.card-actions button, .card-actions a {
  font-size: 12px; padding: 5px 10px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--card);
  cursor: pointer; text-decoration: none; color: var(--ink);
}
.card-actions .danger:hover { background: #fdecea; border-color: #e57373; color: #c62828; }

.card.selectable { cursor: pointer; }
.card.selected { outline: 3px solid var(--accent); }
.card .check { position: absolute; }

.import-row { display: flex; gap: 8px; margin-bottom: 12px; max-width: 560px; }
.import-row input {
  flex: 1; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px; background: var(--card); color: var(--ink);
}
.import-row button {
  padding: 9px 16px; border: none; border-radius: 8px;
  background: var(--accent); color: #fff; font-size: 13px; cursor: pointer;
}
.import-card {
  max-width: 560px; margin-bottom: 14px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); font-size: 14px;
}
.import-card.import-ok { border-color: var(--accent); background: var(--accent-soft); }
.import-card details { margin-top: 8px; }
.import-card summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.captured {
  white-space: pre-wrap; font-size: 12px; background: var(--bg);
  border-radius: 6px; padding: 8px; max-height: 200px; overflow-y: auto;
}
#import-status.hidden { display: none; }
.spinner {
  display: inline-block; width: 13px; height: 13px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
  vertical-align: -2px; margin-right: 4px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 16px;
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
}
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.cat-select {
  font-size: 12px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}

.plan-layout { display: flex; gap: 20px; align-items: flex-start; }
.plan-layout .cards { flex: 1; }

#plan-sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  position: sticky;
  top: 84px;
}
#plan-sidebar h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  color: var(--accent);
}
#plan-count { color: var(--muted); font-weight: 400; }
.drag-hint { font-size: 12px; color: var(--muted); margin-bottom: 10px; }

.day-bucket {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  margin-bottom: 8px;
  transition: background 0.1s, border-color 0.1s;
}
.day-bucket.drag-over {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.day-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 2px;
}
.day-bucket ul { list-style: none; min-height: 8px; }

#plan-days { list-style: none; }
#plan-days li {
  cursor: grab;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13px;
}
#plan-days li:last-child { border-bottom: none; }
#plan-days img, #plan-days .thumb {
  width: 34px; height: 34px; border-radius: 6px;
  object-fit: cover; flex-shrink: 0;
  background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center;
}
#plan-days .sel-title { flex: 1; }
#plan-days .remove {
  border: none; background: none; color: var(--muted);
  cursor: pointer; font-size: 13px; padding: 2px 4px;
}
#plan-days .remove:hover { color: #c62828; }
#plan-days .sidebar-empty { color: var(--muted); border: none; }
.sidebar-btn {
  width: 100%; margin-top: 12px; padding: 8px;
  border: none; border-radius: 8px;
  background: var(--accent); color: #fff;
  font-size: 13px; cursor: pointer;
}
.sidebar-btn.hidden { display: none; }

@media (max-width: 720px) {
  .plan-layout { flex-direction: column-reverse; }
  #plan-sidebar { width: 100%; position: static; }
}

.week-bar {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 12px; font-size: 16px; font-weight: 600;
}
.week-bar button {
  border: 1px solid var(--border); background: var(--card);
  border-radius: 6px; padding: 4px 12px; cursor: pointer; font-size: 16px;
}

.toolbar { margin-bottom: 16px; }
.toolbar button {
  border: 1px solid var(--border); background: var(--card);
  border-radius: 6px; padding: 6px 14px; cursor: pointer;
}

.aisle {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 16px;
  overflow: hidden;
}
.aisle h3 {
  background: var(--accent-soft);
  padding: 10px 16px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.aisle ul { list-style: none; padding: 8px 16px; }
.aisle li { padding: 6px 0; display: flex; align-items: baseline; gap: 10px; border-bottom: 1px dashed var(--border); }
.aisle li:last-child { border-bottom: none; }
.aisle li label { cursor: pointer; flex: 1; }
.aisle li input:checked + label { text-decoration: line-through; color: var(--muted); }
.item-recipes { font-size: 11px; color: var(--muted); }

.empty { color: var(--muted); padding: 40px; text-align: center; font-size: 15px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 10; }
.modal.hidden { display: none; }
.modal-body {
  background: var(--card); border-radius: 12px; max-width: 640px;
  width: 90%; max-height: 85vh; overflow-y: auto; padding: 28px; position: relative;
}
.modal-close { position: absolute; top: 12px; right: 12px; border: none; background: none; font-size: 18px; cursor: pointer; }
.modal-body h2 { margin-bottom: 8px; }
.modal-body .meta { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.modal-body h4 { margin: 16px 0 8px; }
.modal-body ul, .modal-body ol { padding-left: 22px; }
.modal-body li { margin-bottom: 6px; font-size: 14px; }

.nut-table {
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 4px;
  min-width: 60%;
}
.nut-table th, .nut-table td {
  border: 1px solid var(--border);
  padding: 6px 12px;
  text-align: left;
}
.nut-table th { background: var(--accent-soft); font-size: 12px; }
.nut-note { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.nut-actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }

.serv-edit input {
  width: 90px; padding: 3px 6px; border: 1px solid var(--border);
  border-radius: 5px; font-size: 12px; background: var(--card); color: var(--ink);
}
.serv-edit span { color: var(--muted); font-size: 12px; }

.nut-btn {
  font-size: 12px; padding: 4px 10px; border-radius: 6px;
  border: 1px solid var(--accent); background: var(--accent-soft);
  color: var(--accent); cursor: pointer;
}
.nut-ok { font-size: 12px; color: var(--muted); }

.cf-head { margin-bottom: 4px; }
.cf-progress { color: var(--muted); font-size: 13px; float: right; }
.cf-raw { font-size: 16px; font-weight: 600; margin: 10px 0 2px; }
.cf-parsed { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.cf-parsed code { background: var(--bg); padding: 1px 5px; border-radius: 4px; }
.cf-parsed input, .cf-parsed select {
  padding: 3px 6px; border: 1px solid var(--border); border-radius: 5px;
  font-size: 12px; background: var(--card); color: var(--ink);
}
.cf-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); margin: 12px 0 6px; }
.cand {
  display: flex; gap: 10px; align-items: flex-start;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 8px; cursor: pointer;
}
.cand.sel { border: 2px solid var(--accent); padding: 9px 11px; }
.cand .cand-name { font-size: 14px; }
.cand .cand-meta { font-size: 12px; color: var(--muted); }
.cf-search-row { display: flex; gap: 8px; margin: 10px 0; }
.cf-search-row input { flex: 1; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.cf-search-row button, .cf-actions button {
  padding: 7px 14px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--card); cursor: pointer; font-size: 13px;
}
.cf-measure select, .cf-measure input { width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; margin-bottom: 8px; background: var(--card); color: var(--ink); }
.cf-computed {
  display: flex; gap: 8px; align-items: center;
  background: var(--accent-soft); border-radius: 8px;
  padding: 10px 12px; margin: 12px 0; font-size: 14px;
}
.cf-actions { display: flex; gap: 10px; margin-top: 8px; }
.cf-actions .primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.cf-note { font-size: 13px; color: var(--muted); margin: 8px 0; }
.cf-error { color: #c62828; font-size: 14px; margin: 12px 0; }

.card-cook {
  display: none;
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  filter: grayscale(1);
  opacity: 0.7;
}
.card.selected .card-cook { display: block; }
.card-cook.cooked { filter: none; opacity: 1; background: var(--accent-soft); outline: 2px solid var(--accent); }
#plan-days .cook {
  border: none; background: none; cursor: pointer;
  font-size: 15px; padding: 2px; filter: grayscale(1); opacity: 0.6;
}
#plan-days .cook.cooked { filter: none; opacity: 1; }
#plan-days li.was-cooked .sel-title { text-decoration: line-through; color: var(--muted); }

@media print {
  header, .week-bar, .toolbar, .hint { display: none; }
  body { background: #fff; }
  .aisle { break-inside: avoid; border: none; }
}
