:root {
  --bg: #f5efe5;
  --bg-secondary: #dcebe3;
  --surface: rgba(255, 255, 255, 0.92);
  --ink: #201d17;
  --muted: #686158;
  --line: #d8cfbf;
  --accent: #1b6c5e;
  --accent-dark: #145348;
  --accent-soft: #e1f0e9;
  --warm: #96531f;
  --danger: #a73b31;
  --shadow: 0 18px 45px rgba(58, 47, 31, 0.09);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(circle at 90% 5%, rgba(255, 255, 255, 0.9), transparent 28rem),
    linear-gradient(135deg, var(--bg), var(--bg-secondary));
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.shell {
  width: min(1240px, calc(100% - 28px));
  margin: 0 auto;
  padding: 54px 0 40px;
}

.hero { margin-bottom: 20px; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  color: inherit;
  text-decoration: none;
}
.brand-mark {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 18px;
  color: #fff;
  background: var(--accent);
  box-shadow: var(--shadow);
  font-weight: 800;
  letter-spacing: .04em;
}
.brand h1 { margin: 0 0 3px; font-size: clamp(1.35rem, 3vw, 1.8rem); }
.brand small { color: var(--muted); font-weight: 650; }

.card {
  border: 1px solid rgba(216, 207, 191, .9);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.auth-card {
  display: grid;
  grid-template-columns: 1fr minmax(280px, 420px);
  gap: 42px;
  padding: 28px;
}
h2 { margin: 0; font-size: 1.3rem; }
.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: .73rem;
  font-weight: 800;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.muted { color: var(--muted); }
.hidden { display: none !important; }
.spacer { flex: 1; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 14px;
}
.nav-tab {
  padding: 9px 13px;
  border-radius: 10px;
  border-color: transparent;
  color: var(--accent);
  background: transparent;
  font-weight: 700;
}
.nav-tab:hover, .nav-tab.active { color: #fff; background: var(--accent); }
.badge {
  display: inline-flex;
  min-width: 20px;
  min-height: 20px;
  margin-left: 4px;
  padding: 1px 6px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: var(--accent-dark);
  background: #fff;
  font-size: .72rem;
}
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}
.workspace.with-editor { grid-template-columns: minmax(0, 1.55fr) minmax(330px, .85fr); }
.list-panel, .editor-panel { padding: 20px; }
.editor-panel { align-self: start; position: sticky; top: 14px; }
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

button {
  min-height: 42px;
  padding: 9px 15px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  color: #fff;
  background: var(--accent);
  font-weight: 700;
}
button:hover { background: var(--accent-dark); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.secondary { color: var(--accent); background: #fff; }
button.ghost { color: var(--accent); background: transparent; border-color: transparent; }
button.icon-button {
  width: 38px;
  min-height: 38px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
  font-size: 1.5rem;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(190px, .35fr) auto;
  gap: 10px;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: #fff;
  padding: 11px 12px;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(27, 108, 94, .13);
}
textarea { resize: vertical; }
.form-grid { display: grid; gap: 15px; }
.form-grid label { display: grid; gap: 7px; font-weight: 650; }
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checkbox-label {
  display: flex !important;
  align-items: center;
  align-self: end;
  min-height: 44px;
  flex-direction: row;
}
.checkbox-label input { width: auto; }

.list-meta { min-height: 22px; margin: 14px 2px 8px; font-size: .9rem; }
.ingredient-list { display: grid; gap: 9px; }
.ingredient-card {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(220px, 1.7fr);
  gap: 18px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, .78);
}
.ingredient-card h3 { margin: 0 0 8px; font-size: 1rem; }
.source-text { margin: 0 0 10px; color: var(--muted); line-height: 1.45; }
.card-actions {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.card-actions button { flex: 0 0 auto; }
.ingredient-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  padding: 4px 8px;
  border: 1px solid #c8ded4;
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: .78rem;
}
.chip.category { color: #754018; background: #f7eadd; border-color: #ead3bd; }
.chip.recommended { color: #155f44; background: #dff3e9; border-color: #b7dfcd; }
.recommendation-toggle { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.recommendation-toggle span { display: grid; gap: 4px; }
.recommendation-toggle small { color: var(--muted); font-weight: 400; }
.recommendation-toggle input { width: 24px; height: 24px; flex: 0 0 24px; }
.alias-group + .alias-group { margin-top: 8px; }
.alias-title {
  display: inline-block;
  width: 68px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
}
.alias-values { font-size: .9rem; line-height: 1.5; }
.empty-state {
  padding: 36px 18px;
  border: 1px dashed var(--line);
  border-radius: 13px;
  color: var(--muted);
  text-align: center;
}
.pagination { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 15px; }
.status {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100% - 36px));
  padding: 11px 14px;
  border-radius: 10px;
  color: #fff;
  background: #35312c;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: .2s ease;
}
.status.visible { opacity: 1; transform: translateY(0); }
.status.error { background: var(--danger); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.diagnostics-workspace { display: grid; gap: 20px; }
.diagnostics-workspace.hidden { display: none; }
.diagnostics-workspace > .card,
.diagnostics-columns > .card { padding: 22px; }
.diagnostic-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 20px;
}
.diagnostic-test {
  display: grid;
  align-content: start;
  gap: 9px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, .68);
}
.diagnostic-test button { width: 100%; }
.diagnostic-test p {
  margin: 0;
  color: var(--muted);
  font-size: .86rem;
  line-height: 1.45;
}
.component-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}
.component-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px;
}
.component-card h3, .component-card p { margin: 0; }
.component-card h3 { font-size: .95rem; }
.health-dot {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  border-radius: 50%;
  background: #9a948d;
}
.health-dot.operational { background: #20865f; }
.health-dot.down { background: var(--danger); }
.health-state {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 999px;
  background: #ece8e3;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 750;
  text-transform: uppercase;
}
.health-state.operational { color: #155f44; background: #dff3e9; }
.health-state.degraded { color: #805510; background: #fff0cb; }
.health-state.down { color: #8d2929; background: #f9dddd; }
.diagnostics-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr);
  gap: 16px;
  align-items: start;
}
.timeline, .diagnostics-history { display: grid; gap: 8px; }
.timeline-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 11px;
  align-items: start;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.timeline-item p { margin: 3px 0 0; color: var(--muted); font-size: .85rem; }
.timeline-item details { margin-top: 8px; }
.timeline-item summary { cursor: pointer; color: var(--muted); font-size: .82rem; }
.timeline-item pre { max-width: min(680px, 70vw); overflow: auto; white-space: pre-wrap; font-size: .75rem; }
.timeline-item time { color: var(--muted); font-size: .78rem; }
.timeline-marker {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 50%;
  background: #9a948d;
}
.timeline-item.passed .timeline-marker { background: #20865f; }
.timeline-item.failed .timeline-marker { background: var(--danger); }
.history-run {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
  text-align: left;
}
.history-run span:first-child { display: grid; gap: 3px; }
.history-run small { color: var(--muted); font-weight: 400; }

.recipe-editor { min-width: 0; max-height: calc(100vh - 32px); overflow: auto; }
.three-columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.editor-details { border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.editor-details summary { cursor: pointer; font-weight: 700; }
.editor-details .form-grid { margin-top: 14px; }
.collection-heading, .item-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.collection-heading h3 { margin: 0; }
.repeatable-list { display: grid; gap: 12px; }
.repeatable-item { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #faf9f7; }
.danger { color: var(--danger); }
.loading { opacity: .55; pointer-events: none; }

@media (max-width: 900px) {
  .workspace.with-editor { grid-template-columns: 1fr; }
  .editor-panel { position: static; grid-row: 1; }
  .diagnostics-columns { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .shell { padding-top: 26px; }
  .auth-card { grid-template-columns: 1fr; gap: 18px; }
  .search-row { grid-template-columns: 1fr; }
  .ingredient-card { grid-template-columns: 1fr; gap: 10px; }
  .two-columns { grid-template-columns: 1fr; }
  .three-columns { grid-template-columns: 1fr; }
  #userEmail { display: none; }
  .list-panel, .editor-panel { padding: 15px; }
  .diagnostic-actions { grid-template-columns: 1fr; }
  .diagnostics-workspace > .card,
  .diagnostics-columns > .card { padding: 16px; }
}
