/* TRLands – ruhiges, responsives Grundlayout (ohne Framework). */

:root {
    --bg: #f5f6f4;
    --surface: #ffffff;
    --surface-2: #eef1ed;
    --border: #dde2db;
    --text: #1f2a24;
    --muted: #5d6b63;
    --primary: #2f6b4f;
    --primary-hover: #25573f;
    --primary-contrast: #ffffff;
    --danger: #a63a32;
    --danger-bg: #fbeceb;
    --ok: #2f6b4f;
    --ok-bg: #e7f2ec;
    --warn: #8a5a00;
    --warn-bg: #fdf3dc;
    --focus: #2f6b4f;
    --radius: 8px;
    --sidebar-w: 248px;
    --topbar-h: 52px;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #161b18;
        --surface: #1e2521;
        --surface-2: #262e29;
        --border: #34403a;
        --text: #e6ece8;
        --muted: #9aa8a0;
        --primary: #5aa882;
        --primary-hover: #6fb994;
        --primary-contrast: #0f1a14;
        --danger: #e08a82;
        --danger-bg: #3a2220;
        --ok: #7bc8a0;
        --ok-bg: #1f3329;
        --warn: #e5b85c;
        --warn-bg: #3a3017;
        --focus: #7bc8a0;
    }
}

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

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

h1 { font-size: 1.5rem; margin: 0; font-weight: 600; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; font-weight: 600; }
h3 { font-size: 1rem; margin: 0 0 .5rem; font-weight: 600; }
p { margin: 0 0 .75rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }
a { color: var(--primary); }
.muted { color: var(--muted); }
small { font-size: .85rem; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Gerüst ---------- */

.shell { min-height: 100vh; }
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }

.topbar {
    display: none;
    position: fixed; top: 0; left: 0; right: 0; z-index: 30;
    height: var(--topbar-h);
    align-items: center; gap: .75rem;
    padding: 0 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.burger { display: inline-flex; padding: .5rem; margin-left: -.5rem; cursor: pointer; border-radius: var(--radius); color: var(--text); }
.burger:hover { background: var(--surface-2); }

.brand { font-weight: 700; letter-spacing: .02em; color: var(--primary); }
.brand-side { padding: 1.25rem 1.25rem 1rem; font-size: 1.2rem; }

.sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 40;
    width: var(--sidebar-w);
    display: flex; flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

.content {
    margin-left: var(--sidebar-w);
    padding: 1.75rem 2rem 3rem;
    max-width: 1200px;
}

.scrim { display: none; }

/* ---------- Navigation ---------- */

.nav { display: flex; flex-direction: column; padding: 0 .75rem; gap: 2px; flex: 1; }
.nav-group { margin: 1.25rem .5rem .35rem; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.nav-link {
    display: block; padding: .55rem .75rem; border-radius: var(--radius);
    color: var(--text); text-decoration: none;
}
.nav-link:hover { background: var(--surface-2); }
.nav-link.active { background: var(--ok-bg); color: var(--primary); font-weight: 600; }

.nav-footer { padding: .75rem; border-top: 1px solid var(--border); }
.nav-user { padding: 0 .5rem .5rem; font-size: .9rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Bausteine ---------- */

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: .5rem 1rem; min-height: 40px;
    font: inherit; color: var(--text); text-decoration: none; cursor: pointer;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-ghost { width: 100%; justify-content: flex-start; border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-small { min-height: 32px; padding: .25rem .75rem; font-size: .9rem; }
.btn-block { width: 100%; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0 .5rem; }

.alert { padding: .65rem .9rem; border-radius: var(--radius); margin-bottom: 1rem; background: var(--surface-2); border: 1px solid var(--border); }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.alert-ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; background: var(--surface-2); border: 1px solid var(--border); }
.badge-ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge-off { background: var(--surface-2); color: var(--muted); }
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }

/* ---------- Formulare ---------- */

.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .9rem; }
.field label { font-size: .9rem; font-weight: 600; }
input[type="text"], input[type="email"], input[type="password"], input:not([type]), select {
    width: 100%; min-height: 40px; padding: .45rem .65rem;
    font: inherit; color: var(--text);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
input:focus, select:focus { border-color: var(--focus); }
.check { display: inline-flex; align-items: center; gap: .5rem; margin: 0 0 .9rem; cursor: pointer; }
.check input { width: 18px; height: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 1rem; align-items: start; }
.form-inline { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.form-inline input { flex: 1 1 220px; }
.validation-message, .validation-errors { color: var(--danger); font-size: .9rem; }
.invalid { border-color: var(--danger) !important; }

/* ---------- Tabellen ---------- */

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .65rem .85rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); }
.table tr:last-child td { border-bottom: 0; }
.row-actions { text-align: right !important; white-space: nowrap; }
.matrix td:not(:first-child), .matrix th:not(:first-child) { text-align: center; width: 110px; }
.matrix input[type="checkbox"] { width: 18px; height: 18px; }
.group-row td { background: var(--surface-2); font-weight: 600; font-size: .85rem; color: var(--muted); }

.split { display: grid; grid-template-columns: minmax(240px, 320px) 1fr; gap: 1.25rem; align-items: start; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-radius: var(--radius); }
.list li.active { background: var(--ok-bg); }
.list-item {
    width: 100%; display: flex; justify-content: space-between; gap: .5rem; align-items: baseline;
    padding: .6rem .75rem; font: inherit; color: var(--text); text-align: left;
    background: transparent; border: 0; border-radius: var(--radius); cursor: pointer;
}
.list-item:hover { background: var(--surface-2); }

/* ---------- Anmeldung ---------- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 2rem 1.75rem; }
.login-brand { font-size: 1.4rem; margin-bottom: 1rem; }
.login-title { margin-bottom: 1.25rem; }

/* ---------- Fehleranzeige / Wiederverbinden ---------- */

#blazor-error-ui {
    display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
    padding: .75rem 1.25rem; background: var(--warn-bg); color: var(--warn);
    border-top: 1px solid var(--border);
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

/* ---------- Mobil / schmal ---------- */

@media (max-width: 900px) {
    .topbar { display: flex; }
    .sidebar { transform: translateX(-100%); transition: transform .18s ease; box-shadow: none; padding-top: 0; }
    .content { margin-left: 0; padding: calc(var(--topbar-h) + 1.25rem) 1rem 2.5rem; }
    .nav-toggle:checked ~ .sidebar { transform: translateX(0); box-shadow: 4px 0 24px rgba(0, 0, 0, .25); }
    .nav-toggle:checked ~ .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, .35); }
    .split { grid-template-columns: 1fr; }
    .nav-link, .btn { min-height: 44px; }
    .nav-link { display: flex; align-items: center; }
}

/* Tabellen auf Telefonen als Karten */
@media (max-width: 640px) {
    .table:not(.matrix) thead { display: none; }
    .table:not(.matrix) tr { display: grid; grid-template-columns: 1fr 1fr; gap: .2rem 1rem; padding: .75rem .9rem; border-bottom: 1px solid var(--border); }
    .table:not(.matrix) td { display: flex; flex-direction: column; align-items: flex-start; gap: .05rem; padding: 0; border: 0; min-width: 0; overflow-wrap: anywhere; }
    .table:not(.matrix) td::before { content: attr(data-label); color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; }
    .table:not(.matrix) td:first-child { grid-column: 1 / -1; font-size: 1.05rem; font-weight: 600; }
    .table:not(.matrix) td:first-child::before { content: none; }
    .table:not(.matrix) td.row-actions { grid-column: 1 / -1; align-items: stretch; padding-top: .5rem; }
    .table:not(.matrix) td.row-actions::before { content: none; }
    .table:not(.matrix) td.row-actions .btn { width: 100%; }
    .table:not(.matrix) td[colspan] { grid-column: 1 / -1; display: block; }
    .table:not(.matrix) td.num { text-align: left !important; }
    /* Rechte-Matrix: pro Bereich eine Karte mit Titel und beschrifteten Kästchen (alle Rechtearten ohne Seitwärtswischen) */
    .matrix thead { display: none; }
    .matrix tr { display: grid; grid-template-columns: repeat(4, 1fr); gap: .35rem .25rem; padding: .7rem .9rem; border-bottom: 1px solid var(--border); }
    .matrix td { display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: 0; border: 0; width: auto !important; }
    .matrix td:not(:first-child)::before { content: attr(data-label); color: var(--muted); font-size: .72rem; }
    .matrix td:first-child { grid-column: 1 / -1; align-items: flex-start; font-weight: 600; }
    .matrix td[colspan] { grid-column: 1 / -1; }
    .matrix tr.group-row { display: block; padding: .5rem .9rem; }
    .matrix td:not(:first-child) input[type="checkbox"] { width: 24px; height: 24px; }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar { transition: none; }
}

/* ---------- Listen und Stammdaten ---------- */

.toolbar { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar input[type="text"] { max-width: 320px; }
.toolbar .check { margin: 0; }
.toolbar .grow { flex: 1; }
.sum { color: var(--muted); font-size: .9rem; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.pager { display: flex; gap: .5rem; align-items: center; justify-content: flex-end; margin-top: .75rem; color: var(--muted); font-size: .9rem; }
.fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem 0; margin: 0 0 1rem; min-width: 0; }
.fieldset > legend { padding: 0 .4rem; font-size: .85rem; font-weight: 600; color: var(--muted); }
input[type="number"], input[type="date"] {
    width: 100%; min-height: 40px; padding: .45rem .65rem;
    font: inherit; color: var(--text);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
input:disabled, select:disabled { background: var(--surface-2); color: var(--muted); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Anbau: Karten, Abschnitte, Jahresauswahl (Handy zuerst) ---------- */

.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: .75rem; }
.item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem; }
.item + .item { margin-top: .6rem; }
.grid-cards .item + .item { margin-top: 0; }
.item-head { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
.item-meta { color: var(--muted); font-size: .9rem; margin: .15rem 0 .5rem; overflow-wrap: anywhere; }
.item-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .65rem; }
.item-actions .btn { flex: 1 1 auto; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: .1rem .6rem; font-size: .85rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chip-warn { background: var(--warn-bg, #fdf0d5); color: var(--warn, #8a5a00); border-color: transparent; font-weight: 600; }
small.warn { display: block; margin-top: .3rem; color: var(--warn, #8a5a00); }
.form-zeile { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.form-zeile .field { margin: 0; min-width: 8rem; }
.chip-strong { background: var(--ok-bg); color: var(--ok); border-color: transparent; font-weight: 600; }
.sumbar { margin-top: .75rem; padding: .65rem .85rem; background: var(--ok-bg); border-radius: var(--radius); }
.sumbar .label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .25rem; }
.stepper { display: flex; align-items: center; gap: .5rem; }
.stepper .year { min-width: 4.5rem; text-align: center; font-weight: 600; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.back { display: inline-block; margin-bottom: .5rem; }
.titelzeile { display: flex; flex-wrap: wrap; gap: .25rem .75rem; align-items: baseline; margin-bottom: 1rem; }
.titelzeile h1 { overflow-wrap: anywhere; }

details.section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .9rem; }
details.section > summary {
    display: flex; justify-content: space-between; align-items: center; gap: .5rem;
    min-height: 52px; padding: .6rem 1rem; cursor: pointer; font-weight: 600; list-style: none;
}
details.section > summary::-webkit-details-marker { display: none; }
details.section > summary::after { content: "▾"; color: var(--muted); transition: transform .15s; }
details.section[open] > summary::after { transform: rotate(180deg); }
details.section > .section-body { padding: 0 1rem 1rem; }
.section-body .card { background: var(--surface-2); }
.formblock { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: .85rem; }
select { appearance: auto; }
.radiozeile { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: .9rem; }

@media (max-width: 640px) {
    .content { padding-left: .85rem; padding-right: .85rem; }
    h1 { font-size: 1.3rem; }
    .page-head .btn { width: 100%; }
    .form-grid { grid-template-columns: 1fr; }
    .actions .btn { flex: 1 1 140px; }
    .toolbar input[type="text"] { max-width: none; width: 100%; }
}

@media (max-width: 900px) {
    .check { min-height: 44px; }
    .check input { width: 22px; height: 22px; }
}
.btn-abstand { margin-bottom: .75rem; }

.json { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .75rem; margin: .2rem 0 .6rem; font-size: .8rem; overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Berichtsvorschau (DevExpress Report Viewer) ---------- */
.bericht-rahmen { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.bericht-viewer { width: 100%; height: 75vh; min-height: 420px; }
@media (max-width: 640px) { .bericht-viewer { height: 70vh; } }

/* ---------- Berichtsvorschau (DevExpress Fluent): Akzent im TRLands-Grün statt Fluent-Blau ---------- */
:root {
    --dxbl-accent-color-10: #ebf4f0;
    --dxbl-accent-color-20: #d4e9df;
    --dxbl-accent-color-30: #bbdfcf;
    --dxbl-accent-color-40: #a3d6be;
    --dxbl-accent-color-50: #89cbac;
    --dxbl-accent-color-60: #6ebf99;
    --dxbl-accent-color-70: #51b285;
    --dxbl-accent-color-80: #3e8d68;
    --dxbl-accent-color-90: #2f6b4f;
    --dxbl-accent-color-100: #2c6349;
    --dxbl-accent-color-110: #265640;
    --dxbl-accent-color-120: #1f4835;
    --dxbl-accent-color-130: #1a3c2c;
    --dxbl-accent-color-140: #152f23;
    --dxbl-accent-color-150: #10241b;
}

/* =====================================================================
   Feinschliff: ruhig, modern, Symbole, Logo, Akkordeon
   (ergänzt die Grundregeln oben; spätere Regeln gelten)
   ===================================================================== */

:root {
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(23, 43, 33, .06);
    --shadow: 0 1px 2px rgba(23, 43, 33, .05), 0 8px 22px rgba(23, 43, 33, .07);
    --ring: color-mix(in srgb, var(--primary) 28%, transparent);
    --logo-bg: #2f6b4f;
}
@media (prefers-color-scheme: dark) {
    :root {
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 26px rgba(0, 0, 0, .3);
        --ring: color-mix(in srgb, var(--primary) 42%, transparent);
        --logo-bg: #3a8663;
    }
}

body {
    background:
        radial-gradient(900px 360px at 0% -140px, color-mix(in srgb, var(--primary) 10%, transparent), transparent 70%),
        var(--bg);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
}
h1 { font-weight: 650; letter-spacing: -.012em; }
h2, h3 { letter-spacing: -.005em; }

.icon { flex: none; vertical-align: -.2em; }

/* ---------- Logo ---------- */
.logo { display: inline-flex; align-items: center; gap: .65rem; color: var(--text); text-decoration: none; }
.logo-mark { width: 34px; height: 34px; flex: none; filter: drop-shadow(0 2px 6px color-mix(in srgb, var(--primary) 32%, transparent)); }
.logo-bg { fill: var(--logo-bg); }
.logo-text { display: flex; flex-direction: column; line-height: 1.1; }
.logo-wort { font-size: 1.18rem; font-weight: 700; letter-spacing: -.01em; }
.logo-wort b { color: var(--primary); font-weight: 800; }
.logo-wort span { font-weight: 500; }
.logo-sub { margin-top: .18rem; font-size: .66rem; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.logo-kompakt .logo-mark { width: 28px; height: 28px; }
.logo-kompakt .logo-wort { font-size: 1.05rem; }
.logo-gross { flex-direction: column; gap: .75rem; text-align: center; }
.logo-gross .logo-mark { width: 60px; height: 60px; }
.logo-gross .logo-text { align-items: center; }
.logo-gross .logo-wort { font-size: 1.7rem; }
.logo-gross .logo-sub { font-size: .72rem; }
.brand-side { padding: 1.15rem 1.1rem 1rem; }
.login-brand { display: flex; justify-content: center; margin-bottom: 1.25rem; }

/* ---------- Gerüst, Navigation ---------- */
.sidebar { background: color-mix(in srgb, var(--surface) 94%, var(--bg)); }
.topbar {
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
    backdrop-filter: saturate(160%) blur(12px);
}
.nav-group { font-weight: 600; }
.nav-link {
    display: flex; align-items: center; gap: .7rem; position: relative;
    transition: background .15s ease, color .15s ease;
}
.nav-link .icon { color: var(--muted); transition: color .15s ease, transform .15s ease; }
.nav-link:hover .icon { color: var(--primary); transform: translateX(1px); }
.nav-link.active {
    background: linear-gradient(90deg, color-mix(in srgb, var(--primary) 17%, transparent), color-mix(in srgb, var(--primary) 5%, transparent));
    color: var(--primary); font-weight: 600;
}
.nav-link.active .icon { color: var(--primary); }
.nav-link.active::before {
    content: ""; position: absolute; left: -.75rem; top: 22%; bottom: 22%; width: 3px;
    border-radius: 0 3px 3px 0; background: var(--primary);
}
.btn-ghost .icon { color: var(--muted); }

/* ---------- Bausteine ---------- */
.card { border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.item { border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); transition: box-shadow .18s ease, transform .18s ease, border-color .18s ease; }
.grid-cards .item:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: color-mix(in srgb, var(--primary) 38%, var(--border)); }
.table-wrap { border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.bericht-rahmen { border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.login-card { border-radius: 18px; box-shadow: var(--shadow); }
.alert { border-radius: var(--radius); }

.btn {
    gap: .5rem; font-weight: 500; border-radius: var(--radius); box-shadow: var(--shadow-sm);
    transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .06s ease;
}
.btn:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn-primary {
    background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 90%, #fff), var(--primary));
    box-shadow: 0 1px 2px color-mix(in srgb, var(--primary) 45%, transparent);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger:hover { border-color: var(--danger); }
.btn-ghost { box-shadow: none; }
.btn-ghost:hover { border-color: transparent; }

input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring);
}
textarea {
    width: 100%; padding: .45rem .65rem; font: inherit; color: var(--text);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.chip { transition: background .15s ease; }
.page-head { padding-bottom: .25rem; }

/* ---------- Akkordeon: genau ein Abschnitt offen ---------- */
details.section {
    border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm);
    transition: border-color .2s ease, box-shadow .2s ease;
    scroll-margin-top: calc(var(--topbar-h) + .75rem);
}
details.section[open] { border-color: color-mix(in srgb, var(--primary) 42%, var(--border)); box-shadow: var(--shadow); }
details.section > summary { gap: .75rem; transition: background .15s ease; }
details.section > summary:hover { background: var(--surface-2); }
details.section > summary > :first-child { margin-right: auto; }
details.section[open] > summary {
    background: color-mix(in srgb, var(--primary) 7%, var(--surface));
    border-bottom: 1px solid var(--border);
}
.sum-title { display: inline-flex; align-items: center; gap: .7rem; }
.sum-title .icon {
    box-sizing: content-box; padding: 7px; border-radius: 9px;
    background: color-mix(in srgb, var(--primary) 13%, transparent); color: var(--primary);
}
details.section > summary::after {
    content: ""; width: 18px; height: 18px; flex: none; background: var(--muted);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
    transition: transform .2s ease, background .2s ease;
}
details.section[open] > summary::after { transform: rotate(180deg); background: var(--primary); }
details.section[open] > .section-body { padding-top: 1rem; animation: aufklappen .22s ease; }
@keyframes aufklappen { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

@media (max-width: 900px) {
    .logo-kompakt .logo-mark { width: 26px; height: 26px; }
}
@media (prefers-reduced-motion: reduce) {
    details.section[open] > .section-body { animation: none; }
    .item, .btn, .nav-link, .nav-link .icon { transition: none; }
}

/* ---------- Schlagbild und Vorschau ---------- */
.thumb { width: 48px; height: 48px; flex: none; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); box-shadow: var(--shadow-sm); background: var(--surface-2); }
.mit-bild { display: inline-flex; align-items: center; gap: .65rem; min-width: 0; }
.mit-bild span { overflow-wrap: anywhere; }
td .thumb { margin-right: .65rem; vertical-align: middle; }
.schlagbild-rahmen { margin: 0 0 1rem; }
/* Bild oben in der Anbau-Karte: so groß, dass Feldblock und Schlaggrenze erkennbar sind */
.karten-bild { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; margin: 0 0 .75rem; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); }
.schlagbild {
    display: block; width: 100%; max-height: 340px; object-fit: contain; background: var(--surface-2); cursor: zoom-in;
    border-radius: var(--radius-lg); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
    transition: max-height .25s ease;
}
.schlagbild.gross { max-height: 80vh; object-fit: contain; background: var(--surface-2); cursor: zoom-out; }
.fieldset .schlagbild { margin-bottom: .5rem; }
input[type="file"] { width: 100%; font: inherit; color: var(--text); }
@media (prefers-reduced-motion: reduce) { .schlagbild { transition: none; } }

/* ---------- Nähe-Erkennung ---------- */
.card.nahe { display: flex; flex-direction: column; gap: .5rem; border-color: color-mix(in srgb, var(--primary) 30%, var(--border)); }
.card.nahe .btn { margin: 0; }

/* ---------- Startseite: "Heute auf dem Betrieb" ---------- */
.heute-titel { margin: 1.25rem 0 .75rem; }
.heute-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 1rem; align-items: start; }
.heute-karte { display: flex; flex-direction: column; gap: .75rem; }
.heute-karte h2 { margin: 0; display: flex; align-items: center; gap: .5rem; font-size: 1.05rem; }
.heute-bild { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; margin: 0 0 .6rem; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); }
.heute-schlag { display: flex; flex-direction: column; }
.heute-aktionen { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.heute-aktionen .btn { flex: 1 1 auto; min-height: 44px; justify-content: center; }
.heute-weitere { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.heute-wahl { margin: .25rem 0 0; }
.heute-ok { margin: 0; display: flex; align-items: center; gap: .5rem; color: var(--primary); }
.frist { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.frist-gelb { border-color: color-mix(in srgb, #d9a400 55%, var(--border)); }
.frist-rot { border-color: color-mix(in srgb, #d64545 60%, var(--border)); }
.offen-liste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.offen-liste a { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .65rem .75rem; min-height: 44px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); color: inherit; text-decoration: none; }
.offen-liste a:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.heute-weitere .chip { min-height: 40px; padding-inline: .85rem; cursor: pointer; }

/* ---------- Schläge: Umschalter Liste / Kacheln ---------- */
.ansicht-wahl { display: inline-flex; gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.ansicht-wahl .btn { border: 0; border-radius: 0; min-height: 40px; background: transparent; }
.ansicht-wahl .btn.aktiv { background: color-mix(in srgb, var(--primary) 22%, var(--surface)); font-weight: 600; }
.kachel-inaktiv { opacity: .65; }

/* ---------- Bearbeiten-Fenster (Dialog.razor) ---------- */
body.dialog-offen { overflow: hidden; }
.dialog-hintergrund {
    position: fixed; inset: 0; z-index: 1000; display: flex; align-items: flex-start; justify-content: center;
    padding: 4vh 1rem; background: rgb(0 0 0 / .55); overflow-y: auto; overscroll-behavior: contain;
}
.dialog {
    width: min(720px, 100%); background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: 0 18px 50px rgb(0 0 0 / .45);
    outline: none; animation: dialog-ein .16s ease;
}
.dialog-kopf {
    position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    padding: .85rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.dialog-kopf h2 { margin: 0; font-size: 1.1rem; overflow-wrap: anywhere; }
.dialog-zu { flex: none; width: 44px; height: 44px; border: 0; border-radius: var(--radius); background: transparent; color: inherit; font-size: 1.7rem; line-height: 1; cursor: pointer; }
.dialog-zu:hover { background: var(--surface-2); }
.dialog-inhalt { padding: 1rem; }
@keyframes dialog-ein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (max-width: 640px) {
    .dialog-hintergrund { padding: 0; }
    .dialog { min-height: 100%; border: 0; border-radius: 0; box-shadow: none; }
    .dialog-kopf { border-radius: 0; }
}
@media (prefers-reduced-motion: reduce) { .dialog { animation: none; } }

/* ---------- Kennzahlen-Liste (Betrieb, E-Mail) ---------- */
.daten { display: grid; grid-template-columns: minmax(130px, 220px) 1fr; gap: .45rem 1rem; margin: 0 0 1rem; }
.daten dt { color: var(--muted); }
.daten dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 640px) { .daten { grid-template-columns: 1fr; gap: 0; } .daten dd { margin-bottom: .6rem; } }

/* ---------- Zweiter Faktor ---------- */
.schritte { padding-left: 1.2rem; display: flex; flex-direction: column; gap: 1rem; }
.qr { width: min(240px, 100%); margin: .75rem 0; padding: .5rem; background: #fff; border-radius: var(--radius); line-height: 0; }
.qr svg { width: 100%; height: auto; display: block; }
.schluessel { font-family: ui-monospace, Consolas, monospace; font-size: 1.1rem; letter-spacing: .06em; overflow-wrap: anywhere; user-select: all; }
.codes { list-style: none; margin: .75rem 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; font-family: ui-monospace, Consolas, monospace; }
.codes li { padding: .5rem .75rem; border: 1px dashed var(--border); border-radius: var(--radius); background: var(--surface-2); text-align: center; user-select: all; }
@media print { body * { visibility: hidden; } .codes, .codes * { visibility: visible; } .codes { position: absolute; inset: 0 auto auto 0; } }
.zf-alternativen { display: flex; flex-direction: column; gap: .5rem; margin-top: 1rem; }
.zf-alternativen form { margin: 0; }

/* ---------- Suchauswahl (Feld mit Suche und Liste darunter) ---------- */
.suchauswahl { position: relative; }
.suchauswahl-feld { width: 100%; padding-right: 2.6rem; }
.suchauswahl-leeren { position: absolute; top: 0; right: 0; width: 2.75rem; height: 2.75rem; border: 0; background: transparent; color: var(--muted); font-size: 1.4rem; line-height: 1; cursor: pointer; }
.suchauswahl-leeren:hover { color: var(--text); }
.suchauswahl-liste { list-style: none; margin: .35rem 0 0; padding: .25rem; max-height: 17rem; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); overscroll-behavior: contain; }
.suchauswahl-liste li { display: flex; flex-direction: column; gap: .05rem; padding: .55rem .7rem; min-height: 44px; justify-content: center; border-radius: calc(var(--radius) - 2px); cursor: pointer; overflow-wrap: anywhere; }
.suchauswahl-liste li:hover, .suchauswahl-liste li.aktiv { background: color-mix(in srgb, var(--primary) 18%, var(--surface-2)); }
.suchauswahl-liste li[aria-selected="true"] { font-weight: 600; }
.suchauswahl-liste li.leer { cursor: default; color: var(--muted); font-size: .9rem; min-height: 0; }
.suchauswahl-liste li.leer:hover { background: transparent; }
