@font-face {
    font-family: "Werklplan Sans";
    src: url("/fonts/DejaVuSans.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Werklplan Sans";
    src: url("/fonts/DejaVuSans-Bold.ttf") format("truetype");
    font-weight: 600 900;
    font-style: normal;
    font-display: swap;
}

:root {
    --ink: #172620;
    --muted: #607068;
    --primary: #176b5b;
    --primary-dark: #105044;
    --primary-soft: #e7f2ee;
    --accent: #c87531;
    --surface: #ffffff;
    --surface-muted: #f7f9f8;
    --surface-hover: #edf3f0;
    --canvas: #f4f7f5;
    --line: #dbe4df;
    --line-strong: #bdcbc5;
    --field: #ffffff;
    --label: #32463e;
    --placeholder: #7b8d85;
    --topbar: rgba(244, 247, 245, .92);
    --topbar-line: rgba(219, 228, 223, .8);
    --on-primary: #ffffff;
    --danger: #b43b3b;
    --warning: #a35f16;
    --success: #177052;
    --neutral-surface: #edf2f0;
    --neutral-text: #475a52;
    --success-surface: #e3f4eb;
    --success-text: #176744;
    --success-line: #b8e0ca;
    --warning-surface: #fff0d9;
    --warning-text: #88500e;
    --warning-line: #ead69a;
    --danger-surface: #fde8e8;
    --danger-text: #922e2e;
    --danger-line: #f2bcbc;
    --account-glow: #e3efe9;
    --legal-text: #344940;
    --code-surface: #edf2f0;
    --code-text: #2f4b40;
    --error-surface: #fff4d6;
    --error-text: #4d3b08;
    --focus-ring: rgba(200, 117, 49, .45);
    --focus-shadow: rgba(23, 107, 91, .13);
    --shadow: 0 10px 34px rgba(23, 38, 32, .08);
    --dialog-shadow: 0 20px 60px rgba(16, 42, 36, .22);
    --radius: 14px;
    --sidebar: 252px;
    color-scheme: light;
    font-family: "Werklplan Sans", "Segoe UI", Arial, sans-serif;
    color: var(--ink);
    background: var(--canvas);
}

html[data-theme="dark"] {
    --ink: #edf5f1;
    --muted: #a9bbb3;
    --primary: #67c7b0;
    --primary-dark: #91d9c8;
    --primary-soft: #1b3b33;
    --accent: #e0924e;
    --surface: #16231f;
    --surface-muted: #1b2a25;
    --surface-hover: #20342d;
    --canvas: #0d1714;
    --line: #31423b;
    --line-strong: #53685f;
    --field: #121f1b;
    --label: #c8d8d1;
    --placeholder: #83968d;
    --topbar: rgba(13, 23, 20, .92);
    --topbar-line: rgba(49, 66, 59, .88);
    --on-primary: #0b211a;
    --danger: #ef8a8a;
    --warning: #f2b562;
    --success: #69c99f;
    --neutral-surface: #26362f;
    --neutral-text: #c1d0ca;
    --success-surface: #153e2f;
    --success-text: #8ee0ba;
    --success-line: #2e6f54;
    --warning-surface: #3d2c14;
    --warning-text: #ffd08a;
    --warning-line: #735222;
    --danger-surface: #432122;
    --danger-text: #ffabab;
    --danger-line: #75383b;
    --account-glow: #173229;
    --legal-text: #c7d7d0;
    --code-surface: #24352e;
    --code-text: #d8e8e1;
    --error-surface: #423814;
    --error-text: #ffe49a;
    --focus-ring: rgba(224, 146, 78, .58);
    --focus-shadow: rgba(103, 199, 176, .2);
    --shadow: 0 12px 36px rgba(0, 0, 0, .28);
    --dialog-shadow: 0 20px 60px rgba(0, 0, 0, .45);
    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--canvas); color: var(--ink); }
body { line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { outline-offset: 3px; }
:focus-visible { outline: 3px solid var(--focus-ring); }
h1[tabindex="-1"]:focus-visible { outline: none; }
h1, h2, h3 { line-height: 1.18; margin-top: 0; }
h1 { font-size: clamp(1.65rem, 3vw, 2.25rem); letter-spacing: -.035em; margin-bottom: .35rem; }
h2 { font-size: 1.25rem; }
p { margin-top: 0; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) 1fr; }
.app-sidebar { background: #102a24; color: white; position: fixed; inset: 0 auto 0 0; width: var(--sidebar); display: flex; flex-direction: column; z-index: 20; }
.app-main { grid-column: 2; min-width: 0; }
.app-topbar { height: 76px; position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem; padding: 0 clamp(1rem, 3vw, 2.4rem); background: var(--topbar); backdrop-filter: blur(12px); border-bottom: 1px solid var(--topbar-line); }
.app-content { max-width: 1480px; margin: 0 auto; padding: 2rem clamp(1rem, 3vw, 2.5rem) 4rem; }
.mobile-menu { display: none; width: 44px; height: 44px; place-items: center; border: 0; border-radius: 9px; background: transparent; color: var(--ink); font-size: 1.35rem; cursor: pointer; }
.tenant-context { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.tenant-context strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eyebrow { color: var(--muted); text-transform: uppercase; font-size: .68rem; letter-spacing: .12em; font-weight: 700; }
.account-chip { display: flex; align-items: center; gap: .65rem; color: var(--ink); font-size: .85rem; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--primary); color: var(--on-primary); font-weight: 800; }

.theme-toggle { width: 44px; height: 44px; flex: 0 0 44px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); cursor: pointer; }
.theme-toggle:hover { background: var(--surface-hover); border-color: var(--line-strong); }
.theme-icon { display: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
html[data-theme="light"] .theme-icon-moon { display: block; }
html[data-theme="dark"] .theme-icon-sun { display: block; }

.brand { padding: 1.25rem 1rem 1.6rem; }
.brand-logo { color: var(--ink); display: inline-flex; gap: .75rem; align-items: center; }
.brand-logo:hover { color: var(--ink); }
.brand-mark { width: 40px; height: 40px; flex: 0 0 auto; display: grid; }
.brand-mark img { width: 40px; height: 40px; grid-area: 1 / 1; }
.brand-mark-inverse { display: none; }
.brand-logo-inverse .brand-mark-default, html[data-theme="dark"] .brand-logo:not(.brand-logo-inverse) .brand-mark-default { display: none; }
.brand-logo-inverse .brand-mark-inverse, html[data-theme="dark"] .brand-logo:not(.brand-logo-inverse) .brand-mark-inverse { display: block; }
.brand-logo strong, .brand-logo small { display: block; }
.brand-logo strong { font-size: 1.12rem; letter-spacing: -.02em; }
.brand-logo small { color: var(--muted); font-size: .69rem; margin-top: .1rem; }
.brand-logo-inverse, .brand-logo-inverse:hover { color: white; }
.brand-logo-inverse small { color: #a9beb5; }
.nav-list { flex: 1; overflow-y: auto; padding: 0 .65rem; }
.nav-heading { display: block; color: #79978a; text-transform: uppercase; letter-spacing: .12em; font-size: .63rem; font-weight: 800; padding: 1rem .75rem .45rem; }
.nav-list a { display: flex; align-items: center; gap: .7rem; min-height: 44px; padding: .55rem .75rem; margin: .12rem 0; border-radius: 10px; color: #d7e5df; font-size: .91rem; }
.nav-list a:hover, .nav-list a.active { background: rgba(255,255,255,.1); color: white; }
.nav-list a.active { box-shadow: inset 3px 0 var(--accent); }
.nav-icon { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 7px; background: rgba(255,255,255,.08); }
.nav-icon svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-footer { padding: 1rem 1.35rem 1.25rem; border-top: 1px solid rgba(255,255,255,.1); display: flex; align-items: center; gap: .7rem 1rem; flex-wrap: wrap; }
.nav-footer a, .link-button { color: #b9cdc4; font-size: .8rem; }
.nav-footer form { display: flex; margin: 0; }
.link-button { background: none; border: 0; padding: 0; cursor: pointer; line-height: inherit; }
.nav-footer .legal-links { width: 100%; padding-top: .65rem; border-top: 1px solid rgba(255,255,255,.08); }

.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.6rem; }
.page-heading p { color: var(--muted); margin-bottom: 0; max-width: 720px; }
.actions { display: flex; gap: .65rem; flex-wrap: wrap; }
.btn { min-height: 44px; border: 1px solid transparent; border-radius: 10px; padding: .55rem 1rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font-weight: 700; transition: background .15s ease, border-color .15s ease; }
.btn-primary { color: var(--on-primary); background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { color: var(--on-primary); background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-secondary { color: var(--ink); background: var(--surface); border-color: var(--line); }
.btn-secondary:hover { color: var(--ink); background: var(--surface-hover); border-color: var(--line-strong); }
.btn-danger { color: var(--on-primary); background: var(--danger); border-color: var(--danger); }
.btn:disabled { cursor: not-allowed; opacity: .55; }
.btn-link { background: transparent; color: var(--primary); padding-inline: .3rem; }
.w-100 { width: 100%; }
.btn-lg { min-height: 48px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.35rem; }
.stat-card, .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-card { padding: 1.15rem 1.25rem; }
.stat-card .label { color: var(--muted); font-size: .78rem; font-weight: 700; }
.stat-card .value { font-size: 1.8rem; font-weight: 850; letter-spacing: -.04em; margin-top: .25rem; }
.stat-card .detail { color: var(--muted); font-size: .75rem; font-weight: 650; margin-top: .15rem; }
.stat-card .currency { font-size: .52em; letter-spacing: 0; }
.stat-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; }
.stat-pair > div + div { border-inline-start: 1px solid var(--line); padding-inline-start: .85rem; }
.stat-amounts { display: grid; gap: .05rem; }
.stat-amounts.multiple .value { font-size: 1.35rem; }
.stat-card-link { display: block; color: inherit; }
.stat-card-link:hover { color: inherit; border-color: var(--primary); }
.dashboard-stats.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat-card.warning .value { color: var(--warning); }
.stat-card.success .value { color: var(--success); }
.dashboard-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 1rem; }
.dashboard-grid > * { min-width: 0; }
.card { padding: 1.25rem; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; }
.card-header h2 { margin: 0; }
.badge { border-radius: 999px; padding: .3rem .65rem; font-size: .72rem; font-weight: 800; }
.badge-success { color: var(--success-text); background: var(--success-surface); border: 1px solid var(--success-line); }
.badge-warning { color: var(--warning-text); background: var(--warning-surface); border: 1px solid var(--warning-line); }
.stack { display: grid; gap: .75rem; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-top: 1px solid var(--line); padding: .8rem 0; }
.list-row:first-child { border-top: 0; }
.list-row strong, .list-row small { display: block; }
.list-row small { color: var(--muted); }
.quick-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: .65rem; }
.quick-actions a { min-height: 80px; border: 1px dashed var(--line-strong); border-radius: 12px; display: flex; flex-direction: column; justify-content: center; padding: .8rem; color: var(--ink); font-weight: 750; }
.quick-actions a span { color: var(--primary); font-size: 1.25rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; background: var(--surface-muted); }
.data-table th, .data-table td { padding: .82rem 1rem; border-bottom: 1px solid var(--line); }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--surface-hover); }
.status { display: inline-flex; border-radius: 999px; padding: .2rem .55rem; font-size: .72rem; font-weight: 750; background: var(--neutral-surface); color: var(--neutral-text); }
.status.good { color: var(--success-text); background: var(--success-surface); }
.status.warn { color: var(--warning-text); background: var(--warning-surface); }
.status.danger { color: var(--danger-text); background: var(--danger-surface); }
.empty-state { text-align: center; padding: 3rem 1.25rem; color: var(--muted); }

.toolbar { display: flex; gap: .7rem; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar .form-control { max-width: 360px; }
.list-section + .list-section { margin-top: 2rem; }
.list-section-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; }
.list-section-heading h2 { margin-bottom: .2rem; }
.list-section-heading p { color: var(--muted); margin-bottom: 0; }
.list-toolbar { display: grid; grid-template-columns: minmax(220px, 1.35fr) minmax(0, 2fr) auto; gap: .75rem; align-items: end; margin-bottom: 1rem; }
.list-search input { width: 100%; height: 43px; }
.list-filters { display: flex; gap: .65rem; flex-wrap: wrap; align-items: end; }
.list-filter { display: flex; flex-direction: column; gap: .25rem; min-width: 150px; }
.list-filter span { color: var(--label); font-size: .7rem; font-weight: 750; }
.list-filter select, .list-filter input { min-height: 43px; }
.list-filter-date { min-width: 145px; }
.list-toolbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: .65rem; white-space: nowrap; }
.list-result-count { color: var(--muted); font-size: .82rem; }
.sort-button { width: 100%; display: inline-flex; align-items: center; gap: .35rem; border: 0; background: transparent; color: inherit; padding: 0; text-align: left; text-transform: inherit; letter-spacing: inherit; font: inherit; font-weight: inherit; cursor: pointer; }
.sort-button:hover { color: var(--primary); }
.list-pager { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: .8rem; color: var(--muted); font-size: .82rem; }
.list-pager > div { display: flex; align-items: center; gap: .65rem; }
.list-pager .btn { min-height: 38px; padding: .4rem .75rem; }
.list-pager .btn:disabled { cursor: not-allowed; opacity: .5; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.form-field.full {
    grid-column: 1 / -1;
}

.form-field label,
.form-label {
    color: var(--label);
    font-size: .78rem;
    font-weight: 750;
}

.form-submit {
    margin-top: 1rem;
}

.form-control,
.form-select,
input:not([type]),
input[type="text"],
input[type="search"],
input[type="email"],
input[type="url"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
select,
textarea {
    width: 100%;
    min-height: 43px;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    background: var(--field);
    padding: .58rem .72rem;
    color: var(--ink);
}

textarea {
    min-height: 110px;
    resize: vertical;
}

input[type="file"] {
    width: 100%;
    min-height: 43px;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    background: var(--field);
    padding: .3rem;
    color: var(--ink);
}

input[type="file"]::file-selector-button {
    min-height: 35px;
    margin-right: .75rem;
    border: 0;
    border-radius: 7px;
    padding: .4rem .75rem;
    background: var(--primary-soft);
    color: var(--ink);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

input[type="file"]::file-selector-button:hover {
    background: var(--surface-hover);
}

.form-control:focus,
input:not([type]):focus,
input[type="text"]:focus,
input[type="search"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus,
input[type="file"]:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--focus-shadow);
    outline: none;
}

.validation-message,
.text-danger {
    color: var(--danger);
    font-size: .78rem;
}

.valid.modified:not([type="checkbox"]) {
    border-color: var(--success);
}

.invalid {
    border-color: var(--danger) !important;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: .45rem;
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}
.alert { border-radius: 10px; padding: .8rem 1rem; margin-bottom: 1rem; border: 1px solid var(--line); background: var(--surface); }
.alert-danger { color: var(--danger-text); background: var(--danger-surface); border-color: var(--danger-line); }
.alert-success { color: var(--success-text); background: var(--success-surface); border-color: var(--success-line); }
.operation-feedback { position: fixed; z-index: 1080; top: calc(76px + 1rem); right: clamp(1rem, 3vw, 2.5rem); width: min(34rem, calc(100vw - var(--sidebar) - 2rem)); display: grid; gap: .75rem; pointer-events: none; }
.operation-feedback .alert { margin: 0; overflow-wrap: anywhere; box-shadow: var(--dialog-shadow); pointer-events: auto; }

.lookup-picker { position: relative; }
.lookup-picker-input { position: relative; }
.lookup-picker-input input { padding-right: 2.8rem; }
.lookup-picker-clear { position: absolute; right: .35rem; top: .35rem; width: 32px; height: 32px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 1.25rem; cursor: pointer; }
.lookup-picker-clear:hover, .lookup-picker-clear:focus-visible { color: var(--ink); background: var(--surface-hover); outline: 2px solid var(--primary); outline-offset: 1px; }
.lookup-picker-results { position: absolute; z-index: 30; top: calc(100% + .35rem); left: 0; right: 0; max-height: 320px; overflow-y: auto; padding: .35rem; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); box-shadow: var(--dialog-shadow); }
.lookup-picker-option { width: 100%; display: grid; gap: .18rem; padding: .7rem .75rem; border: 0; border-radius: 7px; background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.lookup-picker-option span, .lookup-picker-selection span { color: var(--muted); font-size: .78rem; }
.lookup-picker-option:hover, .lookup-picker-option.active, .lookup-picker-option:focus-visible { background: var(--primary-soft); outline: 2px solid var(--primary); outline-offset: -2px; }
.lookup-picker-hint { padding: .8rem; color: var(--muted); font-size: .84rem; }
.lookup-picker-selection { display: flex; gap: .35rem 1rem; flex-wrap: wrap; margin-top: .45rem; padding: .6rem .75rem; border-radius: 8px; background: var(--surface-muted); }
.checkbox-row { flex-direction: row; align-items: center; gap: .6rem; color: var(--ink); font-size: .9rem; font-weight: 650; }
.maintenance-plan-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.maintenance-plan-meta div { display: grid; gap: .2rem; }
.maintenance-plan-meta span { color: var(--muted); font-size: .78rem; }
.document-summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.document-summary-grid .card { min-width: 0; }
.document-links { margin: .45rem 0 0; padding-left: 1.25rem; }
.document-links li + li { margin-top: .3rem; }
.conversion-card { margin-top: 1rem; background: linear-gradient(135deg, var(--surface), var(--primary-soft)); }
.line-editor { padding: 1rem 0 1.2rem; border-top: 1px solid var(--line); }
.line-editor:first-of-type { border-top: 0; }
.line-editor .actions { margin-top: .75rem; }
.totals-card { margin-top: 1rem; display: flex; justify-content: flex-end; gap: 1rem 2rem; flex-wrap: wrap; }
.totals-card span { display: grid; gap: .2rem; color: var(--muted); }
.totals-card strong { color: var(--ink); font-size: 1.05rem; }

.account-layout { min-height: 100vh; padding: clamp(1.25rem, 4vw, 3rem); background: radial-gradient(circle at top left, var(--account-glow) 0, var(--canvas) 42%); }
.account-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 2rem; }
.account-brand { display: inline-flex; align-items: center; gap: .7rem; color: var(--ink); margin-bottom: 2rem; }
.account-brand small { display: block; color: var(--muted); font-size: .7rem; }
.account-content { width: min(100%, 940px); margin-inline: auto; }
.account-footer { width: min(100%, 940px); margin: 2.5rem auto 0; padding-top: 1rem; border-top: 1px solid var(--line); }
.auth-shell, body:has(form[formname="login"]) .app-content { max-width: 520px; }
.row { display: grid; gap: 1rem; }
.col-lg-6, .col-lg-9, .col-lg-4, .col-lg-3 { min-width: 0; }
.mb-3 { margin-bottom: 1rem; }
.mt-2 { margin-top: .5rem; }
.mx-auto { margin-inline: auto; }
.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.text-secondary { color: var(--muted); }
.form-floating { position: relative; }
.form-floating label { display: block; margin-bottom: .3rem; }
input::placeholder, textarea::placeholder { color: var(--placeholder); opacity: 1; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.2rem 0; }

#blazor-error-ui { color: var(--error-text); background: var(--error-surface); bottom: 0; box-shadow: 0 -1px 4px rgba(0,0,0,.2); box-sizing: border-box; display: none; left: 0; padding: .75rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .4rem; border: 0; background: none; font-size: 1.25rem; }
.blazor-error-boundary { background: var(--danger); padding: 1rem; color: var(--on-primary); border-radius: 10px; }
.blazor-error-boundary::after { content: "Ein unerwarteter Fehler ist aufgetreten."; }

.public-shell { min-height: 100vh; display: flex; flex-direction: column; }
.public-header { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem clamp(1rem, 4vw, 3.5rem); background: var(--topbar); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.public-actions { display: flex; align-items: center; gap: .65rem; }
.public-main { width: min(100% - 2rem, 1120px); margin-inline: auto; flex: 1; padding: clamp(2rem, 5vw, 4.5rem) 0; }
.public-footer { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 1rem 2rem; padding: 1.5rem clamp(1rem, 4vw, 3.5rem); background: #102a24; color: #c7d8d1; }
.public-footer .brand-logo, .public-footer .brand-logo:hover { color: white; }
.public-footer .legal-links { justify-content: flex-end; }
.public-footer .legal-links a { color: #d7e5df; }
.public-footer small { grid-column: 1 / -1; color: #9fb6ac; }
.legal-links { display: flex; flex-wrap: wrap; gap: .45rem 1rem; }
.legal-links a { font-size: .79rem; }

.home-hero { max-width: 820px; margin: 3vh auto; padding: clamp(1.5rem,5vw,4rem); background: radial-gradient(circle at top right, var(--primary-soft), var(--surface) 58%); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
.home-hero h1 { font-size: clamp(2.2rem,7vw,4.7rem); margin-top: .7rem; }
.home-hero p { font-size: 1.12rem; color: var(--muted); max-width: 640px; }

.legal-page { max-width: 860px; margin-inline: auto; }
.legal-heading { padding-bottom: 1.5rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--line); }
.legal-heading h1 { font-size: clamp(1.75rem, 5vw, 3.3rem); margin-top: .65rem; overflow-wrap: anywhere; hyphens: auto; }
.legal-heading p { color: var(--muted); font-size: 1.05rem; max-width: 760px; }
.legal-page section { margin-block: 2rem; }
.legal-page h2 { margin-bottom: .75rem; }
.legal-page h3 { font-size: 1.02rem; margin: 1.4rem 0 .45rem; }
.legal-page p, .legal-page li, .legal-facts dd { color: var(--legal-text); }
.legal-page li + li { margin-top: .35rem; }
.legal-facts { display: grid; grid-template-columns: minmax(180px, .55fr) 1fr; gap: .7rem 1.25rem; }
.legal-facts dt { font-weight: 750; color: var(--ink); }
.legal-facts dd { margin: 0; }
.legal-version { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--line); color: var(--muted) !important; font-size: .82rem; }
.legal-table th:nth-child(n), .legal-table td:nth-child(n) { display: table-cell; }
.settings-note { margin: 1rem 0 0; color: var(--muted); font-size: .88rem; }

.email-settings-form { display: grid; gap: 1.25rem; }
.email-template-heading { margin: .5rem 0 0; }
.email-template-card { padding: 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); display: grid; gap: .8rem; }
.email-template-card h3 { margin: 0; }
.email-template-card small { color: var(--muted); }
.email-test-card { margin-top: 1rem; display: grid; gap: .8rem; }
.email-text-preview { margin: .75rem 0 0; padding: 1rem; max-height: 360px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid var(--line); border-radius: 10px; background: var(--background); color: var(--ink); font: inherit; line-height: 1.5; }
.email-dialog-backdrop { position: fixed; z-index: 200; inset: 0; display: grid; place-items: center; padding: 1rem; background: rgba(9, 28, 24, .66); }
.email-dialog { width: min(760px, 100%); max-height: calc(100vh - 2rem); overflow: auto; padding: 1.25rem; display: grid; gap: 1rem; border: 1px solid var(--line-strong); border-radius: 16px; background: var(--surface); color: var(--ink); box-shadow: var(--dialog-shadow); }
.email-dialog:focus { outline: 3px solid var(--focus); outline-offset: 3px; }
.dialog-close { width: 2.25rem; height: 2.25rem; border: 0; border-radius: 50%; background: var(--surface-soft); color: var(--ink); font-size: 1.5rem; cursor: pointer; }
.dialog-close:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.email-attachment-summary { display: flex; gap: .75rem; align-items: center; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.email-attachment-summary > span:last-child { display: grid; gap: .2rem; }
.email-attachment-summary small { color: var(--muted); }
.email-dialog-actions { justify-content: flex-end; }
.email-history-card { margin-top: 1rem; }
.email-history-row { align-items: center; }
.email-history-detail { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.email-history-detail dl { display: grid; grid-template-columns: minmax(80px, auto) 1fr; gap: .4rem 1rem; }
.email-history-detail dt { font-weight: 750; }
.email-history-detail dd { margin: 0; overflow-wrap: anywhere; }

.document-settings-nav { display: flex; flex-wrap: wrap; gap: .55rem; margin: 0 0 1rem; }
.document-branding-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, .65fr); gap: 1.25rem; align-items: stretch; }
.document-brand-preview { min-height: 150px; padding: 1.25rem; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-end; gap: 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--background); white-space: pre-line; text-align: right; }
.document-brand-preview img { max-width: 180px; max-height: 78px; object-fit: contain; }
.document-footer-preview { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin: 1rem 0 1.25rem; padding: 1rem; border-block: 1px solid var(--line); color: var(--muted); font-size: .78rem; }
.document-footer-preview > div { display: flex; flex-direction: column; gap: .25rem; min-width: 0; overflow-wrap: anywhere; }
.document-footer-preview span:empty { display: none; }
.document-type-settings { margin-bottom: 1rem; }
.document-template-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.document-template-manager { display: grid; gap: 1rem; }
.document-template-edit, .document-template-new { display: grid; gap: .75rem; padding: 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.document-template-edit + .document-template-edit { margin-top: .15rem; }
.document-template-new h3 { margin: 0; }
.document-text-picker small { color: var(--muted); }

.consent-panel { position: fixed; z-index: 100; right: 1rem; bottom: 1rem; width: min(680px, calc(100% - 2rem)); padding: 1.2rem; display: grid; grid-template-columns: 1fr auto; gap: 1rem 1.5rem; align-items: end; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 16px; box-shadow: var(--dialog-shadow); }
.consent-panel[hidden] { display: none; }
.consent-panel h2 { margin: .35rem 0 .5rem; font-size: 1.2rem; }
.consent-panel p { margin-bottom: .45rem; color: var(--muted); font-size: .9rem; }
.consent-panel code { overflow-wrap: anywhere; }
.consent-actions { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: flex-end; }

code { padding: .08rem .28rem; border-radius: 5px; background: var(--code-surface); color: var(--code-text); font-size: .9em; }

@media (max-width: 1050px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-stats.three-columns { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
    .list-toolbar { grid-template-columns: 1fr; }
    .list-toolbar-actions { justify-content: space-between; }
}

@media (max-width: 760px) {
    .app-shell { display: block; }
    .app-sidebar { position: static; width: 100%; min-height: auto; }
    .brand { padding-bottom: .75rem; }
    .nav-list { display: none; gap: .25rem; overflow-x: auto; padding-bottom: .65rem; }
    .navigation-open .nav-list { display: flex; }
    .nav-list .nav-heading, .nav-footer { display: none; }
    .navigation-open .nav-footer { display: flex; }
    .nav-list a { flex: 0 0 auto; }
    .app-main { width: 100%; }
    .app-topbar { height: 64px; }
    .mobile-menu { display: grid; }
    .account-chip span:last-child { display: none; }
    .app-topbar { gap: .65rem; }
    .operation-feedback { top: calc(64px + .75rem); right: .75rem; left: .75rem; width: auto; }
    .stats-grid, .form-grid { grid-template-columns: 1fr; }
    .dashboard-stats.three-columns { grid-template-columns: 1fr; }
    .document-summary-grid, .maintenance-plan-meta { grid-template-columns: 1fr; }
    .form-field.full { grid-column: auto; }
    .page-heading { flex-direction: column; }
    .actions, .actions .btn { width: 100%; }
    .quick-actions { grid-template-columns: 1fr; }
    .data-table { min-width: 720px; }
    .list-filters, .list-filter { width: 100%; }
    .list-filter { min-width: 0; }
    .list-toolbar-actions { align-items: stretch; flex-direction: column; }
    .list-toolbar-actions .btn { width: 100%; }
    .list-pager { align-items: stretch; flex-direction: column; }
    .list-pager > div { justify-content: space-between; }
    .public-footer { grid-template-columns: 1fr; }
    .public-footer .legal-links { justify-content: flex-start; }
    .public-footer small { grid-column: auto; }
    .legal-facts { grid-template-columns: 1fr; gap: .2rem; }
    .legal-facts dd { margin-bottom: .75rem; }
    .legal-table { min-width: 660px; }
    .consent-panel { grid-template-columns: 1fr; }
    .consent-actions { justify-content: stretch; }
    .consent-actions .btn { flex: 1 1 170px; }
    .email-dialog { max-height: calc(100vh - 1rem); padding: 1rem; }
    .email-dialog-actions { flex-direction: column-reverse; }
    .email-history-detail dl { grid-template-columns: 1fr; gap: .15rem; }
    .email-history-detail dd { margin-bottom: .55rem; }
    .document-settings-nav { display: grid; grid-template-columns: 1fr; }
    .document-branding-grid, .document-template-grid, .document-footer-preview { grid-template-columns: 1fr; }
    .document-footer-heading { align-items: stretch; flex-direction: column; }
    .document-footer-heading > .btn { width: 100%; white-space: normal; }
    .document-footer-preview > div + div { padding-top: .65rem; border-top: 1px solid var(--line); }
}
