/* ============================================================
   StockClarity KB Site — ZetaVantage Research
   Professional financial research design system
   ============================================================ */

/* --- CSS Custom Properties --- */
:root {
    /* Primary palette — deep navy + warm gold accent */
    --color-bg:              #0b1120;
    --color-bg-elevated:     #111827;
    --color-bg-card:         #1a2332;
    --color-bg-card-hover:   #1f2b3d;
    --color-bg-section:      #151e2d;
    --color-border:          #2a3548;
    --color-border-subtle:   #1e293b;

    /* Text hierarchy */
    --color-text-primary:    #e2e8f0;
    --color-text-secondary:  #94a3b8;
    --color-text-muted:      #64748b;
    --color-text-heading:    #f1f5f9;

    /* Accent */
    --color-accent:          #c9a84c;
    --color-accent-dim:      #a68a3a;
    --color-accent-glow:     rgba(201, 168, 76, 0.12);

    /* Status colors */
    --color-strong:          #22c55e;
    --color-strong-bg:       rgba(34, 197, 94, 0.10);
    --color-maintaining:     #eab308;
    --color-maintaining-bg:  rgba(234, 179, 8, 0.10);
    --color-weak:            #f97316;
    --color-weak-bg:         rgba(249, 115, 22, 0.10);
    --color-broken:          #ef4444;
    --color-broken-bg:       rgba(239, 68, 68, 0.10);

    /* Health */
    --color-health-good:     #22c55e;
    --color-health-caution:  #eab308;
    --color-health-danger:   #ef4444;

    /* Typography */
    --font-sans:             'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono:             'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

    /* Spacing */
    --space-xs:  0.25rem;
    --space-sm:  0.5rem;
    --space-md:  1rem;
    --space-lg:  1.5rem;
    --space-xl:  2rem;
    --space-2xl: 3rem;

    /* Borders */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    /* Shadows */
    --shadow-card: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-elevated: 0 4px 12px rgba(0,0,0,0.4);

    /* Layout */
    --max-width: 1120px;
    --header-height: 64px;
}


/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text-primary);
    line-height: 1.65;
    min-height: 100vh;
}


/* --- Header / Navigation --- */
.site-header {
    background: var(--color-bg-elevated);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--space-lg);
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-brand {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    text-decoration: none;
    color: var(--color-text-heading);
}

.brand-mark {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--color-accent), var(--color-accent-dim));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
    color: var(--color-bg);
    letter-spacing: -0.5px;
}

.brand-text {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.brand-divider {
    color: var(--color-text-muted);
    font-weight: 300;
    margin: 0 var(--space-xs);
}

.brand-subtitle {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    font-weight: 400;
}

.header-nav {
    display: flex;
    gap: var(--space-md);
    align-items: center;
}

.nav-link {
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    transition: color 0.2s, background 0.2s;
}

.nav-link:hover {
    color: var(--color-text-primary);
    background: rgba(255,255,255,0.05);
}


/* --- Main Content --- */
.main-content {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-xl) var(--space-lg);
}


/* --- Workspace Layout (Sidebar + Main Panel) --- */
.workspace-layout {
    position: relative;
}

.main-panel {
    transition: margin-left 0.3s ease;
}

/* KB Sidebar Toggle Button */
.page-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
}

.kb-sidebar-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--color-bg-card);
    border: 1px solid var(--color-accent);
    border-radius: var(--radius-md);
    color: var(--color-accent);
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.kb-sidebar-toggle:hover {
    background: var(--color-accent);
    color: var(--color-bg);
    box-shadow: 0 4px 24px rgba(201,168,76,0.2);
}

.kb-sidebar-toggle.active {
    background: var(--color-accent);
    color: var(--color-bg);
    border-color: var(--color-accent);
}

/* KB Sidebar Panel */
.kb-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 420px;
    height: 100vh;
    background: var(--color-bg);
    border-left: 1px solid var(--color-border);
    z-index: 200;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 30px rgba(0,0,0,0.4);
}

.kb-sidebar.open {
    transform: translateX(0);
}

.kb-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg-card);
    flex-shrink: 0;
}

.kb-sidebar-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-text-heading);
    margin: 0;
}

.kb-sidebar-close {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    line-height: 1;
}

.kb-sidebar-close:hover {
    background: rgba(255,255,255,0.06);
    color: var(--color-text-heading);
}

.kb-sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
}

.kb-sidebar-body::-webkit-scrollbar {
    width: 6px;
}

.kb-sidebar-body::-webkit-scrollbar-track {
    background: transparent;
}

.kb-sidebar-body::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
}

/* Adjust KB section styles inside sidebar */
.kb-sidebar-body .kb-section {
    margin-bottom: var(--space-lg);
}

.kb-sidebar-body .kb-section h3 {
    font-size: 0.9rem;
}

.kb-sidebar-body .kb-section-content {
    font-size: 0.85rem;
    line-height: 1.7;
}

/* Overlay for mobile */
.kb-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 199;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.kb-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}


/* --- Page Header (Company) --- */
.page-header {
    margin-bottom: var(--space-2xl);
    padding-bottom: var(--space-xl);
    border-bottom: 1px solid var(--color-border);
}

.page-header h1 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--color-text-heading);
    letter-spacing: -0.5px;
    margin-bottom: var(--space-sm);
}

.page-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
}

.exchange-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--font-mono);
    letter-spacing: 0.3px;
}

.exchange-badge.nse {
    background: rgba(59, 130, 246, 0.12);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.exchange-badge.bse {
    background: rgba(168, 85, 247, 0.12);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.2);
}

.exchange-badge.us {
    background: rgba(34, 197, 94, 0.12);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.sector-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--color-accent-glow);
    color: var(--color-accent);
    border: 1px solid rgba(201, 168, 76, 0.2);
}

.competitors {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-xs);
    margin-top: var(--space-sm);
}

.comp-label {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    font-weight: 500;
}

.competitor-badge {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(255,255,255,0.04);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
}

.kb-date {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-left: auto;
}


/* --- Page Section Container --- */
.page-section {
    margin-bottom: var(--space-2xl);
}

.page-section > h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--color-text-heading);
    margin-bottom: var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--color-border-subtle);
}


/* --- KB Sections --- */
.kb-section {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
    transition: border-color 0.2s;
}

.kb-section:hover {
    border-color: var(--color-accent-dim);
}

.kb-section h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-accent);
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.section-content {
    color: var(--color-text-primary);
    font-size: 0.925rem;
    line-height: 1.75;
}

.section-content p {
    margin-bottom: var(--space-sm);
}

.section-content p:last-child {
    margin-bottom: 0;
}

.section-content ul {
    padding-left: var(--space-lg);
    margin-bottom: var(--space-sm);
}

.section-content li {
    margin-bottom: var(--space-xs);
    color: var(--color-text-secondary);
}

.section-content strong {
    color: var(--color-text-heading);
    font-weight: 600;
}


/* --- KB Pulse Items --- */
.pulse-section {
    margin-bottom: var(--space-2xl);
}

.pulse-legend {
    display: flex;
    gap: var(--space-lg);
    margin-bottom: var(--space-md);
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.pulse-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-swatch {
    display: inline-block;
    width: 14px;
    height: 3px;
    border-radius: 2px;
}

.legend-structural {
    background: #60a5fa;
}

.legend-tactical {
    background: var(--color-accent);
}

.pulse-item {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-accent);
    border-radius: var(--radius-sm);
    padding: var(--space-md) var(--space-lg);
    margin-bottom: var(--space-sm);
}

.pulse-item.pulse-structural {
    border-left-color: #60a5fa;
}

.pulse-item.pulse-tactical {
    border-left-color: var(--color-accent);
}

.pulse-factor {
    font-size: 0.7rem;
    font-weight: 700;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-accent);
    margin-right: var(--space-sm);
}

.pulse-category {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 3px;
    background: rgba(255,255,255,0.06);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pulse-meta {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.pulse-date {
    font-size: 0.65rem;
    color: var(--color-text-muted);
    margin-left: auto;
    font-family: var(--font-mono);
}

.pulse-link {
    color: var(--color-text-heading);
    text-decoration: none;
    border-bottom: 1px solid rgba(201,168,76,0.3);
    transition: border-color 0.2s ease;
}

.pulse-link:hover {
    border-bottom-color: var(--color-accent);
    color: var(--color-accent);
}

.pulse-headline {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-text-heading);
    margin-top: var(--space-xs);
    margin-bottom: var(--space-xs);
}

.pulse-detail {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    margin-bottom: 0;
}


/* --- Thesis Section --- */
.thesis-section blockquote {
    background: var(--color-accent-glow);
    border-left: 3px solid var(--color-accent);
    padding: var(--space-md) var(--space-lg);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 1.05rem;
    font-style: italic;
    color: var(--color-text-heading);
    line-height: 1.7;
    margin-bottom: var(--space-xl);
}

.thesis-header-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.thesis-status-card,
.conviction-card,
.time-horizon-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-md) var(--space-lg);
    text-align: center;
}

.thesis-status-card .status-label,
.conviction-card .conviction-label,
.time-horizon-card .horizon-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-text-muted);
    margin-bottom: var(--space-xs);
}

.thesis-status-card .status-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.conviction-card .conviction-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--color-text-heading);
}

.conviction-card .conviction-max {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    font-weight: 400;
}

.time-horizon-card .horizon-value {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text-heading);
}

/* Status colors for thesis status cards */
.status-strong .status-value  { color: var(--color-strong); }
.status-maintaining .status-value { color: var(--color-maintaining); }
.status-weak .status-value    { color: var(--color-weak); }
.status-broken .status-value  { color: var(--color-broken); }

.status-strong  { border-color: rgba(34, 197, 94, 0.3); }
.status-maintaining { border-color: rgba(234, 179, 8, 0.3); }
.status-weak    { border-color: rgba(249, 115, 22, 0.3); }
.status-broken  { border-color: rgba(239, 68, 68, 0.3); }


/* --- Conviction Chart --- */
.conviction-chart-container {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.conviction-chart-container h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-md);
}

.conviction-chart-container canvas {
    width: 100% !important;
    height: 200px;
    max-height: 200px;
}


/* --- Assumptions Grid --- */
.thesis-section h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text-heading);
    margin-bottom: var(--space-md);
    margin-top: var(--space-md);
}

.assumptions-grid {
    display: grid;
    gap: var(--space-md);
}

.assumption-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    transition: border-color 0.2s;
}

.assumption-card:hover {
    border-color: var(--color-border);
    box-shadow: var(--shadow-card);
}

.thesis-legend {
    display: flex;
    gap: var(--space-lg);
    margin-bottom: var(--space-lg);
    font-size: 0.78rem;
    color: var(--color-text-muted);
    flex-wrap: wrap;
    padding: var(--space-sm) var(--space-md);
    background: rgba(255,255,255,0.02);
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
}

.thesis-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.dot-strong { background: var(--color-strong, #22c55e); }
.dot-maintaining { background: var(--color-maintaining, #eab308); }
.dot-weak { background: var(--color-weak, #f97316); }
.dot-broken { background: var(--color-broken, #ef4444); }

.assumption-card.health-good {
    border-left: 3px solid var(--color-health-good);
}

.assumption-card.health-caution {
    border-left: 3px solid var(--color-health-caution);
}

.assumption-card.health-danger {
    border-left: 3px solid var(--color-health-danger);
}

.assumption-legend {
    display: flex;
    gap: var(--space-lg);
    margin-bottom: var(--space-md);
    font-size: 0.8rem;
    color: var(--color-text-muted);
    flex-wrap: wrap;
}

.assumption-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-health-good {
    background: var(--color-health-good);
}

.legend-health-caution {
    background: var(--color-health-caution);
}

.legend-health-danger {
    background: var(--color-health-danger);
}

.legend-critical {
    background: #f97316;
    border-radius: 2px;
    width: 14px !important;
    height: 10px;
    font-size: 0;
    border: 1px solid rgba(249,115,22,0.6);
}

.assumption-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.assumption-number {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-text-muted);
}

.critical-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 3px;
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.assumption-status {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.assumption-status.status-holding {
    background: rgba(34, 197, 94, 0.10);
    color: #4ade80;
}

.assumption-status.status-at_risk {
    background: rgba(234, 179, 8, 0.10);
    color: #facc15;
}

.assumption-status.status-broken {
    background: rgba(239, 68, 68, 0.10);
    color: #f87171;
}

.health-score {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-text-secondary);
}

.assumption-text {
    font-size: 0.925rem;
    color: var(--color-text-primary);
    line-height: 1.7;
    margin-bottom: var(--space-sm);
}

.factor-badges {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

.factor-badge {
    font-size: 0.7rem;
    font-weight: 600;
    font-family: var(--font-mono);
    padding: 2px 8px;
    border-radius: 3px;
    background: rgba(201, 168, 76, 0.10);
    color: var(--color-accent);
    letter-spacing: 0.3px;
}


/* --- Unlinked Factors --- */
.unlinked-factors {
    margin-top: var(--space-lg);
    padding: var(--space-md) var(--space-lg);
    background: var(--color-bg-section);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-sm);
}

.unlinked-factors h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
}

.unlinked-factors ul {
    list-style: none;
    padding: 0;
}

.unlinked-factors li {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    padding: var(--space-xs) 0;
    border-bottom: 1px solid var(--color-border-subtle);
}

.unlinked-factors li:last-child {
    border-bottom: none;
}


/* --- Investor Documents --- */
.docs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--space-md);
}

.doc-link {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--color-text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: border-color 0.2s, background 0.2s;
}

.doc-link:hover {
    border-color: var(--color-accent-dim);
    background: var(--color-bg-card-hover);
}

.doc-icon {
    width: 18px;
    height: 18px;
    color: var(--color-accent);
    flex-shrink: 0;
}

.external-icon {
    width: 14px;
    height: 14px;
    color: var(--color-text-muted);
    margin-left: auto;
    flex-shrink: 0;
}


/* --- Section Icons (SVG) --- */
.section-icon {
    width: 20px;
    height: 20px;
    color: var(--color-accent);
    flex-shrink: 0;
}


/* ============================================================
   INDEX PAGE — Company Listing
   ============================================================ */

.index-header {
    text-align: center;
    margin-bottom: var(--space-2xl);
    padding-bottom: var(--space-xl);
    border-bottom: 1px solid var(--color-border);
}

.index-header h1 {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--color-text-heading);
    letter-spacing: -0.5px;
    margin-bottom: var(--space-xs);
}

.index-header .subtitle {
    font-size: 1rem;
    color: var(--color-text-secondary);
}

.index-header .stats {
    margin-top: var(--space-md);
    font-size: 0.85rem;
    color: var(--color-text-muted);
}


/* --- Search & Filter Bar --- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    align-items: center;
    margin-bottom: var(--space-xl);
}

.search-input {
    flex: 1;
    min-width: 240px;
    padding: var(--space-sm) var(--space-md);
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.search-input::placeholder {
    color: var(--color-text-muted);
}

.search-input:focus {
    border-color: var(--color-accent);
}

.sort-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: var(--space-xs);
}

.sort-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-right: 2px;
}

.sort-btn {
    font-size: 0.78rem;
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid var(--color-border);
    background: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-sans);
}

.sort-btn:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.sort-btn.active {
    background: var(--color-accent);
    color: var(--color-bg);
    border-color: var(--color-accent);
    font-weight: 600;
}

.sector-filters {
    display: flex;
    align-items: center;
}

.sector-select {
    padding: 6px 32px 6px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg-card);
    color: var(--color-text-primary);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.2s;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 5l3 3 3-3'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    min-width: 180px;
}

.sector-select:hover {
    border-color: var(--color-accent-dim);
}

.sector-select:focus {
    border-color: var(--color-accent);
    outline: none;
}

.sector-select option {
    background: var(--color-bg);
    color: var(--color-text-primary);
}


/* --- Company Cards Grid --- */
.company-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-md);
}

.company-card {
    display: block;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s, border-color 0.2s, box-shadow 0.2s;
}

.company-card:hover {
    transform: translateY(-2px);
    border-color: var(--color-accent-dim);
    box-shadow: var(--shadow-elevated);
}

.card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-sm);
}

.card-symbol {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-accent);
    letter-spacing: 0.5px;
}

.card-status {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.card-status.status-strong {
    background: var(--color-strong-bg);
    color: var(--color-strong);
}

.card-status.status-maintaining {
    background: var(--color-maintaining-bg);
    color: var(--color-maintaining);
}

.card-status.status-weak {
    background: var(--color-weak-bg);
    color: var(--color-weak);
}

.card-status.status-broken {
    background: var(--color-broken-bg);
    color: var(--color-broken);
}

.card-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-text-heading);
    margin-bottom: var(--space-sm);
    line-height: 1.3;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-sector {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.card-exchange {
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--color-text-muted);
}

.company-card.hidden {
    display: none;
}


/* --- Footer --- */
.site-footer {
    border-top: 1px solid var(--color-border);
    padding: var(--space-xl) var(--space-lg);
    text-align: center;
    margin-top: var(--space-2xl);
}

.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
}

.footer-brand {
    font-weight: 700;
    color: var(--color-accent);
}

.footer-text {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: var(--space-xs);
    line-height: 1.6;
}

.footer-disclaimer {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--color-border-subtle);
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
}


/* --- 404 Page --- */
.not-found {
    text-align: center;
    padding: var(--space-2xl) 0;
}

.not-found h1 {
    font-size: 4rem;
    font-weight: 800;
    color: var(--color-text-muted);
}

.not-found p {
    color: var(--color-text-secondary);
    margin-top: var(--space-md);
}

.not-found a {
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 600;
}


/* --- Responsive --- */
@media (max-width: 768px) {
    .header-inner {
        flex-direction: column;
        height: auto;
        padding: var(--space-md) var(--space-lg);
        gap: var(--space-sm);
    }

    .thesis-header-row {
        grid-template-columns: 1fr;
    }

    .company-grid {
        grid-template-columns: 1fr;
    }

    .filter-bar {
        flex-direction: column;
    }

    .search-input {
        width: 100%;
    }

    .page-header h1 {
        font-size: 1.5rem;
    }

    .kb-date {
        margin-left: 0;
    }

    .docs-grid {
        grid-template-columns: 1fr;
    }

    /* Sidebar responsive */
    .kb-sidebar {
        width: 100%;
    }

    .kb-sidebar-toggle {
        font-size: 0.75rem;
        padding: 8px 14px;
    }

    .page-header-top {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: var(--space-md);
    }

    .kb-section {
        padding: var(--space-md);
    }

    .assumption-card {
        padding: var(--space-md);
    }
}


/* --- Table of contents sidebar nav (company page) --- */
.page-toc {
    position: sticky;
    top: calc(var(--header-height) + var(--space-lg));
}

.toc-link {
    display: block;
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.8rem;
    color: var(--color-text-muted);
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.toc-link:hover,
.toc-link.active {
    color: var(--color-accent);
    border-left-color: var(--color-accent);
}


/* --- Utility: no-content notice --- */
.empty-state {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--color-text-muted);
}

.empty-state p {
    font-size: 0.9rem;
}
