:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --panel: #ffffff;
  --ink: #202124;
  --muted: #667085;
  --line: #dedbd2;
  --brand: #2f6f73;
  --brand-dark: #204f52;
  --accent: #d95f32;
  --success: #2f7d4f;
}

body.theme-dark {
  color-scheme: dark;
  --bg: #111715;
  --panel: #1b2320;
  --ink: #eef4ef;
  --muted: #a9b8af;
  --line: #334139;
  --brand: #77b9a6;
  --brand-dark: #b8eadb;
  --accent: #ff9a73;
  --success: #8bd49e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Noto Sans TC", Arial, sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 14px clamp(16px, 4vw, 44px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  color: var(--brand-dark);
  font-size: 20px;
  font-weight: 800;
}

.nav {
  align-items: center;
  display: flex;
  gap: 12px;
}

.container {
  margin: 0 auto;
  max-width: 1120px;
  padding: 28px 18px 56px;
}

.hero {
  align-items: end;
  background:
    linear-gradient(90deg, rgba(32, 79, 82, 0.92), rgba(47, 111, 115, 0.62)),
    url("/public/img/table.svg");
  background-size: cover;
  color: white;
  display: grid;
  min-height: 280px;
  padding: clamp(24px, 5vw, 56px);
}

.hero h1 {
  font-size: clamp(34px, 6vw, 68px);
  line-height: 1;
  margin: 0 0 14px;
}

.hero p {
  font-size: 18px;
  margin: 0;
  max-width: 680px;
}

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

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

.card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.card h2,
.panel h2,
.panel h3 {
  margin: 0 0 10px;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.muted {
  color: var(--muted);
}

.badge {
  background: #e7f1ef;
  border-radius: 999px;
  color: var(--brand-dark);
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
}

.button,
button {
  background: var(--brand);
  border: 0;
  border-radius: 6px;
  color: white;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 700;
  justify-content: center;
  padding: 10px 14px;
}

.button.secondary,
button.secondary {
  background: #eef2f2;
  color: var(--brand-dark);
}

.danger-button {
  background: var(--accent);
  color: white;
}

.layout {
  align-items: start;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.8fr);
}

.menu-item,
.order-row,
.summary-row {
  align-items: center;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 12px 0;
}

.menu-category {
  margin-top: 18px;
}

.menu-heading {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.menu-toggle-actions {
  margin-top: 0;
}

.menu-category-toggle {
  background: var(--bg);
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--brand-dark);
  cursor: pointer;
  display: flex;
  font-size: 18px;
  font-weight: 800;
  justify-content: space-between;
  margin: 0;
  padding: 10px 0;
  position: sticky;
  top: 124px;
  width: 100%;
  z-index: 3;
}

.menu-category-toggle::before {
  content: "⌄";
  font-size: 18px;
  margin-right: 8px;
}

.menu-category.is-collapsed .menu-category-toggle::before {
  content: "›";
}

.menu-category-body[hidden] {
  display: none;
}

.menu-category .menu-item:first-of-type {
  border-top: 0;
}

.campaign-heading {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.announcement,
.deadline-box,
.cart-preview,
.notice {
  background: #f8faf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 14px 0;
  padding: 14px;
}

body.theme-dark .announcement,
body.theme-dark .deadline-box,
body.theme-dark .cart-preview,
body.theme-dark .notice {
  background: #16201c;
}

.announcement p,
.deadline-box p,
.notice p {
  margin: 6px 0 0;
}

.notice.danger {
  border-color: var(--accent);
}

.status-badge.status-open {
  background: #e7f1ef;
  color: #204f52;
}

.status-badge.status-closed {
  background: #fff3df;
  color: #806000;
}

.status-badge.status-cancelled {
  background: #ffe7de;
  color: #9b3416;
}

.payment-unpaid {
  background: #fff3df;
  color: #806000;
}

.payment-paid {
  background: #e7f1ef;
  color: #204f52;
}

.payment-refunded {
  background: #ffe7de;
  color: #9b3416;
}

body.theme-dark .status-badge.status-open,
body.theme-dark .status-badge.status-closed,
body.theme-dark .status-badge.status-cancelled {
  background: #26342f;
  color: var(--brand-dark);
}

.mini-form {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  min-width: 150px;
}

.report-layout {
  align-items: start;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.9fr);
  margin-top: 18px;
}

.person-order,
.item-group {
  border-top: 1px solid var(--line);
  padding: 14px 0;
}

.person-order:first-of-type,
.item-group:first-of-type {
  border-top: 0;
}

.person-order-head {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.compact-list {
  display: grid;
  gap: 6px;
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
}

.compact-list li {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  overflow-wrap: anywhere;
}

.preview-table-wrap {
  overflow-x: auto;
}

.preview-table {
  border-collapse: collapse;
  margin-top: 12px;
  min-width: 760px;
  width: 100%;
}

.preview-table th,
.preview-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

.preview-table th {
  color: var(--muted);
  font-size: 13px;
}

.item-total {
  color: var(--brand-dark);
  font-size: 24px;
  font-weight: 800;
  white-space: nowrap;
}

.report-total {
  border-top: 2px solid var(--brand);
  margin-top: 12px;
  padding-top: 14px;
}

.menu-item:first-child,
.order-row:first-child,
.summary-row:first-child {
  border-top: 0;
}

.qty {
  width: 74px;
}

.option-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  margin-top: 10px;
  max-width: 560px;
}

.option-grid label {
  font-size: 13px;
}

.option-checks {
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 8px 10px 10px;
}

.option-checks legend {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  padding: 0 4px;
}

input,
select,
textarea {
  border: 1px solid #c8c5bc;
  border-radius: 6px;
  font: inherit;
  padding: 10px;
  width: 100%;
}

label {
  display: grid;
  font-weight: 700;
  gap: 6px;
}

form.grid {
  gap: 14px;
}

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

.admin-columns {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.admin-tabs {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0;
  padding: 10px;
  position: sticky;
  top: 62px;
  z-index: 8;
}

.admin-tabs button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 9px 12px;
}

.admin-tabs a {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--brand-dark);
  display: inline-flex;
  font-weight: 700;
  padding: 9px 12px;
}

.admin-tabs button.is-active {
  background: var(--brand);
  color: white;
}

.admin-tab-panel {
  display: none;
}

.admin-tab-panel.is-active {
  display: grid;
  gap: 18px;
}

.stat-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.stat-grid div {
  background: #f8faf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 14px;
}

body.theme-dark .stat-grid div {
  background: #16201c;
}

.stat-grid strong {
  color: var(--brand-dark);
  font-size: 28px;
}

.admin-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.admin-filters {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin: 14px 0;
}

.admin-filters > .button,
.admin-filters > button {
  min-height: 44px;
}

.crud-row {
  align-items: end;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  padding-top: 12px;
}

.compact-crud-row {
  border-top: 0;
  margin-top: -6px;
  padding: 0 0 8px;
}

.copy-block {
  margin-top: 14px;
}

.qr-code {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  height: 180px;
  margin-top: 10px;
  padding: 8px;
  width: 180px;
}

.access-panel {
  margin: 36px auto;
  max-width: 560px;
}

.inline-check {
  align-items: center;
  display: flex;
  font-weight: 700;
  gap: 8px;
}

.inline-check input {
  width: auto;
}

.status-open {
  color: var(--success);
}

.status-closed,
.status-cancelled {
  color: var(--accent);
}

@media (max-width: 820px) {
  .layout,
  .report-layout,
  .two {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-tabs {
    top: 96px;
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .admin-tabs button,
  .admin-tabs a {
    white-space: nowrap;
  }

  .crud-row,
  .admin-filters {
    grid-template-columns: 1fr;
  }

  .product-row button,
  .product-row .button {
    width: 100%;
  }
}
