:root {
  --paper: #f5efe3;
  --paper-deep: #eadfcb;
  --card: #fffaf1;
  --ink: #2d2119;
  --muted: #796858;
  --line: #dac8ae;
  --coffee: #4a2f21;
  --espresso: #2a1710;
  --caramel: #b57736;
  --olive: #667349;
  --green: #607d4b;
  --green-soft: #e6efde;
  --orange: #c86e3b;
  --orange-soft: #fae2d1;
  --red: #9e4a3b;
  --red-soft: #f0d7d1;
  --shadow: 0 18px 48px rgba(74, 47, 33, 0.13);
  --radius: 8px;
  --max: 1320px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(245, 239, 227, 0.78), rgba(245, 239, 227, 0.96)),
    url("assets/coffee-workbench.jpg") center top / min(1500px, 165vw) auto no-repeat,
    var(--paper);
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  line-height: 1.55;
}

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

button {
  cursor: pointer;
}

.page-shell {
  width: min(var(--max), calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 52px;
}

.hero {
  min-height: 270px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 24px;
  padding: 34px;
  border: 1px solid rgba(74, 47, 33, 0.18);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(4px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--olive);
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 0.78rem;
  font-weight: 800;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.16;
}

h1 {
  max-width: 760px;
  font-size: clamp(2.1rem, 5vw, 4.5rem);
  font-weight: 900;
}

.subtitle {
  max-width: 560px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
}

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

.save-status {
  padding: 10px 12px;
  border: 1px solid rgba(102, 115, 73, 0.28);
  border-radius: 999px;
  background: rgba(230, 239, 222, 0.72);
  color: #4e5d39;
  font-size: 0.88rem;
  white-space: nowrap;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.danger-btn,
.mini-btn {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 800;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-btn {
  background: var(--coffee);
  color: #fffaf1;
  box-shadow: 0 10px 22px rgba(74, 47, 33, 0.2);
}

.secondary-btn,
.ghost-btn,
.mini-btn {
  background: #fff7ea;
  color: var(--coffee);
  border-color: var(--line);
}

.danger-btn {
  background: var(--red-soft);
  color: var(--red);
  border-color: rgba(158, 74, 59, 0.25);
}

button:hover {
  transform: translateY(-1px);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(181, 119, 54, 0.35);
  outline-offset: 2px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.stat-card {
  min-height: 108px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.94);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  color: var(--coffee);
  font-size: 2rem;
}

.stat-card.alert strong {
  color: var(--orange);
}

.stat-card.warn strong {
  color: #9a6334;
}

.stat-card.muted strong {
  color: var(--red);
}

.workspace-grid {
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.tool-panel,
.list-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.96);
  box-shadow: 0 12px 30px rgba(74, 47, 33, 0.08);
}

.tool-panel {
  position: sticky;
  top: 16px;
  padding: 22px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

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

.field.full,
.form-error,
.form-actions {
  grid-column: 1 / -1;
}

label {
  color: var(--coffee);
  font-size: 0.9rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fffdf8;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

.form-error {
  min-height: 22px;
  color: var(--red);
  font-weight: 800;
}

.form-actions,
.card-actions,
.stock-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.list-panel {
  padding: 18px;
}

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.controls label {
  display: grid;
  gap: 6px;
}

.beans-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.bean-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(181, 119, 54, 0.11), transparent 38%),
    #fffaf1;
  box-shadow: 0 10px 24px rgba(74, 47, 33, 0.08);
}

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

.bean-card h3 {
  font-size: 1.18rem;
}

.tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tag {
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--green-soft);
  color: #4d663c;
  font-size: 0.76rem;
  font-weight: 900;
  white-space: nowrap;
}

.tag.low,
.tag.soon {
  background: var(--orange-soft);
  color: var(--orange);
}

.tag.expired {
  background: var(--red-soft);
  color: var(--red);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.info-item {
  padding: 9px;
  border: 1px dashed rgba(74, 47, 33, 0.16);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.76);
}

.info-item span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
}

.info-item strong {
  display: block;
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.countdown {
  padding: 12px;
  border-left: 4px solid var(--green);
  border-radius: 8px;
  background: var(--green-soft);
  color: #435837;
  font-weight: 850;
}

.countdown.soon {
  border-left-color: var(--orange);
  background: var(--orange-soft);
  color: #89522d;
}

.countdown.expired {
  border-left-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}

.note-block {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.note-block strong {
  color: var(--coffee);
}

.low-alert {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--orange-soft);
  color: var(--orange);
  font-weight: 900;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 360px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.7);
}

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

.empty-mark {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--coffee);
  color: #fffaf1;
  font-size: 2rem;
  font-weight: 900;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid rgba(74, 47, 33, 0.2);
  border-radius: 8px;
  background: var(--espresso);
  color: #fffaf1;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.hidden {
  display: none !important;
}

@media (max-width: 1120px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .tool-panel {
    position: static;
  }
}

@media (max-width: 820px) {
  .page-shell {
    width: min(100% - 24px, var(--max));
    padding-top: 14px;
  }

  .hero {
    min-height: auto;
    grid-template-columns: 1fr;
    padding: 22px;
  }

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

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

  .controls,
  .beans-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  body {
    background-size: 1200px auto;
  }

  h1 {
    font-size: 2rem;
  }

  .stats-grid,
  form,
  .info-grid {
    grid-template-columns: 1fr;
  }

  .hero-actions,
  .form-actions,
  .card-actions,
  .stock-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-btn,
  .secondary-btn,
  .ghost-btn,
  .danger-btn,
  .mini-btn {
    width: 100%;
  }

  .save-status {
    white-space: normal;
  }
}
