/* --- 通用和桌面样式 --- */
:root {
    --primary-color: #3498db;
    --up-color: #e74c3c;
    --down-color: #2ecc71;
    --neutral-color: #34495e;
    --light-gray: #f4f6f8;
    --border-color: #e0e0e0;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
}

body {
    margin: 0;
    padding: 15px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    font-size: 14px; 
    background-color: var(--light-gray); 
    color: var(--neutral-color);
    line-height: 1.6;
}

.container {
    max-width: 1200px; 
    margin: 0 auto; 
    background-color: #fff; 
    padding: 25px; 
    border-radius: 12px; 
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
}

h1 { 
    text-align: center; 
    color: var(--neutral-color); 
    margin-top: 0; 
    margin-bottom: 30px;
    font-size: 2.2em;
    font-weight: 700;
}

.controls {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 20px;
    align-items: end;
    margin-bottom: 25px;
    padding: 20px;
    background-color: #f9f9f9;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.input-group { display: flex; flex-direction: column; }
label { 
    font-weight: 600; 
    margin-bottom: 8px; 
    color: #444;
    font-size: 0.95em;
}
textarea, input[type="number"] {
    padding: 12px; 
    border: 2px solid var(--border-color);
    border-radius: 8px; 
    font-size: 15px;
    line-height: 1.5;
    transition: all 0.3s ease;
    background-color: #fff;
}
textarea:focus, input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.15);
    transform: translateY(-1px);
}
textarea { 
    resize: vertical; 
    min-height: 80px;
    font-family: inherit;
}

button {
    background: linear-gradient(135deg, var(--primary-color), #2980b9);
    color: white; 
    border: none; 
    padding: 14px 28px; 
    border-radius: 8px; 
    cursor: pointer; 
    font-size: 16px; 
    font-weight: 600; 
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
button:hover { 
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(52, 152, 219, 0.4);
}
button:active {
    transform: translateY(0);
}

.status { 
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #666; 
    margin-bottom: 20px; 
    font-size: 13px;
    padding: 0 5px;
}
.status span {
    display: flex;
    align-items: center;
    gap: 8px;
}

.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

table { 
    width: 100%; 
    border-collapse: separate;
    border-spacing: 0;
    text-align: right; 
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
thead { 
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}
th { 
    padding: 16px 12px; 
    font-weight: 600; 
    text-align: right; 
    font-size: 0.9em;
    position: relative;
}
th:first-child { text-align: left; }
th::after {
    content: '';
    position: absolute;
    right: 0;
    top: 20%;
    height: 60%;
    width: 1px;
    background: rgba(255,255,255,0.2);
}
th:last-child::after { display: none; }

tbody tr { 
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--border-color);
}
tbody tr:hover {
    background-color: #f8f9fa;
    transform: scale(1.01);
}
tbody tr:last-child { border-bottom: none; }
td { 
    padding: 14px 12px; 
    position: relative;
}
td:first-child { 
    text-align: left; 
    font-weight: 600; 
    color: var(--neutral-color);
}
.stock-code { 
    font-size: 11px; 
    color: #888; 
    display: block; 
    font-weight: normal;
    margin-top: 2px;
}

.price-up { 
    color: var(--up-color);
    font-weight: 600;
}
.price-down { 
    color: var(--down-color);
    font-weight: 600;
}
.price-neutral { 
    color: var(--neutral-color);
    font-weight: 500;
}

/* 优先级控制 */
[data-priority="low"] {
    opacity: 0.8;
}
[data-priority="medium"] {
    opacity: 0.9;
}

/* --- 响应式布局：平板设备 (768px - 1024px) --- */
@media (max-width: 1024px) {
    .container {
        padding: 20px;
        margin: 10px;
        max-width: none;
    }
    
    /* 隐藏低优先级列 */
    [data-priority="low"] {
        display: none;
    }
    
    .controls {
        grid-template-columns: 1fr auto;
        gap: 15px;
    }
    
    .status {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }
}

/* --- 响应式布局：手机设备 (max-width: 767px) --- */
@media (max-width: 767px) {
    body { 
        padding: 8px;
        font-size: 13px;
    }
    
    .container { 
        padding: 15px;
        border-radius: 10px;
    }
    
    h1 {
        font-size: 1.8em;
        margin-bottom: 20px;
    }
    
    .controls {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 15px;
    }
    
    button {
        width: 100%;
        padding: 12px;
        font-size: 15px;
    }
    
    /* 表格移动端优化 */
    table {
        font-size: 0.9em;
    }
    
    th, td {
        padding: 10px 8px;
    }
    
    /* 隐藏中等优先级列 */
    [data-priority="medium"] {
        display: none;
    }
    
    /* 移动端卡片式布局 */
    thead { display: none; }
    
    tbody tr {
        display: block;
        border: 2px solid var(--border-color);
        border-radius: 8px;
        margin-bottom: 12px;
        padding: 12px;
        background: #fff;
        box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    }
    
    td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 0;
        border-bottom: 1px solid #eee;
    }
    
    td:last-child {
        border-bottom: none;
    }
    
    /* 移动端标签显示 */
    td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #666;
        text-align: left;
        min-width: 80px;
    }
    
    td:first-child::before {
        display: none;
    }
    
    td:first-child {
        font-size: 1.1em;
        padding: 8px 0 12px 0;
        border-bottom: 2px solid var(--border-color);
        justify-content: center;
    }
    
    .stock-code {
        font-size: 0.9em;
        margin-top: 4px;
    }
}

/* --- 响应式布局：超小屏幕设备 (max-width: 480px) --- */
@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    
    .container {
        padding: 12px;
        margin: 5px;
    }
    
    h1 {
        font-size: 1.6em;
    }
    
    .controls {
        padding: 12px;
        gap: 10px;
    }
    
    textarea, input[type="number"] {
        padding: 10px;
        font-size: 14px;
    }
    
    button {
        padding: 11px;
        font-size: 14px;
    }
    
    /* 进一步简化移动端显示 */
    td::before {
        min-width: 70px;
        font-size: 0.9em;
    }
    
    td {
        font-size: 0.95em;
        padding: 8px 0;
    }
}

/* --- 响应式布局：优化控制区域布局 --- */
@media (min-width: 768px) and (max-width: 1024px) {
    .controls {
        grid-template-columns: 1fr auto auto;
        gap: 15px;
    }
}

@media (min-width: 1025px) {
    /* 大屏幕显示所有列 */
    [data-priority] {
        display: table-cell;
        opacity: 1;
    }
}

/* 加载状态和错误提示 */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.error-message {
    background-color: #fee;
    color: var(--danger-color);
    padding: 12px;
    border-radius: 6px;
    border: 1px solid var(--danger-color);
    margin: 10px 0;
    text-align: center;
}

.success-message {
    background-color: #efe;
    color: var(--success-color);
    padding: 12px;
    border-radius: 6px;
    border: 1px solid var(--success-color);
    margin: 10px 0;
    text-align: center;
}