/* ResearchRadar stylesheet.
   Moved out of the page shell 2026-07-25 (audit A1): it was inlined into
   every response, 33 KB each time and never cached. Served from
   /static/app.css with a version query, so a deploy busts the cache. */

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

:root {
    --primary: #6B4C9A;
    --primary-light: #8B6DB5;
    --primary-dark: #4A3470;
    --primary-bg: #F3EFF8;
    --accent: #D4A843;
    --bg: #FAFAFA;
    --bg-card: #FFFFFF;
    --text: #2C2C2C;
    --text-light: #666666;
    --border: #E0D8E8;
    --shadow: 0 2px 8px rgba(107,76,154,0.08);
    --shadow-hover: 0 4px 16px rgba(107,76,154,0.15);
    --radius: 12px;
    --relevance-high: #2D8B4E;
    --relevance-medium: #D4A843;
    --relevance-low: #999999;
    /* the dots above are decoration; text uses these darker variants so it
       clears the 4.5:1 contrast minimum (audit U5) */
    --relevance-high-text: #1F6B39;
    --relevance-medium-text: #7A5B00;
    --relevance-low-text: #5C5C5C;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-light); }

/* Nav */
.nav {
    background: var(--primary-dark);
    color: white;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.nav-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.nav-brand:hover { color: var(--accent); }
.nav-brand svg { width: 24px; height: 24px; }
.nav-links { display: flex; gap: 1.5rem; align-items: center; }
.nav-links a {
    color: rgba(255,255,255,0.85);
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.25rem 0;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}
.nav-links a:hover, .nav-links a.active {
    color: white;
    border-bottom-color: var(--accent);
}
.lang-toggle {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.lang-toggle:hover {
    background: rgba(255,255,255,0.25);
}

/* Main */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    width: 100%;
    flex: 1;
}
/* Pages whose content is a wide table get the full window, not the reading column. */
main.wide {
    max-width: min(1680px, 100%);
    padding-left: 2rem;
    padding-right: 2rem;
}

/* Hero */
.hero {
    text-align: center;
    padding: 2.5rem 1rem 2rem;
}
.hero h1 {
    font-size: 2.2rem;
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
}
.hero .subtitle {
    font-size: 1.15rem;
    color: var(--text-light);
    max-width: 600px;
    margin: 0 auto;
}

/* Start-page intro + about page */
.home-intro {
    max-width: 720px;
    margin: 0 auto 1.5rem;
    text-align: center;
    font-size: 0.95rem;
    color: var(--text-light);
}
.home-intro a { font-weight: 600; white-space: nowrap; }
.about-text {
    max-width: 720px;
    margin: 1rem auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    line-height: 1.7;
}
.about-text h1 {
    font-size: 1.8rem;
    color: var(--primary-dark);
    margin-bottom: 1rem;
}
.about-text h2 {
    font-size: 1.1rem;
    color: var(--primary-dark);
    margin: 1.5rem 0 0.5rem;
}

/* Section */
.section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 2rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}
.section-header h2 {
    font-size: 1.3rem;
    color: var(--primary-dark);
}
.type-badge {
    display: inline-block;
    background: var(--primary-bg);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Cards grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.25rem;
}

/* Institution card */
.inst-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
}
.inst-card:hover {
    box-shadow: var(--shadow-hover);
    border-color: var(--primary-light);
}
.inst-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}
.inst-short-name {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-dark);
}
.inst-full-name {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
    line-height: 1.4;
}
.inst-desc {
    font-size: 0.9rem;
    color: var(--text);
    flex: 1;
    margin-bottom: 1rem;
}
.inst-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-top: auto;
}
.grant-count-badge {
    background: var(--primary-bg);
    color: var(--primary);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    white-space: nowrap;
}
/* the hidden attribute must always win, also against .btn's
   display: inline-flex (caught live: a "Löschen" button showed
   although no reminder was set) */
[hidden] { display: none !important; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.9rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}
.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover { background: var(--primary-light); color: white; }
.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--border);
}
.btn-outline:hover {
    border-color: var(--primary);
    background: var(--primary-bg);
    color: var(--primary);
}

/* Grant card */
.grant-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    /* jump-mark landings (calendar deep links) must clear the
       56px sticky nav, else it covers the card's headline */
    scroll-margin-top: 72px;
}
.grant-card:hover {
    box-shadow: var(--shadow-hover);
    border-color: var(--primary-light);
}
.grant-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}
/* the title column must be allowed to shrink: at its automatic minimum a
   long programme name pushed the relevance label out of the card */
.grant-card-header > div { min-width: 0; }
.grant-name { overflow-wrap: break-word; }
.grant-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-dark);
}
.relevance-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 0.4rem;
}
.relevance-dot.high { background: var(--relevance-high); }
.relevance-dot.medium { background: var(--relevance-medium); }
.relevance-dot.low { background: var(--relevance-low); }
.relevance-label {
    font-size: 0.75rem;
    font-weight: 500;
}
.relevance-label.high { color: var(--relevance-high-text); }
.relevance-label.medium { color: var(--relevance-medium-text); }
.relevance-label.low { color: var(--relevance-low-text); }
.grant-inst-badge {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-bg);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    display: inline-block;
}
.grant-desc {
    font-size: 0.9rem;
    color: var(--text);
    margin-bottom: 0.75rem;
    flex: 1;
}
.grant-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 0.75rem;
}
.grant-meta-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.grant-meta-label { font-weight: 600; color: var(--text); }
.grant-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
}
.tag {
    font-size: 0.75rem;
    background: var(--primary-bg);
    color: var(--primary);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
}
.grant-card-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: auto;
}
.grant-updated {
    font-size: 0.72rem;
    color: #5c5c5c;
    margin-top: 0.5rem;
}

.new-badge {
    display: inline-block;
    background: #2E7D32;
    color: white;
    font-size: 0.68rem;
    font-weight: 600;
    border-radius: 999px;
    padding: 0.1rem 0.55rem;
    margin-left: 0.35rem;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.nonresearch-badge {
    display: inline-block;
    background: #B26A00;
    color: white;
    font-size: 0.68rem;
    font-weight: 600;
    border-radius: 999px;
    padding: 0.1rem 0.55rem;
    margin-left: 0.35rem;
    vertical-align: middle;
    letter-spacing: 0.03em;
}

/* on their own line inside a table cell the badges need no
   inline indent, just a little air above */
.cell-target .nonresearch-badge,
.cell-firstseen .new-badge {
    margin-left: 0;
    margin-top: 0.2rem;
}

/* calendar month view */
.cal-nav { display: flex; align-items: center; gap: 1rem; margin: 1rem 0; }
.cal-nav h2 { margin: 0; min-width: 12rem; text-align: center; }
.cal-scroll { overflow-x: auto; }
.cal-grid { width: 100%; border-collapse: collapse; table-layout: fixed; min-width: 640px; }
.cal-grid th { padding: 0.4rem; border: 1px solid var(--border); background: var(--primary-bg); font-size: 0.8rem; }
.cal-grid td { border: 1px solid var(--border); vertical-align: top; height: 5.5rem; padding: 0.3rem; background: var(--bg-card); }
.cal-grid td.cal-out { background: var(--bg); }
.cal-grid td.cal-out .cal-daynum { color: #8a8a8a; }
.cal-grid td.cal-today { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-daynum { font-size: 0.8rem; color: var(--text-light); margin-bottom: 0.2rem; }
.cal-entry {
    display: block;
    font-size: 0.72rem;
    line-height: 1.25;
    background: var(--primary-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.15rem 0.35rem;
    margin-bottom: 0.2rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cal-entry:hover { background: var(--border); }
.calendar-empty { color: var(--text-light); margin: 1rem 0; }

/* bottom tab bar — phones only (whatthespec pattern) */
.tabbar { display: none; }
@media (max-width: 768px) {
    :root { --tabbar-h: 54px; }
    .tabbar {
        display: flex;
        position: fixed;
        left: 0; right: 0; bottom: 0;
        height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: var(--primary-dark);
        box-shadow: 0 -2px 8px rgba(0,0,0,0.2);
        z-index: 100;
    }
    .tabbar .tab {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.15rem;
        color: rgba(255,255,255,0.75);
        font-size: 0.68rem;
        font-weight: 500;
    }
    .tabbar .tab svg { width: 21px; height: 21px; }
    .tabbar .tab.on { color: var(--accent); font-weight: 600; }
    body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); }
    /* the four main links live in the tabbar on phones */
    .nav-links a.nav-main { display: none; }
}

/* visually hidden, present for screen readers and crawlers */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* legal pages + footer legal links */
.legal-page { max-width: 46rem; }
.legal-page h2 { margin: 1.2rem 0 0.4rem; font-size: 1.05rem; }
.legal-page p, .legal-page ul { margin: 0.5rem 0; }
.legal-page ul { padding-left: 1.2rem; }
.footer-legal { margin-top: 0.5rem; font-size: 0.8rem; }
.footer-legal a { color: inherit; text-decoration: underline; }

/* feed explainer page */
.feed-page p { margin: 0.8rem 0; max-width: 46rem; }
.feed-url { background: var(--primary-bg); border: 1px solid var(--border); border-radius: 6px; padding: 0.4rem 0.7rem; display: inline-block; }
.feed-hint { color: var(--text-light); font-size: 0.9rem; }

/* reminder bell + modal */
.bell-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-light);
    border-radius: 999px;
    padding: 0.2rem 0.45rem;
    cursor: pointer;
    margin-right: 0.25rem;
    vertical-align: middle;
}
.bell-btn svg { width: 15px; height: 15px; }
/* a set reminder turns the bell green (SVG, not emoji — emoji
   fonts render too faint or blank on several phones) */
.bell-btn.bell-set {
    color: #fff;
    background: var(--relevance-high);
    border-color: var(--relevance-high);
}
.bell-btn:hover { border-color: var(--primary); color: var(--primary); }
.bell-btn.bell-set:hover { color: #fff; border-color: var(--primary-dark); }
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.45);
    display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
    background: var(--bg-card); border-radius: var(--radius);
    box-shadow: var(--shadow-hover); padding: 1.5rem; max-width: 26rem; width: 92%;
}
.modal-box h3 { margin-bottom: 0.5rem; }
.modal-hint { color: var(--text-light); font-size: 0.9rem; margin-bottom: 1rem; }
.modal-actions { display: flex; gap: 0.5rem; margin-top: 1rem; flex-wrap: wrap; }

/* per-deadline calendar download under the date */
.cal-pill {
    display: inline-block;
    margin-top: 0.2rem;
    font-size: 0.68rem;
    font-weight: 600;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.05rem 0.5rem;
    background: var(--primary-bg);
    color: var(--primary);
    letter-spacing: 0.03em;
}
.cal-pill:hover { background: var(--border); color: var(--primary-dark); }

.discontinued-badge {
    display: inline-block;
    background: #757575;
    color: white;
    font-size: 0.68rem;
    font-weight: 600;
    border-radius: 999px;
    padding: 0.1rem 0.55rem;
    margin-left: 0.35rem;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.new-window-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.new-window-bar .pill { text-decoration: none; }
.new-window-label { font-size: 0.85rem; color: #666; }

.health-table td, .health-table th { font-size: 0.85rem; }
tr.health-warn td { background: #FDECEA; color: #B71C1C; }
/* the sticky first-column rule (audit W3) sets a card background
   on td:first-child — keep warn rows fully red-shaded */
tr.health-warn td:first-child { background: #FDECEA; }

.auth-card {
    max-width: 26rem;
    margin: 2rem auto;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
}
.auth-card-wide { max-width: 40rem; }
.auth-card h1 { font-size: 1.4rem; margin-bottom: 1rem; }
.auth-card form label {
    display: block;
    margin-bottom: 0.9rem;
    font-size: 0.85rem;
    color: #555;
}
.auth-card form input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]) {
    display: block;
    width: 100%;
    margin-top: 0.3rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
}
.auth-card form input:focus { outline: 2px solid var(--primary-light); border-color: var(--primary); }
.auth-card .btn { margin-top: 0.4rem; }
.auth-alt { margin-top: 1rem; font-size: 0.85rem; color: #666; }
.form-error {
    background: #FDECEA; color: #B71C1C;
    border-radius: 8px; padding: 0.6rem 0.8rem;
    font-size: 0.85rem; margin-bottom: 1rem;
}
.form-ok {
    background: #E8F5E9; color: #1B5E20;
    border-radius: 8px; padding: 0.6rem 0.8rem;
    font-size: 0.85rem; margin-bottom: 1rem;
}
.check-line {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem !important;
    color: #333 !important;
    margin-bottom: 0.5rem !important;
}
.scope-block { margin: 0.75rem 0 1rem; padding-left: 0.25rem; }
.funder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
    gap: 0.1rem 0.8rem;
    margin: 0.5rem 0 0 1.6rem;
}
.nav-logout { display: inline; }
.nav-logout button {
    background: none; border: none; cursor: pointer;
    color: inherit; font: inherit; padding: 0;
}
.nav-logout button:hover { color: var(--primary); }

/* Filters */
.filters-bar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}
.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}
.filter-group { flex: 1; min-width: 200px; }
.filter-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.filter-group input, .filter-group select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
    color: var(--text);
}
.filter-group input:focus, .filter-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(107,76,154,0.15);
}
.results-count {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 1rem;
}

/* Institution detail */
.inst-detail-header {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 2rem;
}
.inst-detail-header h1 {
    font-size: 1.8rem;
    color: var(--primary-dark);
    margin-bottom: 0.25rem;
}
.inst-detail-header .full-name {
    color: var(--text-light);
    font-size: 1rem;
    margin-bottom: 1rem;
}
.inst-detail-header .description {
    font-size: 1rem;
    line-height: 1.7;
    margin-bottom: 1.25rem;
}
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

/* Footer */
footer {
    background: var(--primary-dark);
    color: rgba(255,255,255,0.7);
    text-align: center;
    padding: 1.5rem;
    font-size: 0.85rem;
    margin-top: auto;
}
footer a { color: rgba(255,255,255,0.85); }
footer a:hover { color: white; }
.footer-updated {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.5);
}

/* Grants list */
.grants-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Overview: career-stage filter pills */
/* The filter block is folded away by default (it is a wall of pills and
   explanations); the summary line is the whole control. */
.stage-filter {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0;
    margin-bottom: 1.25rem;
}
.stage-filter > .filter-body { padding: 0 1.25rem 1.1rem; }
.stage-filter-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-dark);
    letter-spacing: 0.3px;
    cursor: pointer;
    list-style: none;
    min-height: 44px;
}
.stage-filter-head::-webkit-details-marker { display: none; }
.stage-filter-head::before {
    content: "\25B8";
    color: var(--primary);
    transition: transform 0.15s;
}
.stage-filter[open] > .stage-filter-head::before { transform: rotate(90deg); }
.stage-filter-head:hover { background: var(--primary-bg); border-radius: var(--radius); }
.stage-filter-head:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
    border-radius: var(--radius);
}
/* how many filters are on — visible while the block is folded away */
.filter-active {
    font-size: 0.72rem;
    font-weight: 600;
    background: var(--primary);
    color: white;
    border-radius: 999px;
    padding: 0.05rem 0.5rem;
}
/* "Alle" sits to the left of both rows and clears both. */
.filter-grid {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.filter-grid > .pill-all { flex-shrink: 0; }
.pill-rows {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}
.pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.pill-status .pill-code { font-weight: 600; }
.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.35rem 0.85rem;
    font-size: 0.85rem;
    font-family: inherit;
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s;
}
.pill:hover { border-color: var(--primary-light); background: var(--primary-bg); }
.pill.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}
.pill-code { font-weight: 700; }
.pill-text { color: inherit; opacity: 0.85; }
.pill-count {
    font-size: 0.72rem;
    font-weight: 600;
    background: var(--primary-bg);
    color: var(--primary);
    border-radius: 999px;
    padding: 0.05rem 0.4rem;
    min-width: 1.5em;
    text-align: center;
}
.pill.active .pill-count { background: rgba(255,255,255,0.25); color: white; }
.stage-explainer {
    font-size: 0.8rem;
    color: var(--text-light);
    line-height: 1.55;
    margin-top: 0.85rem;
}
.no-results { text-align: center; color: #5c5c5c; padding: 2rem; }
.no-results .btn { margin-top: 0.75rem; }

/* Overview table */
.overview-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
/* the four download buttons must be allowed to wrap — as one unbreakable
   row they pushed the whole start page sideways on a phone */
.overview-downloads { display: flex; flex-wrap: wrap; gap: 0.5rem; }
/* The table is meant to be read, not scrolled: it always fits the window
   width, and the page scrolls as one instead of a box inside a box.
   Columns are fixed shares of the width, so no single long value can push
   the layout sideways; narrow screens drop the least useful columns
   (everything stays in the CSV/Excel download). */
.table-scroll {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.overview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
#overview-table { table-layout: fixed; }
/* break a word only when it genuinely cannot fit, so headings wrap at
   their spaces instead of splitting into "FÖRDERGE BER" */
#overview-table th, #overview-table td { overflow-wrap: break-word; }
#overview-table th:nth-child(1) { width: 8%; }
#overview-table th:nth-child(2) { width: 20%; }
#overview-table th:nth-child(3) { width: 10%; }
#overview-table th:nth-child(4) { width: 11%; }
#overview-table th:nth-child(5) { width: 14%; }
#overview-table th:nth-child(6) { width: 9%; }
#overview-table th:nth-child(7) { width: 15%; }
#overview-table th:nth-child(8) { width: 7%; }
#overview-table th:nth-child(9) { width: 6%; }
.overview-table th {
    background: var(--primary-bg);
    color: var(--primary-dark);
    text-align: left;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0;
    padding: 0.6rem 0.55rem;
    border-bottom: 2px solid var(--border);
    user-select: none;
}
.overview-table th .sort-btn {
    /* deliberately not a flex row: a flex container refuses to shrink below
       its content, which pushed the whole table past the window edge */
    display: block;
    width: 100%;
    min-width: 0;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    color: inherit;
    text-align: left;
    text-transform: inherit;
    letter-spacing: inherit;
    cursor: pointer;
}
.overview-table th:hover { background: #E9E1F2; }
.overview-table th .sort-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.sort-arrow { display: inline-block; width: 0.9em; color: var(--primary); }
th.sorted-asc .sort-arrow::after { content: "\25B2"; font-size: 0.7em; }
th.sorted-desc .sort-arrow::after { content: "\25BC"; font-size: 0.7em; }
.overview-table td {
    padding: 0.6rem 0.55rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    line-height: 1.45;
}
.overview-table tbody tr:hover { background: #FBF9FD; }
.overview-table tbody tr:last-child td { border-bottom: none; }
/* the header row stays put while the page scrolls; 56px is the sticky nav */
.overview-table thead th {
    position: sticky;
    top: 56px;
    z-index: 3;
    background: var(--primary-bg);
}
.table-hint {
    font-size: 0.78rem;
    color: #5c5c5c;
    margin: 0.35rem 0;
}
.cell-deadline { white-space: nowrap; }
.deadline-value { font-weight: 600; color: var(--primary-dark); }
.deadline-value.bucket-1 { color: var(--relevance-high); font-weight: 500; }
.deadline-value.bucket-2 { color: var(--text-light); font-weight: 400; }
.deadline-value.bucket-3 { color: var(--text-light); font-weight: 400; }
.deadline-note {
    display: block;
    font-size: 0.7rem;
    color: #6b6b6b;
}
.row-expired { background: #FCFCFC; }
.row-expired .cell-name a { color: var(--primary); }
.cell-target { color: var(--text-light); }
.cell-info { color: var(--text-light); }
/* up to three badges in a narrow column — they must wrap, not push the
   whole page sideways */
.cell-stages { white-space: normal; }
.cell-stages .stage-badge { margin-bottom: 0.15rem; }
.cell-website a {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.stage-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    margin-right: 0.2rem;
    background: var(--primary-bg);
    color: var(--primary);
}
.stage-badge.stage-org { background: #EFEFEF; color: #777; }
.stage-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.25rem;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 1rem;
}
.overview-note {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 0.75rem;
    line-height: 1.5;
}

/* Portal section */
.portal-note {
    font-size: 0.9rem;
    color: var(--text-light);
    font-style: italic;
    margin-bottom: 0.75rem;
}

/* Responsive */
@media (max-width: 768px) {
    .nav {
        padding: 0.5rem 1rem;
        height: auto;
        min-height: 56px;
        gap: 0.4rem;
    }
    /* the four main links live in the bottom tab bar; what
       remains (alarm/login/logout, language) stays on ONE line
       right of the brand — nothing wraps left underneath */
    .nav-links {
        margin-left: auto;
        flex-wrap: nowrap;
        gap: 0.4rem;
    }
    .nav-links a, .nav-logout button {
        border: 1px solid rgba(255,255,255,0.35);
        border-radius: 8px;
        padding: 0.35rem 0.7rem;
        border-bottom-width: 1px;
    }
    .nav-links a:hover, .nav-links a.active {
        border-color: var(--accent);
    }
    .cal-grid { min-width: 0; }
    .cal-grid th { padding: 0.2rem; font-size: 0.7rem; }
    .cal-grid td { height: 3.6rem; padding: 0.15rem; }
    .cal-daynum { font-size: 0.65rem; margin-bottom: 0.1rem; }
    .cal-entry { font-size: 0.6rem; padding: 0.1rem 0.25rem; }
    .cal-nav { gap: 0.5rem; }
    .cal-nav h2 { min-width: 0; font-size: 1.05rem; }
    .hero h1 { font-size: 1.7rem; }
    .hero .subtitle { font-size: 1rem; }
    main { padding: 1rem; }
    .cards-grid { grid-template-columns: 1fr; }
    .filters-row { flex-direction: column; }
    .filter-group { min-width: 100%; }
    .filter-grid { flex-direction: column; align-items: stretch; }
    .filter-grid > .pill-all { align-self: flex-start; }
    .inst-detail-header { padding: 1.25rem; }
    .inst-detail-header h1 { font-size: 1.4rem; }
}

/* The table always fits: as the window narrows, the least useful columns
   step out one by one, widest first. Nothing is lost — the CSV and Excel
   downloads always contain every column. */
@media (max-width: 1180px) {
    #overview-table th:nth-child(n+8),
    #overview-table td:nth-child(n+8) { display: none; }
    #overview-table th:nth-child(2) { width: 24%; }
    #overview-table th:nth-child(5) { width: 20%; }
    #overview-table th:nth-child(7) { width: 20%; }
}
@media (max-width: 900px) {
    #overview-table th:nth-child(7),
    #overview-table td:nth-child(7) { display: none; }
    #overview-table th:nth-child(2) { width: 32%; }
    #overview-table th:nth-child(5) { width: 26%; }
}
@media (max-width: 680px) {
    #overview-table th:nth-child(5),
    #overview-table td:nth-child(5) { display: none; }
    #overview-table th:nth-child(1) { width: 16%; }
    #overview-table th:nth-child(2) { width: 38%; }
    #overview-table th:nth-child(3) { width: 15%; }
    #overview-table th:nth-child(4) { width: 17%; }
    #overview-table th:nth-child(6) { width: 14%; }
    .overview-table { font-size: 0.8rem; }
    .overview-table th, .overview-table td { padding: 0.5rem 0.45rem; }
}
@media (max-width: 460px) {
    #overview-table th:nth-child(4),
    #overview-table td:nth-child(4) { display: none; }
    #overview-table th:nth-child(1) { width: 24%; }
    #overview-table th:nth-child(2) { width: 42%; }
    #overview-table th:nth-child(3) { width: 18%; }
    #overview-table th:nth-child(6) { width: 16%; }
}

@media (max-width: 480px) {
    .nav-brand span { display: none; }
    .grant-meta { flex-direction: column; gap: 0.25rem; }
}

/* Print: the table on paper, nothing else. */
@media print {
    .nav, .tabbar, footer, .overview-toolbar, .stage-filter,
    .table-hint, .skip-link, .bell-btn, .cal-pill { display: none !important; }
    body { background: white; }
    main, main.wide { max-width: none; padding: 0; }
    .table-scroll { border: none; }
    .overview-table { font-size: 9pt; }
    .overview-table thead th { position: static; }
    .overview-table tbody tr { page-break-inside: avoid; }
    a { color: black; text-decoration: none; }
}

/* Skip link: first thing keyboard and screen-reader users reach. */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 200;
    background: var(--primary-dark);
    color: white;
    padding: 0.6rem 1rem;
    border-radius: 0 0 8px 0;
}
.skip-link:focus {
    left: 0;
    color: white;
}
main:focus { outline: none; }

/* Tap targets on phones: every pill and small button reaches 44px. */
@media (max-width: 768px) {
    .pill, .cal-pill, .bell-btn { min-height: 44px; }
    .cal-pill { display: inline-flex; align-items: center; }
}
