:root {
  --bg: #040b17;
  --bg-accent: #0d1f32;
  --card: #ffffff;
  --muted-card: #f7f8fb;
  --stroke: rgba(13, 31, 50, 0.08);
  --text: #101524;
  --muted: #5d6473;
  --accent: #ff7b5f;
  --accent-strong: #f4511e;
  --success: #1bb597;
  --stop: #cf2641;
  --border-radius: 1rem;
  --shadow: 0 12px 34px rgba(15, 23, 42, 0.16);
  font-family: "Space Grotesk", "Figtree", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #162e4b 0%, #040b17 60%);
  color: var(--text);
}

body {
  padding: 2.5rem clamp(1rem, 5vw, 3rem) 4rem;
}

main {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.tab-shell {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.tab-bar {
  display: inline-flex;
  background: rgba(15, 23, 42, 0.2);
  border-radius: 999px;
  padding: 0.35rem;
  align-self: flex-start;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.tab-button {
  border: none;
  background: transparent;
  color: rgba(244, 246, 252, 0.6);
  padding: 0.5rem 1.2rem;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.tab-button.is-active {
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 1.75rem;
}

.tab-panel.is-active {
  display: flex;
}

p,
label,
span,
input,
select,
textarea,
button {
  font-family: inherit;
}

.page-header {
  max-width: 1280px;
  margin: 0 auto 2rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1.5rem;
  color: #f4f6fc;
}

.header-copy h1 {
  margin: 0;
  font-size: clamp(1.9rem, 3vw, 2.6rem);
}

.lede {
  max-width: 32rem;
  color: rgba(244, 246, 252, 0.8);
}

.eyebrow {
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.82rem;
  color: rgba(244, 246, 252, 0.7);
  margin: 0 0 0.35rem;
}

.subhead {
  margin: 0;
  color: var(--muted);
}

.shift-form {
  background: rgba(13, 31, 50, 0.65);
  padding: 1rem 1.25rem;
  border-radius: var(--border-radius);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.shift-form .shift-field {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  color: rgba(244, 246, 252, 0.85);
  gap: 0.4rem;
}

.shift-form input,
.shift-form select {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 0.65rem;
  padding: 0.45rem 0.75rem;
  color: #fefefe;
}

.shift-field.is-hidden {
  display: none;
}

.mixers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.75rem;
}

.ovens {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.75rem;
}

.mesa-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.mesa-batch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.mesa-lane {
  background: var(--muted-card);
  border-radius: var(--border-radius);
  border: 1px solid var(--stroke);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.lane-label {
  margin: 0;
  font-weight: 600;
  color: var(--text);
}

.mixer-card {
  background: var(--card);
  border-radius: calc(var(--border-radius) + 0.25rem);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

.mixer-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255, 123, 95, 0.15), rgba(27, 181, 151, 0.12));
  opacity: 0.5;
}

.oven-card::before {
  background: linear-gradient(135deg, rgba(255, 123, 95, 0.18), rgba(255, 205, 112, 0.18));
}

.mixer-form {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  z-index: 1;
}

.mixer-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: flex-start;
}

.mixer-head h2 {
  margin: 0;
}

.status-pill {
  background: var(--muted-card);
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.status-pill[data-state="running"] {
  background: rgba(27, 181, 151, 0.15);
  color: var(--success);
}

.status-pill[data-state="complete"] {
  background: rgba(255, 123, 95, 0.16);
  color: var(--accent);
}

.batch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  background: var(--muted-card);
  padding: 1rem;
  border-radius: var(--border-radius);
  border: 1px solid var(--stroke);
}

.oven-grid {
  background: rgba(255, 255, 255, 0.85);
}

.env-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  background: rgba(13, 31, 50, 0.05);
  border: 1px dashed rgba(16, 21, 36, 0.2);
  border-radius: var(--border-radius);
  padding: 1rem;
}

.batch-grid label,
.notes-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

input,
select,
textarea {
  border-radius: 0.6rem;
  border: 1px solid var(--stroke);
  padding: 0.65rem 0.85rem;
  font-size: 1rem;
  background: #ffffff;
  color: var(--text);
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 123, 95, 0.2);
}

.radio-field {
  border: none;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin: 0;
  padding: 0;
}

.radio-field legend {
  font-size: 0.85rem;
  color: var(--muted);
  margin-right: 0.35rem;
}

.radio-option {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 500;
}

.stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.ferment-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.stage-card {
  background: #fff;
  border-radius: 1rem;
  padding: 1rem;
  border: 1px solid var(--stroke);
  position: relative;
  box-shadow: 0 12px 20px rgba(15, 23, 42, 0.08);
  animation: floatUp 0.6s ease both;
}

.stage-card--dead {
  background: #101524;
  color: #f4f6fc;
  border-color: rgba(255, 255, 255, 0.08);
}

.fermenter-card::before {
  background: linear-gradient(135deg, rgba(255, 123, 95, 0.2), rgba(108, 99, 255, 0.2));
}

.stage-card--dead .stage-times div {
  background: rgba(255, 255, 255, 0.08);
}

.stage-card__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stage-card__head h3 {
  margin: 0;
}

.stage-status {
  font-size: 0.82rem;
  color: var(--muted);
  background: var(--muted-card);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
}

.stage-status[data-state="running"] {
  background: rgba(27, 181, 151, 0.13);
  color: var(--success);
}

.stage-status[data-state="complete"] {
  background: rgba(255, 123, 95, 0.16);
  color: var(--accent);
}

.stage-times {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0.75rem 0;
  gap: 0.5rem;
}

.stage-times div {
  background: var(--muted-card);
  border-radius: 0.75rem;
  padding: 0.65rem;
}

.stage-times dt {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.stage-times dd {
  margin: 0.15rem 0 0;
  font-weight: 600;
  font-size: 0.95rem;
}

.stage-meta {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 0.85rem;
}

.stage-meta label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.stage-meta input,
.stage-meta textarea {
  font-size: 0.9rem;
}

.stage-meta textarea {
  min-height: 2.4rem;
}

.stage-meta.stage-meta--split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.65rem;
}

.stage-meta--split textarea {
  min-height: 3rem;
}

.stage-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.35rem;
}

.chip {
  flex: 1;
  border: none;
  border-radius: 999px;
  padding: 0.55rem 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.chip:active {
  transform: scale(0.98);
}

.chip--start {
  background: rgba(27, 181, 151, 0.18);
  color: var(--success);
}

.chip--stop {
  background: rgba(207, 38, 65, 0.15);
  color: var(--stop);
}

.chip--reset {
  background: rgba(16, 21, 36, 0.08);
  color: var(--text);
}

.chip--save {
  background: rgba(255, 123, 95, 0.18);
  color: var(--accent);
}

.line-footer {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px dashed rgba(16, 21, 36, 0.15);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.line-footer__total span {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.line-footer__total strong {
  font-size: 1.25rem;
}

.stage-footer {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px dashed rgba(16, 21, 36, 0.12);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.stage-footer .primary-btn {
  width: 100%;
}

.stage-footer__total span {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.stage-footer__total strong {
  font-size: 1.2rem;
}

.machine-metrics {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.85rem;
}

.machine-metrics li {
  background: var(--muted-card);
  border-radius: 0.9rem;
  padding: 0.75rem;
  border: 1px dashed rgba(16, 21, 36, 0.15);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.machine-metrics span {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.machine-metrics strong {
  font-size: 1.05rem;
}

.oven-summary {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

textarea {
  resize: vertical;
}

.mixer-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.total-display span {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
}

.total-display strong {
  font-size: 1.35rem;
}

.button-row {
  display: flex;
  gap: 0.75rem;
}

.button-row--tight {
  flex-direction: column;
  gap: 0.5rem;
}

.button-row--tight button {
  width: 100%;
}

.button-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  border-radius: 0.9rem;
  border: none;
  padding: 0.65rem 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 15px 25px rgba(255, 123, 95, 0.35);
}

.primary-btn--sub {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 15px 25px rgba(255, 123, 95, 0.35);
}

.secondary-btn--sub {
  width: 100%;
  background: #101524;
  color: #fff;
}

.stage-footer .secondary-btn {
  width: 100%;
}

.secondary-btn {
  background: #101524;
  color: #fff;
}

.ghost-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fefefe;
}

.primary-btn:active,
.secondary-btn:active,
.ghost-btn:active {
  transform: translateY(1px);
}

.feedback {
  margin: 0;
  min-height: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.feedback[data-variant="error"] {
  color: var(--stop);
}

.feedback[data-variant="success"] {
  color: var(--success);
}

.results-panel {
  background: var(--card);
  border-radius: calc(var(--border-radius) + 0.25rem);
  padding: 1.75rem;
  box-shadow: var(--shadow);
  position: relative;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.results-list {
  margin-top: 1.5rem;
  display: grid;
  gap: 1rem;
}

.result-card {
  border: 1px solid var(--stroke);
  border-radius: 1rem;
  padding: 1rem 1.25rem;
  background: var(--muted-card);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.result-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.result-card header h3 {
  margin: 0;
}

.result-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.result-meta li {
  background: #fff;
  border-radius: 0.75rem;
  padding: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.result-meta span {
  font-size: 0.75rem;
  color: var(--muted);
}

.result-stage {
  background: #fff;
  border-radius: 0.75rem;
  padding: 0.65rem 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.result-stage small {
  color: var(--muted);
}

.result-stage-meta {
  width: 100%;
  font-size: 0.78rem;
  color: var(--muted);
}

.result-totals {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.result-totals div {
  background: #fff;
  border-radius: 0.75rem;
  padding: 0.6rem 0.9rem;
  min-width: 140px;
}

.results-empty {
  margin: 0;
  color: var(--muted);
}

@keyframes floatUp {
  from {
    transform: translateY(12px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 900px) {
  body {
    padding-bottom: 3rem;
  }
  .mixer-footer {
    flex-direction: column;
    align-items: flex-start;
  }
  .button-row {
    width: 100%;
  }
  .button-row button {
    flex: 1;
  }
}
