:root {
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --text-main: #2c3e50;
    --text-sub: #7f8c8d;
    --border-color: #ebedf0;
    --shadow: 0 4px 12px rgba(0,0,0,0.05);
    --up-color: #f5222d;
    --down-color: #52c41a;
    --susp-color: #fa8c16;
    --flat-color: #bfbfbf;
    --hover-bg: #f8f9fa;
    --toolbar-bg: rgba(255, 255, 255, 0.8);
}

[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --card-bg: #242424;
    --text-main: #e0e0e0;
    --text-sub: #a0a0a0;
    --border-color: #333333;
    --shadow: 0 4px 12px rgba(0,0,0,0.2);
    --hover-bg: #2c2c2c;
    --toolbar-bg: rgba(36, 36, 36, 0.8);
    --flat-color: #595959;
}

body {
    font-family: 'PingFang SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    padding: 20px;
    margin: 0;
    transition: background-color 0.3s, color 0.3s;
}

/* --- Toolbar --- */
.toolbar {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
}

.btn-icon {
    background: var(--toolbar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 42px;
    height: 42px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
}

.btn-icon:hover {
    background: var(--card-bg);
    border-color: var(--text-sub);
    transform: scale(1.05);
}

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

/* --- Container --- */
.stock-container {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
    padding-bottom: 50px;
}

/* --- Card View --- */
.stock-box {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px 20px;
    width: 220px;
    box-shadow: var(--shadow);
    text-align: center;
    transition: transform 0.3s, box-shadow 0.3s, border 0.3s;
    border-top: 4px solid transparent; /* 默认透明，无样式 */
    border-bottom: 4px solid transparent;
    position: relative;
}

.stock-box:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.stock-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 8px;
    text-decoration: none;
    display: block;
}

.stock-code { font-size: 13px; color: var(--text-sub); font-weight: normal; margin-left: 6px; }
.stock-price { font-family: 'Arial', sans-serif; font-size: 32px; font-weight: 800; margin: 10px 0; }
.stock-currency { font-size: 14px; font-weight: 400; color: var(--text-sub); margin-left: 2px; }
.stock-change { font-size: 16px; font-weight: 700; }
.status-label { font-size: 12px; margin-top: 12px; color: var(--text-sub); display: block; }

/* --- List View --- */
.list-view {
    flex-direction: column;
    align-items: center;
    max-width: 900px;
    margin: 0 auto;
}

.list-view .stock-box {
    width: 100%;
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 0.8fr;
    align-items: center;
    text-align: left;
    padding: 16px 30px;
    border-top: none;
    border-left: 4px solid var(--flat-color);
    margin-bottom: 12px;
}

.list-view .stock-name { margin-bottom: 0; }
.list-view .stock-price { font-size: 24px; margin: 0; }
.list-view .stock-change { margin-top: 0; }
.list-view .status-label { margin-top: 0; text-align: right; }

/* --- Dynamic Status --- */
.up { color: var(--up-color); border-top-color: var(--up-color) !important; }
.list-view .up { border-left-color: var(--up-color) !important; border-top-color: transparent !important; }

.down { color: var(--down-color); border-bottom: 4px solid var(--down-color) !important; border-top-color: transparent !important; }
.list-view .down { border-left-color: var(--down-color) !important; border-bottom: none !important; }

/* 1. 停牌 (Suspended) -> 灰色上下边 */
.susp {
    color: var(--flat-color);
    border-top: 4px solid var(--flat-color) !important;
    border-bottom: 4px solid var(--flat-color) !important;
}
.list-view .susp {
    border-top: none !important;
    border-bottom: none !important;
    border-left: 4px solid var(--flat-color) !important;
    border-right: 4px solid var(--flat-color) !important;
}

/* 2. 平盘 (Flat) -> 橙色上下边 */
.flat {
    color: var(--susp-color);
    border-top: 4px solid var(--susp-color) !important;
    border-bottom: 4px solid var(--susp-color) !important;
}
.list-view .flat {
    border-top: none !important;
    border-bottom: none !important;
    border-left: 4px solid var(--susp-color) !important;
    border-right: 4px solid var(--susp-color) !important;
}

/* 3. 午间休市 -> 灰色上下边 */
.lunch {
    color: var(--flat-color);
    border-top: 4px solid var(--flat-color) !important;
    border-bottom: 4px solid var(--flat-color) !important;
}
.list-view .lunch {
    border-top: none !important;
    border-bottom: none !important;
    border-left: 4px solid var(--flat-color) !important;
}

/* --- Context Menu --- */
#context-menu {
    display: none;
    position: fixed;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    padding: 8px 0;
    min-width: 160px;
    z-index: 9999;
}

#context-menu label {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-main);
    transition: background 0.2s;
}

#context-menu label:hover {
    background: var(--hover-bg);
}

#context-menu input[type="checkbox"] {
    margin-right: 12px;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* --- Refresh Timer --- */
#refresh-timer {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    background: var(--toolbar-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    cursor: default;
    z-index: 100;
}

.timer-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.timer-bg {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 2;
}

.timer-progress {
    fill: none;
    stroke: var(--text-sub);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-dasharray: 97.4;  /* 2 * PI * 15.5 */
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear, stroke 0.3s;
}

[data-theme="dark"] .timer-progress {
    stroke: var(--text-main);
}

#timer-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    font-family: 'SF Mono', 'Consolas', monospace;
    z-index: 1;
}

/* --- Data Source Footer --- */
#data-source {
    position: fixed;
    bottom: 12px;
    left: 16px;
    font-size: 12px;
    color: #888888;
    z-index: 10000;
}
