:root {
    /* Farben der Anwendung. Nur diese Variablen anpassen – der Rest der
       Anwendung referenziert ausschließlich diese zentrale Stelle. */
    --color-primary: #2b5797;
    --color-primary-light: #3d6fb5;
    --color-accent: #4a8c3f;
    --color-bg: #f4f6f8;
    --color-surface: #ffffff;
    --color-border: #d8dee3;
    --color-text: #1f2933;
    --color-text-muted: #5c6b7a;
    --color-rot: #d64545;
    --color-rot-bg: #fbe5e5;
    --color-gelb: #c98a1c;
    --color-gelb-bg: #fbf0dc;
    --color-gruen: #2f8a4f;
    --color-gruen-bg: #e4f4e9;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }

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

a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Topbar --- */
.topbar {
    background: var(--color-primary);
    color: #fff;
}
.topbar-inner {
    width: 100%; max-width: 2000px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 24px;
    /* Die Leiste war auf 56 px festgenagelt. Die Navigation braucht aber
       zwei Zeilen (77 px) und auf schmalen Bildschirmen drei (117 px) –
       sie stand damit oben und unten ueber den Rand hinaus und wurde
       beschnitten: bei 1440 px um je 10 px, bei 1366 px um je 30 px.
       Auf eine Zeile passte sie erst ab 2560 px Breite, also praktisch
       nie. Jetzt gibt eine Mindesthoehe die gewohnte Optik vor, und die
       Leiste waechst mit, wenn die Navigation umbricht. */
    min-height: 56px;
    padding: 6px clamp(16px,3vw,40px);
}
.brand { color: #fff; font-weight: 600; font-size: 16px; display: flex; align-items: center; gap: 10px; }
.brand-logo { height: 32px; width: 32px; max-height: calc(100% - 8px); flex: 0 0 auto; object-fit: contain; display: block; }
.brand:hover { text-decoration: none; }
.mainnav { display: flex; gap: 4px 2px; flex: 1; flex-wrap: wrap; align-items: center; }
.mainnav a {
    color: #cfe0ec;
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 13.5px;
}
.mainnav a:hover { background: var(--color-primary-light); text-decoration: none; color: #fff; }
.mainnav a.active { background: var(--color-accent); color: #fff; }

/* Zahnrad-Dropdown (Einstellungen) */
.nav-dropdown { position: relative; display: inline-block; }
.nav-zahnrad {
    display: inline-flex; align-items: center; gap: 6px;
    color: #cfe0ec; background: transparent; border: none; cursor: pointer;
    padding: 8px 12px; border-radius: var(--radius);
    font-size: 13.5px; font-family: inherit; line-height: 1.2;
}
.nav-zahnrad:hover { background: var(--color-primary-light); color: #fff; }
.nav-zahnrad.active { background: var(--color-accent); color: #fff; }
.nav-zahnrad .zahnrad-icon { font-size: 15px; }
.nav-zahnrad .zahnrad-caret { font-size: 9px; opacity: .8; transition: transform .15s; }
.nav-dropdown.open .nav-zahnrad .zahnrad-caret { transform: rotate(180deg); }
.nav-dropdown-menu {
    display: none; position: absolute; right: 0; top: calc(100% + 4px);
    background: #fff; min-width: 180px; padding: 6px;
    border-radius: var(--radius); box-shadow: 0 6px 24px rgba(0,0,0,.18);
    z-index: 200;
}
.nav-dropdown.open .nav-dropdown-menu { display: block; }
.nav-dropdown-menu a {
    display: block; color: #33475b; padding: 9px 12px;
    border-radius: var(--radius); font-size: 13.5px; text-decoration: none;
}
.nav-dropdown-menu a:hover { background: #eef2f6; color: var(--color-primary); }
.nav-dropdown-menu a.active { background: var(--color-accent); color: #fff; }
.usermenu { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #cfe0ec; white-space: nowrap; }
.btn-logout { color: #fff; border: 1px solid rgba(255,255,255,0.4); padding: 5px 10px; border-radius: var(--radius); }
.btn-logout:hover { background: rgba(255,255,255,0.15); text-decoration: none; }

/* --- Layout --- */
.content { width: 100%; max-width: 2000px; margin: 0 auto; padding: 24px clamp(16px,3vw,40px) 60px; }
.footer { border-top: 1px solid var(--color-border); margin-top: 40px; }
.footer-inner { width: 100%; max-width: 2000px; margin: 0 auto; padding: 16px clamp(16px,3vw,40px); color: var(--color-text-muted); font-size: 12px; }
.footer-credit { display: block; margin-top: 4px; font-size: 11px; color: #9aa7b3; }
.footer-credit a { color: #9aa7b3; text-decoration: underline; }
.footer-credit a:hover { color: var(--color-primary); }

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 28px 0 12px; }
.subtitle { color: var(--color-text-muted); margin-bottom: 20px; }

.page-header { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }

/* --- Cards / Panels --- */
.panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi-value { font-size: 26px; font-weight: 700; color: var(--color-primary); }
.kpi-label { color: var(--color-text-muted); font-size: 12.5px; margin-top: 2px; }
/* Klickbare KPI-Kacheln (Schnellzugriff) */
a.kpi-card { display: block; text-decoration: none; color: inherit; transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease; }
a.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(30,46,79,0.12); border-color: var(--color-primary-light); text-decoration: none; }
a.kpi-card:hover .kpi-label { color: var(--color-primary); }
a.kpi-card:focus-visible { outline: 2px solid var(--color-primary-light); outline-offset: 2px; }

/* --- Buttons --- */
.btn {
    display: inline-block;
    background: var(--color-accent);
    color: #fff;
    border: none;
    padding: 9px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 500;
}
.btn:hover { background: var(--color-primary-light); text-decoration: none; }
.btn-secondary { background: #fff; color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: #f0f2f4; }
.btn-danger { background: var(--color-rot); }
.btn-danger:hover { background: #b83a3a; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

/* --- Forms --- */
form .form-row { margin-bottom: 14px; }
label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 13px; }
input[type=text], input[type=date], input[type=number], input[type=password],
input[type=email], select, textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 13.5px;
    font-family: inherit;
    background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--color-accent); outline-offset: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 20px; }
.checkbox-group { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.checkbox-group label { display: flex; align-items: center; gap: 6px; font-weight: 400; }
.checkbox-group input { width: auto; }
.help-text { color: var(--color-text-muted); font-size: 12px; margin-top: 3px; }

/* --- Tables --- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--color-border); text-align: left; }
th { background: #eef1f4; font-weight: 600; color: var(--color-text-muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.02em; position: sticky; top: 0; }
tbody tr:hover { background: #f7f9fa; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--color-border); border-radius: var(--radius); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* --- Matrix (Monatserfassung) --- */
.matrix-table th, .matrix-table td { white-space: nowrap; }
.matrix-table input[type=number] {
    width: 64px; padding: 4px 6px; text-align: right; font-size: 13px;
}
/* Mitarbeiter-Spalte klebt links */
.matrix-table .row-label { position: sticky; left: 0; background: #fff; z-index: 2; min-width: 160px; }
.matrix-table th.row-label { background: #eef1f4; z-index: 3; }
.matrix-table .gruppe-row td { background: #e3e9ee; font-weight: 700; color: var(--color-primary); }

/* Kopfzeilen bleiben beim Vertikal-Scrollen oben kleben.
   Zeile 1 (proj-head) bei top:0, Zeile 2 (col-funk) direkt darunter. */
.matrix-table thead th { position: sticky; top: 0; z-index: 4; }
.matrix-table thead tr:nth-child(1) th { height: 33px; box-sizing: border-box; }
.matrix-table thead tr:nth-child(2) th { top: 33px; }

/* Projekt-Kopf: farblich abgesetzt, weiße Trennstreifen */
.matrix-table th.proj-head {
    text-align: center; background: var(--color-primary); color: #fff;
    font-size: 12.5px; font-weight: 700; padding: 7px 6px;
    border-left: 3px solid #fff; border-right: 3px solid #fff;
    white-space: nowrap; text-transform: none; letter-spacing: 0; z-index: 5;
}
.matrix-table th.proj-head.pg-alt { background: var(--color-primary-light); }
.btn-proj-uebernahme {
    display: block; margin: 5px auto 0; padding: 2px 8px;
    font-size: 10.5px; font-weight: 600; font-family: inherit;
    background: rgba(255,255,255,.15); color: #fff;
    border: 1px solid rgba(255,255,255,.45); border-radius: 4px;
    cursor: pointer; white-space: nowrap;
}
.btn-proj-uebernahme:hover { background: rgba(255,255,255,.3); }
/* Erste Funktionsspalte eines Projekts: kräftige Trennlinie links */
.matrix-table td.proj-start, .matrix-table th.proj-start { border-left: 3px solid var(--color-primary); }
/* Getönter Hintergrund für jede zweite Projektgruppe */
.matrix-table td.pg-alt { background: #f2f6fa; }
.matrix-table tbody tr:nth-child(even) td.pg-alt { background: #e9f0f6; }
.matrix-table th.col-funk.pg-alt { background: #dde6ee; color: var(--color-primary); }
.matrix-table th.col-funk { background: #eef1f4; color: var(--color-text-muted);
    font-weight: 600; font-size: 11px; padding: 5px 4px; white-space: nowrap; z-index: 4; }
/* Projekt-Summenzeile */
.matrix-table tr.proj-sum td { background: #eef1f4; font-weight: 700;
    color: var(--color-primary); border-top: 2px solid var(--color-primary); }
/* Summenspalte am Ende */
.matrix-table td.grand-sum, .matrix-table th.grand-sum {
    border-left: 3px solid var(--color-primary); background: #eef7f1; font-weight: 700; }
/* Ecke oben-links: klebt oben UND links */
.matrix-table thead th.row-label { position: sticky; left: 0; top: 0; z-index: 7; }

/* Projekt-Filter über der Erfassungstabelle */
.erf-filterbar { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; flex-wrap: wrap; }
.erf-filterbar label { display: inline; font-weight: 600; font-size: 13px; margin: 0; }
.erf-filterbar select { width: auto; padding: 6px 10px; }
.erf-filterbar #proj-filter { min-width: 260px; font-weight: 600; }
.erf-filterbar label.abt-auswahl { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; }
.erf-filter-info { color: var(--color-text-muted); font-size: 12.5px; }

/* Scroll-Container der Erfassung: Höhe begrenzt, damit Kopf sichtbar bleibt */
.erf-scroll { overflow: auto; -webkit-overflow-scrolling: touch; max-height: calc(100vh - 300px); min-height: 220px; }

/* --- Ampel / Status --- */
.ampel-rot    { background: var(--color-rot-bg); color: var(--color-rot); font-weight: 700; }
.ampel-gelb   { background: var(--color-gelb-bg); color: var(--color-gelb); font-weight: 700; }
.ampel-gruen  { background: var(--color-gruen-bg); color: var(--color-gruen); font-weight: 600; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-rot { background: var(--color-rot-bg); color: var(--color-rot); }
.badge-gelb { background: var(--color-gelb-bg); color: var(--color-gelb); }
.badge-gruen { background: var(--color-gruen-bg); color: var(--color-gruen); }
.badge-grau { background: #eceff1; color: var(--color-text-muted); }

/* --- Misc --- */
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13.5px; }
.flash-success { background: var(--color-gruen-bg); color: var(--color-gruen); border: 1px solid #bfe3cb; }
.flash-error { background: var(--color-rot-bg); color: var(--color-rot); border: 1px solid #f0bcbc; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.toolbar.wird-geladen { opacity: .6; cursor: progress; }
/* Beschriftete Auswahlfelder in Werkzeugleisten einheitlich: Text links,
   Feld daneben, alle auf einer Linie (seit 15.11.2026 – vorher stand
   „Monate:“ über dem Feld, „Start:“ daneben). */
.toolbar label { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.toolbar label select, .toolbar label input { width: auto; margin: 0; }
.muted { color: var(--color-text-muted); }
.tag { display: inline-block; background: #eef1f4; border-radius: 4px; padding: 2px 8px; font-size: 12px; margin: 2px 3px 2px 0; }

.login-wrap { max-width: 380px; margin: 80px auto; }
.login-wrap .panel { padding: 28px; }
.login-logo { text-align: center; margin-bottom: 16px; font-weight: 700; color: var(--color-primary); font-size: 18px; }

/* ============================================================
   RESPONSIVE DESIGN
   ============================================================ */
@media (min-width: 1600px) {
    .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}
@media (max-width: 1024px) {
    .content { padding: 20px 16px 50px; }
    h1 { font-size: 20px; }
    .kpi-value { font-size: 23px; }
}
@media (max-width: 768px) {
    body { font-size: 13.5px; }
    .topbar-inner { flex-wrap: wrap; height: auto; padding: 8px 16px; gap: 8px 12px; align-items: center; }
    .brand { order: 1; flex: 1 1 auto; }
    .usermenu { order: 2; flex: 0 0 auto; font-size: 12px; margin-left: auto; }
    .mainnav { order: 3; width: 100%; flex-basis: 100%; gap: 4px; }
    .mainnav a { padding: 7px 10px; font-size: 12.5px; }
    .nav-dropdown { margin-left: auto; }
    .content { padding: 16px 12px 50px; }
    h1 { font-size: 18px; }
    h2 { font-size: 15px; margin: 18px 0 8px; }
    .panel { padding: 14px; }
    .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 16px; }
    .kpi-value { font-size: 21px; }
    .kpi-card { padding: 12px 14px; }
    .page-header { align-items: flex-start; }
    .form-grid { grid-template-columns: 1fr; }
    .toolbar .btn { flex: 1; text-align: center; min-width: 120px; }
    .erf-scroll { max-height: calc(100vh - 340px); }
}
@media (max-width: 480px) {
    body { font-size: 13px; }
    .brand { font-size: 15px; }
    .mainnav a { padding: 5px 8px; font-size: 12px; }
    .content { padding: 12px 10px 40px; }
    h1 { font-size: 17px; }
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .kpi-value { font-size: 19px; }
    .panel { padding: 12px; }
    .erf-filterbar { flex-direction: column; align-items: stretch; }
    .erf-filterbar select { min-width: 0; width: 100%; }
}
@media (hover: none) and (pointer: coarse) {
    .matrix-table input[type=number] { min-height: 38px; }
    .mainnav a { padding: 9px 12px; }
    /* Größere Touch-Ziele für zentrale Bedienelemente auf iPad & Co. */
    .btn, .btn-secondary { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
    .nav-zahnrad { min-height: 40px; }
    input[type=text], input[type=number], input[type=month], input[type=password], input[type=email], select {
        min-height: 40px;
    }
    .nav-dropdown-menu a { padding: 12px 14px; }
    .badge { padding: 5px 10px; }
}

@media print {
    .topbar, .footer, .toolbar, .no-print { display: none !important; }
    body { background: #fff; }
}

/* Zeilenweise Bearbeitungssperre */
.matrix-input.zeile-fremd-gesperrt {
    background: #f4e6e6;
    color: #a05a5a;
    cursor: not-allowed;
}
.ma-lock-hinweis {
    display: inline-block;
    margin-left: 6px;
    font-size: 11px;
    color: #c0392b;
    font-weight: 600;
    white-space: nowrap;
}

/* Inline-editierbares E-Mail-Feld in der Benutzerliste */
.email-inline {
    width: 100%; min-width: 160px;
    padding: 6px 8px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    font-size: 13.5px; font-family: inherit;
    color: var(--color-text);
}
.email-inline:hover { border-color: var(--color-border); background: #fff; }
.email-inline:focus { border-color: var(--color-accent); background: #fff; outline: none; }

/* ── Klappbare Auswertungs-Sektionen ────────────────────────── */
.klapp-titel {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    user-select: none;
    -webkit-user-select: none;
}
.klapp-titel:hover { color: var(--color-primary); }
.klapp-titel .klapp-pfeil {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    transition: transform 0.2s ease;
    color: var(--color-text-muted);
}
.klapp-sektion.zu .klapp-titel .klapp-pfeil { transform: rotate(-90deg); }
.klapp-inhalt { overflow: hidden; }
.klapp-sektion.zu .klapp-inhalt { display: none; }
/* dezente Trennlinie unter dem klappbaren Titel, wenn zu */
.klapp-titel .klapp-pfeil svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; }
.klapp-titel-text { flex: 1; }
.klapp-titel-text h2, .klapp-titel-text h3 { margin: 0; }
.klapp-sektion { margin-top: 22px; }
.klapp-sektion:first-of-type { margin-top: 0; }

/* ── Filter-Hinweis (aktiver Zustand-Filter) ────────────────── */
.filter-hinweis {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    background: #EEF4FB;
    border: 1px solid #CBDBF0;
    border-left: 4px solid var(--color-primary);
    border-radius: var(--radius);
    padding: 10px 16px;
    margin-bottom: 14px;
}
.filter-hinweis-text { color: var(--color-text); font-size: 14px; }
.filter-aufheben {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 5px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-primary);
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.12s, border-color 0.12s;
}
.filter-aufheben:hover { background: var(--color-bg); border-color: var(--color-primary-light); text-decoration: none; }

/* Soll-Abgleich über der Erfassungsmatrix (seit 15.10.2026).
   Die beiden Zeilen sitzen im Tabellenkopf, damit sie beim Blättern
   durch lange Mitarbeiterlisten sichtbar bleiben. */
.matrix-table thead tr.soll-zeile th,
.matrix-table thead tr.rest-zeile th {
    font-size: 11px;
    text-align: center;
    padding-top: 3px;
    padding-bottom: 3px;
}
.matrix-table thead tr.soll-zeile th { background: #f3f5f8; color: #35414f; }
.matrix-table thead tr.rest-zeile th { background: #eef1f4; }
.matrix-table thead tr.rest-zeile th.ampel-gruen { background: #e5f4ea; color: #1d6b38; }
.matrix-table thead tr.rest-zeile th.ampel-gelb  { background: #fdf3dd; color: #8a6100; }
.matrix-table thead tr.rest-zeile th.ampel-rot   { background: #fbe6e6; color: #a32020; }

/* ── Dialogfenster ───────────────────────────────────────────────────
   Serverseitig erzeugt: Das Fenster steht schon im HTML, wenn die Seite
   ankommt. Es braucht kein JavaScript und erscheint deshalb auch dann,
   wenn im Browser etwas nicht laedt. */
.wp-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(31, 41, 51, .55);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 6vh 16px 16px;
    overflow-y: auto;
}
.wp-dialog {
    background: #fff; border-radius: 10px; width: 100%; max-width: 640px;
    box-shadow: 0 18px 50px rgba(31, 41, 51, .35);
    overflow: hidden;
}
.wp-dialog-kopf {
    background: var(--color-gelb-bg);
    border-bottom: 1px solid #f0d080;
    padding: 16px 22px;
}
.wp-dialog-kopf h2 {
    margin: 0; font-size: 17px; line-height: 1.4; color: var(--color-gelb);
}
.wp-dialog-inhalt { padding: 18px 22px 4px; line-height: 1.65; }
.wp-dialog-inhalt p { margin: 0 0 14px; }
.wp-dialog-untertitel {
    margin: 4px 0 8px; font-size: 14px; font-weight: 600;
    color: var(--color-text);
}
.wp-dialog-tabelle { width: 100%; border-collapse: collapse; margin: 0 0 14px; }
.wp-dialog-tabelle th, .wp-dialog-tabelle td {
    padding: 6px 10px; border-bottom: 1px solid var(--color-border); font-size: 13.5px;
}
.wp-dialog-tabelle thead th {
    text-align: left; font-size: 12px; letter-spacing: .4px;
    text-transform: uppercase; color: var(--color-text-muted);
}
.wp-dialog-tabelle .num { text-align: right; }
.wp-dialog-fuss {
    display: flex; gap: 10px; align-items: center; justify-content: flex-end;
    flex-wrap: wrap;
    padding: 14px 22px 18px; border-top: 1px solid var(--color-border);
    background: var(--color-bg);
}
@media (max-width: 560px) {
    .wp-dialog-fuss { justify-content: stretch; }
    .wp-dialog-fuss .btn { flex: 1 1 100%; text-align: center; }
}
