/* Förderatlas view (crm-foerderatlas.js). Everything is scoped under .fatl and built on crm-design-tokens.css,
   so light/dark mode and the brand colour follow the CRM automatically. */
#view-foerderatlas { max-width: 1480px; margin: auto; font-size: var(--ui-body-size, 13px); font-variant-numeric: tabular-nums; }
body[data-crm-view=foerderatlas] .topbar .search-wrap { display: none; }
.fatl {
    --fatl-ja: var(--green, #10b981);
    --fatl-teil: var(--brand);
    --fatl-unklar: #d99a2b;
    --fatl-none: #a3acba;
    --fatl-nein: #d64545;
    --fatl-frist: #d9542b;
    --fatl-region: var(--surface-2);
    --fatl-region-line: var(--border-strong);
    --fatl-tint: color-mix(in srgb, var(--brand) 10%, transparent);
}
body.dark-mode .fatl {
    --fatl-ja: #34d399;
    --fatl-teil: var(--brand-on-dark);
    --fatl-unklar: #e8b25a;
    --fatl-none: #556072;
    --fatl-nein: #f07a7a;
    --fatl-frist: #f08a5d;
    --fatl-region: #1a222e;
    --fatl-tint: color-mix(in srgb, var(--brand-on-dark) 12%, transparent);
}
.fatl .workspace-description { color: var(--muted); margin: 8px 0 0; line-height: 1.6; max-width: 760px; }
.fatl-loading, .fatl-error { padding: 40px 0; color: var(--muted); }
.fatl-error small { display: block; margin-top: 6px; }

/* Metrics row, same rhythm as Teamübersicht */
.fatl-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; padding: 0 0 26px; }
.fatl-metric { display: grid; gap: 10px; padding-right: 20px; border-right: 1px solid var(--border); }
.fatl-metric:last-child { border: 0; }
.fatl-metric span { color: var(--muted); font-size: var(--ui-label-size, 11px); line-height: 1.5; }
.fatl-metric strong { font-size: var(--ui-metric-size, 21px); font-weight: 500; }

.fatl-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }

/* Map card */
.fatl-stage { position: relative; display: flex; flex-direction: column; height: clamp(600px, calc(100vh - 140px), 920px);
    background: var(--card); border: 1px solid var(--border); border-radius: var(--ui-panel-radius, var(--radius)); box-shadow: var(--shadow); overflow: hidden; }
.fatl-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.fatl-seg { display: flex; flex-wrap: wrap; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--ui-field-bg, var(--bg)); }
.fatl-seg button { border: 0; background: transparent; color: var(--muted); font: 500 12px/1 var(--app-font); padding: 9px 13px; border-radius: var(--radius-sm, 2px); cursor: pointer; min-height: 32px; }
.fatl-seg button:hover { color: var(--text); }
.fatl-seg button[aria-pressed=true] { background: var(--brand); color: var(--on-brand); }
.fatl-seg button sup { font-size: 9px; font-weight: 600; margin-left: 3px; color: var(--fatl-ja); }
.fatl-seg button[aria-pressed=true] sup { color: inherit; opacity: .85; }
.fatl-svc { order: 3; flex: 1 1 100%; width: max-content; max-width: 100%; }
.fatl-svc button { padding: 8px 10px; font-size: 11.5px; }
.fatl-toggle { margin-left: auto; display: inline-flex; align-items: center; gap: 9px; min-height: 38px; padding: 0 13px; border: 1px solid var(--border);
    border-radius: var(--radius); background: var(--surface); color: var(--muted); font: 500 12px var(--app-font); cursor: pointer; }
.fatl-toggle[aria-pressed=true] { color: var(--text); border-color: var(--border-strong); }
.fatl-sw { width: 28px; height: 16px; border-radius: 99px; background: var(--border-strong); position: relative; transition: background .2s; }
.fatl-sw::after { content: ""; position: absolute; width: 12px; height: 12px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: left .2s; }
.fatl-toggle[aria-pressed=true] .fatl-sw { background: var(--brand); }
.fatl-toggle[aria-pressed=true] .fatl-sw::after { left: 14px; }

.fatl-mapwrap { position: relative; flex: 1; min-height: 0; overflow: hidden;
    background-image: radial-gradient(color-mix(in srgb, var(--text) 7%, transparent) 1px, transparent 1px); background-size: 22px 22px; }
.fatl-map { position: absolute; inset: 0; width: 100%; height: 100%; }
.fatl-region { fill: var(--fatl-region); stroke: var(--fatl-region-line); stroke-width: 1; vector-effect: non-scaling-stroke; cursor: pointer; transition: fill .2s, stroke .2s, opacity .3s; }
.fatl-region:hover { fill: color-mix(in srgb, var(--brand) 12%, var(--fatl-region)); stroke: var(--brand); }
.fatl-region.sel { fill: color-mix(in srgb, var(--brand) 16%, var(--fatl-region)); stroke: var(--brand); stroke-width: 1.8; }
.fatl-region.dim { opacity: .35; }
.fatl-dot { cursor: pointer; transition: opacity .3s; }
.fatl-dot.dim { opacity: .18; }
.fatl-dot .fatl-core { stroke: var(--card); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.fatl-dot text { font-family: var(--app-font); font-weight: 600; fill: #fff; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.fatl-dot .fatl-halo { opacity: 0; animation: fatl-pulse 2.8s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes fatl-pulse { 0% { opacity: .35; transform: scale(1); } 100% { opacity: 0; transform: scale(2.4); } }
@media (prefers-reduced-motion: reduce) { .fatl-dot .fatl-halo { animation: none; } }

.fatl-tip { position: absolute; pointer-events: none; z-index: 6; padding: 9px 12px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--border);
    box-shadow: var(--shadow-lg); font-size: 12px; opacity: 0; transform: translateY(4px); transition: opacity .15s, transform .15s; white-space: nowrap; }
.fatl-tip.on { opacity: 1; transform: none; }
.fatl-tip b { display: block; font-weight: 600; font-size: 13px; }
.fatl-tip span { color: var(--muted); }
.fatl-bund { position: absolute; left: 16px; bottom: 16px; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--card); box-shadow: var(--shadow); color: var(--text); cursor: pointer; font: inherit; text-align: left; }
.fatl-bund:hover { border-color: var(--brand); }
.fatl-bund b { font-weight: 600; }
.fatl-bund small { display: block; color: var(--muted); font-size: 11px; }
.fatl-n { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--fatl-unklar); color: #fff; font-weight: 600; flex: none; }
.fatl-n.leer { background: var(--fatl-none); }
.fatl-hint { position: absolute; right: 16px; bottom: 20px; font-size: 11px; color: var(--muted); z-index: 5; }

/* Programme panel */
.fatl-panel { position: absolute; top: 12px; right: 12px; bottom: 12px; width: min(460px, calc(100% - 24px)); z-index: 8; display: flex; flex-direction: column;
    background: var(--card); border: 1px solid var(--border); border-radius: var(--ui-dialog-radius, var(--radius)); box-shadow: var(--shadow-lg);
    transform: translateX(calc(100% + 24px)); transition: transform .45s cubic-bezier(.2, .8, .2, 1); }
.fatl-panel.on { transform: none; }
@media (prefers-reduced-motion: reduce) { .fatl-panel { transition: none; } }
.fatl-ph { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 20px 20px 14px; border-bottom: 1px solid var(--border); }
.fatl-ph .workspace-eyebrow { margin: 0 0 4px; }
.fatl-ph h3 { font-size: var(--ui-section-size, 17px); font-weight: 550; letter-spacing: -.3px; margin: 0 0 4px; }
.fatl-ph p:not(.workspace-eyebrow) { margin: 0; color: var(--muted); font-size: 12px; }
.fatl-x { flex: none; width: 34px; height: 34px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font-size: 18px; cursor: pointer; }
.fatl-x:hover { border-color: var(--border-strong); }
.fatl-pb { overflow: auto; padding: 12px 14px 20px; display: flex; flex-direction: column; gap: 8px; }
.fatl-prog { flex: none; border: 1px solid var(--border); border-radius: var(--ui-item-radius, var(--radius)); background: var(--surface); overflow: hidden; }
.fatl-prog.open { border-color: var(--border-strong); }
.fatl-prog.closed { opacity: .55; }
.fatl-pr { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 12px; align-items: center; width: 100%; padding: 12px 14px; background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.fatl-pr:hover b { color: var(--primary); }
.fatl-d { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.fatl-pr b { display: block; font-weight: 550; font-size: 13px; line-height: 1.35; }
.fatl-pr small { color: var(--muted); font-size: 11px; }
.fatl-amt { text-align: right; font-weight: 550; white-space: nowrap; }
.fatl-amt small { display: block; font-weight: 400; color: var(--muted); }
.fatl-amt small.frist { color: var(--fatl-frist); }
.fatl-pd { display: none; padding: 0 14px 14px 36px; font-size: 12.5px; }
.fatl-prog.open .fatl-pd { display: block; }
.fatl-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 12px; }
.fatl-chip, .fatl-vf { font-size: 10.5px; font-weight: 550; padding: 3px 8px; border-radius: var(--r-pille, 4px); border: 1px solid var(--border); color: var(--muted); }
.fatl-chip.fit-ja { color: var(--fatl-ja); border-color: color-mix(in srgb, var(--fatl-ja) 40%, transparent); }
.fatl-chip.fit-teilweise { color: var(--fatl-teil); border-color: color-mix(in srgb, var(--fatl-teil) 40%, transparent); }
.fatl-chip.fit-unklar { color: var(--fatl-unklar); border-color: color-mix(in srgb, var(--fatl-unklar) 40%, transparent); }
.fatl-chip.fit-nein { color: var(--fatl-nein); border-color: color-mix(in srgb, var(--fatl-nein) 40%, transparent); }
.fatl-vf { border: 0; }
.fatl-vf.original { color: var(--fatl-ja); background: color-mix(in srgb, var(--fatl-ja) 12%, transparent); }
.fatl-vf.kammer { color: var(--fatl-teil); background: color-mix(in srgb, var(--fatl-teil) 12%, transparent); }
.fatl-vf.sekundaer, .fatl-vf.ungeprueft { color: var(--fatl-unklar); background: color-mix(in srgb, var(--fatl-unklar) 14%, transparent); }
.fatl-pd dl { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 8px 14px; margin: 0; }
.fatl-pd dt { color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; font-weight: 550; padding-top: 2px; }
.fatl-pd dd { margin: 0; color: var(--text); line-height: 1.55; overflow-wrap: anywhere; }
.fatl-muted { color: var(--muted); }
.fatl-note { margin-top: 12px; padding: 10px 12px; border-radius: var(--radius); font-size: 12px; line-height: 1.55; }
.fatl-note.rel { background: color-mix(in srgb, var(--fatl-ja) 9%, transparent); border: 1px solid color-mix(in srgb, var(--fatl-ja) 25%, transparent); }
.fatl-note.warn { background: color-mix(in srgb, var(--fatl-unklar) 10%, transparent); border: 1px solid color-mix(in srgb, var(--fatl-unklar) 28%, transparent); }
.fatl-src { font-size: 11px; color: var(--muted); margin-top: 10px; }
.fatl-btns { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.fatl-btn { display: inline-flex; align-items: center; min-height: 36px; padding: 0 13px; border-radius: var(--ui-button-radius, var(--radius)); background: var(--brand); color: var(--on-brand); font-weight: 550; font-size: 12px; text-decoration: none; }
.fatl-btn:hover { background: var(--brand-hover); }
.fatl-btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.fatl-btn.ghost:hover { border-color: var(--border-strong); }
.fatl-sec { font-size: 10px; letter-spacing: .13em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin: 12px 2px 2px; }
.fatl-empty { color: var(--muted); padding: 14px; border: 1px dashed var(--border); border-radius: var(--radius); }

/* Service matrix */
.fatl-mx { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; margin: 4px 0 14px; }
.fatl-mx div { border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 4px; text-align: center; font-size: 10px; color: var(--muted); line-height: 1.25; }
.fatl-mx b { display: block; font-size: 14px; margin-bottom: 2px; }
.fatl-mx .v-ja { border-color: color-mix(in srgb, var(--fatl-ja) 45%, transparent); background: color-mix(in srgb, var(--fatl-ja) 8%, transparent); }
.fatl-mx .v-bedingt { border-color: color-mix(in srgb, var(--fatl-teil) 40%, transparent); background: color-mix(in srgb, var(--fatl-teil) 7%, transparent); }
.fatl :is(.fatl-mx, .fatl-legend-mx) .v-ja { color: var(--fatl-ja); }
.fatl .fatl-mx .v-ja { color: var(--muted); } .fatl .fatl-mx .v-ja b { color: var(--fatl-ja); }
.fatl .fatl-mx .v-bedingt b, .fatl .fatl-legend-mx .v-bedingt { color: var(--fatl-teil); }
.fatl .fatl-mx .v-nein b, .fatl .fatl-legend-mx .v-nein { color: var(--fatl-nein); }
.fatl .fatl-mx .v-offen b, .fatl .fatl-legend-mx .v-offen { color: var(--muted); }
.fatl-mxn { font-size: 11.5px; color: var(--muted); margin: -6px 0 12px; display: grid; gap: 3px; line-height: 1.5; }
.fatl-mxn b { color: var(--text); font-weight: 550; }

/* Side column */
.fatl-side { display: flex; flex-direction: column; gap: 26px; }
.fatl-h { font-size: var(--ui-label-size, 11px); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 550; margin: 0 0 10px; }
.fatl-hebel { display: flex; flex-direction: column; gap: 6px; }
.fatl-heb { display: flex; gap: 11px; align-items: center; width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: var(--ui-item-radius, var(--radius));
    background: var(--card); color: inherit; font: inherit; text-align: left; cursor: pointer; transition: border-color .15s, background .15s; }
.fatl-heb:hover { border-color: var(--brand); background: var(--fatl-tint); }
.fatl-heb b { display: block; font-weight: 550; font-size: 12.5px; }
.fatl-heb small { display: block; color: var(--muted); font-size: 11px; line-height: 1.4; }
.fatl-heb .fatl-amt { margin-left: auto; font-size: 12px; }
.fatl-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 12px; color: var(--muted); }
.fatl-legend li { display: flex; align-items: center; gap: 10px; }
.fatl-legend i { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.fatl-legend b { width: 12px; text-align: center; font-weight: 600; }
.fatl-foot { font-size: 11px; color: var(--muted); line-height: 1.6; margin: 0; }

@media (max-width: 1200px) {
    .fatl-grid { grid-template-columns: minmax(0, 1fr); }
    .fatl-side { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
    .fatl-side > div:first-child, .fatl-foot { grid-column: 1 / -1; }
}
@media (max-width: 980px) {
    .fatl-stage { height: 82vh; min-height: 600px; }
    .fatl-hint { display: none; }
    .fatl-panel { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; height: 74%; transform: translateY(calc(100% + 16px)); }
    .fatl-pd { padding-left: 14px; }
    .fatl-pd dl { grid-template-columns: 1fr; gap: 2px 0; }
    .fatl-pd dd { margin-bottom: 8px; }
}
@media (max-width: 768px) {
    .fatl-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 16px; }
    .fatl-metric:nth-child(2) { border: 0; }
    .fatl-side { grid-template-columns: minmax(0, 1fr); }
    .fatl-seg button { min-height: 40px; }
    .fatl-controls { padding: 12px; }
    .fatl-svc { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .fatl-svc::-webkit-scrollbar { display: none; }
    .fatl-svc button { white-space: nowrap; flex: none; }
    .fatl-mx { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Bereich filter: all funding areas, next to the service filter */
.fatl .fatl-kat { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted, inherit); }
.fatl .fatl-kat select { font: inherit; color: inherit; background: transparent; border: 1px solid currentColor; border-radius: 8px; padding: 6px 8px; min-height: 34px; max-width: 100%; }
.fatl .fatl-kat select option { color: #111; }
@media (max-width: 767px) { .fatl .fatl-kat select { font-size: 16px; } }
