* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; width: 100%; overflow-x: hidden; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  color: #333;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: #e9ecf2;
  overscroll-behavior-y: none;
}

#phone-frame {
  width: 100%;
  min-height: 100vh;
  background: #f4f6fa;
  position: relative;
}

@media (min-width: 600px) {
  body {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px 0;
    background: #d6dae3;
  }
  #phone-frame {
    width: 420px;
    min-height: 820px;
    max-height: 90vh;
    border-radius: 28px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.08);
    border: 1px solid #ccd2dc;
    background: #f4f6fa;
    overflow-y: auto;
  }
}

#app {
  min-height: 100vh;
  padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  padding-top: env(safe-area-inset-top, 0px);
}
@media (min-width: 600px) {
  #app { min-height: 820px; }
}

.nav {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-bottom: 1px solid #eee;
  position: sticky;
  top: 0;
  z-index: 10;
  font-size: 16px;
  font-weight: 500;
  padding-top: env(safe-area-inset-top, 0px);
  box-sizing: content-box;
}
.nav-back {
  position: absolute;
  left: 8px;
  bottom: 0;
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 22px;
  color: #666;
  cursor: pointer;
}

.page-header {
  padding: 20px 16px 12px;
  background: #fff;
  margin-bottom: 10px;
}
.page-header h2 { font-size: 20px; color: #1a1a2e; margin-bottom: 6px; }
.page-header p { font-size: 13px; color: #888; }

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 12px 16px;
}
.grid-3 { grid-template-columns: repeat(3, 1fr); }

.brand-bar {
  background: linear-gradient(135deg, #5a9bff, #2e6de5);
  color: #fff;
  text-align: center;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 2px;
  padding: 12px 0;
  box-shadow: 0 2px 6px rgba(46, 109, 229, 0.15);
}

.area-bar {
  background: #fff;
  border-bottom: 1px solid #eef1f5;
  padding: 10px 16px;
}
.area-bar-inner {
  background: #eaf2ff;
  border-radius: 6px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  font-size: 13px;
  color: #4a73cb;
}
.area-bar-inner::before {
  content: '';
  width: 14px;
  height: 14px;
  margin-right: 6px;
  border-radius: 50%;
  border: 2px solid #4a8bf7;
  box-shadow: inset 0 0 0 2px #fff;
  background: #4a8bf7;
  flex-shrink: 0;
  display: inline-block;
}
.area-chip {
  display: flex;
  align-items: center;
  gap: 8px;
}
.area-chip-modify {
  background: #4a8bf7;
  color: #fff;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}
.area-chip-modify:active { opacity: 0.8; }
.area-chip-label {
  color: #4a73cb;
  font-size: 13px;
}

.panel {
  background: #fff;
  margin: 12px 16px;
  border-radius: 10px;
  padding: 18px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.03);
}
.panel-title {
  font-size: 15px;
  color: #333;
  font-weight: 500;
  margin-bottom: 12px;
}
.panel-sub {
  font-size: 12px;
  color: #999;
  margin-bottom: 14px;
}

.select-wrap {
  position: relative;
}
.fake-select {
  height: 42px;
  border: 1px solid #dcdfe6;
  border-radius: 6px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
}
.fake-select:active { border-color: #4a8bf7; }
.fake-select-text { color: #999; }
.fake-select-text.has-value { color: #333; }
.fake-select-arrow { color: #999; font-size: 14px; transform: scaleY(0.8); }
.fake-select-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #dcdfe6;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
  max-height: 280px;
  overflow-y: auto;
  z-index: 50;
}
.fake-select-dropdown.hidden { display: none; }
.fake-select-option {
  padding: 11px 14px;
  font-size: 14px;
  color: #333;
  cursor: pointer;
  border-bottom: 1px solid #f5f7fa;
}
.fake-select-option:last-child { border-bottom: none; }
.fake-select-option:active { background: #f0f6ff; color: #4a8bf7; }
.fake-select-empty {
  padding: 20px;
  text-align: center;
  color: #999;
  font-size: 13px;
}

/* 填表 + 预览一体化 */
.action-panel {
  padding: 14px 16px;
}
.btn-reload {
  width: 100%;
  height: 42px;
  font-size: 15px;
  background: #4a8bf7;
  border: none;
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-reload::before {
  content: '↻';
  font-size: 16px;
}
.btn-reload:active { background: #3a7be5; }
.btn-reload:disabled { background: #a0c4ff; cursor: not-allowed; }

/* 图片查看器 */
.img-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.92);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}
.img-viewer-img {
  max-width: 100%;
  max-height: 100%;
  display: block;
  transform-origin: center center;
  transition: transform .15s ease-out;
  user-select: none;
  -webkit-user-drag: none;
  cursor: zoom-in;
}
.img-viewer-close {
  position: absolute;
  top: 14px;
  right: 16px;
  color: #fff;
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.3);
  border-radius: 50%;
}
.img-viewer-close:active { background: rgba(0,0,0,.5); }

.preview-panel {
  padding: 0;
  overflow: hidden;
}
.preview-head {
  background: #eaf2ff;
  color: #4a73cb;
  font-size: 14px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
}
.preview-head::before {
  content: '';
  width: 16px;
  height: 12px;
  margin-right: 8px;
  border: 1.5px solid #4a8bf7;
  border-radius: 2px;
  background:
    linear-gradient(135deg, transparent 55%, #4a8bf7 55%, #4a8bf7 70%, transparent 70%) no-repeat,
    #eaf2ff;
  box-sizing: border-box;
  display: inline-block;
  flex-shrink: 0;
}
.preview-body {
  padding: 16px;
  min-height: 120px;
}
.preview-empty {
  text-align: center;
  color: #999;
  font-size: 13px;
  padding: 30px 0;
}
.preview-img {
  width: 100%;
  border-radius: 4px;
  display: block;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  cursor: zoom-in;
}
.preview-tip {
  text-align: center;
  color: #888;
  font-size: 12px;
  margin-top: 10px;
  margin-bottom: 14px;
}
.btn-download {
  width: 100%;
  height: 42px;
  font-size: 15px;
  background: #4a8bf7;
  border: none;
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 10px;
}
.btn-download:active { background: #3a7be5; }

.preview-label {
  font-size: 14px;
  color: #333;
  font-weight: 500;
  margin-bottom: 8px;
  padding: 2px 0;
}
.preview-divider {
  height: 1px;
  background: #eef1f5;
  margin: 18px 0;
}
.btn-download-all {
  width: 100%;
  height: 46px;
  font-size: 15px;
  font-weight: 500;
  background: linear-gradient(135deg, #ff9a3e, #ff6b2b);
  border: none;
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 16px;
}
.btn-download-all:active { opacity: 0.85; }

/* Modal 弹窗 */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-box {
  width: 100%;
  max-width: 340px;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.modal-body {
  padding: 18px 18px 14px;
}
.modal-header {
  margin-bottom: 14px;
}
.modal-header-with-close {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-title {
  font-size: 16px;
  color: #333;
  font-weight: 500;
}
.modal-close {
  font-size: 22px;
  color: #999;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.modal-close:active { color: #333; }
.modal-warn {
  background: #fef0f0;
  color: #f56c6c;
  font-size: 13px;
  padding: 9px 12px;
  border-radius: 4px;
  border: 1px solid #fde2e2;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-warn-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #f56c6c;
  color: #fff;
  font-size: 12px;
  text-align: center;
  line-height: 16px;
  flex-shrink: 0;
  font-weight: bold;
}
.modal-label {
  font-size: 13px;
  color: #333;
  margin-bottom: 8px;
}
.modal-select {
  width: 100%;
  height: 40px;
  border: 1px solid #4a8bf7;
  border-radius: 4px;
  padding: 0 12px;
  font-size: 14px;
  background: #fff;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%23999' d='M6 8L0 0h12z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  margin-bottom: 14px;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}
.modal-btn {
  border: none;
  padding: 8px 18px;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
}
.modal-btn-cancel {
  background: #fff;
  border: 1px solid #dcdfe6;
  color: #606266;
}
.modal-btn-cancel:active { border-color: #4a8bf7; color: #4a8bf7; }
.modal-btn-ok {
  background: #a0c4ff;
  color: #fff;
}
.modal-btn-ok:active { background: #4a8bf7; }

/* Tree 分类树 */
.tree-box {
  border: 1px solid #ebeef5;
  border-radius: 4px;
  max-height: 320px;
  overflow-y: auto;
  padding: 6px 0;
  margin-bottom: 14px;
}
.tree-cat {
  user-select: none;
}
.tree-cat-head {
  padding: 8px 12px;
  font-size: 14px;
  color: #333;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tree-arrow {
  font-size: 10px;
  color: #999;
  transition: transform .2s;
  display: inline-block;
}
.tree-cat.collapsed .tree-arrow { transform: rotate(-90deg); }
.tree-cat.collapsed .tree-children { display: none; }
.tree-children { padding-left: 8px; }
.tree-row {
  padding: 7px 12px 7px 32px;
  font-size: 14px;
  color: #555;
  cursor: pointer;
  border-radius: 3px;
}
.tree-row:active { background: #ecf5ff; color: #4a8bf7; }
.tree-row.active { background: #ecf5ff; color: #4a8bf7; font-weight: 500; }

.cat-list {
  padding: 18px 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.cat-btn {
  display: block;
  padding: 15px 16px;
  font-size: 15px;
  color: #333;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background .12s;
}
.cat-btn:last-child { border-bottom: none; }
.cat-btn:active { background: #f5f7fa; }

.card {
  background: #fff;
  border-radius: 12px;
  padding: 18px 8px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: transform 0.15s, box-shadow 0.15s;
  border: 1px solid transparent;
  min-height: 76px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.card:active { transform: scale(0.97); box-shadow: 0 2px 4px rgba(0,0,0,.06); }
.card .icon {
  font-size: 26px;
  margin-bottom: 4px;
  display: block;
  line-height: 1;
}
.card .name { font-size: 14px; color: #333; font-weight: 500; }
.card .sub { font-size: 11px; color: #999; margin-top: 4px; }

.list {
  padding: 0 16px;
}
.list-item {
  background: #fff;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.03);
}
.list-item:active { background: #f7f7f9; }
.list-item .arrow { color: #bbb; font-size: 16px; }

.form-tip {
  margin: 10px 16px;
  padding: 10px 14px;
  background: #eef5ff;
  border-radius: 8px;
  font-size: 13px;
  color: #4a73cb;
}

.form {
  padding: 0 16px;
}
.form-item {
  background: #fff;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.panel .form-item {
  background: transparent;
  padding: 8px 0;
  margin-bottom: 8px;
}
.panel .form-input {
  border: 1px solid #dcdfe6;
  background: #fff;
}
.panel .form-input:focus { border-color: #4a8bf7; background: #fff; }
.form-label {
  font-size: 14px;
  color: #333;
  font-weight: 500;
  margin-bottom: 8px;
  display: block;
}
.form-label .required { color: #f56c6c; margin-right: 4px; }
.form-input {
  width: 100%;
  border: none;
  outline: none;
  font-size: 16px;
  padding: 10px 10px;
  background: #f7f8fa;
  border-radius: 6px;
  color: #222;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}
.form-input:focus { background: #eef2f8; }

.btn-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #eee;
  z-index: 20;
  box-shadow: 0 -2px 10px rgba(0,0,0,.04);
}
@media (min-width: 600px) {
  .btn-bar {
    position: absolute;
  }
}
.btn-primary {
  width: 100%;
  height: 46px;
  background: linear-gradient(135deg, #4a8bf7, #2e6de5);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary:active { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.preview-wrap {
  padding: 16px;
  text-align: center;
}
.preview-wrap img {
  max-width: 100%;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,.1);
  touch-action: pinch-zoom;
}
.preview-tip {
  margin-top: 12px;
  color: #888;
  font-size: 13px;
  padding: 0 10px;
}

.empty {
  text-align: center;
  color: #aaa;
  padding: 60px 20px;
  font-size: 14px;
}

.toast {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,.8);
  color: #fff;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  z-index: 1000;
  max-width: 80%;
  text-align: center;
  animation: toastIn .2s;
}
@media (min-width: 600px) {
  .toast { position: absolute; }
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -40%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

.loader {
  text-align: center;
  padding: 60px 20px;
  color: #999;
}

.desktop-hint {
  display: none;
}
@media (min-width: 600px) {
  .desktop-hint {
    display: block;
    position: fixed;
    left: 20px;
    top: 20px;
    bottom: 20px;
    width: 260px;
    padding: 18px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,.08);
    font-size: 13px;
    color: #555;
    line-height: 1.7;
    overflow-y: auto;
  }
  .desktop-hint h3 { font-size: 14px; color: #1a1a2e; margin-bottom: 8px; }
  .desktop-hint code {
    display: inline-block;
    background: #f0f4fa;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: Consolas, monospace;
    color: #4a8bf7;
    font-size: 12px;
    word-break: break-all;
  }
  .desktop-hint hr { border: none; border-top: 1px solid #eee; margin: 10px 0; }
  .desktop-hint .qr-box {
    margin-top: 10px;
    padding: 8px;
    background: #f7f9fc;
    border-radius: 6px;
    text-align: center;
  }
  .desktop-hint .qr-box img { width: 160px; height: 160px; }
}
