:root {
  --bg: #181411;
  --panel: rgba(255, 255, 255, 0.08);
  --panel-strong: rgba(255, 255, 255, 0.12);
  --line: rgba(255, 255, 255, 0.16);
  --text: #fff8ef;
  --muted: rgba(255, 248, 239, 0.68);
  --tomato: #e34d36;
  --olive: #9bb86f;
  --steel: #8ca7b7;
  --fire: #f0a34a;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.38);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: radial-gradient(circle at top left, rgba(240, 163, 74, 0.18), transparent 34rem), var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
.shell {
  width: 100%;
  max-width: none;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
}
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
}
.login-card, .panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.login-card {
  width: min(460px, 100%);
  display: grid;
  gap: 14px;
  padding: 22px;
}
.brand-lockup {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
  font-weight: 900;
}
.brand-logo { width: 132px; height: auto; }
.brand-context { color: var(--muted); }
.eyebrow {
  margin: 0 0 4px;
  color: var(--fire);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 8px;
  font-size: 44px;
  line-height: 0.98;
}
h2 {
  margin-bottom: 0;
  font-size: 24px;
}
label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}
input, select {
  min-height: 46px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.24);
}
select option {
  color: #1f130e;
  background: #fff8ef;
}
select option:checked {
  color: #1f130e;
  background: #f0a34a;
}
.primary-button, .ghost-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 10px 14px;
  font-weight: 950;
  cursor: pointer;
}
.primary-button {
  color: #1f130e;
  background: var(--fire);
}
.ghost-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--line);
}
.nav-link { text-decoration: none; }
.app-view {
  display: grid;
  gap: 16px;
  min-height: 0;
}
.topbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}
.station-pill, .top-actions, .form-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--olive);
  box-shadow: 0 0 0 5px rgba(155, 184, 111, 0.18);
}
.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.48fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  min-height: 0;
}
.panel {
  padding: 16px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 14px;
}
.status-pill {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  color: #1f130e;
  background: var(--steel);
  font-size: 12px;
  font-weight: 950;
}
.status-pill.ok { background: var(--olive); }
.status-pill.warn { background: var(--fire); }
.current-recipe {
  display: grid;
  gap: 12px;
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.metric, .ingredient-card {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}
.metric small {
  display: block;
  color: var(--muted);
  font-weight: 850;
}
.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}
.recipe-form {
  display: grid;
  gap: 14px;
  min-height: 0;
}
.recipe-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.36fr);
  gap: 14px;
  align-items: stretch;
}
.form-main, .ingredient-rows {
  display: grid;
  gap: 10px;
}
.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.mix-preview {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(240, 163, 74, 0.12);
}
.mix-preview strong {
  font-size: 22px;
  line-height: 1.1;
}
.mix-preview span, .muted {
  color: var(--muted);
  font-weight: 800;
}
.ingredient-section {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow: hidden;
}
.ingredient-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(120px, 180px) minmax(90px, 120px);
  gap: 10px;
  align-items: end;
}
.ingredient-list {
  display: grid;
  gap: 8px;
}
.ingredient-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}
.ingredient-card span {
  color: var(--muted);
  font-weight: 850;
}
.empty-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--muted);
  font-weight: 850;
}
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(380px, calc(100vw - 36px));
  padding: 14px 16px;
  border-radius: 8px;
  color: #fff;
  background: rgba(23, 17, 15, 0.96);
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  .topbar, .workspace, .recipe-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 981px) {
  body {
    overflow: hidden;
  }
  .shell {
    height: 100vh;
    overflow: hidden;
  }
  .app-view {
    height: calc(100vh - 32px);
    grid-template-rows: auto minmax(0, 1fr);
  }
  .workspace {
    height: 100%;
    align-items: stretch;
  }
  .current-panel {
    align-self: start;
  }
  .studio-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
  }
  .recipe-form {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .recipe-grid,
  .form-actions {
    flex: 0 0 auto;
  }
  .ingredient-section {
    flex: 1 1 0;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .ingredient-rows {
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
  }
  .form-actions {
    justify-content: flex-end;
    padding-top: 12px;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 680px) {
  .shell { padding: 10px; }
  .split, .metric-grid, .ingredient-row, .ingredient-card {
    grid-template-columns: 1fr;
  }
  h1 { font-size: 36px; }
}
