/* CSS Variables & Global Reset */
:root {
    --primary-color: #2D60FF;
    /* 充满活力的科技蓝 */
    --primary-dark: #1A4BD6;
    --success-color: #00B887;
    --background-color: #F4F6F9;
    --surface-color: #FFFFFF;
    --text-main: #1D1D1F;
    --text-secondary: #86868B;
    --border-radius-lg: 24px;
    --border-radius-md: 16px;
    --border-radius-sm: 8px;
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 8px 24px rgba(45, 96, 255, 0.12);
    --font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
    --safe-area-top: env(safe-area-inset-top, 20px);
    --safe-area-bottom: env(safe-area-inset-bottom, 20px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    /* 防止整个页面滚动，内容区滚动 */
    display: flex;
    justify-content: center;
}

#app {
    width: 100%;
    max-width: 480px;
    /* 模拟手机宽度 */
    background-color: var(--background-color);
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.05);
}

/* 状态栏 */
.status-bar {
    height: 44px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    background: transparent;
    z-index: 100;
    margin-top: 10px;
}

.status-icons i {
    margin-left: 5px;
}

/* 导航栏 */
.navbar {
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: transparent;
    z-index: 99;
}

.page-title {
    font-size: 18px;
    font-weight: 700;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-main);
    padding: 8px;
    cursor: pointer;
}

.placeholder {
    width: 40px;
}

/* 页面容器与切换动画 */
.page-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    padding: 16px;
    padding-bottom: 80px;
    /* 为底部按钮留空间 */
    overflow-y: auto;
}

.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 首页组件 */
.welcome-card {
    background: linear-gradient(135deg, #2D60FF, #5C85FF);
    color: white;
    padding: 24px;
    border-radius: var(--border-radius-lg);
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
}

.welcome-card .sub-text {
    opacity: 0.8;
    font-size: 14px;
    margin-bottom: 12px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-item {
    text-align: center;
    flex: 1;
}

.stat-item .number {
    display: block;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-item .label {
    font-size: 12px;
    opacity: 0.9;
}

.divider {
    width: 1px;
    height: 30px;
    background: rgba(255, 255, 255, 0.2);
}

.action-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.action-card {
    background: var(--surface-color);
    border: none;
    padding: 24px;
    border-radius: var(--border-radius-lg);
    text-align: left;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    cursor: pointer;
    transition: transform 0.2s;
}

.action-card:active {
    transform: scale(0.98);
}

.action-card .icon-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 16px;
}

.action-card.primary .icon-circle {
    background: rgba(45, 96, 255, 0.1);
    color: var(--primary-color);
}

.action-card.secondary .icon-circle {
    background: rgba(0, 184, 135, 0.1);
    color: var(--success-color);
}

.action-card h2 {
    font-size: 18px;
    margin-bottom: 6px;
    color: var(--text-main);
}

.action-card p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* 扫描区域 */
.scan-area {
    background: #000;
    border-radius: var(--border-radius-md);
    height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.scan-frame {
    width: 160px;
    height: 160px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    position: relative;
    margin-bottom: 12px;
}

.scan-frame.success-color {
    border-color: var(--success-color);
}

.scan-line {
    width: 100%;
    height: 2px;
    background: var(--primary-color);
    box-shadow: 0 0 8px var(--primary-color);
    position: absolute;
    top: 0;
    animation: scanMove 2s infinite linear;
}

@keyframes scanMove {
    0% {
        top: 10%;
        opacity: 0;
    }

    20% {
        opacity: 1;
    }

    80% {
        opacity: 1;
    }

    100% {
        top: 90%;
        opacity: 0;
    }
}

/* 列表组件 */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.text-btn {
    background: none;
    border: none;
    font-size: 13px;
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 12px;
    /* Pill shape */
    cursor: pointer;
    transition: all 0.2s;
    background-color: #f0f0f0;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.text-btn:hover {
    background-color: #e5e5e5;
    color: var(--text-main);
}

.text-btn:active {
    transform: scale(0.95);
}

.section-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.badge {
    background: var(--primary-color);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    vertical-align: middle;
}

.item-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 120px;
    /* 防止被底部面板遮挡 */
}

.list-item {
    background: var(--surface-color);
    padding: 16px;
    border-radius: var(--border-radius-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.item-info h4 {
    font-size: 15px;
    margin-bottom: 4px;
}

.item-info .code {
    font-size: 12px;
    color: var(--text-secondary);
    font-family: monospace;
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
}

.delete-btn {
    color: #FF4757;
    background: none;
    border: none;
    padding: 8px;
}

/* 底部操作面板 */
.bottom-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface-color);
    padding: 20px;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
}

.input-group {
    margin-bottom: 16px;
}

.input-row {
    display: flex;
    align-items: center;
    background: var(--background-color);
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 10px;
}

.input-row i {
    color: var(--text-secondary);
    margin-right: 10px;
    font-size: 18px;
}

.input-row input {
    border: none;
    background: none;
    outline: none;
    flex: 1;
    font-size: 15px;
    min-width: 0;
    /* Fix flex child shrinking */
    font-family: var(--font-family);
}

.label-text {
    font-size: 14px;
    color: var(--text-secondary);
    margin-right: 8px;
    white-space: nowrap;
}

.input-tips {
    font-size: 12px;
    color: var(--text-secondary);
    margin: -4px 0 12px 14px;
    /* Pull up closer to input above, push down next element */
    opacity: 0.8;
}

/* 自动完成/模糊搜索组件 */
.autocomplete-wrapper {
    position: relative;
    flex: 1;
}

.suggestions-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-md);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    margin-top: 4px;
    display: none;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.suggestions-dropdown.show {
    display: block;
}

.suggestion-item {
    padding: 12px 16px;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-main);
    transition: background 0.2s;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover,
.suggestion-item.active {
    background-color: #f0f7ff;
    color: var(--primary-color);
}

.suggestion-item .match {
    font-weight: bold;
    color: var(--primary-color);
}

/* 清单页 */
.receipt-card {
    background: var(--surface-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 30px 20px;
    text-align: center;
    position: relative;
    /* Sawtooth border effect simulation could be complex, keeping simple for now */
}

.receipt-header {
    margin-bottom: 24px;
}

.success-icon {
    font-size: 48px;
    color: var(--success-color);
    margin-bottom: 8px;
}

.qrcode-wrapper {
    background: var(--background-color);
    padding: 20px;
    border-radius: 16px;
    display: inline-block;
    margin-bottom: 24px;
}

#qrcode-container img {
    margin: 0 auto;
}

.code-text {
    margin-top: 10px;
    font-family: monospace;
    font-size: 14px;
    color: var(--text-secondary);
    letter-spacing: 1px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 14px;
}

.detail-row .label {
    color: var(--text-secondary);
}

.divider-dashed {
    height: 1px;
    border-top: 1px dashed #ddd;
    margin: 20px 0;
}

.floating-actions {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 16px;
    width: 90%;
    max-width: 440px;
}

/* Tab 切换 */
.tab-control {
    display: flex;
    background: #e9ecef;
    padding: 4px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: none;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: 8px;
    transition: all 0.2s;
}

.tab-btn.active {
    background: white;
    color: var(--text-main);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.return-content {
    display: none;
}

.return-content.active {
    display: block;
}

/* 按钮通用 */
.btn-primary,
.btn-block {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 14px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
}

.btn-block {
    width: 100%;
}

.btn-secondary {
    background: white;
    color: var(--text-main);
    border: 1px solid #ddd;
    padding: 14px;
    border-radius: 14px;
    font-weight: 600;
    font-size: 16px;
    flex: 1;
    cursor: pointer;
}

.btn-primary:active,
.btn-block:active {
    background: var(--primary-dark);
}

/* 弹窗 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.modal-overlay.visible {
    display: flex;
    opacity: 1;
}

.modal {
    background: white;
    width: 85%;
    max-width: 320px;
    border-radius: 20px;
    padding: 20px;
    transform: scale(0.9);
    transition: transform 0.3s;
}

.modal-overlay.visible .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-body {
    margin-bottom: 24px;
}

.summary-box {
    background: var(--background-color);
    padding: 16px;
    border-radius: 12px;
    margin-top: 12px;
}

.summary-box .row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}

.mini-list {
    margin-top: 10px;
    padding-left: 10px;
    font-size: 12px;
    color: var(--text-secondary);
    max-height: 100px;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    gap: 12px;
}

.modal-footer button {
    flex: 1;
    padding: 12px;
    font-size: 14px;
}

/* 搜索框 */
.search-bar {
    display: flex;
    align-items: center;
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
}

.search-bar i {
    margin-right: 10px;
    color: var(--text-secondary);
}

.search-bar input {
    border: none;
    outline: none;
    width: 100%;
    font-size: 16px;
}

/* 贷款列表项 */
.loan-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.loan-card .info h4 {
    font-size: 16px;
    margin-bottom: 4px;
}

.loan-card .info p {
    font-size: 12px;
    color: var(--text-secondary);
}

.status-tag {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    background: #e3f2fd;
    color: #2196f3;
}

/* Toast */
.toast {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s;
    z-index: 300;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Glass effect placeholder removed */