:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1f2733;
  --muted: #6b7787;
  --line: #e4e9f0;
  --free: #35c759;
  --free-d: #29a44a;
  --booked: #c7ccd4;
  --booked-ink: #5a6472;
  --accent: #0a6cff;
  --danger: #e5484d;
  --shadow: 0 6px 20px rgba(20, 40, 70, 0.08);
  --radius: 14px;
}

* { box-sizing: border-box; }

/* 确保 [hidden] 始终生效（避免被组件自身的 display 规则覆盖） */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 28px; }
.brand h1 { margin: 0; font-size: 20px; }
.subtitle { margin: 0; font-size: 13px; color: var(--muted); }

.conn { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.conn .dot { width: 10px; height: 10px; border-radius: 50%; background: #f5a623; display: inline-block; }
.conn.online .dot { background: var(--free); }
.conn.online .txt::after { content: ""; }
.conn.offline .dot { background: var(--danger); }

/* ---------- 图例 ---------- */
.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  padding: 12px 24px;
  font-size: 13px;
  color: var(--muted);
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.sw-free { background: var(--free); }
.sw-booked { background: var(--booked); }
.hint { color: var(--muted); }

/* ---------- 主体：两辆车 ---------- */
.board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 24px;
  padding: 8px 24px 32px;
  max-width: 1200px;
  margin: 0 auto;
}

.car-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.car-head { padding: 16px 18px 6px; }
.car-name { margin: 0; font-size: 18px; letter-spacing: .3px; }
.car-img {
  width: 100%;
  height: 190px;
  object-fit: contain;
  display: block;
  background: linear-gradient(#eef2f7, #dce4ee);
  padding: 6px;
}
.car-img.flip-horizontal {
  transform: scaleX(-1);
}

.slots { padding: 10px 18px 18px; display: flex; flex-direction: column; gap: 14px; }

.slot {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fbfcfe;
}
.slot-label {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.slot-label .clock { color: var(--accent); }

.seats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

/* ---------- 座位 ---------- */
.seat {
  position: relative;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}
.seat .box {
  height: 56px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fff;
  background: var(--free);
  box-shadow: inset 0 -3px 0 var(--free-d);
  transition: transform .08s ease, background .2s ease;
}
.seat .icon { font-size: 22px; line-height: 1; }
.seat.free:hover .box { transform: translateY(-2px); }
.seat.free .cap { font-size: 11px; color: var(--muted); margin-top: 4px; display: block; }

.seat.booked { cursor: not-allowed; }
.seat.booked .box {
  background: var(--booked);
  box-shadow: 0 0 0 2px #aeb4be, inset 0 -3px 0 #b7bdc7;
  color: var(--booked-ink);
}
.seat .name {
  font-size: 12px;
  margin-top: 5px;
  display: block;
  color: var(--booked-ink);
  font-weight: 600;
  word-break: break-all;
}

/* 座位内的编辑表单 */
.seat .edit {
  position: absolute;
  inset: 0;
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
  box-shadow: var(--shadow);
  z-index: 5;
}
.seat .edit input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
  outline: none;
}
.seat .edit input:focus { border-color: var(--accent); }
.seat .edit .row { display: flex; gap: 6px; }
.seat .edit button {
  flex: 1;
  border: none;
  border-radius: 8px;
  padding: 6px 0;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.seat .edit .confirm { background: var(--accent); color: #fff; }
.seat .edit .cancel { background: #eef1f5; color: var(--muted); }

/* ---------- 底部 ---------- */
.foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
  background: var(--card);
}
.admin-link { color: var(--accent); text-decoration: none; font-weight: 600; }
.admin-link:hover { text-decoration: underline; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--free-d); }

@media (max-width: 480px) {
  .seats { gap: 8px; }
  .seat .box { height: 48px; }
}
