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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    color: #2d3748;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background: #f0f2f5;
}

header {
    background: #0a1628;
    color: white;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 8px;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 1.5rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
}

/* Notifications */
.notifications {
    position: relative;
}

#notif-count.unread {
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 0.7rem;
    position: relative;
    top: -2px;
}

.notif-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 320px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(10,22,40,0.15);
    z-index: 1000;
    margin-top: 10px;
    color: #2d3748;
    overflow: hidden;
}

.notif-header {
    padding: 12px 16px;
    background: #e8ecf1;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.btn-link {
    background: none;
    color: #c9a84c;
    padding: 0;
    font-size: 0.8rem;
    text-decoration: underline;
}

.btn-link:hover { background: none; }

#notif-list {
    max-height: 400px;
    overflow-y: auto;
}

.notif-item {
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
}

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

.notif-item.empty {
    text-align: center;
    color: #6b7280;
    padding: 20px;
}

.notif-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.notif-body {
    font-size: 0.85rem;
    color: #555;
}

.notif-time {
    font-size: 0.75rem;
    color: #999;
    margin-top: 4px;
}

/* Toasts */
.notif-toast {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 300px;
    background: white;
    border-left: 5px solid #c9a84c;
    box-shadow: 0 4px 12px rgba(10,22,40,0.2);
    border-radius: 4px;
    z-index: 3000;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast-header {
    padding: 10px 12px;
    background: #e8ecf1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
}

.toast-body {
    padding: 12px;
    font-size: 0.9rem;
}

.toast-close {
    background: none;
    color: #999;
    font-size: 1.2rem;
    padding: 0;
    line-height: 1;
}

.toast-close:hover { color: #2d3748; }

/* Auth Overlay */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 22, 40, 0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.auth-overlay.hidden {
    display: none;
}

.auth-card {
    background: white;
    padding: 40px;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(10, 22, 40, 0.25);
}

.auth-card h2 {
    margin-bottom: 24px;
    color: #0f2444;
    text-align: center;
}

.auth-card form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-card input {
    padding: 12px 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    width: 100%;
}

.auth-card input:focus {
    outline: none;
    border-color: #c9a84c;
}

.auth-card button[type="submit"] {
    margin-top: 8px;
}

.auth-toggle {
    text-align: center;
    margin-top: 16px;
    font-size: 0.9rem;
    color: #6b7280;
}

.auth-toggle a {
    color: #c9a84c;
    text-decoration: none;
    font-weight: 500;
}

.auth-toggle a:hover {
    text-decoration: underline;
}

/* OAuth Divider */
.auth-divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
    color: #9ca3af;
    font-size: 0.85rem;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #ddd;
}

.auth-divider span {
    padding: 0 12px;
}

/* Microsoft OAuth Button */
.btn-microsoft {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px 20px;
    background: #2f2f2f;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}

.btn-microsoft:hover {
    background: #1a1a1a;
}

.btn-microsoft svg {
    flex-shrink: 0;
}

.auth-error {
    color: #e74c3c;
    text-align: center;
    margin-top: 12px;
    font-size: 0.9rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
}

.tab-btn {
    padding: 12px 24px;
    border: none;
    background: #d1d5db;
    color: #0f2444;
    cursor: pointer;
    font-size: 1rem;
    border-radius: 8px 8px 0 0;
    transition: background 0.2s;
}

.tab-btn:hover {
    background: #bbc2cc;
}

.tab-btn.active {
    background: white;
    color: #0f2444;
    font-weight: 600;
}

/* Tab Content */
.tab-content {
    display: none;
    background: white;
    padding: 24px;
    border-radius: 0 8px 8px 8px;
    box-shadow: 0 2px 4px rgba(10, 22, 40, 0.1);
}

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

.tab-content h2 {
    margin-bottom: 20px;
    color: #0f2444;
}

/* Forms */
.form-inline {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

input[type="text"],
input[type="url"] {
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    min-width: 200px;
}

input[type="text"]:focus,
input[type="url"]:focus {
    outline: none;
    border-color: #c9a84c;
}

button {
    padding: 10px 20px;
    background: #c9a84c;
    color: #0a1628;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: background 0.2s;
}

button:hover {
    background: #b8922e;
}

button:disabled {
    background: #bdc3c7;
    color: #6b7280;
    cursor: not-allowed;
}

.btn-small {
    padding: 4px 10px;
    font-size: 0.85rem;
    margin-left: 10px;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-secondary {
    background: #4a5568;
    color: white;
}

.btn-secondary:hover {
    background: #2d3748;
}

/* Data Sections */
.data-section {
    margin-top: 24px;
}

.data-section h3 {
    margin-bottom: 12px;
    color: #0f2444;
    display: flex;
    align-items: center;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background: #e8ecf1;
    font-weight: 600;
    color: #0f2444;
}

tr:hover {
    background: #f5f0e4;
}

td a {
    color: #1a5276;
    text-decoration: none;
}

td a:hover {
    text-decoration: underline;
}

/* Action buttons in tables */
.actions {
    display: flex;
    gap: 8px;
}

.actions button {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* Analysis Controls */
.analysis-controls {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

/* Quote Display */
#quote-data {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
}

#quote-data .quote-ticker {
    font-size: 1.5rem;
    font-weight: 600;
    color: #0f2444;
}

#quote-data .quote-price {
    font-size: 2rem;
    font-weight: 700;
    color: #27ae60;
    margin: 10px 0;
}

#quote-data .quote-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

#quote-data .quote-details span {
    display: block;
}

#quote-data .quote-details .label {
    font-size: 0.85rem;
    color: #6b7280;
}

#quote-data .quote-details .value {
    font-weight: 600;
}

/* Value change colours (used by JS on td/span for quote, backtest, correlation) */
td.positive,
.value.positive {
    color: #27ae60;
    font-weight: 600;
}

td.negative,
.value.negative {
    color: #e74c3c;
    font-weight: 600;
}

td.neutral,
.value.neutral {
    color: #6b7280;
}

/* Sentiment badges */
.sentiment {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

.sentiment.positive {
    background: #d5f5e3;
    color: #27ae60;
}

.sentiment.negative {
    background: #fadbd8;
    color: #e74c3c;
}

.sentiment.neutral {
    background: #eee;
    color: #6b7280;
}

/* Signal Tags */
.signal-tag {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-block;
}

.signal-tag.strong-buy {
    background: #27ae60;
    color: white;
}

.signal-tag.buy {
    background: #d5f5e3;
    color: #27ae60;
}

.signal-tag.hold {
    background: #ecf0f1;
    color: #6b7280;
}

.signal-tag.sell {
    background: #fadbd8;
    color: #e74c3c;
}

.signal-tag.strong-sell {
    background: #e74c3c;
    color: white;
}

.reasoning {
    font-size: 0.85rem;
    color: #6b7280;
    font-style: italic;
}

/* Backtest Summary */
.backtest-summary {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

.summary-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(10,22,40,0.1);
    min-width: 250px;
}

.summary-card.positive { border-top: 4px solid #27ae60; }
.summary-card.negative { border-top: 4px solid #e74c3c; }

.summary-val {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.summary-card.positive .summary-val { color: #27ae60; }
.summary-card.negative .summary-val { color: #e74c3c; }

.summary-label {
    font-weight: 600;
    color: #0f2444;
    text-transform: uppercase;
    font-size: 0.85rem;
}

.summary-sub {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 8px;
}

/* Analysis Results */
#analyze-data {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
}

#analyze-data .analysis-header {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 15px;
}

/* Loading & Error */
#loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(10, 22, 40, 0.85);
    color: white;
    padding: 20px 40px;
    border-radius: 8px;
    z-index: 1000;
}

#error-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #e74c3c;
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    z-index: 1000;
    max-width: 400px;
}

.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .form-inline {
        flex-direction: column;
    }

    input[type="text"],
    input[type="url"] {
        width: 100%;
    }

    table {
        font-size: 0.9rem;
    }

    th, td {
        padding: 8px;
    }

    .actions {
        flex-direction: column;
    }
}
