:root {
  --teal: #0f9e8e;
  --teal-dark: #0b7c70;
  --teal-soft: #e6f6f4;
  --ink: #1f2933;
  --ink-2: #52606d;
  --ink-3: #7b8794;
  --line: #e4e7eb;
  --bg: #f7f9fa;
  --card: #ffffff;
  --amber: #f0a02a;
  --amber-soft: #fef3e2;
  --red: #d64545;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 41, 51, .06), 0 6px 18px rgba(31, 41, 51, .06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

body[data-offline="1"] #offline-bar { display: flex; }

button, input, select, textarea { font: inherit; color: inherit; }

button {
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 10px;
}

a { color: var(--teal); text-decoration: none; }

/* ---------- 结构 ---------- */
#app { display: flex; min-height: 100%; }

.sidebar { display: none; }

.main {
  flex: 1;
  min-width: 0;
  max-width: 620px;
  margin: 0 auto;
  padding: 0 14px 92px;
  width: 100%;
}

#offline-bar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 30;
  align-items: center;
  gap: 8px;
  margin: 0 -14px 8px;
  padding: 9px 14px;
  background: var(--amber-soft);
  color: #8a5a00;
  font-size: 13px;
  border-bottom: 1px solid #f6dfbe;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0 10px;
  background: linear-gradient(var(--bg) 78%, rgba(247, 249, 250, 0));
}

.topbar h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .2px;
}

.topbar .spacer { flex: 1; }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  font-size: 17px;
}

.screen { display: none; animation: fade .16s ease; }
.screen.active { display: block; }

@keyframes fade { from { opacity: .4; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.muted { color: var(--ink-3); font-size: 13px; }
.tiny { color: var(--ink-3); font-size: 12px; }
.strong { font-weight: 700; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 46px;
  padding: 0 18px;
  background: var(--teal);
  color: #fff;
  font-weight: 600;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(15, 158, 142, .25);
}

.btn:active { transform: translateY(1px); }
.btn[disabled] { background: #cfd6dc; box-shadow: none; cursor: not-allowed; }
.btn.ghost { background: var(--card); color: var(--teal); box-shadow: var(--shadow); }
.btn.danger { background: var(--red); box-shadow: none; }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }

.input, select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
}

.input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
textarea { min-height: 76px; resize: vertical; }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  min-height: 54px;
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.search-box input {
  flex: 1;
  border: 0;
  outline: none;
  min-height: 52px;
  font-size: 16px;
  background: transparent;
}

.hint { margin: 8px 2px 0; font-size: 12.5px; color: var(--ink-3); }
.hint b { color: var(--teal); font-weight: 600; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 13px;
  color: var(--ink-2);
  white-space: nowrap;
}

.chip.active { background: var(--teal); color: #fff; box-shadow: 0 2px 8px rgba(15, 158, 142, .3); }

.section-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 20px 2px 10px;
  font-size: 14px;
  color: var(--ink-2);
}

.section-title b { font-size: 15px; color: var(--ink); }

.item-card {
  display: flex;
  gap: 12px;
  padding: 10px;
  margin-bottom: 10px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  text-align: left;
  width: 100%;
}

.item-card img, .thumb {
  width: 78px;
  height: 78px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--teal-soft);
  flex: 0 0 auto;
}

.thumb.placeholder { display: grid; place-items: center; color: var(--teal); font-size: 20px; }

.item-card .body { min-width: 0; flex: 1; }
.item-card .code {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .4px;
  color: var(--teal-dark);
  background: var(--teal-soft);
  border-radius: 6px;
  padding: 1px 6px;
  margin-bottom: 4px;
}

.item-card .name { font-weight: 700; font-size: 15.5px; margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-card .loc { font-size: 12.5px; color: var(--ink-2); }
.item-card .meta { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }

.room-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

.room-card {
  padding: 14px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  text-align: left;
}

.room-card .room-name { font-weight: 700; font-size: 15px; }
.room-card .room-meta { font-size: 12px; color: var(--ink-3); margin-top: 6px; }
.room-card .count { margin-top: 10px; font-size: 22px; font-weight: 700; color: var(--teal); }

.empty {
  padding: 34px 20px;
  text-align: center;
  color: var(--ink-3);
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.empty .big { font-size: 30px; margin-bottom: 8px; }

/* ---------- 页脚导航与悬浮按钮 ---------- */
.fab {
  position: fixed;
  right: max(18px, calc(50% - 300px));
  bottom: 78px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 20px rgba(15, 158, 142, .35);
  z-index: 25;
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 24;
  display: flex;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding: 6px 0 max(6px, env(safe-area-inset-bottom));
}

.tabbar button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  font-size: 11.5px;
  color: var(--ink-3);
}

.tabbar button .ico { font-size: 19px; line-height: 1; }
.tabbar button.active { color: var(--teal); font-weight: 700; }

/* ---------- 详情 / 位置卡 ---------- */
.hero { width: 100%; aspect-ratio: 4 / 3; border-radius: var(--radius); object-fit: cover; background: var(--teal-soft); }
.photo-strip { display: flex; gap: 8px; overflow-x: auto; margin-top: 10px; }
.photo-strip img { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; }

.kv { display: grid; grid-template-columns: 84px 1fr; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--ink-3); font-size: 13px; }
.kv dd { margin: 0; }

.location-card {
  padding: 22px 18px;
  border-radius: 18px;
  background: linear-gradient(160deg, #e6f6f4, #ffffff 70%);
  border: 1px solid #cdeee9;
}

.location-card .label { font-size: 12.5px; color: var(--teal-dark); letter-spacing: .6px; }
.location-card .room { font-size: 30px; font-weight: 800; margin: 8px 0 4px; }
.location-card .path { font-size: 17px; color: var(--ink-2); }
.location-card .code { margin-top: 12px; font-size: 14px; color: var(--ink-3); }

.candidate {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 10px;
  margin-bottom: 10px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: left;
}

.candidate .score {
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
  color: var(--teal-dark);
  background: var(--teal-soft);
  padding: 3px 8px;
  border-radius: 999px;
}

.candidate .reason { font-size: 11.5px; color: var(--ink-3); }

.drop {
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 30px 16px;
  border: 2px dashed #bfe4df;
  border-radius: var(--radius);
  background: var(--card);
  color: var(--teal-dark);
  text-align: center;
}

.drop .big { font-size: 30px; }

.steps { display: grid; gap: 6px; margin: 12px 0; }
.step { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-3); }
.step .dot { width: 8px; height: 8px; border-radius: 50%; background: #d4dae0; }
.step.active { color: var(--teal-dark); font-weight: 600; }
.step.active .dot { background: var(--teal); }
.step.done .dot { background: var(--teal); }

/* ---------- 弹层 / toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%) translateY(20px);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 92vw;
  padding: 11px 16px;
  border-radius: 12px;
  background: rgba(31, 41, 51, .94);
  color: #fff;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast button { color: #7ff0e2; font-weight: 700; }

.modal-back {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 23, 32, .42);
}

.modal-back.show { display: flex; }
.modal {
  width: 100%;
  max-width: 460px;
  max-height: 86vh;
  overflow: auto;
  padding: 18px;
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}

.modal h3 { margin: 0 0 12px; font-size: 17px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }

/* ---------- 登录页 ---------- */
#auth {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  place-items: center;
  padding: 20px;
  background: radial-gradient(1200px 500px at 50% -10%, #dff3f0, var(--bg));
}

#auth.show { display: grid; }
.auth-card { width: 100%; max-width: 380px; padding: 26px 22px; }
.auth-card h2 { margin: 0 0 4px; font-size: 24px; letter-spacing: 1px; }
.auth-card .brand { color: var(--teal); }
.auth-card p { margin: 0 0 18px; font-size: 13px; color: var(--ink-3); }
.auth-switch { margin-top: 12px; font-size: 13px; text-align: center; color: var(--ink-3); }
.auth-switch button { color: var(--teal); font-weight: 600; }
.form-error { min-height: 18px; margin: 6px 0 0; font-size: 12.5px; color: var(--red); }

/* ---------- 桌面布局 ---------- */
@media (min-width: 900px) {
  #app { max-width: 1180px; margin: 0 auto; gap: 20px; padding: 0 20px; }
  .sidebar {
    display: block;
    width: 240px;
    flex: 0 0 240px;
    padding: 18px 0;
    position: sticky;
    top: 0;
    align-self: flex-start;
    max-height: 100vh;
    overflow: auto;
  }
  .sidebar h2 { font-size: 13px; color: var(--ink-3); letter-spacing: .8px; margin: 18px 6px 8px; font-weight: 600; }
  .sidebar .nav-item {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 9px 10px;
    border-radius: 10px;
    font-size: 14px;
    color: var(--ink-2);
    text-align: left;
  }
  .sidebar .nav-item:hover { background: #eef4f4; }
  .sidebar .nav-item.active { background: var(--teal-soft); color: var(--teal-dark); font-weight: 700; }
  .main { max-width: none; margin: 0; padding-bottom: 60px; }
  .tabbar { display: none; }
  .fab { right: 34px; bottom: 34px; }
  .room-grid { grid-template-columns: repeat(3, 1fr); }
  .search-box { min-height: 56px; }
}

@media (min-width: 900px) {
  .screen.active { display: block; }
}
