:root {
  --primary: #e60012;
  --primary-dark: #b8000e;
  --primary-light: #fff0f1;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1a1a1a;
  --text2: #666;
  --text3: #999;
  --border: #e8e8e8;
  --success: #07c160;
  --warning: #ff9f0a;
  --danger: #fa5151;
  --info: #1677ff;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.05);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.1);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-tap-highlight-color: transparent;
  font-size: 15px; line-height: 1.5;
}

/* ===== 登录页 ===== */
#login-page {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: linear-gradient(160deg, #fff5f6 0%, var(--bg) 60%);
  padding: 24px;
}
.login-card { width: 100%; max-width: 380px; }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .icon {
  width: 72px; height: 72px; border-radius: 20px; margin: 0 auto 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 34px; box-shadow: 0 8px 20px rgba(230,0,18,.3);
}
.login-logo h1 { font-size: 22px; font-weight: 700; }
.login-logo p { color: var(--text2); font-size: 13px; margin-top: 4px; }
.form-card {
  background: var(--card); border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow);
}
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 6px; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 15px; background: #fff; outline: none;
  transition: border .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 20px; border: none; border-radius: 10px; font-size: 15px;
  font-weight: 600; cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-sm { padding: 7px 14px; font-size: 13px; border-radius: 8px; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-info { background: var(--info); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.login-hint { text-align: center; margin-top: 16px; font-size: 12px; color: var(--text3); }
.login-error {
  background: var(--primary-light); color: var(--primary); padding: 10px 14px;
  border-radius: 8px; font-size: 13px; margin-bottom: 14px; text-align: center;
}

/* ===== 主应用布局 ===== */
#app { display: none; min-height: 100vh; flex-direction: column; }
#app.active { display: flex; }
.topbar {
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 14px 18px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; }
.topbar .brand .dot {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 17px;
}
.topbar .brand b { font-size: 16px; }
.topbar .brand small { display: block; color: var(--text3); font-size: 11px; margin-top: -2px; }
.user-chip { display: flex; align-items: center; gap: 8px; }
.user-chip .avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary-light);
  color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
}
.user-chip .info { line-height: 1.2; }
.user-chip .info b { font-size: 14px; display: block; }
.user-chip .info small { font-size: 11px; color: var(--text3); }

/* 导航 */
.nav-tabs {
  display: flex; overflow-x: auto; background: var(--card);
  border-bottom: 1px solid var(--border); padding: 0 8px; gap: 4px;
  position: sticky; top: 62px; z-index: 99;
  scrollbar-width: none;
}
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tab {
  flex-shrink: 0; padding: 12px 16px; font-size: 14px; color: var(--text2);
  border: none; background: none; cursor: pointer; font-weight: 500;
  position: relative; border-radius: 8px 8px 0 0;
}
.nav-tab.active { color: var(--primary); font-weight: 700; }
.nav-tab.active::after {
  content: ''; position: absolute; bottom: 0; left: 12px; right: 12px;
  height: 3px; background: var(--primary); border-radius: 3px;
}

/* 内容区 */
.page { padding: 16px; padding-bottom: 90px; max-width: 960px; margin: 0 auto; width: 100%; }
.page-title { font-size: 19px; font-weight: 700; margin-bottom: 4px; }
.page-sub { color: var(--text3); font-size: 13px; margin-bottom: 16px; }

/* 统计卡片 */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 18px; }
.stat-card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c, var(--primary));
}
.stat-card .num { font-size: 30px; font-weight: 800; line-height: 1.1; }
.stat-card .label { color: var(--text2); font-size: 13px; margin-top: 4px; }
.stat-card .ic {
  position: absolute; right: 12px; top: 12px; width: 36px; height: 36px;
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: var(--ic-bg, var(--primary-light)); font-size: 18px;
}

/* 卡片/列表 */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 14px; overflow: hidden;
}
.card-hd { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-hd b { font-size: 15px; }
.card-bd { padding: 14px 16px; }
.card-ft { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; }

.scene-item {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 12px; cursor: pointer; transition: transform .12s;
}
.scene-item:active { transform: scale(.99); }
.scene-item .row1 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.scene-item .name { font-size: 16px; font-weight: 700; }
.scene-item .meta { color: var(--text2); font-size: 13px; margin-top: 6px; display: flex; flex-wrap: wrap; gap: 8px 16px; }
.scene-item .meta span { display: flex; align-items: center; gap: 4px; }
.badge {
  display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.badge-warn { background: #fff7e6; color: var(--warning); }
.badge-danger { background: #ffecec; color: var(--danger); }
.badge-ok { background: #e8f8ee; color: var(--success); }
.badge-info { background: #e8f1ff; color: var(--info); }
.badge-price { background: var(--primary-light); color: var(--primary); }

/* 房间表 */
.room-list { }
.room-item {
  padding: 14px 16px; border-bottom: 1px solid var(--border); cursor: pointer;
}
.room-item:last-child { border-bottom: none; }
.room-item .r-top { display: flex; align-items: center; justify-content: space-between; }
.room-item .r-no { font-weight: 700; font-size: 15px; }
.room-item .r-loc { color: var(--text2); font-size: 13px; margin-top: 3px; }
.room-item .r-fields {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin-top: 10px;
  font-size: 13px;
}
.room-item .r-fields .f { display: flex; gap: 4px; }
.room-item .r-fields .k { color: var(--text3); }
.room-item .r-fields .v { color: var(--text); font-weight: 500; }
.empty { text-align: center; padding: 40px 16px; color: var(--text3); }
.empty .big { font-size: 40px; margin-bottom: 10px; }

/* 底部操作栏 */
.fab {
  position: fixed; right: 20px; bottom: 24px; width: 54px; height: 54px;
  border-radius: 50%; background: var(--primary); color: #fff; border: none;
  font-size: 26px; box-shadow: var(--shadow-lg); cursor: pointer; z-index: 50;
  display: flex; align-items: center; justify-content: center;
}
.fab:active { transform: scale(.94); }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200;
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--card); width: 100%; max-width: 640px; border-radius: 20px 20px 0 0;
  max-height: 92vh; overflow-y: auto; animation: slideUp .25s ease-out;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@media (min-width: 640px) {
  .modal-mask { align-items: center; }
  .modal { border-radius: 16px; }
}
.modal-hd {
  padding: 18px 20px 12px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--card); z-index: 2;
}
.modal-hd b { font-size: 17px; }
.modal-close { width: 32px; height: 32px; border-radius: 50%; border: none; background: var(--bg); color: var(--text2); font-size: 18px; cursor: pointer; }
.modal-bd { padding: 12px 20px 24px; }
.form-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 480px) { .form-2col { grid-template-columns: 1fr; } }
.form-2col .full { grid-column: 1 / -1; }

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,.85); color: #fff; padding: 12px 22px; border-radius: 30px;
  font-size: 14px; z-index: 999; opacity: 0; pointer-events: none; transition: all .25s;
  max-width: 86vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 搜索框 */
.search-bar {
  display: flex; gap: 8px; margin-bottom: 14px;
}
.search-bar input {
  flex: 1; padding: 11px 14px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; outline: none; background: var(--card);
}
.search-bar input:focus { border-color: var(--primary); }

/* 表格 */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th, table.tbl td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.tbl th { color: var(--text2); font-weight: 600; background: #fafafa; position: sticky; top: 0; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-total { background: var(--primary-light); font-weight: 700; }
.tbl-total td { color: var(--primary); border: none; }

/* 到期提醒卡片 */
.expire-item {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.expire-item:last-child { border-bottom: none; }
.expire-item .e-ic { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.expire-item .e-body { flex: 1; min-width: 0; }
.expire-item .e-room { font-weight: 700; font-size: 14px; }
.expire-item .e-scene { color: var(--text2); font-size: 12px; margin-top: 2px; }
.expire-item .e-date { font-size: 12px; margin-top: 4px; }
.days-chip { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 12px; flex-shrink: 0; }

/* 角色标签 */
.role-tag { font-size: 11px; padding: 2px 8px; border-radius: 10px; }

/* 加载更多/骨架 */
.skeleton { background: linear-gradient(90deg,#eee 25%,#f5f5f5 37%,#eee 63%); background-size:400% 100%; animation:sk 1.4s infinite; border-radius:8px; }
@keyframes sk { 0%{background-position:100% 0} 100%{background-position:0 0} }

/* 费用汇总 */
.fee-summary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
  box-shadow: var(--shadow-lg);
}
.fee-summary .fs-num { font-size: 34px; font-weight: 800; }
.fee-summary .fs-label { opacity: .85; font-size: 13px; }

/* 用户管理 */
.user-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.user-row:last-child { border-bottom: none; }
.user-row .u-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.user-row .u-body { flex: 1; min-width: 0; }
.user-row .u-name { font-weight: 700; font-size: 15px; }
.user-row .u-sub { color: var(--text3); font-size: 12px; }

.hidden { display: none !important; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mb-16 { margin-bottom: 16px; }
.text-center { text-align: center; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.link-btn { color: var(--primary); background: none; border: none; cursor: pointer; font-size: 13px; font-weight: 600; padding: 0; }

/* ===== 场景工具栏 ===== */
.scene-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; margin-bottom: 10px;
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.scene-detail-toolbar {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px; flex-wrap: wrap;
}
.scene-detail-toolbar .btn {
  flex-shrink: 0;
}

/* ===== Excel 表格编辑 ===== */
.filter-bar {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px;
  padding: 8px 12px; background: var(--card); border-radius: 8px;
  box-shadow: var(--shadow);
}
.filter-bar select {
  flex: 1; min-width: 100px; max-width: 160px;
  padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 12px; color: var(--text); background: #fff; cursor: pointer;
}
.filter-bar select:focus { border-color: var(--primary); outline: none; }

.tbl-wrap { overflow-x: auto; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.room-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 900px; }
.room-table thead th {
  background: #f8f9fa; padding: 10px 8px; text-align: left; font-weight: 600;
  color: var(--text2); border-bottom: 2px solid var(--border); white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
.room-table tbody td {
  padding: 8px; border-bottom: 1px solid #f0f0f0; cursor: pointer;
  transition: background .15s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px;
}
.room-table tbody td:hover { background: #f0f7ff; }
.room-table tbody tr:hover { background: #fafbfc; }
.room-table .row-dirty { background: #fffde7; }
.room-table .row-dirty td { background: #fffde7; }
.room-table .row-dirty td:hover { background: #fff9c4; }

.td-edit { position: relative; }
.td-remark { max-width: 280px; min-width: 200px; white-space: normal; word-break: break-all; }
.td-input, .td-select {
  width: 100%; border: 1.5px solid var(--info); border-radius: 4px; padding: 4px 6px;
  font-size: 13px; outline: none; background: #fff;
}
.td-input:focus, .td-select:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(230,0,18,.1); }

/* 到期状态标签 */
.exp-tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.exp-expired { background: #ffecec; color: var(--danger); }
.exp-soon { background: #fff7e6; color: var(--warning); }
.exp-ok { background: #e8f8ee; color: var(--success); }
.exp-none { background: #f5f5f5; color: var(--text3); }

/* 表格底部操作栏 */
.tbl-actions {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
}

/* 响应式：小屏横向滚动 */
@media (max-width: 768px) {
  .room-table { font-size: 12px; }
  .room-table thead th, .room-table tbody td { padding: 6px 5px; max-width: 90px; }
}

/* ===== 复选框列 + 操作列 ===== */
.room-table .th-check, .room-table .td-check {
  width: 36px; min-width: 36px; text-align: center;
}
.room-table .th-check input, .room-table .td-check input {
  width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary);
}
.room-table .th-op, .room-table .td-op {
  width: 80px; min-width: 80px; text-align: center; white-space: nowrap;
}

/* ===== 派单弹窗 ===== */
.dispatch-types { display: flex; gap: 12px; flex-wrap: wrap; }
.dt-item {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 14px; border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; background: #fafbfc;
  transition: all .15s; font-size: 14px;
}
.dt-item:hover { border-color: var(--primary); background: var(--primary-light); }
.dt-item input { accent-color: var(--primary); width: 16px; height: 16px; }
.dispatch-info {
  margin-top: 10px; padding: 10px 12px; background: #f5f6f8;
  border-radius: 8px; font-size: 13px; color: var(--text2);
}

/* ===== 待办模块 ===== */
.orders-summary {
  display: flex; gap: 12px; margin: 16px 0;
}
.os-item {
  flex: 1; background: var(--card); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 14px;
  border-left: 4px solid transparent;
}
.os-item .os-num { font-size: 28px; font-weight: 700; line-height: 1; }
.os-item .os-label { font-size: 13px; color: var(--text2); }
.os-pending { border-left-color: var(--danger); }
.os-pending .os-num { color: var(--danger); }
.os-done { border-left-color: var(--success); }
.os-done .os-num { color: var(--success); }

.order-status {
  display: inline-block; padding: 3px 10px; border-radius: 12px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.status-pending { background: #ffecec; color: var(--danger); }
.status-done { background: #e8f8ee; color: var(--success); }

/* ===== 工单详情 ===== */
.order-meta {
  background: #f8f9fb; border-radius: 10px; padding: 12px 14px;
  margin-bottom: 14px; font-size: 13px;
}
.om-row { padding: 4px 0; display: flex; gap: 8px; }
.om-row span:first-child { color: var(--text3); min-width: 70px; }
.order-divider {
  font-size: 13px; font-weight: 600; color: var(--text2);
  padding: 10px 0 8px; margin-top: 8px;
  border-top: 1px dashed var(--border);
}
.form-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-2col .field.full { grid-column: 1 / -1; }


/* ICP 备案号 */
.icp-footer { position: fixed; bottom: 0; left: 0; right: 0; text-align: center; padding: 6px 0 8px; font-size: 11px; color: #999; background: transparent; z-index: 50; }
.icp-footer a { color: #999; text-decoration: none; }
.icp-footer a:hover { color: #666; }
