:root {
    --bg-color: #ffffff;
    --bg-surface: #f8fafc;
    --card-bg: #1e3a8a;
    --text-primary: #ffffff;
    --text-secondary: #cbd5e1;
    --text-on-bg: #0f172a;
    --text-on-bg-sec: #475569;
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-green: #065f46;
    --accent-orange: #b45309;
    --accent-teal: #14b8a6;
    --border-color: rgba(255, 255, 255, 0.1);
    --border-hover: rgba(255, 255, 255, 0.2);
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.12);
    --shadow-hover: 0 16px 48px rgba(0, 0, 0, 0.24);
    --radius-card: 1rem;
    --radius-pill: 9999px;
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-on-bg);
    font-family: var(--font-family);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0;
}

#loginView, #companyView, #overviewView {
    padding: 0 1rem 1rem 1rem;
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
}

/* ── Navigation Bar ────────────────────────────────────────────────── */

#topNav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(30, 58, 138, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
    margin: 0 0 2rem 0;
    animation: fadeInDown 0.6s ease-out;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-brand {
    color: #ffffff;
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.nav-right {
    display: flex;
    align-items: center;
}

.hamburger {
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    height: 24px;
    width: 30px;
    padding: 0;
    z-index: 101;
}

.hamburger .bar {
    width: 30px;
    height: 3px;
    background-color: #ffffff;
    border-radius: 10px;
    transition: all 0.3s linear;
    transform-origin: 1px;
}

/* Dropdown Menu */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    width: 100%;
    margin-top: 0;
    background-color: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 5px;
    box-shadow: var(--shadow-hover);
    display: none; /* toggled via JS */
    flex-direction: column;
    z-index: 100;
    overflow: hidden;
}

.dropdown-menu.show {
    display: flex;
    animation: fadeIn 0.2s ease-out;
}

.nav-item {
    background-color: transparent;
    color: var(--text-on-bg);
    border: none;
    padding: 1.2rem 1.2rem;
    text-align: left;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
    outline: none;
    width: 100%;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

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

.nav-item:hover {
    background-color: #f8fafc; /* Subtle gray background */
    color: var(--card-bg); /* Dark blue text */
}

.nav-item.active {
    background-color: var(--bg-surface);
    color: var(--card-bg);
    font-weight: 800;
}

/* ── Login View ──────────────────────────────────────────────────── */

#loginView {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
}

.login-container {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-card);
    padding: 3rem 2.5rem;
    box-shadow: var(--shadow-hover);
    width: 100%;
    max-width: 420px;
    animation: fadeInUp 0.8s ease-out backwards;
}

.login-container h2 {
    font-size: 1.8rem;
    font-weight: 800;
    color: #1e3a8a;
    text-align: center;
    margin-bottom: 2rem;
    letter-spacing: -0.02em;
}

#loginForm {
    display: flex;
    flex-direction: column;
}

#loginForm input {
    width: 100%;
    padding: 0.9rem 1.2rem;
    margin-bottom: 1.25rem;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 0.5rem;
    font-size: 1rem;
    color: var(--text-on-bg);
    background-color: var(--bg-surface);
    outline: none;
    transition: all var(--transition-fast);
}

#loginForm input::placeholder {
    color: var(--text-on-bg-sec);
    opacity: 0.7;
}

#loginForm input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    background-color: #ffffff;
}

#loginForm button {
    width: 100%;
    padding: 1rem;
    background-color: var(--card-bg);
    color: #ffffff;
    border: none;
    border-radius: 0.5rem;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-top: 0.5rem;
}

#loginForm button:hover {
    background-color: #172554;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(23, 37, 84, 0.3);
}

#loginForm button:active {
    transform: translateY(0);
}


.active-ticker-display {
    text-align: center;
    margin-bottom: 1.7rem;
    animation: fadeInDown 0.8s ease-out;
}

#currentTickerDisplay {
    font-size: 2rem;
    font-weight: 800;
    color: #1e3a8a;
    letter-spacing: 0.02em;
}

.ticker-search-container {
    position: relative;
    text-align: center;
    margin: 0 auto 1.5rem auto;
    width: 100%;
    max-width: 100%;
    animation: fadeIn 1s ease-out;
}

.ticker-search-input {
    width: 100%;
    padding: 0.8rem 1.2rem;
    font-size: 1.05rem;
    font-weight: 500;
    color: #0f172a;
    background-color: #ffffff;
    border: 1px solid rgba(59, 130, 246, 0.4);
    border-radius: 5px;
    outline: none;
    transition: all var(--transition-normal);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.ticker-search-input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.ticker-search-input:focus {
    background-color: #ffffff;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.ticker-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 250px;
    overflow-y: auto;
    background-color: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 5px;
    box-shadow: var(--shadow-hover);
    z-index: 1000;
    text-align: left;
}

.ticker-dropdown-item {
    padding: 1.2rem 1.2rem;
    font-size: 1rem;
    font-weight: 500;
    color: #0f172a;
    cursor: pointer;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

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

.ticker-dropdown-item:hover {
    background-color: #f8fafc; /* Subtle gray background */
    color: var(--card-bg); /* Dark blue text */
}

.ticker-dropdown-item .ticker-symbol {
    font-weight: 700;
    margin-right: 0.5rem;
    color: var(--card-bg);
}

/* ── Status Bar ──────────────────────────────────────────────────── */

.status-bar {
    text-align: center;
    padding: 0;
    font-size: 0.9rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    border-radius: 0.5rem;
    transition: all var(--transition-normal);
    overflow: hidden;
    max-height: 0;
}

.status-bar.visible {
    padding: 0.75rem 1.25rem;
    max-height: 60px;
}

.status-bar.success {
    color: var(--accent-green);
    background: rgba(6, 95, 70, 0.1);
    border: 1px solid rgba(6, 95, 70, 0.2);
}

.status-bar.info {
    color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.status-bar.error {
    color: #991b1b;
    background: rgba(153, 27, 27, 0.1);
    border: 1px solid rgba(153, 27, 27, 0.2);
}

/* ── Error Message ───────────────────────────────────────────────── */

.error-msg {
    text-align: center;
    color: #991b1b;
    background: rgba(153, 27, 27, 0.08);
    border: 1px solid rgba(153, 27, 27, 0.15);
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 2rem;
    display: none;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    font-size: 0.9rem;
}

/* ── Loading ─────────────────────────────────────────────────────── */

.loading {
    display: none;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    text-align: center;
    color: var(--text-on-bg-sec);
    padding: 2rem;
    font-size: 0.95rem;
}

.loading.visible {
    display: flex;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ── Sync Button Spinner ─────────────────────────────────────────── */

.sync-spinning {
    display: inline-block;
    animation: spin 1s linear infinite;
}

/* ── AI Context Grid ─────────────────────────────────────────────── */

.ai-context-container {
    min-width: 0;
}

.section-title {
    font-size: 1.2rem;
    color: #1e3a8a;
    margin-bottom: 1rem;
}

.ai-context-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.context-card {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-card);
    padding: 1.2rem;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.context-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.context-header h3 {
    font-size: 1.15rem;
    font-weight: 600;
    color: #1e3a8a;
    letter-spacing: -0.01em;
}

.eval-badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-pill);
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-on-bg-sec);
    font-weight: 600;
}

.context-chart-wrapper {
    position: relative;
    height: 140px;
    width: 100%;
    margin-top: auto;
}

/* ── Dashboard Grid ──────────────────────────────────────────────── */

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    min-width: 0;
}

/* ── Overview Card ───────────────────────────────────────────────── */

.overview-card {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-card);
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-card);
    grid-column: 1 / -1;
    animation: fadeInUp 0.8s ease-out backwards;
    min-width: 0;
}

.overview-card h3 {
    font-size: 1.15rem;
    font-weight: 600;
    color: #1e3a8a;
    margin-bottom: 1rem;
    letter-spacing: -0.01em;
}

.overview-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
}

.overview-item {
    display: flex;
    justify-content: space-between;
    padding: 0.6rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    font-size: 0.95rem;
    min-width: 0;
}

.overview-item:first-child {
    padding-top: 0;
}

.overview-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.overview-item span {
    color: #475569;
    font-weight: 500;
}

.overview-item strong {
    font-weight: 600;
}


/* ── No Data State ───────────────────────────────────────────────── */

.no-data {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 280px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    opacity: 0.6;
}

/* ── Footer ──────────────────────────────────────────────────────── */

.ticker-meta {
    text-align: center;
    color: var(--text-on-bg-sec);
    font-size: 0.8rem;
    opacity: 0.8;
    margin-top: 0.25rem;
}


/* ── Report View ─────────────────────────────────────────────────── */

.report-container {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-card);
    padding: 1.25rem;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow-card);
    animation: fadeInUp 0.8s ease-out backwards;
    min-width: 0;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.supervisor-report h2 {
    color: #1e3a8a;
    margin-bottom: 1rem;
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.supervisor-report h3 {
    color: #1e3a8a;
    margin-top: 1.25rem;
    margin-bottom: 1rem;
    font-size: 1.05rem;
    font-weight: 600;
}

.supervisor-report p {
    line-height: 1.5;
    margin-bottom: 0.5rem;
    color: #000000;
}

.supervisor-report ul {
    list-style-type: disc;
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

.supervisor-report li {
    margin-bottom: 0.5rem;
    line-height: 1.5;
    color: #000000;
}

.supervisor-report hr {
    border: 0;
    height: 1px;
    background: var(--border-color);
    margin: 1rem 0;
}

.report-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: right;
    margin-bottom: 0;
}


/* ── Keyframes ───────────────────────────────────────────────────── */

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Metrics Explanation Box ─────────────────────────────────────── */

.metrics-explanation-card {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-card);
    padding: 1.5rem 1.5rem 0.5rem 1.5rem;
    box-shadow: var(--shadow-card);
    grid-column: 1 / -1;
    animation: fadeInUp 0.8s ease-out backwards;
    min-width: 0;
}

.metrics-explanation-card h3 {
    font-size: 1.15rem;
    font-weight: 600;
    color: #1e3a8a;
    margin-bottom: 1.25rem;
    letter-spacing: -0.01em;
}

.metrics-explanation-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.explanation-item h4 {
    font-size: 1rem;
    color: #0f172a;
    margin-bottom: 0.5rem;
}

.explanation-item p {
    font-size: 0.85rem;
    color: #475569;
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.explanation-item ul {
    list-style-type: none;
    padding: 0;
    font-size: 0.85rem;
}

.explanation-item li {
    margin-bottom: 0.5rem;
    color: #0f172a;
    line-height: 1.3;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.text-dark-green {
    color: #065f46 !important;
    font-weight: 600;
}

.text-dark-orange {
    color: #b45309 !important;
    font-weight: 600;
}

.text-dark-red {
    color: #991b1b !important;
    font-weight: 600;
}

/* ── Insider Transactions Box ────────────────────────────────────── */

.insider-transactions-card {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-card);
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    grid-column: 1 / -1;
    animation: fadeInUp 0.8s ease-out backwards;
    min-width: 0;
}

.insider-transactions-card h3 {
    font-size: 1.15rem;
    font-weight: 600;
    color: #1e3a8a;
    margin-bottom: 1.25rem;
    letter-spacing: -0.01em;
}

.insider-transactions-table-wrapper {
    overflow-x: auto;
}

.insider-transactions-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    color: #0f172a;
}

.insider-transactions-table th,
.insider-transactions-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.insider-transactions-table th {
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
    background: #f8fafc;
}

.insider-transactions-table tbody tr:hover {
    background: rgba(0, 0, 0, 0.02);
}

/* ── Analyst Ratings Box ────────────────────────────────────── */

.analyst-ratings-card {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-card);
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    grid-column: 1 / -1;
    animation: fadeInUp 0.8s ease-out backwards;
    min-width: 0;
}

.analyst-ratings-card h3 {
    font-size: 1.15rem;
    font-weight: 600;
    color: #1e3a8a;
    margin-bottom: 1.25rem;
    letter-spacing: -0.01em;
}

.analyst-ratings-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.rating-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.75rem;
    background: #f8fafc;
    border-radius: 0.5rem;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.rating-label {
    font-size: 0.95rem;
    color: #475569;
    font-weight: 500;
}

.rating-value {
    font-size: 1.1rem;
    font-weight: 600;
}

/* ── Item Cards Grid ────────────────────────────────────────────── */

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    grid-column: 1 / -1;
}

.item-card {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-card);
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.item-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.item-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    padding-bottom: 0.75rem;
    margin-bottom: 0.5rem;
}

.item-card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #1e3a8a;
}

.item-card-badge {
    font-size: 0.8rem;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-pill);
    font-weight: 600;
    background: rgba(0, 0, 0, 0.05);
}

.item-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
}

.item-card-label {
    color: #475569;
    font-weight: 500;
}

.item-card-value {
    font-weight: 600;
    color: #0f172a;
}

/* ── Mobile Optimizations ────────────────────────────────────── */

@media (max-width: 768px) {
    .overview-item {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 0.25rem;
    }
}

/* ── Toast Notification ──────────────────────────────────────── */

.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #991b1b;
    color: white;
    padding: 1rem 2rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    font-weight: 500;
}

.toast.show {
    opacity: 1;
    visibility: visible;
}
