:root {
  color-scheme: light;
  --bg: #fff7f6;
  --ink: #342524;
  --muted: #806b68;
  --line: #ead6d1;
  --panel: #ffffff;
  --coffee: #a33d36;
  --coffee-dark: #6f2522;
  --mint: #ffe1dc;
  --mint-strong: #d34c43;
  --amber: #efaa66;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
}
button, input, a { font: inherit; }
button { border: 0; color: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

.app-shell {
  width: min(100%, 480px);
  min-height: 100vh;
  margin: 0 auto;
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 218, 212, .86), rgba(255, 247, 246, 0) 260px),
    var(--bg);
  padding: 24px 18px 96px;
}

.page { display: none; }
.page.active { display: block; }

.store-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.store-head p {
  margin: 0 0 4px;
  color: var(--coffee);
  font-size: 14px;
  font-weight: 800;
}
.store-head h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.08;
  letter-spacing: 0;
}
.admin-link {
  min-width: 54px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.75);
  color: var(--muted);
  font-weight: 750;
  font-size: 14px;
}

.drink-list {
  display: grid;
  gap: 14px;
}
.drink-card {
  min-height: 132px;
  display: grid;
  grid-template-columns: 112px 1fr;
  align-items: center;
  gap: 16px;
  padding: 12px;
  border-radius: 8px;
  background: var(--panel);
  border: 2px solid transparent;
  box-shadow: 0 14px 34px rgba(36, 48, 44, .08);
  text-align: left;
}
.drink-card.active {
  border-color: var(--coffee);
}
.drink-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 24px;
}
.drink-card small {
  color: var(--muted);
  font-size: 14px;
}
.drink-photo {
  width: 112px;
  height: 108px;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  background: #f8ebe8;
}
.drink-photo::before {
  content: "";
  position: absolute;
  left: 27px;
  right: 27px;
  bottom: 13px;
  height: 72px;
  border-radius: 5px 5px 18px 18px;
  border: 4px solid rgba(255,255,255,.92);
  box-shadow: 0 10px 20px rgba(36, 48, 44, .14);
}
.drink-photo::after {
  content: "";
  position: absolute;
  left: 36px;
  right: 36px;
  top: 15px;
  height: 13px;
  border-radius: 999px;
  background: rgba(255,255,255,.95);
}
.latte {
  background:
    linear-gradient(180deg, transparent 0 36px, #f7efe4 36px 60px, #b77c52 60px 100%),
    #ffe1dc;
}
.americano {
  background:
    linear-gradient(180deg, transparent 0 34px, #3c2419 34px 78px, #17110e 78px 100%),
    #f4e3df;
}

.choice-panel {
  margin: 22px 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.82);
}
.choice-panel h2 {
  margin: 0 0 14px;
  font-size: 17px;
}
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.segmented button {
  height: 48px;
  border-radius: 8px;
  background: #faebe8;
  color: var(--muted);
  font-weight: 850;
}
.segmented button.active {
  color: #fff;
  background: var(--coffee);
}

.primary-action,
.secondary-action,
.download-link,
.ghost-btn,
.danger-btn {
  min-height: 50px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  padding: 0 18px;
  font-weight: 850;
}
.primary-action {
  width: 100%;
  background: var(--coffee);
  color: #fff;
  box-shadow: 0 12px 24px rgba(138, 75, 50, .22);
}
.primary-action:disabled {
  opacity: .7;
  cursor: wait;
}
.secondary-action,
.download-link,
.ghost-btn {
  background: #fff;
  border: 1px solid var(--line);
}
.export-btn {
  color: var(--coffee);
  background: #fff7f6;
}
.danger-btn {
  background: #fff0ed;
  color: #b94934;
}
.danger-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  filter: grayscale(.25);
}

.ticket-wrap { margin-top: 24px; }
.ticket {
  padding: 24px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 18px 38px rgba(36, 48, 44, .10);
  text-align: center;
}
.ticket p {
  margin: 0 0 8px;
  color: var(--muted);
  font-weight: 800;
}
.ticket h2 {
  margin: 0 0 22px;
  color: var(--coffee);
  font-size: 46px;
  letter-spacing: 0;
}
.ticket dl {
  display: grid;
  gap: 12px;
  margin: 0 0 18px;
  padding: 16px;
  border-radius: 8px;
  background: #fff0ee;
}
.ticket div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}
.ticket dt {
  color: var(--muted);
  font-weight: 700;
}
.ticket dd {
  margin: 0;
  font-weight: 850;
}
.ticket small { color: var(--muted); }
.ticket-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  width: min(100%, 480px);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 18px max(10px, env(safe-area-inset-bottom));
  background: rgba(255,255,255,.92);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.bottom-nav button {
  height: 48px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
}
.bottom-nav button.active {
  background: var(--mint);
  color: var(--coffee-dark);
}

.order-list {
  display: grid;
  gap: 10px;
}
.order-row {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  width: 100%;
  padding: 16px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  text-align: left;
}
.order-row strong {
  color: var(--coffee);
  font-size: 20px;
}
.order-row span {
  justify-self: end;
  font-weight: 850;
}
.order-row small {
  grid-column: 1 / 3;
  color: var(--muted);
}
.order-row em {
  position: absolute;
  right: 14px;
  bottom: 14px;
  min-height: 28px;
  display: inline-grid;
  place-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.18);
  color: #fff;
  font-style: normal;
  font-size: 13px;
  font-weight: 900;
}
.order-row.is-ready {
  min-height: 96px;
  background: linear-gradient(135deg, #c73735, #8f2528);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 18px 38px rgba(163, 61, 54, .28);
}
.order-row.is-ready strong,
.order-row.is-ready span,
.order-row.is-ready small {
  color: #fff;
}
.order-row.is-ready strong {
  font-size: 26px;
}
.order-row.is-ready small {
  padding-right: 82px;
  opacity: .92;
}
.order-row:active {
  transform: translateY(1px);
}
.empty-state {
  margin: 24px 0;
  padding: 22px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 86px;
  z-index: 20;
  transform: translateX(-50%);
  max-width: min(86vw, 360px);
  padding: 12px 16px;
  border-radius: 8px;
  background: #342524;
  color: #fff;
  font-weight: 750;
  box-shadow: 0 12px 34px rgba(36,48,44,.2);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(52, 37, 36, .36);
  backdrop-filter: blur(8px);
}
.order-modal {
  width: min(100%, 360px);
  position: relative;
  padding: 24px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 24px 70px rgba(36, 48, 44, .22);
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #faebe8;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
}
.order-modal p {
  margin: 0 0 8px;
  color: var(--muted);
  font-weight: 800;
}
.order-modal h2 {
  margin: 0 0 18px;
  color: var(--coffee);
  font-size: 42px;
  letter-spacing: 0;
}
.order-modal dl {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 16px;
  border-radius: 8px;
  background: #fff0ee;
}
.order-modal div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.order-modal dt {
  color: var(--muted);
  font-weight: 750;
}
.order-modal dd {
  margin: 0;
  font-weight: 900;
  text-align: right;
}
.order-modal .is-ready {
  color: var(--mint-strong);
}
.password-modal {
  width: min(100%, 360px);
  position: relative;
  display: grid;
  gap: 16px;
  padding: 24px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 24px 70px rgba(36, 48, 44, .22);
}
.password-modal p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}
.password-modal h2 {
  margin: 0;
  color: var(--coffee);
  font-size: 28px;
}
.password-modal label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 750;
}
.password-modal input {
  width: 100%;
  height: 50px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  outline: 0;
  color: var(--ink);
  background: #fff7f6;
}
.password-modal input:focus {
  border-color: var(--coffee);
  box-shadow: 0 0 0 3px rgba(163, 61, 54, .12);
}

.admin-page {
  background: #fff7f6;
  padding: 28px;
}
.admin-top {
  max-width: 1120px;
  margin: 0 auto 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}
.admin-top h1 {
  margin: 0 0 6px;
  font-size: 30px;
}
.admin-top p {
  margin: 0;
  color: var(--muted);
}
.admin-grid {
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.stat-card,
.panel {
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 14px 34px rgba(36,48,44,.06);
}
.stat-card {
  padding: 18px;
}
.stat-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 750;
}
.stat-card strong {
  color: var(--coffee);
  font-size: 34px;
}
.panel {
  grid-column: 1 / -1;
  padding: 20px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.admin-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.lock-btn {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 22px;
}
.lock-btn:hover {
  border-color: var(--coffee);
  background: #fff0ee;
}
.panel h2 {
  margin: 0 0 6px;
  font-size: 21px;
}
.panel p {
  margin: 0;
  color: var(--muted);
}
.table-wrap {
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}
th {
  color: var(--muted);
  font-size: 14px;
}
.status-new {
  display: inline-grid;
  place-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--mint);
  color: var(--coffee-dark);
  font-weight: 800;
}
.status-new.is-ready {
  background: #ffe9e5;
  color: #c23b34;
}
.complete-btn {
  min-height: 32px;
  margin-left: 10px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--coffee);
  color: #fff;
  font-weight: 800;
}
.complete-btn:disabled {
  opacity: .7;
  cursor: wait;
}

@media (max-width: 760px) {
  .admin-page { padding: 18px; }
  .admin-top {
    align-items: flex-start;
    flex-direction: column;
  }
  .admin-grid { grid-template-columns: 1fr 1fr; }
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 380px) {
  .drink-card {
    grid-template-columns: 92px 1fr;
  }
  .drink-photo {
    width: 92px;
    height: 96px;
  }
  .store-head h1 { font-size: 30px; }
}
