:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --line: #e6eaf0;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-d: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 6px 18px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }

/* 关键：任何带 hidden 属性的元素必须隐藏。
   否则 .mask{display:flex} 等类选择器会覆盖浏览器默认的 [hidden]{display:none}，
   导致 JS 设置 hidden=true 后面板依然可见（关不掉）。 */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
/* 左上角 logo 与登录页保持一致：渐变胶囊（参数完全对齐登录页 .login-card .logo） */
.logo {
  display: inline-flex; align-items: center; justify-content: center;
  box-sizing: border-box;
  padding: 12px 28px; border-radius: 14px;
  background: linear-gradient(135deg, #2563eb 0%, #38bdf8 100%);
  color: #fff; font-weight: 800; font-size: 24px; letter-spacing: 1px;
  line-height: 1.15; white-space: nowrap;
  box-shadow: 0 8px 22px rgba(37, 99, 235, .28);
}
.topbar h1 { margin: 0; font-size: 20px; font-weight: 700; }
.sub { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.topbar-right { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 12px; }
.dot-ok::before {
  content: ""; display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: var(--ok); margin-right: 6px;
}
.dot-err::before {
  content: ""; display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: var(--danger); margin-right: 6px;
}

/* ---------- 统计 ---------- */
.stats {
  display: grid; grid-template-columns: repeat(6, 1fr);
  gap: 12px; padding: 16px 24px 4px;
}
.stat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 2px;
}
.stat-label { font-size: 12px; color: var(--muted); }
.stat-card b { font-size: 20px; font-weight: 700; letter-spacing: .3px; }
.stat-card em { font-style: normal; font-size: 11px; color: var(--muted); }
.stat-card.hl b { color: var(--ok); }
.stat-card.warn b { color: var(--warn); }

/* ---------- 月份选择器卡片 ---------- */
.stat-card.month { background: linear-gradient(180deg, #eef4ff, #ffffff); border-color: #c9d9f7; }
.month-sel {
  font-size: 18px; font-weight: 700; letter-spacing: .3px;
  color: var(--primary); background: #fff;
  border: 1px solid #c9d9f7; border-radius: 6px;
  padding: 1px 6px; margin: 1px 0; cursor: pointer; outline: none;
}
.month-sel:focus { border-color: var(--primary); }
.month-tip { font-style: normal; font-size: 11px; color: var(--muted); }

/* ---------- 订单状态色块标签 ---------- */
.status-tag {
  display: inline-block; min-width: 56px; padding: 2px 8px;
  border-radius: 4px; font-size: 12px; font-weight: 600;
  line-height: 1.5; white-space: nowrap; color: #fff;
}
.st-pending  { background: #8a94a6; }   /* 待分配 - 灰 */
.st-ready    { background: transparent; color: #2563eb; border: 1px solid #c7d2fe; }   /* 待入住 - 无背景色 */
.st-living   { background: #facc15; color: #1f2937; }   /* 入住中 - 高亮黄 */
.st-checkout { background: #e08a00; }   /* 已退房 - 橙 */
.st-done     { background: #16a34a; }   /* 已完成 - 绿 */
.st-cancel   { background: #d92d20; }   /* 已取消 - 红 */
.st-book     { background: #7c3aed; color: #fff; }   /* 待预订 - 醒目紫 */

/* ---------- 工具栏 ---------- */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 24px; flex-wrap: wrap;
}
.search-box { display: flex; align-items: center; gap: 8px; }
.search-box select, .search-box input {
  height: 34px; padding: 0 10px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; font-size: 13px; color: var(--text);
  outline: none;
}
.search-box input { width: 300px; }
.search-box input:focus, .search-box select:focus { border-color: var(--primary); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--text); cursor: pointer; font-size: 13px;
  transition: .15s; white-space: nowrap;
}
.btn:hover { background: #f3f4f6; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-d); }
.btn.voice { background: #eef2ff; border-color: #c7d2fe; color: #4338ca; }
.btn.voice:hover { background: #e0e7ff; }
.btn.ghost { background: #fff; }
.btn.danger { color: var(--danger); border-color: #fecaca; background: #fff5f5; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.result-tip { margin: 0 24px 8px; font-size: 12px; color: var(--muted); }

/* ---------- 表格 ---------- */
.table-wrap {
  margin: 0 24px 24px; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow); overflow: auto; max-height: 80vh;
}
table { border-collapse: collapse; width: 100%; font-size: 13px; }
thead th {
  position: sticky; top: 0; z-index: 2; background: #f8fafc;
  border-bottom: 1px solid var(--line); padding: 10px 12px; text-align: left;
  font-weight: 600; color: #374151; white-space: nowrap; cursor: pointer;
}
thead th:hover { background: #eef2f7; }
thead th.col-idx, thead th.col-op { cursor: default; }
thead th.col-idx:hover, thead th.col-op:hover { background: #f8fafc; }
tbody td {
  padding: 9px 12px; border-bottom: 1px solid #f1f3f7; white-space: nowrap;
}
tbody tr:hover { background: #f9fbff; }
td.c, th.c { text-align: center; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
td.hotel { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
td.remark { max-width: 200px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
/* 列宽截断：预订账号最多 5 个中文字符、入住人最多 4 个中文字符，超出省略号 */
td .clip { display: inline-block; vertical-align: bottom; max-width: 5.2em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td .clip-4 { max-width: 4.2em; }
/* 已完成 / 已取消：整行文字变淡，与其他订单明显区分 */
tbody tr.row-muted { opacity: .55; }
tbody tr.row-muted:hover { opacity: .82; background: #f9fbff; }
.profit-pos { color: var(--ok); font-weight: 600; }
.profit-neg { color: var(--danger); font-weight: 600; }
.pend { color: var(--warn); font-weight: 600; }
.phone { font-variant-numeric: tabular-nums; }
.op-btn {
  border: none; background: none; cursor: pointer; color: var(--primary);
  padding: 2px 6px; font-size: 12px;
}
.op-btn.del { color: var(--danger); }
tfoot td {
  padding: 10px 12px; background: #f8fafc; font-weight: 700;
  border-top: 1px solid var(--line); position: sticky; bottom: 0;
}
.empty { padding: 40px; text-align: center; color: var(--muted); }
.sort-mark { color: var(--primary); font-size: 11px; margin-left: 2px; }

/* ---------- 弹窗 ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  padding: 20px;
}
.modal {
  background: #fff; border-radius: 12px; width: 560px; max-width: 100%;
  max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .2);
}
.modal-lg { width: 860px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 16px; }
.x { border: none; background: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 12px 18px; border-top: 1px solid var(--line);
}
.err { margin-right: auto; color: var(--danger); font-size: 12px; }

.voice-hint {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #eef2ff; border: 1px solid #c7d2fe; color: #3730a3;
  border-radius: 8px; padding: 8px 12px; font-size: 12px; margin-bottom: 14px;
}
.form-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 14px;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field.wide { grid-column: span 2; }
.field > span { font-size: 12px; color: var(--muted); }
.with-mic { display: flex; gap: 6px; align-items: stretch; }
.with-mic input, .with-mic textarea {
  flex: 1; min-width: 0; height: 34px; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 13px;
  font-family: inherit; color: var(--text); outline: none; background: #fff;
}
.with-mic textarea { height: auto; min-height: 56px; resize: vertical; }
.with-mic input:focus, .with-mic textarea:focus { border-color: var(--primary); }
.mic {
  width: 34px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; cursor: pointer; font-size: 14px; flex: none;
}
.mic:hover { background: #eef2ff; border-color: #c7d2fe; }
.mic.on { background: var(--danger); color: #fff; border-color: var(--danger); animation: pulse 1s infinite; }
/* 多行控件旁的麦克风按钮顶部对齐 */
.with-mic > textarea ~ .mic, .with-mic > .custom-input ~ .mic { align-self: flex-start; height: 34px; }
.flash { animation: flash .6s ease; }
@keyframes flash { 0% { background: #fff7c2; } 100% { background: #fff; } }
@keyframes pulse { 50% { opacity: .6; } }

/* ---------- 语音弹窗 ---------- */
.tip { font-size: 12px; color: var(--muted); background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.tip i { color: #374151; font-style: normal; }
.voice-stage { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 0; }
.mic-big {
  width: 64px; height: 64px; border-radius: 50%; font-size: 26px;
  border: none; cursor: pointer; background: #eef2ff; color: #4338ca;
  box-shadow: 0 4px 14px rgba(37, 99, 235, .18);
}
.mic-big.on { background: var(--danger); color: #fff; animation: pulse 1s infinite; }
#recState { font-size: 12px; color: var(--muted); }
.wave { display: flex; gap: 4px; align-items: flex-end; height: 20px; }
.wave i { width: 4px; background: var(--primary); border-radius: 2px; animation: bar .8s infinite ease-in-out; }
.wave i:nth-child(2) { animation-delay: .1s; } .wave i:nth-child(3) { animation-delay: .2s; }
.wave i:nth-child(4) { animation-delay: .3s; } .wave i:nth-child(5) { animation-delay: .4s; }
@keyframes bar { 0%, 100% { height: 6px; } 50% { height: 20px; } }
.unsupported { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; border-radius: 8px; padding: 8px 10px; font-size: 12px; margin-bottom: 10px; }
#voiceText {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px;
  font-family: inherit; font-size: 13px; resize: vertical; outline: none;
}
#voiceText:focus { border-color: var(--primary); }
.row-btns { display: flex; justify-content: flex-end; gap: 8px; margin: 10px 0; }
.parse-result { display: flex; flex-direction: column; gap: 6px; }
.parse-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.parse-row .k { width: 92px; color: var(--muted); flex: none; }
.parse-row input {
  flex: 1; height: 30px; padding: 0 8px; border: 1px solid var(--line);
  border-radius: 6px; font-size: 13px; font-family: inherit;
}
.parse-row input:focus { border-color: var(--primary); outline: none; }

/* ---------- 查询界面（首屏） ---------- */
.query-card {
  margin: 12px 24px 0; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow); overflow: visible;
}
.query-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px; background: #f8fafc; border-bottom: 1px solid var(--line);
  border-radius: 10px 10px 0 0;
}
.query-head h3 { margin: 0; font-size: 15px; }
.query-body { padding: 14px 16px; }
.search-box label { font-size: 13px; color: var(--muted); margin-right: 2px; }

/* 横向一排查询条件（整体上移、无提示小字） */
.qbar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 14px;
}
.qfield { display: flex; flex-direction: column; gap: 4px; }
.qfield > label { font-size: 12px; color: var(--muted); }
.qfield select, .qfield input {
  height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; font-size: 13px; color: var(--text); outline: none; min-width: 140px;
}
.qfield select:focus, .qfield input:focus { border-color: var(--primary); }
.qfield input#qPhone { min-width: 150px; }
.qbtns { flex-direction: row; align-items: flex-end; gap: 8px; }

/* 酒店名称多选下拉 */
.ms-btn {
  height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; font-size: 13px; color: var(--text); cursor: pointer; min-width: 160px;
  text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ms-btn:hover { border-color: var(--primary); }
.ms-btn.active { border-color: var(--primary); color: var(--primary); font-weight: 600; }
/* 面板锚定到酒店名称字段，默认不小于文本框宽度，可随内容横向展开 */
#hotelMs { position: relative; }
.ms-panel {
  position: absolute; left: 0; top: 100%; z-index: 40; margin-top: 4px;
  padding: 6px 8px 6px 0;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); max-height: 260px; overflow: auto;
  width: auto; min-width: 100%; max-width: min(520px, 92vw);
  display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 8px;
}
/* 横向紧凑排列：复选框紧贴左缘、与文字零间距、名称不换行 */
.ms-item { display: inline-flex; align-items: center; gap: 0px; font-size: 13px; cursor: pointer; padding: 3px 10px 3px 0; white-space: nowrap; border-radius: 6px; }
.ms-item input { width: 15px; height: 15px; margin: 0; flex: 0 0 auto; accent-color: var(--primary); cursor: pointer; }
.ms-item:hover { background: #f4f6fa; border-radius: 6px; }

/* 弹窗内“其他属性”复选行 */
.checks-row { grid-column: 1 / -1; }
.checks-row > span:first-child { font-size: 12px; color: var(--muted); }
.checks-row .checks { display: flex; flex-wrap: wrap; gap: 16px; padding: 6px 0 2px; }
.checks-row .chk { font-size: 13px; }

/* 表单录入页复选类字段 */
.field.check-field > .chk { font-size: 13px; }
.field.check-field .field-err { grid-column: 1 / -1; }

/* 弹窗右上角操作区 */
.head-actions { display: flex; align-items: center; gap: 8px; }
.voice-mask { z-index: 60; }   /* 语音面板始终压在新增表单之上 */

/* ---------- 视图切换 ---------- */
.tabs { display: flex; gap: 4px; padding: 0 24px; margin-top: 4px; }
.tab {
  border: 1px solid transparent; background: none; cursor: pointer;
  padding: 8px 16px; font-size: 14px; color: var(--muted);
  border-radius: 8px 8px 0 0; border-bottom: none;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: var(--card); color: var(--primary); font-weight: 600;
  border-color: var(--line); box-shadow: 0 -2px 6px rgba(16, 24, 40, .04);
}

/* ---------- 表单录入页 ---------- */
.form-page {
  margin: 0 24px 24px; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow); padding: 18px 20px 20px;
}
.form-page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--line);
}
.form-page-head h2 { margin: 0; font-size: 16px; }
.form-page-head .sub { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.req-star { color: var(--danger); }
.form-grid { margin-top: 16px; }

.with-mic select {
  flex: 1; min-width: 0; height: 34px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  font-size: 13px; font-family: inherit; color: var(--text); outline: none;
}
.with-mic select:focus { border-color: var(--primary); }
.with-mic .custom-input { display: none; }
.with-mic .custom-input.show { display: block; }

.field-err { font-size: 11px; color: var(--danger); min-height: 14px; }
.field.invalid input, .field.invalid select, .field.invalid textarea {
  border-color: var(--danger) !important; background: #fff5f5;
}
.hint { font-size: 11px; color: var(--muted); }

.form-options {
  display: flex; gap: 20px; flex-wrap: wrap; margin-top: 6px;
  padding: 10px 12px; background: #f8fafc; border: 1px solid var(--line);
  border-radius: 8px;
}
.chk { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.chk input { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; }

.form-page-foot {
  display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px;
  padding-top: 14px; border-top: 1px solid var(--line);
}
#btnPageSubmit { min-width: 120px; }

/* 保存结果提示条 */
.msg {
  margin-top: 14px; padding: 10px 14px; border-radius: 8px; font-size: 13px;
  border: 1px solid var(--line);
}
.msg.ok { background: #ecfdf5; border-color: #a7f3d0; color: #047857; }
.msg.err { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }

/* ---------- 设置菜单 ---------- */
.settings-wrap { position: relative; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-size: 17px; line-height: 1;
  display: flex; align-items: center; justify-content: center; color: var(--muted);
}
.icon-btn:hover { background: #f3f4f6; color: var(--text); }
.dropdown {
  position: absolute; right: 0; top: 38px; min-width: 168px; z-index: 80;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 6px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .15);
}
.dropdown-item {
  display: block; width: 100%; text-align: left; border: none; background: none;
  padding: 9px 12px; border-radius: 7px; font-size: 14px; cursor: pointer;
  color: var(--text); font-family: inherit;
}
.dropdown-item:hover { background: #f1f5f9; }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: #fef2f2; }
.dropdown-sep { height: 1px; background: var(--line); margin: 5px 4px; }

/* ---------- 酒店清单 ---------- */
.hotel-add { display: flex; gap: 8px; margin-bottom: 12px; }
.hotel-add input {
  flex: 1; min-width: 0; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 14px; font-family: inherit; outline: none;
}
.hotel-add input:focus { border-color: var(--primary); }
.hotel-list { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow: auto; }
.hotel-list li {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px;
}
.hotel-list .hname { flex: 1; font-size: 14px; word-break: break-all; }
.hotel-list .mini {
  border: 1px solid var(--line); background: #fff; border-radius: 6px;
  padding: 4px 9px; font-size: 12px; cursor: pointer; color: var(--muted);
  font-family: inherit; flex: none;
}
.hotel-list .mini:hover { background: #f3f4f6; color: var(--text); }
.hotel-list .mini.del:hover { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.hotel-empty {
  color: var(--muted); font-size: 13px; padding: 16px; text-align: center;
  background: #f8fafc; border-radius: 8px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 13px; z-index: 99; box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
}

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .field.wide { grid-column: span 2; }
  .search-box input { width: 200px; }
}
