@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Noto+Sans+TC:wght@300;400;500;700&family=Noto+Serif+TC:wght@400;600&display=swap');

:root {
    --bg-ivory: #FDFCF8;
    --card-bg: #FFFFFF;
    --text-navy: #1A2436;
    --text-muted: #8A94A6;
    --accent-gold: #C5A059;
    --up-red: #D96B6B;
    --down-green: #549B7B;
    --shadow-soft: 0 16px 40px rgba(26, 36, 54, 0.04);
    --border-light: rgba(26, 36, 54, 0.05);
    --transition-smooth: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg-ivory);
    color: var(--text-navy);
    font-family: 'Inter', 'Noto Sans TC', sans-serif;
    -webkit-font-smoothing: antialiased;
    padding: 80px 0;
}

h1,
h2,
h3 {
    font-family: 'Noto Serif TC', serif;
    font-weight: 600;
}

.num {
    font-family: 'Inter', sans-serif;
}

.color-up {
    color: var(--up-red);
}

.color-down {
    color: var(--down-green);
}

.color-gold {
    color: var(--accent-gold);
}

.app-container {
    max-width: 480px;
    margin: 0 auto;
    padding: 24px 20px;
    position: relative;
}

.top-nav {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: 70px;
    background: rgba(253, 252, 248, 0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    padding: 0 10px;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
}

.nav-item {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: var(--transition-smooth);
    padding: 10px 5px;
    cursor: pointer;
    position: relative;
    flex: 1;
}

.nav-item i {
    font-size: 16px;
}

.nav-item.active {
    color: var(--text-navy);
}

.nav-item.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20%;
    width: 60%;
    height: 2px;
    background: var(--accent-gold);
    border-radius: 2px;
}

.hero-section {
    text-align: center;
    padding: 20px 0 30px;
    position: relative;
}

.sync-btn-wrapper {
    position: absolute;
    top: -10px;
    right: 0;
}

.sync-btn {
    background: none;
    border: none;
    color: var(--accent-gold);
    font-size: 22px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.sync-btn.spin {
    animation: spin 1s linear infinite;
    opacity: 0.5;
    pointer-events: none;
}

.hero-title {
    font-size: 13px;
    color: var(--text-muted);
    letter-spacing: 2px;
    margin-bottom: 8px;
    font-family: 'Noto Sans TC';
}

.hero-amount {
    font-size: 42px;
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 16px;
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: 4px;
}

.hero-amount .currency {
    font-size: 22px;
    color: var(--accent-gold);
    font-weight: 500;
}

.hero-sub-info {
    display: flex;
    justify-content: center;
    gap: 16px;
    font-size: 13px;
}

.hero-sub-info div {
    display: flex;
    flex-direction: column;
}

.hero-sub-info span {
    color: var(--text-muted);
    margin-bottom: 4px;
}

.card {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-light);
    overflow: hidden;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    cursor: pointer;
}

.card-title {
    font-size: 18px;
    margin-bottom: 4px;
}

.card-subtitle {
    font-size: 12px;
    color: var(--text-muted);
}

.card-value {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 4px;
    text-align: right;
}

.card-roi {
    font-size: 14px;
    font-weight: 500;
    text-align: right;
}

.card-footer-time {
    font-size: 11px;
    color: var(--text-muted);
    text-align: right;
    padding-top: 12px;
    border-top: 1px dashed var(--border-light);
    margin-top: 12px;
}

.list-container {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: var(--transition-smooth);
}

.card.expanded .list-container {
    max-height: 5000px;
    opacity: 1;
    margin-top: 16px;
    border-top: 1px solid var(--border-light);
}

.list-item {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
}

.list-item:last-child {
    border-bottom: none;
}

.item-col {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.item-col.right {
    align-items: flex-end;
}

.item-main {
    font-weight: 600;
}

.item-sub {
    font-size: 12px;
    color: var(--text-muted);
}

.history-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.hero-btn {
    white-space: nowrap;
    background: var(--bg-ivory);
    color: var(--text-muted);
    border: 1px solid var(--border-light);
    padding: 6px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
    transition: var(--transition-smooth);
}

.hero-btn:active {
    transform: scale(0.96);
}

.hero-btn.active-hero {
    background: linear-gradient(135deg, #C5A059, #D4AF37);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(197, 160, 89, 0.3);
}

.hero-btn.dark-btn {
    background: #3A4A63;
    color: white;
    border: none;
}

.hero-btn.dark-btn.active-hero {
    background: #1A2436;
    box-shadow: 0 4px 12px rgba(26, 36, 54, 0.3);
}

.history-grid {
    display: grid;
    grid-template-columns: 1.4fr 1.1fr 1.1fr 1.1fr 1.8fr 1.8fr;
    gap: 4px;
    align-items: center;
    font-size: 12px;
    text-align: right;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-light);
}

.history-grid:last-child {
    border-bottom: none;
}

.history-grid .col-name {
    text-align: left;
    font-weight: 600;
    font-size: 14px;
}

.progress-bar-container {
    width: 100%;
    background: var(--border-light);
    border-radius: 4px;
    height: 4px;
    margin-top: 10px;
    overflow: hidden;
    display: none;
}

.progress-bar {
    height: 100%;
    background: var(--accent-gold);
    width: 0%;
    transition: width 0.3s ease;
}

.chart-container {
    position: relative;
    height: 260px;
    width: 100%;
    margin-top: 10px;
}

.allocation-chart-container {
    position: relative;
    height: 200px;
    width: 100%;
    margin-top: 16px;
}

.mid-hero-section {
    text-align: center;
    padding: 10px 0 24px;
    border-top: 1px dashed var(--border-light);
    margin-top: 10px;
}

.edit-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 0;
    border-bottom: 1px solid var(--border-light);
}

.edit-item:last-child {
    border-bottom: none;
}

.edit-symbol {
    font-weight: 700;
    font-size: 13px;
    width: 54px;
    color: var(--text-navy);
    flex-shrink: 0;
}

.edit-inputs {
    display: flex;
    gap: 8px;
    flex: 1;
}

.edit-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
}

.edit-label {
    font-size: 9px;
    color: var(--text-muted);
    letter-spacing: 1px;
    font-weight: 100;
}

.edit-input {
    width: 92%;
    border: 1.5px solid var(--border-light);
    border-radius: 8px;
    padding: 7px 9px;
    font-size: 13px;
    font-family: 'Inter';
    background: var(--bg-ivory);
    outline: none;
}

.edit-input:focus {
    border-color: var(--accent-gold);
    background: #FFF;
    box-shadow: 0 0 0 3px rgba(197, 160, 89, 0.08);
}

.btn-action-group {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.btn-save,
.btn-del {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 13px;
    cursor: pointer;
    transition: 0.2s;
    background: transparent;
}

.btn-save {
    border: 1.5px solid var(--accent-gold);
    color: var(--accent-gold);
}

.btn-save:hover {
    background: var(--accent-gold);
    color: white;
}

.btn-del {
    border: 1.5px solid rgba(26, 36, 54, 0.08);
    color: #B0B8C8;
}

.btn-del:hover {
    border-color: rgba(217, 107, 107, 0.4);
    color: var(--up-red);
    background: rgba(217, 107, 107, 0.05);
}

.btn-add-stock {
    width: 100%;
    padding: 13px;
    border-radius: 12px;
    background: var(--text-navy);
    color: white;
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 12px;
}

.btn-cash-update {
    padding: 8px 16px;
    border-radius: 10px;
    background: transparent;
    border: 1.5px solid var(--accent-gold);
    color: var(--accent-gold);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.btn-cash-update:hover {
    background: var(--accent-gold);
    color: white;
}

.changelog-panel {
    background: var(--card-bg);
    border-radius: 20px;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-soft);
    margin-bottom: 20px;
    overflow: hidden;
}

.changelog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border-light);
    font-weight: 600;
}

.changelog-title {
    font-family: 'Noto Serif TC', serif;
    font-size: 16px;
}

.changelog-badge {
    background: var(--up-red);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    min-width: 22px;
    text-align: center;
}

.changelog-badge.empty {
    background: #D0D5DF;
}

.changelog-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.changelog-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 20px;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
}

.changelog-row:last-child {
    border-bottom: none;
}

.changelog-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.changelog-tag {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.8px;
    padding: 2px 7px;
    border-radius: 6px;
}

.tag-edit {
    background: rgba(197, 160, 89, 0.12);
    color: var(--accent-gold);
}

.tag-add {
    background: rgba(84, 155, 123, 0.12);
    color: var(--down-green);
}

.tag-del {
    background: rgba(217, 107, 107, 0.12);
    color: var(--up-red);
}

.tag-cash {
    background: rgba(26, 36, 54, 0.07);
    color: var(--text-navy);
}

.changelog-symbol {
    font-weight: 700;
    color: var(--text-navy);
}

.changelog-right {
    font-size: 12px;
    color: var(--text-muted);
    text-align: right;
    line-height: 1.6;
}

.cloud-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    padding: 10px 16px;
    background: var(--bg-ivory);
    border-radius: 12px;
    margin-bottom: 16px;
    border: 1px solid var(--border-light);
}

.cloud-status .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ccc;
}

.cloud-status.synced .dot {
    background: var(--down-green);
}

.cloud-status.syncing .dot {
    background: var(--accent-gold);
    animation: pulse 1s infinite;
}

.cloud-status.error .dot {
    background: var(--up-red);
}

.save-to-cloud-btn {
    width: 100%;
    padding: 14px;
    border-radius: 14px;
    background: linear-gradient(135deg, #1A2436, #2C3A50);
    color: white;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
}

.save-to-cloud-btn:disabled {
    opacity: 0.5;
    pointer-events: none;
}

.toast {
    position: fixed;
    bottom: -60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(26, 36, 54, 0.9);
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 13px;
    opacity: 0;
    transition: var(--transition-smooth);
    z-index: 9999;
}

.toast.show {
    bottom: 100px;
    opacity: 1;
}

.footer {
    text-align: center;
    font-size: 11px;
    color: #A0A5B1;
    margin-top: 40px;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1
    }

    50% {
        opacity: 0.3
    }
}

.hide {
    display: none;
}

.mini-allocation-bar {
    display: flex;
    height: 22px;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 12px;
    margin-top: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.mini-bar-segment {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFF;
    font-size: 10px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    white-space: nowrap;
    transition: width 0.5s cubic-bezier(0.25, 1, 0.5, 1);
    cursor: pointer;
    border-right: 1px solid rgba(255, 255, 255, 0.15);
}

.mini-bar-segment:last-child {
    border-right: none;
}

.reduced-font {
    font-size: 10.5px !important;
    color: var(--text-muted) !important;
    font-weight: 500;
    letter-spacing: 0.2px;
}

/* 🌟 高密度交易紀錄專屬樣式 */
.tx-card {
    padding: 16px 14px;
    margin-bottom: 10px;
    border-radius: 16px;
}

.tx-stock-header {
    padding: 8px 10px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    background: rgba(197, 160, 89, 0.05);
}

.tx-card .card-title {
    font-size: 16px;
    margin-bottom: 0px;
}

.tx-card .card-subtitle {
    font-size: 11px;
}

.tx-expand-icon {
    font-size: 11px;
    color: #B0B8C8;
    transition: transform 0.3s ease;
    margin-left: 10px;
    margin-bottom: 4px;
}

.card.expanded .tx-expand-icon {
    transform: rotate(180deg);
    color: var(--accent-gold);
}

.tx-grid {
    display: grid;
    grid-template-columns: 1fr 0.9fr 0.8fr 1fr 1.2fr 0.6fr;
    gap: 4px;
    font-size: 11px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
    align-items: center;
}

.tx-grid:last-child {
    border-bottom: none;
}

.tx-header {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 10px;
    border-bottom: 2px solid var(--border-light);
    padding-bottom: 6px;
}

.tx-tag {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 4px;
    display: inline-block;
}

.tag-buy {
    background: rgba(217, 107, 107, 0.15);
    color: var(--up-red);
}

.tag-sell {
    background: rgba(84, 155, 123, 0.15);
    color: var(--down-green);
}

.tag-div {
    background: rgba(197, 160, 89, 0.15);
    color: var(--accent-gold);
}

.tx-action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    padding: 4px;
    transition: 0.2s;
}

.tx-action-btn:hover {
    color: var(--text-navy);
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.form-col {
    flex: 1;
    min-width: 45%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.btn-half {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: 0.2s;
}

.btn-stage {
    background: var(--text-navy);
    color: white;
}

.btn-clear {
    background: var(--bg-ivory);
    color: var(--text-muted);
    border: 1px solid var(--border-light);
}

.btn-commit {
    width: 100%;
    padding: 14px;
    border-radius: 14px;
    background: var(--accent-gold);
    color: white;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 12px;
}

/* ==========================================================================
   🌟 資訊頁面 (Global Market Monitoring) 專屬樣式
   ========================================================================== */

.market-header {
    background: #2C3A50;
    /* 延續專案深色調 */
    color: white;
    text-align: center;
    padding: 30px 15px;
    border-radius: 20px 20px 40px 40px;
    margin-bottom: 25px;
    box-shadow: 0 10px 30px rgba(44, 58, 80, 0.15);
}

.market-subtitle {
    font-size: 11px;
    letter-spacing: 2px;
    opacity: 0.7;
    margin-bottom: 8px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
}

.market-title {
    font-size: 24px;
    font-weight: 800;
    margin: 0;
    font-family: 'Noto Serif TC', serif;
}

.market-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    /* 2xN 佈局 */
    gap: 15px;
    padding: 0 4px 30px;
    /* 配合 app-container 的 padding */
}

.market-card {
    background: var(--card-bg);
    border: 1.5px solid var(--accent-gold);
    /* 使用全域金邊變數 */
    border-radius: 20px;
    padding: 22px 10px;
    text-align: center;
    box-shadow: var(--shadow-soft);
    transition: var(--transition-smooth);
}

.market-card:active {
    transform: scale(0.97);
}

.card-label {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
}

.market-val {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-navy);
    margin-bottom: 4px;
}

.market-chg {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

/* 針對小螢幕裝置的優化 */
@media (max-width: 360px) {
    .market-grid {
        grid-template-columns: 1fr;
        /* 螢幕過窄時改為單欄顯示 */
    }
}

.cursor-default {
    cursor: default;
}

.mb-0 {
    margin-bottom: 0px !important;
}

.mt-10 {
    margin-top: 10px;
}

.pb-8 {
    padding-bottom: 8px;
}

.pb-12 {
    padding-bottom: 12px;
}

.align-center {
    align-items: center;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.flex-nowrap {
    flex-wrap: nowrap;
}

.flex-07 {
    flex: 0.7;
}

.flex-11 {
    flex: 1.1;
}

.hero-amount-large {
    font-size: 38px;
    margin-bottom: 8px;
}

.currency-mid {
    font-size: 20px;
}

.empty-state {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
    font-size: 13px;
}

.chart-empty {
    text-align: center;
    padding: 50px 0;
    color: var(--text-muted);
    font-size: 13px;
}

.tx-deleted {
    opacity: 0.4;
    text-decoration: line-through;
}

.tx-added-text {
    color: var(--down-green);
    font-weight: 700;
}

.tx-deleted-text {
    color: var(--up-red);
    font-weight: 700;
}

.symbol-mini {
    font-size: 9px;
    font-weight: 600;
}

/* =========================================
   新聞頁面專屬樣式
========================================= */

#news-content {
    padding: 15px;
}

/* 頂部 Hero 區塊 */
.news-hero {
    display: flex;
    align-items: center;
    background-color: #F8F5FB; /* 淡紫色背景 */
    padding: 20px 15px;
    gap: 15px;
    margin-bottom: 0;
    border-radius: 8px 8px 0 0; /* 讓頂部微圓角 */
}

.news-hero-img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.news-hero-text {
    flex: 1;
}

.news-hero-title {
    font-size: 16px;
    font-weight: 800;
    color: #2C2C2C;
    margin-bottom: 8px;
    line-height: 1.3;
}

.news-hero-subtitle {
    font-size: 10px;
    color: #777;
    margin-bottom: 10px;
}

.news-social-icons i {
    font-size: 12px;
    margin-right: 8px;
    color: #555;
    cursor: pointer;
}

/* 雙色分隔線 */
.news-divider {
    display: flex;
    height: 6px;
    margin-bottom: 20px;
}

.news-divider-yellow {
    background-color: #F3C95A;
    flex: 3; /* 比例佔多數 */
}

.news-divider-purple {
    background-color: #52319A;
    flex: 1; /* 比例佔少數 */
}

/* 新聞卡片列表 */
.news-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-bottom: 60px; /* 留白避免貼底 */
}

.news-card {
    border: 2px solid #E0E0E0;
    padding: 15px 15px 10px 15px;
    background: #FFF;
    border-radius: 2px;
}

.news-card-title {
    font-size: 22px;
    font-weight: 900;
    color: #666;
    margin-bottom: 2px;
    letter-spacing: 2px;
}

.news-card-tag {
    font-size: 9px;
    color: #999;
    letter-spacing: 1px;
    display: block;
    margin-bottom: 20px;
}

.news-card-content {
    font-size: 15px;
    font-weight: 600;
    color: #555;
    margin-bottom: 25px;
}

.news-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.news-card-date {
    font-size: 10px;
    color: #999;
}

.news-card-link {
    font-size: 12px;
    font-weight: bold;
    color: #333;
    text-decoration: none;
}

.news-card-link:hover {
    color: #F3C95A;
}

.app-container {
    position: relative; /* 確保內部絕對定位基準點正確 */
}

.global-refresh-btn {
    position: absolute;
    top: 40px;    /* 距離頂部的高度，可依喜好微調 */
    right: 35px;  /* 距離右側的寬度 */
    z-index: 99;  /* 確保永遠顯示在最上層 */
    color: #c5aa798d; /* 指揮中心專屬金 */
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    transition: opacity 0.1s;
}

.global-refresh-btn:active {
    opacity: 0.5; /* 點擊時的視覺回饋 */
}

/* 讀取時的旋轉動畫 */
#syncBtn.spin {
    animation: spin-anim 0.5s linear infinite;
}

@keyframes spin-anim {
    100% { transform: rotate(360deg); }
}