:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --gray-50: #111827;
        --gray-100: #1f2937;
        --gray-200: #374151;
        --gray-500: #9ca3af;
        --gray-900: #f9fafb;
        --f8fafc: #0f172a;
    }
    body { background: #0f172a; color: #f1f5f9; }
    .navbar, .tabbar, .card, .quick-item, .order-card, .form-control, .form-select {
        background-color: #1e293b !important;
        border-color: #334155 !important;
        color: #f1f5f9 !important;
    }
    .bg-light { background-color: #334155 !important; }
    .text-muted { color: #94a3b8 !important; }
    .text-dark { color: #f1f5f9 !important; }
}

body {
    background: #f8fafc;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--gray-900);
    font-size: 15px;
    padding-bottom: calc(85px + var(--safe-bottom));
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.01em;
}

.page-with-nav { padding-top: 64px; min-height: 100vh; }
.page-full { min-height: 100vh; }

/* Navbar Refinement */
.navbar {
    background: rgba(255, 255, 255, 0.8) !important;
    backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--gray-200);
    height: 60px;
}
.navbar-brand {
    color: var(--primary) !important;
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: -0.02em;
}

/* Tabbar Refinement */
.tabbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--gray-200);
    padding-bottom: var(--safe-bottom);
    z-index: 1000;
    height: calc(65px + var(--safe-bottom));
}
.tabbar a {
    flex: 1;
    text-align: center;
    color: var(--gray-500);
    text-decoration: none;
    font-size: 10px;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}
.tabbar a i { font-size: 22px; margin-bottom: 4px; transition: transform 0.2s; }
.tabbar a.active { color: var(--primary); }
.tabbar a.active i { transform: translateY(-2px); }
.tabbar a.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 3px 3px;
}

/* Cards & Grid */
.card-stat {
    border: none;
    border-radius: var(--radius-lg);
    background: #fff;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.quick-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
.quick-item {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 20px 12px;
    text-align: center;
    text-decoration: none;
    color: var(--gray-900);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.quick-item:active { transform: scale(0.95); background: var(--gray-50); }
.quick-item .quick-label {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
}
.quick-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    flex-shrink: 0;
}
.quick-icon i {
    font-size: 24px;
    line-height: 1;
    display: inline-block;
}
.quick-icon--primary { background: var(--primary-light); color: var(--primary); }
.quick-icon--muted { background: var(--gray-100); color: var(--gray-600); }
.quick-icon--info { background: #eff6ff; color: #2563eb; }
.quick-icon--warn { background: #fffbeb; color: #d97706; }
.quick-icon--claim { background: #f5f3ff; color: var(--primary); }

/* 统计页顶部主菜单 */
.stats-main-menu {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.stats-menu-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 8px;
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-100);
    text-decoration: none;
    color: var(--gray-900);
    transition: transform 0.2s, box-shadow 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.stats-menu-item:active {
    transform: scale(0.96);
    box-shadow: none;
}
.stats-menu-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    font-size: 20px;
}
.stats-menu-icon--primary { background: var(--primary-light); color: var(--primary); }
.stats-menu-icon--info { background: #eff6ff; color: #2563eb; }
.icon-racket {
    width: 22px;
    height: 22px;
    display: block;
}
.stats-menu-icon--muted { background: var(--gray-100); color: var(--gray-600); }
.stats-menu-label {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
}
.stats-menu-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    color: #fff;
    background: var(--primary);
    border-radius: 10px;
    border: 2px solid #fff;
}

.badge-count {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 700;
    border: 2px solid #fff;
}

/* Order List */
.order-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 0;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-100);
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: hidden;
}
.order-card:active { transform: scale(0.99); }
.order-card__inner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
}
.order-card__check { flex-shrink: 0; padding-top: 4px; }
.order-card__main {
    flex: 1;
    min-width: 0;
    cursor: pointer;
}
.order-card__top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}
.order-card__head { flex: 1; min-width: 0; }
.order-card__name {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.3;
    margin-bottom: 4px;
    letter-spacing: -0.02em;
}
.order-card__meta {
    font-size: 13px;
    color: var(--gray-500);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.order-card__amount {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
    flex-shrink: 0;
}
.order-card__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.tag-paid {
    background: #ecfdf5;
    color: #059669;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
}
.tag-unpaid {
    background: var(--gray-100);
    color: var(--gray-500);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
}
.racket-thumb--empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-400);
    font-size: 1.5rem;
}

/* 筛选条 */
.filter-bar {
    position: sticky;
    top: 60px;
    z-index: 100;
    background: linear-gradient(180deg, #f8fafc 85%, transparent);
    padding: 8px 0 12px;
    margin: 0 -12px 12px;
    padding-left: 12px;
    padding-right: 12px;
}
.filter-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
}
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tabs .filter-pill {
    flex-shrink: 0;
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    background: #fff;
    color: var(--gray-600);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
}
.filter-tabs .filter-pill.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}
.page-header-title { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.02em; }
.page-header-sub { font-size: 13px; color: var(--gray-500); }

.status-badge {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
.bg-status-1 { background: var(--gray-100); color: var(--gray-600); }
.bg-status-2 { background: #eff6ff; color: #2563eb; }
.bg-status-3 { background: #fffbeb; color: #d97706; }
.bg-status-4 { background: #f5f3ff; color: #4f46e5; }
.bg-status-5 { background: #ecfdf5; color: #059669; }

.racket-thumb {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius-md);
    background: var(--gray-100);
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.05);
}

/* Forms Refinement */
.form-control, .form-select {
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-200);
    padding: 12px 16px;
    font-size: 15px;
    transition: all 0.2s;
    background-color: #fff;
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.btn {
    border-radius: var(--radius-md);
    padding: 10px 20px;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.btn-primary,
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active,
.btn-primary:disabled {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.35);
}
.btn-primary:active { transform: scale(0.96); box-shadow: none !important; }
.btn-touch { min-height: 52px; }

/* 分段切换（收单页 Tab / 支付状态） */
.segment-tabs,
.segment-pay {
    background: var(--gray-100);
    padding: 4px;
    border-radius: var(--radius-md);
    gap: 4px;
}
.segment-tabs .nav-link,
.segment-pay label {
    border-radius: 10px !important;
    color: var(--gray-600);
    font-weight: 600;
    font-size: 14px;
    border: none !important;
    margin: 0;
}
.segment-tabs .nav-link.active {
    background: var(--primary) !important;
    color: #fff !important;
    box-shadow: var(--shadow-sm);
}
.segment-pay .btn-check:checked + label {
    background: var(--primary) !important;
    color: #fff !important;
    box-shadow: var(--shadow-sm);
}
.segment-pay label {
    background: transparent;
}
.hint-found {
    background: var(--primary-light) !important;
    color: var(--primary) !important;
    border: 1px solid rgba(79, 70, 229, 0.15) !important;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}
@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}
.empty-state i {
    font-size: 64px;
    color: var(--gray-300);
    display: block;
    margin-bottom: 16px;
}
.empty-state h6 { color: var(--gray-900); font-weight: 700; margin-bottom: 8px; }
.empty-state p { color: var(--gray-500); font-size: 14px; }

/* Timeline */
.timeline { position: relative; }
.timeline::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--gray-200);
}
.timeline-item {
    position: relative;
    padding-left: 28px;
    margin-bottom: 24px;
}
.timeline-dot {
    position: absolute;
    left: 0;
    top: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--gray-300);
    border: 2px solid #fff;
    z-index: 1;
}
.timeline-item.active .timeline-dot {
    background: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
}

/* Batch Bar */
.batch-bar {
    position: fixed;
    bottom: calc(75px + var(--safe-bottom));
    left: 12px;
    right: 12px;
    background: var(--gray-900);
    padding: 10px;
    border-radius: var(--radius-lg);
    display: none;
    z-index: 999;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.batch-bar.show {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    animation: slide-up 0.3s ease-out;
}
.batch-btn {
    white-space: nowrap;
    border: none;
    border-radius: var(--radius-md);
    padding: 12px 4px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    color: #fff;
    text-align: center;
    transition: transform 0.15s, opacity 0.15s;
}
.batch-btn:active {
    transform: scale(0.96);
    opacity: 0.9;
}
.batch-btn--info { background: #3b82f6; }
.batch-btn--warn { background: #f59e0b; }
.batch-btn--primary { background: var(--primary); }
.batch-btn--success { background: var(--success); }
@keyframes slide-up {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Animations */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.spinning i, .spinning {
    display: inline-block;
    animation: spin 1s linear infinite;
}

.z-1 { z-index: 1; }

.bg-warning-light { background-color: #fffbeb !important; }
.bg-success-light { background-color: #ecfdf5 !important; }
.bg-danger-light { background-color: #fef2f2 !important; }
.bg-info-light { background-color: #eff6ff !important; }

/* 图片全屏预览 */
.image-preview-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 16px 24px;
    animation: fade-in 0.2s ease-out;
}
.image-preview-overlay .image-preview-img {
    max-width: 100%;
    max-height: calc(100vh - 100px);
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
.image-preview-close {
    position: absolute;
    top: calc(12px + env(safe-area-inset-top, 0px));
    right: 16px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.image-preview-hint {
    margin-top: 16px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}
@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.order-photo-wrap {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.order-photo-thumb {
    max-height: 280px;
    object-fit: cover;
    display: block;
}
.order-photo-zoom {
    position: absolute;
    right: 12px;
    bottom: 12px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
}

.extra-small { font-size: 11px; }
.bg-primary-light { background-color: var(--primary-light); }
