/* ============================================================
   寄宿考研管理系统 · style.css  v1
   设计系统：亮/暗双主题 + 设计令牌 + 桌面侧栏 / 移动端底部 Tab
   ============================================================ */
:root {
  /* 品牌色 */
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-hover: #1d4ed8;
  --brand: #2563eb;
  --brand-50: #eff6ff;

  /* 背景 / 卡片 */
  --bg: #f1f5f9;
  --sidebar: #1e293b;
  --sidebar-2: #16202e;
  --card: #ffffff;
  --page-bg: #f1f5f9;

  /* 导航栏（可配置：--nav-bg / --nav-text / --nav-active-bg） */
  --nav-bg: #1e293b;
  --nav-active-bg: #334155;

  /* 文字 */
  --text: #1e293b;
  --muted: #64748b;
  --ink-2: #475569;
  --ink-3: #94a3b8;

  /* 边框 / 阴影 */
  --border: #e2e8f0;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.08);

  /* 语义色 */
  --avail: #22c55e;
  --occupied: #ef4444;
  --reserved: #f59e0b;
  --danger: #ef4444;
  --warn: #f59e0b;
  --free: #e2e8f0;

  /* 字体令牌 */
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --mono: 'SF Mono', 'Cascadia Mono', Consolas, 'Courier New', monospace;
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;

  /* 导航栏（侧边栏 / TabBar 用） */
  --nav-text: #cbd5e1;
  --nav-title: #f8fafc;
  --nav-active: #ffffff;

  /* 圆角 */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
}

[data-theme="dark"] {
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --brand-50: #1e293b;
  --bg: #0f172a;
  --page-bg: #0f172a;
  --card: #1e293b;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --ink-2: #cbd5e1;
  --ink-3: #64748b;
  --border: #334155;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.4);
  --sidebar: #0b1220;
  --sidebar-2: #0f172a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--page-bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  font-size: var(--fs-md);
  -webkit-tap-highlight-color: transparent;
}

/* ============ 滚动条彻底隐藏 ============ */
::-webkit-scrollbar { width: 8px; height: 8px; }
.sidebar, .main, .modal-content { -ms-overflow-style: auto; scrollbar-width: thin; }

/* ============ 侧边栏（桌面） ============ */
.sidebar {
  width: 240px;
  background: var(--nav-bg, var(--sidebar));
  color: var(--nav-text);
  padding: 24px 0 16px;
  flex-shrink: 0;
  position: fixed; left: 0; top: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
}
.sidebar .logo { text-align: center; padding: 0 20px 20px; border-bottom: 1px solid var(--nav-active-bg, #334155); margin-bottom: 16px; }
.sidebar .logo h2 { font-size: 1.3em; font-weight: 600; color: var(--nav-title); display: flex; align-items: center; justify-content: center; gap: 8px; }
.sidebar .logo p { font-size: 0.75em; color: #94a3b8; margin-top: 4px; }
.sidebar nav { flex: 1; }
.sidebar nav a, .sidebar-foot button {
  display: flex; align-items: center; gap: 10px;
  color: var(--nav-text);
  padding: 12px 24px;
  text-decoration: none;
  font-size: var(--fs-md);
  cursor: pointer;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
  background: none; border-top: none; border-right: none; border-bottom: none;
  width: 100%; text-align: left; font-family: inherit;
}
.sidebar nav a:hover, .sidebar-foot button:hover { background: var(--nav-active-bg, #334155); color: #fff; }
.sidebar nav a.active { background: var(--nav-active-bg, #334155); color: #fff; border-left-color: var(--primary); }
.sidebar .divider { border-top: 1px solid var(--nav-active-bg, #334155); margin: 12px 0; }
/* 导航分组标题 */
.nav-group-title {
  font-size: 0.7em;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--nav-text);
  opacity: 0.55;
  padding: 16px 24px 4px;
  user-select: none;
}
/* 主题按钮图标：亮色模式显示月亮（点击进入暗色）、暗色模式显示太阳 */
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: inline-block; }
.sidebar-foot { padding: 8px 0 0; border-top: 1px solid var(--nav-active-bg, #334155); }
.sidebar-foot .danger-action { color: #f87171 !important; }

/* ============ 主内容区 ============ */
.main {
  flex: 1;
  padding: 24px;
  margin-left: 240px;
  overflow-y: auto;
  min-height: 100vh;
  padding-bottom: 40px;
}

/* ============ 卡片 ============ */
.card {
  background: var(--card);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  padding: 24px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
}
.card h3 {
  color: var(--text);
  margin-bottom: 20px;
  font-size: 1.3em;
  font-weight: 700;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--border);
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card h3::after { content: ''; position: absolute; bottom: -2px; left: 0; width: 40px; height: 2px; background: var(--primary); border-radius: 2px; }
.card h4 { color: var(--text); margin-bottom: 12px; font-size: 1.05em; }

/* ============ 统计卡（KPI） ============ */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { background: var(--card); border-radius: var(--r-md); padding: 18px 16px; text-align: center; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.stat-card .stat-value { font-size: 1.9rem; font-weight: 700; color: var(--primary); font-family: var(--mono); }
.stat-card .stat-label { font-size: 0.85em; color: var(--muted); margin-top: 4px; }
.stat-card.warn { border-color: var(--warn); }
.stat-card.warn .stat-value { color: var(--warn); }
.stat-card.ok .stat-value { color: var(--avail); }

/* ============ 分段控件 SegBar ============ */
.segbar {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
  flex-wrap: wrap;
}
.seg {
  padding: 7px 16px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  white-space: nowrap;
}
.seg:hover { color: var(--text); }
.seg.active { background: var(--primary); color: #fff; }

/* ============ 搜索栏 ============ */
.search-bar { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; align-items: center; }
.search-bar input, .search-bar select {
  flex: 1; min-width: 160px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: var(--fs-md);
  font-family: var(--mono);
  background: var(--card);
  color: var(--text);
  transition: all 0.2s ease;
}
.search-bar input:focus, .search-bar select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); outline: none; }

/* ============ 房间网格 ============ */
.grid-rooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.room-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}
.room-card:hover { box-shadow: var(--shadow-lg); border-color: var(--primary); }
.room-card .room-header { font-weight: 600; font-size: 1.1em; margin-bottom: 8px; color: var(--text); }
.room-card .rc-badges { display: inline-flex; gap: 4px; margin-left: 6px; vertical-align: middle; }
.rc-badge { font-size: 0.62em; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--border); color: var(--muted); }
.rc-badge-ok { background: var(--brand-50); color: var(--primary); }
.room-card .op-menu-anchor { float: right; margin-top: -4px; }
.room-card .op-trigger { padding: 2px 8px; border-radius: 6px; }
.room-card .op-trigger:hover { background: var(--border); color: var(--primary); border-color: var(--border); }
.room-card .occupants { font-size: 0.85em; color: var(--muted); min-height: 40px; word-break: break-all; }
.room-card .type-badge { font-size: 0.75em; padding: 3px 10px; border-radius: 12px; background: var(--border); color: var(--muted); display: inline-block; margin-top: 8px; }
.room-card .status-indicator { position: absolute; top: 10px; right: 10px; width: 10px; height: 10px; border-radius: 50%; }
.status-available { background: var(--avail); }
.status-occupied { background: var(--occupied); }
.status-booked { background: var(--reserved); }

/* ============ 表格 ============ */
.table-container { overflow-x: auto; margin: 16px 0; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: separate; border-spacing: 0; margin: 16px 0; font-size: var(--fs-md); table-layout: auto; border-radius: var(--r-md); overflow: hidden; }
th, td { border-bottom: 1px solid var(--border); padding: 12px 14px; text-align: left; word-wrap: break-word; overflow-wrap: break-word; line-height: 1.6; vertical-align: middle; }
th { background: linear-gradient(135deg, var(--card) 0%, var(--bg) 100%); font-weight: 600; color: var(--muted); font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: 0.4px; white-space: nowrap; }
td { background: var(--card); min-width: 70px; }
tr:hover td { background: var(--bg); }
tr:last-child td { border-bottom: none; }
td.num, .num { font-family: var(--mono); }
.td-date { font-family: var(--mono); }
.empty-tip { text-align: center; color: var(--muted); padding: 32px 0; }

/* ============ 徽章 ============ */
.badge { padding: 4px 12px; border-radius: 12px; font-size: 0.75em; color: white; font-weight: 500; white-space: nowrap; display: inline-block; }
.badge-available { background: var(--avail); }
.badge-occupied { background: var(--occupied); }
.badge-reserved { background: var(--reserved); }
.badge-full { background: #3b82f6; }
.badge-summer { background: #f97316; }
.badge-winter { background: #14b8a6; }
.badge-monthly { background: #8b5cf6; }
.badge-gray { background: var(--ink-3); }

/* ============ 按钮 ============ */
.btn {
  padding: 9px 16px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: var(--fs-md);
  font-weight: 500;
  transition: all 0.2s ease;
  margin: 4px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--avail); color: white; }
.btn-success:hover { background: #16a34a; }
.btn-warning { background: var(--reserved); color: white; }
.btn-warning:hover { background: #d97706; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 5px 12px; font-size: var(--fs-sm); }
.btn-block { width: 100%; justify-content: center; }

/* ============ 表单 ============ */
.form-group { margin: 12px 0; }
.form-group label { display: block; font-size: var(--fs-sm); font-weight: 500; margin-bottom: 6px; color: var(--text); }
input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: var(--fs-md);
  font-family: var(--mono);
  background: var(--card);
  color: var(--text);
  transition: border-color 0.2s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
input[type="date"] { font-family: var(--mono); }
input[readonly] { background: var(--bg); color: var(--muted); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.error-message { color: var(--danger); font-size: var(--fs-sm); margin-top: 4px; }
.checkbox-line { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.checkbox-line input[type="checkbox"] { width: 18px; height: 18px; }
.checkbox-line label { margin: 0; font-size: var(--fs-md); }

/* 费用摘要卡 */
.summary-box { background: var(--bg); padding: 14px; border-radius: 10px; margin: 14px 0; border: 1px solid var(--border); }
.summary-row { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: var(--fs-md); }
.summary-row.total { font-weight: 600; border-top: 1px dashed var(--border); padding-top: 8px; }
.summary-row.total .val { color: var(--primary); }

/* ============ 教室座位（按排布局，A+C 风格） ============ */
.classroom-map { display: flex; flex-direction: column; gap: 12px; margin: 16px 0 18px; }
.seat-row { display: flex; align-items: flex-start; gap: 10px; }
.seat-row-label { flex: 0 0 54px; font-size: 0.72em; color: var(--muted); padding-top: 14px; font-weight: 600; }
.seat-row-seats { display: flex; flex-wrap: wrap; gap: 10px; flex: 1; }
.seat-cell {
  width: 92px; min-height: 74px;
  display: flex; flex-direction: column; justify-content: space-between;
  border-radius: 10px; padding: 8px 10px;
  font-size: 13px; cursor: pointer;
  border: 1.5px solid transparent;
  transition: transform 0.15s, box-shadow 0.15s;
}
.seat-cell:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.seat-cell.free { background: var(--free); border-color: var(--free); color: #475569; }
[data-theme="dark"] .seat-cell.free { background: #334155; border-color: #334155; color: #cbd5e1; }
.seat-cell.used { background: #fef2f2; border-color: var(--occupied); color: var(--occupied); }
[data-theme="dark"] .seat-cell.used { background: #450a0a; border-color: var(--occupied); }
.seat-cell.seat-spacer { visibility: hidden; pointer-events: none; border: none; background: transparent; box-shadow: none; }
.seat-cell .sc-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.sc-no { font-weight: 700; font-size: 0.95em; }
.sc-state { font-size: 0.62em; opacity: 0.8; }
.sc-name { font-size: 0.85em; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 4px; }
.sc-bed { font-size: 0.68em; opacity: 0.8; cursor: pointer; margin-top: 2px; align-self: flex-start; }
.sc-bed:hover { text-decoration: underline; }
/* 教室详情弹窗加宽（仅含 classroom-map 时生效） */
.modal-content:has(.classroom-map) { max-width: 740px; min-width: 560px; }

/* ============ 教室示意图（方格画布） ============ */
.toolbar-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.cm-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.cm-tool {
  padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--card);
  cursor: pointer; font-size: 0.8em; font-family: inherit;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all 0.15s;
}
.cm-tool:hover { border-color: var(--primary); }
.cm-tool.active { border-color: var(--primary); color: var(--primary); font-weight: 600; background: var(--brand-50); }
.cm-swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; border: 1px solid rgba(0,0,0,0.12); }
.cm-grid {
  display: grid; gap: 2px; padding: 10px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  margin: 12px 0; overflow-x: auto; user-select: none;
  touch-action: none;
}
.cm-cell {
  width: 26px; height: 26px; border-radius: 4px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 0.62em; color: #fff; font-weight: 600;
  border: 1px solid transparent;
}
.cm-cell.cm-empty { background: transparent; border-color: var(--border); color: transparent; }
[data-theme="dark"] .cm-cell.cm-empty { border-color: #334155; }
.cm-wall { background: #475569; }
.cm-desk { background: #22c55e; }
.cm-chair { background: #0ea5e9; }
.cm-aisle { background: #e2e8f0; color: #64748b; }
[data-theme="dark"] .cm-aisle { background: #293548; color: #94a3b8; }
.cm-podium { background: #8b5cf6; }
.cm-window { background: #06b6d4; }
.cm-door { background: #b45309; }
.cm-seat { background: #3b82f6; font-size: 0.58em; padding: 0 2px; cursor: grab; }
.cm-seat:active { cursor: grabbing; }
.cm-cell[data-dragtarget="1"] { outline: 3px solid var(--primary); outline-offset: -1px; z-index: 3; transform: scale(1.06); }
/* 示意图查看模式：座位实时状态 */
.cm-view .cm-cell { cursor: default; }
.cm-cell.cm-used { background: var(--occupied); color: #fff; font-size: 0.6em; font-weight: 700; padding: 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-cell.cm-free { background: var(--avail); color: #14532d; font-size: 0.6em; font-weight: 600; }
[data-theme="dark"] .cm-cell.cm-free { color: #dcfce7; }
.cm-cell.cm-miss { background: var(--reserved); color: #fff; font-size: 0.58em; font-weight: 700; }
.cm-legend { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 0.72em; margin-right: 6px; color: #fff; }
.cm-legend-used { background: var(--occupied); }
.cm-legend-free { background: var(--avail); color: #14532d; }
.cm-legend-miss { background: var(--reserved); }

/* ============ 楼层示意图（整层平面总览） ============ */
.floor-wrap {
  display: flex; flex-wrap: wrap; gap: 22px; align-items: flex-start;
  padding: 18px; margin: 6px 0 14px;
  background: var(--bg); border: 1px dashed var(--border); border-radius: 14px;
}
.floor-room {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px; cursor: pointer; transition: all 0.15s;
}
.floor-room:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.floor-room .floor-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; font-weight: 700; font-size: 0.85em; margin-bottom: 8px; color: var(--text); }
.floor-room .floor-stats { font-size: 0.72em; font-weight: 500; color: var(--muted); }
.floor-room .cm-grid { padding: 6px; gap: 2px; margin: 0; border-radius: 8px; }
.floor-room .cm-cell { width: 22px; height: 22px; font-size: 0.52em; cursor: pointer; }
.floor-room.no-map { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-width: 130px; min-height: 90px; text-align: center; color: var(--muted); font-size: 0.8em; }

/* 楼层排布（自由摆放教室位置） */
.floor-canvas {
  position: relative;
  background:
    repeating-linear-gradient(0deg, transparent, transparent 47px, var(--border) 47px, var(--border) 48px),
    repeating-linear-gradient(90deg, transparent, transparent 47px, var(--border) 47px, var(--border) 48px),
    var(--bg);
  border: 1px solid var(--border); border-radius: 12px;
  margin: 8px 0 16px; overflow: auto;
}
/* 楼层总图：表格合并单元格布局 */
.floor-scroll {
  overflow-x: auto;
  padding-bottom: 0;
  position: relative;
  scrollbar-width: none;
}
.floor-scroll::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148,163,184,.5); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(100,116,139,.75); }
::-webkit-scrollbar-corner { background: transparent; }
/* 自定义滚动条：sticky 贴容器可视底部，hover 时出现（JS 事件驱动加 .sb-show） */
.sb-bar {
  position: sticky; bottom: 0; left: 0;
  height: 12px; margin-top: -12px;
  display: flex; align-items: center;
  padding: 0 6px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
  background: transparent;
}
.floor-scroll.sb-show .sb-bar { opacity: 1; pointer-events: auto; }
.sb-thumb {
  height: 5px; border-radius: 999px;
  background: rgba(128, 138, 152, 0.35);
  min-width: 48px; cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}
.sb-thumb:hover { background: rgba(128, 138, 152, 0.55); }
.sb-thumb:active { background: rgba(128, 138, 152, 0.65); }
.floor-table {
  display: grid; gap: 4px; padding: 4px;
  grid-template-columns: repeat(var(--fc, 2), minmax(120px, 1fr));
  background:
    repeating-linear-gradient(0deg, transparent, transparent 47px, var(--border) 47px, var(--border) 48px),
    repeating-linear-gradient(90deg, transparent, transparent 47px, var(--border) 47px, var(--border) 48px),
    var(--bg);
  border: 1px solid var(--border); border-radius: 12px;
  margin: 8px 0 16px; overflow: auto; min-width: 0;
}
.floor-block {
  position: absolute;
  background: var(--card); border: 1.5px solid var(--ink-3); border-radius: 6px;
  padding: 10px; cursor: pointer; transition: all 0.15s;
}
.floor-block:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.floor-block .floor-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; font-weight: 700; font-size: 0.85em; margin-bottom: 6px; color: var(--text); }
.floor-block .floor-stats { font-size: 0.72em; font-weight: 500; color: var(--muted); }
.floor-block .cm-grid { padding: 6px; gap: 2px; margin: 0; border-radius: 6px; background: var(--bg); }
.floor-block .cm-cell { width: 22px; height: 22px; font-size: 0.52em; cursor: pointer; }
.floor-block.no-map { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-width: 120px; min-height: 80px; text-align: center; color: var(--muted); font-size: 0.8em; }
.floor-unplaced { margin: 10px 0; }
.floor-cell-empty { background: var(--bg); border: 1px dashed var(--border); border-radius: 0; min-height: 44px; }

/* 表格样式教室块（纯表格：表头条 + 座位单元格区） */
.floor-block-grid {
  position: static; display: flex; flex-direction: column;
  border: 1.5px solid var(--primary); border-radius: 0; padding: 0;
  background: var(--card); min-width: 0; overflow: hidden;
}
.floor-block-grid:hover { border-color: var(--primary); box-shadow: none; transform: none; }
.fbg-head {
  display: flex; justify-content: space-between; align-items: center; gap: 4px;
  padding: 4px 8px; border-bottom: 1.5px solid var(--primary);
  background: var(--brand-50); font-weight: 700; font-size: 0.85em; color: var(--text);
}
.fbg-name { white-space: nowrap; }
.fbg-meta { font-size: 0.68em; font-weight: 500; color: var(--muted); white-space: nowrap; }
.fbg-pct { font-size: 0.7em; font-weight: 500; color: var(--muted); }
.fbg-grid {
  display: grid; gap: 1px; padding: 4px; flex: 1; justify-content: center; align-content: center;
  background: var(--border); border: none; border-radius: 0;
}
.fbg-cell {
  width: 100%; height: 28px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  font-size: 0.72em; font-weight: 600; padding: 0 2px;
  border-radius: 0; cursor: pointer; overflow: hidden; white-space: nowrap;
  transition: all 0.12s;
}
.fbg-cell:hover { filter: brightness(0.94); }
.fbg-cell b { font-weight: 600; line-height: 1; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.fbg-arrow { font-style: normal; font-size: 0.55em; line-height: 1; opacity: 0.85; }
.fbg-cell.free { background: var(--avail); color: #14532d; }
[data-theme="dark"] .fbg-cell.free { color: #dcfce7; }
.fbg-cell.used { background: var(--occupied); color: #fff; }
.fbg-grid-map { justify-content: stretch; }
.fbg-grid-map .fbg-cell { width: 100%; height: 28px; font-size: 0.72em; }
.fbg-grid-map .fbg-arrow { font-size: 0.6em; }
.fbg-blank { background: var(--bg); cursor: default; }
.fbg-blank:hover { filter: none; }
.fbg-grid-map .fbg-blank { color: var(--muted); opacity: 0.55; }
.fp-mapbtn { font-size: 0.6em; font-weight: 600; color: var(--primary); border: 1px solid var(--primary); border-radius: 999px; padding: 0 6px; cursor: pointer; }

/* 楼层教室面板（座位按钮样式，参考座位分布界面） */
.floor-block.floor-panel { min-width: 220px; }
.fp-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 700; font-size: 0.85em; color: var(--text); margin-bottom: 4px; }
.fp-pct { font-size: 0.7em; font-weight: 500; color: var(--muted); }
.fp-mapbtn:hover { background: var(--primary); color: #fff; }
.fp-stats { display: flex; justify-content: space-between; font-size: 0.72em; color: var(--muted); margin-bottom: 8px; }
.fp-seats { display: flex; flex-wrap: wrap; gap: 5px; }
.fp-seat {
  position: relative; flex: 0 0 auto; width: 44px; min-height: 38px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72em; font-weight: 600; padding: 2px 4px; cursor: pointer;
  transition: all 0.15s;
}
.fp-seat:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.fp-seat.free { background: var(--avail); color: #14532d; }
[data-theme="dark"] .fp-seat.free { color: #dcfce7; }
.fp-seat.used { background: var(--occupied); color: #fff; }
.fp-zuo { position: absolute; bottom: 2px; right: 5px; font-size: 0.58em; opacity: 0.75; }

/* 楼层走廊条带（表格内合并单元格样式） */
.floor-corridor {
  position: static; z-index: 1;
  background: repeating-linear-gradient(45deg, #aab7c6, #aab7c6 6px, #c3cdd8 6px, #c3cdd8 12px);
  color: #3f4c5c; border: 1px solid #8b99aa; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72em; font-weight: 700; letter-spacing: 3px;
  min-height: 40px;
}
.floor-slot.has-corridor { border-style: solid; border-color: #8b99aa; background: #e2e8f0; }
.floor-slot .fl-corridor { color: #3f4c5c; font-size: 0.72em; font-weight: 600; letter-spacing: 1px; }

/* 楼层图统计行（参照房间卡片统计样式：空闲/在住） */
.floor-total {
  display: inline-block; margin: 10px 0 4px; padding: 6px 14px;
  background: var(--card); border: 1px solid var(--border); border-radius: 999px;
  font-size: 0.8em; font-weight: 600; color: var(--text);
}
.floor-statline {
  display: flex; justify-content: space-between; gap: 10px;
  margin-top: 8px; padding-top: 6px; border-top: 1px dashed var(--border);
  font-size: 0.68em; color: var(--muted);
}
.floor-edit-grid { display: grid; gap: 10px; margin: 12px 0; }
.floor-slot {
  min-height: 72px; border: 1.5px dashed var(--border); border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  cursor: pointer; transition: all 0.15s; font-size: 0.85em;
}
.floor-slot:hover { border-color: var(--primary); background: var(--brand-50); }
.floor-slot.has-room { border-style: solid; border-color: var(--primary); background: var(--brand-50); color: var(--text); cursor: grab; padding: 4px; overflow: hidden; }
.floor-slot.has-room:active { cursor: grabbing; }
.floor-slot[data-dragtarget="1"] { outline: 3px solid var(--primary); outline-offset: -1px; transform: scale(1.04); z-index: 3; }
/* 编辑槽位内的教室紧凑座位面板 */
.fl-roompanel { position: relative; display: flex; flex-direction: column; gap: 3px; min-height: 46px; }
.fl-rp-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 0.78em; font-weight: 700; color: var(--text); }
.fl-rp-pct { font-size: 0.68em; font-weight: 500; color: var(--muted); }
.fl-rp-seats { display: flex; flex-wrap: wrap; gap: 2px; }
.fl-rp-seat { font-size: 0.58em; font-weight: 600; padding: 1px 4px; border-radius: 3px; line-height: 1.5; cursor: default; max-width: 100%; overflow: hidden; white-space: nowrap; }
.fl-rp-seat.free { background: var(--avail); color: #14532d; }
[data-theme="dark"] .fl-rp-seat.free { color: #dcfce7; }
.fl-rp-seat.used { background: var(--occupied); color: #fff; }
.fl-roompanel .fl-remove { position: absolute; top: 2px; right: 4px; font-size: 0.68em; color: var(--muted); cursor: pointer; opacity: 0.7; }
.fl-roompanel .fl-remove:hover { opacity: 1; color: var(--danger, #ef4444); }
.floor-slot .fl-empty { color: var(--ink-3); font-size: 0.72em; }
.floor-slot .fl-remove { color: var(--danger); font-size: 0.7em; }
.fl-label { font-size: 0.85em; color: var(--muted); }

/* 管理座位：座位格删除按钮 */
.seat-cell { position: relative; }
.sc-del {
  position: absolute; top: 2px; right: 2px; z-index: 2;
  width: 16px; height: 16px; line-height: 14px; text-align: center;
  background: rgba(239, 68, 68, 0.9); color: #fff; border-radius: 50%;
  font-size: 0.6em; cursor: pointer; opacity: 0.85;
}
.sc-del:hover { opacity: 1; transform: scale(1.1); }

/* 教室占位图：大方格展示入住人信息 */
.occ-grid { display: grid; gap: 12px; margin: 12px 0; }
.seat-cell.seat-cell-lg {
  min-height: 110px; border-radius: 14px; padding: 12px 10px;
  display: flex; flex-direction: column; gap: 6px; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: all 0.15s;
}
.seat-cell.seat-cell-lg:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.seat-cell.seat-cell-lg .sc-top { display: flex; justify-content: space-between; align-items: center; font-size: 0.8em; gap: 4px; }
.seat-cell.seat-cell-lg .sc-no { font-weight: 700; }
.seat-cell.seat-cell-lg .sc-state { font-size: 0.72em; opacity: 0.85; background: rgba(255,255,255,0.22); padding: 1px 8px; border-radius: 999px; }
.seat-cell.seat-cell-lg .sc-name { font-size: 1.35em; font-weight: 700; line-height: 1.15; word-break: break-all; }
.seat-cell.seat-cell-lg .sc-bed { font-size: 0.75em; opacity: 0.9; }
.seat-cell.seat-cell-lg .sc-empty { font-size: 0.85em; opacity: 0.55; margin-top: 6px; }
[data-theme="dark"] .seat-cell.seat-cell-lg .sc-name,
[data-theme="dark"] .seat-cell.seat-cell-lg .sc-no { color: #fff; }

/* 占位图按示意图布局：大方格 + 图块混合网格 */
.occ-map { display: grid; gap: 6px; margin: 12px 0; }
.occ-map .cm-cell { width: 100%; height: 52px; font-size: 0.62em; }
.occ-map .seat-cell.seat-cell-lg { min-height: 52px; height: 52px; border-radius: 8px; padding: 5px 4px; gap: 1px; box-shadow: none; }
.occ-map .seat-cell.seat-cell-lg .sc-top { font-size: 0.6em; }
.occ-map .seat-cell.seat-cell-lg .sc-state { font-size: 0.58em; padding: 0 5px; }
.occ-map .seat-cell.seat-cell-lg .sc-name { font-size: 0.92em; }
.occ-map .seat-cell.seat-cell-lg .sc-bed { font-size: 0.58em; }
.occ-map .seat-cell.seat-cell-lg .sc-empty { font-size: 0.68em; margin-top: 2px; }

/* ============ Toast（统一右下角） ============ */
#toastWrap { position: fixed; right: 18px; bottom: 90px; z-index: 3000; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
.toast {
  padding: 10px 18px;
  border-radius: 10px;
  color: white;
  font-size: var(--fs-md);
  font-weight: 500;
  z-index: 3000;
  animation: slideInRight 0.3s ease;
  box-shadow: var(--shadow-lg);
  max-width: 86vw;
}
.toast-success { background: var(--avail); }
.toast-error { background: var(--occupied); }
.toast-warning { background: var(--reserved); }
.toast-info { background: var(--primary); }
@keyframes slideInRight { from { transform: translateX(24px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ============ 弹窗 ============ */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); justify-content: center; align-items: center; z-index: 1000; }
.modal.active { display: flex; }
.modal-content {
  background: var(--card);
  border-radius: var(--r-lg);
  padding: 24px 28px;
  min-width: 480px;
  max-width: 92%;
  max-height: 86vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: modalFadeIn 0.2s ease;
  color: var(--text);
}
@keyframes modalFadeIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
.modal-content h3 { margin-bottom: 16px; font-size: 1.2em; color: var(--text); }
.modal-close {
  position: absolute; right: 14px; top: 14px;
  font-size: 20px; cursor: pointer;
  color: var(--ink-3);
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; transition: background 0.2s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-foot { margin-top: 20px; text-align: right; }

/* ============ 语义工具类（统一收编内联样式） ============ */
/* 布局辅助 */
.d-none { display: none !important; }
.span-all { grid-column: 1 / -1; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.btn-group { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn-file { cursor: pointer; margin: 4px; }
.section-title { margin: 20px 0 12px; font-weight: 600; color: var(--text); }
.section-head { font-weight: 600; margin-bottom: 12px; color: var(--text); }
.section-block { margin-bottom: 14px; }
.mt-14 { margin-top: 14px; }
.mt-12 { margin-top: 12px; }
.hint-text { margin-bottom: 15px; color: var(--muted); font-size: var(--fs-sm); }
.import-block { padding: 12px 14px; border: 1px dashed var(--border); border-radius: 10px; margin-bottom: 14px; }
.import-block h4 { margin: 0 0 8px; font-size: 14px; }

/* 文本状态色 */
.text-muted { color: var(--muted); }
.sub-text { font-size: 0.78em; line-height: 1.15; margin-top: 1px; }
.text-ok { color: var(--avail); }
.text-warn { color: var(--reserved); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }

/* 金额数字列 */
.num-ok { color: var(--avail); font-weight: 600; }
.num-warn { color: var(--reserved); font-weight: 600; }
.num-primary { color: var(--primary); font-weight: 600; }

/* 微排版 */
.meta-sm { font-size: 0.7em; color: var(--ink-3); }
.card-stats { font-size: 0.7em; color: var(--ink-3); margin-top: auto; padding-top: 8px; border-top: 1px dashed var(--border); }
.td-date-resv { color: var(--reserved); }
.divider-line { border-top: 1px dashed var(--border); margin: 14px 0; }

/* 提示框 */
.alert-box { border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; font-size: var(--fs-sm); }
.alert-danger { background: #fef2f2; border: 1px solid #fecaca; }
.alert-warn { background: #fffbeb; border: 1px solid #fde68a; }
.alert-title { font-weight: 600; margin-bottom: 6px; }
.alert-body { color: var(--text); margin-top: 4px; }
.alert-sub { color: var(--muted); margin-top: 4px; }
.info-box { color: var(--warn); background: var(--brand-50); padding: 10px 12px; border-radius: 8px; font-size: var(--fs-sm); margin-bottom: 10px; }

/* 教室座位占位格 */
.seat-spacer { border: none; background: transparent; }

/* 分页条 */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 12px 0 4px;
}
.page-info { font-size: 12px; color: var(--muted); }
.pagination .btn[disabled] { opacity: 0.4; cursor: not-allowed; }

/* 座位下宿舍床位关联标签（无边框纯文本） */
.bed-tag {
  display: inline-block;
  margin-top: 3px;
  padding: 1px 6px;
  font-size: 10px;
  line-height: 1.5;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 0;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
}
.bed-tag:hover { color: var(--primary); background: transparent; }

/* 费用摘要辅助 */
.summary-box-accent { background: var(--brand-50); }
.total-gap { margin-top: 10px; }
.arrears-row { display: flex; justify-content: space-between; font-size: var(--fs-sm); padding: 4px 0; border-bottom: 1px dashed #fecaca; }

/* 房间详情操作：三点按钮 + 下拉菜单 */
.op-wrap { position: relative; display: inline-block; }.op-trigger {
  width: 30px; height: 30px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 8px;
  font-size: 16px; line-height: 1;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.op-trigger:hover { background: var(--brand-50); border-color: var(--primary); color: var(--primary); }
.op-menu {
  position: fixed; z-index: 300;
  min-width: 132px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 5px;
  display: flex; flex-direction: column; gap: 2px;
}
.op-item {
  display: block; width: 100%; text-align: left;
  padding: 9px 12px;
  border: none; background: none;
  font-size: var(--fs-md);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.op-item:hover { background: var(--brand-50); }
.op-danger { color: var(--danger); }
.op-danger:hover { background: #fef2f2; }
.op-primary { color: var(--primary); }

/* 设置页标签页 */
.settings-tabs {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.settings-tab {
  padding: 9px 16px;
  border: none; background: none;
  color: var(--muted);
  font-size: var(--fs-md);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s;
}
.settings-tab:hover { color: var(--primary); }
.settings-tab.active { color: var(--primary); font-weight: 600; border-bottom-color: var(--primary); }

/* ============ 确认框 ============ */
.confirm-dialog {
  display: none;
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--card);
  border-radius: var(--r-lg);
  padding: 24px;
  min-width: 320px; max-width: 90%;
  z-index: 2001;
  box-shadow: var(--shadow-lg);
  color: var(--text);
}
.confirm-dialog.active { display: block; animation: modalFadeIn 0.2s ease; }
.confirm-dialog h4 { margin-bottom: 10px; font-size: 1.1em; }
.confirm-dialog p { color: var(--muted); margin-bottom: 18px; line-height: 1.6; word-break: break-all; }
.confirm-dialog .btn-group { display: flex; justify-content: flex-end; gap: 8px; }

/* ============ Loading 遮罩 ============ */
.loading-mask {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(15,23,42,0.45);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 4000; gap: 12px; color: #fff; font-size: var(--fs-md);
}
.loading-spinner {
  width: 34px; height: 34px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ 移动端 ============ */
.menu-toggle { display: none; }
.overlay { display: none; }
.tabbar { display: none; }

@media (max-width: 768px) {
  body { display: block; padding-bottom: 60px; }
  .sidebar {
    width: 78%; max-width: 300px;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 1000;
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; padding: 14px; padding-bottom: 80px; }
  .modal-content { min-width: 92%; padding: 20px; }
  .grid-rooms { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .menu-toggle {
    display: flex !important;
    width: 40px; height: 40px;
    background: var(--sidebar); color: white;
    border: none; border-radius: 8px;
    font-size: 18px; cursor: pointer;
    position: fixed; top: 12px; left: 12px; z-index: 1001;
    align-items: center; justify-content: center;
  }
  .overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 999; }
  .overlay.active { display: block; }
  .search-bar { flex-direction: column; align-items: stretch; }
  .search-bar input, .search-bar select { min-width: 100%; }
  .segbar { width: 100%; flex-wrap: wrap; row-gap: 6px; }
  .seg { flex: 1; padding: 7px 6px; text-align: center; }

  /* 底部 Tab Bar（6 项） */
  .tabbar {
    display: flex;
    position: fixed; left: 0; right: 0; bottom: 0;
    height: 56px;
    background: var(--card);
    border-top: 1px solid var(--border);
    z-index: 900;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px;
    color: var(--muted);
    text-decoration: none;
    font-size: var(--fs-xs);
    cursor: pointer;
  }
  .tabbar a.active { color: var(--primary); font-weight: 600; }
  .tabbar svg { width: 20px; height: 20px; }

  table { font-size: var(--fs-sm); }
  th, td { padding: 8px 10px; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .stat-card .stat-value { font-size: 1.5rem; }
  .form-row { grid-template-columns: 1fr; }
}

/* ============================================================
   A+C 组合风格：上下铺色块矩阵（房间页）
   - 每间房间内床位按两两分组（上铺/下铺纵向排列）
   - 状态色走可配置变量：--occupied / --reserved / --avail
   ============================================================ */
.toolbar-row { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.bunk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, 56px);
  justify-content: start;
  gap: 6px;
  margin: 10px 0 4px;
}
.bunk-pair { display: grid; grid-template-rows: 1fr 1fr; grid-template-columns: 1fr; gap: 5px; min-width: 0; }
.bunk-cell {
  position: relative;
  border-radius: 6px;
  padding: 6px 4px;
  text-align: center;
  cursor: pointer;
  min-height: 46px;
  min-width: 0;
  overflow: hidden;
  transition: transform 0.12s, box-shadow 0.12s;
}
.bunk-cell:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.bunk-cell.occupied { background: var(--occupied); color: #fff; }
.bunk-cell.booked { background: var(--reserved); color: #fff; }
.bunk-cell.available { background: var(--free); color: #475569; }
[data-theme="dark"] .bunk-cell.available { background: #334155; color: #cbd5e1; }
.bunk-cell .bc-lv {
  position: absolute; top: 3px; left: 6px;
  font-size: 9px; font-weight: 600; opacity: 0.9;
}
.bunk-cell .bc-no { font-size: 11px; font-weight: 700; line-height: 1.2; }
.bunk-cell .bc-name { font-size: 10px; margin-top: 2px; opacity: 0.95; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bunk-cell.empty-slot { visibility: hidden; }

/* 房间楼层示意图 */
.map-section { margin: 18px 0 8px; font-size: 14px; color: var(--text); }
.map-section::before { content: ''; display: inline-block; width: 4px; height: 14px; background: var(--primary); border-radius: 2px; margin-right: 6px; vertical-align: -2px; }
.room-floor-table { grid-template-columns: repeat(4, minmax(200px, 1fr)); }
.room-floor-table .floor-block-grid { min-width: 0; }
.rm-grid { display: grid; grid-auto-flow: column; grid-template-rows: repeat(2, 42px); gap: 4px; justify-content: center; padding: 8px 10px; }
.rm-cell {
  width: 56px; height: 42px; border-radius: 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: #fff; cursor: pointer;
  gap: 1px; overflow: hidden; white-space: nowrap; padding: 2px 3px;
  transition: all 0.12s;
}
.rm-cell:hover { transform: translateY(-1px); filter: brightness(1.08); }
.rm-cell .rm-lv { font-size: 9px; opacity: 0.85; line-height: 1; }
.rm-cell .rm-no { font-size: 10.5px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rm-cell.occupied { background: var(--occupied); }
.rm-cell.booked { background: var(--reserved); }
.rm-cell.available { background: var(--avail); color: #0b2b12; }
.rm-cell.available .rm-lv { color: #0b2b12; }
.rm-empty { background: transparent; border: 1px dashed var(--border); cursor: default; }
.map-legend { display: inline-flex; align-items: center; margin-right: 14px; font-size: 12px; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-right: 4px; }
.dot-occupied { background: var(--occupied); }
.dot-booked { background: var(--reserved); }
.dot-avail { background: var(--avail); }

/* 房间卡宿舍类型标识 */
.gender-tag {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: 1px;
  font-weight: 600;
}
.gender-tag.male { background: #dbeafe; color: #1d4ed8; }
.gender-tag.female { background: #fce7f3; color: #db2777; }

/* 房间详情表：上/下铺小标签 */
.level-tag {
  display: inline-block;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg);
  color: var(--muted);
  margin-left: 4px;
  vertical-align: 1px;
}

/* ============================================================
   外观设置面板（可配置颜色）
   ============================================================ */
.appearance-block { margin-bottom: 18px; }
.app-block-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 8px;
  letter-spacing: 0.4px;
}
.app-hint { font-size: 11px; color: var(--muted); margin-top: 6px; line-height: 1.6; }
.color-presets { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.color-dot {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.12s;
}
.color-dot:hover { transform: scale(1.12); }
.color-dot.active { border-color: var(--text); box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--text); }
.color-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px dashed var(--border);
}
.color-row:last-of-type { border-bottom: none; }
.color-name { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.color-chip { width: 16px; height: 16px; border-radius: 4px; display: inline-block; }
.color-row input[type="color"] {
  width: 52px; height: 30px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  cursor: pointer;
}

/* ============================================================
   移动端专属 UI 重构 v3（≤768px）
   A+C 组合：深色导航 + 紧凑数据 + 色块矩阵
   ============================================================ */
@media (min-width: 769px) {
  .mobile-topbar { display: none; }
}
@media (max-width: 768px) {
  body { background: var(--page-bg); display: block; }
  .main { padding: 12px 12px 80px; }

  /* 深色顶栏 */
  .mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--nav-bg, #1e293b);
    color: var(--nav-text);
    padding: 10px 12px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
  }
  .menu-toggle {
    position: static;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px; height: 34px;
    border-radius: 8px;
    background: transparent;
    color: var(--nav-text);
    font-size: 18px;
    box-shadow: none;
  }
  .mobile-title { font-size: 15px; font-weight: 700; letter-spacing: 0.3px; }

  /* 卡片：小圆角 / 细边框 / 紧凑 */
  .card { border-radius: 10px; border: 1px solid var(--border); padding: 14px 12px; margin-bottom: 12px; }
  .card h3 { font-size: 1.05rem; margin-bottom: 12px; padding-bottom: 8px; }
  .card h3::after { width: 22px; height: 3px; }

  /* 统计卡 */
  .stats-row { gap: 8px; margin-bottom: 12px; }
  .stat-card { border-radius: 10px; padding: 12px 8px; }
  .stat-card .stat-value { font-size: 1.45rem; }

  /* 分段 / 筛选：紧凑小圆角 */
  .segbar { border-radius: 8px; padding: 3px; }
  .seg { border-radius: 6px; padding: 7px 10px; font-size: var(--fs-sm); }
  .search-bar { gap: 6px; margin-bottom: 12px; }
  .search-bar input, .search-bar select {
    border-radius: 8px;
    padding: 9px 12px;
    -webkit-appearance: none; appearance: none;
  }

  /* 表格：保持紧凑表格形态（横滑查看），去卡片化 */
  .table-container { overflow-x: auto; margin: 10px 0; }
  .table-container table { display: table; }
  .table-container tbody { display: table-row-group; }
  .table-container tbody tr { display: table-row; background: none; border-radius: 0; padding: 0; margin: 0; box-shadow: none; }
  .table-container td { display: table-cell; justify-content: initial; gap: 0; padding: 8px 10px; border-bottom: 1px solid var(--border); min-width: 0; background: transparent; }
  .table-container td::before { content: none; }
  .table-container td > * { text-align: left; }
  .table-container tbody tr:hover td { background: var(--hover, rgba(0,0,0,0.02)); }
  .table-container thead th { padding: 8px 10px; font-size: 11px; }

  /* 房间：色块矩阵自适应 */
  .grid-rooms { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .room-card { border-radius: 10px; padding: 12px 10px; }
  .room-card .room-header { font-size: 0.98rem; }
  .bunk-grid { grid-template-columns: repeat(auto-fit, 56px); gap: 5px; }
  .bunk-cell { min-height: 40px; padding: 5px 3px; }
  .bunk-cell .bc-no { font-size: 10px; }
  .bunk-cell .bc-name { font-size: 9px; }

  /* 按钮 / 表单：紧凑小圆角 */
  .btn { border-radius: 8px; padding: 9px 14px; }
  .btn-sm { padding: 6px 10px; }
  .modal-foot .btn { flex: 1; justify-content: center; margin: 0; }
  .form-group { margin: 8px 0; }
  input, select, textarea { border-radius: 8px; padding: 10px 11px; }
  .summary-box { border-radius: 10px; }

  /* 教室座位 */
  .seat-grid { grid-template-columns: repeat(var(--seat-cols, 4), minmax(52px, 1fr)); gap: 6px; }
  .seat-cell { width: auto; height: 54px; border-radius: 8px; }

  /* 弹窗：居中（保留高度滚动） */
  .modal-content {
    width: 94%;
    min-width: 0;
    max-width: 94%;
    max-height: 86vh;
    border-radius: 12px;
    padding: 18px 14px 20px;
  }

  /* 三点菜单 / 告警框 / 分页 */
  .op-menu { border-radius: 10px; }
  .alert-box { border-radius: 12px; }
  .pagination { gap: 6px; margin: 12px 0 4px; }
  .pagination .btn { border-radius: 8px; }

  /* Toast / 深色 TabBar */
  #toastWrap { bottom: 72px; }
  .tabbar {
    background: var(--nav-bg, #1e293b);
    border-top: none;
    box-shadow: 0 -2px 10px rgba(15, 23, 42, 0.25);
    height: 56px;
  }
  [data-theme="dark"] .tabbar { background: var(--nav-bg, #0f172a); border-top: 1px solid var(--nav-active-bg, #1e293b); }
  [data-theme="dark"] .mobile-topbar { background: var(--nav-bg, #0f172a); }
  .tabbar a { font-size: 10px; color: var(--nav-text); }
  .tabbar a.active { color: #fff; font-weight: 700; border-top: 2px solid var(--primary); }
  [data-theme="dark"] .tabbar a.active { color: #fff; border-top-color: var(--nav-text); }
  .tabbar svg { width: 20px; height: 20px; }

  /* 教室座位移动端：格子收窄、弹窗全宽 */
  .modal-content:has(.classroom-map) { min-width: 0; max-width: 96%; padding: 16px 14px; }
  .seat-cell { width: 76px; min-height: 62px; padding: 6px 8px; }
  .seat-row-label { flex-basis: 42px; font-size: 0.66em; padding-top: 10px; }
}
