/* ══════════ 校园宿舍营销管理系统 · 高保真原型 ══════════ */
:root {
  --primary: #0081C6;
  --primary-dark: #00639c;
  --primary-light: #e3f2fb;
  --danger: #e5484d;
  --warn: #e8a013;
  --ok: #2e9e5b;
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1f2733;
  --text-light: #8a94a3;
  --line: #e6eaf0;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(31, 60, 96, .08);
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.55;
  max-width: 560px; margin: 0 auto; min-height: 100vh; position: relative;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select { font-family: inherit; font-size: 14px; }

/* ── 登录 / 强制改密 ── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: linear-gradient(160deg, #0072b3 0%, #0081C6 45%, #4aa8dd 100%); }
.login-card { background: #fff; border-radius: 18px; padding: 30px 26px; width: 100%; max-width: 380px; box-shadow: 0 12px 40px rgba(0,40,80,.25); }
.login-logo { text-align: center; margin-bottom: 24px; }
.logo-mark { width: 58px; height: 58px; margin: 0 auto 12px; background: var(--primary); color: #fff; border-radius: 16px;
  display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700; }
.logo-mark.warn { background: var(--warn); }
.login-logo h1 { font-size: 20px; color: var(--text); }
.login-logo .sub { color: var(--text-light); font-size: 12.5px; margin-top: 4px; }
.demo-accounts { margin-top: 20px; padding-top: 16px; border-top: 1px dashed var(--line); }
.demo-accounts p { font-size: 12px; color: var(--text-light); margin-bottom: 8px; }
.demo-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 11.5px; padding: 4px 10px; background: var(--primary-light); color: var(--primary-dark); border-radius: 20px; }
.chip:active { opacity: .7; }

/* ── 表单 ── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; color: var(--text); font-weight: 600; margin-bottom: 6px; }
.form-group label .required { color: var(--danger); }
.form-group label .hint { font-weight: 400; color: var(--text-light); font-size: 11.5px; }
.form-group input, .form-group select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fafbfc; outline: none;
  transition: border .15s;
}
.form-group input:focus, .form-group select:focus { border-color: var(--primary); background: #fff; }
.form-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn { border-radius: 10px; font-size: 14.5px; padding: 12px 18px; font-weight: 600; transition: transform .1s, opacity .15s; }
.btn:active { transform: scale(.97); opacity: .85; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-plain { background: #eef1f5; color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; display: block; }

/* ── 顶栏 ── */
.topbar { background: linear-gradient(135deg, #0072b3, #0090d8); color: #fff; position: sticky; top: 0; z-index: 50; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 30px; height: 30px; background: rgba(255,255,255,.18); border-radius: 9px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; }
.brand-name { font-weight: 700; font-size: 15.5px; }
.proto-tag { font-size: 10px; background: rgba(255,255,255,.22); padding: 2px 7px; border-radius: 10px; letter-spacing: 1px; }
.user-zone { display: flex; align-items: center; gap: 8px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.2); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; }
.avatar.big { width: 64px; height: 64px; background: var(--primary); font-size: 26px; margin: 0 auto 10px; }
.user-meta { line-height: 1.25; }
.user-meta strong { font-size: 13.5px; display: block; }
.user-meta em { font-style: normal; font-size: 10.5px; opacity: .92; }
.caret { font-size: 11px; opacity: .8; }
.role-menu { background: #fff; color: var(--text); border-radius: 0 0 14px 14px; box-shadow: 0 10px 30px rgba(0,40,80,.18); padding: 12px 14px; position: absolute; right: 10px; top: 100%; width: 270px; }
.role-menu-title { font-size: 11.5px; color: var(--text-light); margin-bottom: 8px; }
.role-option { padding: 9px 10px; border-radius: 9px; font-size: 13.5px; }
.role-option small { display: block; color: var(--text-light); font-size: 11px; }
.role-option:active, .role-option:hover { background: var(--primary-light); }

/* ── 角色徽章 ── */
.role-badge { padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.role-badge.super_admin { background: #fdecec; color: #c03538; }
.role-badge.admin { background: #fdf0dd; color: #b06e00; }
.role-badge.building_manager { background: #e5f6ec; color: #1f7a45; }
.role-badge.floor_manager { background: #e3f0fd; color: #1c62b9; }
.scope-badge { font-size: 11px; color: var(--text-light); background: #f0f2f5; padding: 2px 8px; border-radius: 10px; }
.vacant { color: var(--danger); }

/* ── 页面容器 ── */
.page { padding: 14px 14px 86px; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card-title { font-size: 15px; margin-bottom: 12px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.card-title .hint { font-weight: 400; font-size: 11.5px; color: var(--text-light); }
.card-head-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-head-row .card-title { margin-bottom: 0; }

/* ── 看板 ── */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--primary); }
.stat-card.warn::before { background: var(--warn); } .stat-card.ok::before { background: var(--ok); } .stat-card.danger::before { background: var(--danger); }
.stat-num { font-size: 26px; font-weight: 800; color: var(--primary-dark); line-height: 1.1; }
.stat-card.warn .stat-num { color: var(--warn); } .stat-card.ok .stat-num { color: var(--ok); } .stat-card.danger .stat-num { color: var(--danger); }
.stat-label { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.bar-row { margin-bottom: 12px; }
.bar-row .bar-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.bar-row .bar-head strong { font-weight: 600; }
.bar-track { height: 10px; background: #edf0f4; border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), #35a7e0); border-radius: 6px; transition: width .5s; }
.bar-fill.ok { background: linear-gradient(90deg, #23915a, #3cb878); }
.mk-tag-row { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 7px; }
.mk-tag-row .pct { color: var(--text-light); }

/* ── 分段选择器 ── */
.seg-scroll { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; }
.seg-scroll::-webkit-scrollbar { display: none; }
.seg-item { flex-shrink: 0; padding: 8px 16px; background: #fff; border-radius: 22px; font-size: 13.5px; font-weight: 600; color: var(--text-light); box-shadow: var(--shadow); }
.seg-item.active { background: var(--primary); color: #fff; }

/* ── 宿舍视图 ── */
.building-block { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 12px; overflow: hidden; }
.bld-head { padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.bld-head .t { font-size: 15px; font-weight: 700; }
.bld-head .mgr { font-size: 12px; color: var(--text-light); }
.floor-block { border-bottom: 1px solid var(--line); }
.floor-head { padding: 9px 14px; background: #fafcfe; font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.floor-head .fl { font-weight: 700; color: var(--primary-dark); }
.floor-head .pen { margin-left: auto; font-size: 11.5px; color: var(--text-light); }
.floor-head .pen b { color: var(--primary); }
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; padding: 12px 14px; }
.room-card { border: 1.5px solid #cfe6f5; background: #f6fbff; border-radius: 10px; padding: 9px 6px; text-align: center; position: relative; }
.room-card:active { transform: scale(.96); }
.room-card .rc-room { font-weight: 800; font-size: 15px; color: var(--primary-dark); }
.room-card .rc-cap { font-size: 11px; color: var(--text-light); margin-top: 2px; }
.room-card .rc-mk { font-size: 10.5px; color: var(--ok); margin-top: 1px; }
.room-card.full { border-color: #f3c1c3; background: #fff7f7; }
.room-card.full .rc-room { color: var(--danger); }
.room-card.empty-dorm { border-color: #e2e5ea; background: #fafbfc; }
.room-card.empty-dorm .rc-room { color: var(--text-light); }
.room-card.zero { border-style: dashed; border-color: #e2e5ea; background: transparent; opacity: .6; }

/* ── 弹窗 ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 30, 50, .45); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(2px); }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 360px; max-height: 82vh; overflow-y: auto; padding: 18px; position: relative; animation: pop .18s ease; }
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-close { position: absolute; right: 12px; top: 12px; width: 28px; height: 28px; border-radius: 50%; background: #f0f2f5; color: var(--text-light); font-size: 13px; }
.modal-head { margin-bottom: 14px; padding-right: 30px; }
.modal-head h3 { font-size: 17px; }
.modal-sub { font-size: 12.5px; color: var(--text-light); }

/* 床位网格（两列） */
.bed-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.bed-cell { border-radius: 11px; padding: 10px 11px; border: 1.5px solid var(--line); background: #fafbfc; font-size: 12.5px; }
.bed-cell .bed-no { font-weight: 800; font-size: 13px; color: var(--text-light); }
.bed-cell.occupied { border-color: #bcd9ee; background: #eef7fd; }
.bed-cell.occupied .bed-no { color: var(--primary-dark); }
.bed-cell.occupied .bed-name { font-weight: 700; font-size: 13.5px; margin-top: 2px; }
.bed-cell .bed-meta { color: var(--text-light); font-size: 11.5px; margin-top: 1px; }
.bed-cell .mk-tag { display: inline-block; margin-top: 4px; font-size: 10.5px; background: #e5f6ec; color: #1f7a45; border-radius: 8px; padding: 1px 7px; }
.bed-cell.vacant-bed { border-style: dashed; color: var(--text-light); }

/* 床位图点选（录入） */
.bed-map { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.bed-pick { border: 1.5px solid var(--line); border-radius: 11px; padding: 10px; text-align: center; background: #fafbfc; font-size: 12.5px; }
.bed-pick .bed-no { font-weight: 800; font-size: 13px; color: var(--text-light); }
.bed-pick .bed-sub { font-size: 11px; color: var(--text-light); margin-top: 2px; }
.bed-pick.empty:active { transform: scale(.96); }
.bed-pick.empty { border-color: #bcd9ee; background: #eef7fd; cursor: pointer; }
.bed-pick.empty .bed-no { color: var(--primary-dark); }
.bed-pick.selected { border-color: var(--primary); background: var(--primary); color: #fff; }
.bed-pick.selected .bed-no, .bed-pick.selected .bed-sub { color: #fff; }
.bed-pick.disabled { opacity: .55; }
.bed-empty-tip { grid-column: 1 / -1; text-align: center; color: var(--text-light); font-size: 12.5px; padding: 10px 0; }

/* ── 管理页 ── */
.admin-tabs { display: flex; gap: 6px; margin-bottom: 12px; background: #fff; border-radius: var(--radius); padding: 5px; box-shadow: var(--shadow); }
.admin-tab { flex: 1; padding: 9px 0; border-radius: 9px; font-size: 13.5px; font-weight: 600; color: var(--text-light); }
.admin-tab.active { background: var(--primary); color: #fff; }
.adm-bld { border: 1px solid var(--line); border-radius: 11px; margin-bottom: 10px; overflow: hidden; }
.adm-bld-head { padding: 10px 12px; background: #fafcfe; display: flex; align-items: center; justify-content: space-between; }
.adm-bld-head .t { font-weight: 700; font-size: 14px; }
.adm-floor { padding: 8px 12px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; }
.adm-dorm-row { display: flex; align-items: center; gap: 8px; padding: 8px 12px 8px 24px; border-top: 1px dashed var(--line); font-size: 13px; }
.adm-dorm-row .dm { font-weight: 600; width: 52px; }
.adm-dorm-row .cap { color: var(--text-light); font-size: 12px; }
.adm-dorm-row .ops { margin-left: auto; display: flex; gap: 5px; }
.user-item { display: flex; align-items: center; gap: 10px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.user-item:last-child { border-bottom: none; }
.user-item .u-info { line-height: 1.3; }
.user-item .u-info strong { font-size: 14px; }
.user-item .u-info .un { color: var(--text-light); font-size: 12px; }
.user-item .u-badges { display: flex; gap: 5px; margin-top: 2px; flex-wrap: wrap; }
.user-item .u-ops { margin-left: auto; display: flex; gap: 5px; flex-shrink: 0; }
.pwd-state { font-size: 10.5px; border-radius: 8px; padding: 1px 7px; }
.pwd-state.init { background: #fdf0dd; color: #b06e00; }
.pwd-state.active { background: #e5f6ec; color: #1f7a45; }
.note-card { background: #fffbe8; border: 1px solid #f3e3ab; border-radius: var(--radius); padding: 12px 14px; font-size: 12.5px; color: #7a621f; margin-bottom: 12px; }
.tpl-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 12px; }
.tpl-table th { background: #f0f4f8; padding: 7px 8px; text-align: left; }
.tpl-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); }

/* ── 我的 ── */
.me-card { text-align: center; padding: 24px 16px; }
.me-card h3 { font-size: 17px; }
.me-scope { font-size: 12.5px; color: var(--text-light); margin-top: 3px; }
.foot-note { text-align: center; color: var(--text-light); font-size: 11.5px; margin-top: 18px; line-height: 1.7; }

/* ── 底部导航 ── */
.tabbar { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 560px;
  background: #fff; border-top: 1px solid var(--line); display: flex; z-index: 60; padding-bottom: env(safe-area-inset-bottom); }
.tab { flex: 1; padding: 8px 0 9px; font-size: 11px; color: var(--text-light); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tab span { font-size: 19px; }
.tab.active { color: var(--primary); font-weight: 700; }

/* ── Toast ── */
.toast { position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%) translateY(20px); background: rgba(25,35,50,.92); color: #fff;
  padding: 10px 20px; border-radius: 24px; font-size: 13.5px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 200; max-width: 80vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: rgba(30,130,80,.95); }
.toast.error { background: rgba(200,55,60,.95); }

@media (min-width: 480px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .room-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}
