:root {
    --bg: #eef2f5;
    --panel: #ffffff;
    --panel-soft: #f8fafb;
    --ink: #15222d;
    --muted: #63717d;
    --line: #d9e1e7;
    --line-strong: #c7d1d9;
    --accent: #08715c;
    --accent-strong: #045844;
    --accent-soft: #e4f4ef;
    --accent-faint: #f2faf7;
    --danger: #a33232;
    --danger-soft: #fff1f1;
    --warning: #7f5600;
    --warning-soft: #fff8df;
    --success: #176a43;
    --shadow-sm: 0 8px 24px rgba(31, 48, 61, .07);
    --shadow-lg: 0 24px 70px rgba(31, 48, 61, .13);
    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 24px;
    color: var(--ink);
    background: var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-synthesis: none;
}
* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body { min-height: 100vh; margin: 0; color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
img, svg { max-width: 100%; }
address { color: var(--muted); font-style: normal; line-height: 1.7; }
code { padding: .12rem .35rem; border-radius: 6px; color: #33424e; background: #edf2f5; font-size: .9em; }

h1, h2, h3 { color: var(--ink); letter-spacing: -.025em; }
h1 { margin: 8px 0 12px; font-size: clamp(2rem, 4vw, 2.85rem); line-height: 1.08; }
h2 { margin: 0 0 8px; font-size: 1.25rem; }
h3 { margin: 0 0 6px; }
p { color: var(--muted); line-height: 1.65; }
small, .muted { color: var(--muted); }
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; font-weight: 850; }
.lead { margin: 0 0 26px; font-size: 1.02rem; }
.page-intro { max-width: 760px; margin: 8px 0 0; }

.panel { background: var(--panel); border: 1px solid rgba(210, 220, 227, .92); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: var(--radius-sm); padding: 9px 15px; cursor: pointer; font-weight: 780; transition: transform .15s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-strong)); box-shadow: 0 7px 18px rgba(8, 113, 92, .19); }
.button.primary:hover { color: #fff; box-shadow: 0 10px 24px rgba(8, 113, 92, .25); }
.button.ghost { color: var(--ink); background: #fff; border-color: var(--line); }
.button.ghost:hover { border-color: var(--line-strong); background: var(--panel-soft); }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.button.wide { width: 100%; }
.small-button { min-height: 35px; padding: 6px 10px; font-size: .82rem; }

.alert { margin: 0 0 20px; padding: 14px 16px; border-radius: 12px; line-height: 1.55; }
.alert.error { color: var(--danger); background: var(--danger-soft); border: 1px solid #efcaca; }
.alert.success { color: var(--success); background: var(--accent-soft); border: 1px solid #cce8de; }
.alert.warning { color: var(--warning); background: var(--warning-soft); border: 1px solid #ebdda8; }
.alert ul { margin-bottom: 0; }
.security-note { margin-top: 18px; padding: 15px 16px; border-left: 4px solid var(--accent); border-radius: 8px; color: #42515c; background: var(--accent-faint); line-height: 1.6; }

/* Authentication */
.auth-body { background: radial-gradient(circle at 15% 15%, rgba(91, 188, 157, .28), transparent 30%), radial-gradient(circle at 88% 82%, rgba(102, 151, 189, .18), transparent 34%), #edf2f4; }
.auth-shell { min-height: calc(100vh - 54px); display: grid; place-items: center; padding: 36px 18px; }
.auth-layout { width: min(100%, 980px); display: grid; grid-template-columns: 1.15fr .85fr; overflow: hidden; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.auth-intro { position: relative; min-height: 560px; display: flex; flex-direction: column; justify-content: center; padding: clamp(34px, 6vw, 72px); color: #fff; background: linear-gradient(145deg, #075a4a 0%, #0a8069 58%, #0a685a 100%); }
.auth-intro::after { content: ""; position: absolute; inset: auto -90px -120px auto; width: 280px; height: 280px; border: 1px solid rgba(255,255,255,.18); border-radius: 50%; box-shadow: 0 0 0 48px rgba(255,255,255,.035), 0 0 0 96px rgba(255,255,255,.025); }
.auth-intro .eyebrow { color: #bdebdc; }
.auth-intro h1 { max-width: 590px; color: #fff; }
.auth-intro p { max-width: 560px; color: rgba(255,255,255,.78); }
.brand-mark { width: 54px; height: 54px; display: grid; place-items: center; flex: 0 0 auto; margin-bottom: 24px; border-radius: 15px; color: #fff; background: var(--accent); box-shadow: 0 12px 30px rgba(0,0,0,.15); font-size: 1.65rem; font-weight: 900; }
.auth-intro .brand-mark { color: var(--accent-strong); background: #fff; }
.brand-mark.small { width: 38px; height: 38px; margin: 0; border-radius: 11px; font-size: 1.1rem; }
.security-list { position: relative; z-index: 1; display: grid; gap: 12px; margin: 24px 0 0; padding: 0; list-style: none; }
.security-list li { display: flex; gap: 10px; align-items: center; color: rgba(255,255,255,.9); }
.security-list li::before { content: "✓"; width: 23px; height: 23px; display: grid; place-items: center; border-radius: 50%; color: #075a4a; background: #d9f4eb; font-size: .78rem; font-weight: 900; }
.auth-form-column { display: flex; flex-direction: column; justify-content: center; padding: clamp(32px, 5vw, 58px); background: #fff; }
.auth-form-column h2 { margin-top: 8px; font-size: 2rem; }
.auth-help { margin: 20px 0 0; font-size: .82rem; text-align: center; }
.auth-footer { min-height: 54px; display: flex; align-items: center; justify-content: center; gap: 24px; padding: 12px 18px; color: var(--muted); font-size: .88rem; }

/* Forms */
.stack { display: grid; gap: 18px; }
.form-grid, .form-sections { display: grid; gap: 22px; }
fieldset { display: grid; gap: 16px; margin: 0; padding: 22px; border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(180deg, #fff, #fcfdfd); }
legend { padding: 0 8px; color: #273641; font-weight: 850; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 14px; }
.grid-2-equal { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.span-2 { grid-column: span 2; }
.span-4 { grid-column: span 4; }
label { display: grid; align-content: start; gap: 7px; color: #34434e; font-size: .87rem; font-weight: 760; }
label small { line-height: 1.45; font-weight: 450; }
input, select, textarea { width: 100%; min-height: 46px; border: 1px solid #c9d3db; border-radius: 10px; padding: 10px 12px; color: var(--ink); background: #fff; transition: border-color .15s ease, box-shadow .15s ease, background .15s ease; }
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input:hover, select:hover, textarea:hover { border-color: #aebbc5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 4px rgba(8, 113, 92, .12); }
input[readonly] { color: #687681; background: #f2f5f7; }
.checkbox { display: flex; align-items: center; gap: 10px; }
.checkbox input { width: 19px; min-height: 19px; margin: 0; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding-top: 2px; }
.hint { margin: 12px 0 0; color: var(--muted); font-size: .82rem; }

/* App shell */
.topbar { position: sticky; top: 0; z-index: 20; min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 24px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); backdrop-filter: blur(14px); }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.brand:hover { color: var(--ink); }
.brand-copy { display: grid; gap: 1px; }
.brand-copy strong { font-size: .96rem; }
.brand-copy small { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .72rem; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.user-name { color: #465560; font-size: .86rem; font-weight: 700; }
.secure-indicator { display: inline-flex; align-items: center; gap: 7px; color: var(--success); font-size: .75rem; font-weight: 760; }
.secure-indicator span { width: 8px; height: 8px; border-radius: 50%; background: #2a9d68; box-shadow: 0 0 0 4px rgba(42,157,104,.12); }
.app-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: calc(100vh - 72px); }
.sidebar-wrap { position: sticky; top: 72px; height: calc(100vh - 72px); display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #fff; }
.sidebar { flex: 1; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; padding: 24px 15px; }
.sidebar a, .nav-disabled { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-radius: 10px; color: #42515c; font-size: .89rem; font-weight: 680; }
.sidebar a:hover { color: var(--accent-strong); background: #f3f7f6; }
.sidebar a.active { color: var(--accent-strong); background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.nav-disabled { color: #9aa5ad; cursor: not-allowed; }
.nav-disabled small { font-size: .64rem; font-weight: 600; }
.nav-label { margin: 19px 12px 5px; color: #8b98a1; font-size: .65rem; font-weight: 850; text-transform: uppercase; letter-spacing: .12em; }
.sidebar-security { display: grid; gap: 5px; margin: 0 15px 18px; padding: 13px; border: 1px solid #d9e9e3; border-radius: 12px; color: #315044; background: var(--accent-faint); }
.sidebar-security strong { font-size: .76rem; }
.sidebar-security span { color: #64756d; font-size: .7rem; line-height: 1.45; }
.main-column { min-width: 0; display: flex; flex-direction: column; }
.content { width: min(100%, 1420px); flex: 1; padding: 36px clamp(20px, 3vw, 42px); }
.app-footer { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 15px clamp(20px, 3vw, 42px); border-top: 1px solid var(--line); color: var(--muted); background: rgba(255,255,255,.55); font-size: .8rem; }
.app-footer nav, .public-footer nav { display: flex; gap: 20px; }
.mobile-navigation { display: none; }

.page-heading, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.page-heading { margin-bottom: 24px; }
.page-heading h1 { margin-bottom: 0; }
.heading-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.workspace-panel { margin-bottom: 22px; padding: 24px; box-shadow: none; }
.narrow-panel { max-width: 880px; }
.section-heading p { margin: 0; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; margin-bottom: 22px; }
.metric-card { position: relative; overflow: hidden; display: grid; gap: 8px; padding: 21px; border: 1px solid var(--line); border-radius: 15px; background: linear-gradient(150deg, #fff 65%, #f3faf7); box-shadow: 0 5px 18px rgba(31,48,61,.04); }
.metric-card::after { content: ""; position: absolute; top: -20px; right: -18px; width: 70px; height: 70px; border-radius: 50%; background: rgba(8,113,92,.06); }
.metric-card span { color: var(--muted); font-size: .84rem; font-weight: 730; }
.metric-card strong { font-size: 2.25rem; letter-spacing: -.04em; }
.metric-card small { font-size: .78rem; }
.status-badge { display: inline-flex; align-items: center; white-space: nowrap; padding: 6px 10px; border-radius: 999px; color: var(--accent-strong); background: var(--accent-soft); font-size: .72rem; font-weight: 820; }
.status-badge.neutral { color: #65717a; background: #edf1f3; }
.module-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; margin-top: 22px; }
.module-grid article { padding: 19px; border: 1px solid var(--line); border-radius: 13px; background: linear-gradient(180deg, #fff, #fcfdfd); }
.module-grid p { min-height: 52px; margin: 8px 0 12px; }
.done, .planned { font-size: .75rem; font-weight: 820; }
.done { color: var(--success); }
.planned { color: #91640c; }
.toolbar-form { display: flex; align-items: end; gap: 12px; }
.grow { flex: 1; }
.upload-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 14px; margin-top: 20px; }
.upload-form input[type="file"] { padding: 9px; }
.invoice-items { display: grid; gap: 16px; }
.invoice-item { padding: 18px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel-soft); }
.item-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }

/* Tables */
.table-wrap { margin-top: 18px; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; background: #fff; }
th, td { padding: 14px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: #6a7781; background: #f7f9fa; font-size: .7rem; text-transform: uppercase; letter-spacing: .065em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfcfc; }
td code { white-space: nowrap; }

/* Public legal pages */
.public-body { min-height: 100vh; display: flex; flex-direction: column; background: radial-gradient(circle at 10% 10%, rgba(8,113,92,.10), transparent 30%), var(--bg); }
.public-header { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px max(20px, calc((100vw - 1080px) / 2)); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.92); backdrop-filter: blur(12px); }
.public-header .brand > span:last-child { display: grid; gap: 1px; }
.public-header .brand small { font-size: .72rem; }
.legal-shell { width: min(100%, 1080px); flex: 1; margin: 0 auto; padding: 38px 20px; }
.legal-card { padding: clamp(25px, 5vw, 56px); }
.legal-heading { max-width: 790px; padding-bottom: 26px; border-bottom: 1px solid var(--line); }
.legal-heading p { margin-bottom: 0; }
.legal-section { max-width: 830px; padding: 25px 0; border-bottom: 1px solid var(--line); }
.legal-section:last-child { border-bottom: 0; }
.legal-section p:last-child { margin-bottom: 0; }
.legal-list { display: grid; gap: 8px; margin: 0; }
.legal-list > div { display: grid; grid-template-columns: minmax(150px, .4fr) 1fr; gap: 16px; padding: 8px 0; }
.legal-list dt { color: #4f5d67; font-weight: 760; }
.legal-list dd { margin: 0; color: var(--muted); }
.public-footer { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px max(20px, calc((100vw - 1080px) / 2)); border-top: 1px solid var(--line); color: var(--muted); background: rgba(255,255,255,.72); font-size: .82rem; }

.installer-shell { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; background: radial-gradient(circle at top right, #d9efe8, transparent 35%), var(--bg); }
.installer-panel { width: min(100%, 760px); padding: 38px; }

@media (max-width: 1050px) {
    .metric-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .span-4 { grid-column: span 2; }
    .app-layout { grid-template-columns: 220px minmax(0,1fr); }
}

@media (max-width: 850px) {
    .auth-layout { grid-template-columns: 1fr; }
    .auth-intro { min-height: auto; padding: 38px; }
    .security-list { grid-template-columns: 1fr; }
    .sidebar-wrap { display: none; }
    .app-layout { grid-template-columns: 1fr; }
    .mobile-navigation { display: block; position: sticky; top: 72px; z-index: 15; border-bottom: 1px solid var(--line); background: #fff; }
    .mobile-navigation summary { padding: 13px 20px; color: #3d4c57; cursor: pointer; font-weight: 760; list-style: none; }
    .mobile-navigation summary::-webkit-details-marker { display: none; }
    .mobile-navigation summary::after { content: "+"; float: right; color: var(--accent); }
    .mobile-navigation[open] summary::after { content: "−"; }
    .mobile-navigation nav { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; padding: 0 16px 16px; }
    .mobile-navigation a { padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; color: #42515c; }
    .mobile-navigation a.active { color: var(--accent-strong); background: var(--accent-soft); border-color: #c8e5db; }
    .content { padding-top: 26px; }
}

@media (max-width: 650px) {
    .topbar { min-height: 66px; padding: 0 14px; }
    .app-layout { min-height: calc(100vh - 66px); }
    .mobile-navigation { top: 66px; }
    .brand-copy small, .secure-indicator, .user-name { display: none; }
    .topbar-actions { gap: 8px; }
    .topbar .button { min-height: 38px; padding: 7px 10px; }
    .auth-shell { padding: 18px 12px; }
    .auth-layout { border-radius: 18px; }
    .auth-intro, .auth-form-column { padding: 28px 24px; }
    .auth-intro h1 { font-size: 2rem; }
    .security-list { display: none; }
    .grid-2, .grid-2-equal, .grid-3, .grid-4, .metric-grid, .module-grid { grid-template-columns: 1fr; }
    .span-2, .span-4 { grid-column: span 1; }
    .content { padding: 22px 14px; }
    .page-heading, .section-heading { align-items: flex-start; flex-direction: column; }
    .heading-actions { width: 100%; }
    .heading-actions .button { flex: 1; }
    .workspace-panel { padding: 18px; }
    fieldset { padding: 17px; }
    .toolbar-form, .upload-form { display: grid; grid-template-columns: 1fr; }
    .form-actions .button { width: 100%; }
    .app-footer, .public-footer { align-items: flex-start; flex-direction: column; }
    .legal-shell { padding: 22px 12px; }
    .legal-card { padding: 24px 20px; }
    .legal-list > div { grid-template-columns: 1fr; gap: 3px; }
    .public-header { padding: 12px 14px; }
    .public-header .brand small { display: none; }
    .mobile-navigation nav { grid-template-columns: 1fr; }
}
.metric-date { font-size: 1.45rem !important; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.inline-actions form { margin: 0; }

/* Version 0.4.0: Rechnungsfestschreibung und Zahlungen */
.page-actions, .table-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(260px, .7fr); gap: 22px; margin-bottom: 22px; }
.detail-card { padding: 24px; }
.detail-card h2 { margin-top: 0; }
.detail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 26px; margin: 0; }
.detail-list div { min-width: 0; }
.detail-list .span-all { grid-column: 1 / -1; }
.detail-list dt, .totals-list dt { color: var(--muted); font-size: .8rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.detail-list dd, .totals-list dd { margin: 4px 0 0; }
.hash-code { display: block; max-width: 100%; overflow-wrap: anywhere; padding: 8px 10px; }
.totals-list { margin: 0; }
.totals-list div { display: flex; justify-content: space-between; gap: 20px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.totals-list .grand { margin-top: 5px; font-size: 1.08rem; font-weight: 850; }
.totals-list .open { color: var(--accent-strong); font-weight: 850; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 28px; padding: 24px; border-color: #fecaca; background: var(--danger-soft); }
.danger-zone h2 { margin: 0 0 8px; color: var(--danger); }
.danger-zone p { margin: 0; max-width: 760px; }
.button.danger { color: #fff; background: var(--danger); border-color: var(--danger); white-space: nowrap; }
.button.danger:hover { filter: brightness(.94); }
.inline-callout { margin-top: 20px; padding: 16px 18px; border-left: 4px solid var(--accent); border-radius: 10px; background: var(--accent-faint); }
.empty-state { padding: 18px; border: 1px dashed var(--line-strong); border-radius: 12px; color: var(--muted); background: var(--panel-soft); }
.status-finalized { color: #075a4a; background: #d9f4eb; }
.status-partial { color: #8a4b08; background: #fff1d4; }
.status-paid { color: #166534; background: #dcfce7; }
.status-cancelled { color: #991b1b; background: #fee2e2; }
.metric-money { font-size: clamp(1.25rem, 2vw, 1.8rem) !important; }

@media (max-width: 900px) {
    .detail-grid { grid-template-columns: 1fr; }
    .danger-zone { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 620px) {
    .detail-list { grid-template-columns: 1fr; }
    .detail-list .span-all { grid-column: auto; }
    .page-actions { width: 100%; }
    .page-actions .button { flex: 1 1 auto; }
}
.finalize-form { display: grid; gap: 12px; min-width: min(100%, 330px); }
.confirm-check { display: flex; align-items: flex-start; gap: 9px; font-size: .88rem; line-height: 1.4; }
.confirm-check input { width: auto; margin-top: 3px; }
.narrow-panel { max-width: 820px; }
.status-matched { color: #075a4a; background: #d9f4eb; }
.status-reversed { color: #7f1d1d; background: #fee2e2; }

/* Version 0.5.0: Angebote und Aufträge */
.status-accepted { color: #166534; background: #dcfce7; }
.status-rejected { color: #991b1b; background: #fee2e2; }
.status-draft { color: #475569; background: #e2e8f0; }
