:root {
  --bg: #f7f2e8;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #20231f;
  --muted: #6f746b;
  --line: #ded8ca;
  --green: #2e684d;
  --green-dark: #204c38;
  --green-soft: #e1eee5;
  --orange: #d96f36;
  --orange-soft: #f9e5d7;
  --yellow-soft: #f5eec8;
  --red: #a84035;
  --red-soft: #f8e2df;
  --shadow: 0 18px 45px rgba(61, 54, 39, 0.09);
  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(217, 111, 54, 0.10), transparent 28%),
    radial-gradient(circle at 95% 8%, rgba(46, 104, 77, 0.12), transparent 28%),
    var(--bg);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, textarea, select { font: inherit; }
button { color: inherit; }

.app-shell { min-height: 100vh; }

.topbar {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  appearance: none;
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--green);
  font-size: 22px;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(46, 104, 77, 0.22);
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; }
.brand small { color: var(--muted); margin-top: 2px; }

.connection {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.78);
  color: var(--muted);
  font-size: 13px;
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #b6a98d;
  box-shadow: 0 0 0 4px rgba(182, 169, 141, 0.14);
}

.connection.online .connection-dot { background: #39a86b; box-shadow: 0 0 0 4px rgba(57,168,107,.13); }
.connection.offline .connection-dot { background: var(--red); box-shadow: 0 0 0 4px rgba(168,64,53,.12); }

main {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 72px;
}

.page { display: none; animation: rise .35s ease; }
.page.active { display: block; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero { padding: 66px 0 40px; max-width: 900px; }
.eyebrow {
  margin: 0 0 10px;
  color: var(--orange);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 18px; font-size: clamp(40px, 6vw, 76px); line-height: 1.08; letter-spacing: -.04em; }
h2 { margin-bottom: 12px; font-size: 24px; letter-spacing: -.02em; }
h3 { margin-bottom: 8px; }

.hero-copy, .page-heading > p:last-child {
  max-width: 720px;
  color: var(--muted);
  line-height: 1.8;
  font-size: 17px;
}

.date-strip {
  display: inline-flex;
  margin-top: 14px;
  padding: 11px 15px;
  background: var(--yellow-soft);
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
}

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

.role-card {
  position: relative;
  min-height: 310px;
  padding: 24px;
  border: 1px solid rgba(222, 216, 202, .9);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  cursor: pointer;
  overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.role-card::after {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  right: -70px;
  bottom: -70px;
  border-radius: 50%;
  background: var(--green-soft);
  opacity: .7;
}
.role-away::after { background: var(--orange-soft); }
.role-manager::after { background: var(--yellow-soft); }
.role-card:hover { transform: translateY(-5px); box-shadow: 0 24px 55px rgba(61,54,39,.14); border-color: #c8beaa; }
.role-number { color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .14em; }
.role-icon { margin-top: 34px; font-size: 36px; }
.role-title { margin-top: 22px; font-size: 24px; font-weight: 850; }
.role-desc { margin-top: 10px; color: var(--muted); line-height: 1.7; max-width: 280px; }
.role-action { margin-top: auto; color: var(--green); font-weight: 800; z-index: 1; }

.home-note {
  margin-top: 20px;
  padding: 17px 20px;
  border: 1px dashed #cfc5b2;
  border-radius: var(--radius-md);
  color: var(--muted);
  display: flex;
  gap: 10px 18px;
  flex-wrap: wrap;
}
.home-note strong { color: var(--ink); }

.page-heading { padding: 34px 0 28px; }
.page-heading h1 { font-size: clamp(38px, 5vw, 62px); }
.narrow-heading { max-width: 820px; }
.back-button {
  margin-bottom: 32px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--green);
  font-weight: 800;
  cursor: pointer;
}

.panel {
  padding: 26px;
  border: 1px solid rgba(222, 216, 202, .95);
  border-radius: var(--radius-lg);
  background: rgba(255, 253, 248, .94);
  box-shadow: var(--shadow);
}

.diner-layout { display: grid; grid-template-columns: minmax(320px, .82fr) minmax(0, 1.5fr); gap: 18px; align-items: start; }
.composer-panel { position: sticky; top: 16px; }
.history-panel { margin-top: 18px; }
.section-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.wrap-gap { flex-wrap: wrap; }
.mini-badge { white-space: nowrap; padding: 7px 10px; border-radius: 999px; background: var(--green-soft); color: var(--green-dark); font-size: 12px; font-weight: 800; }

.field-label { display: block; margin: 18px 0 8px; font-size: 13px; font-weight: 800; }
.field-help { color: var(--muted); font-size: 12px; line-height: 1.65; margin: 8px 0 0; }
.search-wrap { position: relative; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 20px; }
.search-wrap input, .text-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  color: var(--ink);
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.search-wrap input { height: 50px; padding: 0 46px 0 43px; }
.text-input { min-height: 48px; padding: 12px 14px; }
.textarea { min-height: 100px; resize: vertical; }
.select-input { cursor: pointer; }
.search-wrap input:focus, .text-input:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(46,104,77,.10); }
.icon-button { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border: 0; border-radius: 10px; background: #f0ece3; cursor: pointer; }

.search-results { margin-top: 14px; display: grid; gap: 8px; max-height: 260px; overflow: auto; }
.search-result-item, .dish-card, .manager-suggestion-item {
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface-strong);
}
.search-result-item { padding: 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dish-info { min-width: 0; }
.dish-name { font-weight: 850; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dish-meta { margin-top: 5px; color: var(--muted); font-size: 12px; }

.category-tag { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.category-meat { background: #fae2db; color: #91422f; }
.category-mixed { background: #f6e9c8; color: #82611f; }
.category-vegetable { background: #dff0df; color: #2f6b40; }
.category-soup { background: #dfeaf5; color: #355f86; }

.new-dish-box { margin-top: 18px; padding: 18px; border-radius: var(--radius-md); background: #f1eee6; }
.new-dish-box > div:first-child { display: grid; gap: 4px; }
.new-dish-box span { color: var(--muted); font-size: 12px; }
.category-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin: 14px 0; }
.category-option, .filter-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
}
.category-option { padding: 9px 5px; }
.category-option.active, .filter-chip.active { color: white; background: var(--green); border-color: var(--green); }

.primary-button, .secondary-button, .danger-button, .vote-button {
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 800;
  cursor: pointer;
  transition: transform .15s ease, opacity .15s ease, background .15s ease;
}
.primary-button { padding: 12px 18px; color: white; background: var(--green); }
.primary-button:hover { background: var(--green-dark); transform: translateY(-1px); }
.secondary-button { padding: 11px 16px; background: var(--surface-strong); border-color: var(--line); }
.danger-button { padding: 12px 18px; color: var(--red); background: var(--red-soft); border-color: #edc7c2; }
.full { width: 100%; }
button:disabled { cursor: not-allowed; opacity: .45; transform: none !important; }

.filter-row { display: flex; flex-wrap: wrap; gap: 7px; }
.filter-chip { padding: 7px 11px; }
.dish-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.dish-card { padding: 15px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.dish-votes { margin-top: 8px; font-size: 13px; color: var(--muted); }
.dish-votes strong { color: var(--ink); font-size: 19px; }
.vote-button { min-width: 55px; min-height: 42px; padding: 8px 11px; background: var(--green-soft); color: var(--green-dark); }
.vote-button.mine { background: var(--orange-soft); color: #984b27; }

.empty-state, .empty-state-small { color: var(--muted); text-align: center; line-height: 1.7; }
.empty-state { grid-column: 1 / -1; padding: 42px 15px; border: 1px dashed var(--line); border-radius: var(--radius-md); }
.empty-state-small { padding: 20px 12px; border: 1px dashed var(--line); border-radius: 14px; font-size: 13px; }

.history-list { display: grid; gap: 10px; margin-top: 16px; }
.history-day { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 18px; padding: 16px 0; border-top: 1px solid var(--line); }
.history-day:first-child { border-top: 0; }
.history-date { font-weight: 850; }
.history-date small { display: block; margin-top: 5px; color: var(--muted); font-weight: 500; }
.history-dishes { display: flex; flex-wrap: wrap; gap: 8px; }
.history-dish { padding: 7px 10px; border-radius: 999px; background: #f0ece3; font-size: 13px; }

.gate-banner, .lock-banner { padding: 17px 19px; margin-bottom: 18px; border-radius: var(--radius-md); line-height: 1.7; font-weight: 700; }
.gate-banner { color: #7b382b; background: var(--orange-soft); border: 1px solid #efc6ad; }
.lock-banner { color: var(--green-dark); background: var(--green-soft); border: 1px solid #bdd8c4; }

.two-column-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, .8fr); gap: 18px; }
.form-panel { align-self: start; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.absence-list { display: grid; gap: 10px; margin-top: 15px; }
.absence-item { padding: 13px 14px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.absence-item strong { display: block; }
.absence-time { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.absence-note { margin-top: 6px; font-size: 12px; }
.compact .absence-item { padding: 11px; }

.manager-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(310px, .7fr); gap: 18px; align-items: start; }
.manager-suggestion-list { display: grid; gap: 9px; margin-top: 16px; }
.manager-suggestion-item { padding: 14px; display: flex; align-items: center; gap: 12px; cursor: pointer; }
.manager-suggestion-item.selected { border-color: var(--green); background: #f1f8f3; }
.manager-suggestion-item input { width: 18px; height: 18px; accent-color: var(--green); }
.manager-suggestion-item .dish-info { flex: 1; }
.vote-count-badge { padding: 6px 9px; border-radius: 999px; background: var(--yellow-soft); font-size: 12px; font-weight: 800; }
.custom-menu-box { margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--line); }
.custom-add-row { display: grid; grid-template-columns: minmax(0, 1fr) 110px auto; gap: 8px; align-items: center; }
.selected-chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.selected-chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 999px; background: var(--orange-soft); font-size: 12px; }
.selected-chip button { border: 0; background: transparent; cursor: pointer; padding: 0; color: var(--red); }
.sticky-panel { position: sticky; top: 16px; }
.selected-preview { min-height: 110px; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px; padding: 13px; border: 1px dashed var(--line); border-radius: 14px; background: #f8f5ee; }
.preview-item { padding: 7px 9px; border-radius: 999px; background: white; border: 1px solid var(--line); font-size: 12px; }
.warning-copy { margin: 12px 0 0; color: var(--muted); font-size: 11px; line-height: 1.65; }

.confirm-dialog { border: 0; padding: 0; background: transparent; max-width: calc(100% - 28px); }
.confirm-dialog::backdrop { background: rgba(22, 25, 21, .55); backdrop-filter: blur(5px); }
.dialog-card { width: min(480px, 100%); padding: 30px; border-radius: 26px; background: var(--surface); box-shadow: 0 30px 80px rgba(0,0,0,.25); text-align: center; }
.dialog-icon { width: 54px; height: 54px; margin: 0 auto 18px; display: grid; place-items: center; border-radius: 50%; background: var(--orange-soft); color: var(--orange); font-size: 26px; font-weight: 900; }
.dialog-card p:not(.eyebrow) { color: var(--muted); line-height: 1.8; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }

.toast-stack { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 9px; width: min(360px, calc(100% - 36px)); }
.toast { padding: 14px 16px; border-radius: 14px; color: white; background: #28352d; box-shadow: 0 14px 34px rgba(0,0,0,.18); animation: toast-in .25s ease; line-height: 1.55; }
.toast.error { background: #8f3d34; }
.toast.success { background: var(--green-dark); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.hidden { display: none !important; }

@media (max-width: 920px) {
  .role-grid { grid-template-columns: 1fr; }
  .role-card { min-height: 230px; }
  .diner-layout, .two-column-layout, .manager-layout { grid-template-columns: 1fr; }
  .composer-panel, .sticky-panel { position: static; }
  .manager-sidebar { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
}

@media (max-width: 640px) {
  .topbar, main { width: min(100% - 20px, 1240px); }
  .topbar { padding: 14px 0; }
  .brand small { display: none; }
  .connection { padding: 8px 9px; }
  .connection span:last-child { font-size: 0; }
  .connection span:last-child::after { content: "云端"; font-size: 12px; }
  main { padding-top: 0; }
  .hero { padding: 42px 0 28px; }
  h1 { font-size: 40px; }
  .page-heading h1 { font-size: 38px; }
  .panel { padding: 19px; border-radius: 21px; }
  .role-card { padding: 20px; border-radius: 21px; }
  .dish-grid { grid-template-columns: 1fr; }
  .history-day { grid-template-columns: 1fr; gap: 10px; }
  .form-grid, .dialog-actions { grid-template-columns: 1fr; }
  .custom-add-row { grid-template-columns: 1fr 105px; }
  .custom-add-row button { grid-column: 1 / -1; }
  .manager-sidebar { grid-template-columns: 1fr; }
  .category-picker { grid-template-columns: repeat(2, 1fr); }
}
