:root {
  --bg: #f4f1ea;
  --ink: #232323;
  --muted: #6c665e;
  --line: #d8d0c4;
  --panel: #fffdf8;
  --accent: #b93f22;
  --accent-dark: #8d2f1a;
  --green: #2c6b52;
  --gold: #e2b84d;
  --shadow: 0 18px 44px rgba(56, 45, 34, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  align-items: center;
  background: #222;
  color: white;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  padding: 18px clamp(18px, 4vw, 48px);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 3.3vw, 42px);
  line-height: 1.15;
}

h2 {
  font-size: clamp(24px, 3vw, 36px);
}

h3 {
  font-size: 18px;
}

.eyebrow {
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.tabs,
.button-row,
.actions,
.member-toolbar {
  align-items: center;
  display: flex;
  gap: 10px;
}

.tab,
button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  min-height: 42px;
  padding: 0 16px;
}

.tab {
  background: rgba(255, 255, 255, 0.14);
  color: white;
}

.tab.active,
.primary {
  background: var(--accent);
  color: white;
}

.primary:hover {
  background: var(--accent-dark);
}

.secondary {
  background: #ebe2d4;
  color: var(--ink);
}

.danger {
  background: #352b25;
  color: white;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.subtle-danger {
  min-height: 44px;
  width: 100%;
}

.mini-danger {
  font-size: 13px;
  min-height: 34px;
  padding: 0 10px;
  white-space: nowrap;
}

.admin-status {
  align-content: center;
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
}

main {
  margin: 0 auto;
  max-width: 1180px;
  padding: 20px clamp(14px, 4vw, 40px) 48px;
}

.menu-hero {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(170px, 220px) 1fr;
  margin-bottom: 20px;
}

.menu-hero img {
  aspect-ratio: 710 / 945;
  border-radius: 8px;
  box-shadow: var(--shadow);
  object-fit: cover;
  width: 100%;
}

.menu-copy {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  padding: 18px;
}

.menu-copy h2 {
  font-size: 24px;
  margin-bottom: 12px;
}

.dish-list {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  list-style: none;
  margin: 0;
  padding: 0;
}

.dish-list li {
  background: #f4efe6;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 800;
  line-height: 1.35;
  min-height: 44px;
  padding: 10px 12px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 30px);
}

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

.form-grid,
.filters {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 22px;
}

.filter-action {
  align-items: end;
  display: flex;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 14px;
  font-weight: 800;
  gap: 7px;
}

input,
select {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 44px;
  padding: 0 12px;
  width: 100%;
}

.hidden {
  display: none;
}

.member-toolbar {
  justify-content: space-between;
  margin-bottom: 10px;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  min-width: 640px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #efe7d9;
  font-size: 13px;
}

tr:last-child td {
  border-bottom: 0;
}

.actions {
  justify-content: space-between;
  margin-top: 18px;
}

#formMessage {
  color: var(--green);
  font-weight: 800;
}

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

.stat {
  background: #f4efe6;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.stat strong {
  display: block;
  font-size: 28px;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.split {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.25fr);
}

.split > section {
  min-width: 0;
}

.split h3 {
  margin-bottom: 10px;
}

.compact {
  max-height: 460px;
  overflow: auto;
}

.compact table {
  min-width: 0;
  table-layout: fixed;
}

.summary-table th:nth-child(2),
.summary-table td:nth-child(2) {
  text-align: center;
  width: 86px;
}

.summary-table td:nth-child(2) {
  font-size: 20px;
  font-weight: 900;
}

.total-row td {
  background: #f4efe6;
  font-weight: 900;
}

.detail-table th,
.detail-table td {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.detail-table th:nth-child(1),
.detail-table td:nth-child(1) {
  width: 24%;
}

.detail-table th:nth-child(2),
.detail-table td:nth-child(2) {
  text-align: center;
  width: 70px;
}

.detail-table th:nth-child(3),
.detail-table td:nth-child(3) {
  width: 37%;
}

.detail-table th:nth-child(4),
.detail-table td:nth-child(4) {
  width: 20%;
}

.detail-table th:nth-child(5),
.detail-table td:nth-child(5) {
  text-align: center;
  width: 86px;
}

.danger-zone {
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 18px;
}

.login-dialog {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 420px;
  padding: 0;
  width: calc(100% - 32px);
}

.login-dialog::backdrop {
  background: rgba(0, 0, 0, 0.42);
}

.login-dialog form {
  display: grid;
  gap: 14px;
  padding: 24px;
}

.login-dialog p {
  color: var(--muted);
  line-height: 1.5;
}

.login-error {
  color: var(--accent);
  font-weight: 900;
  min-height: 22px;
}

.dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

@media (max-width: 820px) {
  .topbar,
  .section-heading,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .tabs,
  .button-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .menu-hero,
  .form-grid,
  .filters,
  .stats,
  .split {
    grid-template-columns: 1fr;
  }

  .dish-list {
    grid-template-columns: 1fr;
  }

  table {
    min-width: 560px;
  }
}
