:root {
    --primary: #123eb7;
    --primary-dark: #0d2e88;
    --primary-light: #e6ecf9;
    --secondary: #ffffff;
    --border: #f0f3fa;
    --border-strong: #d3dbed;
    --text: #00030a;
    --muted: #5c6773;
    --bg-soft: #f5f7fb;
    --bg-card: #ffffff;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f7fb;
    color: var(--text);
    margin: 0;
}

.app-header {
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.tno-logo {
    max-height: 64px;
    width: auto;
    padding: 0.2rem 0.4rem;
}

.app-brand h1,
.app-brand .subtitle {
    margin: 0;
}

.app-header nav a {
    color: white;
    text-decoration: none;
}

.current-user {
    font-size: 0.9rem;
    opacity: 0.9;
}

.card {
    border-radius: 12px;
}


.flash-container {
    max-width: 1200px;
    margin: 1rem auto 0 auto;
    padding: 0 2rem;
}

.flash {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.flash.success {
    background: #d1fae5;
    color: #064e3b;
}

.flash.error {
    background: #fee2e2;
    color: #991b1b;
}

.app-footer {
    color: #6b7280;
}

.hyphenate {
    hyphens: auto;
    word-break: break-word;
}

@media (min-width: 1200px) {

    .history-entry {
        border-left: 4px solid var(--primary);
        padding: 1rem 1rem 1rem 1.5rem;
        background: #fff;
        border-radius: 8px;
    }

    .history-entry+.history-entry {
        margin-top: 0.75rem;
    }

    .history-meta {
        font-size: 0.9rem;
        color: #6b7280;
    }

    .history-diff {
        margin-top: 0.5rem;
    }

    .history-diff table {
        width: 100%;
    }

    .history-diff th {
        width: 30%;
    }
}

.ghs-icon {
    height: 32px;
    width: auto;
    margin-right: 4px;
    vertical-align: middle;
}

@media print {
    /* Reset layout for print */
    body {
        background: white;
        color: black;
        margin: 0;
        padding: 0;
    }
    
    .container {
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Hide unnecessary elements */
    .app-header, 
    .app-footer,
    .flash-container,
    .d-print-none {
        display: none !important;
    }

    /* Hide DataTables controls */
    .dt-search, 
    .dt-length, 
    .dt-paging, 
    .dt-info {
        display: none !important;
    }

    /* Card adjustments */
    .card {
        border: none !important;
        box-shadow: none !important;
        margin-bottom: 0 !important;
    }

    .card-body {
        padding: 0 !important;
    }

    /* Table adjustments */
    .table-responsive {
        overflow: visible !important;
    }
    
    table {
        width: 100% !important;
        border-collapse: collapse !important;
    }
    
    /* Hide Actions column explicitly */
    th:last-child, 
    td:last-child {
        display: none !important;
    }
    
    /* Ensure text is black */
    th, td, h1, h2, h3, p {
        color: black !important;
    }

    /* Links shouldn't look like links necessarily, or show URL */
    a {
        text-decoration: none !important;
        color: black !important;
    }
}

/* ============================================================ */
/* Policy Compass — app-specific layout                          */
/* ============================================================ */

* { box-sizing: border-box; }

.app-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}
.app-header .subtitle {
    margin: 0;
    font-size: 0.85rem;
    opacity: 0.85;
}

.app-header nav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}
.app-header nav a {
    font-size: 0.9rem;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    transition: background 0.15s ease;
}
.app-header nav a:hover { background: rgba(255, 255, 255, 0.12); }
.app-header nav a.active {
    background: rgba(255, 255, 255, 0.18);
    font-weight: 600;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.25rem 2rem;
}

.app-footer {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 2rem 2.5rem;
    font-size: 0.8rem;
}

/* Dashboard grid (chat + scenarios) */
.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    gap: 1.25rem;
}
@media (max-width: 1000px) {
    .dashboard-grid { grid-template-columns: 1fr; }
}

.panel {
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
}
.panel h2 {
    margin: 0 0 0.85rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* Chat */
#chat-panel { height: calc(100vh - 180px); min-height: 540px; }
#messages {
    flex: 1;
    overflow-y: auto;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 0.85rem;
    background: var(--bg-soft);
    margin-bottom: 0.85rem;
}
.msg { margin-bottom: 1rem; }
.msg .role {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 0.25rem;
}
.msg .bubble {
    padding: 0.7rem 0.85rem;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid var(--border-strong);
    white-space: pre-wrap;
    font-size: 0.92rem;
    line-height: 1.5;
}
.msg.user .bubble {
    background: var(--primary-light);
    border-color: #c8d3ee;
}
.msg.assistant .bubble { white-space: normal; }
.msg .bubble > *:first-child { margin-top: 0; }
.msg .bubble > *:last-child { margin-bottom: 0; }
.msg .bubble p { margin: 0 0 0.6rem; }
.msg .bubble h1, .msg .bubble h2, .msg .bubble h3, .msg .bubble h4 {
    margin: 0.8rem 0 0.4rem;
    line-height: 1.3;
    font-weight: 600;
}
.msg .bubble h1 { font-size: 1.1rem; }
.msg .bubble h2 { font-size: 1.02rem; }
.msg .bubble h3, .msg .bubble h4 { font-size: 0.96rem; }
.msg .bubble ul, .msg .bubble ol { margin: 0.35rem 0 0.6rem 1.2rem; padding: 0; }
.msg .bubble li { margin-bottom: 0.2rem; }
.msg .bubble code {
    background: rgba(0, 0, 0, 0.06);
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    font-size: 0.85em;
}
.msg .bubble pre {
    background: rgba(0, 0, 0, 0.06);
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    overflow-x: auto;
}
.msg .bubble pre code { background: none; padding: 0; }
.msg .bubble table { border-collapse: collapse; margin: 0.4rem 0; }
.msg .bubble th, .msg .bubble td { border: 1px solid var(--border-strong); padding: 0.3rem 0.5rem; }
.msg .bubble a { color: var(--primary); }
.citations {
    margin-top: 0.5rem;
    font-size: 0.78rem;
    color: var(--muted);
}
.citations ul { margin: 0.25rem 0 0 1rem; padding: 0; }
.citations li { margin-bottom: 0.15rem; }

#composer { display: flex; gap: 0.5rem; }
#composer textarea {
    flex: 1;
    resize: vertical;
    min-height: 50px;
    max-height: 200px;
    padding: 0.65rem 0.75rem;
    font: inherit;
    font-size: 0.92rem;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: #ffffff;
}
#composer textarea:focus {
    outline: 2px solid var(--primary);
    outline-offset: -1px;
}

button {
    padding: 0.6rem 1.1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.15s ease;
}
button:hover { background: var(--primary-dark); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.quick-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.65rem;
}
.quick-prompts button {
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.78rem;
    padding: 0.4rem 0.7rem;
    font-weight: 500;
}
.quick-prompts button:hover { background: #d4dff5; }

/* Scenarios — collapsible accordion */
.scenario {
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    margin-bottom: 0.65rem;
    background: #ffffff;
    overflow: hidden;
}
.scenario[open] { border-color: var(--primary); }

.scenario > summary {
    list-style: none;
    cursor: pointer;
    padding: 0.85rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    user-select: none;
    transition: background 0.15s ease;
}
.scenario > summary:hover { background: var(--primary-light); }
.scenario > summary::-webkit-details-marker { display: none; }

.scenario .chevron {
    width: 0.7rem;
    height: 0.7rem;
    border-right: 2px solid var(--primary);
    border-bottom: 2px solid var(--primary);
    transform: rotate(-45deg);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}
.scenario[open] .chevron { transform: rotate(45deg); }

.scenario .summary-title {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}
.scenario .summary-title h3 {
    margin: 0;
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--text);
}
.scenario .summary-title .summary-tag {
    font-size: 0.75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.scenario .body {
    padding: 0.25rem 1rem 1rem;
    border-top: 1px solid var(--border);
}
.scenario .desc {
    font-size: 0.88rem;
    color: var(--muted);
    margin: 0.5rem 0 0.65rem;
    line-height: 1.45;
}
.scenario .measures {
    font-size: 0.85rem;
    margin: 0.3rem 0 0.8rem 1.1rem;
    padding: 0;
}
.scenario .measures li { margin-bottom: 0.15rem; }

.scenario canvas { max-height: 260px; }
.scenario .map {
    height: 280px;
    width: 100%;
    margin: 0.55rem 0;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--bg-soft);
}
.scenario .map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.75rem;
    font-size: 0.75rem;
    color: var(--muted);
    margin-bottom: 0.35rem;
}
.scenario .map-legend .item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.scenario .map-legend .swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 2px;
    border: 1px solid rgba(0,0,0,0.15);
}
.scenario .map-note {
    font-size: 0.75rem;
    color: var(--muted);
    font-style: italic;
    margin-top: 0.15rem;
}
.scenario .ask-row {
    margin-top: 0.65rem;
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.scenario .ask-row button {
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.78rem;
    padding: 0.35rem 0.7rem;
    font-weight: 500;
}
.scenario .ask-row button:hover { background: #d4dff5; }

.loading {
    color: var(--muted);
    font-style: italic;
    padding: 0.5rem;
    font-size: 0.9rem;
}

/* Indicators page */
.stats-row {
    display: flex;
    gap: 1rem;
    margin: 0 0 1.25rem;
    font-size: 0.9rem;
    color: var(--muted);
    flex-wrap: wrap;
}
.stats-row .stat {
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 0.5rem 0.85rem;
}
.stats-row strong { color: var(--text); font-size: 1.05rem; }

.indicators-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 1rem;
}

.ind-thema {
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    padding: 0.9rem 1rem;
    background: var(--bg-card);
}
.ind-thema h3 {
    margin: 0 0 0.5rem;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--primary);
    font-weight: 600;
}
.ind-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    padding: 0.45rem 0;
    font-size: 0.88rem;
    border-top: 1px dashed var(--border);
}
.ind-row:first-of-type { border-top: none; }
.ind-row .ind-name { color: var(--text); }
.ind-row .ind-value { font-weight: 600; white-space: nowrap; color: var(--text); }
.ind-row .ind-bron {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 0.76rem;
    margin-top: 0.15rem;
}

.badge {
    display: inline-block;
    font-size: 0.65rem;
    padding: 0.05rem 0.45rem;
    border-radius: 8px;
    margin-left: 0.4rem;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}
.badge.real { background: #d6e4d8; color: #1f5934; }
.badge.placeholder { background: #fbe4d4; color: #8a3b0c; }

/* About page */
.about-panel {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.75rem 2rem;
    line-height: 1.55;
}
.about-section { margin-bottom: 1.5rem; }
.about-section:last-child { margin-bottom: 0; }
.about-section h2 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0 0 0.6rem;
    text-align: left;
}
.about-section p { margin: 0; font-size: 0.95rem; }

.about-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}
@media (max-width: 700px) {
    .about-columns { grid-template-columns: 1fr; }
}

.tag-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.tag-list li {
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 999px;
    padding: 0.3rem 0.8rem;
    font-size: 0.82rem;
    font-weight: 500;
}

.about-dl { margin: 0; }
.about-dl dt {
    font-weight: 600;
    color: var(--text);
    margin-top: 0.5rem;
    font-size: 0.9rem;
}
.about-dl dt:first-child { margin-top: 0; }
.about-dl dd {
    margin: 0.15rem 0 0;
    color: var(--text);
    font-size: 0.95rem;
}

.source-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.source-list li {
    padding: 0.35rem 0;
    border-top: 1px dashed var(--border);
    font-size: 0.92rem;
}
.source-list li:first-child { border-top: none; }
.source-list a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}
.source-list a:hover { text-decoration: underline; }
