:root {
  --bg: #0a1228;
  --bg-2: #0d1733;
  --panel: #111e3f;
  --panel-2: #15244a;
  --border: #1e2f5a;
  --primary: #2f7bff;
  --primary-soft: #1d4fb0;
  --accent: #ff8a3d;
  --text: #e6edff;
  --text-dim: #8aa0c8;
  --ok: #2fd08a;
  --warn: #ffb454;
  --danger: #ff5d6c;
  --seat: #16264d;
  --seat-border: #2a3f73;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

/* ---------- 自定义滚动条（全局替换原生滚动条） ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(120,150,210,.30); border-radius: 8px;
  border: 2px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(120,150,210,.55); background-clip: content-box; }
::-webkit-scrollbar-corner { background: transparent; }
* { scrollbar-width: thin; scrollbar-color: rgba(120,150,210,.45) transparent; }
html, body {
  margin: 0; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  overflow: hidden;
}
button, input, select, textarea { font-family: inherit; }
.hidden { display: none !important; }

/* ---------- 顶部栏 ---------- */
.topbar {
  height: 60px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
  background: linear-gradient(90deg, #0c1838, #0a1228);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #5aa0ff);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; color: #fff;
  box-shadow: 0 0 0 1px rgba(47,123,255,.4), 0 4px 14px rgba(47,123,255,.35);
}
.brand-title { font-size: 16px; font-weight: 700; letter-spacing: .5px; }
.brand-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.scenario-switch { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 3px; }
.scenario-switch button {
  border: none; background: transparent; color: var(--text-dim);
  padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 12px;
}
.scenario-switch button.active { background: var(--primary-soft); color: #fff; }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
  transition: all .15s ease;
}
.btn:hover { border-color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #4a8dff; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: #ff9f5a; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-xs { padding: 2px 8px; font-size: 13px; line-height: 1; }

/* ---------- 布局 ---------- */
.layout { display: flex; height: calc(100% - 60px); }
.sidebar {
  width: 260px; background: var(--bg-2); border-right: 1px solid var(--border);
  padding: 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px;
}
.canvas-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.rightpanel {
  width: 340px; background: var(--bg-2); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}

/* ---------- 侧栏模块 ---------- */
.side-section { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.side-title { font-size: 13px; font-weight: 600; margin-bottom: 10px; color: #cfe0ff; }
.tool-row { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.tool-row .btn { flex: 1; }
.seat-input { align-items: center; gap: 8px; }
.seat-input label { color: var(--text-dim); font-size: 12px; }
.seat-input input { width: 64px; }
.gen-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.gen-row label { color: var(--text-dim); font-size: 12px; white-space: nowrap; }
.gen-row select, .gen-row input[type="number"] { flex: 1; min-width: 0; }
.gen-row input[type="checkbox"] { width: 16px; height: 16px; }
input, select, textarea {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 7px 9px; outline: none; font-size: 13px;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
.tool-hint { font-size: 11px; color: var(--text-dim); line-height: 1.6; margin-top: 4px; }
.inspector-empty { font-size: 12px; color: var(--text-dim); }

.inspector-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 12px; }
.inspector-row label { color: var(--text-dim); }
.inspector-row input[type="text"], .inspector-row input[type="number"], .inspector-row select { width: 140px; }
.inspector-actions { display: flex; gap: 6px; margin-top: 6px; }
.inspector-actions .btn { flex: 1; }

/* ---------- 画布 ---------- */
.canvas-toolbar {
  height: 44px; display: flex; align-items: center; gap: 14px; padding: 0 16px;
  border-bottom: 1px solid var(--border); background: var(--bg-2);
}
.canvas-label { font-weight: 600; }
.canvas-tip { font-size: 12px; color: var(--text-dim); }
.zoom-control { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--text-dim); }
.canvas-scroll { flex: 1; overflow: auto; position: relative; cursor: grab; user-select: none; }
.canvas-scroll.panning { cursor: grabbing; }
.canvas-viewport { position: relative; transform-origin: 0 0; }
.canvas {
  position: relative; width: 1600px; height: 1400px;
  background:
    linear-gradient(rgba(47,123,255,.06) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, rgba(47,123,255,.06) 1px, transparent 1px) 0 0 / 40px 40px,
    radial-gradient(circle at 30% 20%, #0f1d40, #070d1f 70%);
  transform-origin: 0 0;
}

/* ---------- 右下角缩略导航窗口 ---------- */
.minimap {
  position: absolute; right: 16px; bottom: 16px; width: 200px; height: 175px;
  background: rgba(10,16,32,.86); border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; z-index: 40; box-shadow: var(--shadow); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
}
.minimap-label { position: absolute; left: 8px; top: 6px; font-size: 10px; color: var(--text-dim); pointer-events: none; z-index: 2; }
.minimap-content { position: absolute; inset: 0; }
.minimap-dot { position: absolute; background: var(--primary); border-radius: 2px; opacity: .85; }
.minimap-dot.host { background: var(--accent); }
.minimap-view {
  position: absolute; border: 2px solid var(--accent); background: rgba(255,138,61,.14);
  border-radius: 3px; cursor: grab; z-index: 3;
}
.minimap-view:active { cursor: grabbing; }
.minimap.hidden { display: none !important; }

/* ---------- 桌子 ---------- */
.table {
  position: absolute; left: 0; top: 0; user-select: none; cursor: grab;
  will-change: transform; backface-visibility: hidden; touch-action: none;
}
.table.dragging { cursor: grabbing; opacity: .92; }
.table.selected .table-shape { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.table-shape {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: linear-gradient(135deg, #1b2c54, #142146);
  border: 2px solid #34508c; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #cfe0ff; font-weight: 700; font-size: 13px;
}
.table.round .table-shape { border-radius: 50%; }
.table.square .table-shape { border-radius: 10px; }
.table.rect .table-shape { border-radius: 8px; }
.table.boardroom .table-shape { border-radius: 10px; border-color: #c9a227; background: linear-gradient(135deg, #2a2410, #1e1a0a); color: #ffe8a0; }
.table.hollow .table-shape { border-radius: 12px; border-style: dashed; border-color: #4a6fa5; background: linear-gradient(135deg, #151d35, #0f162b); }
.table.ushape .table-shape { border-radius: 14px; border-color: #3d7ea6; background: linear-gradient(135deg, #182848, #101c38); }
.table.classroom .table-shape { border-radius: 4px; height: 28px !important; font-size: 11px; }
.table.theater .table-shape { display: none; } /* 剧院式无桌面 */
.table.host .table-shape { border-color: var(--accent); background: linear-gradient(135deg, #3a2a12, #2a1d0c); color: #ffd9a8; }

/* 旋转手柄（选中桌子时显示，用于拖拽调节角度） */
.rotate-handle {
  display: none;
  position: absolute; width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); border: 2px solid #1a1206; cursor: grab;
  transform: translateX(-50%); z-index: 5;
  box-shadow: 0 0 0 3px rgba(255,138,61,.25);
}
.table.selected .rotate-handle { display: block; }
.rotate-handle::before {
  content: ''; position: absolute; left: 50%; top: 100%; width: 2px; height: 12px;
  background: var(--accent); transform: translateX(-50%); opacity: .6;
}
.rotate-handle:active { cursor: grabbing; }
.table-label {
  position: absolute; left: 50%; bottom: -20px; transform: translateX(-50%);
  font-size: 11px; color: var(--text-dim); white-space: nowrap;
}
.table.host .table-label { color: var(--accent); }

/* 拖动对齐参考线（贯穿画布，跟随缩放，不拦截事件） */
.guide-line {
  position: absolute; background: var(--accent); pointer-events: none;
  display: none; z-index: 50; opacity: .85;
}
.guide-v { top: 0; width: 1px; }
.guide-h { left: 0; height: 1px; }

/* ---------- 座位 ---------- */
.seat {
  position: absolute; width: 30px; height: 30px; border-radius: 50%;
  background: var(--seat); border: 1px solid var(--seat-border);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; color: var(--text-dim); cursor: pointer; text-align: center;
  line-height: 1.05; padding: 1px; overflow: hidden;
  transition: background .12s, border-color .12s;
}
.seat:hover { border-color: var(--primary); }
.seat.occupied { background: linear-gradient(135deg, #1e4fb0, #2f7bff); border-color: #5aa0ff; color: #fff; font-weight: 600; }
.seat.vip { background: linear-gradient(135deg, #c9712a, #ff8a3d); border-color: #ffb277; color: #1a1206; font-weight: 700; }
.seat.host-seat { border-color: var(--accent); box-shadow: inset 0 0 0 2px rgba(255,138,61,.75); }
.seat-tag { position: absolute; top: 1px; right: 1px; font-size: 8px; background: var(--accent); color: #1a1206; border-radius: 3px; padding: 0 2px; line-height: 1.3; font-weight: 700; }
.seat.droptarget { border-color: var(--ok); box-shadow: 0 0 0 2px var(--ok); }
.seat-empty-tag { font-size: 8px; color: #4e6a9e; }

/* ---------- 右侧 tabs ---------- */
.tabs { display: flex; border-bottom: 1px solid var(--border); background: var(--bg-2); }
.tab {
  flex: 1; border: none; background: transparent; color: var(--text-dim);
  padding: 12px 0; cursor: pointer; font-size: 13px; border-bottom: 2px solid transparent;
}
.tab.active { color: #fff; border-bottom-color: var(--primary); }
.tab-panel { flex: 1; overflow-y: auto; padding: 12px; display: none; }
.tab-panel.active { display: block; }

.panel-actions { display: flex; gap: 8px; margin-bottom: 10px; }
.guest-form, .import-box {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 8px;
}
.gf-row { display: flex; gap: 8px; }
.gf-row > * { flex: 1; }
.gf-actions { display: flex; gap: 8px; }
.import-hint { font-size: 11px; color: var(--text-dim); margin: 0 0 4px; line-height: 1.5; }
#importText { width: 100%; height: 120px; resize: vertical; }

/* ---------- 宾客列表 ---------- */
.guest-list { display: flex; flex-direction: column; gap: 6px; }
.guest-item {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; display: flex; align-items: center; gap: 8px; cursor: grab;
}
.guest-item:active { cursor: grabbing; }
.guest-item.placed { opacity: .55; }
.guest-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); flex-shrink: 0; }
.guest-item .g-name { font-weight: 600; }
.guest-item .g-meta { font-size: 11px; color: var(--text-dim); }
.guest-item .g-level { font-size: 10px; padding: 1px 6px; border-radius: 10px; background: var(--panel-2); color: var(--accent); }
.guest-item .g-remove { margin-left: auto; color: var(--text-dim); cursor: pointer; border: none; background: transparent; font-size: 14px; }
.guest-item .g-remove:hover { color: var(--danger); }

/* ---------- 规则 ---------- */
.rules-list { display: flex; flex-direction: column; gap: 4px; }
.rule-item { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--border); }
.rule-item input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }
.rule-item label { flex: 1; font-size: 13px; }
.rule-item .desc { font-size: 11px; color: var(--text-dim); }
.rules-note { font-size: 11px; color: var(--text-dim); line-height: 1.6; margin-top: 10px; }

/* ---------- 统计 ---------- */
.stat-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.stat-card .num { font-size: 22px; font-weight: 700; color: #fff; }
.stat-card .lab { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.bar-block { margin-bottom: 8px; }
.bar-head { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; }
.bar-track { height: 8px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), #5aa0ff); border-radius: 6px; }
.bar-fill.full { background: linear-gradient(90deg, var(--ok), #6fe0b0); }
.bar-fill.host { background: linear-gradient(90deg, var(--accent), #ffb277); }
.unseated-list { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.unseated-item { font-size: 12px; color: var(--warn); }

/* mini stats in sidebar */
.stats-mini .stat-line { display: flex; justify-content: space-between; font-size: 12px; padding: 4px 0; }
.stats-mini .stat-line .v { color: #fff; font-weight: 600; }

/* ---------- 场景说明卡片 ---------- */
#eventSelect { background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 6px; padding: 7px 9px; outline: none; font-size: 13px; }
#eventSelect:focus { border-color: var(--primary); }
.sc-card { font-size: 12px; line-height: 1.5; }
.sc-row { display: flex; gap: 8px; padding: 5px 0; border-bottom: 1px dashed var(--border); }
.sc-row:last-child { border-bottom: none; }
.sc-k { flex-shrink: 0; width: 34px; color: var(--primary); font-weight: 600; }
.sc-v { flex: 1; color: var(--text-dim); }
.sc-v.ok { color: var(--ok); }
.sc-v.warn { color: var(--warn); }

/* ---------- 座位弹层 ---------- */
.seat-popover {
  position: fixed; z-index: 100; background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px; width: 220px; box-shadow: var(--shadow);
}
.pop-title { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.seat-popover select { width: 100%; margin-bottom: 8px; }
.pop-actions { display: flex; gap: 6px; }
.pop-actions .btn { flex: 1; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--primary); color: #fff;
  padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow); z-index: 200; font-size: 13px;
}

/* 操作进度状态条 */
.op-status {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  width: min(440px, 92vw); padding: 13px 18px;
  background: rgba(18,24,36,.94); color: #e9eefb;
  border: 1px solid rgba(255,255,255,.12); border-radius: 14px;
  box-shadow: 0 12px 34px rgba(0,0,0,.5); z-index: 300;
  font-size: 13px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.op-status.hidden { display: none; }
.op-text { display: flex; justify-content: space-between; align-items: center; margin-bottom: 9px; letter-spacing: .2px; }
.op-text #opLabel { opacity: .92; }
.op-text #opPct { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.op-bar { height: 8px; background: rgba(255,255,255,.10); border-radius: 99px; overflow: hidden; }
.op-fill { height: 100%; width: 0%; background: linear-gradient(90deg,#ff8a3d,#ffb169); border-radius: 99px; transition: width .14s ease; }
.op-status.err #opFill { background: linear-gradient(90deg,#ff5d5d,#ff8a8a); }
.op-status.err #opPct { color: #ff7a7a; }

/* ---------- 自定义弹窗（替代系统 confirm / prompt） ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(4,8,18,.62); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
}
.modal-mask.hidden { display: none; }
.modal {
  width: min(380px, 92vw); background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 22px; box-shadow: var(--shadow);
  animation: modalIn .16s ease;
}
@keyframes modalIn { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-title { font-size: 15px; font-weight: 700; margin-bottom: 10px; color: #fff; }
.modal.danger .modal-title { color: var(--danger); }
.modal-body { font-size: 13px; color: var(--text-dim); line-height: 1.7; margin-bottom: 16px; }
.modal-input { margin-bottom: 14px; }
.modal-input input { width: 100%; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal-actions .btn { min-width: 84px; }

/* ---------- AI 排桌对话 ---------- */
.ai-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.ai-title { font-size: 14px; font-weight: 700; color: #fff; }
.ai-chat { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 120px; }
.ai-msg { max-width: 92%; padding: 9px 12px; border-radius: 12px; font-size: 13px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.ai-msg.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 3px; }
.ai-msg.bot { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--border); color: var(--text); border-bottom-left-radius: 3px; }
.ai-msg.bot.err { border-color: var(--danger); color: #ff9a9a; }
.ai-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 10px; }
.chip { font-size: 12px; padding: 6px 10px; border-radius: 99px; background: rgba(47,123,255,.14); border: 1px solid rgba(47,123,255,.32); color: #cfe0ff; cursor: pointer; transition: background .15s; }
.chip:hover { background: rgba(47,123,255,.26); }
.ai-upload { display: flex; align-items: center; gap: 8px; padding: 0 12px 10px; }
.ai-filename { font-size: 12px; color: var(--text-dim); }
.ai-input-row { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); align-items: flex-end; }
#aiInput { flex: 1; resize: none; height: 52px; min-height: 40px; font-size: 13px; line-height: 1.5; }
.ai-input-row .btn-primary { height: 52px; }
.ai-hint { font-size: 11px; color: var(--text-dim); padding: 0 12px 12px; line-height: 1.6; }
#panel-ai { display: none; }
#panel-ai.active { display: flex; flex-direction: column; }

/* AI 设置面板 */
.ai-setting-row { margin-bottom: 16px; }
.ai-setting-row label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.ai-setting-row input { width: 100%; padding: 8px 12px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); border-radius: 6px; color: var(--text); font-size: 13px; outline: none; }
.ai-setting-row input:focus { border-color: var(--primary); }
.ai-setting-tip { font-size: 11px; color: var(--text-dim); margin-top: 4px; opacity: .7; }

/* 打印 */
@media print {
  .topbar, .sidebar, .rightpanel, .canvas-toolbar .zoom-control, .canvas-tip { display: none !important; }
  body { background: #fff; color: #000; overflow: visible; }
  .layout { display: block; }
  .canvas { background: #fff; transform: none !important; width: auto; height: auto; }
  .table-shape { background: #e7f0ff !important; border-color: #2f7bff !important; color: #1a2b4a !important; }
  .table.host .table-shape { background: #fff3e6 !important; border-color: #ff8a3d !important; color: #a8521a !important; }
  .seat { background: #2f7bff !important; border-color: #1a2b4a !important; color: #fff !important; }
  .seat.occupied { background: #2f7bff !important; color: #fff !important; }
  .seat.vip { background: #ff8a3d !important; color: #1a1206 !important; }
  .rotate-handle { display: none !important; }
  .op-status { display: none !important; }
  .minimap { display: none !important; }
  .modal-mask { display: none !important; }
}
