:root {
  font-family:
    system-ui,
    -apple-system,
    'Noto Sans TC',
    sans-serif;
  color: #283831;
  background: #f5f4ee;
  --green: #234f3e;
  --muted: #6b756e;
  --line: #dedfd4;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
header {
  padding: 20px 5%;
  background: #fffefa;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  font-size: 25px;
  letter-spacing: 3px;
  color: var(--green);
  font-weight: 800;
  text-decoration: none;
}
.brand small {
  display: block;
  font-size: 9px;
  letter-spacing: 2px;
}
#context {
  color: var(--muted);
  font-size: 14px;
}
main {
  max-width: 1200px;
  margin: auto;
  padding: 32px 24px 100px;
}
h1 {
  font-size: 32px;
  margin: 8px 0;
}
h2 {
  font-size: 21px;
}
p {
  line-height: 1.7;
}
.eyebrow {
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--muted);
}
.muted,
small {
  color: var(--muted);
}
.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}
.notice {
  background: #e8eee4;
  color: var(--green);
  border-radius: 12px;
  padding: 14px 18px;
  margin: 18px 0;
  font-size: 14px;
}
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 24px 0;
}
.tabs button {
  background: transparent;
  color: var(--green);
  border: 1px solid var(--line);
}
.tabs button.active {
  background: var(--green);
  color: white;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.card {
  background: #fffefa;
  border: 1px solid var(--line);
  padding: 22px;
  border-radius: 16px;
}
.card h3 {
  margin: 10px 0;
}
.card p {
  font-size: 14px;
  color: var(--muted);
}
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.stack {
  display: grid;
  gap: 12px;
}
.price {
  font-size: 21px;
  font-weight: 700;
}
.badge {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 30px;
  font-size: 12px;
  background: #e8eee4;
  color: var(--green);
}
.badge.warn {
  background: #fff0d9;
  color: #835b20;
}
button {
  background: var(--green);
  color: white;
  border: 0;
  border-radius: 9px;
  padding: 11px 16px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  min-height: 42px;
}
button:hover {
  filter: brightness(0.95);
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
button.secondary {
  background: #eaece4;
  color: var(--green);
}
button.danger {
  background: #f4e6e0;
  color: #984c33;
}
button.small {
  padding: 7px 12px;
}
input,
select,
textarea {
  font: inherit;
  background: white;
  color: #283831;
  border: 1px solid #cbd0c4;
  border-radius: 8px;
  padding: 11px;
  width: 100%;
  margin: 6px 0 14px;
}
input[type='checkbox'],
input[type='radio'] {
  width: auto;
  margin: 0 10px 0 0;
}
label {
  display: block;
  font-size: 14px;
}
textarea {
  min-height: 90px;
}
fieldset {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  margin: 12px 0;
}
fieldset label {
  padding: 10px 0;
}
.layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
}
.cart {
  position: sticky;
  top: 20px;
  align-self: start;
}
.line {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.line small {
  display: block;
  margin: 6px 0;
}
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.login {
  max-width: 420px;
  margin: 45px auto;
}
.empty {
  text-align: center;
  padding: 50px 12px;
  color: var(--muted);
}
dialog {
  border: 0;
  border-radius: 18px;
  max-width: 680px;
  width: calc(100% - 32px);
  max-height: 90vh;
  padding: 26px;
  color: #283831;
}
dialog::backdrop {
  background: #18271fcc;
}
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #253b30;
  color: white;
  border-radius: 12px;
  padding: 14px 22px;
  max-width: 90vw;
  z-index: 20;
  display: none;
}
pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
}
#paper {
  display: none;
}
.qr {
  width: 220px;
  height: 220px;
  display: block;
  margin: 20px auto;
}
.center {
  text-align: center;
}
.table-name {
  font-size: 30px;
}
a {
  color: var(--green);
}
.history {
  margin-top: 32px;
}
.history .card {
  margin: 10px 0;
}
.pill {
  font-size: 12px;
  color: #8c6240;
}
.category-title {
  margin: 28px 0 16px;
}
.group-builder {
  border: 1px solid var(--line);
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 14px;
}
.choice-row {
  display: grid;
  grid-template-columns: 1fr 100px 70px;
  gap: 8px;
  align-items: center;
}
.formcols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.error {
  color: #a63a27;
}
#connection {
  font-size: 12px;
  color: #a63a27;
}
@media (max-width: 800px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .cart {
    position: static;
  }
  .hero {
    align-items: flex-start;
  }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  }
  h1 {
    font-size: 27px;
  }
  main {
    padding: 24px 16px 80px;
  }
  .formcols {
    grid-template-columns: 1fr;
  }
}
@media print {
  body > * {
    display: none !important;
  }
  #paper {
    display: block !important;
    color: black;
    background: white;
    width: 72mm;
    font-size: 12px;
    padding: 0;
    margin: 0;
  }
  #paper img {
    width: 48mm;
    height: 48mm;
  }
  #paper h2 {
    text-align: center;
    font-size: 20px;
  }
  #paper p {
    margin: 6px 0;
  }
  #paper .row {
    display: flex;
  }
  #paper hr {
    border: 0;
    border-top: 1px dashed black;
  }
  @page {
    margin: 4mm;
  }
}

.unpaid-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #d52f37;
  box-shadow: 0 0 0 4px #fbe5e6;
  margin-left: 8px;
  vertical-align: middle;
}
.pending-badge {
  background: #fbe5e6;
  color: #b51e2b;
}
#admin-connection {
  display: block;
  color: #a63a27;
  margin-top: 8px;
}

.checkout-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 24px;
}
.checkout-heading h2 {
  font-size: 28px;
  margin: 6px 0;
}
.cash-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 1fr);
  gap: 24px;
  align-items: start;
}
.checkout-summary {
  padding: 28px;
}
.checkout-summary section {
  margin-top: 24px;
}
.checkout-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 0;
  margin: 12px 0;
  border-top: 2px solid var(--line);
}
.checkout-total strong {
  font-size: 30px;
}
.checkout-payment {
  padding: 32px;
}
.checkout-payment form {
  margin-top: 24px;
}
.cash-input {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 2px solid var(--green);
  border-radius: 12px;
  padding: 8px 16px;
  margin: 10px 0 16px;
}
.cash-input span {
  font-weight: 700;
  color: var(--muted);
}
.cash-input input {
  border: 0;
  margin: 0;
  font-size: 34px;
  min-width: 0;
  outline: 0;
  font-weight: 700;
}
.cash-shortcuts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.cash-shortcuts button {
  min-height: 48px;
}
.change-panel {
  background: #e8f0e7;
  border-radius: 14px;
  padding: 24px;
  margin: 24px 0;
  display: grid;
  gap: 12px;
}
.change-panel strong {
  font-size: 42px;
  color: var(--green);
  overflow-wrap: anywhere;
}
.change-panel.insufficient {
  background: #fff0df;
}
.change-panel.insufficient strong {
  font-size: 28px;
  color: #975520;
}
.collect-primary {
  width: 100%;
  font-size: 18px;
  min-height: 58px;
}
.payment-complete {
  max-width: 900px;
  margin: auto;
  padding: 32px;
}
.receipt-amounts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 32px 0;
}
.receipt-amounts > div {
  display: grid;
  gap: 12px;
  padding: 20px;
  background: #f3f4ed;
  border-radius: 12px;
}
.receipt-amounts strong {
  font-size: 28px;
}
.receipt-amounts .receipt-change {
  background: #e8f0e7;
}
.receipt-change strong {
  font-size: 34px;
  color: var(--green);
}
@media (max-width: 800px) {
  .cash-workspace {
    grid-template-columns: 1fr;
  }
  .checkout-payment,
  .checkout-summary {
    padding: 22px;
  }
  .receipt-amounts {
    grid-template-columns: 1fr;
  }
  .checkout-heading h2 {
    font-size: 24px;
  }
}

main.checkout-mode {
  padding-top: 16px;
}
.checkout-mode > .hero {
  display: none;
}
.checkout-mode #admin-tabs {
  margin: 8px 0 12px;
}
.checkout-mode .checkout-heading {
  margin-bottom: 16px;
}
.checkout-mode .checkout-heading h2 {
  font-size: 24px;
}
.checkout-mode .checkout-payment {
  padding: 20px;
}
.checkout-mode .checkout-payment > .eyebrow {
  display: none;
}
.checkout-mode .checkout-payment form {
  margin-top: 0;
}
.checkout-mode .cash-input {
  margin: 8px 0 12px;
  padding: 6px 14px;
}
.checkout-mode .cash-input input {
  height: 48px;
  padding: 6px;
  font-size: 32px;
}
.checkout-mode .cash-shortcuts button {
  min-height: 42px;
}
.checkout-mode .change-panel {
  padding: 16px;
  margin: 12px 0;
  gap: 8px;
}
.checkout-mode .change-panel small {
  display: none;
}
.checkout-mode .change-panel strong {
  font-size: 40px;
}
.checkout-mode #cash-error:empty {
  display: none;
}
.checkout-mode .collect-primary {
  min-height: 54px;
}
.checkout-mode .checkout-payment .muted {
  display: none;
}

.addon-choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.addon-choice label {
  padding: 0;
}
.addon-choice small {
  display: block;
  margin-top: 4px;
}
.quantity-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.quantity-stepper input {
  width: 58px;
  min-width: 0;
  margin: 0;
  text-align: center;
  padding: 10px 4px;
}
.quantity-stepper button {
  min-width: 42px;
  min-height: 44px;
  padding: 8px;
}
.addon-choice > div:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}
@media (max-width: 420px) {
  .addon-choice {
    gap: 8px;
  }
  .quantity-stepper {
    gap: 4px;
  }
  .quantity-stepper input {
    width: 48px;
  }
  .quantity-stepper button {
    min-width: 40px;
    padding: 6px;
  }
}

.pickup-time {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pickup-time select {
  margin: 6px 0 10px;
}
.takeout-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  background: #f3f4ed;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 8px 0;
}
.takeout-info a {
  color: var(--green);
}
#takeout-alert {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: #fff0d9;
  color: #5f3f10;
  border-bottom: 3px solid #d99a3d;
  padding: 12px 5%;
  box-shadow: 0 4px 18px #0003;
  animation: takeout-pulse 1.4s ease-in-out infinite;
}
#takeout-alert p {
  margin: 4px 0;
  font-size: 15px;
}
#takeout-alert .row {
  margin-bottom: 4px;
}
@keyframes takeout-pulse {
  50% {
    background: #ffe2b0;
  }
}
@media (prefers-reduced-motion: reduce) {
  #takeout-alert {
    animation: none;
  }
}

.big-number {
  color: var(--green);
  font-size: 1.3em;
}
.my-order {
  margin: 12px 0;
}
.lookup {
  margin: 18px 0;
}
.lookup summary {
  cursor: pointer;
  color: var(--green);
}

.dish {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: 10px;
  margin: 0 0 12px;
  background: #eaece4;
}
.crop {
  margin: 0 0 16px;
}
.crop-frame {
  position: relative;
  width: 100%;
  max-width: 420px;
  aspect-ratio: 4/3;
  margin: 6px auto 10px;
  overflow: hidden;
  border-radius: 12px;
  border: 2px dashed #b9c0b2;
  background: #eef0e8;
  touch-action: none;
  user-select: none;
}
.crop-frame.editing {
  cursor: grab;
  border-style: solid;
  border-color: var(--green);
}
.crop-frame.dragging {
  cursor: grabbing;
}
.crop-frame:focus-visible {
  outline: 3px solid #8fb7a3;
}
.crop-img {
  position: absolute;
  left: 0;
  top: 0;
  max-width: none;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
}
.crop-frame:not(.editing) .crop-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.crop-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
}
.crop-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 420px;
  margin: 0 auto;
}
.crop-controls input {
  margin: 8px 0;
}
.crop .actions {
  justify-content: center;
  margin-top: 8px;
}
.crop-hint {
  display: block;
  text-align: center;
  margin-top: 8px;
}
.file-button {
  display: inline-flex;
  align-items: center;
  background: var(--green);
  color: white;
  border-radius: 9px;
  padding: 11px 16px;
  cursor: pointer;
  font-size: 14px;
  min-height: 42px;
  margin: 0;
}

/* 點餐頁：有照片的餐點改成左圖右文的橫式卡片，縮圖固定 4:3，不撐高版面 */
#menu {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}
#menu .card.with-dish {
  display: grid;
  grid-template-columns: 112px 1fr;
  column-gap: 14px;
  align-items: start;
  padding: 14px;
}
#menu .card.with-dish .dish {
  grid-column: 1;
  grid-row: 1 / span 4;
  width: 112px;
  height: 84px;
  aspect-ratio: auto;
  margin: 0;
  border-radius: 8px;
}
#menu .card.with-dish > *:not(.dish) {
  grid-column: 2;
  min-width: 0;
}
#menu .card.with-dish h3 {
  margin: 0 0 4px;
}
#menu .card.with-dish p {
  margin: 0 0 8px;
}
@media (max-width: 420px) {
  #menu {
    grid-template-columns: 1fr;
  }
  #menu .card.with-dish {
    grid-template-columns: 96px 1fr;
  }
  #menu .card.with-dish .dish {
    width: 96px;
    height: 72px;
  }
}

/* 選購視窗：顯示較大的照片（原圖 800×600） */
#modalbody > .dish {
  width: 100%;
  max-width: 460px;
  height: auto;
  aspect-ratio: 4/3;
  margin: 0 auto 14px;
  border-radius: 12px;
}

.warn-notice {
  background: #fff0d9;
  color: #835b20;
  font-weight: 600;
}
.takeout-settings-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-top: 10px;
}
.takeout-settings-form label {
  margin: 0;
}
.takeout-settings-form input {
  display: inline-block;
  width: 76px;
  margin: 0 6px;
}

.alert-block + .alert-block {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #d99a3d66;
}

/* 後台版面精簡 */
.admin-bar {
  margin-bottom: 6px;
}
.admin-bar h1 {
  font-size: 24px;
  margin: 2px 0;
}
main {
  padding-top: 20px;
}
#admin-tabs {
  margin: 14px 0 18px;
}
#admin-tabs button[data-count]::after {
  content: attr(data-count);
  display: inline-block;
  min-width: 20px;
  margin-left: 8px;
  padding: 1px 6px;
  border-radius: 10px;
  background: #d52f37;
  color: #fff;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
}
.takeout-settings {
  padding: 12px 18px;
  margin: 0 0 14px;
}
.takeout-settings summary {
  cursor: pointer;
  list-style: revert;
}
.takeout-settings[open] summary {
  margin-bottom: 6px;
}
#order-filters {
  margin: 0 0 16px;
}
/* 新單橫幅：留在版面內（置頂黏住），不再蓋住內容；精簡高度 */
#takeout-alert {
  position: sticky;
  top: 0;
  left: auto;
  right: auto;
  padding: 8px 5%;
  border-bottom-width: 2px;
}
#takeout-alert p {
  margin: 2px 0;
  font-size: 14px;
  line-height: 1.5;
}
#takeout-alert .row {
  margin-bottom: 0;
}
#takeout-alert .alert-block + .alert-block {
  margin-top: 6px;
  padding-top: 6px;
}
/* 後台菜單：有照片的卡片改縮圖橫式 */
#admin-menu .card.with-dish {
  display: grid;
  grid-template-columns: 112px 1fr;
  column-gap: 14px;
  align-items: start;
}
#admin-menu .card.with-dish .dish {
  grid-column: 1;
  grid-row: 1 / span 5;
  width: 112px;
  height: 84px;
  aspect-ratio: auto;
  margin: 0;
  border-radius: 8px;
}
#admin-menu .card.with-dish > *:not(.dish) {
  grid-column: 2;
  min-width: 0;
}
#admin-menu .card.with-dish > .actions {
  grid-column: 1/-1;
}
#unpaid-count {
  display: none !important;
}
#admin-menu .card.with-dish {
  align-content: start;
  grid-auto-rows: min-content;
  row-gap: 2px;
}
#admin-menu .card.with-dish .dish {
  grid-row: 1 / span 6;
}
#admin-menu .card.with-dish > .actions {
  margin-top: 10px;
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.printer-chip.printer-bad {
  background: #fbe5e6;
  color: #b51e2b;
  font-weight: 600;
}
.print-jobs {
  display: grid;
  gap: 10px;
  margin: 12px 0;
  max-height: 55vh;
  overflow: auto;
}
.print-job {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}
.print-job img {
  width: 120px;
  max-height: 150px;
  object-fit: contain;
  object-position: top;
  background: #fff;
  border: 1px solid var(--line);
}
.print-job-info small {
  display: block;
  margin: 4px 0;
}

/* 營運報表 */
.report-range {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px 14px;
  margin: 0 0 16px;
}
.report-range label {
  margin: 0;
}
.report-range input {
  margin: 4px 0 0;
  width: auto;
}
.report-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
  margin: 0 0 16px;
}
.report-cards .card {
  display: grid;
  gap: 4px;
  padding: 16px;
}
.report-cards strong {
  font-size: 24px;
  color: var(--green);
}
#report-body > .card {
  margin: 0 0 16px;
}
.report-two {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}
.report-two .card {
  margin: 0;
}
.bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 170px;
  margin-top: 14px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.bar-col {
  flex: 1 0 22px;
  min-width: 22px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 3px;
}
.bar {
  width: 100%;
  max-width: 34px;
  background: var(--green);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
}
.bar-val {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}
.bar-label {
  font-size: 11px;
  color: var(--muted);
}
.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.report-table th,
.report-table td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
}
.report-table td:nth-child(n + 2),
.report-table th:nth-child(n + 2) {
  text-align: right;
}
.backup-card {
  margin: 0 0 18px;
}
.backup-card h3 {
  margin: 0;
}
.backup-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 18px;
  font-size: 14px;
}
.backup-grid span {
  color: var(--muted);
}
