/* Liegenschaftsverwaltung – Design-System (hell, blauer Akzent; Dark Mode nach Systemeinstellung)
   Gilt für die eigenen Seiten (Karte, Wiedervorlagen, Import) UND die Django-Verwaltung (admin-theme.css baut darauf auf). */
:root, :root[data-theme="light"] {   /* auch gegen html[data-theme=light] der Django-Verwaltung */
  --font: Inter, "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --bg: #f6f7f9;            /* Seitenhintergrund */
  --surface: #ffffff;       /* Karten, Panels, Formulare */
  --surface-2: #f1f4f8;     /* leichte Flächen (Tabellenkopf, Hover) */
  --line: #e3e8ef;
  --line-strong: #cbd5e1;
  --fg: #0f172a;
  --fg-2: #475569;          /* Sekundärtext */
  --muted: #94a3b8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #e8efff;
  --accent-fg: #ffffff;
  --success: #15803d; --success-soft: #dcfce7;
  --warn: #b45309;    --warn-soft: #fef3c7;
  --danger: #b91c1c;  --danger-soft: #fee2e2;
  --info-soft: #e0f2fe;
  --radius: 10px; --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .06);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .12);
  --sidebar-w: 236px; --topbar-h: 52px;
  --side: 320px;            /* Kartenpanel */
  color-scheme: light;
}
/* Dunkler Modus: html[data-theme=dark] – wird vom Kopfzeilen-Umschalter bzw. der Systemeinstellung gesetzt (shell.js, Inline-Skript im Head) */
:root[data-theme="dark"] {
    --bg: #0b1220; --surface: #111a2e; --surface-2: #17223a; --line: #223050; --line-strong: #2e3f63;
    --fg: #e5e9f0; --fg-2: #a7b3c7; --muted: #6b7a94; --accent: #5b8def; --accent-hover: #7aa2f7; --accent-soft: #1b2a4a; --accent-fg: #0b1220;
    --success: #4ade80; --success-soft: #0f2e1d; --warn: #fbbf24; --warn-soft: #3a2a08; --danger: #f87171; --danger-soft: #3b1212; --info-soft: #0c2a3d;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 10px 30px rgba(0,0,0,.5);
    color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); color: var(--fg); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }

/* ---------- App-Shell: Seitenleiste + Kopfzeile + Inhalt ---------- */
.lg-shell { display: flex; min-height: 100%; }
.lg-sidebar { width: var(--sidebar-w); flex: none; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow: hidden; transition: width .15s ease; z-index: 30; }
.lg-sidebar .lg-brand { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--fg); min-height: var(--topbar-h); }
.lg-brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; overflow: hidden; }
.lg-brand .logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.lg-brand .t { line-height: 1.2; min-width: 0; }
.lg-brand .t b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lg-brand .t span { color: var(--fg-2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.lg-nav { flex: 1; overflow-y: auto; padding: 10px 10px 20px; }
.lg-nav .grp { margin-top: 14px; }
.lg-nav .grp:first-child { margin-top: 2px; }
.lg-nav .grp > span { display: block; padding: 0 8px 6px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.lg-nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--fg-2); text-decoration: none; font-weight: 500; font-size: 13.5px; white-space: nowrap; }
.lg-nav a .l { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.lg-nav a svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.lg-nav a:hover { background: var(--surface-2); color: var(--fg); }
.lg-nav a.active { background: var(--accent-soft); color: var(--accent); }
.lg-nav a.active svg { opacity: 1; }
.lg-sidebar .lg-foot { padding: 10px 12px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* eingeklappt: nur Icons (html.lg-pre-collapsed: vor dem Laden von shell.js, verhindert Aufblitzen) */
html.lg-pre-collapsed .lg-sidebar { width: 64px; }
html.lg-pre-collapsed .lg-brand .t, html.lg-pre-collapsed .lg-nav .grp > span, html.lg-pre-collapsed .lg-nav a .l, html.lg-pre-collapsed .lg-kommune span, html.lg-pre-collapsed .lg-foot .v { display: none; }
.lg-shell.collapsed .lg-sidebar { width: 64px; }
.lg-shell.collapsed .lg-brand .t, .lg-shell.collapsed .lg-nav .grp > span, .lg-shell.collapsed .lg-nav a .l { display: none; }
.lg-shell.collapsed .lg-nav a { justify-content: center; padding: 9px 0; }
.lg-shell.collapsed .lg-nav .grp { margin-top: 6px; border-top: 1px solid var(--line); padding-top: 6px; }
.lg-shell.collapsed .lg-brand { justify-content: center; padding: 14px 8px; }

.lg-body { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.lg-topbar { height: var(--topbar-h); flex: none; display: flex; align-items: center; gap: 12px; padding: 0 18px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.lg-topbar .lg-toggle { border: 0; background: transparent; color: var(--fg-2); width: 34px; height: 34px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.lg-topbar .lg-toggle:hover { background: var(--surface-2); color: var(--fg); }
.lg-topbar .lg-toggle svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.lg-topbar h1 { font-size: 16px; font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lg-topbar .lg-user { display: flex; align-items: center; gap: 10px; color: var(--fg-2); font-size: 13px; }
.lg-topbar .lg-user .avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 600; font-size: 12px; }
.lg-topbar .lg-user a { color: var(--fg-2); text-decoration: none; padding: 5px 9px; border-radius: 6px; border: 1px solid var(--line); font-size: 12.5px; }
.lg-topbar .lg-user a:hover { background: var(--surface-2); color: var(--fg); }
.lg-content { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.lg-page { padding: 22px 24px 40px; max-width: 1280px; width: 100%; }

@media (max-width: 900px) {
  .lg-sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .lg-shell.open .lg-sidebar { transform: none; }
  .lg-shell.collapsed .lg-sidebar { width: var(--sidebar-w); }
  .lg-shell.collapsed .lg-brand .t, .lg-shell.collapsed .lg-nav .grp > span, .lg-shell.collapsed .lg-nav a .l { display: block; }
  .lg-shell.collapsed .lg-nav a { justify-content: flex-start; padding: 7px 10px; }
  .lg-page { padding: 14px; }
}

/* ---------- Bausteine ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.card h2 { font-size: 14px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.card h2 .n { margin-left: auto; font-weight: 500; color: var(--muted); font-size: 12px; }
.btn, .btn2 { font: inherit; font-size: 13px; font-weight: 500; padding: 7px 12px; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; line-height: 1.2; }
.btn { background: var(--accent); color: var(--accent-fg); border: 1px solid transparent; }
.btn:hover { background: var(--accent-hover); }
.btn2 { background: var(--surface); color: var(--fg); border: 1px solid var(--line-strong); }
.btn2:hover { background: var(--surface-2); }
.btn2.danger { color: var(--danger); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; line-height: 1.5; background: var(--surface-2); color: var(--fg-2); }
.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--accent); }
.muted { color: var(--muted); }
.hidden { display: none !important; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th { text-align: left; font-weight: 600; color: var(--fg-2); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
table.tbl th:first-child { border-radius: 6px 0 0 6px; } table.tbl th:last-child { border-radius: 0 6px 6px 0; }
table.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
table.tbl a { text-decoration: none; font-weight: 500; }
table.tbl a:hover { text-decoration: underline; }
.msg { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; background: var(--success-soft); color: var(--success); border: 1px solid color-mix(in srgb, var(--success) 25%, transparent); }
.msg.error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.msg.warning { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
input[type=text], input[type=search], input[type=number], input[type=email], input[type=url], input[type=password], input[type=date], input:not([type]), select, textarea {
  font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; padding: 7px 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); outline-offset: 0; border-color: var(--accent); }
input::placeholder { color: var(--muted); }

/* ---------- Marke (Neovers-Logo) und Kommune in der Seitenleiste ---------- */
.lg-brand img { display: none; height: 22px; width: auto; }
.lg-brand .logo-full.hell { display: block; }
.lg-shell.collapsed .lg-brand .logo-full { display: none !important; }
.lg-shell.collapsed .lg-brand .logo-n.hell { display: block; height: 24px; }
.lg-kommune { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-bottom: 1px solid var(--line); font-size: 12.5px; color: var(--fg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lg-kommune img { height: 20px; width: auto; flex: none; }
.lg-kommune span { overflow: hidden; text-overflow: ellipsis; }
.lg-shell.collapsed .lg-kommune { justify-content: center; padding: 8px 4px; }
.lg-shell.collapsed .lg-kommune span { display: none; }
.lg-shell.collapsed .lg-kommune { display: none; }
.lg-foot { display: flex; align-items: center; gap: 6px; }
.lg-foot .v { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.lg-expand { border: 1px solid var(--line); background: var(--surface); color: var(--fg-2); width: 28px; height: 28px; border-radius: 7px; cursor: pointer; display: grid; place-items: center; flex: none; }
.lg-expand:hover { background: var(--surface-2); color: var(--fg); }
.lg-expand svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.lg-shell:not(.collapsed) .lg-expand svg { transform: rotate(180deg); }
.lg-shell.collapsed .lg-foot { display: flex; justify-content: center; padding: 10px 6px; }
.lg-shell.collapsed .lg-foot .v { display: none; }
:root[data-theme="dark"] .lg-brand .logo-full.hell, :root[data-theme="dark"] .lg-shell.collapsed .lg-brand .logo-n.hell { display: none; }
:root[data-theme="dark"] .lg-brand .logo-full.dunkel { display: block; }
:root[data-theme="dark"] .lg-shell.collapsed .lg-brand .logo-full.dunkel { display: none; }
:root[data-theme="dark"] .lg-shell.collapsed .lg-brand .logo-n.dunkel { display: block; height: 24px; }
/* Umschalter hell/dunkel in der Kopfzeile */
.lg-topbar .lg-theme { border: 1px solid var(--line); background: var(--surface); color: var(--fg-2); width: 32px; height: 32px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.lg-topbar .lg-theme:hover { background: var(--surface-2); color: var(--fg); }
.lg-topbar .lg-theme svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lg-topbar .lg-theme .mond { display: none; }
:root[data-theme="dark"] .lg-topbar .lg-theme .sonne { display: none; }
:root[data-theme="dark"] .lg-topbar .lg-theme .mond { display: block; }
@media (max-width: 900px) {
  .lg-shell.collapsed .lg-brand .logo-full.hell { display: block; } .lg-shell.collapsed .lg-brand .logo-n { display: none !important; }
  .lg-shell.collapsed .lg-kommune span { display: inline; } .lg-shell.collapsed .lg-foot .v { display: block; }
}

/* Seitenleiste ohne angeheftete Module */
.lg-nav .lg-hinweis { margin: 0; padding: 4px 8px; font-size: 12px; color: var(--muted); white-space: normal; line-height: 1.4; }
.lg-nav .lg-hinweis a { display: inline; padding: 0; color: var(--accent); font-size: inherit; }
html.lg-pre-collapsed .lg-nav .lg-leer, .lg-shell.collapsed .lg-nav .lg-leer { display: none; }

/* Mandant in der Kopfzeile (Cloud): Betreiber sehen den gewählten Mandanten mit „×“ zum Verlassen */
.lg-topbar .lg-mandant { display: inline-flex; align-items: center; gap: 6px; padding: 4px 4px 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12.5px; font-weight: 600; margin-right: 6px; }
.lg-topbar .lg-mandant a { color: inherit; text-decoration: none; border: 0; padding: 0; font-size: inherit; }
.lg-topbar .lg-mandant button { border: 0; background: transparent; color: inherit; font-size: 15px; line-height: 1; cursor: pointer; padding: 0 5px; border-radius: 999px; }
.lg-topbar .lg-mandant button:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }
span.lg-mandant { padding: 4px 10px; }
/* Hilfe-Knopf in der Kopfzeile */
.lg-topbar .lg-hilfe { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line-strong, #cbd5e1); font-weight: 700; text-decoration: none; color: inherit; margin-right: 6px; }
.lg-topbar .lg-hilfe:hover { background: var(--surface-2, #eef2f7); }

/* ---------- Mobil (Handy/Tablet hochkant): kompakte Kopfzeile, große Touch-Ziele, keine Zoomsprünge in Eingaben ---------- */
@media (max-width: 700px) {
  .lg-topbar { padding: 0 8px; gap: 6px; }
  .lg-topbar .lg-user { gap: 6px; }
  .lg-topbar .lg-user .name, .lg-topbar .lg-user a[href*="password"], .lg-topbar .lg-user a[href*="/2fa/"] { display: none; }
  .lg-topbar .lg-user form button { font-size: 0 !important; padding: 5px 8px !important; }
  .lg-topbar .lg-user form button::before { content: "⎋"; font-size: 15px; line-height: 1; }
  .btn, .btn2 { min-height: 40px; }
  input, select, textarea { font-size: 16px; }   /* iOS zoomt sonst beim Fokus */
  .fe-actions { gap: 6px; }
  .fe-actions .btn, .fe-actions .btn2 { padding: 7px 10px; }
}
