/* Django-Verwaltung im Design der Anwendung (baut auf theme.css auf). Django ≥ 4.2 nutzt CSS-Variablen – die setzen wir um,
   dazu Layout: unsere Seitenleiste ersetzt die Django-Navigation, unsere Kopfzeile den Django-Header. */
:root, html[data-theme="light"], html[data-theme="dark"] {
  --primary: var(--accent); --secondary: var(--surface); --primary-fg: var(--accent-fg);
  --body-fg: var(--fg); --body-bg: var(--bg); --body-quiet-color: var(--fg-2); --body-loud-color: var(--fg); --body-medium-color: var(--fg-2);
  --header-color: var(--fg); --header-branding-color: var(--fg); --header-bg: var(--surface); --header-link-color: var(--fg);
  --breadcrumbs-fg: var(--fg-2); --breadcrumbs-link-fg: var(--accent); --breadcrumbs-bg: transparent;
  --link-fg: var(--accent); --link-hover-color: var(--accent-hover); --link-selected-fg: var(--accent);
  --hairline-color: var(--line); --border-color: var(--line-strong); --darkened-bg: var(--surface-2); --selected-bg: var(--accent-soft); --selected-row: var(--accent-soft);
  --button-fg: var(--accent-fg); --button-bg: var(--accent); --button-hover-bg: var(--accent-hover);
  --default-button-bg: var(--accent); --default-button-hover-bg: var(--accent-hover);
  --close-button-bg: var(--fg-2); --close-button-hover-bg: var(--fg);
  --delete-button-bg: var(--danger); --delete-button-hover-bg: #991b1b;
  --object-tools-fg: var(--fg); --object-tools-bg: var(--surface); --object-tools-hover-bg: var(--surface-2);
  --message-success-bg: var(--success-soft); --message-warning-bg: var(--warn-soft); --message-error-bg: var(--danger-soft);
  --error-fg: var(--danger); --font-family-primary: var(--font); --font-family-monospace: ui-monospace, SFMono-Regular, Menlo, monospace;
}
html { scroll-padding-top: 60px; }
body.lg-admin { background: var(--bg); font-family: var(--font); font-size: 14px; }
#header.lg-hidden-header { display: none; }
#container { display: block; min-height: 100vh; }
#container > .main, .main#main { display: flex; align-items: stretch; min-height: 100vh; }
.main > .lg-sidebar { position: sticky; top: 0; height: 100vh; }
#content-start.content { flex: 1; min-width: 0; padding: 0 !important; display: flex; flex-direction: column; }
#content-start > .lg-topbar { margin: 0; }
#content, #content.colM, #content.colMS, #content.colSM, #content.flex { padding: 22px 24px 40px; max-width: none; }
div.breadcrumbs { background: transparent; padding: 10px 24px 0; color: var(--fg-2); font-size: 12.5px; }
div.breadcrumbs a { color: var(--fg-2); } div.breadcrumbs a:hover { color: var(--accent); }
ul.messagelist { padding: 12px 24px 0; margin: 0; }
ul.messagelist li { border-radius: 8px; border: 1px solid var(--line); background: var(--success-soft); color: var(--success); font-size: 13px; padding: 10px 14px 10px 40px; }
ul.messagelist li.warning { background: var(--warn-soft); color: var(--warn); } ul.messagelist li.error { background: var(--danger-soft); color: var(--danger); }
#content h1 { font-size: 20px; font-weight: 600; margin: 0 0 14px; color: var(--fg); }
#content h2 { font-size: 15px; }
.lg-shell.collapsed, html.lg-pre-collapsed .main { --sidebar-w: 64px; }
/* Django-Sidebar-Toggle-Button ausblenden (wir haben unseren) */
#toggle-nav-sidebar, #header .theme-toggle { display: none; }

/* Module / Formulare */
.module { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; }
.module h2, .module caption, .inline-group h2 { background: var(--surface-2); color: var(--fg); font-weight: 600; font-size: 13px; padding: 10px 14px; border-bottom: 1px solid var(--line); text-transform: none; letter-spacing: 0; }
fieldset.module { padding: 6px 0 4px; }
fieldset.module h2 { margin: -6px 0 8px; }
.aligned label { color: var(--fg-2); font-weight: 500; width: 190px; padding: 8px 10px 0 0; }
.form-row { border-bottom: 1px solid var(--line); padding: 10px 14px; }
.form-row:last-child { border-bottom: 0; }
.aligned .form-row > div { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 4px 10px; }
.aligned .form-row .help, .aligned .form-row div.help { margin-left: 200px; color: var(--muted); font-size: 12px; padding-top: 4px; }
fieldset .fieldBox { margin-right: 24px; }
fieldset .description { padding: 8px 14px; color: var(--fg-2); font-size: 12.5px; background: var(--surface); border-bottom: 1px solid var(--line); }
input[type=text], input[type=password], input[type=email], input[type=url], input[type=number], input[type=tel], input[type=date], input[type=time], textarea, select, .vTextField, .vURLField, .vDateField, .vTimeField, .vIntegerField {
  border: 1px solid var(--line-strong); border-radius: 8px; padding: 7px 10px; font: inherit; background: var(--surface); color: var(--fg); }
input:focus, textarea:focus, select:focus, .vTextField:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); outline: 0; }
select { padding-right: 28px; }
.select2-container--admin-autocomplete .select2-selection--single, .select2-container--admin-autocomplete .select2-selection--multiple { border: 1px solid var(--line-strong) !important; border-radius: 8px !important; min-height: 36px !important; background: var(--surface) !important; }
.select2-container--admin-autocomplete .select2-selection--single .select2-selection__rendered { line-height: 34px !important; color: var(--fg) !important; }
.select2-container--admin-autocomplete .select2-selection--single .select2-selection__arrow { height: 34px !important; }
.submit-row { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 16px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; position: sticky; bottom: 12px; z-index: 5; }
.submit-row input, .submit-row a.closelink, .submit-row a.deletelink, .button, input[type=submit], input[type=button], .object-tools a, .object-tools button.button {
  border-radius: 8px !important; padding: 8px 14px !important; font-weight: 500; font-size: 13px !important; text-transform: none !important; letter-spacing: 0 !important; height: auto; line-height: 1.3; }
.submit-row input.default, input[type=submit].default { background: var(--accent); font-weight: 600; }
.submit-row input[type=submit]:not(.default) { background: var(--surface); color: var(--fg); border: 1px solid var(--line-strong) !important; }
.submit-row input[type=submit]:not(.default):hover { background: var(--surface-2); }
.submit-row a.deletelink { display: inline-block; background: var(--danger-soft) !important; color: var(--danger) !important; margin-left: auto; height: auto !important; line-height: 1.3 !important; box-sizing: border-box; }
.submit-row a.deletelink:hover { background: var(--danger) !important; color: #fff !important; }
.object-tools { margin: 0 0 12px; float: none; display: flex; flex-wrap: wrap; gap: 6px; }
.object-tools li { list-style: none; margin: 0; height: auto; }
.object-tools a, .object-tools button.button { background: var(--surface) !important; color: var(--fg) !important; border: 1px solid var(--line-strong) !important; }
.object-tools a:hover, .object-tools button.button:hover { background: var(--surface-2) !important; }
.object-tools a.addlink { background: var(--accent) !important; color: var(--accent-fg) !important; border-color: transparent !important; padding-left: 14px !important; background-image: none !important; }
.inline-group .tabular table, .inline-group .tabular td, .inline-group .tabular th { font-size: 13px; }
.inline-related h3 { background: var(--surface-2); border-bottom: 1px solid var(--line); padding: 8px 14px; font-weight: 500; }
.inline-group .tabular tr.add-row td { background: var(--surface); padding: 8px 14px; }
.add-row a { color: var(--accent); font-weight: 500; }
.datetimeshortcuts a, .datetimeshortcuts { color: var(--accent); font-size: 12px; }
.related-widget-wrapper-link img { filter: none; }
.help, .helptext { color: var(--muted); font-size: 12px; }
.errornote { border-radius: 8px; background: var(--danger-soft); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); }
.errorlist li { background: var(--danger-soft); color: var(--danger); border-radius: 6px; }

/* Listen */
/* Filter oben (wie in der Fach-Oberfläche) als Dropdowns – keine Seitenleiste */
body.lg-admin #changelist { display: flex; flex-direction: column; gap: 0; }
body.lg-admin #changelist .changelist-form-container { flex: 1 1 auto; min-width: 0; width: 100%; }
body.lg-admin #changelist.filtered { min-height: 0; }
body.lg-admin #changelist-filter { order: -1; flex: 0 0 auto; width: 100%; box-sizing: border-box; margin: 0 0 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px 12px; }
body.lg-admin #changelist-filter h2 { display: none; }
body.lg-admin #changelist-filter #changelist-filter-extra-actions { order: 99; margin: 0 0 0 auto; background: transparent; border: 0; padding: 0; white-space: nowrap; }
body.lg-admin #changelist-filter #changelist-filter-extra-actions h3, body.lg-admin #changelist-filter #changelist-filter-extra-actions ul { display: inline; margin: 0; padding: 0; }
body.lg-admin #changelist-filter #changelist-filter-extra-actions li { display: inline; margin-left: 10px; font-size: 12.5px; }
body.lg-admin #changelist-filter details { position: relative; margin: 0; }
body.lg-admin #changelist-filter details summary { list-style: none; cursor: pointer; font-size: 13px; color: var(--fg); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; padding: 6px 28px 6px 10px; font-weight: 500; text-transform: none; }
body.lg-admin #changelist-filter details summary::-webkit-details-marker { display: none; }
body.lg-admin #changelist-filter details > summary::before { content: none; }
body.lg-admin #changelist-filter details > summary > * { display: inline; }
body.lg-admin #changelist-filter details summary::after { content: "▾"; position: absolute; right: 10px; top: 6px; color: var(--muted); }
body.lg-admin #changelist-filter details summary.aktiv { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
body.lg-admin #changelist-filter details[open] > ul { position: absolute; top: calc(100% + 4px); left: 0; z-index: 60; min-width: 220px; max-height: 320px; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-lg); padding: 6px 0; margin: 0; }
body.lg-admin #changelist-filter details > ul li { list-style: none; padding: 0; border: 0; }
body.lg-admin #changelist-filter details > ul li a { display: block; padding: 6px 12px; color: var(--fg-2); text-decoration: none; font-size: 13px; }
body.lg-admin #changelist-filter details > ul li a:hover { background: var(--surface-2); color: var(--fg); }
body.lg-admin #changelist-filter details > ul li.selected a { color: var(--accent); font-weight: 600; background: var(--accent-soft); }
body.lg-admin #changelist .results, body.lg-admin #changelist .paginator, body.lg-admin #toolbar, body.lg-admin #changelist .actions { background: var(--surface); }
body.lg-admin #changelist .results { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; }
body.lg-admin #toolbar { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
body.lg-admin #toolbar form input[type=text], body.lg-admin #searchbar { border-radius: 8px; padding: 7px 10px; font-size: 13.5px; min-width: 300px; }
body.lg-admin #toolbar form input[type=submit] { border-radius: 8px !important; padding: 7px 12px !important; }
body.lg-admin #changelist table { border-collapse: separate; border-spacing: 0; width: 100%; }
body.lg-admin #changelist table thead th { background: var(--surface-2); color: var(--fg-2); font-weight: 600; font-size: 12px; padding: 9px 10px; border-bottom: 1px solid var(--line); text-transform: none; }
body.lg-admin #changelist table thead th a { color: var(--fg-2); }
body.lg-admin #changelist table thead th.sorted { background: var(--surface-2); }
body.lg-admin #changelist table tbody td, body.lg-admin #changelist table tbody th { padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
body.lg-admin #changelist table tbody tr:hover td, body.lg-admin #changelist table tbody tr:hover th { background: var(--surface-2); }
body.lg-admin #changelist table tbody th a { font-weight: 500; }
body.lg-admin #changelist .actions { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 12px; box-shadow: var(--shadow); color: var(--fg-2); }
body.lg-admin #changelist .actions select { padding: 5px 30px 5px 8px; }
.paginator { border: 1px solid var(--line); border-radius: var(--radius); margin-top: 12px; padding: 10px 14px; box-shadow: var(--shadow); font-size: 13px; color: var(--fg-2); }
.paginator a, .paginator .this-page { border-radius: 6px; padding: 3px 8px; }
.paginator .this-page { background: var(--accent); color: var(--accent-fg); }
.paginator a:link, .paginator a:visited { background: var(--surface-2); color: var(--fg); }
.paginator .showall { color: var(--accent); }
body.lg-admin #changelist .actions .button { padding: 5px 12px !important; }
body.lg-admin #changelist.filtered .results, body.lg-admin #changelist.filtered .paginator, body.lg-admin .filtered #toolbar, body.lg-admin .filtered div.xfull { margin-right: 0; }

/* Startseite der Verwaltung (Verwaltung – alles) */
/* Startseite der Verwaltung: Module als Kachelraster, „Neueste Aktionen“ rechts daneben (kein Float-Umbruch) */
body.lg-admin.dashboard #content.colMS { width: auto; display: grid; grid-template-columns: minmax(0, 1fr) 320px; grid-template-areas: "kopf kopf" "module aktionen"; column-gap: 24px; align-items: start; margin-right: 0; max-width: none; }
body.lg-admin.dashboard #content.colMS > h1 { grid-area: kopf; }
body.lg-admin.dashboard #content-main { grid-area: module; float: none; width: auto; min-width: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 16px; align-content: start; align-items: start; }
body.lg-admin.dashboard #content-main .module { margin: 0; }
body.lg-admin.dashboard #content-related { grid-area: aktionen; float: none; position: static; margin: 0; width: auto; background: transparent; border: 0; padding: 0; }
@media (max-width: 1100px) { body.lg-admin.dashboard #content.colMS { grid-template-columns: minmax(0, 1fr); grid-template-areas: "kopf" "module" "aktionen"; } }
#content-related .module { padding: 0; }
#content-related h2, #recent-actions-module h2 { background: var(--surface-2); }
.dashboard .module table th, .dashboard .module table td { padding: 8px 14px; border-bottom: 1px solid var(--line); }
.dashboard .module table th a { font-weight: 500; }
.dashboard .module table caption a.section { color: var(--fg); font-weight: 600; text-transform: none; }
.dashboard .module table td a { color: var(--accent); font-size: 12.5px; }

/* Login-Seite (ohne Seitenleiste) */
body.login { background: linear-gradient(160deg, var(--accent-soft), var(--bg) 60%); display: flex; align-items: center; justify-content: center; min-height: 100vh; }
body.login #container { min-height: 0; width: 100%; max-width: 420px; }
body.login #header { display: flex; background: transparent; padding: 0 0 8px; justify-content: center; }
body.login #header #branding h1, body.login #header #branding h1 a { color: var(--fg); font-weight: 700; font-size: 20px; }
body.login #content { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 24px 26px !important; }
body.login .form-row { border: 0; padding: 6px 0; }
body.login .form-row label { display: block; width: auto; padding: 0 0 4px; color: var(--fg-2); }
body.login .form-row input[type=text], body.login .form-row input[type=password] { width: 100%; padding: 10px 12px; font-size: 14px; }
body.login .submit-row { position: static; border: 0; box-shadow: none; padding: 10px 0 0; background: transparent; }
body.login .submit-row input { width: 100%; padding: 10px !important; font-size: 14px !important; }
body.login .password-reset-link { text-align: center; }
/* Leaflet-Widgets in Formularen */
.leaflet-container { border-radius: 10px; border: 1px solid var(--line); }
div.django-leaflet-raw-textarea { display: none; }
@media (max-width: 900px) { #content { padding: 14px; } .aligned label { width: 100%; padding: 0 0 4px; } .aligned .form-row .help { margin-left: 0; } }

/* Pin je Modul in der Verwaltung: angeheftet = eigener Eintrag in der Seitenleiste */
body.lg-admin .dashboard .module table td.lg-pin-zelle, body.lg-admin #content-main .module table td.lg-pin-zelle { width: 28px; text-align: right; padding-right: 10px; }
.lg-pin-modul { display: inline-flex; align-items: center; padding: 2px 4px; border-radius: 4px; color: var(--muted); }
.lg-pin-modul svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.lg-pin-modul.on { color: var(--accent); }
.lg-pin-modul.on svg { fill: var(--accent); }
.lg-pin-modul:hover { color: var(--accent); }

/* Modulsuche auf der Verwaltungs-Startseite: filtert die Kacheln nach Modul-/Kategoriename */
body.lg-admin.dashboard #content.colMS .lg-modulsuche { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
body.lg-admin.dashboard #content.colMS { grid-template-areas: "kopf kopf" "suche suche" "module aktionen"; }
body.lg-admin.dashboard #content.colMS .lg-modulsuche { grid-area: suche; }
@media (max-width: 1100px) { body.lg-admin.dashboard #content.colMS { grid-template-areas: "kopf" "suche" "module" "aktionen"; } }
.lg-modulsuche input[type=search] { width: min(520px, 100%); padding: 9px 12px; font-size: 14px; }
.lg-modulsuche-info { color: var(--muted); font-size: 12.5px; }
.lg-modulsuche-link { margin-left: auto; font-size: 13px; color: var(--accent); }

/* Dokumente öffnen (ONLYOFFICE / Bildansicht) – Schaltflächen in Listen, Inlines und Objektwerkzeugen */
a.lg-office { display: inline-block; padding: 2px 9px; border: 1px solid var(--line-strong); border-radius: 12px; font-size: 12px; text-decoration: none; color: var(--fg); background: var(--surface); white-space: nowrap; }
a.lg-office:hover { background: var(--surface-2); }
a.lg-office + a.lg-office { margin-left: 4px; }
.object-tools li.lg-office-tools { display: flex; gap: 6px; align-items: center; }
.object-tools li.lg-office-tools a.lg-office { padding: 5px 12px; border-radius: 6px; font-size: 12px; }

/* Sofort-Upload für Dokumente (Drag & Drop) */
.lg-dropzone { margin: 8px 0 14px; padding: 14px 16px; border: 2px dashed var(--line-strong); border-radius: 10px; background: var(--surface); position: relative; font-size: 13px; }
.lg-dropzone.lg-over { border-color: #2563eb; background: #eff6ff; }
.lg-dropzone-input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.lg-dropzone label { cursor: pointer; display: block; margin-bottom: 6px; }
.lg-dropzone-kat { color: var(--muted, #6b7280); }
.lg-dok-neu-form { display: inline-flex; gap: 6px; align-items: center; margin-left: 18px; color: var(--muted, #6b7280); } .lg-dok-neu-form input { width: 220px; } .lg-dok-neu-form .button { padding: 4px 10px; }
.lg-dropzone-kategorie { width: 160px; padding: 2px 6px; }
.lg-dropzone-status { margin-top: 6px; }
.lg-dropzone-status .ok { color: #166534; } .lg-dropzone-status .fehler { color: #b91c1c; }
tr.lg-dok-neu td { background: #f0fdf4; }
.lg-dropzone-hinweis { color: var(--muted, #6b7280); font-size: 12.5px; margin: 6px 0 12px; }
