/* Code blocks in orchestrator live output — light theme for maximum readability */
.orch-code-block {
    background: #f1f5f9 !important;
    color: #0f172a !important;
    border-radius: 8px;
    padding: 14px 16px;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 0.875rem;
    line-height: 1.65;
    white-space: pre-wrap;
    border: 1px solid #cbd5e1;
}
.orch-code-block .code-comment {
    color: #475569 !important;
    font-weight: 500;
}
.orch-code-block .code-keyword { color: #0369a1 !important; font-weight: 600; }
.orch-code-block .code-string { color: #0d9488 !important; }

/* Current running block in Live Output (right panel) — visible loading state */
.orch-current-running {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 1px solid #93c5fd;
    border-radius: 12px;
    font-size: 1rem;
    color: #1e40af;
    font-weight: 600;
}
.orch-current-running .spinner-border { width: 1.5rem; height: 1.5rem; }

:root {
    --bg-main: #ffffff;
    --bg-subtle: #f8fafc;
    --bg-muted: #f1f5f9;
    --panel-bg: #ffffff;
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;
    --text-main: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --accent-blue: #2563eb;
    --accent-blue-hover: #1d4ed8;
    --accent-indigo: #4f46e5;
    --accent-violet: #7c3aed;
    --red: #dc2626;
    --amber: #d97706;
    --green: #059669;
    --graph-bg: #f8fafc;
    --graph-node: #ffffff;
    --graph-border: #cbd5e1;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    font-family: 'Inter', sans-serif !important;
}

/* ═══════ Glass Panel ═══════ */
.glass-panel {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 20px rgba(0, 0, 0, 0.03);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s ease, box-shadow 0.3s ease;
}

.glass-panel:hover {
    border-color: var(--border-hover);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

/* ═══════ Deal Cards ═══════ */
.demo-card {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: #ffffff !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.demo-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-indigo));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.demo-card:hover {
    transform: translateY(-4px);
    border-color: rgba(37, 99, 235, 0.3) !important;
    box-shadow: 0 8px 30px rgba(37, 99, 235, 0.08);
}

.demo-card:hover::before {
    opacity: 1;
}

.demo-card.border-primary {
    border-color: var(--accent-blue) !important;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.08), 0 4px 16px rgba(37, 99, 235, 0.08);
    background: #f8faff !important;
}

.demo-card.border-primary::before {
    opacity: 1;
}

/* ═══════ Layout ═══════ */
.app-container {
    display: flex;
    width: 100%;
}

.sidebar {
    width: 320px;
    background-color: #ffffff;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 20px;
}

.search-box input {
    width: 100%;
    padding: 10px 16px;
    background: var(--bg-muted);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.search-box input:focus {
    border-color: var(--accent-blue);
}

.deal-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.deal-list::-webkit-scrollbar {
    width: 6px;
}

.deal-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.08);
    border-radius: 3px;
}

.deal-item {
    padding: 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    margin-bottom: 8px;
    background: transparent;
}

.deal-item:hover {
    background: var(--bg-muted);
    border-color: var(--border-color);
}

.deal-item.active {
    background: rgba(37, 99, 235, 0.06);
    border-color: var(--accent-blue);
}

.deal-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.deal-item-header h4 {
    font-size: 0.95rem;
    color: var(--text-main);
    font-weight: 600;
}

.region-tag {
    font-size: 0.75rem;
    background: var(--bg-muted);
    padding: 2px 8px;
    border-radius: 12px;
    color: var(--text-muted);
}

.deal-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ═══════ Main Content ═══════ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--bg-main);
}

.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 40px;
    border-bottom: 1px solid var(--border-color);
}

.top-nav h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-main);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-indigo));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
    font-size: 0.8rem;
}

.role {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.btn-primary:hover {
    background: var(--accent-blue-hover) !important;
    border-color: var(--accent-blue-hover) !important;
    transform: translateY(-1px);
}

.content-body {
    padding: 40px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* ═══════ Header Section ═══════ */
.header-section {
    margin-bottom: 32px;
    background: #ffffff;
    border: 1px solid var(--border-color);
}

.title-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.title-row h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
}

.badge {
    background: rgba(37, 99, 235, 0.08);
    color: var(--accent-blue);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid rgba(37, 99, 235, 0.15);
}

.metric-row {
    display: flex;
    gap: 24px;
}

.metric-card {
    flex: 1;
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    padding: 18px 22px;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all 0.3s ease;
}

.metric-card:hover {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    border-color: var(--border-hover);
}

.metric-card .label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.metric-card .value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.metric-card .value.highlight {
    color: var(--amber);
}

.panel-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-header h3::before {
    content: '';
    width: 4px;
    height: 16px;
    background: var(--accent-blue);
    border-radius: 2px;
}

/* ═══════ Recommendation Panel ═══════ */
.rec-panel {
    position: relative;
    overflow: hidden;
}

.rec-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-indigo));
}

.recommended-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.rec-scenario {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.rec-scenario .big-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--accent-blue);
}

.executive-narrative {
    font-size: 0.92rem;
    line-height: 1.7;
    color: var(--text-secondary);
    background: var(--bg-subtle);
    padding: 20px;
    border-radius: 12px;
    border-left: 3px solid var(--accent-blue);
}

/* ═══════ Table ═══════ */
table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 12px 16px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
}

td {
    padding: 14px 16px;
    font-size: 0.92rem;
    border-bottom: 1px solid var(--bg-muted);
    color: var(--text-secondary);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: rgba(37, 99, 235, 0.02);
}

td strong {
    color: var(--text-main);
}

/* ═══════ Issues Summary ═══════ */
.issues-summary {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.issue-pill {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px;
    border-radius: 12px;
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.issue-pill:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.issue-pill .count {
    font-size: 1.5rem;
    font-weight: 800;
}

.issue-pill .label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 4px;
    font-weight: 600;
    color: var(--text-muted);
}

.issue-pill.red .count {
    color: var(--red);
}

.issue-pill.amber .count {
    color: var(--amber);
}

.issue-pill.green .count {
    color: var(--green);
}

.issues-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.issues-list li {
    font-size: 0.88rem;
    padding: 14px 16px;
    color: var(--text-secondary);
    background: #ffffff;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
    line-height: 1.5;
}

.issues-list li:hover {
    background: var(--bg-subtle);
}

.issues-list li.RED {
    border-left-color: var(--red);
}

.issues-list li.AMBER {
    border-left-color: var(--amber);
}

/* ═══════ Traceability ═══════ */
.trace-box p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.audit-list {
    list-style: none;
    font-family: 'Courier New', monospace;
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ═══════ Empty State ═══════ */
.empty-state {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 60px 20px;
    background: var(--bg-subtle);
    border: 1px dashed var(--border-color);
    border-radius: 20px;
    margin-top: 20px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.pulse-ring {
    width: 64px;
    height: 64px;
    background: rgba(37, 99, 235, 0.08);
    border-radius: 50%;
    position: relative;
    animation: pulse 2s infinite;
}

.pulse-ring::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    background: var(--accent-blue);
    border-radius: 50%;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.3);
    }

    70% {
        box-shadow: 0 0 0 20px rgba(37, 99, 235, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0);
    }
}

.empty-state h2,
.empty-state h5 {
    color: var(--text-main);
    font-weight: 500;
}

.empty-state p {
    color: var(--text-muted);
}

/* ════════════════════════════════════════════════════════════════
   ORCHESTRATOR SECTION — Light theme with high contrast
   ════════════════════════════════════════════════════════════════ */
.orchestrator-panel {
    background: #ffffff !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 20px rgba(0, 0, 0, 0.04) !important;
}

.orchestrator-panel .panel-header {
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border-color);
    padding: 18px 24px;
}

.orchestrator-panel .panel-header h3 {
    color: var(--text-main) !important;
    font-size: 0.9rem !important;
}

.orchestrator-panel #orchToggleIcon {
    color: var(--text-muted) !important;
}

.orchestrator-view {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: row !important;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0;
    padding: 0;
    background: #ffffff;
    min-height: 520px;
}

/* LEFT: Graph canvas */
.orch-canvas-wrapper {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-subtle);
    padding: 12px 12px 8px 12px;
    position: relative;
}

/* Subtle grid overlay */
.orch-canvas-wrapper::before {
    content: '';
    position: absolute;
    inset: 12px;
    background-image:
        radial-gradient(circle at 1px 1px, rgba(0, 0, 0, 0.04) 1px, transparent 0);
    background-size: 32px 32px;
    pointer-events: none;
    border-radius: 12px;
    z-index: 0;
}

#cy {
    width: 100% !important;
    min-height: 500px !important;
    flex: 1;
    border-radius: 12px;
    background: transparent !important;
    position: relative;
    z-index: 1;
}

/* RIGHT: Live output panel */
.live-output-panel {
    width: 380px;
    flex-shrink: 0;
    border-left: 1px solid var(--border-color);
    padding: 20px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    max-height: 600px;
}

.live-output-panel h6 {
    color: var(--text-muted) !important;
    font-size: 0.65rem !important;
    letter-spacing: 2px;
    font-weight: 700;
}

.live-output-panel h4 {
    color: var(--text-main) !important;
    font-size: 0.95rem !important;
}

#liveOutputContent {
    background: var(--bg-subtle) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 10px;
    padding: 16px !important;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.08) transparent;
}

#liveOutputContent::-webkit-scrollbar {
    width: 4px;
}

#liveOutputContent::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
}

/* Status bar */
.orch-status-box {
    margin-top: 6px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 100%;
    padding: 10px 14px;
    text-align: left;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.5s ease;
    z-index: 2;
    position: relative;
}

.orch-status-box.active {
    opacity: 1;
    transform: translateY(0);
}

.orch-timeline-container {
    width: 100%;
    height: 3px;
    background: var(--bg-muted);
    border-radius: 2px;
    margin-bottom: 6px;
    overflow: hidden;
}

.orch-timeline {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-indigo), var(--accent-violet));
    background-size: 200% 100%;
    animation: gradientShift 3s ease infinite;
    width: 0%;
    transition: width 0.4s ease-out;
    border-radius: 2px;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.orch-log {
    font-family: 'Courier New', monospace;
    color: var(--text-muted) !important;
    font-size: 0.75rem;
}

.orch-loading {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    margin-top: 6px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    font-size: 0.8rem;
    color: var(--accent-blue);
}
.orch-loading .spinner-border-sm { width: 1rem; height: 1rem; }

/* ═══════ LLM Output Typography ═══════ */
#liveOutputContent h1,
#liveOutputContent h2,
#liveOutputContent h3,
#liveOutputContent h4,
#liveOutputContent h5,
#liveOutputContent h6,
#liveOutputContent strong {
    font-size: 0.88rem !important;
    font-weight: 700 !important;
    margin-top: 0.5rem !important;
    margin-bottom: 0.3rem !important;
    color: var(--text-main) !important;
    line-height: 1.4 !important;
}

#liveOutputContent p,
#liveOutputContent span,
#liveOutputContent li,
#liveOutputContent div:not(.live-output-content) {
    font-size: 0.84rem !important;
    line-height: 1.55 !important;
    color: var(--text-secondary) !important;
    margin-bottom: 0.3rem !important;
}

/* Allow white text inside dark code blocks */
#liveOutputContent div[style*="monospace"] {
    color: #ffffff !important;
}

#liveOutputContent ul,
#liveOutputContent ol {
    padding-left: 1.2rem;
    margin-bottom: 0.5rem;
}

#liveOutputContent .text-muted {
    color: var(--text-muted) !important;
}

#liveOutputContent .text-primary {
    color: var(--accent-blue) !important;
}

#liveOutputContent .text-danger {
    color: var(--red) !important;
}

#liveOutputContent .border-bottom {
    border-color: var(--border-color) !important;
}

/* Exec narrative */
#execNarrative h1,
#execNarrative h2,
#execNarrative h3,
#execNarrative h4,
#execNarrative strong {
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    margin-top: 0.5rem !important;
    margin-bottom: 0.3rem !important;
    color: var(--text-main) !important;
    line-height: 1.4 !important;
}

#execNarrative p,
#execNarrative span:not(.typing-cursor),
#execNarrative li {
    font-size: 0.9rem !important;
    line-height: 1.65 !important;
    color: var(--text-secondary) !important;
    margin-bottom: 0.3rem !important;
}

/* Typing cursor */
.typing-cursor {
    animation: blink 0.7s infinite;
    color: var(--accent-blue) !important;
    font-weight: 400 !important;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* ═══════ Search Box ═══════ */
.search-box-premium {
    background: var(--bg-muted) !important;
    border: 1px solid var(--border-color) !important;
    backdrop-filter: none !important;
    box-shadow: none !important;
    transition: all 0.3s ease;
}

.search-box-premium:focus-within {
    border-color: var(--accent-blue) !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08) !important;
}

.search-box-premium input {
    color: var(--text-main) !important;
}

.search-box-premium input::placeholder {
    color: var(--text-muted) !important;
}

/* ═══════ Table overrides ═══════ */
.table-dark {
    --bs-table-bg: transparent !important;
    --bs-table-color: var(--text-secondary) !important;
}

.table-dark th {
    color: var(--text-muted) !important;
    border-bottom-color: var(--border-color) !important;
}

.table-dark td {
    color: var(--text-secondary) !important;
    border-bottom-color: var(--bg-muted) !important;
}

.table-dark tbody tr:hover td {
    background: rgba(37, 99, 235, 0.02) !important;
}

/* ═══════ Navbar — light ═══════ */
.navbar {
    background: #ffffff !important;
    border-bottom: 1px solid var(--border-color) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.navbar-brand {
    color: var(--text-main) !important;
}

/* ════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ════════════════════════════════════════ */
@media (max-width: 1200px) {
    .orchestrator-view {
        flex-direction: column !important;
        min-height: auto;
    }

    .live-output-panel {
        width: 100% !important;
        max-height: 350px;
        border-left: none !important;
        border-top: 1px solid var(--border-color);
    }

    #cy {
        min-height: 400px !important;
    }

    .content-body {
        padding: 24px;
    }

    .title-row h2 {
        font-size: 1.4rem;
    }
}

@media (max-width: 768px) {
    .content-body {
        padding: 16px;
    }

    .title-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .title-row h2 {
        font-size: 1.15rem;
    }

    .metric-row {
        flex-direction: column;
        gap: 12px;
    }

    .rec-scenario .big-value {
        font-size: 1.8rem;
    }

    #cy {
        min-height: 320px !important;
    }

    .live-output-panel {
        max-height: 280px;
        padding: 14px;
    }

    .orchestrator-view {
        flex-direction: column !important;
    }

    .issues-summary {
        flex-direction: column;
    }

    h1.display-5 {
        font-size: 1.5rem !important;
    }

    h2.h4 {
        font-size: 1rem !important;
    }

    .narrative {
        font-size: 0.9rem !important;
    }

    .glass-panel {
        padding: 16px;
        border-radius: 12px;
    }
}

@media (max-width: 480px) {
    .title-row h2 {
        font-size: 1.05rem;
    }

    .btn {
        font-size: 0.8rem;
        padding: 6px 12px;
    }

    #cy {
        min-height: 260px !important;
    }

    .live-output-panel {
        max-height: 250px;
        padding: 12px;
    }
}

/* ═══════ Data Modal ═══════ */
#dataModal .nav-tabs .nav-link {
    color: var(--text-muted);
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 18px;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

#dataModal .nav-tabs .nav-link:hover {
    color: var(--text-main);
    border-bottom-color: var(--border-hover);
}

#dataModal .nav-tabs .nav-link.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
    background: transparent;
}

#dataModal .table tbody tr:hover td {
    background: rgba(37, 99, 235, 0.03);
}

#dataModal .table tbody tr:nth-child(even) td {
    background: var(--bg-subtle);
}

#dataModal .table tbody tr:nth-child(even):hover td {
    background: rgba(37, 99, 235, 0.04);
}