:root {
  --ink: #261a10;
  --muted: #766958;
  --line: #e2d3b8;
  --paper: #fbf4e4;
  --panel: #fffaf0;
  --honey: #d9961f;
  --gold: #f2c45b;
  --green: #4f6f3a;
  --rose: #a94f3f;
  --blue: #6f7f56;
  --shadow: 0 18px 50px rgba(38, 26, 16, .10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(135deg, rgba(217, 150, 31, .22), transparent 28%),
    linear-gradient(315deg, rgba(79, 111, 58, .16), transparent 32%),
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 44px);
  border-bottom: 1px solid rgba(226, 211, 184, .88);
  background: rgba(251, 244, 228, .9);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.05rem;
}

.brand svg {
  width: 34px;
  height: 34px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-chip {
  color: var(--muted);
  font-size: .9rem;
}

.page {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(280px, .92fr);
  gap: 28px;
  align-items: center;
  min-height: calc(100vh - 76px);
  padding-bottom: 42px;
}

.hero h1 {
  margin: 0;
  max-width: 780px;
  font-size: clamp(3rem, 7vw, 6.8rem);
  line-height: .9;
  letter-spacing: 0;
}

.hero p {
  max-width: 660px;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.7;
}

.hero-art {
  min-height: 440px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 36% 26%, rgba(255,255,255,.85) 0 5%, transparent 6%),
    linear-gradient(160deg, rgba(217, 150, 31, .94), rgba(79, 111, 58, .9)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='800' height='900' viewBox='0 0 800 900'%3E%3Cg fill='none' stroke='%23f4ca64' stroke-width='10' opacity='.42'%3E%3Cpath d='M220 120h360l-34 490a142 142 0 0 1-142 132h-8a142 142 0 0 1-142-132z'/%3E%3Cpath d='M260 190h280M280 310c58-46 106-46 164 0s106 46 164 0M294 410h214M310 520h180'/%3E%3C/g%3E%3Cg fill='%23fff6d7' opacity='.72'%3E%3Ccircle cx='220' cy='168' r='18'/%3E%3Ccircle cx='598' cy='246' r='12'/%3E%3Ccircle cx='510' cy='656' r='20'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
  background-position: center;
  box-shadow: var(--shadow);
}

.toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.toolbar h1,
.section-title h2 {
  margin: 0;
}

.toolbar p,
.section-title p {
  margin: 6px 0 0;
  color: var(--muted);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.button.primary {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.button.warn {
  border-color: rgba(169, 79, 63, .35);
  color: var(--rose);
}

.button:disabled {
  cursor: not-allowed;
  opacity: .48;
}

.button.icon {
  width: 42px;
  padding: 0;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, .94);
  box-shadow: 0 10px 26px rgba(38, 26, 16, .06);
}

.card.pad {
  padding: 18px;
}

.batch-card {
  min-height: 240px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  background:
    linear-gradient(140deg, rgba(255, 252, 244, .96), rgba(255, 246, 228, .9)),
    var(--panel);
}

.batch-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.batch-card h3 {
  margin: 0;
  color: #241a12;
  font-size: clamp(1.35rem, 2vw, 1.7rem);
  line-height: 1.12;
}

.batch-card p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.batch-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: .92rem;
  font-weight: 700;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: auto;
}

.stat {
  min-height: 66px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff8ea;
  overflow-wrap: anywhere;
}
  
.stat strong {
  display: block;
  font-size: 1.2rem;
  line-height: 1.15;
}

.stage-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  max-width: 100%;
  padding: 5px 12px;
  border-radius: 999px;
  color: #fff;
  font-size: .9rem;
  font-weight: 800;
  line-height: 1.15;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
}

.stage-pill.green {
  background: #667a24;
}

.stage-pill.amber {
  background: #d08212;
}

.stage-pill.deep {
  background: #385b2b;
}

.stage-pill.gold {
  background: #7b651d;
}

.batch-stage-rail {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(74px, 1fr));
  overflow: hidden;
  border: 1px solid rgba(126, 100, 64, .18);
  border-radius: 999px;
  background: rgba(245, 236, 215, .72);
  box-shadow: inset 0 1px 3px rgba(38, 26, 16, .06);
}

.stage-chip {
  min-height: 38px;
  display: grid;
  place-items: center;
  padding: 7px 9px;
  color: #6d6254;
  font-size: .82rem;
  font-weight: 800;
  text-align: center;
  border-right: 1px solid rgba(255, 255, 255, .7);
}

.stage-chip:last-child {
  border-right: 0;
}

.stage-chip.complete {
  color: #52652b;
  background: rgba(111, 127, 86, .12);
}

.stage-chip.current {
  color: #fff;
}

.stage-chip.current.green {
  background: #667a24;
}

.stage-chip.current.amber {
  background: #d08212;
}

.stage-chip.current.deep {
  background: #385b2b;
}

.stat span,
.small {
  color: var(--muted);
  font-size: .84rem;
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, .88);
}

.batch-card .row-actions {
  margin-top: auto;
}

.batch-card .row-actions .button {
  width: 100%;
}

.button.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 1.35rem;
  line-height: 1;
}

.pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(79, 111, 58, .12);
  color: var(--green);
  font-size: .82rem;
  font-weight: 800;
}

.pill.gold {
  background: rgba(217, 150, 31, .2);
  color: #6d4711;
}

.pill.blue {
  background: rgba(111, 127, 86, .16);
  color: var(--blue);
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin: 18px 0;
}

.page-tabs {
  margin-top: -4px;
  margin-bottom: 20px;
}

.tab {
  white-space: nowrap;
}

.tab.active {
  border-color: var(--green);
  background: rgba(79, 111, 58, .12);
  color: var(--green);
}

.journey-wrap {
  margin: 20px 0 18px;
}

.journey {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px 0;
  overflow: visible;
  padding: 18px 0 26px;
}

.journey-step {
  display: flex;
  align-items: center;
  position: relative;
  isolation: isolate;
}

.journey-step.inserting {
  z-index: 10;
}

.journey-stage {
  width: 172px;
  min-height: 168px;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  align-items: start;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(255, 253, 247, .98), rgba(255, 247, 232, .9));
  color: var(--ink);
  text-align: left;
  box-shadow: 0 10px 26px rgba(38, 26, 16, .05);
}

.stage-remove {
  position: absolute;
  top: 8px;
  right: 56px;
  z-index: 8;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 999px;
  background: rgba(255, 250, 240, .72);
  color: rgba(85, 67, 48, .52);
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
  opacity: .42;
  transition: opacity .16s ease, color .16s ease, border-color .16s ease, background .16s ease;
}

.journey-step:hover .stage-remove,
.stage-remove:focus-visible {
  opacity: 1;
  border-color: rgba(169, 79, 63, .24);
  background: #fffaf0;
  color: var(--rose);
}

.journey-stage strong {
  overflow: hidden;
  color: #2b1b12;
  font-size: 1.05rem;
  line-height: 1.08;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.journey-stage span,
.journey-stage small {
  color: var(--muted);
}

.journey-stage small {
  min-height: 38px;
  font-size: .9rem;
  line-height: 1.32;
}

.journey-stage.active,
.journey-stage.selected {
  border-color: var(--green);
  background: linear-gradient(145deg, rgba(255, 253, 247, .98), rgba(247, 246, 230, .96));
  color: var(--ink);
  box-shadow: 0 0 0 2px rgba(79, 111, 58, .14), 0 14px 34px rgba(38, 26, 16, .1);
}

.journey-stage.complete {
  border-color: rgba(217, 150, 31, .55);
  background: rgba(242, 196, 91, .22);
}

.journey-stage.readonly {
  cursor: default;
  box-shadow: 0 6px 16px rgba(38, 26, 16, .04);
}

.journey-stage.readonly.selected {
  border-color: var(--line);
  background: rgba(255, 250, 240, .94);
}

.stage-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 999px;
  background: rgba(79, 111, 58, .13);
  color: var(--green) !important;
}

.stage-icon svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.journey-stage.active .stage-icon,
.journey-stage.selected .stage-icon {
  background: rgba(79, 111, 58, .18);
  color: var(--green) !important;
}

.journey-stage.complete .stage-icon {
  background: rgba(217, 150, 31, .2);
  color: #7b651d !important;
}

.journey-state {
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stage-check {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--green);
  color: #fff !important;
  font-size: .78rem;
  font-weight: 900;
}

.stage-badge {
  width: fit-content;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--green);
  color: #fff !important;
  font-size: .75rem;
  font-weight: 900;
}

.journey-insert-slot {
  width: 48px;
  min-height: 168px;
  display: grid;
  place-items: center;
  position: relative;
  z-index: 2;
}

.journey-insert-slot::before {
  content: "";
  position: absolute;
  left: -8px;
  right: -8px;
  top: 50%;
  height: 2px;
  background: rgba(126, 100, 64, .2);
  transform: translateY(-50%);
  z-index: -1;
}

.journey-insert-slot.active {
  width: min(320px, 72vw);
  place-items: center start;
  z-index: 30;
}

.journey-insert-slot.locked {
  z-index: 0;
}

.journey-insert {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(217, 150, 31, .55);
  border-radius: 999px;
  background: rgba(255, 250, 240, .96);
  color: #9a6415;
  font-size: 1.35rem;
  font-weight: 900;
  box-shadow: 0 8px 20px rgba(217, 150, 31, .12);
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

.journey-insert:hover {
  background: #fff;
  box-shadow: 0 10px 24px rgba(38, 26, 16, .14);
  transform: translateY(-1px);
}

.journey-insert.locked {
  width: 18px;
  height: 2px;
  border: 0;
  border-radius: 999px;
  background: rgba(126, 100, 64, .22);
  box-shadow: none;
}

.journey-insert-form {
  width: min(300px, 72vw);
  display: grid;
  gap: 10px;
  position: relative;
  z-index: 40;
  padding: 14px;
  border: 1px solid rgba(79, 111, 58, .28);
  border-radius: 8px;
  background: linear-gradient(180deg, #fffdf7, #fff7e8);
  box-shadow: 0 18px 44px rgba(38, 26, 16, .18);
}

.journey-insert-form label {
  color: var(--green);
  font-size: .82rem;
  font-weight: 900;
}

.journey-insert-form input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

.journey-insert-form .row-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  justify-content: stretch;
  gap: 8px;
}

.journey-insert-form .button {
  min-height: 36px;
  padding: 7px 10px;
}

.stage-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin: -2px 0 14px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, .9);
}

.stage-actions > div:first-child {
  display: grid;
  gap: 3px;
}

.stage-actions span {
  color: var(--muted);
  line-height: 1.45;
}

.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.inline-form input {
  width: min(210px, 42vw);
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: #fff;
  color: var(--ink);
}

.stage-command {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr);
  gap: 14px;
  align-items: stretch;
  margin-bottom: 18px;
}

.command-main {
  min-height: 280px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.command-main h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1;
}

.command-main p {
  margin: 0;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.6;
}

.command-side h3 {
  margin: 0 0 12px;
}

.stage-command .command-side:last-child {
  grid-column: 1 / -1;
}

.stage-dates {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: auto;
}

.stage-dates div {
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: #fff8ea;
}

.stage-dates strong,
.stage-dates span {
  display: block;
}

.stage-dates span {
  color: var(--muted);
  font-size: .86rem;
}

.mini-list {
  display: grid;
  gap: 8px;
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
}

.mini-list li {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel);
}

.mini-list span,
.muted-item {
  color: var(--muted);
  font-size: .88rem;
}

.stage-timeline {
  margin-bottom: 18px;
}

.stage-section-list {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.stage-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff8ea;
  overflow: hidden;
}

.stage-section-head {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 12px;
  background: var(--panel);
  color: var(--ink);
  text-align: left;
}

.stage-section-head.static {
  cursor: default;
}

.stage-section .timeline {
  padding: 14px;
}

.stage-empty {
  padding: 18px;
  color: var(--muted);
}

.support-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.summary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(260px, .85fr) minmax(260px, .85fr);
  gap: 14px;
  align-items: start;
  margin-bottom: 18px;
}

.bottling-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compact-section .stage-section-head {
  min-height: 48px;
}

.compact-list {
  padding: 12px;
}

.form {
  display: grid;
  gap: 14px;
}

.form.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-weight: 800;
  font-size: .88rem;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: #fff;
  color: var(--ink);
}

.field textarea {
  min-height: 92px;
  resize: vertical;
}

.list {
  display: grid;
  gap: 10px;
}

.row-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.row-item.compact {
  grid-template-columns: 1fr;
}

.row-item h3,
.row-item h4 {
  margin: 0 0 4px;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.timeline {
  position: relative;
  display: grid;
  gap: 12px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 14px;
}

.timeline-date {
  color: var(--muted);
  font-weight: 800;
  font-size: .86rem;
}

.timeline-content {
  border-left: 3px solid var(--gold);
  padding: 0 0 14px 16px;
}

.timeline-content h4 {
  margin: 0 0 4px;
}

.timeline-content p {
  margin: 0;
  color: var(--muted);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 16px;
  align-items: start;
}

.qr-box {
  display: grid;
  place-items: center;
  min-height: 260px;
  border: 1px dashed #c9b487;
  border-radius: 8px;
  background: #fff8ea;
}

.qr-box canvas {
  width: 220px;
  height: 220px;
  image-rendering: pixelated;
}

.review-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.review-panel {
  width: min(680px, 100%);
}

.rating {
  display: flex;
  gap: 8px;
}

.rating button {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-weight: 900;
}

.rating button.active {
  border-color: var(--honey);
  background: rgba(242, 196, 91, .38);
}

.empty {
  min-height: 220px;
  display: grid;
  place-items: center;
  padding: 32px;
  text-align: center;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 36px));
  padding: 13px 15px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(38, 26, 16, .46);
}

.delete-dialog {
  width: min(520px, 100%);
  box-shadow: var(--shadow);
}

.delete-dialog h2 {
  margin: 12px 0 8px;
}

.delete-dialog p {
  color: var(--muted);
  line-height: 1.55;
}

.hidden {
  display: none !important;
}

@media (max-width: 860px) {
  .hero,
  .split,
  .stage-command,
  .support-grid,
  .summary-grid,
  .stage-actions,
  .filter-bar,
  .grid.two,
  .grid.three,
  .form.two {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
    padding-top: 32px;
  }

  .hero-art {
    min-height: 300px;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .timeline-item {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .row-item {
    grid-template-columns: 1fr;
  }

  .row-actions {
    justify-content: flex-start;
  }

  .batch-meta {
    flex-direction: column;
    gap: 4px;
  }

  .batch-stage-rail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-radius: 8px;
  }

  .stage-chip {
    border-bottom: 1px solid rgba(255, 255, 255, .7);
  }

  .journey {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: visible;
    padding-inline: 14px;
    scrollbar-gutter: stable;
  }

  .journey-step {
    flex: 0 0 auto;
  }

  .journey-step.inserting {
    flex: 0 0 auto;
  }

  .journey-stage {
    width: 160px;
    min-height: 156px;
    padding: 15px;
  }

  .stage-remove {
    right: 50px;
  }

  .journey-insert-slot {
    min-height: 156px;
  }

  .journey-insert-form {
    width: min(300px, 78vw);
  }

  .inline-form {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .inline-form input {
    width: 100%;
  }

  .command-main {
    min-height: auto;
  }

  .stage-section-head {
    grid-template-columns: 1fr;
  }
}
