:root {
    --primary: #dc2626;
    --primary-dark: #991b1b;
    --bg-main: #f4f7fa;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #f1f5f9;
    --up-color: #ef4444;
    --down-color: #10b981;
    --card-bg: rgba(255, 255, 255, 0.94);
    /* Unified Numeric Font */
    --font-num: 'Inter', 'SF Pro Display', -apple-system, sans-serif;
}

/* Base utilities to replace tailwind */
.bg-white {
    background-color: #ffffff;
}

.bg-gray-50 {
    background-color: #f8fafc;
}

.text-gray-400 {
    color: #94a3b8;
}

.text-blue-500 {
    color: #3b82f6;
}

.px-4 {
    padding-left: 16px;
    padding-right: 16px;
}

.py-2 {
    padding-top: 8px;
    padding-bottom: 8px;
}

.mt-1 {
    margin-top: 4px;
}

.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.space-x-3>*+* {
    margin-left: 12px;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* Atmospheric Headers & Cards */
.account-card {
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
    color: #fff;
    margin: 16px 12px;
    border-radius: 24px;
    padding: 24px 20px;
    box-shadow: 0 12px 24px -8px rgba(185, 28, 28, 0.4);
    position: relative;
    overflow: hidden;
}

.account-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0) 70%);
    border-radius: 50%;
    pointer-events: none;
}

.account-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.account-value {
    font-size: 34px;
    font-weight: 800;
    margin-top: 4px;
    font-family: var(--font-num);
    letter-spacing: -0.5px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 12px;
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    margin-top: 2px;
    font-family: var(--font-num);
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

body {
    background: var(--bg-main);
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    color: var(--text-main);
    line-height: 1.5;
}

.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

/* --- Components --- */
.top-actions-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 8px 16px;
    background: #fff;
    flex-shrink: 0;
}

.action-btns {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-btn {
    padding: 8px;
    background: #f8fafc;
    border-radius: 100px;
    color: #94a3b8;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:active {
    background: #f1f5f9;
    scale: 0.95;
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

/* Minimal Tabs */
.ths-tabs {
    display: flex;
    background: #fff;
    padding: 0 16px;
    border-bottom: 1px solid #f1f5f9;
    align-items: center;
    position: relative;
    flex-shrink: 0;
    justify-content: space-around;
    height: 48px;
}

.ths-tab {
    font-size: 16px;
    color: #64748b;
    position: relative;
    flex: 1;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent;
    padding: 12px 0;
    border: none;
}

/* Vertical divider between tabs */
.ths-tab:not(:last-child)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 14px;
    width: 1px;
    background: #e2e8f0;
}

.ths-tab.active {
    color: var(--primary);
    font-weight: 600;
}

/* Bottom indicator for active tab */
.ths-tab.active::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    border-radius: 3px;
    background: var(--primary);
}

.ths-tab .count {
    font-size: 12px;
    color: inherit;
    opacity: 0.6;
    margin-left: 4px;
    font-family: var(--font-num);
}

/* Dashboard Header Widgets */
.dashboard-group {
    background: #fff;
    margin: 0;
    padding: 16px;
    border-radius: 0;
    box-shadow: none;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
    position: relative;
    z-index: 5;
}

.index-widget {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 16px;
}

/* Replaced by refined definition above */

.index-item {
    flex: 1;
    padding: 12px 8px;
    border-radius: 12px;
    text-align: center;
    transition: transform 0.2s;
}

.index-item:active {
    scale: 0.96;
}

.index-item.up {
    background: #fef2f2;
    border: 1px solid #fee2e2;
}

.index-item.down {
    background: #f0fdf4;
    border: 1px solid #dcfce7;
}

.index-name {
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    margin-bottom: 4px;
}

.index-val {
    font-size: 16px;
    font-weight: 800;
    font-family: var(--font-num);
}

.index-pct {
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-num);
}

.hot-section-row {
    display: flex;
    gap: 12px;
    margin-top: 4px;
}

.hot-card {
    flex: 1;
    padding: 10px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px solid #f1f5f9;
}

.hot-card-title {
    font-size: 10px;
    color: #94a3b8;
    font-weight: 600;
    margin-bottom: 4px;
}

.hot-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.hot-name {
    font-size: 12px;
    font-weight: 600;
    color: #334155;
}

.hot-val {
    font-size: 12px;
    font-weight: 700;
    color: var(--up-color);
    font-family: var(--font-num);
}


/* Stock Item UI is now in list.css */


/* --- Loading Animation (Redesigned) --- */
#app-loading {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.flight-container {
    position: relative;
    width: 300px;
    height: 120px;
    margin-bottom: 20px;
}

.airplane-wrapper {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    animation: flightPath 3s linear infinite;
}

@keyframes flightPath {
    0% {
        left: -10px;
        transform: translateY(-50%) rotate(0deg);
    }

    10% {
        transform: translateY(-70%) rotate(-5deg);
    }

    30% {
        transform: translateY(-50%) rotate(0deg);
    }

    50% {
        transform: translateY(-30%) rotate(5deg);
    }

    70% {
        transform: translateY(-50%) rotate(0deg);
    }

    100% {
        left: 260px;
        transform: translateY(-50%) rotate(0deg);
    }
}

.progress-container {
    width: 240px;
    text-align: center;
}

.progress-track {
    height: 4px;
    background: #f1f5f9;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #e74c3c, #f59e0b);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.loading-text {
    font-size: 13px;
    color: #94a3b8;
    height: 20px;
}

/* --- Layout --- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: #fff;
    border-top: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    z-index: 1000;
    box-sizing: content-box;
    padding-bottom: 20px; /* 默认底部安全区间距 */
}

/* PWA standalone模式下额外增加底部间距 */
@media all and (display-mode: standalone) {
    .bottom-nav {
        padding-bottom: max(20px, env(safe-area-inset-bottom, 20px));
    }
}

/* 支持safe-area时使用系统值 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .bottom-nav {
        padding-bottom: max(16px, env(safe-area-inset-bottom, 16px));
    }
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 11px;
    background: none;
    border: none;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item svg {
    width: 22px;
    height: 22px;
    margin-bottom: 2px;
}

.page {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 76px; /* 56px nav + 20px safe area */
    background: var(--bg-main);
    overflow: hidden;
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .page {
        bottom: calc(56px + max(16px, env(safe-area-inset-bottom, 16px)));
    }
}

.page.active {
    display: flex;
    flex-direction: column;
}

.page-header {
    flex-shrink: 0;
    background: #fff;
}

.page-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Swiping */
.swipe-wrapper {
    position: relative;
    overflow: hidden;
}

.swipe-content {
    position: relative;
    background: #fff;
    z-index: 10;
    cursor: pointer;
}

.swipe-actions {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    display: flex;
    z-index: 1;
}

.swipe-btn {
    width: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
}

/* Modals moved to components/modal.css */

/* Spinner for drawer loading */
@keyframes spin {
    to { transform: rotate(360deg); }
}