:root {
  --bg: #14171c;
  --panel: #1d2129;
  --panel-2: #262b35;
  --text: #eef0f3;
  --muted: #9aa3b2;
  --accent: #d99a3b;
  --accent-2: #7fb37f;
  --danger: #d9603b;
  --border: #333844;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
}

.topbar h1 {
  margin: 0 0 0.5rem 0;
  font-size: 1.3rem;
}

.tabs {
  display: flex;
  gap: 0.5rem;
}

.tab-btn {
  flex: 1;
  padding: 0.6rem;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
}

.tab-btn.active {
  background: var(--accent);
  color: #201400;
  border-color: var(--accent);
  font-weight: 600;
}

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

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

.panel-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}

input[type="search"], input[type="text"], input[type="number"], select, textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
}

label {
  display: block;
  margin: 0.75rem 0 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

button {
  cursor: pointer;
  font-size: 0.95rem;
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
}

button.primary-wide, #save-btn {
  width: 100%;
  background: var(--accent);
  color: #201400;
  border-color: var(--accent);
  font-weight: 600;
  margin-top: 0.5rem;
}

button.secondary {
  background: transparent;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.muted { color: var(--muted); font-size: 0.85rem; }
.hidden { display: none !important; }

.card-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.bottle-card, .recipe-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.bottle-card .info { flex: 1; min-width: 0; }
.bottle-card .name { font-weight: 600; }
.bottle-card .meta { color: var(--muted); font-size: 0.85rem; }
.bottle-card .qty-controls { display: flex; align-items: center; gap: 0.4rem; }
.bottle-card .qty-controls button { padding: 0.3rem 0.6rem; }
.bottle-card .actions { display: flex; flex-direction: column; gap: 0.3rem; }
.bottle-card .actions button { padding: 0.3rem 0.55rem; font-size: 0.8rem; }

.type-group-header {
  margin: 1rem 0 0.4rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.scan-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  margin-bottom: 1rem;
}

.scan-row {
  display: flex;
  gap: 0.5rem;
}

.scan-row input { flex: 1; }

#scan-camera {
  margin-top: 0.6rem;
  border-radius: 8px;
  overflow: hidden;
}

.recipe-card {
  cursor: pointer;
  align-items: flex-start;
}

.recipe-card img {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.recipe-card .info { flex: 1; }
.recipe-card .name { font-weight: 600; }

.match-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 0.25rem;
}

.match-100 { background: var(--accent-2); color: #052905; }
.match-partial { background: #3d4250; color: var(--muted); }

.missing-list {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}

.modal.hidden { display: none; }

.modal-content {
  background: var(--panel);
  border-radius: 14px 14px 0 0;
  padding: 1.25rem;
  max-width: 720px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  background: var(--panel-2);
  border-radius: 999px;
  width: 2rem;
  height: 2rem;
  padding: 0;
  line-height: 1;
}

.modal-content h2 { margin-top: 0; }
.modal-content img { width: 100%; max-width: 300px; border-radius: 10px; display: block; margin: 0 auto 1rem; }

.ingredient-row {
  display: flex;
  justify-content: space-between;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
}

.ingredient-row.owned { color: var(--accent-2); }
.ingredient-row.missing { color: var(--danger); }

@media (min-width: 600px) {
  .modal { align-items: center; }
  .modal-content { border-radius: 14px; }
}
