/* Open Sans — lokal gehostet (Corporate Design lbm.rlp.de); kein externer Request. */
@font-face {
    font-family: "Open Sans"; font-style: normal; font-weight: 400;
    src: url(../fonts/open-sans-v27-latin-regular.woff2) format("woff2");
}
@font-face {
    font-family: "Open Sans"; font-style: normal; font-weight: 600;
    src: url(../fonts/open-sans-v27-latin-600.woff2) format("woff2");
}
@font-face {
    font-family: "Open Sans"; font-style: normal; font-weight: 700;
    src: url(../fonts/open-sans-v27-latin-700.woff2) format("woff2");
}

:root {
    /* Corporate Design lbm.rlp.de — Tokens siehe Spec E8 */
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-alt: #ededed;
    --text: #2c2c2c;
    --muted: #737373;
    --border: #dee2e6;
    --primary: #3357a5;
    --primary-dark: #2b4a8c;
    --brand: #871d33;
    --ok: #198754;
    --warn: #b26a00;
    --err: #d2000f;
    --radius: 0.15rem;
    --topbar: #d0d0d0;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Open Sans", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.65;
    border-top: 6px solid var(--topbar);
}

main { max-width: 1100px; margin: 1.5rem auto; padding: 0 1rem; }

h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; margin-top: 2rem; }

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

/* Navigation */
.topnav {
    display: flex; align-items: center; gap: 1.25rem;
    background: #fff; color: var(--text);
    padding: 0.6rem 1.25rem;
    border-bottom: 1px solid var(--border);
}
.topnav .brand { font-weight: 700; margin-right: 1rem; color: var(--brand); }
.topnav a { color: var(--primary); font-weight: 600; }
.topnav a:hover { color: var(--primary-dark); text-decoration: none; }
.topnav .logout { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; }
.topnav .username { color: var(--muted); }

button, .button {
    font: inherit; padding: 0.45rem 0.9rem; border: 1px solid var(--border);
    border-radius: var(--radius); background: var(--surface); cursor: pointer;
}
button.primary, .button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { background: var(--primary-dark); }
button.danger { color: var(--err); border-color: var(--err); background: #fff; }
button.linklike { background: none; border: none; color: var(--primary); cursor: pointer; padding: 0; }
button.linklike:hover { color: var(--primary-dark); text-decoration: underline; }

/* Formulare */
form label { display: block; margin: 0.75rem 0 0.25rem; font-weight: 600; }
input[type=text], input[type=password], input[type=date], input[type=time], select {
    width: 100%; max-width: 26rem; padding: 0.45rem 0.6rem;
    border: 1px solid var(--border); border-radius: var(--radius); font: inherit; background: #fff;
}
form .actions { margin-top: 1.25rem; display: flex; gap: 0.75rem; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); margin: 1rem 0; }

/* Login */
.login-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.login-box {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 2rem; width: 24rem; margin: 0;
}
.login-box h1 { margin-top: 0; }
.login-box button { margin-top: 1.25rem; width: 100%; }

/* Karten / KPI-Kacheln */
.cards { display: flex; flex-wrap: wrap; gap: 1rem; margin: 1rem 0; }
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1rem 1.25rem; min-width: 12rem; flex: 1;
}
.card h3 { margin: 0 0 0.5rem; font-size: 0.85rem; text-transform: uppercase; color: var(--muted); }
.card .kpi { font-size: 1.8rem; font-weight: 700; }
.card.kpi-success .kpi { color: var(--ok); }
.card.kpi-partial .kpi { color: var(--warn); }
.card.kpi-failure .kpi { color: var(--err); }

/* Tabellen */
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); }
th { background: var(--surface-alt); font-size: 0.85rem; text-transform: uppercase; color: var(--muted); }
tr:hover td { background: #f2f5fa; }

/* Status-Badges (Ampel) */
.badge {
    display: inline-block; padding: 0.1rem 0.55rem; border-radius: var(--radius);
    font-size: 0.8rem; font-weight: 600; color: #fff; background: var(--muted);
}
.badge.ok, .badge.SUCCESS, .badge.success { background: var(--ok); }
.badge.warn, .badge.PARTIAL, .badge.partial, .badge.PARTIAL_SUCCESS, .badge.partial_success, .badge.LOST, .badge.lost { background: var(--warn); }
.badge.err, .badge.FAILED, .badge.failed, .badge.FAILURE, .badge.failure { background: var(--err); }
.badge.PENDING, .badge.pending { background: #607d8b; }
.badge.RUNNING, .badge.running { background: var(--primary); }
.badge.CANCELLED, .badge.cancelled { background: #9e9e9e; }

/* Fortschrittsbalken */
.progress { background: #e3e7ec; border-radius: var(--radius); height: 0.9rem; overflow: hidden; }
.progress .bar { background: var(--primary); height: 100%; transition: width 0.4s; }

/* Meldungen */
.alert { padding: 0.6rem 0.9rem; border-radius: var(--radius); margin: 0.75rem 0; }
.alert.info { background: #e5effa; color: var(--primary-dark); }
.alert.error { background: #fdecea; color: var(--err); }
.alert.warn { background: #fff4e0; color: var(--warn); }

/* Diagramme */
.chart-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; max-width: 640px; }
.chart-box.small { max-width: 380px; }

/* Nutzertabelle: kompakte Aktionsspalte mit Icon-Buttons */
.actions-cell { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.actions-cell form { display: flex; gap: 0.25rem; align-items: center; margin: 0; }
.actions-cell select,
.actions-cell input[type=password] {
    width: auto; max-width: none; padding: 0.3rem 0.45rem;
}
.actions-cell input[type=password] { width: 11rem; }
.iconbtn {
    padding: 0.32rem 0.5rem; line-height: 1; font-size: 1rem;
    display: inline-flex; align-items: center; justify-content: center;
}
.iconbtn.ok { color: var(--ok); border-color: var(--ok); }
.iconbtn.danger { color: var(--err); border-color: var(--err); }

/* Pagination */
.pagination { display: flex; gap: 0.5rem; align-items: center; margin: 0.75rem 0; }
.filterbar { display: flex; gap: 0.75rem; align-items: end; flex-wrap: wrap; margin: 0.75rem 0; }
.filterbar label { margin: 0 0 0.25rem; }

/* Tabellen-Werkzeuge (table-tools.js) */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable::after { content: " ↕"; color: var(--muted); font-size: 0.8em; }
th.sortable[data-sort-dir="asc"]::after { content: " ▲"; color: var(--text); }
th.sortable[data-sort-dir="desc"]::after { content: " ▼"; color: var(--text); }
tr.hidden { display: none; }
tr.context-only { opacity: 0.55; }
tr[data-href] { cursor: pointer; }
tr[data-href]:hover td { background: #eef2f7; }

/* Gruppierte Ergebnistabelle (Auswertungsseite) */
tr.child-row td:first-child { padding-left: 1.5rem; }
tr.bp-row td { border-top: 2px solid var(--border); }
.typ-badge { font-size: 0.75em; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 0 0.3rem; color: var(--muted); }
td.mono, .mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 0.85em; }

/* BP-Detailseite: Anker-Ziele */
.protocol-block { scroll-margin-top: 4.5rem; }
.protocol-block:target { outline: 2px solid var(--primary); outline-offset: 6px; border-radius: var(--radius); }
.grund { background: #fdf2f2; border: 1px solid var(--err); border-radius: var(--radius);
    padding: 0.6rem 0.8rem; white-space: pre-wrap; font-family: ui-monospace, Consolas, monospace;
    font-size: 0.85em; }

/* Tastatur-Fokus deutlich sichtbar (Corporate-Design-konform in LBM-Blau) */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
th.sortable:focus-visible, tr[data-href]:focus-visible {
    outline: 2px solid var(--primary); outline-offset: 2px;
}

/* Aktions-Dropdown (Läufe-Übersicht) */
.action-menu { position: relative; display: inline-block; }
.action-menu > summary { list-style: none; }
.action-menu > summary::-webkit-details-marker { display: none; }
.action-menu > summary::marker { content: ""; }
.action-menu[open] > summary { background: var(--surface-alt); }
.action-menu-panel {
    position: absolute; right: 0; top: calc(100% + 0.25rem); z-index: 20;
    display: flex; flex-direction: column; gap: 0.4rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 0.5rem; min-width: 9rem; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.action-menu-panel form { margin: 0; }
.action-menu-panel button { width: 100%; }
