:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --border: #e2e7ee;
  --text: #1c2733;
  --muted: #67788c;
  --primary: #1a6fd4;
  --primary-dark: #125aaf;
  --green: #1e9e5a;
  --green-bg: #e3f6ec;
  --blue: #1a6fd4;
  --blue-bg: #e6f0fc;
  --orange: #d97b12;
  --orange-bg: #fdf0e0;
  --gray: #8a97a6;
  --gray-bg: #eef1f5;
  --red: #d64545;
  --red-bg: #fdeaea;
  --purple: #7a4fd0;
  --purple-bg: #f1eafd;
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", "Microsoft YaHei", -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ---------- Offline banner（断网提示条：WiFi 瞬断时前台一眼知道是网络问题） ---------- */
:root { --netbar-h: 34px; }
.netbar {
  display: none; position: fixed; top: 0; left: 0; right: 0; height: var(--netbar-h);
  z-index: 1100; align-items: center; justify-content: center; gap: 8px;
  background: var(--orange); color: #fff; font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; box-shadow: 0 2px 6px rgba(28, 39, 51, .18);
}
.netbar.show { display: flex; }
.netbar .en { color: #fff; font-weight: 700; }
.nb-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #fff; flex: none;
  animation: nb-blink 1s ease-in-out infinite;
}
@keyframes nb-blink { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
body.offline { padding-top: var(--netbar-h); }
body.offline .topbar { top: var(--netbar-h); }
@media (max-width: 460px) { .netbar .en { display: none; } }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  background: #fff; border-bottom: 1px solid var(--border);
  padding: 0 20px; height: 56px; position: sticky; top: 0; z-index: 50;
}
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tabs button {
  border: none; background: transparent; padding: 8px 14px; cursor: pointer;
  border-radius: 8px; font-size: 14px; color: var(--muted); white-space: nowrap;
}
.tabs button:hover { background: var(--gray-bg); color: var(--text); }
.tabs button.active { background: var(--blue-bg); color: var(--primary); font-weight: 600; }
/* Bilingual side-by-side labels */
.en { color: var(--muted); font-weight: 700; }
.tabs .en { font-size: 12px; margin-left: 3px; }
.topbar-right { display: flex; gap: 8px; align-items: center; }
#operator {
  width: 130px; padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px;
}
.lang-btn {
  border: 1px solid var(--border); background: #fff; border-radius: 8px;
  padding: 6px 12px; cursor: pointer; font-weight: 600;
}

/* ---------- Login screen ---------- */
.login-mask {
  /* 四边展开写法在前，旧 Safari（<14.5）不认识 inset 时回退到它 */
  display: none; position: fixed; top: 0; right: 0; bottom: 0; left: 0; inset: 0; z-index: 1000;
  background: var(--bg);
  align-items: center; justify-content: center;
}
.login-mask.show { display: flex; }
.login-box {
  width: 360px; max-width: 92vw;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 32px 28px;
  box-shadow: 0 8px 32px rgba(28, 39, 51, .12);
}
.login-title { font-size: 20px; font-weight: 700; text-align: center; }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin: 8px 0 22px; }
.login-enter { width: 100%; padding: 10px; font-size: 15px; margin-top: 6px; }
.login-hint { min-height: 16px; line-height: 1.45; margin: -6px 0 8px; }
.who-chip {
  display: inline-block; background: var(--blue-bg); color: var(--primary);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; font-weight: 600; white-space: nowrap;
}

/* ---------- Layout ---------- */
main { padding: 20px; max-width: 1280px; margin: 0 auto; }
.grid { display: grid; gap: 16px; }
.grid.cols3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 1280px) { .grid.cols5 { grid-template-columns: repeat(3, 1fr); } }
/* 平板：三列以上改两列，两列保持 */
@media (max-width: 900px) {
  .grid.cols3, .grid.cols4, .grid.cols5 { grid-template-columns: repeat(2, 1fr); }
}
/* 手机竖屏：全部单列 */
@media (max-width: 560px) {
  .grid.cols2, .grid.cols3, .grid.cols4, .grid.cols5 { grid-template-columns: 1fr; }
}

/* ---------- Dashboard department blocks ---------- */
.dept { margin-bottom: 22px; }
.dept-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 8px;
  font-weight: 700; font-size: 15px; margin-bottom: 12px;
}
.dept-head .en { font-size: 13px; }
.dept-rooms { background: var(--blue-bg); color: var(--primary); }
.dept-rest  { background: var(--orange-bg); color: var(--orange); }
.dept-svc   { background: var(--green-bg); color: var(--green); }
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.card h3 { font-size: 15px; margin-bottom: 12px; }
.stat-num { font-size: 28px; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 4px; }
/* 总览未结算卡：按币种逐行「字段名小字 + 金额中号粗体」（2026-10-09） */
.amt-line { margin-top: 3px; }
.amt-line:first-child { margin-top: 0; }
.amt-cap { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.amt-cap .en { font-size: 10.5px; }
.amt-val { display: block; font-size: 18px; line-height: 1.25; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

/* ---------- Forms ---------- */
label.f { display: block; margin-bottom: 10px; }
label.f span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; background: #fff; color: var(--text);
  font-family: inherit;
}
input:focus, select:focus { outline: 2px solid var(--blue-bg); border-color: var(--primary); }
.btn {
  border: none; border-radius: 8px; padding: 9px 18px; cursor: pointer;
  font-size: 14px; font-weight: 600; background: var(--gray-bg); color: var(--text);
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.success { background: var(--green); color: #fff; }
/* 深色底按钮（蓝/绿）内的英文改白色，避免灰蓝色文字看不清（如登录页"进入系统 Enter"） */
.btn.primary .en, .btn.success .en { color: rgba(255, 255, 255, .95); }
.btn.danger { background: #fbe9e9; color: var(--red); }
.btn.ghost { background: transparent; border: 1px solid var(--border); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
/* 预订按钮：紫色一等选项，与「办理入住」平级醒目 */
.btn.res { background: var(--purple); color: #fff; }
.btn.res .en { color: rgba(255, 255, 255, .95); }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }

/* ---------- Room grid ---------- */
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.room-tile {
  border: 1px solid var(--border); border-radius: 10px; padding: 12px;
  cursor: pointer; background: #fff; transition: transform .08s;
}
.room-tile:hover { transform: translateY(-2px); box-shadow: 0 3px 10px rgba(0,0,0,.08); }
.room-tile .num { font-size: 18px; font-weight: 700; }
.room-tile .guest { font-size: 12px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-tile.vacant { border-top: 3px solid var(--green); }
/* 在住 = 红（2026-09-30 按业主指定，由蓝改为红） */
.room-tile.occupied { border-top: 3px solid var(--red); background: var(--red-bg); }
.room-tile.dirty { border-top: 3px solid var(--orange); background: var(--orange-bg); }
.room-tile.maintenance { border-top: 3px solid var(--gray); background: var(--gray-bg); }
/* 预订日期段内 = 紫（锁定，他人不能入住） */
.room-tile.booked { border-top: 3px solid var(--purple); background: var(--purple-bg); }
/* 房间上有预订（未到 / 已过期但未取消）→ 左侧紫色竖条，与物理状态并存 */
.room-tile.has-res { border-left: 3px solid var(--purple); }
.room-tile .resline { color: var(--purple); font-size: 12px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge.vacant { background: var(--green-bg); color: var(--green); }
.badge.occupied { background: var(--red-bg); color: var(--red); }
.badge.dirty { background: var(--orange-bg); color: var(--orange); }
.badge.maintenance { background: var(--gray-bg); color: var(--gray); }
.badge.booked { background: var(--purple-bg); color: var(--purple); }
/* 预订信息块（房间弹窗内） */
.resbox { border: 1px solid var(--purple-bg); background: var(--purple-bg); border-radius: 10px; padding: 12px; }
.resbox table td { border-bottom: 1px solid #e5daf8; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 12px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; }

/* ---------- Counter picker (restaurant) ---------- */
.counter-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.counter-row:last-child { border-bottom: none; }
.counter-row .name { font-weight: 600; }
.counter-row .price { color: var(--muted); font-size: 13px; }
.counter-ctrl { display: flex; align-items: center; gap: 10px; }
.counter-ctrl button {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; font-size: 18px; cursor: pointer; font-weight: 700;
}
.counter-ctrl button:hover { background: var(--gray-bg); }
.counter-ctrl .val { min-width: 28px; text-align: center; font-weight: 700; font-size: 16px; }
.big-total { font-size: 24px; font-weight: 700; color: var(--primary); }

/* ---------- 餐厅「额外点餐」：品类标签 + 菜品卡片 ---------- */
.dish-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.dish-tab {
  padding: 6px 15px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); cursor: pointer;
  font-size: 13px; font-weight: 600; font-family: inherit;
}
.dish-tab:hover { border-color: var(--primary); color: var(--primary); }
.dish-tab.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.dish-tab .en { font-size: 11px; margin-left: 3px; opacity: .75; }
.dish-tab.on .en { color: #fff; opacity: .95; }
.dish-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px; }
.dish-card {
  position: relative; background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 11px 36px; cursor: pointer;
  transition: border-color .12s, background .12s, box-shadow .12s;
  user-select: none; min-height: 82px;
}
.dish-card:hover { border-color: var(--primary); }
.dish-card.on { border-color: var(--primary); background: var(--blue-bg); box-shadow: 0 0 0 1px var(--primary) inset; }
.dish-card .dn { font-weight: 600; font-size: 13.5px; line-height: 1.35; padding-right: 22px; }
.dish-card .de { font-size: 11px; color: var(--muted); margin-top: 2px; }
.dish-card .dp { color: var(--primary); font-weight: 700; font-size: 14px; margin-top: 8px; }
.dish-badge {
  position: absolute; top: -9px; right: -9px; min-width: 26px; height: 26px;
  border-radius: 13px; background: var(--red); color: #fff;
  font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center;
  padding: 0 7px; box-shadow: 0 1px 4px rgba(214, 69, 69, .45);
}
.dish-minus {
  position: absolute; right: 8px; bottom: 9px; width: 28px; height: 24px;
  border-radius: 6px; border: 1px solid var(--border); background: var(--panel);
  color: var(--muted); font-size: 15px; line-height: 1; cursor: pointer; font-family: inherit;
}
.dish-minus:hover { background: var(--red-bg); color: var(--red); border-color: var(--red); }
.dish-empty { color: var(--muted); font-size: 13px; }
@media (max-width: 720px) {
  .dish-grid { grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 10px; }
}

/* ---------- Modal ---------- */
.modal-mask {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; inset: 0; background: rgba(15,25,40,.45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: #fff; border-radius: 14px; padding: 22px; width: 460px; max-width: 94vw;
  max-height: 86vh; overflow-y: auto;
}
.modal h3 { margin-bottom: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: #22303f; color: #fff; padding: 10px 22px; border-radius: 24px;
  font-size: 14px; opacity: 0; transition: all .25s; z-index: 200; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--red); }

/* ---------- 无操作自动退出 · 倒计时预警层 ----------
   z-index 1500：高于业务弹窗(100)/登录页(1000)/断网条(1100)，任何界面都能被它盖住 */
.idle-warn {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; inset: 0; z-index: 1500;
  background: rgba(15, 25, 40, .55);
  display: flex; align-items: center; justify-content: center;
  animation: idle-fade .2s ease-out;
}
@keyframes idle-fade { from { opacity: 0; } to { opacity: 1; } }
.idle-warn-box {
  background: #fff; border-radius: 14px; padding: 26px 24px;
  width: 400px; max-width: 92vw; text-align: center;
  box-shadow: 0 8px 32px rgba(28, 39, 51, .25);
  border-top: 4px solid var(--orange);
}
.idle-warn-box h3 { font-size: 17px; margin-bottom: 12px; }
.idle-warn-box .mb { margin-bottom: 12px; }
.idle-warn-box b { color: var(--orange); }

/* ============================================================
   屏幕自适应（手机 / 平板 / 手提电脑）
   断点：≤1500px 顶栏折两行（页签独占一行）· ≤860px 平板收紧
   · ≤560px 手机竖屏进一步收紧
   ============================================================ */

/* ---------- 手提及以下：顶栏折两行（品牌+操作一行，页签一行可横滑） ---------- */
@media (max-width: 1500px) {
  .topbar {
    flex-wrap: wrap; height: auto; padding: 8px 12px 0; row-gap: 4px;
  }
  .topbar-right { margin-left: auto; }
  .tabs {
    order: 3; flex: 1 1 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding-bottom: 6px; scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
}

/* ---------- 平板与手机：进一步收紧 ---------- */
@media (max-width: 860px) {
  .brand { font-size: 14px; }
  .brand .en { display: none; }          /* 小屏隐藏品牌英文，省宽度 */
  .topbar-right { gap: 6px; }
  #operator { width: 92px; padding: 5px 8px; }
  .lang-btn { padding: 5px 10px; }
  .lang-btn .en { display: none; }
  .tabs .en { display: none; }           /* 页签只留中文，横滑更从容 */
  .tabs button { padding: 8px 12px; font-size: 14px; flex: none; }

  /* 宽表格在卡片内横向滚动，不撑破布局 */
  .card { overflow-x: auto; }

  /* 防止 iOS/安卓聚焦输入框时页面自动放大（需 ≥16px） */
  input, select, textarea { font-size: 16px; }
  body { font-size: 14px; }

  /* 弹窗贴边留窄边，内边距收紧 */
  .modal { padding: 16px; max-height: 90vh; }
}

/* ---------- 手机竖屏：进一步收紧 ---------- */
@media (max-width: 600px) {
  main { padding: 12px; }
  .card { padding: 14px; border-radius: 8px; }
  .card h3 { font-size: 14px; }
  .stat-num { font-size: 24px; }

  /* 入住弹窗里并排的字段（人数/晚数/房价/币种）改为两列，避免挤成一条缝 */
  .row > label.f { flex: 1 1 44% !important; }

  .modal-actions button { flex: 1; padding: 11px 10px; }  /* 手指好按 */
  .room-grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }
  .room-tile { padding: 10px; }
  .login-box { padding: 24px 18px; }
  .toast { width: max-content; max-width: 88vw; bottom: 18px; font-size: 13px; }
  th, td { padding: 8px 8px; }           /* 表格单元更紧凑 */
}

/* ---------- 房态图（房间 × 日期） Room calendar (tape chart) ---------- */
.cal-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.cal-month { font-weight: 700; font-size: 15px; min-width: 128px; text-align: center; white-space: nowrap; }
/* 横向滚动容器；首列与表头吸附，滚动时不丢房号/日期 */
.cal-wrap { overflow: auto; max-height: 58vh; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.cal-tbl { border-collapse: separate; border-spacing: 0; width: auto; }
.cal-tbl th, .cal-tbl td { border: 0; padding: 0; }
.cal-tbl thead th {
  position: sticky; top: 0; z-index: 3; background: var(--panel);
  border-bottom: 1px solid var(--border); font-size: 11px; font-weight: 600;
  color: var(--muted); text-align: center; width: 34px; min-width: 34px; padding: 3px 0; line-height: 1.25;
}
.cal-tbl thead th.we { color: var(--orange); }
.cal-tbl thead th.today { background: var(--red-bg); color: var(--red); }
.cal-tbl th.cal-rm {
  position: sticky; left: 0; top: 0; z-index: 5; width: 88px; min-width: 88px;
  text-align: left; padding: 3px 10px;
}
.cal-tbl td.cal-rm {
  position: sticky; left: 0; z-index: 2; background: var(--panel);
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  padding: 4px 10px; font-size: 13px; font-weight: 700; white-space: nowrap; cursor: pointer;
}
.cal-tbl td.cal-rm:hover { background: var(--gray-bg); }
.cal-tbl td.cal-rm .fl { font-size: 10px; color: var(--muted); font-weight: 600; margin-right: 3px; }
.cal-tbl td.cal-cell {
  height: 26px; border-bottom: 1px solid var(--border); border-right: 1px solid #eef1f5;
  text-align: center; font-size: 11px; font-weight: 600; color: var(--muted);
  cursor: pointer; background: #fff;
}
.cal-tbl td.cal-cell.we { background: #f8fafc; }
.cal-tbl td.cal-cell.past { background: #f7f9fb; cursor: default; }
.cal-tbl td.cal-cell.occ { background: var(--red); color: #fff; }
.cal-tbl td.cal-cell.res { background: var(--purple); color: #fff; }
.cal-tbl td.cal-cell.dirty { background: var(--orange); color: #fff; }
.cal-tbl td.cal-cell.maint { background: var(--gray); color: #fff; }
/* 一段连续日期（住期/预订期）的首尾描边 + 圆角，读起来像一根条 */
.cal-tbl td.cal-cell.s:not(.e) { border-left: 2px solid rgba(0, 0, 0, .22); border-top-left-radius: 7px; border-bottom-left-radius: 7px; }
.cal-tbl td.cal-cell.e:not(.s) { border-right: 2px solid rgba(0, 0, 0, .22); border-top-right-radius: 7px; border-bottom-right-radius: 7px; }
.cal-tbl td.cal-cell.s.e { border-left: 2px solid rgba(0, 0, 0, .22); border-right: 2px solid rgba(0, 0, 0, .22); border-radius: 7px; }
.cal-tbl td.cal-cell.todaycol { box-shadow: inset 0 0 0 1px rgba(214, 69, 69, .38); }
.cal-tbl tfoot td {
  position: sticky; bottom: 0; background: var(--panel); border-top: 1px solid var(--border);
  font-size: 11px; color: var(--muted); text-align: center; padding: 3px 0;
}
.cal-tbl tfoot td.cal-rm { z-index: 2; text-align: left; padding: 3px 10px; cursor: default; }
@media (max-width: 600px) {
  .cal-wrap { max-height: 52vh; }
  .cal-tbl thead th { width: 30px; min-width: 30px; font-size: 10px; }
  .cal-tbl th.cal-rm, .cal-tbl td.cal-rm { width: 72px; min-width: 72px; padding-left: 8px; }
  .cal-month { font-size: 14px; min-width: 108px; }
}
