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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 40px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

main {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 25px;
}

.card h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.form-row {
    display: flex;
    gap: 15px;
    align-items: flex-end;
}

.form-group {
    flex: 1;
}

.form-group.full-width {
    flex: 1 1 100%;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
}

input[type="text"],
input[type="number"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #e1e4e8;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

input[type="text"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: #667eea;
}

.btn-primary, .btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.hidden {
    display: none;
}

.loading {
    text-align: center;
    padding: 40px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

#pools-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.pool-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border: 2px solid #e1e4e8;
    cursor: pointer;
    transition: all 0.3s;
}

.pool-card:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.pool-pair {
    font-size: 1.2rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 10px;
}

.pool-details {
    font-size: 0.9rem;
    color: #666;
}

.pool-details div {
    margin-bottom: 5px;
}

.pool-info {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.section {
    margin-bottom: 30px;
}

.section h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.content {
    background: white;
    padding: 20px;
    border-radius: 8px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.warning-box {
    border-left: 4px solid #f0ad4e;
    background: #fff3cd;
}

.positions-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.position-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border: 2px solid #667eea;
}

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

.position-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: #333;
}

.position-allocation {
    background: #667eea;
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 600;
}

.position-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.position-metric {
    display: flex;
    flex-direction: column;
}

.metric-label {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 4px;
}

.metric-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}

.position-rationale {
    padding-top: 15px;
    border-top: 1px solid #e1e4e8;
    color: #555;
    font-style: italic;
}

.metrics {
    background: white;
    padding: 20px;
    border-radius: 8px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.metric-box {
    text-align: center;
}

.metric-box-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 8px;
}

.metric-box-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #667eea;
}

.action-buttons {
    display: flex;
    gap: 15px;
    margin: 20px 0;
}

.chat-messages {
    background: white;
    border: 2px solid #e1e4e8;
    border-radius: 8px;
    height: 300px;
    overflow-y: auto;
    padding: 15px;
    margin-bottom: 15px;
}

.chat-message {
    margin-bottom: 15px;
    padding: 10px;
    border-radius: 6px;
}

.chat-message.user {
    background: #e3f2fd;
    margin-left: 40px;
}

.chat-message.assistant {
    background: #f5f5f5;
    margin-right: 40px;
}

.message-role {
    font-weight: 700;
    margin-bottom: 5px;
    color: #667eea;
}

.message-content {
    color: #333;
    line-height: 1.5;
}

.chat-input-container {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

#chat-input {
    flex: 1;
}

.suggested-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.suggested-questions p {
    font-size: 0.9rem;
    color: #666;
    margin-right: 10px;
}

.quick-question {
    padding: 8px 16px;
    background: white;
    border: 2px solid #667eea;
    border-radius: 20px;
    color: #667eea;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s;
}

.quick-question:hover {
    background: #667eea;
    color: white;
}

footer {
    text-align: center;
    color: white;
    margin-top: 40px;
    opacity: 0.8;
}

.allocation-visual {
    background: white;
    padding: 30px;
    border-radius: 8px;
    display: flex;
    justify-content: center;
}

.range-viz {
    background: white;
    padding: 20px;
    border-radius: 8px;
}

.range-bar {
    margin-bottom: 25px;
    position: relative;
}

.range-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.range-track {
    height: 40px;
    background: #f0f0f0;
    border-radius: 20px;
    position: relative;
    overflow: hidden;
}

.range-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
}

.range-current-price {
    position: absolute;
    width: 3px;
    height: 50px;
    background: #e74c3c;
    top: -5px;
    z-index: 10;
}

.range-current-price::before {
    content: 'Current';
    position: absolute;
    top: -20px;
    left: -20px;
    font-size: 0.75rem;
    color: #e74c3c;
    font-weight: 600;
}

.range-bounds {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
    font-size: 0.85rem;
    color: #666;
}

.deployment-steps {
    background: white;
    padding: 20px;
    border-radius: 8px;
}

.deploy-step {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 15px;
    border-left: 4px solid #667eea;
}

.deploy-step-header {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.deploy-step-number {
    background: #667eea;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    margin-right: 10px;
}

.deploy-step-title {
    font-weight: 700;
    color: #333;
    font-size: 1.1rem;
}

.deploy-step-details {
    margin-left: 40px;
    color: #555;
    line-height: 1.6;
}

.deploy-amount {
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    font-weight: 600;
    display: inline-block;
    margin: 5px 5px 5px 0;
}

.deploy-range {
    background: #f0f0f0;
    padding: 8px 12px;
    border-radius: 4px;
    font-family: monospace;
    display: inline-block;
    margin: 5px 0;
}

.backtest-input {
    background: white;
    padding: 20px;
    border-radius: 8px;
}

.backtest-position {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    border-left: 4px solid #667eea;
}

.backtest-position-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.backtest-position-title {
    font-weight: 700;
    color: #333;
}

.remove-position {
    background: #dc3545;
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.remove-position:hover {
    background: #c82333;
}

.backtest-position-inputs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.backtest-input-group {
    display: flex;
    flex-direction: column;
}

.backtest-input-group label {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 4px;
}

.backtest-input-group input {
    padding: 8px;
    font-size: 0.9rem;
}

/* News Citations Styles */
.news-citations {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.news-card {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px 16px;
    transition: all 0.2s ease;
}

.news-card:hover {
    background: #ffffff;
    border-color: #2563eb;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
}

.news-header {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.news-freshness {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.news-freshness.fresh {
    background: #dcfce7;
    color: #166534;
}

.news-freshness.recent {
    background: #dbeafe;
    color: #1e40af;
}

.news-freshness.stale {
    background: #fef3c7;
    color: #92400e;
}

.news-freshness.outdated {
    background: #fee2e2;
    color: #991b1b;
}

.news-freshness.unknown {
    background: #f3f4f6;
    color: #6b7280;
}

.news-title {
    font-size: 0.95rem;
    line-height: 1.5;
}

.news-title a {
    color: #1e293b;
    text-decoration: none;
    font-weight: 500;
}

.news-title a:hover {
    color: #2563eb;
    text-decoration: underline;
}

/* Sentiment Display Styles */
.sentiment-display {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 12px;
}

.sentiment-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 16px 20px;
    transition: all 0.3s ease;
}

.sentiment-card:hover {
    border-color: #2563eb;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
    transform: translateY(-2px);
}

.sentiment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.sentiment-token {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
}

.sentiment-badge {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sentiment-badge.bullish {
    background: #dcfce7;
    color: #166534;
}

.sentiment-badge.bearish {
    background: #fee2e2;
    color: #991b1b;
}

.sentiment-badge.neutral {
    background: #e0e7ff;
    color: #3730a3;
}

.sentiment-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.sentiment-metric {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sentiment-metric .metric-label {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sentiment-metric .metric-value {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
}

.sentiment-metric .metric-value.positive {
    color: #16a34a;
}

.sentiment-metric .metric-value.negative {
    color: #dc2626;
}

@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .action-buttons {
        flex-direction: column;
    }

    .backtest-position-inputs {
        grid-template-columns: 1fr;
    }
}

/* Tab Navigation */
.tab-navigation {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 30px;
}

.tab-btn {
    padding: 12px 30px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.tab-btn.active {
    background: white;
    color: #667eea;
    border-color: white;
}

.tab-content {
    display: none;
}

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

/* Library Grid */
.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.analysis-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.analysis-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
}

.analysis-card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 15px;
}

.analysis-card-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 5px;
}

.analysis-card-date {
    font-size: 0.85rem;
    color: #666;
}

.analysis-card-badge {
    padding: 4px 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.analysis-card-body {
    margin-bottom: 15px;
}

.analysis-card-stat {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
}

.analysis-card-stat:last-child {
    border-bottom: none;
}

.analysis-card-stat-label {
    color: #666;
    font-weight: 500;
}

.analysis-card-stat-value {
    color: #333;
    font-weight: 600;
}

.analysis-card-footer {
    display: flex;
    gap: 10px;
}

.analysis-card-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.analysis-card-btn-view {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.analysis-card-btn-view:hover {
    opacity: 0.9;
    transform: scale(1.02);
}

.analysis-card-btn-delete {
    background: #f5f5f5;
    color: #e74c3c;
}

.analysis-card-btn-delete:hover {
    background: #e74c3c;
    color: white;
}
