/* 股價追蹤系統樣式 - 手機版優化 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 標籤頁導航樣式 */
.tab-navigation {
    display: flex;
    justify-content: center;
    margin: 13px 0;
    gap: 6px;
    padding: 0 5px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

.tab-navigation::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 14px;
    border: 2px solid #dee2e6;
    border-radius: 7px;
    background: white;
    color: #6c757d;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 0 1 auto;
    justify-content: center;
    min-width: fit-content;
    white-space: nowrap;
}

.tab-btn:hover {
    border-color: #007bff;
    color: #007bff;
    transform: translateY(-1px);
}

.tab-btn.active {
    background: #007bff;
    border-color: #007bff;
    color: white;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

.tab-btn i {
    font-size: 15px;
}

.tab-btn span {
    font-weight: 600;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    min-height: 100vh;
    color: #333;
    font-size: 14px;
    padding-bottom: 80px;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 15px;
}

/* 頭部樣式 */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    color: #333;
    position: relative;
}

header h1, header h3 {
    font-size: 1.5rem;
    margin-bottom: 5px;
    flex: 1;
    text-align: center;
}

header p {
    font-size: 0.85rem;
    opacity: 0.9;
}

/* 財務儀表板按鈕 */
.dashboard-btn {
    background: linear-gradient(135deg, #6f42c1, #5a32a3);
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(111, 66, 193, 0.3);
    white-space: nowrap;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

.dashboard-btn:hover {
    background: linear-gradient(135deg, #5a32a3, #4c2a91);
    transform: translateY(-50%) translateY(-2px);
    box-shadow: 0 4px 12px rgba(111, 66, 193, 0.4);
}

.dashboard-btn i {
    font-size: 1rem;
}

/* 手機版響應式 */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 10px;
    }
    
    header h3 {
        text-align: center;
        width: 100%;
    }
    
    .dashboard-btn {
        position: static;
        transform: none;
        align-self: center;
        margin-top: 5px;
    }
    
    /* 手機版餅圖調整 */
    .card-chart-container {
        margin: 10px 0;
    }
    
    .card-chart-content {
        padding: 6px 6px;
        height: 220px;
    }
    
    .card-chart-content canvas {
        height: 200px !important;
    }
    
    .chart-time-buttons {
        padding: 8px;
    }
}


/* 搜尋列 */
.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    align-items: center;
}

#stockSymbol {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s ease;
    height: 40px;
    box-sizing: border-box;
}

#stockSymbol:focus {
    outline: none;
    border-color: #6c757d;
    box-shadow: 0 0 0 2px rgba(108, 117, 125, 0.1);
}

/* 搜尋結果區域 */
.search-result {
    background: white !important;
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    margin: 0 auto 25px auto;
    overflow: hidden;
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 1200px;
}

.search-stock-card {
    padding: 25px;
    border-bottom: 1px solid #ecf0f1;
    background: white;
    position: relative;
}

.search-stock-card:last-child {
    border-bottom: none;
}

.search-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.action-buttons {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}


.pin-info {
    margin: 15px 0;
    padding: 12px;
    background: #e3f2fd;
    border-radius: 8px;
    border-left: 4px solid #2196f3;
}

.pin-info p {
    margin: 0;
    color: #1565c0;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 統一的圓形動作按鈕樣式 */
.action-btn {
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: white;
    font-size: 0.9rem;
}

.action-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.action-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.pin-btn {
    background: #27ae60;
}

.pin-btn:hover {
    background: #219a52;
    transform: scale(1.1);
    box-shadow: 0 3px 10px rgba(39, 174, 96, 0.4);
}

.unpin-btn {
    background: #f39c12;
}

.unpin-btn:hover {
    background: #e67e22;
    transform: scale(1.1);
    box-shadow: 0 3px 10px rgba(243, 156, 18, 0.4);
}

.close-search {
    background: #e74c3c;
}

.close-search:hover {
    background: #c0392b;
    transform: scale(1.1);
    box-shadow: 0 3px 10px rgba(231, 76, 60, 0.4);
}

/* 搜尋資訊提示 */
.search-info {
    margin-top: 15px;
    padding: 12px;
    background: #e3f2fd;
    border-radius: 8px;
    border-left: 4px solid #2196f3;
}

.search-info p {
    margin: 0;
    color: #1565c0;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 交易表單樣式 */
.transaction-form {
    margin-top: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 2px solid #e9ecef;
}

.transaction-form h4 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 8px;
}

.transaction-note {
    margin-top: 15px;
    padding: 10px;
    background: #e3f2fd;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #1565c0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.add-transaction {
    display: flex;
    align-items: flex-end;
}

/* 卡片內圖表樣式 */
.card-chart-container {
    margin: 15px 0;
    background: white;
    border-radius: 8px;
    border: 1px solid #ddd;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 0;
}

.card-chart-content {
    padding: 12px 6px;
    height: 250px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    position: relative;
}

.card-chart-content canvas {
    width: 100% !important;
    height: 220px !important;
}

.chart-time-buttons {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 10px;
    background: #f8f9fa;
    border-top: 1px solid #ddd;
}

.time-btn {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 15px;
    background: white;
    color: #666;
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.time-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.time-btn.active {
    background: #6c757d;
    color: white;
    border-color: #6c757d;
}

.time-btn.active:hover {
    background: #495057;
    border-color: #495057;
}

/* 投資組合卡片樣式 */
.portfolio-summary {
    margin: 10px 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid #eee;
}

.summary-label {
    font-size: 0.75rem;
    color: #666;
    font-weight: 500;
}

.summary-value {
    font-size: 0.75rem;
    font-weight: 600;
    color: #2c3e50;
}

.summary-value.positive {
    color: #27ae60;
}

.summary-value.negative {
    color: #e74c3c;
}

.portfolio-details {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #eee;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7rem;
    color: #666;
}

.detail-item span:last-child {
    font-weight: 500;
    color: #2c3e50;
}

.stock-actions {
    display: flex;
    gap: 8px;
}

.portfolio-menu {
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.portfolio-menu:hover {
    background: #495057;
    transform: scale(1.1);
}

.portfolio-menu.chart-toggle {
    background: #868e96;
}

.portfolio-menu.chart-toggle:hover {
    background: #6c757d;
}

/* 卡片內交易表單樣式 */
.card-transaction-form {
    margin-top: 15px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    animation: slideDown 0.3s ease-out;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        padding: 0 15px;
    }
    to {
        opacity: 1;
        max-height: 300px;
        padding: 15px;
    }
}

.card-transaction-form h5,
.edit-transaction-form h5 {
    margin: 0 0 12px 0;
    color: #2c3e50;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    justify-content: flex-end;
}

.form-actions button {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* 交易記錄明細樣式 */
.transaction-history {
    margin-top: 12px;
    padding: 12px;
    background: #f1f3f4;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    position: relative;
}

.add-transaction-section {
    margin-top: 10px;
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 8px 0;
    flex-wrap: wrap;
}

.add-transaction-btn-corner {
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.3s ease;
    font-size: 0.75rem;
    font-weight: 500;
}

.add-transaction-btn-corner:hover {
    background: #495057;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(108, 117, 125, 0.3);
}

.show-transaction-btn {
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.3s ease;
    font-size: 0.7rem;
    font-weight: 500;
    flex: 1;
}

.show-transaction-btn:hover {
    background: #495057;
    transform: translateY(-1px);
}

/* 新增買入按鈕 */
.add-buy-btn {
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.3s ease;
    font-size: 0.7rem;
    font-weight: 500;
    flex: 1;
}

.add-buy-btn:hover {
    background: #495057;
    transform: translateY(-1px);
}

/* 新增賣出按鈕 */
.add-sell-btn {
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.3s ease;
    font-size: 0.7rem;
    font-weight: 500;
    flex: 1;
}

.add-sell-btn:hover {
    background: #495057;
    transform: translateY(-1px);
}


.transaction-history h5 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 4px;
}

.no-transactions {
    text-align: center;
    padding: 20px;
    color: #7f8c8d;
    font-style: italic;
}

.no-transactions i {
    margin-right: 5px;
    color: #bdc3c7;
}

.transaction-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.transaction-item {
    background: white;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    overflow: hidden;
}

/* 買入記錄樣式 */
.transaction-item.transaction-buy {
    border-left: 4px solid #28a745;
    background: #f8fdf8;
}

/* 賣出記錄樣式 */
.transaction-item.transaction-sell {
    border-left: 4px solid #dc3545;
    background: #fdf8f8;
}

/* 股數顏色區別 */
.buy-shares {
    color: #28a745;
    font-weight: 600;
}

.sell-shares {
    color: #dc3545;
    font-weight: 600;
}

.transaction-main {
    padding: 8px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.transaction-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    flex: 1;
}

.transaction-date,
.transaction-shares,
.transaction-price,
.transaction-total {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.75rem;
    color: #666;
}

.transaction-date i { color: #3498db; }
.transaction-shares i { color: #f39c12; }
.transaction-price i { color: #27ae60; }
.transaction-total i { color: #e74c3c; }

.transaction-actions {
    display: flex;
    gap: 6px;
    margin-left: 10px;
}

.btn-edit {
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.8rem;
}

.btn-edit:hover {
    background: #495057;
    transform: translateY(-1px);
}

.btn-delete {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.8rem;
}

.btn-delete:hover {
    background: #c0392b;
    transform: translateY(-1px);
}

.edit-transaction-form {
    padding: 15px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    border-radius: 0 0 6px 6px;
    animation: slideDown 0.3s ease-out;
}


.btn-pin {
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-pin:hover {
    background: #219a52;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(39, 174, 96, 0.4);
}

.btn-unpin {
    background: #f39c12;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-unpin:hover {
    background: #e67e22;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(243, 156, 18, 0.4);
}

.search-stock-info {
    flex: 1;
}

.search-stock-symbol {
    font-size: 1.5rem;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 5px;
}

.search-stock-name {
    font-size: 1rem;
    color: #7f8c8d;
    margin-bottom: 10px;
}

.search-stock-price {
    font-size: 1.3rem;
    font-weight: bold;
    margin-bottom: 5px;
    color: #2c3e50;
}

.search-stock-change {
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
}

.search-stock-change.positive {
    color: #27ae60;
}

.search-stock-change.negative {
    color: #e74c3c;
}

.search-stock-change.neutral {
    color: #7f8c8d;
}

.search-week52-range {
    font-size: 0.75rem;
    color: #95a5a6;
    margin-top: 2px;
    font-weight: 500;
}

/* 配息資訊區域 */
.dividend-info {
    margin: 20px 0;
    padding: 15px;
    background: #e8f5e8;
    border-radius: 8px;
    border-left: 4px solid #27ae60;
}

.dividend-info h4 {
    margin: 0 0 12px 0;
    color: #27ae60;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dividend-details {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.dividend-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.dividend-item span:first-child {
    color: #666;
    font-weight: 500;
}

.dividend-value {
    font-weight: 600;
    color: #27ae60;
}

/* 持股輸入表單 */
.holding-form {
    margin-top: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 2px solid #e9ecef;
    position: relative;
    z-index: 1;
}

.holding-form h4 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-row {
    display: flex;
    flex-direction: row;
    gap: 8px;
    margin-bottom: 15px;
    width: 100%;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
    box-sizing: border-box;
}

.form-group label {
    font-weight: 600;
    color: #2c3e50;
    font-size: 10px;
    white-space: nowrap;
}

.form-group input[type="number"],
.form-group input[type="date"] {
    padding: 6px 8px;
    border: 1px solid #e1e5e9;
    border-radius: 4px;
    font-size: 11px;
    transition: border-color 0.3s ease;
    background: white;
    width: 100%;
    height: 32px;
    box-sizing: border-box;
    max-width: 100%;
    overflow: hidden;
}

.form-group input[type="number"]:focus,
.form-group input[type="date"]:focus {
    outline: none;
    border-color: #6c757d;
    box-shadow: 0 0 0 2px rgba(108, 117, 125, 0.1);
}

/* 特別針對日期輸入框 */
.form-group input[type="date"] {
    -webkit-appearance: none;
    -moz-appearance: textfield;
    min-width: 0;
    flex-shrink: 1;
}

.add-to-portfolio {
    grid-column: span 3;
    justify-self: center;
}

.dividend-note {
    margin-top: 10px;
    padding: 10px;
    background: #f0f9ff;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #0369a1;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 目前持股顯示 */
.current-holding {
    margin: 20px 0;
    padding: 15px;
    background: #fff8e1;
    border-radius: 8px;
    border-left: 4px solid #f39c12;
}

.current-holding h4 {
    margin: 0 0 12px 0;
    color: #f39c12;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.holding-details {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

/* 卡片中的編輯表單 */
.holding-edit-form {
    margin-bottom: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.edit-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 12px;
    align-items: end;
}

.edit-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.edit-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #495057;
}

.edit-group input {
    padding: 8px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: border-color 0.3s ease;
}

.edit-group input:focus {
    outline: none;
    border-color: #6c757d;
    box-shadow: 0 0 0 2px rgba(108, 117, 125, 0.1);
}

.update-holding {
    background: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    height: fit-content;
}

.update-holding:hover {
    background: #218838;
    transform: translateY(-1px);
}


/* 按鈕樣式 */
.btn-primary, .btn-secondary, .btn-danger, .btn-info, .btn-warning, .btn-success {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: linear-gradient(45deg, #6c757d, #495057);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(108, 117, 125, 0.4);
}

/* 搜尋按鈕特殊樣式 */
#searchStock {
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
    flex-shrink: 0;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #545b62;
    transform: translateY(-1px);
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
    transform: translateY(-1px);
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-info:hover {
    background: #138496;
    transform: translateY(-1px);
}

.btn-warning {
    background: #ffc107;
    color: #212529;
}

.btn-warning:hover {
    background: #e0a800;
    transform: translateY(-1px);
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
    transform: translateY(-1px);
}

/* 浮動控制按鈕 */
.floating-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    gap: 8px;
    z-index: 1000;
    padding: 12px 10px;
    box-sizing: border-box;
    background: rgba(248, 249, 250, 0.96);
    backdrop-filter: blur(15px);
    justify-content: center;
    align-items: center;
    box-shadow: 0 -2px 15px rgba(0, 0, 0, 0.1);
}

.floating-btn {
    background: rgba(108, 117, 125, 0.95);
    color: white;
    border: none;
    border-radius: 16px;
    padding: 6px 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 7px;
    white-space: nowrap;
    flex: 1;
    min-width: 55px;
    max-width: 85px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.floating-btn i {
    font-size: 12px;
    margin-bottom: 2px;
}

.floating-btn span {
    font-size: 7px;
    font-weight: 500;
}

.floating-btn:hover {
    background: rgba(73, 80, 87, 0.95);
    transform: scale(1.05);
}

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

/* 浮動按鈕特殊樣式 */
#refreshAll.floating-btn {
    background: rgba(40, 167, 69, 0.95);
}

#refreshAll.floating-btn:hover {
    background: rgba(33, 136, 56, 0.95);
}

.reload-btn.floating-btn {
    background: rgba(255, 152, 0, 0.95);
}

.reload-btn.floating-btn:hover {
    background: rgba(230, 137, 0, 0.95);
}


#refreshAll.btn-compact {
    background: #28a745;
}

#refreshAll.btn-compact:hover {
    background: #218838;
}

#testConnection.btn-compact {
    background: #17a2b8;
}

#testConnection.btn-compact:hover {
    background: #138496;
}

.reload-btn {
    background: #ff9800;
}

.reload-btn:hover {
    background: #e68900;
}

/* 緊湊自動更新樣式 */
.auto-refresh-compact {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    color: #666;
    cursor: pointer;
    user-select: none;
    flex-shrink: 1;
    min-width: 0;
    white-space: nowrap;
}

.auto-refresh-compact input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    flex-shrink: 0;
}

.auto-refresh-compact span {
    font-weight: 500;
}

.settings-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.storage-settings,
.data-source-settings {
    display: flex;
    gap: 15px;
    align-items: center;
}

.setting-label {
    font-weight: 600;
    color: #2c3e50;
    min-width: 80px;
}

.storage-settings label,
.data-source-settings label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
}

.storage-settings input[type="radio"],
.data-source-settings input[type="radio"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.auto-refresh {
    display: flex;
    align-items: center;
}

.auto-refresh label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
}

.auto-refresh input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* 股票列表 */
.stock-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-bottom: 20px;
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.stock-card {
    background: white;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
    min-height: auto;
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
}

.stock-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.15);
}

.stock-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(45deg, #6c757d, #495057);
}

.stock-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.stock-header-line {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 5px;
}

.stock-symbol {
    font-size: 1.1rem;
    font-weight: bold;
    color: #2c3e50;
}

.stock-name {
    font-size: 0.75rem;
    color: #7f8c8d;
}

.price-change-line {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 5px;
}

.pinned-stock {
    background: #f39c12;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    transform: rotate(45deg);
}

.pinned-stock:hover {
    background: #e67e22;
    transform: rotate(45deg) scale(1.1);
}

.stock-price {
    font-size: 1.1rem;
    font-weight: bold;
    color: #2c3e50;
}

.stock-price-hkd {
    font-size: 0.9rem;
    color: #666;
    margin-left: 10px;
    font-weight: normal;
}


.stock-change {
    font-size: 0.8rem;
    font-weight: 600;
}

.stock-change.positive {
    color: #27ae60;
}

.stock-change.negative {
    color: #e74c3c;
}

.stock-change.neutral {
    color: #7f8c8d;
}

.week52-range {
    font-size: 0.65rem;
    color: #95a5a6;
    margin-top: 2px;
    font-weight: 500;
}

.holding-info {
    margin: 15px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #6c757d;
}

.holding-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.holding-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.holding-label {
    font-size: 0.85rem;
    color: #6c757d;
    font-weight: 500;
}

.holding-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: #2c3e50;
}

.holding-value.positive {
    color: #27ae60;
}

.holding-value.negative {
    color: #e74c3c;
}

.stock-info {
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px solid #ecf0f1;
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    font-size: 0.8rem;
    color: #7f8c8d;
}

.info-item {
    display: flex;
    justify-content: space-between;
}

.last-updated {
    text-align: center;
    font-size: 0.8rem;
    color: #95a5a6;
    margin-top: 10px;
    font-style: italic;
}

/* 無股票狀態 */
.no-stocks {
    text-align: center;
    background: white;
    padding: 60px 30px;
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    color: #7f8c8d;
    max-width: 1200px;
    margin: 0 auto;
}

.no-stocks i {
    font-size: 4rem;
    margin-bottom: 20px;
    color: #bdc3c7;
}

.no-stocks h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #34495e;
}

/* 載入模態框 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    min-width: 200px;
    max-width: 90vw;
    white-space: nowrap;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #6c757d;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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


/* 頁腳 */
footer {
    text-align: center;
    color: white;
    opacity: 0.8;
    font-size: 0.9rem;
}

footer i {
    margin-right: 5px;
}


/* 動畫效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stock-card {
    animation: fadeIn 0.5s ease forwards;
}

/* 滾動條樣式 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 計算配息按鈕 */
.calc-dividend-btn {
    background: linear-gradient(135deg, #007bff, #0056b3);
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 4px rgba(0,123,255,0.2);
}

.calc-dividend-btn:hover {
    background: linear-gradient(135deg, #0056b3, #004085);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,123,255,0.3);
}

.calc-dividend-btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
}

.calc-dividend-btn.success {
    background: linear-gradient(135deg, #28a745, #1e7e34);
    box-shadow: 0 2px 4px rgba(40,167,69,0.2);
}

.calc-dividend-btn.success:hover {
    background: linear-gradient(135deg, #1e7e34, #155724);
}

/* 資金流向摘要樣式 */
.funding-summary {
    margin: 15px 0;
    padding: 0;
}

/* 目前價值和獲利總計兩欄 */
.current-value-row {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
}

.current-value-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.current-value-field .field-label {
    font-size: 16px;
    font-weight: 600;
    color: #495057;
}

.current-value-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
}

.current-value-field .field-value {
    font-size: 20px;
    font-weight: bold;
    color: #212529;
}

.current-value-field .usd-value {
    font-size: 20px;
}

.current-value-field .twd-value {
    font-size: 12px;
    color: #6c757d;
    font-weight: 400;
}

.funding-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.funding-field {
    text-align: center;
    padding: 8px 4px;
}

.field-label {
    display: block;
    font-size: 10px;
    color: #666;
    margin-bottom: 2px;
    font-weight: 500;
}

.field-value {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: #333;
}

.field-value.positive {
    color: #28a745;
}

.field-value.negative {
    color: #dc3545;
}

/* 漸進式載入效果 */
.stock-card.loading-price {
    position: relative;
}

.stock-card.loading-price::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.8), transparent);
    animation: shimmer 1.5s infinite;
    pointer-events: none;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.stock-price.loading {
    background: #f0f0f0;
    color: transparent;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.stock-price.loading::after {
    content: '載入中...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #666;
    font-size: 12px;
}

/* 損益分行顯示 */
.profit-amount {
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
}

.profit-percent {
    font-size: 10px;
    font-weight: 500;
    line-height: 1.2;
    opacity: 0.8;
}


/* 浮動控制按鈕中的計算配息按鈕 */
.calc-all-dividends-btn {
    background: linear-gradient(135deg, #6f42c1, #5a32a3) !important;
}

.calc-all-dividends-btn:hover {
    background: linear-gradient(135deg, #5a32a3, #4c2a91) !important;
    transform: translateY(-2px);
}
