/* Feature Flags – „Warmes Anthrazit und Salbei“, nur Dark Mode. Farbwerte aus Spec §4.7 (Variante C). */
:root {
    color-scheme: dark;

    --bg: #1a1917;              /* Seitenhintergrund */
    --header: #201f1c;          /* Kopfzeile */
    --surface: #211f1c;         /* Fläche (Tabelle) */
    --surface-head: #1d1c19;    /* Tabellenkopf */
    --line: #302e29;            /* Linien */
    --row-line: #2a2824;        /* Zeilentrenner */
    --text: #ece8df;
    --muted: #a29d90;           /* gedämpft */
    --faint: #848073;           /* schwach */
    --btn: #282622;             /* Knopf */
    --btn-border: #3a3832;      /* Knopf-Rand */
    --btn-text: #e3dfd4;
    --accent: #9cae78;          /* Primärknopf, Logo-Punkt */
    --on-accent: #1a1d12;       /* Text auf Akzent */
    --switch-on: #8fa36a;
    --switch-off: #3a3832;
    --warn: #e9b467;
    --warn-bg: rgba(230, 160, 70, .15);

    --font: "Inter", "Segoe UI", system-ui, sans-serif;
    --mono: ui-monospace, Consolas, monospace;
}

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

html, body { margin: 0; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
    line-height: 1.4;
    min-height: 100vh;
}

/* Kopfzeile */
.top {
    display: flex;
    align-items: center;
    flex-wrap: wrap;    /* schmale Displays: Knöpfe brechen um, statt die Seite zu verbreitern */
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: var(--header);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 650;
    letter-spacing: .2px;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
}

.acts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.acts form { margin: 0; }

/* Knöpfe */
.btn {
    display: inline-block;
    padding: 6px 11px;
    border-radius: 7px;
    border: 1px solid var(--btn-border);
    background: var(--btn);
    color: var(--btn-text);
    font: inherit;
    font-size: 12px;
    font-weight: 550;
    cursor: pointer;
}

.btn:hover { border-color: var(--faint); }

.btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
}

.btn.primary:hover { filter: brightness(1.06); }

.btn.danger {
    background: var(--warn-bg);
    border-color: transparent;
    color: var(--warn);
}

.btn.danger:hover { border-color: var(--warn); }

.btn.htmx-request,
.btn:disabled { opacity: .6; cursor: progress; }

.mono { font-family: var(--mono); }

button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Abschnitte Kunden / Test */
.entries + .entries { margin-top: 22px; }

.entries-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 14px 14px 0;
}

.entries-head h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

/* Matrix */
.wrap {
    margin: 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    overflow-x: auto;   /* viele Flags: horizontal scrollen, Kundenspalte bleibt stehen */
    position: relative; /* Bezugsrahmen für absolut positionierte Kinder (.sr), damit sie im Scrollbereich bleiben */
}

.matrix {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.matrix thead th {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    background: var(--surface-head);
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
    vertical-align: bottom;
    text-align: center;
}

.matrix thead th.flag {
    min-width: 120px;
    max-width: 220px;
}

.matrix td,
.matrix tbody th {
    padding: 11px 12px;
    text-align: center;
    border-bottom: 1px solid var(--row-line);
    font-weight: normal;
}

.matrix tbody tr:last-child td,
.matrix tbody tr:last-child th { border-bottom: 0; }

.matrix .customer {
    position: sticky;
    left: 0;
    z-index: 1;
    text-align: left;
    min-width: 220px;
    background: var(--surface);
    border-right: 1px solid var(--line);
}

.matrix thead th.customer {
    z-index: 2;
    background: var(--surface-head);
}

/* Spaltenkopf ist ein Knopf: Klick öffnet „Flag bearbeiten“. */
.flaghead {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: inherit;
    cursor: pointer;
}

.flaghead:hover .desc { color: var(--text); }

.matrix th .desc { display: block; }

.matrix th .desc.mono { font-weight: 500; }

.matrix th .k {
    display: block;
    margin-top: 2px;
    font-family: var(--mono);
    font-size: 10.5px;
    font-weight: 500;
    color: var(--faint);
}

.badge {
    display: inline-block;
    margin-top: 4px;
    padding: 1px 6px;
    border-radius: 9px;
    font-size: 9.5px;
    font-weight: 600;
    background: var(--warn-bg);
    color: var(--warn);
}

.name { font-weight: 600; }

.meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
    font-size: 11px;
    color: var(--faint);
}

.warn {
    padding: 1px 6px;
    border-radius: 7px;
    font-size: 10.5px;
    font-weight: 600;
    background: var(--warn-bg);
    color: var(--warn);
}

/* Schalter */
.cell { cursor: pointer; }

.sw {
    display: inline-block;
    position: relative;
    width: 34px;
    height: 19px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: var(--switch-off);
    vertical-align: middle;
    cursor: pointer;
    transition: background-color .15s;
}

.sw::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .35);
    transition: left .15s;
}

.sw.on { background: var(--switch-on); }
.sw.on::after { left: 17px; }

.htmx-request .sw { opacity: .6; cursor: progress; }

.keycol { width: 1%; white-space: nowrap; }

.settings {
    margin-left: 6px;
    padding: 4px 7px;
    border: 0;
    border-radius: 7px;
    background: var(--btn);
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
}

.settings:hover { color: var(--text); }

.keyhint {
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--muted);
}

.keyhint.none {
    font-family: var(--font);
    color: var(--faint);
}

.empty {
    margin: 14px;
    color: var(--muted);
}

.matrix .empty-row { color: var(--muted); }

/* Nur für Screenreader. Braucht einen positionierten Vorfahren in der Nähe (.wrap), sonst verbreitert es die Seite. */
.sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

/* Login */
.login {
    display: flex;
    justify-content: center;
    padding: 64px 16px;
}

.card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    max-width: 320px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
}

.card h1 {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 650;
}

.card label {
    margin-top: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
}

.card input {
    padding: 7px 9px;
    border: 1px solid var(--btn-border);
    border-radius: 7px;
    background: var(--btn);
    color: var(--text);
    font: inherit;
}

.card .btn { margin-top: 12px; padding: 8px 11px; }

.card .error {
    margin: 0 0 4px;
    padding: 6px 9px;
    font-size: 12px;
}

/* Dialoge (Verwaltung) */
.dlg {
    width: min(420px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
}

.dlg::backdrop { background: rgba(12, 11, 10, .65); }

.dlg-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    padding: 18px 20px;
}

.dlg h2 {
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 650;
    overflow-wrap: anywhere;
}

.dlg label,
.dlg .field-label {
    margin-top: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
}

.dlg .opt { font-weight: 500; color: var(--faint); }

.dlg input,
.dlg select {
    padding: 7px 9px;
    border: 1px solid var(--btn-border);
    border-radius: 7px;
    background: var(--btn);
    color: var(--text);
    font: inherit;
}

.dlg input.mono { font-family: var(--mono); }

.dlg .hint {
    margin: 0;
    font-size: 11px;
    color: var(--faint);
}

.dlg .hint .badge { margin: 0 4px 0 0; }

.dlg .error,
.dlg .note {
    margin: 0 0 4px;
    padding: 6px 9px;
    font-size: 12px;
}

.dlg .sub {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 12px;
    color: var(--faint);
}

.dlg .confirm-text {
    margin: 0;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.fixed-key {
    padding: 7px 9px;
    border: 1px dashed var(--btn-border);
    border-radius: 7px;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.set-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.set-sec {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
    padding-top: 12px;
    border-top: 1px solid var(--btn-border);
}

.dlg h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 650;
}

.set-text {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
}

.set-acts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
}

.keyout {
    display: flex;
    gap: 8px;
    margin: 4px 0;
}

.keyout input {
    flex: 1;
    min-width: 0;
    font-size: 12px;
}

.dlg-acts {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
}

.dlg-acts .left { margin-right: auto; }
