:root {
  --bg: #f5f6fa;
  --card-bg: #ffffff;
  --primary: #4f7cff;
  --primary-dark: #3a63e0;
  --danger: #e74c3c;
  --success: #27ae60;
  --text: #2c3e50;
  --text-muted: #7f8c8d;
  --border: #e4e7ed;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --radius: 10px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", "Microsoft YaHei", -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 20px;
}

/* ===== Header ===== */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  background: var(--card-bg);
  padding: 16px 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.header-left h1 {
  font-size: 22px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 4px;
}

.search-box {
  margin-left: 12px;
}

.search-box input {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  width: 240px;
  outline: none;
  transition: all 0.15s;
  font-family: inherit;
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 124, 255, 0.12);
  width: 280px;
}

.dish-item.hidden {
  display: none;
}

.dish-item .match-highlight {
  background: #fff3a3;
  color: #b8860b;
  padding: 0 2px;
  border-radius: 3px;
}

.stall-card.no-match {
  display: none;
}

/* Storage bar */
.storage-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  background: var(--card-bg);
  padding: 10px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.storage-status {
  font-size: 13px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 6px;
}

.storage-status.active {
  background: #e8f5e9;
  color: var(--success);
}

.storage-status.warn {
  background: #fff8e1;
  color: #f57c00;
}

.storage-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.storage-notice {
  flex: 0 1 auto;
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: #a5342a;
  background: #fdecea;
  border: 1px solid #f5c6c2;
  border-radius: 6px;
  padding: 4px 12px;
}

.storage-notice strong {
  color: var(--danger);
  font-weight: 700;
}

.storage-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.storage-divider {
  color: var(--border);
  margin: 0 4px;
}

.btn-file {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 12px;
  font-size: 12px;
}

.btn-file:hover {
  background: #f0f4ff;
  border-color: var(--primary);
  color: var(--primary);
}

.btn-file.btn-file-danger {
  color: var(--danger);
}

.btn-file.btn-file-danger:hover {
  background: #fef0ef;
  border-color: var(--danger);
  color: var(--danger);
}

.print-file-row .btn[hidden] {
  display: none;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Meal toggle */
.meal-toggle {
  display: flex;
  background: var(--bg);
  border-radius: 8px;
  padding: 4px;
}

.meal-btn {
  border: none;
  background: transparent;
  padding: 8px 18px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.2s;
}

.meal-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(79, 124, 255, 0.35);
}

.action-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-import { background: var(--success); color: #fff; }
.btn-import:hover { background: #219a52; }

.btn-add { background: #16a085; color: #fff; }
.btn-add:hover { background: #13876f; }

.btn-export { background: #3498db; color: #fff; }
.btn-export:hover { background: #2980b9; }

.btn-template { background: #9b59b6; color: #fff; }
.btn-template:hover { background: #8e44ad; }

.btn-print { background: #e67e22; color: #fff; }
.btn-print:hover { background: #d35400; }

.btn-clear { background: #fff; color: var(--danger); border: 1px solid var(--border); }
.btn-clear:hover { background: #fef0ef; }

.btn-cancel { background: #ecf0f1; color: var(--text); }
.btn-cancel:hover { background: #dfe6e9; }

/* ===== Stalls grid ===== */
.stalls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.stall-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s;
}

.stall-card:hover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}

.stall-header {
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.stall-drag-handle {
  color: rgba(255, 255, 255, 0.7);
  font-size: 15px;
  line-height: 1;
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
}

.stall-drag-handle:active {
  cursor: grabbing;
}

.stall-sortable-ghost {
  opacity: 0.4;
}

.stall-sortable-chosen {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.stall-name {
  font-size: 16px;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stall-count {
  font-size: 12px;
  background: rgba(255, 255, 255, 0.25);
  padding: 2px 10px;
  border-radius: 12px;
}

.stall-body {
  flex: 1;
  padding: 8px;
  min-height: 80px;
}

.dish-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dish-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #f8f9fb;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: grab;
  transition: all 0.15s;
  position: relative;
}

.dish-item:hover {
  background: #eef2ff;
  border-color: #c7d2fe;
}

.dish-item:active {
  cursor: grabbing;
}

.dish-item.sortable-ghost {
  opacity: 0.4;
  background: #dfe7ff;
}

.dish-item.sortable-chosen {
  box-shadow: 0 4px 12px rgba(79, 124, 255, 0.3);
  transform: scale(1.01);
}

.drag-handle {
  color: #b0b8c4;
  font-size: 16px;
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
}

.dish-info {
  flex: 1;
  min-width: 0;
}

.dish-zh {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dish-en {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-style: italic;
}

.dish-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.icon-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-muted);
  transition: all 0.15s;
}

.icon-btn:hover {
  background: #fff;
  color: var(--primary);
}

.icon-btn.del:hover {
  color: var(--danger);
  background: #fef0ef;
}

.add-dish-row {
  list-style: none;
  margin-top: 8px;
  padding: 0 4px;
}

.stall-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}

.add-dish-btn {
  width: 100%;
  padding: 8px;
  border: 1px dashed #b0b8c4;
  background: #fafbfc;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}

.add-dish-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #f0f4ff;
}

.empty-hint {
  text-align: center;
  padding: 24px 12px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ===== Modal ===== */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.show {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 460px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  animation: modalIn 0.2s ease;
}

.modal-wide {
  max-width: 680px;
}

@keyframes modalIn {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 17px;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  border-radius: 6px;
}

.modal-close:hover {
  background: var(--bg);
  color: var(--text);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ===== Help Modal ===== */
.help-content {
  max-height: 62vh;
  overflow-y: auto;
  line-height: 1.7;
}

.help-content h4 {
  font-size: 14px;
  color: var(--primary-dark);
  margin: 16px 0 6px;
}

.help-content h4:first-child {
  margin-top: 0;
}

.help-content ul {
  padding-left: 20px;
}

.help-content li {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 4px;
}

.help-content code {
  background: #f0f3f9;
  padding: 1px 5px;
  border-radius: 4px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  color: #444;
}

.help-tip {
  margin-top: 16px;
  padding: 10px 12px;
  background: #f0f7ff;
  border-left: 3px solid var(--primary);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
}

.form-group {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.form-group input,
.form-group select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border 0.15s;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 124, 255, 0.12);
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

.translate-row {
  display: flex;
  gap: 8px;
}

.translate-row input {
  flex: 1;
}

/* 菜品名输入联想 */
.suggest-wrap {
  position: relative;
  flex: 1;
  display: flex;
}

.suggest-list {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  list-style: none;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  z-index: 10;
}

.suggest-list.show {
  display: block;
}

.suggest-item {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

.suggest-item.active,
.suggest-item:hover {
  background: #eef2ff;
}

.suggest-text {
  flex: 1;
  min-width: 0;
}

.suggest-zh {
  font-size: 14px;
  font-weight: 600;
}

.suggest-en {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

.suggest-tag {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.btn-translate {
  white-space: nowrap;
  padding: 9px 14px;
}

.translate-result {
  margin-top: 8px;
  padding: 10px 12px;
  background: #f0f7ff;
  border: 1px solid #c7e0ff;
  border-radius: 6px;
  font-size: 13px;
  display: none;
  cursor: pointer;
  transition: all 0.15s;
}

.translate-result.show {
  display: block;
}

.translate-result:hover {
  background: #e0efff;
  border-color: var(--primary);
}

.translate-result .result-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.translate-result .result-text {
  color: var(--primary);
  font-weight: 600;
}

.translate-result.loading {
  color: var(--text-muted);
  cursor: default;
}

.translate-result.error {
  background: #fef0ef;
  border-color: #f5c6c0;
  color: var(--danger);
  cursor: default;
}


/* Import modal */
.import-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.import-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.radio-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}

.import-preview {
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

.preview-table th {
  background: #f8f9fb;
  font-weight: 600;
  position: sticky;
  top: 0;
}

.preview-table tr:last-child td {
  border-bottom: none;
}

.preview-table td.en {
  color: var(--text-muted);
  font-style: italic;
}

/* Print modal */
.print-file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.print-template-select {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  min-width: 220px;
  cursor: pointer;
  outline: none;
  transition: all 0.15s;
}

.print-template-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 124, 255, 0.12);
}

/* 档口多选复选框 */
.stall-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafbfc;
  max-height: 180px;
  overflow-y: auto;
}

.check-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.check-item:hover {
  border-color: var(--primary);
}

.check-item input[type="checkbox"] {
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.check-item:has(input:checked) {
  border-color: var(--primary);
  background: #eef2ff;
  color: var(--primary);
}

.check-item.check-all {
  align-self: flex-start;
  font-weight: 600;
}

.check-count {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}


.print-file-name {
  font-size: 13px;
  color: var(--text-muted);
  flex: 1;
  min-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.print-template-tip {
  background: #f0f6ff;
  border: 1px solid #d6e4ff;
  border-left: 3px solid var(--primary);
  border-radius: 8px;
  padding: 10px 14px;
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.8;
  color: #4a5b73;
}

.print-template-tip strong {
  color: var(--text);
}

.preview-table td.zh {
  font-weight: 500;
}

.preview-table td.empty {
  color: var(--text-muted);
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  background: #eef2ff;
  color: var(--primary);
  font-weight: 600;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: var(--text);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  z-index: 2000;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ===== 重复菜品提示 ===== */
.dup-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  background: var(--card-bg);
  padding: 10px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  font-size: 13px;
}

.dup-bar.ok {
  color: var(--success);
  font-weight: 600;
}

.dup-bar.warn {
  border-left: 4px solid #f0a020;
}

.dup-bar-title {
  font-weight: 600;
  color: #d35400;
}

.dup-bar-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dup-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  border: 1px solid #ffd9a3;
  background: #fff8ee;
  color: #b35c00;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.dup-chip:hover {
  background: #ffefd6;
  border-color: #f0a020;
}

.dup-chip-names {
  font-weight: 400;
  color: #8a6d3b;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stall-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stall-dup-flag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  color: #c0392b;
  white-space: nowrap;
}

.dish-item.duplicate {
  background: #fff5f4;
  border-color: #f5c6c0;
}

.dish-item.duplicate:hover {
  background: #ffeceb;
  border-color: #eda39c;
}

.dish-item.name-mismatch {
  background: #fffaf0;
  border-color: #ffdfa8;
}

.dish-item.name-mismatch:hover {
  background: #fff4e0;
  border-color: #f0c27b;
}

.dup-badge {
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: #fdecea;
  color: #c0392b;
  border: 1px solid #f5c6c0;
}

.dup-badge.warn {
  background: #fff4e0;
  color: #b35c00;
  border-color: #ffdfa8;
}

@keyframes dupFlash {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.5); }
}

.dish-item.flash {
  animation: dupFlash 0.8s ease 2;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #c8ccd4;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a8adb8;
}

/* Responsive */
@media (max-width: 600px) {
  .stalls-grid {
    grid-template-columns: 1fr;
  }
  .app-header {
    padding: 12px 16px;
  }
  .header-left h1 {
    font-size: 18px;
  }
}
