:root {
  --bg: #f6f7f3;
  --surface: #ffffff;
  --ink: #12341b;
  --text: #243026;
  --muted: #6f776f;
  --border: #dde2da;
  --primary: #12341b;
  --green: #386939;
  --soft: #e5ede0;
  --soft-strong: #d8e5d3;
  --accent: #c0b58e;
  --silver: #c7c9c9;
  --danger: #a04436;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

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

a { color: var(--primary); }

/* ===== 登录 ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 10%, rgba(192,181,142,.24), transparent 30%),
    linear-gradient(145deg, #f6f7f3 0%, #e5ede0 100%);
}
.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 34px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-brand { margin-bottom: 6px; }
.login-card h1 {
  margin: 0;
  color: var(--ink);
  font-size: 26px;
  line-height: 1.2;
}
.login-card p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
}
.login-error {
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff0f0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}
.login-submit {
  justify-content: center;
  margin-top: 8px;
  padding: 12px 18px;
}

/* ===== 布局 ===== */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; min-width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 20px 20px; border-bottom: 1px solid var(--border); }
.brand-mark {
  width: 42px; height: 42px; border-radius: 10px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700;
}
.brand-title { display: block; font-size: 16px; font-weight: 700; color: var(--ink); }
.brand-subtitle { display: block; font-size: 12px; color: var(--muted); }
.nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-button {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 20px;
  border: none; background: none;
  font-size: 15px; color: var(--text); cursor: pointer;
  text-align: left; transition: background .15s;
}
.nav-button:hover { background: var(--soft); }
.nav-button.active { background: var(--soft-strong); font-weight: 700; color: var(--ink); }
.nav-icon { font-size: 18px; width: 26px; text-align: center; }

.content { flex: 1; padding: 32px 36px 80px; overflow-y: auto; }

.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface); border-top: 1px solid var(--border);
  z-index: 100;
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 14px; font-weight: 600; color: var(--text);
  cursor: pointer; transition: all .15s;
}
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { opacity: .88; }
.btn.soft { background: var(--soft); border-color: var(--soft); color: var(--ink); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.loading { opacity: .5; pointer-events: none; }

/* ===== 卡片 ===== */
.panel { background: var(--surface); border-radius: 12px; border: 1px solid var(--border); margin-top: 18px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.page-title { font-size: 22px; font-weight: 700; color: var(--ink); margin: 0; }
.page-desc { font-size: 14px; color: var(--muted); margin: 4px 0 0; }

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

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 220px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}
.user-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-chip-role {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.publish-badge {
  min-width: 178px;
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.publish-badge span { font-size: 13px; font-weight: 700; color: var(--ink); }
.publish-badge small { font-size: 11px; color: var(--muted); line-height: 1.35; }
.publish-badge.published { background: var(--soft); border-color: var(--soft-strong); }
.publish-badge.dirty { background: #fff9e8; border-color: var(--accent); }
.publish-badge.failed { background: #fff0f0; border-color: #e7b9b1; }
.publish-badge.failed span { color: var(--danger); }
.publish-badge.publishing { background: var(--soft); opacity: .7; }

/* ===== 统计卡片 ===== */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-top: 14px; }
.stats-grid.compact { grid-template-columns: repeat(4,1fr); }
.stat-card { background: var(--surface); border-radius: 10px; border: 1px solid var(--border); padding: 20px; }
.stat-number { display: block; font-size: 28px; font-weight: 700; color: var(--ink); }
.stat-label { display: block; font-size: 13px; color: var(--muted); margin-top: 4px; }

.config-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 16px; margin-top: 18px; }
.config-card { background: var(--surface); border-radius: 10px; border: 1px solid var(--border); padding: 22px; }
.config-card h2 { font-size: 16px; font-weight: 700; margin: 0 0 12px; color: var(--ink); }

/* ===== 表格 ===== */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
.table th { font-weight: 700; color: var(--muted); font-size: 13px; background: var(--soft); }
.item-title { font-size: 15px; font-weight: 600; color: var(--ink); }
.item-subtitle { font-size: 13px; color: var(--muted); }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); font-size: 14px; }
.row-actions { display: flex; gap: 8px; }

/* ===== 标签 ===== */
.pill {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600; background: var(--soft); color: var(--ink);
}
.pill.off { background: var(--silver); color: var(--muted); }
.pill.danger { background: #fce4e4; color: var(--danger); }

/* ===== 工具栏 ===== */
.toolbar { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; gap: 12px; }
.filters { display: flex; gap: 10px; align-items: center; flex: 1; }

/* ===== 表单 ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row.full { grid-column: 1 / -1; }
.label { font-size: 13px; font-weight: 600; color: var(--ink); }
.input, .select, .textarea {
  padding: 10px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 14px; color: var(--text); outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); }
.textarea { min-height: 80px; resize: vertical; }

/* ===== 上传 ===== */
.upload-row { display: flex; flex-direction: column; gap: 8px; }
.upload-tip { font-size: 13px; color: var(--muted); }
.upload-preview { max-width: 200px; max-height: 160px; border-radius: 8px; border: 1px solid var(--border); object-fit: cover; display: none; }
.upload-preview.visible { display: block; }
.image-spec { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.6; }

/* ===== 多图管理 ===== */
.image-list { display: flex; flex-direction: column; gap: 8px; }
.image-list-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg);
}
.image-list-item img {
  width: 80px; height: 56px; object-fit: cover; border-radius: 6px;
  flex-shrink: 0;
}
.image-list-path {
  flex: 1; font-size: 12px; color: var(--muted);
  word-break: break-all; min-width: 0;
}
.btn.small {
  padding: 4px 10px; font-size: 16px; line-height: 1;
  flex-shrink: 0;
}

/* ===== 图片网格 ===== */
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 16px; padding: 20px; }
.image-card { background: var(--surface); border-radius: 10px; border: 1px solid var(--border); overflow: hidden; }
.image-preview {
  height: 180px; background: var(--soft);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.image-preview img { width: 100%; height: 100%; object-fit: cover; }
.image-preview span { color: var(--muted); font-size: 13px; }
.image-card-body { padding: 14px; }
.image-path { font-size: 12px; color: var(--muted); word-break: break-all; margin: 4px 0 8px; }

/* ===== 弹窗 ===== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 200; display: flex; align-items: center; justify-content: center;
}
.modal {
  background: var(--surface); border-radius: 14px;
  max-width: 680px; width: 92%; max-height: 85vh;
  overflow-y: auto; box-shadow: 0 12px 40px rgba(0,0,0,.18);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 18px; font-weight: 700; margin: 0; }
.modal-body { padding: 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border); }

/* ===== Toast ===== */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 9999; padding: 12px 28px; border-radius: 8px;
  font-size: 15px; font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  animation: toastIn .25s ease; pointer-events: none;
}
.toast.success { background: #1a3520; color: #fff; }
.toast.error   { background: #a04436; color: #fff; }
.toast.info    { background: #12341b; color: #fff; }
@keyframes toastIn { from { opacity:0; transform: translateX(-50%) translateY(-12px); } to { opacity:1; transform: translateX(-50%) translateY(0); } }

/* ===== 确认弹窗 ===== */
.confirm-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 9000; display: flex; align-items: center; justify-content: center;
}
.confirm-box {
  background: #fff; border-radius: 12px; padding: 32px;
  max-width: 380px; width: 90%; box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.confirm-box h3 { margin: 0 0 12px; font-size: 18px; color: var(--ink); }
.confirm-box p { margin: 0 0 24px; font-size: 14px; color: var(--muted); }
.confirm-actions { display: flex; gap: 12px; justify-content: flex-end; }

/* ===== Hero 轮播图 ===== */
.hero-images-editor { margin-bottom: 4px; }
.hero-image-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0; border-bottom: 1px solid var(--border);
}
.hero-image-row:last-child { border-bottom: none; }
.hero-image-thumb {
  width: 120px; height: 80px; border-radius: 8px;
  object-fit: cover; flex-shrink: 0;
  border: 1px solid var(--border);
}
.hero-image-path {
  flex: 1; font-size: 12px; color: var(--muted);
  word-break: break-all;
}

/* ===== 首页排序行 ===== */
.home-sort-row {
  display: flex; align-items: center; gap: 6px;
}
.home-sort-num {
  width: 22px; text-align: center; font-size: 12px;
  font-weight: 700; color: var(--primary); flex-shrink: 0;
}
.home-sort-btn {
  width: 24px; height: 24px; padding: 0; border: 1px solid var(--border);
  border-radius: 4px; background: var(--surface);
  font-size: 10px; color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.home-sort-btn:hover:not(:disabled) { background: var(--soft); color: var(--ink); }
.home-sort-btn:disabled { opacity: .3; cursor: default; }
.home-sort-divider {
  padding: 8px 10px; font-size: 12px; color: var(--muted);
  border-top: 1px dashed var(--border); margin-top: 4px;
}

/* ===== 复选框列表 ===== */
.check-list { display: flex; flex-direction: column; gap: 6px; max-height: 420px; overflow-y: auto; }
.check-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
}
.check-row:hover { background: var(--soft); }
.publish-dirty-badge {
  display: inline-block; padding: 2px 10px; border-radius: 12px;
  background: #fef3c7; color: #92400e; font-size: 12px; font-weight: 700;
  margin-left: 2px;
}

/* ===== 移动端卡片 ===== */
.mobile-list { display: none; }
.mobile-card {
  background: var(--surface); border-radius: 10px; border: 1px solid var(--border);
  padding: 16px; margin: 10px 20px;
}
.mobile-card-head { display: flex; justify-content: space-between; align-items: flex-start; }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .layout { display: flex; flex-direction: column; }
  .sidebar { display: none; }
  .bottom-nav {
    display: flex;
    justify-content: space-around;
    order: 1;
    position: sticky;
    top: 0;
    bottom: auto;
    padding: 8px 0;
    z-index: 80;
  }
  .bottom-nav .nav-button { flex-direction: column; gap: 3px; font-size: 11px; padding: 6px; }
  .bottom-nav .nav-icon { font-size: 20px; }
  .content { order: 2; padding: 16px 16px 48px; }
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .config-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .table-wrap { display: none; }
  .mobile-list { display: block; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .page-head { flex-direction: column; gap: 12px; }
  .user-chip { width: 100%; max-width: none; justify-content: space-between; }
  .modal { max-width: 100%; width: 100%; max-height: 100vh; border-radius: 0; }
}

/* ===== 导入攻略 ===== */
.import-textarea {
  width: 100%; min-height: 160px; padding: 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 15px; line-height: 1.7; color: var(--text);
  resize: vertical; outline: none;
}
.import-textarea:focus { border-color: var(--primary); }

.import-row-card {
  display: flex; gap: 14px; align-items: center;
  padding: 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  margin-top: 10px;
}
.import-thumb {
  width: 72px; height: 54px; border-radius: 8px;
  object-fit: cover; flex-shrink: 0;
}
.import-thumb-empty {
  width: 72px; height: 54px; border-radius: 8px;
  background: var(--soft); display: flex;
  align-items: center; justify-content: center;
  font-size: 24px; flex-shrink: 0;
}
.import-row-main { display: flex; flex-direction: column; gap: 4px; }
.import-row-name { font-size: 15px; font-weight: 700; color: var(--ink); }
.import-row-meta { font-size: 13px; color: var(--muted); }

.import-tag-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; margin-bottom: 10px; }

/* ===== 路线地点编排预览 ===== */
.route-spots-preview {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px; background: var(--soft); border-radius: 10px;
}
.route-spots-day {
  display: flex; gap: 10px; align-items: flex-start;
}
.route-spots-day-label {
  font-size: 13px; font-weight: 700; color: var(--primary);
  background: var(--surface); padding: 2px 10px; border-radius: 6px;
  white-space: nowrap; flex-shrink: 0;
}
.route-spots-day-items {
  font-size: 13px; color: var(--ink); line-height: 1.8;
}
.route-spot-chip {
  display: inline-block; padding: 1px 8px; margin: 0 2px;
  border-radius: 4px; background: var(--surface);
  font-weight: 600;
}
.route-spot-chip:not(:last-child)::after {
  content: ' →'; color: var(--muted); font-weight: 400; margin-left: 2px;
}

/* ===== spots 编辑器 ===== */
.spot-day-group {
  margin-top: 14px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface);
  overflow: hidden;
}
.spot-day-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: var(--soft);
}
.spot-day-label { font-weight: 700; font-size: 14px; color: var(--ink); }
.spot-day-count { font-size: 12px; color: var(--muted); }

.spot-list { padding: 4px 8px; }
.spot-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 6px; border-bottom: 1px solid var(--border);
}
.spot-row:last-child { border-bottom: none; }
.spot-arrows {
  display: flex; flex-direction: column; gap: 2px;
  width: 22px; flex-shrink: 0;
}
.spot-btn {
  width: 22px; height: 18px; padding: 0; border: 1px solid var(--border);
  border-radius: 3px; background: var(--surface);
  font-size: 8px; color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.spot-btn:hover { background: var(--soft); color: var(--ink); }
.spot-btn-spacer { width: 22px; height: 18px; }
.spot-index {
  width: 22px; text-align: center; font-size: 12px; font-weight: 700;
  color: var(--muted); flex-shrink: 0;
}
.spot-name { flex: 1; font-size: 14px; font-weight: 600; color: var(--ink); }
.spot-day-select {
  width: 100px; padding: 4px 8px; font-size: 12px; flex-shrink: 0;
}
.spot-remove {
  padding: 2px 8px; font-size: 14px; line-height: 1;
  flex-shrink: 0;
}
.spot-add-day {
  margin: 8px; padding: 6px 14px; font-size: 13px;
}

/* ===== 地点选择器 ===== */
.spot-picker {
  margin-top: 10px; padding: 10px;
  border: 1px solid var(--primary); border-radius: 10px;
  background: var(--surface);
}
.spot-picker-search { width: 100%; margin-bottom: 8px; }
.spot-picker-list {
  max-height: 240px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
}
.spot-picker-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
  border: 1px solid transparent;
}
.spot-picker-item:hover { background: var(--soft); border-color: var(--border); }
.spot-picker-name { font-size: 14px; font-weight: 600; color: var(--ink); }
.spot-picker-meta { font-size: 12px; color: var(--muted); }

/* ===== 地点图片网格 ===== */
.place-images-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px; margin-top: 8px;
}
.place-image-card {
  position: relative; aspect-ratio: 4/3;
  border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border); background: var(--soft);
}
.place-image-card img {
  width: 100%; height: 100%; object-fit: cover;
}
.place-image-card.is-new {
  border-color: var(--primary); border-style: dashed;
}
.place-image-card.is-add {
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; border-style: dashed;
}
.place-image-card.is-add:hover { background: var(--soft-strong); }
.place-image-card.is-add span { font-size: 28px; color: var(--muted); }
.place-img-remove {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; padding: 0; border: none;
  border-radius: 50%; background: rgba(0,0,0,.55); color: #fff;
  font-size: 14px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.place-img-remove:hover { background: var(--danger); }
