/* ============================================
   Code 33 Analysis Tool - Styles
   Premium Dark Mode Design
   ============================================ */

/* CSS Variables */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a25;
    --bg-card-hover: #22222f;
    --border-color: rgba(255, 255, 255, 0.08);

    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #6b6b7a;

    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);

    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.15);

    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* Reset & Base */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(99, 102, 241, 0.15), transparent),
        radial-gradient(ellipse 60% 40% at 100% 0%, rgba(139, 92, 246, 0.1), transparent),
        var(--bg-primary);
}

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 10, 15, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 1.75rem;
    filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.5));
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    padding-left: 0.75rem;
    border-left: 1px solid var(--border-color);
}

.nav {
    display: flex;
    gap: 0.5rem;
}

.nav-link {
    padding: 0.5rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.nav-link:hover,
.nav-link.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
}

/* Search Section */
.search-section {
    text-align: center;
    margin-bottom: 3rem;
}

.search-container {
    position: relative;
    max-width: 500px;
    margin: 0 auto;
}

.search-box {
    display: flex;
    gap: 0.75rem;
    padding: 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md), var(--shadow-glow);
    transition: all var(--transition-normal);
}

.search-box:focus-within {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-lg), 0 0 60px rgba(99, 102, 241, 0.2);
}

.search-input {
    flex: 1;
    padding: 1rem 1.5rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.125rem;
    font-weight: 500;
    outline: none;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-lg);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.search-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.search-btn:active {
    transform: translateY(0);
}

.search-icon {
    font-size: 1.125rem;
}

.search-hint {
    margin-top: 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Suggestions Dropdown */
.suggestions {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 50;
}

.suggestion-item {
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.suggestion-item:hover {
    background: var(--bg-card-hover);
}

.suggestion-id {
    font-weight: 600;
    color: var(--accent-primary);
}

.suggestion-name {
    color: var(--text-primary);
}

.suggestion-industry {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Loading State */
.loading-section {
    text-align: center;
    padding: 4rem 2rem;
}

.loader {
    width: 60px;
    height: 60px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    margin: 0 auto 1.5rem;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Results Section */
.results-section {
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stock Info Card */
.stock-info-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
}

.stock-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stock-title {
    display: flex;
    align-items: baseline;
    gap: 1rem;
}

.stock-id {
    font-size: 1rem;
    color: var(--accent-primary);
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    background: rgba(99, 102, 241, 0.1);
    border-radius: var(--radius-sm);
}

.stock-name {
    font-size: 1.75rem;
    font-weight: 700;
}

.stock-industry,
.detail-badge {
    font-size: 0.875rem;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    display: inline-block;
}

.detail-badge.market-cap {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.stock-details {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* Score Card */
.score-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.score-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.score-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.score-status {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
}

.score-status.perfect {
    background: var(--success-bg);
    color: var(--success);
}

.score-status.strong {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.score-status.moderate {
    background: var(--warning-bg);
    color: var(--warning);
}

.score-status.weak {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.score-status.fail {
    background: var(--danger-bg);
    color: var(--danger);
}

.score-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.score-circle {
    position: relative;
    width: 160px;
    height: 160px;
}

.score-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.score-ring-bg {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 8;
}

.score-ring-fill {
    fill: none;
    stroke: url(#scoreGradient);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s ease;
}

.score-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

#scoreNumber {
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.score-max {
    font-size: 1rem;
    color: var(--text-muted);
}

.score-message {
    font-size: 1.125rem;
    color: var(--text-secondary);
}

.recommendations {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    text-align: left;
    max-width: 500px;
    margin: 0 auto;
}

.recommendation-item {
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Expected Values Card */
.expected-card {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.05) 100%);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: var(--radius-lg);
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
}

.expected-header {
    margin-bottom: 1.5rem;
}

.expected-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.expected-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.5rem;
}

.expected-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.expected-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.expected-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.expected-range {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.recommendation-badge {
    font-size: 1rem !important;
    padding: 0.25rem 0.75rem;
    background: var(--success-bg);
    color: var(--success);
    border-radius: var(--radius-sm);
    display: inline-block;
}

.recommendation-badge.buy {
    background: var(--success-bg);
    color: var(--success);
}

.recommendation-badge.hold {
    background: var(--warning-bg);
    color: var(--warning);
}

.recommendation-badge.sell {
    background: var(--danger-bg);
    color: var(--danger);
}

/* Criteria Grid */
.criteria-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.criteria-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: all var(--transition-normal);
}

.criteria-card:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.criteria-card.accelerating {
    border-color: var(--success);
}

.criteria-card.not-accelerating {
    border-color: var(--warning);
}

.criteria-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.criteria-header h4 {
    font-size: 1rem;
    font-weight: 600;
}

.accel-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.accel-badge.accelerating {
    background: var(--success-bg);
    color: var(--success);
}

.accel-badge.not-accelerating {
    background: var(--warning-bg);
    color: var(--warning);
}

.accel-badge.good {
    background: var(--success-bg);
    color: var(--success);
}

.accel-badge.bad {
    background: var(--danger-bg);
    color: var(--danger);
}

.criteria-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 1rem;
}

.criteria-value {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
}

.value-main {
    font-size: 2rem;
    font-weight: 700;
}

.value-main.positive {
    color: var(--success);
}

.value-main.negative {
    color: var(--danger);
}

.value-unit {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.criteria-score {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.criteria-chart {
    height: 80px;
    margin-top: 0.5rem;
}

.roe-threshold {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Data Table */
.data-table-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.table-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
}

.table-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 1rem 1.5rem;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table th:first-child,
.data-table td:first-child {
    text-align: left;
}

.data-table tbody tr:hover {
    background: var(--bg-card-hover);
}

.data-table td.positive,
.positive {
    color: var(--success);
}

.data-table td.negative,
.negative {
    color: var(--danger);
}

/* Momentum Table */
.momentum-card {
    margin-bottom: 2rem;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.table-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.momentum-table tr.expected-row {
    background: rgba(99, 102, 241, 0.15) !important;
    border-left: 4px solid var(--accent-primary);
}

.momentum-table tr.expected-row td {
    font-weight: 600;
}

.momentum-table tr.expected-row td.positive {
    color: var(--success) !important;
}

.momentum-table tr.expected-row td.negative {
    color: var(--danger) !important;
}

.momentum-table tr.expected-row .accel-positive {
    color: var(--success) !important;
}

.momentum-table tr.expected-row .accel-negative {
    color: var(--danger) !important;
}

.momentum-table th:nth-child(4),
.momentum-table th:nth-child(7),
.momentum-table td:nth-child(4),
.momentum-table td:nth-child(7) {
    background: rgba(255, 255, 255, 0.02);
    font-weight: 600;
}

.accel-positive {
    color: var(--success);
}

.accel-negative {
    color: var(--danger);
}

/* Error State */
.error-section {
    text-align: center;
    padding: 4rem 2rem;
}

.error-content {
    max-width: 400px;
    margin: 0 auto;
}

.error-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

.error-section p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.retry-btn {
    padding: 0.75rem 2rem;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.retry-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.disclaimer {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    opacity: 0.7;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        padding: 1rem;
    }

    .logo-subtitle {
        display: none;
    }

    .main-content {
        padding: 1rem;
    }

    .search-box {
        flex-direction: column;
    }

    .search-btn {
        width: 100%;
        justify-content: center;
    }

    .stock-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .criteria-grid {
        grid-template-columns: 1fr;
    }

    .score-header {
        flex-direction: column;
        gap: 1rem;
    }
}

/* Score Badge */
.score-badge {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    font-weight: 700;
}

/* Institutional Summary */
.inst-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.inst-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.inst-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.inst-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Surprise Coloring */
.surprise-positive {
    color: #10b981;
}

.surprise-negative {
    color: #ef4444;
}

/* Sparklines */
.inst-chart {
    height: 30px;
    width: 100%;
    margin-top: 0.25rem;
}

.inst-dates {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.sparkline-path {
    fill: none;
    stroke: var(--accent-primary);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: all 0.3s ease;
}

.sparkline-trust .sparkline-path {
    stroke: #10b981;
}

.sparkline-foreign .sparkline-path {
    stroke: #6366f1;
}

/* Tooltip & Interactivity */
.chart-tooltip {
    position: fixed;
    pointer-events: none;
    background: rgba(18, 18, 26, 0.95);
    border: 1px solid var(--accent-primary);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    transition: opacity 0.2s ease;
    display: none;
}

.chart-tooltip .tooltip-date {
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.chart-tooltip .tooltip-value {
    font-weight: 700;
    font-size: 0.9rem;
}

.hover-line {
    stroke: var(--text-muted);
    stroke-width: 1;
    stroke-dasharray: 2, 2;
}

.hover-point {
    fill: var(--accent-primary);
    stroke: white;
    stroke-width: 2;
}

.sparkline-trust .hover-point {
    fill: #10b981;
}

.sparkline-foreign .hover-point {
    fill: #6366f1;
}

.inst-chart svg {
    overflow: visible;
    cursor: crosshair;
}

/* ============================================
   Floating Widgets Container
   ============================================ */

.floating-widgets-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1000;
    align-items: flex-end;
}

/* ============================================
   Widget Title Truncation
   ============================================ */

.collapsed .tracker-en-title {
    display: none;
}

/* ============================================
   Fund Tracker Floating Widget
   ============================================ */

.fund-tracker-widget {
    width: 420px;
    max-height: 500px;
    background: var(--card-bg, #1e293b);
    border: 1px solid var(--border-color, #334155);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    transition: max-height 0.3s ease, width 0.3s ease;
    overflow: hidden;
}

.fund-tracker-widget.collapsed {
    max-height: 48px;
    width: 250px;
}

.fund-tracker-widget.collapsed .fund-tracker-body {
    display: none;
}

.fund-tracker-widget.collapsed .toggle-arrow {
    transform: rotate(180deg);
}

.fund-tracker-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: #e2e8f0;
    background: rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid var(--border-color, #334155);
    user-select: none;
    white-space: nowrap;
}

.fund-tracker-toggle:hover {
    background: rgba(0, 0, 0, 0.25);
}

.toggle-arrow {
    transition: transform 0.2s;
    font-size: 0.7rem;
}

.fund-tracker-body {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
}

.fund-search-section {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fund-search-input {
    flex: 1;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color, #334155);
    border-radius: 6px;
    color: #e2e8f0;
    font-size: 0.85rem;
    outline: none;
}

.fund-search-input:focus {
    border-color: #6366f1;
}

.fund-count {
    font-size: 0.75rem;
    color: #94a3b8;
    white-space: nowrap;
}

.fund-selection-list {
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.fund-selection-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
}

.fund-selection-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.fund-selection-item input[type="checkbox"] {
    accent-color: #6366f1;
    cursor: pointer;
}

.fund-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    cursor: pointer;
}

.fund-item-name {
    font-size: 0.8rem;
    color: #e2e8f0;
}

.fund-item-company {
    font-size: 0.7rem;
    color: #64748b;
}

.fund-clear-btn {
    align-self: flex-end;
    padding: 4px 10px;
    background: transparent;
    border: 1px solid #ef4444;
    color: #ef4444;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
}

.fund-clear-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

.loading-text {
    text-align: center;
    padding: 16px;
    color: #94a3b8;
    font-size: 0.85rem;
}

/* ============================================
   Fund Holdings Dashboard Card
   ============================================ */

.fund-holdings-card {
    background: var(--card-bg, #1e293b);
    border: 1px solid var(--border-color, #334155);
    border-radius: 12px;
    padding: 0;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.fund-holdings-card .table-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color, #334155);
}

.fund-holdings-list {
    max-height: 400px;
    overflow-y: auto;
}

.fund-holding-item {
    display: grid;
    grid-template-columns: 1fr 1.2fr auto;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.85rem;
}

.fund-holding-item:last-child {
    border-bottom: none;
}

.fund-holding-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.fund-name-col {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #e2e8f0;
    font-size: 0.82rem;
}

.fund-company-badge {
    font-size: 0.65rem;
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.fund-history-col {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: #94a3b8;
}

.fund-pct {
    color: #e2e8f0;
    font-weight: 500;
}

.fund-arrow {
    color: #64748b;
}

.fund-change-col {
    text-align: right;
    font-weight: 600;
    font-size: 0.85rem;
    min-width: 80px;
}

.fund-change-col.change-up {
    color: #ef4444;
}

.fund-change-col.change-down {
    color: #10b981;
}

.fund-change-col.change-none {
    color: #64748b;
}

/* Responsive: hide floating widget on mobile */
@media (max-width: 768px) {
    .fund-tracker-widget {
        width: calc(100vw - 20px);
        right: 10px;
        bottom: 10px;
    }

    .fund-holding-item {
        grid-template-columns: 1fr auto;
    }

    .fund-history-col {
        display: none;
    }
}

/* ============================================
   Estimate Revision Stars & Popup
   ============================================ */

.revision-star {
    cursor: pointer;
    font-size: 0.85rem;
    margin-left: 2px;
    transition: transform 0.15s;
    display: inline-block;
}

.revision-star:hover {
    transform: scale(1.3);
}

.revision-star.star-up {
    color: #ef4444;
    text-shadow: 0 0 4px rgba(239, 68, 68, 0.4);
}

.revision-star.star-down {
    color: #10b981;
    text-shadow: 0 0 4px rgba(16, 185, 129, 0.4);
}

.revision-popup-container {
    position: fixed;
    z-index: 2000;
    pointer-events: none;
}

.revision-popup {
    background: #1e293b;
    border: 1px solid #475569;
    border-radius: 8px;
    padding: 12px 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    max-width: 380px;
    min-width: 280px;
}

.revision-popup-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: #e2e8f0;
    margin-bottom: 8px;
    border-bottom: 1px solid #334155;
    padding-bottom: 6px;
}

.revision-popup-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.revision-popup-table th {
    text-align: left;
    color: #94a3b8;
    padding: 3px 6px;
    border-bottom: 1px solid #334155;
    font-weight: 500;
}

.revision-popup-table td {
    padding: 3px 6px;
    color: #cbd5e1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.revision-popup-table .positive {
    color: #ef4444;
}

.revision-popup-table .negative {
    color: #10b981;
}

.revision-popup-summary {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid #334155;
    font-size: 0.8rem;
    font-weight: 600;
}

.revision-popup-summary.positive {
    color: #ef4444;
}

.revision-popup-summary.negative {
    color: #10b981;
}

.revision-val-cell {
    white-space: nowrap;
}

.revision-arrow {
    color: #64748b;
    margin: 0 2px;
}

/* ============================================
   ETF Tracker Floating Widget
   ============================================ */

.etf-tracker-widget {
    width: 380px;
    background: var(--card-bg, #1e293b);
    border: 1px solid var(--border-color, #334155);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    transition: max-height 0.3s ease, width 0.3s ease;
    overflow: hidden;
}

.etf-tracker-widget.collapsed {
    max-height: 44px;
    width: 250px;
}

.etf-tracker-widget.collapsed .etf-tracker-body {
    display: none;
}

.etf-tracker-widget.collapsed .toggle-arrow {
    transform: rotate(180deg);
}

.etf-tracker-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: #e2e8f0;
    background: rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid var(--border-color, #334155);
    user-select: none;
    white-space: nowrap;
}

.etf-tracker-toggle:hover {
    background: rgba(0, 0, 0, 0.25);
}

.etf-tracker-body {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.etf-period-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.etf-period-buttons {
    display: flex;
    gap: 4px;
}

.etf-period-btn {
    background: var(--bg-color, #0f172a);
    border: 1px solid var(--border-color, #334155);
    color: var(--text-secondary, #94a3b8);
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.etf-period-btn:hover {
    background: var(--border-color, #334155);
    color: #fff;
}

.etf-period-btn.active {
    background: var(--primary-color, #3b82f6);
    color: #fff;
    border-color: var(--primary-color, #3b82f6);
}

.etf-holdings-list {
    flex: 1;
    overflow-y: auto;
    font-size: 0.85rem;
    max-height: 380px;
    padding-right: 4px;
}

.etf-holdings-list::-webkit-scrollbar {
    width: 6px;
}

.etf-holdings-list::-webkit-scrollbar-thumb {
    background: var(--border-color, #334155);
    border-radius: 3px;
}

.etf-holding-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.etf-holding-item:last-child {
    border-bottom: none;
}

.etf-item-info {
    display: flex;
    flex-direction: column;
}

.etf-item-code {
    font-weight: 600;
    color: #e2e8f0;
}

.etf-item-name {
    color: var(--text-secondary, #94a3b8);
    font-size: 0.8rem;
}

.etf-item-change {
    text-align: right;
    font-weight: 600;
}

.change-positive {
    color: #ef4444;
    /* red for TW market up */
}

.change-negative {
    color: #22c55e;
    /* green for TW market down */
}

.change-neutral {
    color: var(--text-secondary, #94a3b8);
}