:root {
  --bg: #f3f5f9;
  --panel: #fff;
  --acc: #1677ff;
  --acc-hover: #0958d9;
  --acc-light: #e6f4ff;
  --text: #1a1a2e;
  --sub: #6b7280;
  --mute: #9ca3af;
  --border: #e5e7eb;
  --border-soft: #f0f1f3;
  --meat: #ef4444;
  --veg: #22c55e;
  --staple: #f59e0b;
  --danger: #dc2626;
  --success: #16a34a;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.04);
  --radius: 14px;
  --tabbar-h: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  overflow-x: hidden;
  min-height: 100vh;
}
input, button, select { font-family: inherit; font-size: inherit; }
.hidden { display: none !important; }

/* ============== 登录 ============== */
.login-screen {
  min-height: 100vh;
  background: linear-gradient(135deg, #1677ff, #6c3ce0);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-box {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 20px;
  padding: 32px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  text-align: center;
}
.login-logo {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--acc-light);
  color: var(--acc);
  font-size: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.login-box h1 { font-size: 22px; }
.login-sub { color: var(--sub); font-size: 13px; margin: 4px 0 22px; }
.login-box input {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  margin-bottom: 12px;
  outline: none;
}
.login-box input:focus { border-color: var(--acc); }
.login-box button {
  width: 100%;
  padding: 14px;
  background: var(--acc);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 15px;
}
.login-err { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 12px; }

/* ============== 主框架 ============== */
.app {
  min-height: 100vh;
  padding-bottom: var(--tabbar-h);
}

.page { display: none; }
.page.active { display: block; }

.page-head {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #fff;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}
.page-head h1 { flex: 1; font-size: 17px; font-weight: 600; }
.back-btn, .head-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--sub);
  cursor: pointer;
}
.back-btn:active, .head-btn:active { background: #f5f5f5; }

/* ============== 排菜·周视图 ============== */
.week-view { padding: 14px 16px; }
.day-view { padding: 14px 16px; }

.week-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.week-nav .nav-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--sub);
}
.week-nav .week-range {
  flex: 1;
  text-align: center;
  font-weight: 500;
  font-size: 13px;
}

.week-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.chip-btn {
  padding: 8px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.chip-btn:active { background: var(--acc-light); color: var(--acc); border-color: var(--acc); }

.day-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.day-card {
  background: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s;
}
.day-card:active { transform: scale(0.98); }
.day-card.today {
  background: var(--acc-light);
  border: 1.5px solid var(--acc);
}
.day-card .left {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 50px;
  flex-shrink: 0;
}
.day-card .dow { font-size: 11px; color: var(--sub); }
.day-card .date {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}
.day-card.today .date { color: var(--acc); }

.day-card .mid {
  flex: 1;
  min-width: 0;
}
.day-card .summary {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
}
.day-card .summary .pill {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 600;
}
.day-card .summary .pill.meat { background: #fff5f5; color: var(--meat); }
.day-card .summary .pill.veg { background: #f0fdf4; color: var(--veg); }
.day-card .summary .pill.staple { background: #fffbeb; color: var(--staple); }
.day-card .preview {
  font-size: 12px;
  color: var(--sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.day-card.empty .preview { color: var(--mute); font-style: italic; }

.day-card .right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 11px;
}
.day-card .vote-cnt {
  color: var(--sub);
  display: flex;
  align-items: center;
  gap: 3px;
}
.day-card i { color: var(--mute); }

.week-tip {
  margin-top: 14px;
  font-size: 12px;
  color: var(--sub);
  text-align: center;
}
.week-tip b { color: var(--acc); }

/* ============== 排菜·单日编辑 ============== */
.day-summary {
  background: linear-gradient(135deg, #1677ff, #6c3ce0);
  color: #fff;
  border-radius: 16px;
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  box-shadow: 0 6px 20px rgba(22, 119, 255, 0.25);
}
.day-summary-l .day-date { font-size: 26px; font-weight: 700; }
.day-summary-l .day-dow { font-size: 13px; opacity: 0.85; }
.day-summary-r { text-align: right; font-size: 13px; }
.day-summary-r b { font-size: 18px; margin: 0 2px; }
.day-summary-r .price { margin-top: 4px; opacity: 0.85; }
.day-summary-r .price b { color: #ffdf81; }

.day-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.btn-action {
  padding: 10px 18px;
  background: var(--acc);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.btn-action:disabled { background: var(--mute); }
.btn-action.full { width: 100%; justify-content: center; }
.btn-danger {
  padding: 10px 18px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-weight: 600;
}
.btn-danger.full { width: 100%; }

.cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.cat-dot.meat { background: var(--meat); }
.cat-dot.veg { background: var(--veg); }
.cat-dot.staple { background: var(--staple); }

.day-section { margin-bottom: 18px; }
.day-section h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--sub);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-soft);
}
.sec-cnt {
  margin-left: auto;
  background: #f5f5f5;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 8px;
  color: var(--sub);
}

.day-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.day-chip {
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
}
.day-chip .name { flex: 1; font-weight: 500; }
.day-chip .price { color: var(--meat); font-size: 12px; }
.day-chip .rm-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #fff2f0;
  border: none;
  color: var(--danger);
}

.add-row-btn {
  width: 100%;
  padding: 12px;
  background: #fff;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  color: var(--sub);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}
.add-row-btn:active { border-color: var(--acc); color: var(--acc); }

/* ============== 菜品库 page ============== */
.search-bar {
  margin: 12px 16px;
  padding: 10px 14px;
  background: #fff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
}
.search-bar i { color: var(--sub); }
.search-bar input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
}

.filter-row {
  padding: 0 16px;
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.filter-chip {
  padding: 6px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: 12px;
  color: var(--sub);
  cursor: pointer;
}
.filter-chip.active { background: var(--acc); color: #fff; border-color: var(--acc); }

.dish-cards {
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dish-card-mob {
  background: #fff;
  border-radius: 12px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.dish-card-mob.disabled .dish-name-mob { text-decoration: line-through; color: var(--mute); }
.dish-card-mob .dish-name-mob { flex: 1; font-weight: 500; }
.dish-card-mob .dish-price-mob { color: var(--sub); font-size: 12px; }
.dish-card-mob .dish-on { font-size: 11px; padding: 2px 6px; border-radius: 4px; }
.dish-card-mob .dish-on.on { background: #dcfce7; color: #16a34a; }
.dish-card-mob .dish-on.off { background: #f3f4f6; color: #9ca3af; }

/* ============== 投票 page ============== */
.vote-date-bar {
  margin: 12px 16px;
  padding: 12px 14px;
  background: #fff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
}
.vote-date-bar input[type=date] {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  background: transparent;
}
.vote-stat-summary {
  font-size: 12px;
  color: var(--sub);
}
.vote-stat-summary b { color: var(--acc); margin: 0 2px; }

.vote-tabs {
  display: flex;
  margin: 0 16px 12px;
  background: #fff;
  border-radius: 10px;
  padding: 3px;
  box-shadow: var(--shadow);
}
.vote-tab {
  flex: 1;
  padding: 8px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--sub);
  font-weight: 500;
}
.vote-tab.active { background: var(--acc); color: #fff; }

.vote-panel { padding: 0 16px; }
.vote-cat-block { margin-bottom: 16px; }
.vote-cat-title {
  font-size: 12px;
  color: var(--sub);
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.rank-mob-row {
  background: #fff;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 6px;
  box-shadow: var(--shadow);
}
.rank-mob-name {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 13px;
}
.rank-mob-name b { color: var(--acc); }
.rank-mob-bar {
  height: 8px;
  background: #f0f1f3;
  border-radius: 4px;
  overflow: hidden;
}
.rank-mob-fill {
  height: 100%;
  border-radius: 4px;
}
.rank-mob-fill.meat { background: var(--meat); }
.rank-mob-fill.veg { background: var(--veg); }
.rank-mob-fill.staple { background: var(--staple); }

.voters-list { list-style: none; padding: 0 16px; }
.voter-item-mob {
  background: #fff;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 6px;
  box-shadow: var(--shadow);
}
.voter-head-mob {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  align-items: center;
}
.voter-name-mob {
  font-weight: 600;
  color: var(--acc);
  font-size: 13px;
}
.voter-price-mob { color: var(--meat); margin-left: 4px; font-size: 12px; font-weight: 400; }
.voter-time-mob { font-size: 11px; color: var(--mute); }
.voter-dishes-mob { font-size: 12px; color: var(--sub); line-height: 1.4; }
.voter-dishes-mob b { color: var(--text); }

/* ============== 我的 ============== */
.me-block {
  background: #fff;
  margin: 12px 16px;
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.me-block h4 { font-size: 14px; margin-bottom: 12px; }
.me-row {
  display: grid;
  grid-template-columns: 70px 1fr;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.me-row label { color: var(--sub); font-size: 13px; }
.me-row input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
}
.me-row input:focus { border-color: var(--acc); }

.logout-btn {
  width: calc(100% - 32px);
  margin: 12px 16px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--danger);
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* ============== 底部 tab bar ============== */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: var(--tabbar-h);
  background: #fff;
  display: flex;
  border-top: 1px solid var(--border);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-item {
  flex: 1;
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--sub);
  font-size: 11px;
}
.tab-item i { font-size: 20px; }
.tab-item.active { color: var(--acc); font-weight: 600; }

/* ============== Sheet (从下方滑入) ============== */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
}
.sheet.active { display: block; }
.sheet-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.sheet-body {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  max-height: 85vh;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 18px;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
  animation: slideUp 0.2s ease;
}
.sheet-mini { max-height: auto; }
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.sheet-head h3 { font-size: 16px; font-weight: 600; }
.close-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #f5f5f5;
  border: none;
  color: var(--sub);
}

.sheet-search {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  margin-bottom: 12px;
}
.sheet-search:focus { border-color: var(--acc); }

.pick-list-mob {
  flex: 1;
  overflow-y: auto;
  margin: 0 -6px;
}
.pick-item-mob {
  padding: 12px 14px;
  margin: 4px 6px;
  background: #f8f9fa;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.pick-item-mob.disabled { opacity: 0.5; }
.pick-item-mob.selected { background: var(--acc-light); border: 1.5px solid var(--acc); }
.pick-item-mob .price { color: var(--meat); margin-left: auto; font-size: 12px; }
.pick-item-mob .check {
  color: var(--success);
  display: none;
  font-size: 16px;
}
.pick-item-mob.selected .check { display: inline; }

.form-row {
  margin-bottom: 12px;
}
.form-row label {
  display: block;
  font-size: 12px;
  color: var(--sub);
  margin-bottom: 4px;
}
.form-row input, .form-row select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
}
.form-row input:focus, .form-row select:focus { border-color: var(--acc); }

.sheet-foot {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.copy-list-mob {
  overflow-y: auto;
  max-height: 60vh;
}
.copy-row-mob {
  padding: 12px 14px;
  background: #f8f9fa;
  border-radius: 10px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}
.copy-row-mob:active { background: var(--acc-light); }

.big-action {
  width: 100%;
  padding: 14px;
  background: var(--acc-light);
  color: var(--acc);
  border: 1px solid var(--acc);
  border-radius: 10px;
  font-weight: 500;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* ============== Toast ============== */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(8px); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* 滚动条 */
::-webkit-scrollbar { width: 0; }
