:root {
  --primary-color: #007AFF;
  --bg-color: #F2F2F7;
  --card-bg: #FFFFFF;
  --text-primary: #000000;
  --text-secondary: #8E8E93;
  --text-tertiary: #AEAEB2;
  --separator: #E5E5EA;
  --success: #34C759;
  --danger: #FF3B30;
  --warning: #FF9500;
  --border-radius: 12px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  padding-bottom: var(--safe-area-bottom);
}

.page {
  min-height: 100vh;
  background-color: var(--bg-color);
  padding-top: 44px;
}

.nav-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 44px;
  background-color: rgba(249, 249, 249, 0.94);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  border-bottom: 0.5px solid var(--separator);
}

.nav-bar .nav-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

.nav-bar .nav-back {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--primary-color);
  font-size: 17px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.nav-bar .nav-right {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--primary-color);
  font-size: 17px;
  background: none;
  border: none;
  cursor: pointer;
}

.content {
  padding: 20px 16px;
  padding-bottom: calc(70px + var(--safe-area-bottom));
}

.btn-primary {
  width: 100%;
  height: 50px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.btn-primary:active {
  opacity: 0.7;
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  width: 100%;
  height: 50px;
  background-color: var(--card-bg);
  color: var(--primary-color);
  border: none;
  border-radius: var(--border-radius);
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 12px;
}

.input-group {
  background-color: var(--card-bg);
  border-radius: var(--border-radius);
  margin-bottom: 16px;
  overflow: hidden;
}

.input-group input {
  width: 100%;
  height: 50px;
  border: none;
  border-bottom: 0.5px solid var(--separator);
  padding: 0 16px;
  font-size: 16px;
  background-color: transparent;
  outline: none;
  color: var(--text-primary);
  -webkit-appearance: none;
}

.input-group input:last-child {
  border-bottom: none;
}

.input-group input::placeholder {
  color: var(--text-tertiary);
}

.form-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  padding-left: 4px;
}

.card {
  background-color: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.card-value {
  font-size: 17px;
  font-weight: 500;
  color: var(--text-primary);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
}

.empty-state .empty-icon {
  width: 80px;
  height: 80px;
  background-color: var(--separator);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  font-size: 36px;
  color: var(--text-tertiary);
}

.empty-state .empty-text {
  font-size: 17px;
  color: var(--text-tertiary);
  margin-bottom: 24px;
}

.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  background-color: rgba(249, 249, 249, 0.94);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  display: flex;
  border-top: 0.5px solid var(--separator);
  padding-bottom: var(--safe-area-bottom);
  z-index: 999;
}

.tab-bar .tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: 3px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color 0.2s;
}

.tab-bar .tab-item.active {
  color: var(--primary-color);
}

.tab-bar .tab-icon {
  width: 22px;
  height: 22px;
  margin-bottom: 1px;
}

.tab-bar .tab-label {
  font-size: 10px;
  font-weight: 500;
}

.fab {
  position: fixed;
  bottom: 70px;
  right: 20px;
  width: 52px;
  height: 52px;
  background-color: var(--primary-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 26px;
  box-shadow: 0 4px 16px rgba(0, 122, 255, 0.3);
  cursor: pointer;
  z-index: 100;
  transition: transform 0.2s;
}

.fab:active {
  transform: scale(0.92);
}

.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(0, 0, 0, 0.75);
  color: white;
  padding: 12px 20px;
  border-radius: var(--border-radius);
  font-size: 14px;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
}

.status-online {
  background-color: rgba(52, 199, 89, 0.15);
  color: var(--success);
}

.status-offline {
  background-color: rgba(142, 142, 147, 0.15);
  color: var(--text-tertiary);
}

.device-card {
  background-color: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.device-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.device-id {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

.device-info {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-secondary);
}

.device-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

/* 开关按钮 */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #ccc;
  border-radius: 28px;
  transition: 0.3s;
}

.toggle-slider:before {
  content: "";
  position: absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--success);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(24px);
}

.toggle-label {
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.btn-unbind {
  margin-left: auto;
  height: 32px;
  padding: 0 14px;
  background-color: rgba(255, 59, 48, 0.1);
  color: var(--danger);
  border: none;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-unbind:active {
  opacity: 0.7;
}

.settings-group {
  background-color: var(--card-bg);
  border-radius: var(--border-radius);
  margin-bottom: 20px;
  overflow: hidden;
}

.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 0.5px solid var(--separator);
  cursor: pointer;
  transition: background-color 0.15s;
}

.settings-item:last-child {
  border-bottom: none;
}

.settings-item:active {
  background-color: var(--bg-color);
}

.settings-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.settings-icon.blue { background-color: rgba(0, 122, 255, 0.15); color: var(--primary-color); }
.settings-icon.red { background-color: rgba(255, 59, 48, 0.15); color: var(--danger); }
.settings-icon.orange { background-color: rgba(255, 149, 0, 0.15); color: var(--warning); }

.settings-text {
  font-size: 16px;
  color: var(--text-primary);
}

.settings-arrow {
  color: var(--text-tertiary);
  font-size: 18px;
}

.brand-logo {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #007AFF, #5AC8FA);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 28px;
  font-weight: bold;
  margin: 0 auto 16px;
}

.brand-title {
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.brand-subtitle {
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 40px;
}

.footer-link {
  text-align: center;
  font-size: 15px;
  color: var(--primary-color);
  margin-top: 24px;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
}

.footer-link:active {
  opacity: 0.7;
}

.user-profile {
  background: linear-gradient(135deg, #007AFF, #5AC8FA);
  border-radius: var(--border-radius);
  padding: 24px 20px;
  margin-bottom: 20px;
  color: white;
  display: flex;
  align-items: center;
  gap: 16px;
}

.avatar {
  width: 60px;
  height: 60px;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 600;
}

.user-info .username {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}

.user-info .user-phone {
  font-size: 14px;
  opacity: 0.8;
}

/* 扫码页 - 上传识别区 */
.scan-upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  background-color: var(--card-bg);
  border: 2px dashed var(--border-color);
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s;
}
.scan-upload-area:active {
  background-color: var(--bg-color);
  border-color: var(--primary-color);
}
.scan-upload-icon {
  font-size: 48px;
  margin-bottom: 12px;
}
.scan-upload-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-color);
  margin-bottom: 6px;
}
.scan-upload-desc {
  font-size: 13px;
  color: var(--text-secondary);
}

/* 扫码页 - 识别结果 */
.scan-result {
  padding: 32px 24px;
  background-color: var(--card-bg);
  border-radius: 16px;
  text-align: center;
}
.scan-result-icon {
  font-size: 48px;
  margin-bottom: 12px;
}
.scan-result-text {
  font-size: 15px;
  color: var(--text-color);
  word-break: break-all;
}

/* 扫码页 - 分隔线 */
.scan-divider {
  display: flex;
  align-items: center;
  margin: 28px 0;
}
.scan-divider-line {
  flex: 1;
  height: 1px;
  background-color: var(--border-color);
}
.scan-divider-text {
  padding: 0 16px;
  font-size: 14px;
  color: var(--text-secondary);
}

/* 扫码页 - 手动输入 */
.scan-manual-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-color);
  margin-bottom: 12px;
}
.scan-manual-row {
  display: flex;
  gap: 10px;
}
.scan-manual-row input {
  flex: 1;
  height: 44px;
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-color);
  padding: 0 16px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}
.scan-manual-row input:focus {
  border-color: var(--primary-color);
}
.scan-manual-row input::placeholder {
  color: var(--text-secondary);
}

.btn-secondary {
  background-color: var(--card-bg);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  height: 44px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:active {
  background-color: var(--bg-color);
}

.danger-text {
  color: var(--danger);
}
