.auto-plan-dialog { width: min(1780px, calc(100vw - 16px)); max-width: none; }
.auto-plan-card { width: 100%; max-height: min(96dvh, 1020px); overflow: hidden; padding: 0; }
.auto-plan-dialog[data-step="progress"] .auto-plan-card,
.auto-plan-dialog[data-step="preview"] .auto-plan-card { height: min(96dvh, 1020px); }
.auto-plan-header { display: flex; flex: 0 0 auto; justify-content: space-between; gap: 24px; padding: 18px 22px 14px; border-bottom: 1px solid var(--border, rgba(128,140,160,.25)); }
.auto-plan-header h2 { margin: 3px 0 4px; }
.auto-plan-header p { margin: 0; color: var(--muted, #657083); }
.auto-plan-step { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 20px 22px 24px; }
.auto-plan-step[hidden] { display: none !important; }
.auto-plan-dialog[data-step="progress"] .auto-plan-header,
.auto-plan-dialog[data-step="preview"] .auto-plan-header { padding-block: 12px 10px; }
#autoPlanProgressStep,
#autoPlanPreviewStep { overflow: hidden; padding: 12px 18px 0; }
#autoPlanPreviewStep { position: relative; }
#autoPlanProgressStep { grid-template-rows: auto auto auto minmax(0, 1fr) auto; }
#autoPlanPreviewStep { grid-template-rows: auto minmax(0, 1fr) auto; }
.auto-plan-dialog[data-step="progress"] #autoPlanProgressStep,
.auto-plan-dialog[data-step="preview"] #autoPlanPreviewStep { display: grid; }
.auto-plan-settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.auto-plan-step fieldset { min-width: 0; margin: 0; padding: 14px; border: 1px solid var(--border, rgba(128,140,160,.28)); border-radius: 14px; }
.auto-plan-step legend { padding: 0 6px; font-weight: 750; }
.auto-plan-step select { width: 100%; margin: 5px 0 10px; }
.auto-plan-toggle { display: flex; align-items: center; gap: 9px; margin: 8px 0; }
.auto-plan-toggle input { width: 18px; height: 18px; }
.auto-plan-participants { margin-top: 16px !important; }
.auto-plan-participants > p { margin: 0 0 12px; color: var(--muted, #657083); font-size: .9rem; }
.auto-plan-participant-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, max-content)); gap: 8px; overflow-x: auto; }
.auto-plan-participant { display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: 10px; background: color-mix(in srgb, var(--surface, #fff) 76%, var(--accent, #397bb5) 8%); }
.auto-plan-participant > span { white-space: nowrap; }
.auto-plan-participant small { display: block; color: var(--muted, #657083); }
.auto-plan-targets { margin-top: 16px !important; }
.auto-plan-targets-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 10px; }
.auto-plan-targets-head p { max-width: 760px; margin: 0; color: var(--muted, #657083); font-size: .9rem; }
.auto-plan-targets-head button { flex: 0 0 auto; }
.auto-plan-target-table-wrap { max-width: 100%; overflow-x: auto; border: 1px solid var(--border, rgba(128,140,160,.24)); border-radius: 12px; }
.auto-plan-target-table { width: max-content; min-width: 100%; border-spacing: 0; border-collapse: separate; font-size: .82rem; }
.auto-plan-target-table th, .auto-plan-target-table td { padding: 8px 9px; border-bottom: 1px solid var(--border, rgba(128,140,160,.2)); text-align: left; vertical-align: top; background: var(--surface, #fff); }
.auto-plan-target-table thead th { position: sticky; top: 0; z-index: 2; color: var(--muted, #657083); white-space: nowrap; }
.auto-plan-target-table tbody tr:last-child > * { border-bottom: 0; }
.auto-plan-target-name { position: sticky; left: 0; z-index: 1; min-width: max-content; width: max-content; line-height: 1.25rem; white-space: nowrap; box-shadow: 1px 0 0 var(--border, rgba(128,140,160,.2)); }
.auto-plan-target-name span { display: block; min-width: max-content; white-space: nowrap; }
.auto-plan-target-name small, .auto-plan-target-value small { display: block; color: var(--muted, #657083); font-weight: 500; white-space: nowrap; }
.auto-plan-target-value input { width: 88px; margin: 0 0 3px; font-variant-numeric: tabular-nums; }
.auto-plan-target-value input[aria-invalid="true"] { border-color: var(--red); outline-color: var(--red); }
.auto-plan-target-mode { min-width: 132px; white-space: nowrap; }
.auto-plan-target-mode span { display: block; margin-bottom: 5px; color: var(--muted, #657083); }
.auto-plan-target-mode button { padding: 5px 9px; }
.auto-plan-target-empty { color: var(--muted, #657083); text-align: center !important; }
.auto-plan-target-warnings { display: grid; gap: 4px; margin-top: 9px; }
.auto-plan-target-message { margin: 0; color: var(--orange); font-size: .82rem; }
.auto-plan-target-message--error { color: var(--red); font-weight: 650; }
.auto-plan-actions { position: sticky; bottom: 0; margin: 20px -22px -24px; padding: 13px 22px; background: color-mix(in srgb, var(--surface, #fff) 92%, transparent); backdrop-filter: blur(14px); border-top: 1px solid var(--border, rgba(128,140,160,.25)); }
.auto-plan-dialog[data-step="progress"] .auto-plan-actions { position: static; z-index: 5; align-self: end; margin: 8px -18px 0; padding: 10px 18px; }
.auto-plan-dialog[data-step="preview"] .auto-plan-actions { position: sticky; bottom: 0; z-index: 5; align-self: end; margin: 8px -18px 0; padding: 10px 18px; }
.auto-plan-error { color: var(--red); font-weight: 650; }
.auto-plan-progress-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 8px; }
.auto-plan-progress-head > div { display: grid; gap: 5px; }
.auto-plan-phase { color: var(--muted, #657083); }
.auto-plan-progress-head strong { font-variant-numeric: tabular-nums; }
.auto-plan-telemetry { text-align: right; color: var(--muted, #657083); }
.auto-plan-pulse { display: flex; gap: 7px; align-items: center; height: 14px; margin: 0 0 6px; }
.auto-plan-pulse i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent, #397bb5); animation: auto-plan-pulse 1.2s ease-in-out infinite; }
.auto-plan-pulse i:nth-child(2) { animation-delay: .16s; }
.auto-plan-pulse i:nth-child(3) { animation-delay: .32s; }
@keyframes auto-plan-pulse { 0%, 65%, 100% { opacity: .25; transform: translateY(0); } 32% { opacity: 1; transform: translateY(-4px); } }
.auto-plan-scan-stage { position: relative; min-width: 0; min-height: 0; isolation: isolate; border-radius: 14px; }
.auto-plan-scan-beam { position: absolute; inset: 0; z-index: 3; overflow: hidden; border-radius: inherit; pointer-events: none; }
.auto-plan-scan-beam::before { content: ""; position: absolute; left: -8%; right: -8%; top: -24%; height: 26%; background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--accent, #397bb5) 15%, transparent) 42%, color-mix(in srgb, var(--accent, #397bb5) 38%, white 22%) 50%, transparent 58%); filter: blur(2px); animation: auto-plan-scan 3.7s cubic-bezier(.48,.05,.52,.95) infinite; }
.auto-plan-scan-beam > i { position: absolute; width: 6px; height: 6px; border-radius: 50%; background: color-mix(in srgb, var(--accent, #397bb5) 72%, white); box-shadow: 0 0 12px color-mix(in srgb, var(--accent, #397bb5) 80%, transparent); animation: auto-plan-orbit 2.8s ease-in-out infinite; }
.auto-plan-scan-beam > i:nth-child(1) { left: 11%; top: 26%; }
.auto-plan-scan-beam > i:nth-child(2) { right: 18%; top: 48%; animation-delay: -.9s; }
.auto-plan-scan-beam > i:nth-child(3) { left: 47%; bottom: 15%; animation-delay: -1.8s; }
@keyframes auto-plan-scan { 0% { transform: translateY(-10%); opacity: 0; } 12% { opacity: .9; } 82% { opacity: .75; } 100% { transform: translateY(560%); opacity: 0; } }
@keyframes auto-plan-orbit { 0%, 100% { opacity: .15; transform: translate3d(-8px, 4px, 0) scale(.7); } 50% { opacity: .9; transform: translate3d(13px, -9px, 0) scale(1.15); } }
.auto-plan-week-grid { display: grid; grid-auto-rows: minmax(0, 1fr); gap: clamp(3px, .55vh, 7px); width: 100%; height: 100%; min-width: 0; min-height: 0; overflow: hidden; }
/* Die Prüfvorschau skaliert auf die Modalbreite, statt waagerecht zu scrollen:
   Die sieben Tagesspalten teilen sich die Breite, Schriftgrößen folgen der
   Containerbreite und ein zu langer Name endet als Ellipse mit vollem Tooltip. */
#autoPlanPreview.auto-plan-week-grid { height: auto; width: 100%; min-width: 0; grid-auto-rows: minmax(clamp(74px, 9.5vh, 116px), auto); overflow: visible; container-type: inline-size; }
#autoPlanPreview.auto-plan-week-grid .auto-plan-day-head { font-size: clamp(.64rem, 1.05cqi, .77rem); }
#autoPlanPreview.auto-plan-week-grid .auto-plan-slot { font-size: clamp(.63rem, 1.12cqi, .81rem); }

.auto-plan-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: clamp(3px, .35vw, 6px); width: 100%; min-width: 0; min-height: 0; }
.auto-plan-day { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: clamp(5px, .45vw, 8px); border: 1px solid var(--border, rgba(128,140,160,.25)); border-radius: 10px; background: color-mix(in srgb, var(--surface, #fff) 94%, var(--accent, #397bb5) 3%); }
.auto-plan-day--outside { opacity: .25; }
.auto-plan-day-head { display: flex; justify-content: space-between; gap: 4px; margin-bottom: clamp(2px, .35vh, 5px); color: var(--muted, #657083); font-size: clamp(.68rem, .64vw, .77rem); line-height: 1.05; }
.auto-plan-slot { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 3px; min-width: 0; margin-top: clamp(1px, .25vh, 3px); font-size: clamp(.68rem, .67vw, .81rem); line-height: 1.15; }
.auto-plan-slot b { color: var(--muted, #657083); }
.auto-plan-assignment-name { min-width: 0; white-space: nowrap; letter-spacing: -.012em; }
/* Ein überlanger Name endet als Ellipse in seiner eigenen Tageszelle, statt in
   die Nachbartage zu laufen. Der vollständige Name steht weiterhin im Tooltip. */
.auto-plan-assignment-name > span, .auto-plan-slot-status { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auto-plan-slot-status { margin-top: 2px; color: var(--muted, #657083); font-size: .68em; font-weight: 650; letter-spacing: 0; }
.auto-plan-assignment-trigger { display: block; width: 100%; padding: 0; overflow: visible; border: 0; border-radius: 3px; color: inherit; background: transparent; box-shadow: none; font: inherit; font-weight: inherit; line-height: inherit; text-align: left; }
.auto-plan-assignment-trigger:hover { color: color-mix(in srgb, var(--accent, #246da5) 72%, #6d28d9); background: color-mix(in srgb, var(--accent, #246da5) 8%, transparent); transform: none; }
.auto-plan-assignment-trigger:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent, #397bb5) 65%, transparent); outline-offset: 1px; }
.auto-plan-slot--new { position: relative; color: var(--accent, #246da5); font-weight: 750; }
.auto-plan-slot--existing { color: var(--text, #1f2937); }
.auto-plan-slot--changed { z-index: 1; border-radius: 7px; animation: auto-plan-incumbent-glow 1.45s cubic-bezier(.2,.8,.2,1); }
.auto-plan-slot--changed .auto-plan-assignment-name { animation: auto-plan-name-colour 1.65s cubic-bezier(.2,.75,.2,1) both; }
.auto-plan-slot--tone-0 { --auto-plan-colour-a: #b42318; --auto-plan-colour-b: #6d28d9; --auto-plan-colour-c: #087f5b; }
.auto-plan-slot--tone-1 { --auto-plan-colour-a: #6d28d9; --auto-plan-colour-b: #9a3412; --auto-plan-colour-c: #0369a1; }
.auto-plan-slot--tone-2 { --auto-plan-colour-a: #087f5b; --auto-plan-colour-b: #b42318; --auto-plan-colour-c: #7e22ce; }
.auto-plan-slot--tone-3 { --auto-plan-colour-a: #a15c00; --auto-plan-colour-b: #0369a1; --auto-plan-colour-c: #be185d; }
html[data-color-scheme="dark"] .auto-plan-slot--tone-0 { --auto-plan-colour-a: #fca5a5; --auto-plan-colour-b: #c4b5fd; --auto-plan-colour-c: #6ee7b7; }
html[data-color-scheme="dark"] .auto-plan-slot--tone-1 { --auto-plan-colour-a: #c4b5fd; --auto-plan-colour-b: #fdba74; --auto-plan-colour-c: #7dd3fc; }
html[data-color-scheme="dark"] .auto-plan-slot--tone-2 { --auto-plan-colour-a: #6ee7b7; --auto-plan-colour-b: #fca5a5; --auto-plan-colour-c: #d8b4fe; }
html[data-color-scheme="dark"] .auto-plan-slot--tone-3 { --auto-plan-colour-a: #fcd34d; --auto-plan-colour-b: #7dd3fc; --auto-plan-colour-c: #f9a8d4; }
.auto-plan-slot--removed { border-radius: 7px; animation: auto-plan-remove .7s ease-out; }
.auto-plan-reject { position: relative; z-index: 2; display: inline-grid; place-items: center; width: 26px; min-width: 26px; height: 26px; min-height: 26px; margin: -2px 0; padding: 0; border: 1px solid color-mix(in srgb, var(--red) 38%, var(--border, #9aa3af)); border-radius: 50%; color: var(--red); background: color-mix(in srgb, var(--surface, #fff) 91%, var(--red) 9%); box-shadow: none; font: 800 1rem/1 system-ui, sans-serif; }
.auto-plan-reject:hover { color: var(--surface, #fff); background: var(--red); transform: scale(1.08); }
.auto-plan-reject:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent, #397bb5) 58%, transparent); outline-offset: 1px; }
.auto-plan-sparkles { position: absolute; inset: -3px; pointer-events: none; }
.auto-plan-sparkles i { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: color-mix(in srgb, var(--accent, #397bb5) 62%, white); box-shadow: 0 0 8px color-mix(in srgb, var(--accent, #397bb5) 76%, transparent); animation: auto-plan-sparkle .72s ease-out both; }
.auto-plan-sparkles i:nth-child(1) { left: 8%; top: 4%; }
.auto-plan-sparkles i:nth-child(2) { right: 17%; top: 16%; animation-delay: .08s; }
.auto-plan-sparkles i:nth-child(3) { right: 4%; bottom: 5%; animation-delay: .15s; }
@keyframes auto-plan-incumbent-glow { 0% { background: transparent; box-shadow: 0 0 0 transparent; transform: scale(.985); } 38% { background: color-mix(in srgb, var(--accent, #397bb5) 15%, transparent); box-shadow: 0 0 18px color-mix(in srgb, var(--accent, #397bb5) 35%, transparent); transform: scale(1.025); } 100% { background: transparent; box-shadow: 0 0 0 transparent; transform: scale(1); } }
@keyframes auto-plan-name-colour { 0% { color: var(--accent, #246da5); text-shadow: none; } 12% { color: var(--auto-plan-colour-a); text-shadow: 0 0 10px color-mix(in srgb, var(--auto-plan-colour-a) 45%, transparent); } 34% { color: var(--auto-plan-colour-b); text-shadow: 0 0 12px color-mix(in srgb, var(--auto-plan-colour-b) 42%, transparent); } 56% { color: var(--auto-plan-colour-c); text-shadow: 0 0 10px color-mix(in srgb, var(--auto-plan-colour-c) 38%, transparent); } 72% { color: var(--auto-plan-colour-a); } 100% { color: var(--accent, #246da5); text-shadow: none; } }
@keyframes auto-plan-sparkle { 0% { opacity: 0; transform: scale(.2) translateY(4px); } 34% { opacity: 1; } 100% { opacity: 0; transform: scale(1.6) translateY(-10px); } }
@keyframes auto-plan-remove { 0% { color: var(--red); background: color-mix(in srgb, var(--red) 10%, transparent); opacity: 1; } 100% { color: inherit; background: transparent; opacity: .7; } }
.auto-plan-summary { display: flex; flex-wrap: wrap; gap: 8px; }
.auto-plan-summary-status { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; width: 100%; }
.auto-plan-summary-status span { color: var(--muted, #657083); }
.auto-plan-metrics { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
.auto-plan-metric { display: grid; gap: 2px; min-width: 94px; padding: 7px 9px; border: 1px solid var(--border, rgba(128,140,160,.22)); border-radius: 9px; font-variant-numeric: tabular-nums; }
.auto-plan-metric > span { color: var(--muted, #657083); font-size: .74rem; }
.auto-plan-metric--attention, .auto-plan-metric--yellow { border-color: var(--yellow); }
.auto-plan-metric--orange { border-color: var(--orange); }
.auto-plan-metric--danger { border-color: var(--red); color: var(--red); }
.auto-plan-metric--ok { border-color: #24835b; }
.auto-plan-view-switch { display: flex; gap: 6px; }
.auto-plan-detail { position: static; max-height: none; overflow: visible; padding: 15px; border: 1px solid var(--border, rgba(128,140,160,.25)); border-radius: 14px; background: color-mix(in srgb, var(--surface, #fff) 94%, var(--accent, #397bb5) 6%); }
.auto-plan-confirm-box, .auto-plan-error-card { max-width: 700px; margin: 20px auto; padding: 24px; border: 1px solid var(--border, rgba(128,140,160,.25)); border-radius: 16px; }
.auto-plan-preview { width: 100%; max-width: 100%; min-width: 0; min-height: 0; overflow: hidden; }
.auto-plan-preview:not(.auto-plan-week-grid) { overflow: auto; }
/* Die Prüftabelle ist die echte Dienstplantabelle: `.plan-table-wrap` und
   `.plan-table` bringen Rahmen, Kopfzeile, Wochenend-, Feiertags- und
   Dunkelmodusfarben unverändert mit. Hier stehen nur die Abweichungen. */
.auto-plan-table-wrap { width: 100%; max-width: 100%; }
.auto-plan-table { width: 100%; min-width: 0; table-layout: fixed; border-collapse: collapse; }
.auto-plan-table th:nth-child(3), .auto-plan-table th:nth-child(4) { width: auto; }
.auto-plan-table td.auto-plan-table-slot { padding: 0 !important; height: 38px; }
.auto-plan-table-cell { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 36px; padding: 2px 6px; }
.auto-plan-table-alternative, .auto-plan-table-static { display: grid; flex: 1 1 auto; gap: 1px; min-width: 0; padding: 2px 3px; border: 0; border-radius: 5px; color: var(--accent, #246da5); background: transparent; box-shadow: none; font: inherit; font-weight: 750; line-height: 1.12; text-align: left; }
.auto-plan-table-static { color: var(--text, #1f2937); }
.auto-plan-table-open { color: var(--muted, #657083); font-style: italic; }
.auto-plan-table-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auto-plan-table-cell small { color: var(--muted, #657083); font-size: .68rem; font-weight: 600; letter-spacing: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auto-plan-table-alternative:hover { color: color-mix(in srgb, var(--accent, #246da5) 72%, #6d28d9); background: color-mix(in srgb, var(--accent, #246da5) 10%, transparent); transform: none; }
.auto-plan-table-alternative:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent, #397bb5) 65%, transparent); outline-offset: 1px; }
/* Im Dunkeln liegen Vorschlagsnamen auch auf den warmen Wochenend- und
   Feiertagsflächen. Der reine Akzentblauton verlöre dort seinen Kontrast. */
html[data-color-scheme="dark"] .auto-plan-table-alternative { color: color-mix(in srgb, var(--accent, #7dd3fc) 34%, #e9f2ff); }
html[data-color-scheme="dark"] .auto-plan-table-alternative:hover { color: #fff; }
.auto-plan-table td[data-auto-plan-status="proposal-yellow"] { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--yellow) 62%, transparent); }
.auto-plan-table td[data-auto-plan-status="proposal-orange"] { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--orange) 62%, transparent); }
.auto-plan-table td[data-auto-plan-status^="open"] { background-image: repeating-linear-gradient(135deg, transparent 0 8px, color-mix(in srgb, var(--muted, #657083) 9%, transparent) 8px 16px); }
.auto-plan-result-name { min-width: max-content; white-space: nowrap; }
.auto-plan-target-summary { position: relative; z-index: 7; margin: 0 0 7px; }
.auto-plan-target-summary > summary { width: max-content; cursor: pointer; color: var(--muted, #657083); font-size: .8rem; font-weight: 700; }
.auto-plan-preview-scroll { min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; padding: 0 2px 22px; }
.auto-plan-result-section { margin: 0 0 15px; }
.auto-plan-result-section > h4 { margin: 0 0 8px; }
.auto-plan-plan-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.auto-plan-result-legend { display: flex; flex-wrap: wrap; gap: 5px; }
.auto-plan-result-legend span { padding: 3px 7px; border: 1px solid var(--border, rgba(128,140,160,.28)); border-radius: 999px; font-size: .75rem; }
.auto-plan-result-legend [data-status="proposal-yellow"] { border-color: var(--yellow); }
.auto-plan-result-legend [data-status="proposal-orange"] { border-color: var(--orange); }
.auto-plan-result-legend [data-status^="open"] { border-style: dashed; }
.auto-plan-attention-lane { margin: 0 0 9px; padding: 9px 11px; border-left: 3px solid var(--accent, #397bb5); background: color-mix(in srgb, var(--surface, #fff) 88%, var(--accent, #397bb5) 5%); }
.auto-plan-attention-lane h5, .auto-plan-alternative h5 { margin: 0 0 5px; }
.auto-plan-attention-lane ul, .auto-plan-difference { display: grid; gap: 6px; margin: 0; padding-left: 18px; }
.auto-plan-attention-lane li { display: flex; justify-content: space-between; gap: 12px; }
.auto-plan-attention-lane p { margin: 2px 0; }
.auto-plan-attention-lane small { display: block; color: var(--muted, #657083); }
.auto-plan-undo-all { margin-top: 3px; }
/* Die Verteilung je Person ist ein Prüfergebnis, kein Detail: Sie steht offen
   im Ergebnis und wird nicht mehr hinter einem zugeklappten Aufklapper
   versteckt. */
.auto-plan-people-section > .auto-plan-people-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 8px; }
.auto-plan-people-section h4 { margin: 0 0 2px; }
.auto-plan-people-section #autoPlanPeopleSummary { margin: 0; color: var(--muted, #657083); font-size: .82rem; }
.auto-plan-people-filter { display: inline-flex; align-items: center; gap: 7px; margin: 0; flex: 0 0 auto; white-space: nowrap; }
.auto-plan-people-table-wrap { max-width: 100%; overflow-x: auto; border: 1px solid var(--border, rgba(128,140,160,.22)); border-radius: 10px; }
.auto-plan-people-table { width: max-content; min-width: 100%; border-collapse: collapse; }
.auto-plan-people-table th, .auto-plan-people-table td { padding: 8px 9px; border-bottom: 1px solid var(--border, rgba(128,140,160,.18)); text-align: left; white-space: nowrap; }
.auto-plan-people-table thead th { position: sticky; top: 0; z-index: 1; color: var(--muted, #657083); font-size: .78rem; background: color-mix(in srgb, var(--surface, #fff) 94%, var(--accent, #397bb5) 6%); }
.auto-plan-people-table tbody td { font-variant-numeric: tabular-nums; vertical-align: top; }
/* Die Ergebniszahl trägt die Zeile; Ziel und Maximum bleiben Referenz. */
.auto-plan-balance-value { display: block; font-size: 1.06em; line-height: 1.2; }
.auto-plan-balance-reference { display: block; margin-top: 1px; color: var(--muted, #657083); font-size: .72rem; font-weight: 600; }
/* Nur die Verletzung eines harten Maximums ist ein Alarm. Eine überschrittene
   Zielvorgabe ist weich und steht als Wortlaut in der Statusspalte. */
.auto-plan-people-table td[data-auto-plan-balance="over-max"] .auto-plan-balance-value { color: var(--red); }
.auto-plan-people-table tbody tr[data-auto-plan-person-attention="true"] > * { background: color-mix(in srgb, var(--surface, #fff) 88%, var(--yellow) 12%); }
html[data-color-scheme="dark"] .auto-plan-people-table tbody tr[data-auto-plan-person-attention="true"] > * { background: color-mix(in srgb, transparent 82%, var(--yellow) 18%); }
.auto-plan-person-status { display: block; margin-bottom: 3px; }
.auto-plan-run-details dl { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.auto-plan-run-details dl > div { padding: 6px 8px; border: 1px solid var(--border, rgba(128,140,160,.2)); border-radius: 8px; }
.auto-plan-run-details dt { color: var(--muted, #657083); font-size: .72rem; }
.auto-plan-run-details dd { margin: 1px 0 0; font-variant-numeric: tabular-nums; }
.auto-plan-alternative { margin-top: 10px; padding: 10px; border: 1px solid var(--border, rgba(128,140,160,.25)); border-radius: 10px; }
.auto-plan-alternative button { margin-top: 9px; }

@media (max-width: 820px) {
  .auto-plan-dialog { width: calc(100vw - 10px); }
  .auto-plan-settings-grid { grid-template-columns: 1fr; }
  .auto-plan-targets-head { flex-direction: column; }
  .auto-plan-header { padding-inline: 14px; }
  #autoPlanProgressStep, #autoPlanPreviewStep { padding-inline: 10px; }
  .auto-plan-dialog[data-step="progress"] .auto-plan-actions,
  .auto-plan-dialog[data-step="preview"] .auto-plan-actions { margin-inline: -10px; padding-inline: 10px; }
  .auto-plan-slot { font-size: clamp(.56rem, 1.45vw, .72rem); }
  .auto-plan-reject { width: 24px; min-width: 24px; height: 24px; min-height: 24px; }
  .auto-plan-plan-head { flex-direction: column; }
}

/* Ergebnisvorschau --------------------------------------------------------
   Der Monatsplan ist der primäre Prüfgegenstand. Die folgenden Regeln stehen
   bewusst nach den älteren Vorschau-Regeln: Sie übersteuern nur die
   Ergebnisansicht, nicht das kompakte Live-Raster während der Berechnung. */
.auto-plan-schedule,
.auto-plan-evaluation {
  margin: 0 0 18px;
  border: 1px solid var(--border, rgba(128,140,160,.25));
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface, #fff) 96%, var(--accent, #397bb5) 4%);
}
.auto-plan-schedule { padding: 14px; }
.auto-plan-evaluation { padding: 14px; }
.auto-plan-schedule-head,
.auto-plan-evaluation-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.auto-plan-schedule-head .eyebrow,
.auto-plan-evaluation-head .eyebrow { margin-bottom: 2px; }
.auto-plan-schedule-head h4,
.auto-plan-evaluation-head h4 { margin: 0; }
.auto-plan-schedule-head p {
  max-width: 720px;
  margin: 4px 0 0;
  color: var(--muted, #657083);
  font-size: .84rem;
  line-height: 1.35;
}
.auto-plan-view-switch {
  flex: 0 0 auto;
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border, rgba(128,140,160,.28));
  border-radius: 9px;
  background: color-mix(in srgb, var(--surface, #fff) 86%, var(--accent, #397bb5) 8%);
}
.auto-plan-view-switch button {
  min-height: 32px;
  padding: 5px 9px;
  border: 0;
  border-radius: 6px;
  color: var(--muted, #657083);
  background: transparent;
  box-shadow: none;
  font-size: .8rem;
  font-weight: 720;
  transform: none;
}
.auto-plan-view-switch button[aria-pressed="true"] {
  color: var(--text, #1f2937);
  background: var(--surface, #fff);
  box-shadow: 0 1px 3px color-mix(in srgb, #0f172a 16%, transparent);
}
.auto-plan-view-switch button:hover { color: var(--text, #1f2937); }
.auto-plan-view-switch button:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent, #397bb5) 55%, transparent); outline-offset: 1px; }

.auto-plan-result-legend {
  margin: 12px 0 10px;
  padding: 8px 0 0;
  border-top: 1px solid var(--border, rgba(128,140,160,.2));
}
.auto-plan-result-legend span { display: inline-flex; align-items: center; gap: 5px; }
.auto-plan-result-legend span::before {
  content: "";
  width: 8px;
  height: 8px;
  border: 1px solid currentColor;
  border-radius: 2px;
  background: color-mix(in srgb, currentColor 18%, transparent);
}
.auto-plan-result-legend [data-status="existing"]::before { border-radius: 50%; background: color-mix(in srgb, var(--muted, #657083) 30%, transparent); }
.auto-plan-result-legend [data-status="proposal-yellow"]::before { color: var(--yellow); }
.auto-plan-result-legend [data-status="proposal-orange"]::before { color: var(--orange); }
.auto-plan-result-legend [data-status^="open"]::before { border-style: dashed; background: transparent; }

#autoPlanPreview.auto-plan-week-grid {
  gap: 8px;
  padding: 10px;
  border: 1px solid color-mix(in srgb, var(--accent, #397bb5) 18%, var(--border, rgba(128,140,160,.24)));
  border-radius: 11px;
  background: color-mix(in srgb, var(--surface, #fff) 92%, var(--accent, #397bb5) 4%);
}
.auto-plan-weekday-header {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: clamp(3px, .35vw, 6px);
  color: var(--muted, #657083);
  font-size: clamp(.66rem, 1.08cqi, .78rem);
  font-weight: 780;
  letter-spacing: .035em;
  text-align: center;
  text-transform: uppercase;
}
.auto-plan-weekday-header span:nth-child(6),
.auto-plan-weekday-header span:nth-child(7) { color: color-mix(in srgb, var(--orange, #b45309) 72%, var(--muted, #657083)); }
#autoPlanPreview .auto-plan-week { gap: clamp(3px, .35vw, 6px); }
#autoPlanPreview .auto-plan-day {
  overflow: hidden;
  padding: 0;
  border-color: color-mix(in srgb, var(--border, rgba(128,140,160,.25)) 84%, var(--accent, #397bb5));
  border-radius: 9px;
  background: var(--surface, #fff);
  box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 78%, transparent);
}
#autoPlanPreview .auto-plan-day--saturday { background: var(--saturday-row-bg, color-mix(in srgb, var(--orange) 7%, var(--surface, #fff))); }
#autoPlanPreview .auto-plan-day--sunday { background: var(--sunday-row-bg, color-mix(in srgb, var(--orange) 11%, var(--surface, #fff))); }
#autoPlanPreview .auto-plan-day--holiday { background: var(--holiday-row-bg, color-mix(in srgb, var(--yellow) 12%, var(--surface, #fff))); }
#autoPlanPreview .auto-plan-day--outside { opacity: .42; background: color-mix(in srgb, var(--surface, #fff) 86%, var(--muted, #657083) 6%); }
#autoPlanPreview .auto-plan-day-head {
  align-items: flex-start;
  margin: 0;
  padding: 5px 6px 4px;
  border-bottom: 1px solid color-mix(in srgb, var(--border, rgba(128,140,160,.25)) 75%, transparent);
  color: var(--muted, #657083);
  background: color-mix(in srgb, var(--surface, #fff) 74%, var(--accent, #397bb5) 6%);
}
.auto-plan-day-date { display: grid; gap: 1px; min-width: 0; }
.auto-plan-day-date small { overflow: hidden; color: inherit; font-size: .64em; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
#autoPlanPreview .auto-plan-day-head strong {
  display: grid;
  place-items: center;
  min-width: 20px;
  min-height: 20px;
  border-radius: 50%;
  color: var(--text, #1f2937);
  background: color-mix(in srgb, var(--accent, #397bb5) 12%, var(--surface, #fff));
  font-variant-numeric: tabular-nums;
}
.auto-plan-duty-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
  min-width: 0;
  margin: 4px;
  padding: 4px;
  border: 1px solid transparent;
  border-left: 3px solid color-mix(in srgb, var(--muted, #657083) 52%, transparent);
  border-radius: 6px;
  color: var(--text, #1f2937);
  background: color-mix(in srgb, var(--surface, #fff) 88%, var(--muted, #657083) 5%);
}
.auto-plan-duty-role {
  display: grid;
  place-items: center;
  min-width: 22px;
  min-height: 22px;
  border-radius: 4px;
  color: var(--muted, #657083);
  background: color-mix(in srgb, var(--muted, #657083) 10%, transparent);
  font-size: .67em;
  font-weight: 850;
  letter-spacing: .04em;
}
.auto-plan-duty-content { min-width: 0; }
.auto-plan-duty-card .auto-plan-assignment-name { min-width: 0; }
.auto-plan-duty-card .auto-plan-slot-status { line-height: 1.12; }
.auto-plan-duty-card[data-auto-plan-status^="proposal"] { border-left-color: var(--accent, #246da5); background: color-mix(in srgb, var(--accent, #397bb5) 9%, var(--surface, #fff)); }
.auto-plan-duty-card[data-auto-plan-status="proposal-yellow"] { border-color: color-mix(in srgb, var(--yellow) 72%, var(--border, rgba(128,140,160,.25))); border-left-color: var(--yellow); background: color-mix(in srgb, var(--yellow) 12%, var(--surface, #fff)); }
.auto-plan-duty-card[data-auto-plan-status="proposal-orange"] { border-color: color-mix(in srgb, var(--orange) 72%, var(--border, rgba(128,140,160,.25))); border-left-color: var(--orange); background: color-mix(in srgb, var(--orange) 12%, var(--surface, #fff)); }
.auto-plan-duty-card[data-auto-plan-status^="open"] { border-style: dashed; border-left-style: solid; background-image: repeating-linear-gradient(135deg, transparent 0 7px, color-mix(in srgb, var(--muted, #657083) 8%, transparent) 7px 14px); }
.auto-plan-duty-card[data-auto-plan-status="open-unfillable"] { border-left-color: var(--red); }
.auto-plan-duty-card[data-auto-plan-status="open-profile"] { border-left-color: var(--orange); }
.auto-plan-duty-card[data-auto-plan-status="existing"] { border-left-color: color-mix(in srgb, var(--muted, #657083) 70%, transparent); }
.auto-plan-duty-card[data-auto-plan-status^="proposal"] .auto-plan-duty-role { color: var(--accent, #246da5); background: color-mix(in srgb, var(--accent, #397bb5) 14%, transparent); }
.auto-plan-duty-card[data-auto-plan-status="proposal-yellow"] .auto-plan-duty-role { color: color-mix(in srgb, var(--yellow) 72%, #725300); background: color-mix(in srgb, var(--yellow) 21%, transparent); }
.auto-plan-duty-card[data-auto-plan-status="proposal-orange"] .auto-plan-duty-role { color: color-mix(in srgb, var(--orange) 75%, #7c2d12); background: color-mix(in srgb, var(--orange) 18%, transparent); }

.auto-plan-preview:not(.auto-plan-week-grid) { overflow: visible; }
.auto-plan-table-wrap { overflow: auto; border-radius: 10px; }
.auto-plan-table { min-width: 620px; }
.auto-plan-table caption { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.auto-plan-table th { white-space: nowrap; }
.auto-plan-table td.auto-plan-table-slot { height: 48px; }
.auto-plan-table-cell { min-height: 46px; padding: 4px 6px; }
.auto-plan-table-alternative,
.auto-plan-table-static { padding: 4px 5px; border-left: 3px solid color-mix(in srgb, var(--muted, #657083) 55%, transparent); background: color-mix(in srgb, var(--surface, #fff) 74%, transparent); }
.auto-plan-table-alternative { border-left-color: var(--accent, #246da5); }
.auto-plan-table td[data-auto-plan-status="proposal-yellow"] .auto-plan-table-alternative,
.auto-plan-table td[data-auto-plan-status="proposal-yellow"] .auto-plan-table-static { border-left-color: var(--yellow); background: color-mix(in srgb, var(--yellow) 12%, transparent); }
.auto-plan-table td[data-auto-plan-status="proposal-orange"] .auto-plan-table-alternative,
.auto-plan-table td[data-auto-plan-status="proposal-orange"] .auto-plan-table-static { border-left-color: var(--orange); background: color-mix(in srgb, var(--orange) 12%, transparent); }
.auto-plan-table td[data-auto-plan-status^="open"] .auto-plan-table-static { border-left-color: var(--orange); border-left-style: dashed; }
.auto-plan-table td[data-auto-plan-status="open-unfillable"] .auto-plan-table-static { border-left-color: var(--red); }
.auto-plan-table td[data-auto-plan-status="existing"] .auto-plan-table-static { border-left-color: color-mix(in srgb, var(--muted, #657083) 70%, transparent); }

.auto-plan-evaluation { background: color-mix(in srgb, var(--surface, #fff) 98%, var(--muted, #657083) 2%); }
.auto-plan-evaluation-head { margin-bottom: 12px; }
.auto-plan-evaluation .auto-plan-result-section { margin-bottom: 16px; }
.auto-plan-evaluation .auto-plan-result-section:last-child { margin-bottom: 0; }
.auto-plan-evaluation h5 { margin: 0 0 8px; font-size: .92rem; }
.auto-plan-summary-status { padding-bottom: 2px; }
.auto-plan-metric { flex: 1 1 104px; min-width: 104px; background: color-mix(in srgb, var(--surface, #fff) 93%, var(--accent, #397bb5) 4%); }
.auto-plan-attention { padding: 10px; border: 1px solid color-mix(in srgb, var(--orange) 30%, var(--border, rgba(128,140,160,.25))); border-radius: 10px; background: color-mix(in srgb, var(--orange) 5%, var(--surface, #fff)); }
.auto-plan-people-section { padding-top: 2px; }
.auto-plan-people-section h5 { margin: 0 0 2px; }
.auto-plan-run-details { padding: 0; border: 1px solid var(--border, rgba(128,140,160,.22)); border-radius: 9px; background: color-mix(in srgb, var(--surface, #fff) 90%, var(--muted, #657083) 4%); }
.auto-plan-run-details > summary { padding: 9px 10px; cursor: pointer; color: var(--muted, #657083); font-size: .82rem; font-weight: 760; }
.auto-plan-run-details[open] > summary { border-bottom: 1px solid var(--border, rgba(128,140,160,.2)); color: var(--text, #1f2937); }
.auto-plan-run-details > div { padding: 9px 10px; }
.auto-plan-run-details dl { margin: 0; }

html[data-color-scheme="dark"] .auto-plan-schedule,
html[data-color-scheme="dark"] .auto-plan-evaluation,
html[data-color-scheme="dark"] #autoPlanPreview.auto-plan-week-grid { background: color-mix(in srgb, var(--surface, #111827) 90%, var(--accent, #7dd3fc) 7%); }
html[data-color-scheme="dark"] .auto-plan-day-head,
html[data-color-scheme="dark"] .auto-plan-view-switch button[aria-pressed="true"] { color: var(--text, #f3f4f6); background: color-mix(in srgb, var(--surface, #111827) 84%, var(--accent, #7dd3fc) 9%); }
html[data-color-scheme="dark"] .auto-plan-duty-card { background: color-mix(in srgb, var(--surface, #111827) 85%, var(--muted, #94a3b8) 8%); }

@media (max-width: 820px) {
  .auto-plan-schedule,
  .auto-plan-evaluation { padding: 10px; border-radius: 11px; }
  .auto-plan-schedule-head { flex-direction: column; }
  .auto-plan-view-switch { width: 100%; }
  .auto-plan-view-switch button { flex: 1 1 0; }
  #autoPlanPreview.auto-plan-week-grid { padding: 6px; }
  .auto-plan-duty-card { gap: 2px; margin: 3px; padding: 3px; }
  .auto-plan-duty-role { min-width: 20px; min-height: 20px; }
}

@media (max-width: 540px) {
  .auto-plan-schedule-head p { font-size: .78rem; }
  #autoPlanPreview.auto-plan-week-grid .auto-plan-day-head { padding: 4px; }
  .auto-plan-day-date small { display: none; }
  #autoPlanPreview .auto-plan-day-head strong { min-width: 18px; min-height: 18px; }
  .auto-plan-duty-card .auto-plan-slot-status { display: none; }
  .auto-plan-metric { flex-basis: 92px; min-width: 92px; }
}
