/* ===== 全局样式 ===== */
:root {
  --primary: #1e88e5;
  --primary-dark: #1565c0;
  --primary-light: #42a5f5;
  --bg: #f5f6fa;
  --bg-white: #ffffff;
  --text-primary: #1a1a1a;
  --text-secondary: #666666;
  --text-hint: #999999;
  --border: #e8e8e8;
  --success: #4caf50;
  --warning: #ff9800;
  --danger: #f44336;
  --banner-yellow: #fff8e1;
  --banner-yellow-border: #ffc107;
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg);
  overflow: hidden;
}

#app {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background: var(--bg-white);
}

/* ===== 页面切换 ===== */
.page {
  display: none;
  height: 100%;
  position: relative;
}

.page.active {
  display: flex;
  flex-direction: column;
}

.app-page {
  display: none;
  flex: 1;
  overflow: hidden;
  flex-direction: column;
}

.app-page.active {
  display: flex;
}

/* ===== 登录页 ===== */
#page-login {
  background: var(--bg-white);
  padding: 60px 24px 24px;
  align-items: stretch;
}

.login-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.login-logo {
  text-align: center;
  margin-bottom: 24px;
}

.login-title {
  text-align: center;
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 40px;
}

.login-form {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.form-item {
  margin-bottom: 24px;
}

.form-item label {
  display: block;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 10px;
  font-weight: 500;
}

.required {
  color: var(--danger);
  margin-right: 2px;
}

.form-item input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 15px;
  background: var(--bg-white);
  outline: none;
  transition: border-color 0.2s;
}

.form-item input:focus {
  border-color: var(--primary);
}

.btn-login {
  width: 100%;
  height: 46px;
  background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
  color: #fff;
  border: none;
  border-radius: 23px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 20px;
  box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
  transition: transform 0.1s, box-shadow 0.2s;
}

.btn-login:active {
  transform: scale(0.98);
  box-shadow: 0 1px 4px rgba(33, 150, 243, 0.3);
}

.login-helpers {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
}

.helper-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
}

.login-agreement {
  text-align: center;
  font-size: 11px;
  color: var(--text-hint);
  margin-top: auto;
  padding-bottom: 20px;
}

.agreement-links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
}

.agreement-links a {
  color: var(--primary);
  text-decoration: none;
  font-size: 11px;
}

/* ===== 主应用框架 ===== */
#page-app {
  background: var(--bg);
}

/* ===== 首页 ===== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 50px;
  padding: 0 16px;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

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

.header-scan-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.header-scan-btn:active {
  background: rgba(0, 0, 0, 0.05);
}

.app-content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 20px;
}

/* 账单 Banner */
.bill-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px;
  padding: 12px 14px;
  background: var(--banner-yellow);
  border: 1px solid var(--banner-yellow-border);
  border-radius: 8px;
}

.banner-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.banner-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.banner-text {
  font-size: 13px;
  color: #795548;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.banner-pay-btn {
  background: var(--warning);
  color: #fff;
  border: none;
  padding: 6px 16px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 500;
  flex-shrink: 0;
  margin-left: 10px;
}

/* 蓝色数据卡片 */
.data-card {
  margin: 12px;
  padding: 16px;
  background: linear-gradient(135deg, #64b5f6 0%, #1976d2 50%, #0d47a1 100%);
  border-radius: 10px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(25, 118, 210, 0.25);
}

.data-card-header {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
}

.data-title {
  font-size: 13px;
  opacity: 0.9;
}

.data-info-icon {
  font-size: 12px;
  opacity: 0.7;
}

.data-value-main {
  font-size: 36px;
  font-weight: 700;
  margin-bottom: 14px;
}

.data-sub-row {
  display: flex;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.data-sub-item {
  flex: 1;
  text-align: center;
}

.data-sub-label {
  display: block;
  font-size: 12px;
  opacity: 0.8;
  margin-bottom: 4px;
}

.data-sub-value {
  font-size: 18px;
  font-weight: 600;
}

/* 数据详情行 */
.detail-rows {
  margin: 0 12px 12px;
  background: var(--bg-white);
  border-radius: 10px;
  overflow: hidden;
}

.detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  color: var(--text-primary);
}

.info-icon {
  color: var(--text-hint);
  font-size: 14px;
}

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

/* 功能图标区 */
.function-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px 8px;
  padding: 16px 12px;
  background: var(--bg-white);
  margin: 0 12px;
  border-radius: 10px;
}

.func-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
  cursor: pointer;
}

.func-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.func-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.3;
}

.func-item-badge {
  position: relative;
}

.func-badge {
  position: absolute;
  top: -4px;
  right: -2px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 8px;
  white-space: nowrap;
}

/* 图标颜色 */
.func-blue { background: #e3f2fd; }
.func-green { background: #e8f5e9; }
.func-teal { background: #e0f2f1; }
.func-orange { background: #fff3e0; }
.func-indigo { background: #e8eaf6; }
.func-purple { background: #f3e5f5; }
.func-pink { background: #fce4ec; }
.func-red { background: #ffebee; }
.func-amber { background: #fff8e1; }
.func-rose { background: #fce4ec; }
.func-yellow { background: #fffde7; }
.func-cyan { background: #e0f7fa; }
.func-lime { background: #f1f8e9; }
.func-sky { background: #e1f5fe; }
.func-red-dark { background: #fdecea; }
.func-orange-dark { background: #feefe3; }
.func-gray { background: #f5f5f5; }

/* 在线信息 */
.online-info {
  text-align: right;
  padding: 12px 20px 4px;
  font-size: 12px;
  color: var(--text-hint);
}

/* ===== 底部导航栏 ===== */
.bottom-nav {
  display: flex;
  height: 56px;
  background: var(--bg-white);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-hint);
  cursor: pointer;
  transition: color 0.2s;
}

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

.nav-icon svg {
  display: block;
}

.nav-label {
  font-size: 11px;
}

/* ===== 我的页面 ===== */
.profile-content {
  padding: 0;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 16px;
  background: linear-gradient(135deg, #1e88e5 0%, #1565c0 100%);
  color: #fff;
}

.user-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.2);
}

.user-info {
  flex: 1;
}

.user-name {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 4px;
}

.user-id {
  font-size: 13px;
  opacity: 0.8;
}

.profile-menu {
  margin: 12px;
  background: var(--bg-white);
  border-radius: 10px;
  overflow: hidden;
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

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

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

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

.menu-icon {
  font-size: 18px;
}

.menu-label {
  font-size: 14px;
  color: var(--text-primary);
}

.menu-right {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-hint);
}

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

.btn-logout {
  display: block;
  width: calc(100% - 24px);
  margin: 20px 12px 12px;
  height: 44px;
  background: var(--bg-white);
  color: var(--danger);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
}

.btn-logout:active {
  background: #ffebee;
}

/* ===== 扫一扫 ===== */
.scan-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  background: #000;
  z-index: 1000;
  display: none;
  flex-direction: column;
}

.scan-modal.active {
  display: flex;
}

.scan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 50px;
  padding: 0 12px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  flex-shrink: 0;
}

.scan-back-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scan-title {
  font-size: 16px;
  font-weight: 500;
}

.scan-placeholder {
  width: 36px;
}

.scan-body {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#cameraVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.scan-frame {
  position: relative;
  width: 220px;
  height: 220px;
}

.corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border: 3px solid var(--primary);
}

.corner-tl {
  top: 0;
  left: 0;
  border-right: none;
  border-bottom: none;
}

.corner-tr {
  top: 0;
  right: 0;
  border-left: none;
  border-bottom: none;
}

.corner-bl {
  bottom: 0;
  left: 0;
  border-right: none;
  border-top: none;
}

.corner-br {
  bottom: 0;
  right: 0;
  border-left: none;
  border-top: none;
}

.scan-line {
  position: absolute;
  top: 0;
  left: 10px;
  right: 10px;
  height: 2px;
  background: var(--primary);
  animation: scanMove 2.5s ease-in-out infinite;
}

@keyframes scanMove {
  0%, 100% { top: 10px; }
  50% { top: calc(100% - 10px); }
}

.scan-tip {
  margin-top: 30px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  text-align: center;
}

.scan-error {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 40px 24px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  text-align: center;
}

.scan-error p {
  margin-bottom: 20px;
  font-size: 14px;
}

.btn-back-home {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 12px 32px;
  border-radius: 24px;
  font-size: 14px;
  cursor: pointer;
}

/* ===== 语言选择弹层 ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  width: 280px;
  background: var(--bg-white);
  border-radius: 12px;
  padding: 24px;
}

.modal-title {
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 20px;
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 8px;
}

.lang-option:active {
  background: var(--bg);
}

.lang-option.active {
  background: #e3f2fd;
}

.lang-text {
  flex: 1;
  font-size: 15px;
}

.lang-check {
  color: var(--primary);
  font-weight: 600;
  display: none;
}

.lang-option.active .lang-check {
  display: block;
}

.modal-close {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  background: var(--bg);
  border: none;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
}
