:root {
    --bg-color: #F4F1EB;
    --bg-deep: #E8E4DA;
    --card-bg: #FFFFFF;
    --primary: #6FA89A;
    --primary-dark: #4F8578;
    --primary-soft: #E4F2ED;
    --gold: #C4A35A;
    --text-main: #2C3330;
    --text-muted: #6B736F;
    --text-light: #9AA19C;
    --border: #E6E2DA;
    --shadow: 0 8px 24px rgba(44, 51, 48, 0.06);
    --shadow-lg: 0 16px 40px rgba(44, 51, 48, 0.10);
    --radius-lg: 22px;
    --radius-md: 16px;
    --safe-area-bottom: env(safe-area-inset-bottom);
    --safe-area-top: env(safe-area-inset-top);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

.hidden { display: none !important; }

body, html {
    margin: 0; padding: 0; height: 100%; width: 100%;
    background:
        radial-gradient(120% 80% at 10% -10%, #E7F3EE 0%, transparent 55%),
        radial-gradient(90% 60% at 100% 0%, #F3EFE6 0%, transparent 45%),
        var(--bg-color);
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--text-main);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

#app-root {
    display: flex; flex-direction: column;
    height: 100%; width: 100%; position: relative;
}

.view-container {
    flex: 1; overflow-y: auto;
    padding: 16px 18px calc(100px + var(--safe-area-bottom)) 18px;
    -webkit-overflow-scrolling: touch;
}

/* 头部与底部 */
.header {
    padding: calc(28px + var(--safe-area-top)) 8px 12px;
    background: transparent; flex-shrink: 0;
}
.header h2 { letter-spacing: -0.02em; font-weight: 750; }
.bottom-dock {
    position: absolute; bottom: calc(14px + var(--safe-area-bottom));
    left: 16px; right: 16px; height: 64px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-radius: 22px; border: 1px solid rgba(255,255,255,0.7);
    display: flex; justify-content: space-around; align-items: center;
    box-shadow: var(--shadow-lg); z-index: 100;
}
.dock-item { font-size: 22px; color: #C5CBC7; transition: 0.2s; cursor: pointer; padding: 10px 16px; }
.dock-item.active { color: var(--primary-dark); transform: scale(1.08); }

/* 组件 */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 14px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(255,255,255,0.8);
}
.btn {
    background: var(--primary); color: white; border: none; padding: 15px;
    width: 100%; border-radius: var(--radius-md); font-weight: 700; font-size: 16px;
    margin-top: 10px; cursor: pointer;
    transition: transform .15s ease, background .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
    background: linear-gradient(180deg, #7BB5A6 0%, var(--primary-dark) 100%);
    box-shadow: 0 10px 20px rgba(79, 133, 120, 0.28);
}
.btn-secondary {
    background: #F1EFEA; color: var(--text-main); font-weight: 600;
    box-shadow: none;
}
.btn.vip-btn { background: linear-gradient(135deg, #D4AF37, #FFE98A); color: #5a4a00; }
input, select, textarea {
    width: 100%; padding: 14px 16px; background: #FFF; border: 1.5px solid var(--border);
    border-radius: 14px; margin-bottom: 12px; font-size: 16px; outline: none;
    color: var(--text-main); transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(111, 168, 154, 0.18);
}

/* ===== 登录 / 注册（商用 App 布局）===== */
.auth-screen {
    position: fixed; inset: 0; z-index: 200;
    display: flex; flex-direction: column;
    padding: calc(24px + var(--safe-area-top)) 20px calc(24px + var(--safe-area-bottom));
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    background:
        radial-gradient(100% 60% at 50% -5%, #D8EBE4 0%, transparent 60%),
        linear-gradient(180deg, #F7F5F0 0%, #EFEBE3 100%);
}
.auth-hero {
    flex: 0 0 auto;
    text-align: center;
    padding: 28px 10px 18px;
    animation: auth-rise .45s ease both;
}
.auth-brand-mark {
    width: 64px; height: 64px; margin: 0 auto 14px;
    border-radius: 20px;
    background: linear-gradient(145deg, #8FC4B5, #4F8578);
    color: #fff; font-size: 30px; font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 12px 28px rgba(79, 133, 120, 0.35);
    letter-spacing: -0.04em;
}
.auth-brand {
    margin: 0; font-size: 34px; font-weight: 800; letter-spacing: -0.03em;
    color: var(--text-main);
}
.auth-tagline {
    margin: 8px 0 0; color: var(--text-muted); font-size: 15px; letter-spacing: 0.02em;
}
.auth-sheet {
    flex: 1; display: flex; flex-direction: column; justify-content: flex-start;
    background: rgba(255,255,255,0.88);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-radius: 28px 28px 24px 24px;
    padding: 22px 20px 18px;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255,255,255,0.9);
    animation: auth-rise .5s ease .05s both;
}
.auth-sheet-scroll { justify-content: flex-start; }
.auth-title { margin: 4px 0 18px; font-size: 24px; font-weight: 750; }
.auth-back {
    align-self: flex-start; border: none; background: transparent;
    color: var(--text-muted); font-size: 14px; padding: 0 0 8px; cursor: pointer;
}
.auth-field { margin-bottom: 4px; }
.auth-field label {
    display: block; font-size: 13px; font-weight: 600; color: var(--text-muted);
    margin: 0 0 6px 4px;
}
.auth-field input { margin-bottom: 14px; background: #FAFAF8; }
.auth-code-row {
    display: flex; gap: 10px; align-items: flex-start;
}
.auth-code-row input { flex: 1; margin-bottom: 14px; }
.btn-code {
    width: auto; flex: 0 0 auto; margin-top: 0; padding: 14px 14px;
    white-space: nowrap; font-size: 13px; min-width: 108px;
}
.auth-links {
    display: flex; justify-content: space-between;
    margin-top: 16px; font-size: 14px; color: var(--primary-dark); font-weight: 600;
}
.auth-links span { cursor: pointer; padding: 6px 0; }
.auth-migrate {
    margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--border);
}
.auth-migrate-toggle {
    width: 100%; border: none; background: transparent; cursor: pointer;
    display: flex; justify-content: space-between; align-items: center;
    color: var(--text-muted); font-size: 14px; font-weight: 600; padding: 8px 0;
}
.auth-migrate-toggle i { transition: transform .2s ease; font-size: 12px; }
.auth-migrate-hint {
    font-size: 12px; color: var(--text-light); line-height: 1.65; margin: 0 0 12px;
}
@keyframes auth-rise {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 兼容旧 fullscreen-dialog（若有残留页面） */
.fullscreen-dialog {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-color); padding: 40px;
    display: flex; flex-direction: column; justify-content: center;
    z-index: 200;
}
.link-text {
    text-align: center; margin-top: 20px; color: #888; cursor: pointer;
}

/* 首页指标卡 */
.metric-card { text-align: center; padding: 18px 14px; }
.metric-icon { font-size: 22px; }
.metric-value {
    font-size: 34px; font-weight: 800; margin: 8px 0 4px;
    letter-spacing: -0.03em; color: var(--text-main);
}
.metric-value-sm { font-size: 26px; }
.metric-label { font-size: 12px; color: var(--text-light); }
.location-icon-wrap {
    background: #F6EDEB; padding: 12px; border-radius: 16px;
}
.location-card { cursor: pointer; }
.location-card:active { transform: scale(0.99); }

/* --- 传感器开关样式 --- */
.sensor-toggle {
    transition: all 0.25s ease;
    cursor: pointer;
    background: #F7F5F1;
    color: var(--text-muted);
    font-weight: 500;
    border: 1.5px solid transparent;
}
.sensor-toggle:active { transform: scale(0.97); }
.sensor-toggle.active {
    background-color: var(--primary-soft) !important;
    border-color: var(--primary) !important;
    color: var(--primary-dark) !important;
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(79, 133, 120, 0.15);
}

/* VIP 样式 */
.vip-badge {
    background: linear-gradient(135deg, #D4AF37, #FFE98A); color: #5a4a00;
    padding: 4px 10px; border-radius: 10px; font-size: 10px; font-weight: bold;
    vertical-align: middle; margin-left: 5px;
}
.plan-card {
    border: 2px solid #eee; border-radius: 16px; padding: 15px; margin-bottom: 10px;
    cursor: pointer; transition: 0.2s; display: flex; justify-content: space-between; align-items: center;
}
.plan-card.selected { border-color: var(--gold); background: #fffcf0; }
.payment-method { display: flex; gap: 10px; margin-top: 10px; }
.pay-icon { flex: 1; padding: 10px; border: 1px solid #eee; border-radius: 10px; text-align: center; cursor: pointer; }
.pay-icon.selected { border-color: var(--primary); background: #f0fffa; }

/* D6：同意门槛 */
.consent-block { margin: 8px 0 18px; display: flex; flex-direction: column; gap: 12px; }
.consent-item {
    display: flex; align-items: flex-start; gap: 10px;
    font-size: 13px; line-height: 1.6; color: #666;
    text-align: left; cursor: pointer;
}
.consent-item input[type="checkbox"] {
    width: 18px; height: 18px; margin: 2px 0 0; flex: 0 0 auto;
    accent-color: var(--primary-dark);
}
.consent-item a { color: var(--primary-dark); text-decoration: underline; }

/* ===== P2：轻量 UI 反馈层 ===== */
.app-toast {
    position: fixed; left: 50%; bottom: calc(120px + var(--safe-area-bottom));
    transform: translate(-50%, 16px);
    max-width: 82%; padding: 12px 18px; border-radius: 14px;
    font-size: 14px; line-height: 1.5; color: #fff; text-align: center;
    background: rgba(40, 40, 40, 0.92); box-shadow: 0 8px 24px rgba(0,0,0,.18);
    opacity: 0; pointer-events: none; z-index: 999; transition: all .25s ease;
}
.app-toast-show { opacity: 1; transform: translate(-50%, 0); }
.app-toast-err { background: rgba(198, 40, 40, 0.95); }
.app-toast-warn { background: rgba(230, 145, 30, 0.95); }

.app-modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.45);
    display: flex; align-items: center; justify-content: center;
    padding: 30px; z-index: 1000;
}
.app-modal {
    background: #fff; border-radius: 20px; padding: 24px 20px 14px;
    width: 100%; max-width: 340px; box-shadow: 0 16px 40px rgba(0,0,0,.2);
}
.app-modal-title { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.app-modal-body { font-size: 14px; color: #555; line-height: 1.7; margin-bottom: 18px; }
.app-modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.app-modal-btn { border: none; padding: 10px 18px; border-radius: 12px; font-size: 15px; background: #f0f0f0; color: #555; cursor: pointer; }
.app-modal-btn-primary { background: var(--primary); color: #fff; font-weight: 700; }
.app-modal-btn-danger { background: #ff4757; color: #fff; font-weight: 700; }

.app-btn-loading { opacity: .65; cursor: wait !important; }

.app-skeleton {
    height: 16px; border-radius: 8px; margin: 12px 0;
    background: linear-gradient(90deg, #eee 25%, #f6f6f6 50%, #eee 75%);
    background-size: 200% 100%; animation: app-shimmer 1.2s infinite;
}
@keyframes app-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.slider-row { margin: 14px 0 4px; }
.slider-row .slider-label { display: flex; justify-content: space-between; font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.slider-row .slider-value { color: var(--primary-dark); font-weight: 700; }
.slider-row input[type="range"] {
    -webkit-appearance: none; appearance: none; width: 100%; height: 6px;
    border-radius: 3px; background: #e4e0d8; padding: 0; margin: 0; border: none;
}
.slider-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none; width: 26px; height: 26px; border-radius: 50%;
    background: var(--primary); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2); cursor: pointer;
}
.slider-hint { font-size: 12px; color: #999; margin-top: 6px; line-height: 1.6; }

.guard-hero { display: flex; align-items: center; gap: 14px; }
.guard-streak-num { font-size: 34px; font-weight: 800; color: var(--primary-dark); line-height: 1; }
.guard-bars { display: flex; align-items: flex-end; gap: 6px; height: 46px; margin-top: 10px; }
.guard-bar { flex: 1; background: #e8e4db; border-radius: 4px; min-height: 4px; transition: height .3s; }
.guard-bar.on { background: var(--primary); }
.guard-bar.today { outline: 2px solid var(--primary-dark); }

.health-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid #f2f2f2; font-size: 13px; }
.health-item:last-child { border-bottom: none; }
.health-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex: 0 0 auto; background: #e74c3c; }
.health-dot.on { background: #2ecc71; }
.health-dot.optional { background: #f1c40f; }
.health-hint { color: #999; font-size: 12px; margin-top: 2px; line-height: 1.6; }
.health-score { font-size: 26px; font-weight: 800; }

/* ===== 微信式「我的 / 设置」列表 ===== */
.me-profile {
    display: flex; align-items: center; gap: 14px;
    padding: 18px 16px; margin-bottom: 12px;
}
.me-avatar {
    width: 56px; height: 56px; border-radius: 12px;
    background: linear-gradient(145deg, #8FC4B5, #4F8578);
    color: #fff; font-size: 24px; font-weight: 800;
    display: flex; align-items: center; justify-content: center;
}
.me-profile-text { flex: 1; min-width: 0; }
.me-name { font-size: 18px; font-weight: 750; }
.me-sub { font-size: 13px; color: var(--text-light); margin-top: 4px; }

.me-group {
    background: #fff; border-radius: 12px; margin-bottom: 12px;
    overflow: hidden; box-shadow: var(--shadow);
}
.me-cell {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px; background: #fff; border: none; width: 100%;
    text-align: left; color: inherit; text-decoration: none; cursor: pointer;
    border-bottom: 1px solid #f2f2f2;
}
.me-cell:last-child { border-bottom: none; }
.me-cell:active { background: #f7f7f7; }
.me-icon {
    width: 28px; height: 28px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 14px; flex: 0 0 auto;
}
.me-cell-label { flex: 1; font-size: 16px; font-weight: 500; }
.me-cell-value { font-size: 13px; color: #999; max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-chevron { color: #c7c7cc; font-size: 12px; }

.me-switch {
    width: 48px; height: 28px; border-radius: 14px; background: #e5e5ea;
    position: relative; transition: background .2s; flex: 0 0 auto;
}
.me-switch::after {
    content: ''; position: absolute; top: 2px; left: 2px;
    width: 24px; height: 24px; border-radius: 50%; background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s;
}
.me-switch.active { background: #07c160; }
.me-switch.active::after { transform: translateX(20px); }

.me-logout {
    width: 100%; margin: 8px 0 24px; padding: 14px;
    border: none; border-radius: 12px; background: #fff;
    color: #fa5151; font-size: 16px; font-weight: 600;
    box-shadow: var(--shadow); cursor: pointer;
}
.me-logout:active { background: #fff5f5; }

.settings-panel { animation: auth-rise .25s ease; }
.panel-nav {
    display: flex; align-items: center; gap: 8px;
    margin: 0 0 14px; padding-top: 4px;
}
.panel-nav h3 { margin: 0; font-size: 18px; font-weight: 750; }
.panel-back {
    border: none; background: transparent; color: var(--text-main);
    font-size: 18px; padding: 8px 10px 8px 0; cursor: pointer;
}
.hint { font-size: 12px; color: #999; line-height: 1.6; margin: 0 0 10px; }
.card h4 { margin: 0 0 8px; font-size: 15px; }
.me-chip-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.me-chip-grid .sensor-toggle {
    padding: 14px; border-radius: 10px; text-align: center;
}
