/* ── Shell layout ─────────────────────────────────────────────────────────── */

.calculator-shell {
  display: grid;
  grid-template-columns: 300px 1fr 260px;
  gap: 0;
  height: calc(100vh - 57px); /* minus nav height */
  overflow: hidden;
}

/* ── Column structure ─────────────────────────────────────────────────────── */

.calculator-shell > section {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.calculator-shell > section:last-child {
  border-right: none;
}

.col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  padding-bottom: 4px;
}

.col-header h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--fg);
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.btn-primary {
  background: var(--accent);
  color: #0d0d0d;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-dim); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.btn-secondary:hover { border-color: var(--accent); }

.btn-ghost {
  background: transparent;
  color: var(--fg-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-family: var(--font-body);
  font-size: 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.btn-ghost:hover { color: var(--fg); border-color: var(--fg-muted); }
.btn-danger { color: #e05a5a; border-color: #e05a5a; }
.btn-danger:hover { background: rgba(224,90,90,0.1); }

.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── Empty state ──────────────────────────────────────────────────────────── */

.empty-state {
  color: var(--fg-muted);
  font-size: 13px;
  line-height: 1.6;
  padding: 20px 0;
}

/* ── Dish list ────────────────────────────────────────────────────────────── */

.dish-list { display: flex; flex-direction: column; gap: 4px; }

.dish-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dish-item:hover { border-color: var(--accent-dim); }
.dish-item.active {
  border-color: var(--accent);
  background: var(--surface-2);
}

.dish-item-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 6px;
}

.dish-item-meta {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--fg-muted);
}

.dish-item-meta strong {
  color: var(--fg);
  font-weight: 600;
}

.margin-good { color: #4caf50; }
.margin-ok   { color: var(--accent); }
.margin-bad  { color: #e05a5a; }

/* ── Detail panel ────────────────────────────────────────────────────────── */

.detail-actions { display: flex; gap: 6px; }

.dish-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.summary-label { color: var(--fg-muted); }

.summary-value { font-weight: 600; color: var(--fg); }
.summary-value.highlight { color: var(--accent); font-size: 16px; }

.ingredients-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
  padding: 8px 0 4px;
}

/* ── Ingredient list ──────────────────────────────────────────────────────── */

.ingredient-list { display: flex; flex-direction: column; gap: 6px; }

.ingredient-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 13px;
}

.ingredient-row-name {
  flex: 1;
  color: var(--fg);
  font-weight: 500;
}

.ingredient-row-cost {
  color: var(--fg-muted);
  font-size: 12px;
  text-align: right;
  min-width: 80px;
}

.ingredient-row-qty {
  color: var(--accent);
  font-size: 12px;
  text-align: right;
  min-width: 60px;
}

.btn-remove {
  background: transparent;
  border: none;
  color: #e05a5a;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 4px;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.btn-remove:hover { opacity: 1; }

/* ── Add ingredient box ───────────────────────────────────────────────────── */

.add-ingredient-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.add-ing-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.add-ing-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Quick-add details ─────────────────────────────────────────────────────── */

.quick-add {
  font-size: 12px;
  color: var(--fg-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.quick-add summary {
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.quick-add summary::before {
  content: '+';
  font-weight: 700;
  color: var(--accent);
}
.quick-add[open] summary::before { content: '−'; }

.qa-form {
  padding: 0 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Ingredient library ───────────────────────────────────────────────────── */

.library-list { display: flex; flex-direction: column; gap: 6px; }

.library-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.library-item-name { color: var(--fg); font-weight: 500; }

.library-item-cost { color: var(--accent); font-size: 12px; }

.library-item-unit { color: var(--fg-muted); font-size: 11px; }

/* ── Form elements ────────────────────────────────────────────────────────── */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
  letter-spacing: 0.04em;
}

.input-field, .select-field {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 12px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 13px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.input-field:focus, .select-field:focus {
  border-color: var(--accent);
}

.qty-input { width: 72px; }
.yield-input { width: 80px; }

.field-error {
  color: #e05a5a;
  font-size: 12px;
  padding: 6px 0;
}

/* ── Modals ────────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  width: 420px;
  max-width: calc(100vw - 40px);
}

.modal h3 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 20px;
}

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

/* ── Responsive ────────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .calculator-shell {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .calculator-shell > section {
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow: visible;
  }

  .add-ing-row { flex-wrap: wrap; }
}