:root {
    --primary-color: #3167FF;
    --primary-light: #5a85ff;
    --success-color: #28a745;
    --warning-color: #fd7e14;
    --danger-color: #dc3545;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --border-color: #e9ecef;
    --text-primary: #1a1a1a;
    --text-secondary: #4a4a4a;
    --text-muted: #6c757d;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --radius: 12px;
    --radius-sm: 8px;
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
}

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

html {
    font-size: 16px;
}

body {
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8f0 100%);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    color: var(--text-primary);
    line-height: 1.4;
    padding: 8px;
    padding-bottom: calc(8px + var(--safe-area-inset-bottom));
    -webkit-user-select: none;
    user-select: none;
    min-height: 100vh;
}

/* 紧凑头部样式 */
.compact-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    margin-bottom: 8px;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px 16px;
}

.compact-header .header-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.compact-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.group-select {
    font-size: 0.75rem;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--text-primary);
    min-width: 80px;
}

.compact-btn {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 32px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.compact-btn:active {
    background: var(--light-color);
    transform: scale(0.95);
}

/* 表格容器 - 优化高度 */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-family: inherit;
    table-layout: fixed;
}

thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

/* 压缩表格行高 */
th {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    padding: 8px 4px;
    font-size: 0.7rem;
    font-weight: 600;
    color: white;
    text-align: center;
    border-bottom: 2px solid rgba(255,255,255,0.2);
    position: relative;
}

td {
    padding: 10px 4px;
    text-align: center;
    font-size: 0.75rem;
    border-bottom: 1px solid #f0f0f0;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

/* 压缩行高后的单元格样式 */
.bank-cell {
    font-weight: 700;
    color: var(--text-primary);
}

.data-cell {
    font-weight: 600;
    color: var(--text-primary);
}

.status-cell {
    font-weight: 600;
}

.action-cell {
    padding: 6px 2px !important;
}

/* 行样式优化 */
tr {
    transition: transform 0.2s ease, background-color 0.2s ease;
    height: 44px;
}

tr:nth-child(even) {
    background-color: #fafbfc;
}

tr:nth-child(odd) {
    background-color: white;
}

tr:active {
    background-color: #f0f4ff;
}

.paid-row {
    background-color: #f8fff9 !important;
    opacity: 0.8;
}

.urgent-row {
    background-color: #fff5f5 !important;
}

/* 银行名称 */
.bank-name {
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
    font-size: 0.75rem;
}

/* 状态标签 */
.status-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 600;
    min-width: 32px;
}

.status-badge.paid {
    color: var(--success-color);
    background: rgba(40, 167, 69, 0.1);
}

.status-badge.urgent {
    color: var(--danger-color);
    background: rgba(220, 53, 69, 0.1);
}

.status-badge.warning {
    color: var(--warning-color);
    background: rgba(253, 126, 20, 0.1);
}

.status-badge.normal {
    color: var(--success-color);
    background: rgba(40, 167, 69, 0.1);
}

.overdue-text {
    color: var(--danger-color);
    font-weight: 700;
    font-size: 0.7rem;
}

/* 操作按钮 - 压缩尺寸 */
.action-btns {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.btn {
    padding: 4px 8px;
    border: none;
    border-radius: 6px;
    font-size: 0.65rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    font-weight: 600;
    min-width: 32px;
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-small {
    padding: 3px 6px;
    font-size: 0.6rem;
    min-width: 28px;
    min-height: 24px;
}

.btn:active {
    transform: scale(0.95);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-secondary {
    background: var(--dark-color);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--dark-color);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

/* 设置面板 */
.settings-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: var(--radius) var(--radius) 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    z-index: 1000;
    max-height: 80vh;
    overflow-y: auto;
}

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

.settings-header h3 {
    font-size: 1.125rem;
    color: var(--text-primary);
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-content {
    padding: 16px;
}

/* 用户信息区域 */
.user-info-section {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 12px;
    background: var(--light-color);
    border-radius: var(--radius);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1rem;
}

.user-details {
    flex: 1;
}

.user-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.user-stats {
    display: flex;
    gap: 8px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.logout-btn {
    background: transparent;
    border: 1px solid var(--danger-color);
    color: var(--danger-color);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 600;
}

/* 快捷操作网格 */
.quick-actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 20px;
}

.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.75rem;
    color: var(--text-primary);
}

.quick-action-btn:active {
    background: var(--light-color);
    transform: scale(0.98);
}

.quick-action-btn.primary {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.action-icon {
    font-size: 1.125rem;
}

/* 手势操作提示 */
.gesture-hints {
    margin-bottom: 20px;
}

.gesture-hints h4 {
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.gesture-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.gesture-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--light-color);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
}

.gesture-icon {
    font-weight: 600;
    color: var(--primary-color);
}

/* 危险操作区域 */
.danger-section h4 {
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.danger-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.danger-btn {
    padding: 10px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.danger-btn:active {
    transform: scale(0.98);
}

/* 隐藏卡片区域 */
.hidden-section {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 8px;
    overflow: hidden;
}

.hidden-header {
    padding: 12px;
    background: var(--light-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.hidden-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.hidden-table {
    width: 100%;
    border-collapse: collapse;
}

.hidden-table td {
    padding: 8px 4px;
    font-size: 0.75rem;
}

/* 空状态 */
.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state p {
    margin-bottom: 8px;
    font-size: 0.8rem;
}

/* 提示信息 */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 0.8rem;
    z-index: 1002;
    animation: fadeInOut 3s ease;
    max-width: 80%;
    text-align: center;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
    10% { opacity: 1; transform: translateX(-50%) translateY(0); }
    90% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* 表单样式 */
.form-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 16px;
    backdrop-filter: blur(4px);
}

.form-container {
    background: white;
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
    position: relative;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-header {
    padding: 16px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
    border-radius: var(--radius) var(--radius) 0 0;
    position: relative;
}

.form-close-btn {
    position: absolute;
    right: 12px;
    top: 12px;
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.125rem;
    transition: all 0.2s ease;
}

.form-close-btn:active {
    background: rgba(255,255,255,0.3);
    transform: scale(0.9);
}

.form-body {
    padding: 16px;
}

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.8rem;
}

.form-input, .form-select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-family: inherit;
    transition: all 0.2s ease;
    background: white;
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(49, 103, 255, 0.1);
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.form-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.form-btn.cancel {
    background: var(--light-color);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.form-btn.submit {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
}

.form-btn:active {
    transform: scale(0.98);
}

.remember-me {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 16px 0;
}

.form-checkbox {
    width: 16px;
    height: 16px;
}

.remember-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* 卡片详情样式 */
.card-detail-section {
    margin-bottom: 20px;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.detail-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

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

.note-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.note-section h4 {
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.encrypted-note {
    color: var(--text-muted);
    font-style: italic;
}

.password-input {
    font-family: monospace;
    letter-spacing: 2px;
}

.note-value {
    font-family: monospace;
    background: #f5f5f5;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
}

.repayment-history {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.repayment-history h4 {
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.history-item {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 0.75rem;
}

.history-item:not(:last-child) {
    border-bottom: 1px solid #f0f0f0;
}

/* 手势确认提示 */
.swipe-confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 16px;
}

.swipe-confirm {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    max-width: 300px;
    width: 100%;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.swipe-confirm h4 {
    margin-bottom: 10px;
    color: var(--text-primary);
}

.swipe-confirm p {
    margin-bottom: 20px;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.swipe-confirm-btns {
    display: flex;
    gap: 10px;
}

.swipe-confirm-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.swipe-confirm-cancel {
    background: var(--light-color);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.swipe-confirm-ok {
    background: var(--success-color);
    color: white;
}

/* 安装提示 */
.install-prompt {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 12px;
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 2000;
    max-width: 90%;
    animation: slideUp 0.3s ease;
}

.install-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    font-weight: 600;
}

.install-close {
    background: transparent;
    border: none;
    font-size: 1.125rem;
    cursor: pointer;
    color: var(--text-muted);
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.install-close:active {
    background: #f0f0f0;
}

/* 手势操作视觉反馈 */
tr.swipe-left {
    transform: translateX(-50px);
    background-color: rgba(40, 167, 69, 0.1) !important;
}

tr.swipe-right {
    transform: translateX(50px);
    background-color: rgba(49, 103, 255, 0.1) !important;
}

tr.long-press {
    background-color: rgba(253, 126, 20, 0.1) !important;
    transform: scale(0.98);
}

/* 自定义滚动条 */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 响应式设计 */
@media (max-width: 340px) {
    html {
        font-size: 14px;
    }
    
    .compact-header {
        padding: 8px 12px;
    }
    
    .compact-header .header-title {
        font-size: 1.125rem;
    }
    
    .group-select {
        min-width: 70px;
        font-size: 0.7rem;
        padding: 4px 8px;
    }
    
    .compact-btn {
        min-width: 28px;
        min-height: 28px;
        padding: 4px;
    }
    
    .table-container {
        max-height: calc(100vh - 110px);
    }
    
    .quick-actions-grid {
        grid-template-columns: 1fr;
    }
}

/* 平板适配 */
@media (min-width: 768px) {
    body {
        padding: 16px;
        padding-bottom: calc(16px + var(--safe-area-inset-bottom));
        max-width: 600px;
        margin: 0 auto;
    }
    
    .table-container {
        max-height: calc(100vh - 140px);
    }
    
    .form-container {
        max-width: 500px;
    }
}

/* 桌面适配 */
@media (min-width: 1024px) {
    body {
        max-width: 800px;
        padding: 20px;
        padding-bottom: calc(20px + var(--safe-area-inset-bottom));
    }
    
    .table-container {
        max-height: 75vh;
    }
}

/* 移除原有的头部和统计信息样式 */
.header-controls,
.stats-filters,
.network-status {
    display: none;
}