* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--tblr-body-bg);
    color: var(--tblr-body-color);
}

.page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    background: var(--tblr-bg-surface);
    border-bottom: 1px solid var(--tblr-border-color);
    position: sticky;
    top: 0;
    z-index: 900;
}

.topbar__left {
    display: flex;
    align-items: center;
    gap: 1.1rem;
}

.topbar__brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon {
    font-size: 1.8rem;
}

.brand-title {
    font-weight: 700;
    font-size: 1.1rem;
}

.brand-subtitle {
    font-size: 0.8rem;
    color: var(--tblr-secondary-color);
}

.topbar__actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#logout-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.logout-label {
    display: inline;
}

.btn.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    display: grid;
    place-items: center;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    background: var(--tblr-bg-muted);
    color: var(--tblr-body-color);
    font-weight: 600;
}

.page-content {
    flex: 1;
    display: flex;
    min-height: 0;
}

.sidebar {
    width: 250px;
    background: var(--tblr-bg-surface);
    border-right: 1px solid var(--tblr-border-color);
    padding: 1.75rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    transition: transform 0.25s ease;
}

.sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    border-radius: 0.75rem;
    color: var(--tblr-secondary-color);
    text-decoration: none;
    font-weight: 600;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.sidebar__link:hover {
    background: rgba(37, 99, 235, 0.08);
    color: var(--tblr-primary);
}

.sidebar__link.active {
    background: rgba(37, 99, 235, 0.18);
    color: var(--tblr-primary);
}

.sidebar__footer {
    font-size: 0.85rem;
    margin-top: auto;
}

.main {
    flex: 1;
    padding: 2rem clamp(1.2rem, 4vw, 2.6rem);
    overflow-y: auto;
    background: var(--tblr-body-bg);
}

.section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.section[hidden] {
    display: none !important;
}

.code-block {
    background: #0f1a32;
    color: #f5f9ff;
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    max-height: 420px;
    overflow: auto;
    font-family: "JetBrains Mono", "Fira Code", monospace;
    font-size: 0.9rem;
}

.badge {
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.table td .badge {
    font-size: 0.75rem;
}

.login {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background: rgba(9, 16, 31, 0.68);
    backdrop-filter: blur(6px);
}

.login__panel {
    width: min(420px, 94vw);
    background: var(--tblr-bg-surface);
    border-radius: 1rem;
    box-shadow: var(--tblr-shadow-lg);
    padding: 2.2rem 2.4rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.login__form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login__footer {
    font-size: 0.85rem;
    text-align: center;
}

.toast-message {
    position: fixed;
    right: clamp(1rem, 4vw, 2.5rem);
    bottom: clamp(1rem, 4vw, 2.5rem);
    min-width: 240px;
    padding: 0.9rem 1.2rem;
    border-radius: 0.85rem;
    background: var(--tblr-bg-surface);
    color: var(--tblr-body-color);
    font-weight: 600;
    box-shadow: var(--tblr-shadow-lg);
    border-left: 4px solid var(--tblr-primary);
}

.toast-message[data-variant="error"] {
    border-left-color: var(--tblr-danger);
}

.toast-message[data-variant="success"] {
    border-left-color: var(--tblr-success);
}

#sidebar-toggle {
    color: var(--tblr-secondary-color);
}

.section .card {
    border-radius: 1rem;
}

#config-download {
    display: none;
}

.card-timeline .card-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.timeline-empty {
    text-align: center;
    font-size: 0.9rem;
}

.timeline-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.timeline-axis {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--tblr-secondary-color);
}

.timeline-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.timeline-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1rem;
    font-size: 0.78rem;
    color: var(--tblr-secondary-color);
}

.timeline-legend__item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.timeline-legend__dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid transparent;
}

.timeline-track,
.timeline-day__track {
    position: relative;
    --lane-count: 1;
    --lane-height: 48px;
    min-height: calc(var(--lane-count) * var(--lane-height) + 18px);
    border-radius: 0.85rem;
    background: var(--tblr-bg-muted);
    border: 1px solid var(--tblr-border-color);
    overflow: hidden;
}

.timeline-track::before,
.timeline-day__track::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: repeating-linear-gradient(
        to right,
        rgba(255, 255, 255, 0.05) 0,
        rgba(255, 255, 255, 0.05) 1px,
        transparent 0,
        transparent calc(100% / 6)
    );
    pointer-events: none;
    opacity: 0.6;
}

.timeline-track__bars,
.timeline-day__bars {
    position: absolute;
    inset: 0.45rem 0.65rem;
    min-height: calc(var(--lane-count) * var(--lane-height));
}

.timeline-bar {
    position: absolute;
    top: calc(var(--lane, 0) * var(--lane-height) + 4px);
    height: calc(var(--lane-height) - 12px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: 0.15rem;
    padding: 0.35rem 0.6rem;
    border-radius: 0.75rem;
    font-size: clamp(0.72rem, 1.6vw, 0.8rem);
    font-weight: 600;
    left: var(--start, 0%);
    width: var(--width, 8%);
    min-width: clamp(3.2rem, var(--width) * 1.1, 5.5rem);
    border: 1px solid transparent;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.timeline-bar:hover {
    box-shadow: var(--tblr-shadow-sm);
    transform: translateY(-2px);
}

.timeline-bar.is-next {
    border-width: 2px;
}

.timeline-bar__label {
    display: block;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.timeline-bar__time {
    font-size: clamp(0.68rem, 1.5vw, 0.74rem);
    font-weight: 500;
    opacity: 0.9;
}

.timeline-bar[data-job="ingest_news"] {
    background: rgba(37, 99, 235, 0.18);
    color: var(--tblr-primary);
    border-color: rgba(37, 99, 235, 0.35);
}

.timeline-legend__dot[data-job="ingest_news"] {
    background: rgba(37, 99, 235, 0.45);
    border-color: rgba(37, 99, 235, 0.8);
}

.timeline-bar[data-job="vectorize_data"] {
    background: rgba(236, 72, 153, 0.18);
    color: #ec4899;
    border-color: rgba(236, 72, 153, 0.4);
}

.timeline-legend__dot[data-job="vectorize_data"] {
    background: rgba(236, 72, 153, 0.5);
    border-color: rgba(236, 72, 153, 0.85);
}

.timeline-bar[data-job="run_daily"] {
    background: rgba(255, 153, 0, 0.18);
    color: #f97316;
    border-color: rgba(255, 153, 0, 0.35);
}

.timeline-legend__dot[data-job="run_daily"] {
    background: rgba(255, 153, 0, 0.45);
    border-color: rgba(255, 153, 0, 0.8);
}

.portfolio-metrics {
    display: grid;
    gap: 0.4rem 1rem;
}

.portfolio-metrics div {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 1px dashed var(--tblr-border-color);
    padding: 0.25rem 0;
    font-size: 0.92rem;
}

.portfolio-metrics div:last-child {
    border-bottom: none;
}

.portfolio-metrics dt {
    font-weight: 600;
    color: var(--tblr-secondary-color);
}

.portfolio-metrics dd {
    margin-bottom: 0;
    font-weight: 600;
}

.portfolio-exposure {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.portfolio-exposure__item {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.4rem 0.6rem;
    border-radius: 0.75rem;
    background: rgba(37, 99, 235, 0.04);
    border: 1px solid rgba(37, 99, 235, 0.08);
}

.portfolio-exposure__header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    font-weight: 600;
}

.portfolio-exposure__meta {
    display: flex;
    gap: 0.75rem;
    font-size: 0.82rem;
    color: var(--tblr-secondary-color);
}

.portfolio-exposure__bar {
    position: relative;
    height: 6px;
    border-radius: 999px;
    background: var(--tblr-bg-muted);
    overflow: hidden;
}

.portfolio-exposure__bar span {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, rgba(37, 99, 235, 0.4), rgba(37, 99, 235, 0.9));
}

.portfolio-exposure__empty {
    color: var(--tblr-secondary-color);
    font-size: 0.9rem;
}

#portfolio-status {
    margin-bottom: 1rem;
}

.timeline-bar[data-job="daily_report"] {
    background: rgba(16, 185, 129, 0.18);
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.35);
}

.timeline-legend__dot[data-job="daily_report"] {
    background: rgba(16, 185, 129, 0.45);
    border-color: rgba(16, 185, 129, 0.8);
}

.timeline-bar[data-job="default"] {
    background: rgba(107, 114, 128, 0.18);
    color: #6b7280;
    border-color: rgba(107, 114, 128, 0.35);
}

.timeline-legend__dot[data-job="default"] {
    background: rgba(107, 114, 128, 0.45);
    border-color: rgba(107, 114, 128, 0.8);
}

.timeline-week {
    display: grid;
    gap: 1rem;
}

@media (min-width: 768px) {
    .timeline-week {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
}

.timeline-day {
    border: 1px solid var(--tblr-border-color);
    border-radius: 0.9rem;
    padding: 0.75rem;
    background: var(--tblr-bg-surface);
}

.timeline-day__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--tblr-secondary-color);
}

.timeline-day__track {
    --lane-height: 44px;
}

.timeline-day__bars .timeline-bar {
    max-width: calc(100% - 0.25rem);
}

.overlay-modal,
.secret-modal {
    position: fixed;
    inset: 0;
    z-index: 1250;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background: rgba(9, 16, 31, 0.72);
    backdrop-filter: blur(6px);
}

.overlay-modal__panel,
.secret-modal__panel {
    width: min(520px, 95vw);
    background: var(--tblr-bg-surface);
    border-radius: 1rem;
    box-shadow: var(--tblr-shadow-lg);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.overlay-modal__header,
.secret-modal__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.overlay-modal__header .btn,
.secret-modal__header .btn {
    padding: 0.25rem;
}

.overlay-modal__form,
.secret-modal__form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.overlay-modal[hidden],
.secret-modal[hidden] {
    display: none !important;
}

@media (max-width: 1100px) {
    .sidebar {
        position: fixed;
        top: 64px;
        bottom: 0;
        transform: translateX(-110%);
        box-shadow: var(--tblr-shadow-lg);
        width: 260px;
        background: var(--tblr-bg-surface);
        z-index: 900;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-open::after {
        content: "";
        position: fixed;
        inset: 64px 0 0 0;
        background: rgba(9, 16, 31, 0.45);
        z-index: 800;
    }

    .main {
        padding: 1.5rem;
    }
}

@media (max-width: 640px) {
    .topbar {
        padding: 0 1rem;
    }

    .topbar__brand {
        gap: 0.5rem;
    }

    .brand-subtitle {
        display: none;
    }

    .topbar__actions {
        gap: 0.5rem;
    }

    .user-chip span {
        display: none;
    }

    #logout-btn {
        width: 38px;
        height: 38px;
        padding: 0;
        display: grid;
        place-items: center;
        gap: 0;
    }

    .logout-label {
        display: none;
    }

    .login__panel {
        padding: 1.8rem 1.6rem;
    }

    .toast-message {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }
}

/* ==================== Config Analysis Styles ==================== */

#config-analysis-content .alert-title {
    font-size: 1.1rem;
    font-weight: 600;
}

#analysis-risk-factors .alert {
    border-left: 3px solid currentColor;
}

#analysis-key-params .list-group-item {
    border-left: 3px solid var(--tblr-blue);
}

#analysis-avantages .h5,
#analysis-inconvenients .h5 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

#analysis-optimisations .card {
    border-width: 2px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#analysis-optimisations .card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

#analysis-coherence-bar {
    transition: width 0.6s ease;
}

.code-block {
    background: var(--tblr-bg-surface-tertiary);
    color: var(--tblr-body-color);
    border: 1px solid var(--tblr-border-color);
    border-radius: 0.375rem;
    padding: 1rem;
    overflow-x: auto;
}

.border-red {
    border-color: var(--tblr-red) !important;
}

.border-orange {
    border-color: var(--tblr-orange) !important;
}

.border-blue {
    border-color: var(--tblr-blue) !important;
}

/* Running Jobs Styles */
.running-job-item {
    border-bottom: 1px solid var(--tblr-border-color);
}

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

.running-job-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--tblr-bg-surface-tertiary);
    cursor: pointer;
    transition: background 0.15s ease;
}

.running-job-header:hover {
    background: var(--tblr-bg-surface-secondary);
}

.running-job-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
}

.running-job-duration {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--tblr-secondary);
}

.running-job-console {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.running-job-console.expanded {
    max-height: 500px;
}

.running-job-console-inner {
    padding: 1rem 1.5rem;
    background: #1e1e1e;
    color: #d4d4d4;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.75rem;
    line-height: 1.5;
    overflow-y: auto;
    max-height: 450px;
}

.running-job-console-inner.light-theme {
    background: #f5f5f5;
    color: #333;
}

.console-log-line {
    padding: 0.25rem 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.console-log-line.log-level-ERROR,
.console-log-line.log-level-CRITICAL {
    color: #f48771;
    font-weight: 600;
}

.console-log-line.log-level-WARNING {
    color: #dcdcaa;
}

.console-log-line.log-level-INFO {
    color: #4ec9b0;
}

.console-log-line.log-level-DEBUG {
    color: #858585;
}

.running-job-toggle-icon {
    transition: transform 0.3s ease;
}

.running-job-toggle-icon.expanded {
    transform: rotate(180deg);
}

.pulse-animation {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Ops Console Styles */
.ops-console-wrapper {
    max-height: 500px;
    transition: max-height 0.3s ease;
    overflow: hidden;
}

.ops-console-wrapper.collapsed {
    max-height: 0;
}

.ops-console {
    background: #1e1e1e;
    color: #d4d4d4;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.75rem;
    line-height: 1.4;
    padding: 1rem;
    height: 500px;
    overflow-y: auto;
    overflow-x: hidden;
}

.ops-console.light-theme {
    background: #f5f5f5;
    color: #333;
}

.ops-console-line {
    padding: 0.15rem 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.ops-console-line .timestamp {
    color: #858585;
    margin-right: 0.5rem;
}

.ops-console-line .module {
    color: #9cdcfe;
    margin-right: 0.5rem;
}

.ops-console-line.level-ERROR,
.ops-console-line.level-CRITICAL {
    color: #f48771;
    font-weight: 600;
}

.ops-console-line.level-WARNING {
    color: #dcdcaa;
}

.ops-console-line.level-INFO {
    color: #4ec9b0;
}

.ops-console-line.level-DEBUG {
    color: #858585;
}

.ops-console-line.level-SUCCESS {
    color: #4ec9b0;
}


