/* B1 馆展位预定协同系统 — 扁平纯色设计系统 */
:root {
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --bg: #F4F6F9;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --text: #1E293B;
  --text-2: #64748B;
  --available: #FFFFFF;
  --intent: #F5B54A;
  --intent-text: #7A4E00;
  --booked: #E2595A;
  --booked-text: #FFFFFF;
  --danger: #DC2626;
  --radius: 10px;
  --font: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; font-family: var(--font); color: var(--text); background: var(--bg); }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 14px; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 8px; outline: none; background: #fff; color: var(--text); transition: border-color .15s; }
input:focus, textarea:focus, select:focus { border-color: var(--primary); }
label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 14px; }
label input, label textarea { display: block; width: 100%; margin-top: 6px; color: var(--text); }

/* ---------- 按钮 ---------- */
.btn { height: 38px; padding: 0 18px; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; transition: filter .15s, transform .1s; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; color: var(--text-2); border: 1.5px solid var(--border); height: 34px; font-weight: 500; }
.btn-ghost:hover { color: var(--primary); border-color: var(--primary); }
.btn-danger-ghost { background: transparent; color: var(--danger); border: 1.5px solid #F3C2C2; }
.btn-danger-ghost:hover { background: #FEF2F2; }
.btn-block { width: 100%; height: 44px; }
.btn-mini { font-size: 12px; border: 1px solid var(--border); background: #fff; border-radius: 6px; padding: 2px 8px; color: var(--text-2); }
.btn-mini:hover { color: var(--primary); border-color: var(--primary); }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 6px 0; }
.muted { color: var(--text-2); font-size: 13px; }

/* ---------- 登录页 ---------- */
.login-view { height: 100%; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card { width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 40px 36px; }
.login-brand { text-align: center; margin-bottom: 28px; }
.login-logo { width: 56px; height: 56px; margin: 0 auto 14px; background: var(--primary); color: #fff; font-size: 22px; font-weight: 800; border-radius: 14px; display: flex; align-items: center; justify-content: center; letter-spacing: 1px; }
.login-brand h1 { font-size: 20px; margin-bottom: 6px; }
.login-brand p { font-size: 13px; color: var(--text-2); }

/* ---------- 顶栏 ---------- */
.app-view { height: 100%; display: flex; flex-direction: column; }
.topbar { height: 56px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 16px; gap: 16px; flex-shrink: 0; }
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hall-badge { background: var(--primary); color: #fff; font-weight: 800; border-radius: 8px; padding: 4px 9px; font-size: 14px; }
.topbar-title strong { font-size: 15px; white-space: nowrap; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #22C55E; margin: 0 4px 0 10px; }
.live-dot.off { background: #EF4444; }
.live-text { font-size: 12px; color: var(--text-2); }
.topbar-stats { display: flex; gap: 8px; margin-left: auto; }
.stat-chip { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 4px 12px; font-size: 13px; color: var(--text-2); white-space: nowrap; }
.stat-chip b { color: var(--text); font-size: 14px; }
.stat-chip.red b { color: var(--booked); }
.stat-chip.blue b { color: var(--primary); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.user-chip { position: relative; padding: 6px 12px; border-radius: 8px; background: var(--bg); border: 1px solid var(--border); font-size: 14px; cursor: pointer; user-select: none; }
.user-menu { position: absolute; right: 0; top: 42px; background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; z-index: 60; min-width: 120px; }
.user-menu button { display: block; width: 100%; padding: 10px 14px; border: none; background: #fff; text-align: left; font-size: 14px; }
.user-menu button:hover { background: var(--bg); }

/* ---------- 主区域 ---------- */
.main { flex: 1; display: flex; min-height: 0; }
.map-panel { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.map-toolbar { height: 44px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; border-bottom: 1px solid var(--border); background: var(--surface); }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--text-2); }
.legend span { display: flex; align-items: center; gap: 6px; }
.lg { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.lg-available { background: #fff; border: 1.5px solid #94A3B8; }
.lg-intent { background: var(--intent); }
.lg-booked { background: var(--booked); }
.map-tools { display: flex; gap: 6px; }
.tool-btn { border: 1px solid var(--border); background: #fff; border-radius: 6px; padding: 3px 10px; font-size: 13px; color: var(--text-2); }
.tool-btn:hover { color: var(--primary); border-color: var(--primary); }
.map-wrap { flex: 1; overflow: hidden; position: relative; background: var(--bg); cursor: grab; }
.map-wrap.panning { cursor: grabbing; }
#boothMap { width: 100%; height: 100%; display: block; }

/* SVG 展位 */
.booth rect { stroke: #94A3B8; stroke-width: .12; transition: filter .15s; }
.booth:hover rect { filter: brightness(.93); }
.booth { cursor: pointer; }
.booth text { pointer-events: none; user-select: none; }
.booth-label { font-weight: 700; }
.booth.selected rect { stroke: var(--primary); stroke-width: .3; }
.aisle { fill: #E9EDF2; }

/* ---------- 侧栏 ---------- */
.side-panel { width: 380px; flex-shrink: 0; background: var(--surface); border-left: 1px solid var(--border); overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.stat-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stat-card p { font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.stat-card b { font-size: 20px; }
.stat-card.blue b { color: var(--primary); }
.stat-card.red b { color: var(--booked); }
.stat-card.amber b { color: #D98E04; }
.charts { display: flex; justify-content: space-between; gap: 8px; }
.chart-box { flex: 1; text-align: center; }
.chart-box p { font-size: 12px; color: var(--text-2); margin-top: 6px; }
.donut { position: relative; width: 104px; height: 104px; margin: 0 auto; }
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut .donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut .donut-center b { font-size: 17px; }
.donut .donut-center span { font-size: 10px; color: var(--text-2); }
.chart-legend { display: flex; justify-content: center; gap: 10px; font-size: 11px; color: var(--text-2); margin-top: 4px; flex-wrap: wrap; }

.log-panel { flex: 1; min-height: 200px; display: flex; flex-direction: column; }
.log-panel h3 { font-size: 14px; margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; }
.log-list { list-style: none; overflow-y: auto; flex: 1; }
.log-list li { font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--border); line-height: 1.5; color: var(--text-2); }
.log-list li b { color: var(--text); }
.log-list li .log-time { color: #94A3B8; font-size: 11px; margin-right: 6px; }
.log-empty { text-align: center; color: #94A3B8; padding: 20px 0; }

/* ---------- 展位抽屉 ---------- */
.drawer-mask { position: fixed; inset: 0; background: rgba(15,23,42,.25); z-index: 80; }
.booth-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 400px; max-width: 92vw; background: var(--surface); z-index: 90; display: flex; flex-direction: column; border-left: 1px solid var(--border); animation: slideIn .2s ease; }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.booth-drawer header { padding: 18px 20px 12px; display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid var(--border); }
.booth-drawer h2 { font-size: 22px; }
.drawer-sub { font-size: 13px; color: var(--text-2); }
.drawer-close { border: none; background: none; font-size: 26px; color: var(--text-2); line-height: 1; }
.drawer-close:hover { color: var(--text); }
.drawer-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.status-picker { display: flex; gap: 8px; margin-bottom: 16px; }
.status-picker button { flex: 1; height: 36px; border-radius: 8px; border: 1.5px solid var(--border); background: #fff; font-size: 13px; font-weight: 600; color: var(--text-2); }
.status-picker button.on[data-status="available"] { border-color: #64748B; background: #F1F5F9; color: var(--text); }
.status-picker button.on[data-status="intent"] { border-color: var(--intent); background: var(--intent); color: var(--intent-text); }
.status-picker button.on[data-status="booked"] { border-color: var(--booked); background: var(--booked); color: #fff; }
.drawer-info { font-size: 12.5px; color: var(--text-2); background: var(--bg); border-radius: 8px; padding: 10px 12px; line-height: 1.7; margin-bottom: 10px; }
.drawer-actions { display: flex; gap: 10px; }
.drawer-actions .btn { flex: 1; }
.history-title { font-size: 14px; margin: 20px 0 6px; display: flex; align-items: center; gap: 8px; }

/* ---------- 签约信息 ---------- */
.contract-chip { font-size: 12px; font-weight: 600; border-radius: 20px; padding: 2px 10px; background: var(--bg); color: var(--text-2); border: 1px solid var(--border); }
.contract-chip.st-pending { background: #FEF3D9; color: #96660D; border-color: #F0DBA8; }
.contract-chip.st-approved { background: #DEF7E5; color: #14713D; border-color: #BCE5CC; }
.contract-chip.st-rejected { background: #FDE2E2; color: var(--danger); border-color: #F3C2C2; }
.contract-form { margin-top: 8px; }
.row-off { opacity: .45; }

/* ---------- 弹窗 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.35); z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal { width: 640px; max-width: 94vw; max-height: 86vh; overflow-y: auto; background: var(--surface); border-radius: 14px; padding: 22px 26px; }
.modal-sm { width: 380px; }
.modal header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal h2 { font-size: 18px; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab { border: none; background: none; padding: 8px 14px; font-size: 14px; color: var(--text-2); border-bottom: 2px solid transparent; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-page h4 { margin: 16px 0 8px; font-size: 14px; }
.price-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 12px 0 16px; }
.price-grid label { margin-bottom: 0; }
.user-add { display: grid; grid-template-columns: 1.2fr 1fr 1.2fr .9fr auto; gap: 8px; }
.user-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.user-table th, .user-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.user-table th { color: var(--text-2); font-weight: 500; font-size: 12px; }
.user-table .row-actions button { margin-right: 6px; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); background: #1E293B; color: #fff; padding: 10px 22px; border-radius: 10px; font-size: 14px; z-index: 200; animation: toastIn .2s ease; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

.btn-wechat { background: #07C160; color: #fff; margin-top: 10px; }
.btn-wechat:hover { background: #06AD56; }
.btn-wechat:disabled { background: #A7D9BC; cursor: not-allowed; }
.wx-bind-tip { font-size: 12.5px; color: #07C160; background: #EAF9F0; border-radius: 8px; padding: 8px 12px; margin-top: 12px; line-height: 1.6; }
.wx-guide { margin-top: 14px; background: var(--bg); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.wx-guide code { background: #E2E8F0; border-radius: 4px; padding: 1px 6px; font-size: 12px; word-break: break-all; }
.user-table .row-actions { white-space: nowrap; }

/* ---------- 移动端 / 微信 H5 适配 ---------- */
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 10px; row-gap: 6px; }
  .topbar-stats { display: none; }
  .topbar-title strong { font-size: 14px; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; }
  .topbar-right { margin-left: auto; gap: 6px; }
  .topbar-right .btn-ghost { height: 40px; padding: 0 10px; font-size: 13px; }
  .main { flex-direction: column; overflow-y: auto; }
  .map-panel { flex: none; height: 58vh; min-height: 340px; }
  .map-toolbar { padding: 0 10px; }
  .legend { gap: 10px; font-size: 12px; }
  .tool-btn { min-width: 40px; min-height: 34px; font-size: 15px; }
  .side-panel { width: auto; border-left: none; border-top: 1px solid var(--border); }
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .charts { flex-wrap: wrap; }
  .chart-box { flex: 1 1 45%; }
  .booth-drawer { width: 100vw; max-width: 100vw; }
  .drawer-actions .btn { min-height: 46px; }
  #boothForm .btn-primary { min-height: 46px; }
  .user-add { grid-template-columns: 1fr 1fr; }
  .price-grid { grid-template-columns: repeat(2, 1fr); }
  .user-table { font-size: 12px; }
  .user-table th:nth-child(2), .user-table td:nth-child(2) { display: none; }
  .modal { padding: 16px; border-radius: 12px; }
  .login-card { width: auto; margin: 0 16px; padding: 32px 24px; }
  #loginForm input { height: 46px; }
}
@media (max-width: 480px) {
  .chart-box { flex: 1 1 100%; }
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .topbar-right .btn-ghost { padding: 0 8px; font-size: 12px; }
}

/* ---------- 客户需求多选 ---------- */
.needs-group { display: flex; flex-direction: column; gap: 6px; margin: 2px 0 10px; }
.needs-label { font-size: 13px; color: #64748B; }
.needs-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.needs-chips label {
  display: inline-flex; align-items: center; gap: 5px;
  background: #F1F5F9; border: 1px solid #E2E8F0; border-radius: 14px;
  padding: 4px 11px; font-size: 13px; cursor: pointer; user-select: none;
}
.needs-chips label:has(input:checked) { background: #DBEAFE; border-color: #2563EB; color: #1D4ED8; }
.needs-chips input { accent-color: #2563EB; margin: 0; }
#contractFileInfo { margin: 4px 0; }
#contractFileInfo .btn-mini { margin-left: 6px; }
.contract-file-info { font-size: 13px; color: var(--text); margin-bottom: 6px; word-break: break-all; }

/* ---------- 备份设置 ---------- */
.backup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- 移动端触摸优化 ---------- */
.map-wrap { touch-action: none; -webkit-tap-highlight-color: transparent; }
button, .booth, .tab, .needs-chips label { -webkit-tap-highlight-color: transparent; }

/* ---------- 移动端 / 微信 H5 适配（覆盖早期规则） ---------- */
@media (max-width: 900px) {
  /* iOS：输入框字号 ≥16px，聚焦时浏览器不自动放大页面 */
  input, textarea, select { font-size: 16px; }
  .needs-chips label { font-size: 14px; }
  .topbar { padding-top: calc(8px + env(safe-area-inset-top)); }
  .topbar-right { flex-wrap: wrap; justify-content: flex-end; }
  .map-panel { height: 56vh; min-height: 320px; }
  .booth-drawer .drawer-body { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(24px + env(safe-area-inset-bottom)); left: 12px; right: 12px; transform: none; width: auto; text-align: center; }
  @keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
  .modal { max-height: calc(92vh - env(safe-area-inset-top)); }
  .backup-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .user-table th:nth-child(n+6), .user-table td:nth-child(n+6) { display: none; } /* 超窄屏隐藏次要列，保留核心操作 */
}

/* ---------- 移动端"返回上层"按钮（仅小屏显示，桌面端用 × 关闭） ---------- */
.mobile-back { display: none; background: none; border: none; color: #2563EB; font-size: 15px; font-weight: 600; padding: 8px 10px 8px 0; cursor: pointer; white-space: nowrap; }
@media (max-width: 900px) {
  .mobile-back { display: inline-block; }
}

/* ---------- 展位备注速览 ---------- */
.note-panel { background: #EFF6FF; border: 1px solid #BFDBFE; border-radius: 10px; padding: 10px 12px; }
.note-panel h3 { font-size: 13px; color: #1D4ED8; margin-bottom: 6px; }
.note-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; }
.note-item { background: #FFFFFF; border: 1px solid #DBEAFE; border-radius: 8px; padding: 8px 10px; cursor: pointer; }
.note-item:hover { border-color: #2563EB; }
.note-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.note-head b { color: #1D4ED8; }
.note-head span { color: #64748B; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-body { margin: 4px 0; font-size: 13px; color: #1E293B; word-break: break-all; }
.note-meta { font-size: 11px; color: #94A3B8; }
.note-badge { cursor: pointer; }
