/* hellobill-admin – eigenes Stylesheet, kein Framework.
   Marke aus hello-bill: Beleg mit gewellter Abrisskante, Blau #004cb3 / #00347b. */

@font-face {
    font-family: "Instrument Sans";
    src: url("fonts/instrument-sans-latin.woff2") format("woff2");
    font-weight: 400 700;
    font-display: swap;
}

:root {
    --blue: #004cb3;
    --blue-deep: #00347b;
    --blue-wash: #e6eefb;
    --ink: #16233a;
    --muted: #5d6a80;
    --line: #dde3ec;
    --canvas: #eef1f6;
    --paper: #ffffff;
    --ok: #1d7f4e;
    --warn: #a86a12;
    --err: #b8322a;
    --off: #8792a5;
    --radius: 6px;
    --font: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font: 15px/1.5 var(--font);
    font-variant-numeric: tabular-nums;
    color: var(--ink);
    background: var(--canvas);
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--blue); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--blue-deep); }
code { font-family: var(--mono); font-size: 0.88em; }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 3px; }

.visually-hidden {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

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

.shell {
    display: grid;
    grid-template-columns: 236px minmax(0, 1fr);
    min-height: 100vh;
}

.rail {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 22px 14px 18px;
    background: var(--blue-deep);
    color: #c9d7ef;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px 26px;
    color: #fff;
    text-decoration: none;
}
.brand:hover { color: #fff; }
.brand__mark {
    width: 30px;
    height: 30px;
    padding: 4px;
    border-radius: 7px;
    background: #fff;
}
.brand__name { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.brand__name span { font-weight: 400; color: #9fb6dc; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__link {
    display: block;
    padding: 8px 10px;
    border-radius: var(--radius);
    color: #c9d7ef;
    text-decoration: none;
}
.nav__link:hover { color: #fff; background: rgba(255, 255, 255, 0.07); }
.nav__link[aria-current="page"] { color: #fff; background: rgba(255, 255, 255, 0.13); font-weight: 600; }

.rail__foot {
    margin-top: auto;
    padding: 14px 10px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 13px;
}
.rail__user { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #9fb6dc; margin-bottom: 8px; }
.rail__logout {
    padding: 0;
    border: 0;
    background: none;
    color: #fff;
    font: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.page {
    width: 100%;
    min-width: 0;
    padding: 34px 44px 64px;
}

/* Fließtext und Formulare bleiben lesbar schmal, auch wenn die Seite die volle Breite nutzt */
.health__sub, .page-head__lead { max-width: 80ch; }

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 26px;
}
.page-head h1 { font-size: 26px; }
.page-head__lead { margin-top: 6px; color: var(--muted); max-width: 62ch; }
.page-head__actions { display: flex; flex-wrap: wrap; gap: 8px; }

.back { display: inline-block; margin-bottom: 10px; font-size: 14px; color: var(--muted); text-decoration: none; }
.back:hover { color: var(--blue); }

/* ------------------------------------------------------------ Lagesatz (Dashboard) */

.health {
    padding: 4px 0 30px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--line);
}
.health__line {
    display: flex;
    align-items: baseline;
    gap: 14px;
    font-size: clamp(26px, 3.4vw, 38px);
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.02em;
    max-width: 26ch;
}
.health__dot {
    flex: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--ok);
    transform: translateY(-0.12em);
}
.health--alert .health__dot { background: var(--err); }
.health--unknown .health__dot { background: var(--off); }
.health__sub { margin-top: 10px; color: var(--muted); }
.health__sub a { color: var(--err); font-weight: 600; }

/* ------------------------------------------------------------ Buttons & Formulare */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
    color: var(--ink);
    font: 600 14px/1 var(--font);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}
.btn:hover { border-color: #c3ccd9; color: var(--ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn--primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn--primary:hover { background: var(--blue-deep); border-color: var(--blue-deep); color: #fff; }
.btn--danger { color: var(--err); }
.btn--danger:hover { border-color: var(--err); color: var(--err); }
.btn--sm { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn--block { width: 100%; min-height: 44px; font-size: 15px; }

.form { max-width: 640px; }
.field { margin-bottom: 20px; }
.field__label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 14px; }
.field__hint { margin-top: 6px; font-size: 13px; color: var(--muted); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }

.input, .select, .textarea {
    display: block;
    width: 100%;
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid #cbd3df;
    border-radius: var(--radius);
    background: var(--paper);
    color: var(--ink);
    font: 15px/1.4 var(--font);
}
.textarea { min-height: 76px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-wash); }
.input--mono, .textarea--mono { font-family: var(--mono); font-size: 14px; }

.input-suffix { display: flex; }
.input-suffix .input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-suffix__text {
    display: flex;
    align-items: center;
    padding: 0 12px;
    border: 1px solid #cbd3df;
    border-left: 0;
    border-radius: 0 var(--radius) var(--radius) 0;
    background: var(--canvas);
    color: var(--muted);
    white-space: nowrap;
}

.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 22px; }
.check input { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--blue); }

/* 2FA-Code direkt neben einer kritischen Aktion */
.confirm { display: inline-flex; gap: 6px; align-items: center; }
.code {
    width: 104px;
    min-height: 32px;
    padding: 4px 10px;
    border: 1px solid #cbd3df;
    border-radius: var(--radius);
    font: 14px/1 var(--font);
    letter-spacing: 0.12em;
}
.code::placeholder { letter-spacing: 0; color: #98a2b3; }
.code:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-wash); }

.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 6px; }

/* ------------------------------------------------------------ Hinweise */

.notice {
    margin-bottom: 20px;
    padding: 12px 16px;
    border-left: 3px solid var(--blue);
    border-radius: 0 var(--radius) var(--radius) 0;
    background: var(--paper);
}
.notice--danger { border-color: var(--err); }
.notice--warning { border-color: var(--warn); }
.notice--success { border-color: var(--ok); }

/* ------------------------------------------------------------ Status */

.status { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: 14px; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status--ok { color: var(--ok); }
.status--warn { color: var(--warn); }
.status--err { color: var(--err); }
.status--off { color: var(--off); }
.status--busy { color: var(--blue); }

/* ------------------------------------------------------------ Positionsliste */

.ledger { width: 100%; border-collapse: collapse; }
.ledger th {
    padding: 0 12px 10px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
}
.ledger td { padding: 14px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.ledger tbody tr:hover td { background: rgba(255, 255, 255, 0.6); }
.ledger th:first-child, .ledger td:first-child { padding-left: 0; }
.ledger__num { text-align: right; }
.ledger__name { font-weight: 600; color: var(--ink); text-decoration: none; }
.ledger__name:hover { color: var(--blue); }
.ledger__sub { display: block; font-size: 13px; color: var(--muted); }
.ledger__more { font-size: 13px; color: var(--muted); }
.ledger__empty { padding: 26px 0; color: var(--muted); }

/* ------------------------------------------------------------ Abschnitte */

.section { margin-top: 44px; }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section__head h2 { font-size: 17px; }
.section__note { font-size: 13px; color: var(--muted); }

.columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 44px; }
.columns > .section { margin-top: 0; }

.meta { display: flex; flex-wrap: wrap; gap: 6px 28px; margin: 12px 0 0; }
.meta div { display: flex; gap: 8px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; font-weight: 600; }

.rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.rows li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 11px 0;
    border-bottom: 1px solid var(--line);
}
.tag { font-size: 12px; font-weight: 600; color: var(--blue); background: var(--blue-wash); padding: 2px 8px; border-radius: 99px; }

.inline-form { display: flex; gap: 8px; margin-top: 14px; }
.inline-form .input { flex: 1; min-width: 0; }

.versions { list-style: none; margin: 0 0 14px; padding: 0; }
.versions li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.versions li:first-child { font-weight: 600; }

/* ------------------------------------------------------------ Protokoll */

.log {
    margin: 0;
    padding: 16px 18px;
    max-height: 480px;
    overflow: auto;
    border-radius: var(--radius);
    background: #0b2752;
    color: #d6e2fa;
    font: 12.5px/1.6 var(--mono);
    white-space: pre-wrap;
    word-break: break-word;
}

.secret {
    margin: 18px 0;
    padding: 16px 18px;
    border: 1px dashed var(--warn);
    border-radius: var(--radius);
    background: var(--paper);
}
.secret code { display: inline-block; margin-top: 6px; font-size: 20px; user-select: all; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 24px; margin: 18px 0 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }

.audit-alert td { color: var(--err); }

/* ------------------------------------------------------------ Login: der Beleg */

.auth {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
    background: linear-gradient(180deg, var(--blue-deep) 0 34vh, var(--canvas) 34vh);
}

.slip-wrap {
    width: 100%;
    max-width: 384px;
    filter: drop-shadow(0 18px 30px rgba(0, 52, 123, 0.18));
    animation: print 520ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.slip {
    position: relative;
    padding: 34px 34px 30px;
    background: var(--paper);
    border-radius: 10px 10px 0 0;
}
/* Gewellte Abrisskante wie im hello-bill-Logo */
.slip::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -11px;
    height: 12px;
    background: radial-gradient(circle at 12px 0, var(--paper) 11.5px, transparent 12px) 0 0 / 24px 12px repeat-x;
}

.slip__brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.slip__brand img { width: 40px; height: 40px; }
.slip__title { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.slip__title span { display: block; font-size: 14px; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.slip__lead { margin-bottom: 20px; color: var(--muted); }
.slip__foot {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px dashed var(--line);
    font-size: 13px;
    color: var(--muted);
}

.otp {
    display: block;
    width: 100%;
    padding: 12px 0;
    border: 1px solid #cbd3df;
    border-radius: var(--radius);
    font: 600 28px/1 var(--font);
    letter-spacing: 0.32em;
    text-indent: 0.32em;
    text-align: center;
}
.otp:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-wash); }

@keyframes print {
    from { transform: translateY(-14px); opacity: 0; }
    to { transform: none; opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .slip-wrap { animation: none; }
}

/* ------------------------------------------------------------ Klein */

@media (max-width: 860px) {
    .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
    .rail {
        position: static;
        height: auto;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px 16px;
        padding: 12px 16px;
    }
    .brand { padding: 0; }
    .nav { flex-direction: row; overflow-x: auto; order: 3; width: 100%; margin: 0 -4px; }
    .nav__link { white-space: nowrap; }
    .rail__foot { margin: 0 0 0 auto; padding: 0; border: 0; display: flex; gap: 12px; align-items: center; }
    .rail__user { display: none; }
    .page { padding: 24px 16px 48px; }
    .columns, .field-row { grid-template-columns: 1fr; gap: 0; }
    .columns > .section + .section { margin-top: 40px; }

    .ledger thead { display: none; }
    .ledger, .ledger tbody { display: block; }
    .ledger tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 2px 12px;
        padding: 14px 0;
        border-bottom: 1px solid var(--line);
    }
    .ledger td { display: block; padding: 0; border: 0; }
    .ledger td:first-child { grid-column: 1; }
    .ledger__wide { display: none !important; }
    .ledger__side { grid-column: 2; grid-row: 1; text-align: right; }
    .ledger td[data-label]::before { content: attr(data-label) " "; color: var(--muted); }
    .ledger td[colspan] { grid-column: 1 / -1; }
    .toolbar { justify-content: stretch; }
    .toolbar .page-head__actions { width: 100%; }
    .toolbar .btn { flex: 1; }
    .page-head__actions { width: 100%; }
}

.reveal { margin-top: 18px; }
[hidden] { display: none !important; }

/* Kritische Aktion: erst aufklappen, dann mit 2FA-Code bestätigen */
.danger-zone { position: relative; }
.danger-zone > summary { list-style: none; }
.danger-zone > summary::-webkit-details-marker { display: none; }
.danger-zone[open] > summary { color: var(--muted); border-color: var(--line); }
.danger-zone__panel {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 8px;
}
.health__line > span:last-child { min-width: 0; }

/* ------------------------------------------------------------ Instanz-Karten */

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 28px 0 16px;
}
.toolbar__title { font-size: 17px; }

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px 20px 18px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--paper);
}
.card:hover { border-color: #b9c6db; }
.card:focus-within { border-color: var(--blue); }
.card--alert { border-color: #e7b9b5; box-shadow: inset 3px 0 0 var(--err); }

.card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card__title { min-width: 0; }
.card__link {
    display: block;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--ink);
    text-decoration: none;
}
/* Ganze Karte klickbar, ohne verschachtelte Links */
.card__link::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.card__link:focus-visible { outline: none; }
.card__link:focus-visible::after { outline: 2px solid var(--blue); outline-offset: 2px; }
.card__slug { font-size: 13px; color: var(--muted); }

.card__domain { position: relative; z-index: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card__more { margin-left: 6px; font-size: 13px; color: var(--muted); }
.card__reason { font-size: 14px; color: var(--err); }

.card__facts {
    display: grid;
    grid-template-columns: repeat(3, auto);
    justify-content: start;
    gap: 4px 28px;
    margin: auto 0 0;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}
.card__facts dt { font-size: 12px; color: var(--muted); }
.card__facts dd { margin: 0; font-weight: 600; font-size: 14px; }

.empty {
    padding: 40px 24px;
    border: 1px dashed #c3ccd9;
    border-radius: 10px;
    color: var(--muted);
    text-align: center;
}

.versions-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px 24px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
}
.versions-bar h2 { font-size: 15px; margin-bottom: 2px; }

.card__reason--warn { color: var(--warn); }
.card__facts .status { font-size: 14px; }
.card__facts .status::before { width: 7px; height: 7px; }

.domain { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.domain__cert { font-size: 13px; color: var(--muted); }
.domain__cert .status { font-size: 13px; }
.domain__cert .status::before { width: 6px; height: 6px; }
.domain__problem { font-size: 13px; color: var(--err); }
.domain__problem--warn { color: var(--warn); }

.tag--primary { color: #fff; background: var(--blue); }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; }

.versions-bar + .versions-bar { margin-top: 0; }
.versions-bar .domain__problem { display: block; margin: 4px 0; }
