:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-d: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #f59e0b;
  --radius: 12px;
  --shadow: 0 8px 28px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 10px; line-height: 1.3; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line);
}
.topbar .tl { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar .tr { display: flex; align-items: center; gap: 8px; }
.brand { font-weight: 700; font-size: 16px; letter-spacing: .3px; white-space: nowrap; }
.evname { font-size: 14px; color: var(--muted); max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- 通用 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--text); cursor: pointer; white-space: nowrap;
  transition: .15s; font-size: 14px;
}
.btn:hover { background: #f8fafc; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #f1f5f9; color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-link { border: none; background: none; color: var(--primary); cursor: pointer; padding: 0; font-size: 13px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 180px; min-width: 0; }
.row > .btn, .row > a.btn, .row > .spacer, .row > .actions { flex: 0 0 auto; }
.row > .spacer { flex: 1 1 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.spacer { flex: 1; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hide { display: none !important; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; background: #eef2ff; color: #3730a3; }
.pill.ok { background: #dcfce7; color: #166534; }
.pill.warn { background: #fef3c7; color: #92400e; }
.pill.danger { background: #fee2e2; color: #991b1b; }
.pill.gray { background: #e5e7eb; color: #374151; }

/* ---------------- 表单 ---------------- */
label.fl { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.input, select.input, textarea.input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--text); outline: none;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.input-sm { padding: 4px 8px; border-radius: 8px; border: 1px solid var(--line); width: 70px; }
.checkline { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.checkline input { width: 16px; height: 16px; }

/* ---------------- 表格 ---------------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { background: #f8fafc; font-weight: 600; color: var(--muted); font-size: 13px; white-space: nowrap; }
.table tr:hover td { background: #fafbfd; }
.table-wrap { overflow: auto; max-width: 100%; }
.table td.actions { white-space: nowrap; }

/* ---------------- 登录页 ---------------- */
.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 28px 26px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.login-card .brand { font-size: 22px; margin-bottom: 4px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.login-card .foot { margin-top: 18px; text-align: center; font-size: 13px; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 8px; }

/* ---------------- 业务员选座 ---------------- */
.seat-main { max-width: 1080px; margin: 0 auto; padding: 12px 12px 150px; }
.banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px; border-radius: 12px; background: #fff; border: 1px solid var(--line);
  margin-bottom: 12px; font-size: 15px;
}
.banner.hot { background: linear-gradient(90deg, #eff6ff, #fff); border-color: #bfdbfe; }
.banner.turn { background: linear-gradient(90deg, #ecfdf5, #fff); border-color: #a7f3d0; }
.banner.locked { background: #f8fafc; color: var(--muted); }
.banner .big { font-weight: 700; }
.banner .countdown { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--danger); }

.stage-wrap { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: auto; max-height: 62vh; }
.stage { position: relative; width: 100%; }
.stage img { width: 100%; display: block; user-select: none; -webkit-user-drag: none; }
.markers { position: absolute; inset: 0; }
.seat {
  position: absolute; width: 16px; height: 16px; margin: 0; padding: 0;
  border-radius: 50%; border: 2px solid #16a34a; background: rgba(22, 163, 74, .15);
  transform: translate(-50%, -50%); cursor: pointer;
}
.seat.free:hover { background: rgba(22, 163, 74, .45); }
.seat.mine { border-color: #2563eb; background: #2563eb; }
.seat.pending { border-color: #f59e0b; background: #f59e0b; }
.seat.taken { border-color: #9ca3af; background: #d1d5db; cursor: not-allowed; }
.seat.disabled { border-color: #cbd5e1; background: transparent; border-style: dashed; cursor: not-allowed; }
.seat.conflict { border-color: #dc2626; background: #fecaca; animation: blink .6s 3; }
@keyframes blink { 50% { opacity: .25; } }
.seat .lbl {
  position: absolute; left: 50%; top: 100%; transform: translateX(-50%);
  font-size: 9px; line-height: 1.2; white-space: nowrap; color: #334155;
  background: rgba(255, 255, 255, .82); padding: 0 2px; border-radius: 2px; pointer-events: none;
}
.stage-empty { padding: 48px 16px; text-align: center; color: var(--muted); }

.zoom { position: sticky; bottom: 8px; float: right; display: flex; gap: 4px; margin: 8px; }
.zoom .btn { padding: 4px 10px; font-size: 13px; }

.foot-panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: #fff; border-top: 1px solid var(--line);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 18px rgba(15, 23, 42, .06);
}
.foot-inner { max-width: 1080px; margin: 0 auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.quota { font-weight: 600; white-space: nowrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; border-radius: 999px; padding: 2px 10px; font-size: 13px; }
.chip.mine { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.chip button { border: none; background: none; color: #9a3412; cursor: pointer; padding: 0; font-size: 14px; }
.foot-panel .hint { font-size: 12px; color: var(--muted); }

/* ---------------- 弹窗 / 提示 ---------------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .48); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 760px; max-height: 88vh; overflow: auto; padding: 20px; box-shadow: var(--shadow); }
.modal h3 { font-size: 17px; }
.modal .modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

.toast {
  position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%);
  background: rgba(17, 24, 39, .92); color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 14px; z-index: 200; max-width: 86vw; text-align: center; white-space: pre-wrap;
}
.toast.err { background: rgba(153, 27, 27, .95); }
.toast.ok { background: rgba(22, 101, 52, .95); }

/* ---------------- 管理端 ---------------- */
.admin-main { max-width: 1280px; margin: 0 auto; padding: 16px; }
.tabs { display: flex; gap: 6px; margin: 14px 0; flex-wrap: wrap; }
.tab { padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 14px; }
.tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stat .v { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat .k { font-size: 12px; color: var(--muted); }

.plan-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; }
.plan-layout .side { align-self: start; }
.editor .seat { cursor: move; border-color: #2563eb; background: rgba(37, 99, 235, .18); }
.editor .seat.sel { border-color: #dc2626; background: #dc2626; }
.editor .seat .lbl { display: block; }

.seatmap-admin { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: auto; max-height: 64vh; }
.seatmap-admin .stage img { width: 100%; display: block; }

.event-card { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; background: #fff; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; }
.event-card .t { font-weight: 600; }

.free-seat-list { display: flex; flex-wrap: wrap; gap: 8px; max-height: 320px; overflow: auto; padding: 4px; }
.free-seat { border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; cursor: pointer; font-size: 13px; background: #fff; }
.free-seat.on { background: var(--primary); color: #fff; border-color: var(--primary); }

@media (max-width: 820px) {
  .plan-layout { grid-template-columns: 1fr; }
  .seat-main { padding-left: 8px; padding-right: 8px; }
  .topbar { padding: 8px 10px; }
  .brand { font-size: 15px; }
  .evname { max-width: 36vw; }
  .modal { padding: 16px; }
}
