/* CSS Variables */
:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --border-radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.5;
    min-height: 100vh;
}

/* Header */
.header {
    background: white;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    box-shadow: var(--shadow);
}

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

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.api-key-section {
    display: flex;
    gap: 0.5rem;
}

.api-key-section input {
    width: 200px;
    padding: 0.5rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
}

.search-section {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.search-section input {
    flex: 1;
    max-width: 300px;
    padding: 0.75rem 1rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 1rem;
}

.search-section input:focus,
.api-key-section input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

button {
    padding: 0.75rem 1.5rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

button:hover {
    background: var(--primary-dark);
}

.company-header {
    padding-top: 0.5rem;
}

.company-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.price-info {
    display: flex;
    gap: 0.75rem;
    margin: 0.25rem 0;
}

#company-price {
    font-size: 1.25rem;
    font-weight: 600;
}

#company-change.positive { color: var(--success); }
#company-change.negative { color: var(--danger); }

#company-info {
    color: var(--gray-500);
    font-size: 0.875rem;
}

/* Tab Navigation */
.tab-nav {
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem 1.5rem;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    overflow-x: auto;
}

.tab-btn {
    padding: 0.75rem 1.25rem;
    background: transparent;
    color: var(--gray-600);
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    font-weight: 500;
    white-space: nowrap;
}

.tab-btn:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: transparent;
}

/* Main Content */
.main-content {
    padding: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Sections */
.section {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--gray-700);
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: right;
    border-bottom: 1px solid var(--gray-200);
}

.data-table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-600);
    white-space: nowrap;
}

.data-table td.left,
.data-table th.left {
    text-align: left;
}

.data-table tbody tr:hover {
    background: var(--gray-50);
}

.data-table td.positive { color: var(--success); }
.data-table td.negative { color: var(--danger); }

/* Charts */
.chart-container {
    position: relative;
    height: 300px;
}

.chart-controls {
    margin-bottom: 1rem;
}

.chart-controls select {
    padding: 0.5rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
}

/* Valuation Grid */
.valuation-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

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

.sliders-panel h4,
.results-panel h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--gray-600);
}

/* Sliders */
.slider-container {
    margin-bottom: 1.25rem;
}

.slider-container label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-600);
    margin-bottom: 0.5rem;
}

.slider-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.slider-row input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    background: var(--gray-200);
    border-radius: 3px;
    outline: none;
}

.slider-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
}

.slider-value {
    min-width: 60px;
    text-align: right;
    font-weight: 600;
    color: var(--gray-700);
}

/* Valuation Summary */
.valuation-summary {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--gray-100);
}

.summary-item .label {
    color: var(--gray-600);
}

.summary-item .value {
    font-weight: 600;
}

.summary-item.highlight {
    background: var(--gray-50);
    padding: 0.75rem;
    border-radius: var(--border-radius);
    border: none;
}

.summary-item.highlight .value {
    color: var(--primary);
    font-size: 1.125rem;
}

.summary-item.positive .value { color: var(--success); }
.summary-item.negative .value { color: var(--danger); }

/* Risk Scenarios */
.scenarios-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

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

.scenario-card {
    padding: 1.25rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--gray-200);
}

.scenario-card h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.scenario-card.bear { border-left: 4px solid var(--danger); }
.scenario-card.base { border-left: 4px solid var(--primary); }
.scenario-card.bull { border-left: 4px solid var(--success); }

.scenario-card.bear h4 { color: var(--danger); }
.scenario-card.base h4 { color: var(--primary); }
.scenario-card.bull h4 { color: var(--success); }

.scenario-details {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: 1rem;
}

.scenario-details p {
    margin-bottom: 0.25rem;
}

.scenario-value {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-top: 0.75rem;
    border-top: 1px solid var(--gray-200);
}

.scenario-value .intrinsic {
    font-size: 1.25rem;
    font-weight: 700;
}

.scenario-value .upside {
    font-weight: 600;
}

.scenario-value .upside.positive { color: var(--success); }
.scenario-value .upside.negative { color: var(--danger); }

/* Scale Analysis */
.scale-analysis {
    background: var(--gray-50);
    border-radius: var(--border-radius);
    padding: 1rem;
}

.scale-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.scale-header.positive { color: var(--success); }
.scale-header.neutral { color: var(--gray-500); }

.scale-details {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

@media (max-width: 640px) {
    .scale-details {
        grid-template-columns: 1fr;
    }
}

.scale-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
}

.scale-item .label { color: var(--gray-600); }
.scale-item .value { font-weight: 500; }
.scale-item .value.positive { color: var(--success); }
.scale-item .value.negative { color: var(--danger); }

.scale-item.highlight {
    grid-column: span 2;
    padding-top: 0.75rem;
    border-top: 1px solid var(--gray-300);
}

/* Compare */
.compare-input {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.compare-input input {
    flex: 1;
    max-width: 200px;
    padding: 0.5rem 1rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
}

/* Loading & Error */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--gray-500);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

.error-message {
    background: #fef2f2;
    color: var(--danger);
    padding: 1rem;
    border-radius: var(--border-radius);
    border: 1px solid #fecaca;
}

.no-data {
    color: var(--gray-500);
    text-align: center;
    padding: 2rem;
}

/* Notification */
.notification {
    position: fixed;
    top: 1rem;
    right: 1rem;
    padding: 0.75rem 1.25rem;
    background: var(--gray-800);
    color: white;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s;
    z-index: 1000;
}

.notification.show {
    opacity: 1;
    transform: translateY(0);
}

.notification.error {
    background: var(--danger);
}

.notification.success {
    background: var(--success);
}

/* Footer */
.footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--gray-500);
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 640px) {
    .header-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .api-key-section {
        width: 100%;
    }

    .api-key-section input {
        flex: 1;
        width: auto;
    }

    .search-section input {
        max-width: none;
    }

    .tab-nav {
        padding: 0.5rem;
    }

    .tab-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    .main-content {
        padding: 1rem;
    }

    .section {
        padding: 1rem;
    }
}
