:root {
    --primary-color: #415F91;
    --primary-container: #D6E3FF;
    --on-primary-container: #274777;
    --surface-color: #F9F9FF;
    --surface-container: #EDEDF4;
    --surface-container-highest: #E1E2EC;
    --on-surface-color: #191C20;
    --on-surface-variant: #44474E;
    --outline-color: #C4C6D0;
    --profit-color: #D32F2F;
    --loss-color: #2E7D32;
    --elevation-1: 0px 1px 2px 0px rgba(0, 0, 0, 0.15);
    --elevation-2: 0px 2px 6px 2px rgba(0, 0, 0, 0.15);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--surface-color);
    color: var(--on-surface-color);
    margin: 0;
    padding: 16px;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.header {
    text-align: center;
    padding: 8px;
    background: var(--primary-color);
    color: white;
    border-radius: 8px;
    margin-bottom: 12px;
}

h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 0px;
}

.stats-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 12px;
}

.stat-card {
    background-color: var(--surface-container);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.stat-card h3 {
    font-size: 16px;
    font-weight: 500;
    color: var(--on-surface-variant);
    margin: 0 0 8px 0;
}

.stat-card .value {
    font-size: 24px;
    font-weight: 700;
}

.controls-panel {
    background-color: var(--surface-container);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 16px;
}

.search-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-input {
    padding: 10px 14px;
    border: 1px solid var(--outline-color);
    border-radius: 8px;
    background-color: var(--surface-color);
    width: 250px;
}

.total-info {
    color: var(--on-surface-variant);
    font-weight: 500;
}

.sort-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.sort-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background-color: #E1E2EC;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.3s;
    user-select: none;
}

.sort-chip:hover {
    background-color: #D8DAE4;
}

.sort-chip.active {
    background-color: var(--primary-container);
    color: var(--on-primary-container);
}

.sort-chip.active .chip-icon,
.sort-chip.active .sort-direction-icon {
    color: var(--primary-color);
}

.chip-text {
    font-size: 14px;
    font-weight: 500;
}

.sort-direction-icon {
    font-size: 20px;
    color: var(--on-surface-variant);
    transition: color 0.3s, transform 0.3s;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 12px;
    min-height: 300px;
}

.product-card {
    background-color: var(--surface-container);
    border-radius: 8px;
    padding: 16px;
    transition: transform 0.3s, box-shadow 0.3s;
    box-shadow: var(--elevation-1);
}

.product-card:hover {
    box-shadow: var(--elevation-2);
    transform: translateY(-3px);
}

.product-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--outline-color);
}

.product-info {
    display: flex;
    align-items: stretch;
    gap: 12px;
}

.product-thumb {
    width: 48px;
    height: auto;
    min-height: 48px;
    border-radius: 6px;
    object-fit: cover;
    align-self: stretch;
}

.product-name-section {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex: 1;
    min-height: 48px;
}

.product-name {
    font-size: 20px;
    font-weight: 600;
    line-height: 1.2;
}

.product-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.tag {
    font-size: 11px;
    padding: 2px 6px;
    background-color: var(--primary-container);
    color: var(--on-primary-container);
    border-radius: 6px;
    font-weight: 500;
    white-space: nowrap;
}

.current-price {
    font-size: 16px;
    padding: 6px 12px;
    border-radius: 8px;
    background-color: var(--primary-container);
    color: var(--on-primary-container);
    font-weight: 600;
    flex-shrink: 0;
}

.product-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
    margin-bottom: 16px;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}

.detail-label {
    color: var(--on-surface-variant);
}

.detail-value {
    font-weight: 600;
}

.profit {
    color: var(--profit-color);
}

.loss {
    color: var(--loss-color);
}

.chart-container {
    height: 180px;
    margin-top: 16px;
    background-color: var(--surface-container-highest);
    border-radius: 12px;
    padding: 8px;
}

.loading-more,
.no-more-data,
.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: var(--on-surface-variant);
    font-size: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.spinner {
    border: 3px solid var(--outline-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
    margin-right: 12px;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

.last-updated {
    text-align: center;
    color: var(--on-surface-variant);
    margin-top: 24px;
    font-size: 12px;
}

/* FAB 样式 */
.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    background-color: var(--primary-color);
    border: none;
    border-radius: 50%;
    box-shadow: var(--elevation-2);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0px 4px 12px 4px rgba(0, 0, 0, 0.25);
}

.fab:active {
    transform: scale(0.95);
}

.fab-icon {
    color: white;
    font-size: 24px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.fab.rotate .fab-icon {
    transform: rotate(180deg);
}

/* 响应式调整 */
@media (max-width: 768px) {
    .fab {
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
    }

    .fab-icon {
        font-size: 20px;
    }
}

/* FAB 动画效果 */
@keyframes fabBounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0) scale(1);
    }

    40% {
        transform: translateY(-4px) scale(1.05);
    }

    60% {
        transform: translateY(-2px) scale(1.02);
    }
}

.fab.bounce {
    animation: fabBounce 0.6s ease-in-out;
}