/* 家庭橱柜 H5 全局样式 */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: #f5f6f8;
  color: #333;
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 15px;
}
#app { max-width: 640px; margin: 0 auto; padding: 12px 12px 40px; }

.page { }
.empty { text-align: center; color: #999; padding: 48px 16px; }
.muted { color: #999; font-size: 13px; }
.loading { text-align: center; color: #999; padding: 32px; }

/* 顶栏 */
.topbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.topbar .title { font-size: 17px; font-weight: 600; flex: 1; }
.back { color: #e8833a; text-decoration: none; font-size: 15px; padding: 4px 4px 4px 0; }

/* 卡片 */
.card {
  background: #fff;
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.card-title { font-weight: 600; margin-bottom: 10px; font-size: 15px; }

/* 行 */
.row { display: flex; align-items: center; }
.row-item { padding: 11px 0; border-bottom: 1px solid #f0f1f3; cursor: pointer; }
.row-item:last-child { border-bottom: none; }
.item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 标签 */
.tag {
  display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 8px;
  vertical-align: middle; line-height: 18px; margin-left: 6px;
}
.tag.ok { background: #e6f6ea; color: #3a9e52; }
.tag.warn { background: #fdeede; color: #c26a1d; }
.tag.off { background: #eceef1; color: #888; }

/* 按钮 */
.btn-primary, .btn-plain, .btn-danger {
  text-align: center; border-radius: 10px; padding: 11px; font-size: 15px; cursor: pointer;
  border: 1px solid transparent;
}
.btn-primary { background: #e8833a; color: #fff; }
.btn-plain { background: #fff; border-color: #e3e5e8; color: #444; }
.btn-danger { background: #fdeaea; color: #d54848; }
.btn-mini {
  font-size: 12px; padding: 5px 12px; border-radius: 8px; background: #fff;
  border: 1px solid #e3e5e8; color: #444; cursor: pointer;
}
.btn-mini.primary { background: #e8833a; border-color: #e8833a; color: #fff; }

/* 找找：搜索 + tabs */
.search-bar { position: relative; margin-bottom: 10px; }
.search-input {
  width: 100%; padding: 11px 38px 11px 14px; border-radius: 10px; border: none;
  background: #fff; font-size: 15px; outline: none;
}
.search-clear {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: #bbb; font-size: 15px; cursor: pointer; padding: 4px;
}
.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tab { padding: 7px 18px; border-radius: 18px; background: #eceef1; color: #666; font-size: 14px; cursor: pointer; }
.tab.on { background: #e8833a; color: #fff; }

/* 柜子入口卡片（搜索命中柜名） */
.cab-hint { cursor: pointer; }
.cab-hint-main { font-size: 15px; margin-bottom: 4px; }

/* 柜子列表 */
.cab-row { display: flex; align-items: center; cursor: pointer; }
.cab-thumb {
  width: 42px; height: 42px; border-radius: 8px; margin-right: 12px; flex-shrink: 0;
  background: #eef0f3; object-fit: cover;
}
.cab-thumb-empty {
  width: 42px; height: 42px; border-radius: 8px; margin-right: 12px; flex-shrink: 0;
  background: #fff; border: 1px dashed #ccc;
  display: flex; align-items: center; justify-content: center; color: #ccc; font-size: 18px;
}
.cab-main { flex: 1; min-width: 0; }
.cab-name { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cab-arrow { color: #ccc; }
.fab {
  position: fixed; right: 18px; bottom: 26px; width: 52px; height: 52px; border-radius: 50%;
  background: #e8833a; color: #fff; font-size: 28px; display: flex; align-items: center;
  justify-content: center; box-shadow: 0 3px 10px rgba(232, 131, 58, 0.4); cursor: pointer; z-index: 30;
}

/* chips（格子选择 / 移动） */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 6px 12px; background: #f2f3f5; border-radius: 9px; font-size: 13px; color: #555; cursor: pointer;
  border: 1px solid transparent;
}
.chip.cur { background: #fdeede; color: #c26a1d; border-color: #e8833a; }

/* cell-map 组件 */
.cellmap { position: relative; border-radius: 10px; overflow: hidden; background: #f0f1f3; }
.cellmap .cm-photo { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.cm-overlay { position: absolute; inset: 0; touch-action: none; }
.cellmap.view .cm-overlay, .cellmap.pick .cm-overlay { touch-action: auto; }
.cm-cell {
  position: absolute; border: 2px solid rgba(232, 131, 58, 0.85); background: rgba(232, 131, 58, 0.14);
  border-radius: 4px; cursor: pointer;
}
.cm-cell.sel { border-color: #3a9e52; background: rgba(58, 158, 82, 0.2); }
.cm-cell.hl { animation: cmpulse 1.1s ease-in-out infinite; border-color: #e85d1a; background: rgba(232, 93, 26, 0.3); }
@keyframes cmpulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232, 93, 26, 0.55); }
  50% { box-shadow: 0 0 0 6px rgba(232, 93, 26, 0); }
}
.cm-cell.dragging { border-style: dashed; z-index: 5; }
.cm-label {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  color: #fff; font-weight: 600; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55); pointer-events: none;
  white-space: nowrap;
}
.cm-type {
  position: absolute; left: 3px; bottom: 3px; background: rgba(232, 131, 58, 0.92); color: #fff;
  font-size: 12px; line-height: 1; padding: 3px 6px; border-radius: 8px; cursor: pointer;
}
.cm-type.sm { padding: 2px 5px; }
.cm-x {
  position: absolute; right: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: rgba(213, 72, 72, 0.92); color: #fff; font-size: 12px; display: flex;
  align-items: center; justify-content: center; cursor: pointer;
}
.cm-dot {
  position: absolute; right: -7px; bottom: -7px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 2px solid #e8833a; cursor: nwse-resize;
}
.cm-temp {
  position: absolute; border: 2px dashed #e8833a; background: rgba(232, 131, 58, 0.12);
  border-radius: 4px; pointer-events: none;
}

/* 编辑提示条（图片外） */
.edit-hint {
  margin-top: 10px; background: #fdf3e4; color: #b06a1e; border-radius: 8px;
  padding: 8px 12px; font-size: 12px; line-height: 1.6;
}

/* 表单 */
.form-item { margin-bottom: 12px; }
.form-label { font-size: 13px; color: #888; margin-bottom: 5px; }
.form-input, .form-select {
  width: 100%; padding: 10px 12px; border-radius: 9px; border: 1px solid #e3e5e8;
  font-size: 15px; outline: none; background: #fff;
}
.form-input:focus { border-color: #e8833a; }
.form-row { display: flex; gap: 10px; }
.form-row .form-item { flex: 1; }
.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 4px 0; }

/* 底部弹层 */
.mask {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 100;
  display: flex; align-items: flex-end; justify-content: center; animation: fadein 0.15s;
}
@keyframes fadein { from { opacity: 0; } }
.sheet {
  background: #fff; width: 100%; max-width: 640px; border-radius: 16px 16px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 78vh; overflow-y: auto;
  animation: slideup 0.18s ease-out;
}
@keyframes slideup { from { transform: translateY(40px); opacity: 0.5; } }
.sheet-title { font-weight: 600; font-size: 16px; margin-bottom: 12px; }
.sheet-opt { padding: 13px; text-align: center; border-bottom: 1px solid #f0f1f3; cursor: pointer; font-size: 15px; }
.sheet-opt.cancel { border: none; color: #999; margin-top: 4px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 14px; }
.sheet-actions > * { flex: 1; }
.move-cab { margin: 10px 0 6px; }

/* 中央弹窗 */
.modal {
  background: #fff; border-radius: 14px; width: 84%; max-width: 340px; padding: 20px 16px 14px;
  margin: auto; animation: pop 0.15s ease-out;
}
@keyframes pop { from { transform: scale(0.92); opacity: 0.5; } }
.mask.center { align-items: center; }
.modal-title { font-weight: 600; font-size: 16px; text-align: center; margin-bottom: 10px; }
.modal-content { color: #666; font-size: 14px; line-height: 1.6; text-align: center; margin-bottom: 6px; }
.modal-btns { display: flex; gap: 10px; margin-top: 14px; }
.mbtn {
  flex: 1; padding: 10px; border-radius: 9px; border: 1px solid #e3e5e8; background: #fff;
  font-size: 15px; cursor: pointer;
}
.mbtn.ok { background: #e8833a; border-color: #e8833a; color: #fff; }
.mbtn.ok.danger { background: #d54848; border-color: #d54848; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 18%; transform: translateX(-50%) translateY(8px);
  background: rgba(20, 20, 20, 0.82); color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 14px; opacity: 0; transition: 0.18s; pointer-events: none; z-index: 200; max-width: 78%;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 登录页 */
.login-box { max-width: 320px; margin: 60px auto 0; }
.login-box .logo { text-align: center; font-size: 40px; margin-bottom: 8px; }
.login-box h1 { text-align: center; font-size: 19px; margin: 0 0 22px; }

/* 格子弹层内物品列表 */
.cell-item-row { display: flex; align-items: center; padding: 9px 0; border-bottom: 1px solid #f0f1f3; cursor: pointer; }
.cell-item-row:last-child { border-bottom: none; }
.qa-section { border-top: 1px solid #f0f1f3; margin-top: 12px; padding-top: 12px; }
.qa-row { display: flex; gap: 8px; }
.qa-row .form-input { flex: 1; }
.qa-btn { padding: 0 18px; border-radius: 9px; background: #e8833a; color: #fff; border: none; font-size: 14px; cursor: pointer; }

/* 格子列表（编辑页） */
.cell-li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #f0f1f3; }
.cell-li:last-child { border-bottom: none; }
.cell-li .cl-label { font-weight: 600; width: 44px; }
.cell-li .cl-type { color: #999; font-size: 13px; flex: 1; }
.cell-li .cl-pos { color: #bbb; font-size: 12px; }

.grid-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.grid-form .form-item { flex: 1; min-width: 70px; margin-bottom: 0; }
.grid-form .btn-mini { padding: 10px 16px; font-size: 14px; }
.grid-preview { color: #888; font-size: 13px; margin-top: 8px; }

.photo-upload {
  border: 2px dashed #d5d8dd; border-radius: 12px; padding: 26px; text-align: center;
  color: #999; cursor: pointer; margin-bottom: 12px; background: #fff;
}

/* 底部导航 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; background: #fff; border-top: 1px solid #eceef1;
  padding-bottom: env(safe-area-inset-bottom); max-width: 640px; margin: 0 auto;
}
.tb-item {
  flex: 1; text-align: center; padding: 7px 0 6px; color: #999; text-decoration: none; font-size: 11px;
}
.tb-item .tb-ico { display: block; font-size: 20px; margin-bottom: 1px; }
.tb-item.on { color: #e8833a; }
body.has-tabbar { padding-bottom: 64px; }
