:root {
  color-scheme: light;
  --line: #06c755;
  --line-dark: #04a947;
  --ink: #17201a;
  --muted: #68726b;
  --surface: #ffffff;
  --soft: #f2f6f3;
  --border: #dfe7e1;
  --danger: #c83a3a;
  --shadow: 0 18px 50px rgba(24, 50, 31, 0.1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 0%, rgba(6, 199, 85, 0.15), transparent 35%),
    linear-gradient(180deg, #f7fbf8 0%, #edf4ef 100%);
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.shell {
  width: min(100%, 480px);
  margin: 0 auto;
  padding: max(32px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 8px 4px 26px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: var(--line);
  color: white;
  font-size: 24px;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(6, 199, 85, 0.25);
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 28px; letter-spacing: -0.04em; }
h2 { margin-bottom: 10px; font-size: 24px; letter-spacing: -0.03em; }

.eyebrow {
  margin-bottom: 4px;
  color: var(--line-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.card {
  padding: 26px;
  border: 1px solid rgba(223, 231, 225, 0.9);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.hidden { display: none !important; }
.muted { color: var(--muted); line-height: 1.65; }
.caption { margin-bottom: 2px; color: var(--muted); font-size: 12px; }

.step {
  display: inline-block;
  margin-bottom: 12px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #e9f9ef;
  color: #068438;
  font-size: 12px;
  font-weight: 800;
}

form { margin-top: 22px; }
label { display: block; margin-top: 16px; font-size: 14px; font-weight: 700; }

input, select {
  width: 100%;
  margin-top: 8px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  background: #fbfdfb;
  color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus {
  border-color: var(--line);
  box-shadow: 0 0 0 4px rgba(6, 199, 85, 0.12);
}

.button {
  width: 100%;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  margin-top: 20px;
  padding: 14px 18px;
  border: 0;
  border-radius: 13px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 800;
  transition: transform 0.15s, opacity 0.15s, background 0.15s;
}

.button:active { transform: translateY(1px); }
.button:disabled { cursor: wait; opacity: 0.58; }
.line-button { background: var(--line); color: white; }
.line-button:hover { background: var(--line-dark); }
.secondary-button { border: 1px solid var(--border); background: white; color: var(--ink); }
.dark-button { background: var(--ink); color: white; }
.compact { width: auto; margin-top: 0; padding: 10px 15px; font-size: 14px; }

.text-button {
  width: 100%;
  margin-top: 20px;
  padding: 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.danger-text { color: var(--danger); }

.dev-panel {
  margin-top: 24px;
  padding: 16px;
  border: 1px dashed #b9c8bd;
  border-radius: 14px;
  background: var(--soft);
}

.dev-panel form, .dev-panel label:first-of-type { margin-top: 0; }
.dev-label { color: #556159; font-size: 12px; font-weight: 800; }

.message {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.5;
}

.error { background: #fff0f0; color: #a32626; }

.account-strip {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: -8px 0 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--line);
  background-position: center;
  background-size: cover;
  color: white;
  font-weight: 800;
}

.success-icon, .error-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  border-radius: 50%;
  font-size: 28px;
  font-weight: 900;
}

.success-icon { background: #e1f8e9; color: var(--line-dark); }
.error-icon { margin-inline: auto; background: #fff0f0; color: var(--danger); }

.profile-list {
  margin: 24px 0;
  border-top: 1px solid var(--border);
}

.profile-list div {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 15px 0;
  border-bottom: 1px solid var(--border);
}

.profile-list dt { color: var(--muted); }
.profile-list dd { margin: 0; font-weight: 800; text-align: right; }

.status {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status.active { background: #e5f8ec; color: #087b37; }
.status.inactive { background: #f0f1f0; color: #606760; }
.status.resigned { background: #fff0f0; color: #a32626; }

.notice {
  padding: 16px;
  border-radius: 14px;
  background: var(--soft);
  color: #526057;
  line-height: 1.55;
}

.portal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.state-card { text-align: center; color: var(--muted); }
.spinner {
  width: 34px;
  height: 34px;
  margin: 4px auto 14px;
  border: 3px solid #d8e9dd;
  border-top-color: var(--line);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

footer { padding: 24px 0 0; color: #859088; font-size: 12px; text-align: center; }

.admin-body { background: #f4f6f4; }
.admin-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 42px 0; }
.admin-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 28px; }
.admin-login-card { max-width: 620px; }
.account-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; margin-top: 14px; }
.message.success { color: #176b3a; background: #eaf8ef; border: 1px solid #b9e2c8; }
.inline-form { display: flex; align-items: flex-end; gap: 12px; }
.inline-form label { flex: 1; }
.inline-form .button { width: auto; white-space: nowrap; }
.hint { margin: 14px 0 0; color: var(--muted); font-size: 12px; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}

.summary-card {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: white;
}

.summary-card span { display: block; color: var(--muted); font-size: 13px; }
.summary-card strong { display: block; margin-top: 6px; font-size: 28px; }
.table-card { padding: 24px; border: 1px solid var(--border); border-radius: 18px; background: white; margin-bottom: 18px; }
.table-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 18px; }
.table-heading h2, .table-heading p { margin-bottom: 3px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 12px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 12px; }
td { min-width: 130px; padding: 15px 12px; border-bottom: 1px solid #edf1ee; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
.table-sub { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.action-row { display: flex; align-items: center; gap: 8px; }
.action-row select { min-width: 105px; margin: 0; padding: 9px 10px; }
.small-button { padding: 9px 10px; border-radius: 9px; background: white; cursor: pointer; font-size: 12px; font-weight: 700; }
.danger-outline { border: 1px solid #efb8b8; color: var(--danger); }

.wide-shell { width: min(980px, calc(100% - 36px)); }
.lunch-user-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}
.lunch-grid, .admin-lunch-list {
  display: grid;
  gap: 16px;
}
.lunch-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.lunch-day-card, .admin-lunch-day {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: white;
}
.lunch-day-card.locked { background: #fafafa; }
.lunch-day-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.lunch-day-heading h3 { margin: 0; font-size: 18px; }
.meal-list {
  display: grid;
  gap: 9px;
  margin: 12px 0;
}
.meal-option {
  width: 100%;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: white;
  text-align: left;
  cursor: pointer;
}
.meal-option strong, .meal-option span { display: block; }
.meal-option span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.meal-option.selected {
  border-color: var(--line);
  background: #ecfff2;
}
.meal-option:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}
.ordered-box {
  padding: 12px;
  border-radius: 13px;
  background: #ecfff2;
}
.ordered-box span { display: block; color: var(--muted); font-size: 12px; }
.admin-lunch-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}
.meal-form { margin-bottom: 12px; }
.admin-meal-block {
  padding: 14px 0;
  border-top: 1px solid #edf1ee;
}
.admin-meal-block:first-of-type { border-top: 0; }
.order-name-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 6px 12px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}
.order-name-list li {
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--soft);
  font-weight: 700;
}
.order-name-list span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

@media (max-width: 720px) {
  .admin-shell { width: min(100% - 24px, 1180px); padding: 24px 0; }
  .admin-header, .inline-form { display: block; }
  .admin-header .button, .inline-form .button { width: 100%; margin-top: 14px; }
  .summary-grid { grid-template-columns: 1fr; }
  .portal-actions { grid-template-columns: 1fr; }
  .lunch-user-card { display: block; }
  .lunch-user-card .button { width: 100%; margin-top: 14px; }
  .card { padding: 22px; }
}
