html {
    scroll-behavior: smooth;
}

/* --- CSS Variables for Theme Colors --- */
:root {
    --primary-color: #0095ff;
    --secondary-color: #f4faff;
    --background-color: #f6fbff;
    --heading-color: #005b98;
    --text-color: #494949;
    --border-color: #002b47;
    --font-main: 'Montserrat', sans-serif;
}

.sticky-navbar {
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar {
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 10px 20px 10px 100px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-link {
    color: var(--text-color);
    text-decoration: none;
    margin: 0 10px;
    font-size: 1.1rem;
    transition: color 0.2s ease;
}

.nav-link:hover {
    color: var(--primary-color);
}

.nav-col {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 25px;
}

.secondary-navbar {
    background: var(--secondary-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 10px 20px 10px 100px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 20px;
}

.secondary-navbar ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: left;
    gap: 10px;
}

.secondary-navbar a {
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 5px 10px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: color 0.2s ease, border-bottom 0.2s ease;
}

.secondary-navbar a:hover {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
}

.aii-logo {
    height: 40px;
    margin-right: 10px;
    text-decoration: none;
    vertical-align: middle;
    font-size: 22px;
}

/* --- General Styles --- */
body {
    font-family: var(--font-main);
    color: var(--text-color);
    background-color: var(--background-color);
    margin: 0;
    padding: 0;
}

h1 {
    margin-top: 0;
}

h2 {
    text-align: center;
    font-size: 2rem;
    font-weight: 600;
    color: var(--heading-color);
    margin-top: 0;
    margin-bottom: 10px;
}

/* --- Layout Components --- */
.section-card {
    padding: 20px;
    background-color: white;
    margin: 30px 50px;
    border-radius: 20px;
    scroll-margin-top: 120px ;
    box-shadow: 0 0 16px rgba(0,0,0,0.1);
}

.sub-section-card {
    padding: 5px 20px;
    min-width: 300px;
    background-color: white;
    margin: 10px 0;
    position: relative;
    border-radius: 20px;
    box-shadow: 0 0 16px rgba(0,0,0,0.1);
}

.section-content {
    position: relative;
}

/* --- Button Styles --- */
.button-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
}

.styled-button {
    text-decoration: none;
    background-color: var(--primary-color);
    color: #fff;
    border: 1px solid var(--primary-color);
    border-radius: 25px;
    padding: 8px 20px;
    font-family: var(--font-main);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(0,149,255,0.08);
    transition: background 0.2s, color 0.2s, box-shadow 0.2s, transform 0.2s, border 0.2s;
}

.styled-button:hover {
    background-color: #fff;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 0 10px rgba(0, 149, 255, 0.3);
    transform: translateY(0) scale(1.03);
    outline: none;
}

.styled-button-secondary {
    text-decoration: none;
    background-color: white;
    color: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.5);
    border-radius: 25px;
    padding: 8px 20px;
    font-family: var(--font-main);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(0,149,255,0.08);
    transition: color 0.2s ease, box-shadow 0.2s ease, border 0.2s ease;
}

.styled-button-secondary:hover {
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    box-shadow: 0 0 10px rgba(0, 149, 255, 0.3);
    outline: none;
}

@media (max-width: 600px) {
    .styled-button {
        width: 100%;
        padding: 12px 0;
        font-size: 1.1rem;
    }
}

.alert-warning {
    color: var(--text-color);
    margin-top: 20px;
    text-align: center;
}

/* --- Input Styles --- */
.input-card {
    border: 2px solid var(--primary-color);
    border-radius: 25px;
    background: var(--secondary-color);
    color: var(--text-color);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, border-radius 0.2s;
    box-shadow: 0 0 8px rgba(0,149,255,0.08);
}

.input-card:focus {
    border-color: var(--border-color);
    box-shadow: 0 0 16px rgba(0,149,255,0.15);
}

.input-card::placeholder {
    color: #b3d7f7;
    font-style: italic;
    letter-spacing: 1px;
}

/* --- Auth Pages Styles --- */
.auth-container {
    max-width: 550px;
    margin: 0 auto;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-color);
    margin-bottom: 30px;
}

.auth-form-group {
    margin-bottom: 20px;
}

.auth-form-label {
    display: block;
    margin-bottom: 8px;
    color: var(--heading-color);
    font-weight: 500;
}

.auth-form-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    box-sizing: border-box;
}

.auth-form-error {
    color: #e74c3c;
    font-size: 0.85rem;
    margin-top: 5px;
}

.auth-form-error-center {
    color: #e74c3c;
    font-size: 0.85rem;
    margin-bottom: 20px;
    text-align: center;
}

.auth-form-help {
    font-size: 0.8rem;
    color: var(--text-color);
    margin-top: 5px;
    opacity: 0.8;
    line-height: 1.4;
}

.auth-form-help ul {
    margin: 5px 0;
    padding-left: 20px;
}

.auth-form-help li {
    margin: 2px 0;
}

.auth-checkbox-container {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-color);
}

.auth-checkbox-container span {
    margin-left: 8px;
}

.auth-checkbox-container input[type="checkbox"] {
    accent-color: var(--primary-color);
    margin-right: 8px;
}

.auth-button {
    padding: 12px 16px;
}

.auth-divider {
    position: relative;
    margin: 30px 0;
    text-align: center;
}

.auth-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(0, 149, 255, 0.2);
}

.auth-divider span {
    background: white;
    padding: 0 20px;
    color: var(--text-color);
    font-size: 0.9rem;
}

.auth-google-button {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    background: white;
    color: var(--text-color);
    border: 2px solid #e0e0e0;
    text-decoration: none;
}

.auth-google-icon {
    width: 20px;
    height: 20px;
    margin-right: 12px;
}

.auth-section-bottom {
    margin-bottom: 30px;
}

.auth-footer {
    text-align: center;
    margin-top: 30px;
}

.auth-footer p {
    margin: 10px 0;
    color: var(--text-color);
    font-size: 0.9rem;
}

.auth-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

/* --- Social Account Styles --- */
.social-account-info {
    background: var(--secondary-color);
    border: 2px solid rgba(0, 149, 255, 0.2);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
}

.provider-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.provider-details {
    flex: 1;
}

.provider-details strong {
    color: var(--heading-color);
    font-size: 1rem;
    display: block;
    margin-bottom: 4px;
}

.provider-email {
    color: var(--text-color);
    font-size: 0.9rem;
    opacity: 0.8;
}

/* --- Dropdown Menu Styles --- */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
}

.dropdown-toggle::after {
    content: '▼';
    font-size: 0.7rem;
    margin-left: 5px;
    transition: transform 0.2s ease;
}

.dropdown:hover .dropdown-toggle::after {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    padding: 10px 0;
    min-width: 180px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 149, 255, 0.1);
}

.dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: block;
    padding: 12px 20px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border-radius: 0;
}

.dropdown-item:hover {
    background-color: var(--secondary-color);
    color: var(--primary-color);
    padding-left: 25px;
}

.dropdown-item:first-child {
    border-top-left-radius: 15px;
    border-top-right-radius: 15px;
}

.dropdown-item:last-child {
    border-bottom-left-radius: 15px;
    border-bottom-right-radius: 15px;
}

/* --- Search Functionality --- */
.search-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 50px 20px;
}

.search-wrapper {
    position: relative;
    width: 100%;
    max-width: 600px;
}

.home-search {
    width: 100%;
    padding: 12px 80px 12px 16px;
    font-size: 16px;
}

.home-search:focus {
    border-radius: 25px 25px 0 0 !important;
}

.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid var(--primary-color);
    border-top: none;
    border-radius: 0 0 20px 20px;
    box-shadow: 0 4px 16px rgba(0, 149, 255, 0.15);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
}

.search-dropdown:empty {
    display: none;
}

/* Hide dropdown when search input is not focused */
.home-search:not(:focus) + .htmx-indicator + .search-dropdown {
    display: none !important;
}

/* Show dropdown only when search input is focused */
.home-search:focus + .htmx-indicator + .search-dropdown {
    display: block !important;
}

.search-placeholder {
    padding: 12px;
    text-align: center;
    color: var(--text-color);
    font-style: italic;
    background-color: var(--secondary-color);
}

/* --- Navbar Search --- */
.navbar-search-wrapper {
    position: relative;
    width: 300px;
    flex-shrink: 0;
}

.navbar-search {
    width: 100%;
    padding: 8px 40px 8px 12px;
    font-size: 14px;
    border: 2px solid var(--primary-color);
    border-radius: 20px;
    outline: none;
    transition: all 0.3s ease;
    background-color: var(--secondary-color);
}

.navbar-search:focus {
    border-radius: 20px 20px 0 0 !important;
    background-color: white;
    box-shadow: 0 2px 8px rgba(0, 149, 255, 0.2);
}

.navbar-search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid var(--primary-color);
    border-top: none;
    border-radius: 0 0 20px 20px;
    box-shadow: 0 4px 16px rgba(0, 149, 255, 0.15);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
}

.navbar-search-dropdown:empty {
    display: none;
}

/* Hide dropdown when search input is not focused */
.navbar-search:not(:focus) + .htmx-indicator + .navbar-search-dropdown {
    display: none !important;
}

/* Show dropdown only when search input is focused */
.navbar-search:focus + .htmx-indicator + .navbar-search-dropdown {
    display: block !important;
}

/* search dropdown style */
.dropdown-item {
    display: block;
    padding: 12px 16px;
    color: var(--text-color);
    transition: all 0.3s ease;
    border-bottom: 1px solid rgba(0, 149, 255, 0.1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    border-left: 3px solid transparent;
}

.dropdown-item::before {
    content: '';
    position: absolute;
    left: -100%;
    top: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 149, 255, 0.1), transparent);
    transition: left 0.5s ease;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover,
.dropdown-item:focus,
.dropdown-item.keyboard-selected {
    background-color: var(--secondary-color);
    color: var(--heading-color);
    box-shadow: 0 2px 8px rgba(0, 149, 255, 0.15);
    border-left: 3px solid var(--primary-color);
    padding-left: 18px;
}

.dropdown-item:hover::before,
.dropdown-item:focus::before,
.dropdown-item.keyboard-selected::before {
    left: 100%;
}

.dropdown-item:active {
    transform: scale(0.98);
    transition: all 0.1s ease;
}

.dropdown-item .stock-name {
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    text-shadow: 0 0 0 transparent;
}

.dropdown-item:hover .stock-name,
.dropdown-item:focus .stock-name,
.dropdown-item.keyboard-selected .stock-name {
    text-shadow: 0.5px 0 0 currentColor;
}

/* --- Loading System --- */
.htmx-loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(0, 149, 255, 0.2);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spinner-spin 1s linear infinite;
    display: inline-block;
    margin-right: 10px;
}

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

.htmx-loading-text {
    color: var(--primary-color);
    font-family: var(--font-main);
    font-size: 0.9rem;
    font-weight: 500;
}

.htmx-loading-container {
    display: none;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
    text-align: center;
}

.htmx-request .htmx-loading-container {
    display: flex !important;
}

.htmx-request .section-content > *:not(.htmx-loading-container) {
    display: none;
}

.htmx-indicator {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-color);
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.htmx-request .htmx-indicator {
    opacity: 1;
}

.details-header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.watchlist-button {
    margin: 0;
}

/* --- Stock Header --- */
.stock-header {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.stock-details {
    display: flex;
    justify-items: center;
    justify-content: center;
    align-items: center;
    align-content: center;
    margin-right: 10px;
}

/* --- Qualitative Analysis Tabs --- */
.qualitative-tabs {
    width: 100%;
}

.tab-input {
    display: none;
}

.tab-labels {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--secondary-color);
}

.tab-label {
    padding: 10px 20px;
    cursor: pointer;
    background-color: var(--secondary-color);
    color: var(--text-color);
    border-radius: 10px 10px 0 0;
    transition: all 0.3s ease;
    font-weight: 600;
}

.tab-label:hover {
    color: var(--primary-color);
    background-color: rgba(0, 149, 255, 0.1);
}

#tab-business:checked ~ .tab-labels label[for="tab-business"],
#tab-industry:checked ~ .tab-labels label[for="tab-industry"],
#tab-competitive:checked ~ .tab-labels label[for="tab-competitive"],
#tab-management:checked ~ .tab-labels label[for="tab-management"],
#tab-financials:checked ~ .tab-labels label[for="tab-financials"],
#tab-financials-chart:checked ~ .tab-labels label[for="tab-financials-chart"],
#tab-financials-annual:checked ~ .tab-labels label[for="tab-financials-annual"],
#tab-financials-chart-annual:checked ~ .tab-labels label[for="tab-financials-chart-annual"],
#tab-financials-quarterly:checked ~ .tab-labels label[for="tab-financials-quarterly"],
#tab-financials-chart-quarterly:checked ~ .tab-labels label[for="tab-financials-chart-quarterly"],
#tab-balance-financials:checked ~ .tab-labels label[for="tab-balance-financials"],
#tab-balance-chart:checked ~ .tab-labels label[for="tab-balance-chart"],
#tab-cashflow-financials:checked ~ .tab-labels label[for="tab-cashflow-financials"],
#tab-cashflow-chart:checked ~ .tab-labels label[for="tab-cashflow-chart"] {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
}

.tab-content-container {
    position: relative;
    min-height: 200px;
}

.tab-content {
    display: none; /* Hidden by default */
    animation: fadeIn 0.3s ease;
}

#tab-business:checked ~ .tab-content-container #content-business,
#tab-industry:checked ~ .tab-content-container #content-industry,
#tab-competitive:checked ~ .tab-content-container #content-competitive,
#tab-management:checked ~ .tab-content-container #content-management,
#tab-financials:checked ~ .tab-content-container #content-financials,
#tab-financials-chart:checked ~ .tab-content-container #content-financials-chart,
#tab-financials-annual:checked ~ .tab-content-container #content-financials-annual,
#tab-financials-chart-annual:checked ~ .tab-content-container #content-financials-chart-annual,
#tab-financials-quarterly:checked ~ .tab-content-container #content-financials-quarterly,
#tab-financials-chart-quarterly:checked ~ .tab-content-container #content-financials-chart-quarterly,
#tab-balance-financials:checked ~ .tab-content-container #content-balance-financials,
#tab-balance-chart:checked ~ .tab-content-container #content-balance-chart,
#tab-cashflow-financials:checked ~ .tab-content-container #content-cashflow-financials,
#tab-cashflow-chart:checked ~ .tab-content-container #content-cashflow-chart {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.qualitative-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.qualitative-list li {
    padding: 15px;
    margin-bottom: 10px;
    background-color: var(--secondary-color);
    border-radius: 10px;
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.2s ease;
}

.qualitative-list li:hover {
    background-color: rgba(0, 149, 255, 0.08);
}

.qualitative-list li:last-child {
    margin-bottom: 0;
}

/* 1. Highlight Active Label */
/* For Financials Tabs */
input[id*="tab-financials-annual"]:checked ~ .tab-labels label[for*="tab-financials-annual"],
input[id*="tab-financials-quarterly"]:checked ~ .tab-labels label[for*="tab-financials-quarterly"] {
    background-color: var(--primary-color);
    color: white;
}

/* For Chart Tabs */
input[id*="tab-financials-chart-annual"]:checked ~ .tab-labels label[for*="tab-financials-chart-annual"],
input[id*="tab-financials-chart-quarterly"]:checked ~ .tab-labels label[for*="tab-financials-chart-quarterly"] {
    background-color: var(--primary-color);
    color: white;
}

/* 2. CONTENT DISPLAY LOGIC */
input[id="tab-financials-annual"]:checked ~ .tab-content-container #content-financials-annual { display: block; }
input[id="tab-financials-chart-annual"]:checked ~ .tab-content-container #content-financials-chart-annual { display: block; }

input[id="tab-financials-quarterly"]:checked ~ .tab-content-container #content-financials-quarterly { display: block; }
input[id="tab-financials-chart-quarterly"]:checked ~ .tab-content-container #content-financials-chart-quarterly { display: block; }

/* --- Stats Grid Styles --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-top: 20px;
}

.stat-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    background: var(--secondary-color);
    border: 2px solid rgba(0, 149, 255, 0.15);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.stat-label {
    color: var(--text-color);
    font-weight: bold;
    opacity: 0.8;
}

.stat-value {
    color: var(--heading-color);
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

/* --- Plotly Chart Styling --- */
.updatemenu-button rect {
    fill: transparent !important;
}

.updatemenu-button text {
    fill: var(--text-color) !important;
    transition: fill 0.2s ease, font-size 0.2s ease, font-weight 0.2s ease;
}

.updatemenu-button:hover text {
    font-size: 18px !important;
}

.updatemenu-button:has(rect[style*="fill-opacity: 1"]) text {
    fill: var(--primary-color) !important;
    font-weight: bold !important;
}

/* --- Analysis Section --- */
.aii-analysis-container .section-content {
    display: flex;
    align-items: center;
    justify-content: center;
}

.aii-analysis-container #analysis-content {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.aii-analysis-container .button-container {
    margin: 0;
}

.aii-analysis-header {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
}

.ai-analysis-columns {
    display: flex;
    gap: 20px;
    margin: 0 5px;
}

.ai-analysis-columns > div {
    flex: 1;
}

.ai-analysis-columns ul {
    list-style-type: disc;
    padding-left: 20px;
}

.ai-analysis-columns ul li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.ai-analysis-columns ul li:last-child {
    margin-bottom: 0;
}

.ai-pros {
    border: 2px solid white;
    transition: border 0.2s ease;
}

.ai-pros:hover {
    border: 2px solid limegreen;
}

.ai-cons {
    border: 2px solid white;
    transition: border 0.2s ease;
}

.ai-cons:hover {
    border: 2px solid red;
}

.ai-summary {
    border: 2px solid white;
    transition: border 0.2s ease;
}

.ai-summary:hover {
    border: 2px solid var(--primary-color);
}

.ai-disclaimer {
    font-size: 0.8em;
    color: #777;
    position: absolute;
    bottom: 10px;
    right: 10px;
}

/* --- News Section --- */
.news-list {
    margin: 0;
}

.news-date {
    margin: 0;
    float: right;
    color: #777;
    font-size: 0.9em;
    font-style: italic;
}

.news-summary {
    margin: 5px 0 0 0;
}

.news-list li {
    overflow: hidden;
    margin-bottom: 15px;
}

/* --- Financial Tables --- */
.financial-table {
    width: 100%;
    border-collapse: collapse;
}

.financial-table thead {
    background: rgba(0,0,0,0.03);
}

.financial-table thead th {
    color: #777;
    padding: 10px 20px;
    text-align: left;
    font-weight: 600;
    border-radius: 8px 8px 0 0;
}

.financial-table thead th:not(:first-child) {
    text-align: right;
}

.financial-table tbody tr {
    background: white;
}

.financial-table tbody td {
    padding: 5px 20px;
}

.financial-table tbody:last-child tr:last-child td {
    border-radius: 0 0 8px 8px;
}

.financial-table tbody tr:nth-child(even) {
    background: rgba(0,0,0,0.03);
}

.financial-table tbody td:not(:first-child) {
    text-align: right;
}

.financial-table .total-row td {
    padding-top: 10px;
    padding-bottom: 10px;
    font-weight: bold;
}

.financial-table .total-row td:first-child {
    font-weight: bold;
}

/* --- Chart Controls --- */
.chart-controls {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    padding: 15px;
    background-color: rgba(0, 149, 255, 0.05);
    border-radius: 8px;
}

.chart-controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-color);
}

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

/* Force the Plotly graph to stay inside the container */
.financial-chart-container > div,
.js-plotly-plot,
.plot-container {
    width: 100% !important;
    max-width: 100% !important;
}

/* Ensure the container itself is centered and constrained */
.financial-chart-container {
    min-height: 300px;
    margin-bottom: 20px;
    width: 95%;
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
    display: block; /* Ensure it behaves as a block to respect margins */
}

/* --- Peer Comparison Styles --- */
.peer-comparison-table-wrapper {
    overflow-x: auto;
}

.peer-comparison-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
}

.peer-comparison-table thead {
    background: rgba(0,0,0,0.03);
    border-radius: 12px 12px 0 0;
    color: black;
}

.peer-comparison-table thead th {
    color: #777;
    padding: 12px 12px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

.peer-comparison-table thead th:first-child {
    border-top-left-radius: 12px;
}

.peer-comparison-table thead th:last-child {
    border-top-right-radius: 12px;
}

.peer-comparison-table tbody tr {
    border-bottom: 1px solid rgba(0, 149, 255, 0.1);
}

.peer-comparison-table tbody tr:nth-child(even) {
    background: rgba(0,0,0,0.03);
}

.peer-comparison-table tbody:last-child tr:last-child td {
    border-radius: 0 0 8px 8px;
}

.peer-comparison-table tbody td {
    padding: 10px 10px;
    white-space: nowrap;
}

.base-stock-row td {
    font-weight: 600;
}

.heading-link {
    margin: 0 10px 0 0;
    text-decoration: none;
    color: var(--heading-color);
    white-space: nowrap;
    transition: color 0.2s ease;
    align-self: center;
    display: inline-flex;
    align-items: center;
}

.heading-link:hover {
    color: var(--primary-color);
}

@media (max-width: 768px) {
    .peer-comparison-table {
        font-size: 0.85rem;
    }
    .peer-comparison-table thead th,
    .peer-comparison-table tbody td {
        padding: 10px 8px;
    }
}

/* Responsive dropdown for mobile */
@media (max-width: 768px) {
    .dropdown-menu {
        right: -10px;
        min-width: 160px;
    }

    .dropdown-item {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
}

/* --- Ratios Section --- */
.ratios-container {
    margin-top: 20px;
}

.ratio-section {
    margin-bottom: 40px;
}

.ratio-section:last-child {
    margin-bottom: 20px;
}

.section-heading {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--heading-color);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color);
}

/* Info Icon Tooltip Styling */
.info-icon {
    display: inline-block;
    margin-left: 5px;
    cursor: help;
    color: var(--primary-color);
    font-size: 0.9em;
    font-weight: bold;
    position: relative;
    transition: all 0.2s ease;
}

.info-icon:hover {
    color: var(--heading-color);
    transform: scale(1.2);
}

/* Custom tooltip styling for instant appearance */
.info-icon::after {
    content: attr(data-formula);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    padding: 8px 12px;
    background-color: rgba(0, 0, 0, 0.9);
    color: #fff;
    font-size: 0.85em;
    font-weight: normal;
    white-space: normal;
    max-width: 300px;
    min-width: 150px;
    width: max-content;
    border-radius: 6px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.1s ease, visibility 0.1s ease;
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    text-align: center;
    line-height: 1.4;
}

/* Tooltip arrow */
.info-icon::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 2px;
    border: 6px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.1s ease, visibility 0.1s ease;
    pointer-events: none;
    z-index: 1000;
}

.info-icon:hover::after,
.info-icon:hover::before {
    opacity: 1;
    visibility: visible;
}

/* --- Shareholding Section --- */
.shareholding-container {
    /*display: grid;*/
    /*grid-template-columns: 1fr 1fr;*/
    /*gap: 30px;*/
    padding: 10px;
}

.sub-heading {
    font-size: 1.1rem;
    color: var(--heading-color);
    margin-bottom: 15px;
    border-left: 4px solid var(--primary-color);
    padding-left: 10px;
}

.holdings-summary {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.holding-card {
    background: var(--secondary-color);
    padding: 10px 15px;
    border-radius: 10px;
    text-align: center;
    flex: 1;
}

.holding-card .label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-color);
    margin-bottom: 5px;
}

.holding-card .value {
    font-weight: bold;
    color: var(--heading-color);
}

.small-table {
    font-size: 0.9rem;
}

.small-table td, .small-table th {
    padding: 8px 10px;
}

@media (max-width: 768px) {
    .shareholding-container {
        grid-template-columns: 1fr; /* Stack on mobile */
    }
}

/* --- Valuation Section --- */
/* Valuation Split Container */
.valuation-split-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 10px;
}

.valuation-section {
    padding: 15px;
    background: var(--secondary-color);
    border-radius: 12px;
    border: 1px solid rgba(0, 149, 255, 0.1);
}

.graham-section {
    border-left: 4px solid #2ECC40;
}

.dcf-section {
    border-left: 4px solid var(--primary-color);
}

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

.valuation-badge {
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9rem;
    color: white;
}

.valuation-badge.green {
    background-color: #2ECC40; /* Green */
}

.valuation-badge.red {
    background-color: #FF4136; /* Red */
}

.valuation-badge.grey {
    background-color: #999;
}

.valuation-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 15px;
}

.dcf-grid {
    grid-template-columns: 1fr 1fr;
}

.val-card {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid rgba(0, 149, 255, 0.1);
}

.val-card.main-result {
    background: rgba(0, 149, 255, 0.1);
    border: 2px solid var(--primary-color);
}

.val-card.full-width {
    grid-column: 1 / -1;
}

.val-label {
    font-size: 0.85rem;
    color: var(--text-color);
    margin-bottom: 8px;
    opacity: 0.8;
}

.val-value {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--heading-color);
}

.val-input-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 5px;
}

.growth-rate-input {
    width: 80px;
    padding: 8px 12px;
    border: 1px solid rgba(0, 149, 255, 0.3);
    border-radius: 6px;
    background: var(--background-color);
    color: var(--text-color);
    font-size: 1rem;
    text-align: center;
}

.growth-rate-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 149, 255, 0.1);
}

.val-input-suffix {
    font-size: 1rem;
    font-weight: bold;
    color: var(--text-color);
}

.btn-recalculate {
    padding: 8px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.3s ease;
}

.btn-recalculate:hover {
    background: #0078cc;
}

.val-note {
    font-size: 0.85rem;
    color: #777;
    margin-top: 10px;
    font-style: italic;
}

@media (max-width: 1024px) {
    .valuation-split-container {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

@media (max-width: 768px) {
    .valuation-grid {
        grid-template-columns: 1fr;
    }

    .val-input-container {
        flex-direction: column;
        gap: 8px;
    }

    .growth-rate-input {
        width: 100%;
    }

    .btn-recalculate {
        width: 100%;
    }
}
