:root {
  --bg: #f6f4ef;
  --panel: #ffffff;
  --ink: #2b2a26;
  --muted: #8a8679;
  --line: #e6e1d6;
  --accent: #3f7d5a;
  --accent-ink: #ffffff;
  --warn: #b7791f;
  --warn-bg: #fdf3e0;
  --danger: #b3453a;
  --danger-bg: #fbeceb;
  --ok: #2f6b4f;
  --ok-bg: #eaf4ec;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(40, 36, 24, 0.06), 0 4px 14px rgba(40, 36, 24, 0.06);
  font-size: 15px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  line-height: 1.55;
}

/* 顶栏 */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 26px; }
.brand h1 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: .5px; }
.sub { margin: 0; font-size: 12px; color: var(--muted); }

.tabs { display: flex; gap: 4px; }
.tabs button {
  border: 0; background: transparent; color: var(--muted);
  padding: 8px 16px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600;
}
.tabs button:hover { background: #f0ede6; color: var(--ink); }
.tabs button.active { background: var(--accent); color: var(--accent-ink); }

main { max-width: 1180px; margin: 0 auto; padding: 20px; }
.panel { display: none; }
.panel.active { display: block; }

/* 通用 */
.muted { color: var(--muted); font-size: 13px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
h2.sec { font-size: 15px; margin: 4px 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }

.btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.btn:hover { background: #f0ede6; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #356c4d; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { padding: 4px 10px; font-size: 12px; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
}
.badge.demo { background: var(--warn-bg); color: var(--warn); }
.badge.confirmed { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.derived { background: #eef0f5; color: #5a6072; }

/* 总览 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.stat { display: flex; flex-direction: column; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 22px; font-weight: 700; margin: 2px 0; }
.stat .v.small { font-size: 15px; }

.kv { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 600; text-align: right; }

.file-row { display: flex; justify-content: space-between; font-size: 12.5px; padding: 5px 0; }
.file-row .p { color: var(--muted); font-family: ui-monospace, Menlo, monospace; font-size: 11px; }

/* 菜单 */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.toolbar input { flex: 1; max-width: 420px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }

.dish { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.dish .info { flex: 1; min-width: 0; }
.dish .name { font-weight: 700; font-size: 15px; }
.dish .name .cat { color: var(--muted); font-weight: 500; font-size: 12px; margin-left: 6px; }
.dish .meta { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.dish .meta .tag { padding: 1px 7px; background: #f0ede6; border-radius: 6px; }
.dish .price { font-weight: 700; font-size: 14px; white-space: nowrap; }
.evidence { margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.evidence .src { font-family: ui-monospace, Menlo, monospace; }
.evidence .gap { color: var(--warn); }
.missing { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.missing .m { font-size: 11.5px; color: var(--warn); background: var(--warn-bg); padding: 1px 7px; border-radius: 6px; }
.note { font-size: 12px; color: var(--muted); margin-top: 5px; }
.note b { color: var(--ink); }
.dish .actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }

/* 政策 */
.policy-banner { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 14px; font-size: 13.5px; }
.policy-banner.demo { background: var(--warn-bg); border: 1px solid #ecd9ae; }
.policy-banner.confirmed { background: var(--ok-bg); border: 1px solid #c8e0cf; }
.policy-banner .t { font-weight: 700; margin-bottom: 2px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; font-family: inherit;
}
.field textarea { min-height: 60px; resize: vertical; }
.field .hint { font-size: 11px; color: var(--muted); margin-top: 2px; }
.field.row { grid-column: 1 / -1; }
.toggle-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 14px; }
.toggle-row input[type=checkbox] { width: 18px; height: 18px; }

.rooms-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rooms-table th, .rooms-table td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.rooms-table th { background: #f7f4ee; font-weight: 600; }
.rooms-table input { width: 80px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; }

/* 知识 */
#panel-kb { display: none; }
#panel-kb.active { display: grid; grid-template-columns: 250px 1fr; gap: 16px; }
.kb-side { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; height: fit-content; }
.kb-group { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin: 12px 6px 4px; }
.kb-item { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 7px 8px; border-radius: 7px; cursor: pointer; font-size: 13px; color: var(--ink); }
.kb-item:hover { background: #f0ede6; }
.kb-item.active { background: var(--accent); color: var(--accent-ink); }
.kb-item .d { font-size: 10.5px; opacity: .7; margin-left: 4px; }
.kb-main { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; min-height: 70vh; }
.kb-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
#kb-editor { flex: 1; width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.6; resize: none; min-height: 60vh; }
#kb-editor[readonly] { background: #f7f4ee; color: var(--muted); }

/* 试聊 */
.chat-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-height: 420px; max-height: 60vh; overflow-y: auto; margin-bottom: 12px; }
.msg { margin-bottom: 12px; display: flex; flex-direction: column; }
.msg .who { font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }
.msg .bubble { padding: 9px 13px; border-radius: 12px; max-width: 82%; white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.msg.user { align-items: flex-end; }
.msg.user .bubble { background: var(--accent); color: var(--accent-ink); }
.msg.bot { align-items: flex-start; }
.msg.bot .bubble { background: #f0ede6; }
.msg .meta { font-size: 11px; color: var(--muted); margin-top: 3px; }
.msg.error .bubble { background: var(--danger-bg); color: var(--danger); }
.chat-input { display: flex; gap: 10px; }
.chat-input input { flex: 1; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; }
.chat-note { margin-top: 10px; }
.spin::after { content: "…"; animation: blink 1s steps(3) infinite; }
@keyframes blink { 0% { opacity: .2; } 50% { opacity: 1; } 100% { opacity: .2; } }

/* 弹窗 */
.modal { position: fixed; inset: 0; background: rgba(30, 28, 20, .35); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal.hidden, .toast.hidden { display: none; }
.modal-card { background: var(--panel); border-radius: 14px; width: 100%; max-width: 640px; max-height: 88vh; overflow: auto; box-shadow: 0 12px 40px rgba(0,0,0,.2); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 16px; }
.icon-btn { border: 0; background: transparent; font-size: 18px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 16px 18px; }
.modal-foot { display: flex; gap: 10px; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); }
.modal-foot input { flex: 1; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.modal-foot > div { display: flex; gap: 8px; }

/* toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #33302a; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13.5px; z-index: 60; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }

@media (max-width: 800px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  #panel-kb.active { grid-template-columns: 1fr; }
}

/* 登录口令门 (2026-10-04) */
#login-overlay{position:fixed;inset:0;z-index:1000;background:#f4f6f3;display:flex;align-items:center;justify-content:center;padding:16px}
.login-card{width:min(360px,100%);background:#fff;border:1px solid #dfe5dc;border-radius:14px;padding:28px 24px;box-shadow:0 10px 30px rgba(30,60,30,.08);display:flex;flex-direction:column;gap:12px}
.login-title{font-size:20px;font-weight:700;color:#2f4a2f}
.login-sub{font-size:13px;color:#6b7a6b;margin-top:-6px}
.login-card input{font-size:16px;padding:10px 12px;border:1px solid #cfd8cc;border-radius:8px}
.login-card button{font-size:15px;padding:10px;border:0;border-radius:8px;background:#3f6b3f;color:#fff;font-weight:600;cursor:pointer}
.login-err{min-height:18px;font-size:13px;color:#b42318}

/* 包间房态 (2026-10-04) */
#rooms-list{display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:12px}
.room-day{background:#fff;border:1px solid #dfe5dc;border-radius:12px;padding:12px}
.room-day.weekend{border-color:#c9d8c2;background:#fbfdf9}
.room-date{font-weight:700;color:#2f4a2f;margin-bottom:8px}.room-date span{font-weight:500;color:#6b7a6b;font-size:13px;margin-left:4px}
.room-grid{display:grid;grid-template-columns:76px 1fr 1fr;gap:6px;align-items:stretch}
.rg-head{font-size:12px;color:#6b7a6b;text-align:center}
.rg-room{font-size:14px;font-weight:600;color:#2f4a2f;display:flex;flex-direction:column;justify-content:center}
.rg-room small{font-weight:400;color:#8a968a;font-size:11px}
.rg-cell{min-height:44px;border:1px solid #cfe0c9;background:#f1f8ee;color:#3f6b3f;border-radius:8px;font-size:13px;font-weight:600;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;padding:4px}
.rg-cell.booked{background:#fdecea;border-color:#f3c3bd;color:#b42318}
.rg-cell small{font-weight:400;font-size:10.5px;color:#8a5a55;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
@media(max-width:640px){#rooms-list{grid-template-columns:1fr}}
/* 手机上 6 个页签不竖排 (2026-10-04) */
.tabs button{white-space:nowrap}
@media(max-width:640px){.topbar{flex-wrap:wrap;gap:8px}.tabs{width:100%;overflow-x:auto;display:flex;gap:4px;-webkit-overflow-scrolling:touch}.tabs button{flex:0 0 auto;padding:8px 12px}}
