/* KSM-Master – Design nach KSM CheckIn: Anthrazit, Signalgelb, Barlow / Barlow Condensed */
@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url(../fonts/barlow-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-display: swap; src: url(../fonts/barlow-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url(../fonts/barlow-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 700; font-display: swap; src: url(../fonts/barlow-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-display: swap; src: url(../fonts/barlow-condensed-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-display: swap; src: url(../fonts/barlow-condensed-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 800; font-display: swap; src: url(../fonts/barlow-condensed-latin-800-normal.woff2) format("woff2"); }

:root {
  --bg: #F3F4F2; --surface: #FFFFFF; --surface-2: #E9EBE7; --line: #D6D9D3;
  --fg: #1E272C; --muted: #5E686D; --head: #1E272C; --head-fg: #FFFFFF; --head-muted: #A9B2B6; --head-line: #3B474D;
  --yellow: #F2B705; --yellow-ink: #1E272C; --yellow-soft: #FCEFC4;
  --ok: #2E7D4F; --ok-soft: #DDEFE3; --warn: #B8402B; --warn-soft: #F6E0DB; --info: #2F5D7C; --info-soft: #DEE8EF;
  --f-display: "Barlow Condensed", "Arial Narrow", Arial, sans-serif;
  --f-body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141A1D; --surface: #1C2428; --surface-2: #232D32; --line: #33403F;
    --fg: #E8ECEA; --muted: #9AA6AA; --head: #0E1315; --head-muted: #8C989C; --head-line: #2C373C;
    --yellow-soft: #3A3010; --ok: #6CC28F; --ok-soft: #173226; --warn: #EE8A75; --warn-soft: #3A1E18; --info: #8DB8D6; --info-soft: #1B2B36;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141A1D; --surface: #1C2428; --surface-2: #232D32; --line: #33403F;
  --fg: #E8ECEA; --muted: #9AA6AA; --head: #0E1315; --head-muted: #8C989C; --head-line: #2C373C;
  --yellow-soft: #3A3010; --ok: #6CC28F; --ok-soft: #173226; --warn: #EE8A75; --warn-soft: #3A1E18; --info: #8DB8D6; --info-soft: #1B2B36;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 var(--f-body); padding-top: env(safe-area-inset-top, 0px); }
h1, h2, h3 { font-family: var(--f-display); text-transform: uppercase; letter-spacing: .03em; margin: 0; text-wrap: balance; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--info); }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Logo */
.logo { display: inline-flex; flex-direction: column; line-height: 1; user-select: none; }
.logo .k { font: 800 12px var(--f-display); letter-spacing: .18em; color: var(--head-muted); }
.logo .n { font: 800 28px var(--f-display); letter-spacing: .02em; color: var(--head-fg); text-transform: uppercase; margin-top: 1px; }
.logo .b { height: 5px; background: var(--yellow); margin-top: 4px; }
.logo.on-light .k { color: var(--muted); }
.logo.on-light .n { color: var(--fg); }

/* Kopf */
.top { background: var(--head); color: var(--head-fg); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; }
.top-in { max-width: 1240px; margin: 0 auto; padding: 12px 16px 0; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.top-sub { font: 600 12px var(--f-body); color: var(--head-muted); letter-spacing: .06em; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.who { text-decoration: none; font-size: 13px; color: var(--head-muted); background: none; border: 1px solid var(--head-line); border-radius: 6px; padding: 6px 10px; cursor: pointer; }
.who b { color: var(--head-fg); font-weight: 600; }
.iconbtn { background: transparent; border: 1px solid var(--head-line); color: var(--head-fg); border-radius: 6px; padding: 6px 10px; cursor: pointer; font-size: 13px; min-height: 34px; }
.iconbtn:hover, .who:hover { border-color: var(--head-muted); }
nav.tabs { max-width: 1240px; margin: 10px auto 0; padding: 0 16px; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
nav.tabs::-webkit-scrollbar { display: none; }
@media (min-width: 1100px) { nav.tabs { flex-wrap: wrap; overflow: visible; } }
nav.tabs a { color: var(--head-muted); font: 700 15px var(--f-display); letter-spacing: .06em; text-transform: uppercase; padding: 10px 9px 12px; border-bottom: 4px solid transparent; white-space: nowrap; display: flex; align-items: center; gap: 6px; text-decoration: none; }
nav.tabs a[aria-current="page"] { color: var(--head-fg); border-color: var(--yellow); }
nav.tabs a:hover { color: var(--head-fg); }
.cnt { font: 700 11px var(--f-body); background: var(--warn); color: #fff; border-radius: 999px; padding: 1px 7px; letter-spacing: 0; }

main { max-width: 1240px; margin: 0 auto; padding: 20px 16px 64px; display: flex; flex-direction: column; gap: 16px; }
.vhead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.vhead h1 { font-size: 30px; line-height: 1; }
.vhead p { margin: 6px 0 0; color: var(--muted); font-size: 14px; max-width: 70ch; }
.vhead .row { justify-content: flex-end; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.panel h2 { font-size: 18px; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }
.g2 { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.g2e { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 900px) { .g2, .g2e { grid-template-columns: 1fr; } }

.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; text-decoration: none; color: inherit; display: block; }
a.kpi:hover { border-color: var(--muted); }
.kpi .l { font: 700 12px var(--f-display); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.kpi .v { font: 800 38px/1 var(--f-display); font-variant-numeric: tabular-nums; margin-top: 6px; }
.kpi .s { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.kpi.alert { border-color: var(--warn); box-shadow: inset 4px 0 0 var(--warn); }

.btn { border: 1.5px solid var(--line); background: var(--surface); border-radius: 6px; padding: 9px 14px; cursor: pointer; font: 700 14px var(--f-display); letter-spacing: .08em; text-transform: uppercase; min-height: 42px; text-decoration: none; color: var(--fg); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--yellow); border-color: var(--yellow); color: var(--yellow-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.sm { min-height: 34px; padding: 6px 10px; font-size: 13px; }
.btn.danger { color: var(--warn); border-color: var(--warn); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--info); text-decoration: underline; cursor: pointer; font-size: 14px; }

.tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.tools input[type=search], .tools select, .tools input[type=date] { border: 1.5px solid var(--line); background: var(--surface); border-radius: 6px; padding: 9px 12px; font-size: 16px; min-height: 42px; }
.tools input[type=search] { flex: 1; min-width: 200px; }
.tools label.chk { font-size: 14px; display: flex; gap: 6px; align-items: center; }

.tw { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.tw.flat { border: 0; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font: 700 12px var(--f-display); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 10px 12px; border-bottom: 1.5px solid var(--line); white-space: nowrap; background: var(--surface); }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td, tbody tr.click:focus-within td { background: var(--surface-2); }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.id { font: 600 12.5px var(--f-mono); color: var(--muted); white-space: nowrap; }
.mono { font: 600 13.5px var(--f-mono); letter-spacing: .03em; white-space: nowrap; }
.sub { font-size: 12.5px; color: var(--muted); }
.raw { color: var(--warn); font-size: 12.5px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 4px; font: 700 11.5px var(--f-body); padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.y { background: var(--yellow); color: var(--yellow-ink); }
a.badge { text-decoration: none; }
a.badge:hover { filter: brightness(.95); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12.5px; border: 1px dashed var(--line); border-radius: 4px; padding: 2px 7px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.chip button { background: none; border: 0; color: var(--warn); cursor: pointer; padding: 0 2px; font-size: 14px; line-height: 1; }

/* Prüfliste */
.match { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 16px; padding: 14px 0; border-bottom: 1px solid var(--line); align-items: center; }
.match:last-child { border-bottom: 0; }
.match .raw-name { font-weight: 600; overflow-wrap: anywhere; }
.score { font: 700 12px var(--f-mono); padding: 1px 6px; border-radius: 4px; background: var(--yellow-soft); }
@media (max-width: 640px) { .match { grid-template-columns: 1fr; } }

/* Import */
.drop { border: 2px dashed var(--line); border-radius: var(--r); padding: 28px 16px; text-align: center; background: var(--surface); display: flex; flex-direction: column; gap: 8px; align-items: center; }
.drop.over { border-color: var(--yellow); background: var(--yellow-soft); }
.drop b { font: 700 18px var(--f-display); text-transform: uppercase; letter-spacing: .06em; }
.maptable select { min-width: 160px; border: 1.5px solid var(--line); background: var(--surface); border-radius: 6px; padding: 7px 10px; font-size: 15px; }
.req { color: var(--warn); font-weight: 700; }
.steps { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.steps li { flex: 1; font: 700 12px var(--f-display); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); border-top: 4px solid var(--line); padding-top: 6px; }
.steps li.on { color: var(--fg); border-color: var(--yellow); }
.steps li.done { color: var(--ok); border-color: var(--ok); }

/* Programme */
.apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.app { border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--surface); }
.app .t { display: flex; align-items: center; gap: 10px; }
.app h3 { font-size: 17px; }
.scopes { display: flex; flex-wrap: wrap; gap: 4px; }
.scopes code { font: 600 11.5px var(--f-mono); background: var(--surface-2); padding: 2px 6px; border-radius: 4px; }

dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.refs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.ref { border: 1px solid var(--line); border-left: 4px solid var(--yellow); border-radius: 6px; padding: 10px 12px; }
.ref b { font-family: var(--f-display); text-transform: uppercase; letter-spacing: .06em; }

.log { list-style: none; margin: 0; padding: 0; }
.log li { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.log li:last-child { border-bottom: 0; }
.log time { font: 600 12.5px var(--f-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.log .d { color: var(--muted); overflow-wrap: anywhere; }
@media (max-width: 560px) { .log li { grid-template-columns: 1fr; gap: 2px; } }

/* Rechte-Matrix */
.perms { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px 20px; }
.perms fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.perms legend { font: 700 13px var(--f-display); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.chk { display: flex; gap: 8px; align-items: center; font-size: 14px; cursor: pointer; }
.chk input { width: 18px; height: 18px; flex: none; accent-color: var(--yellow); }

/* Dialog */
.ov { position: fixed; inset: 0; background: rgba(14, 19, 21, .55); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: calc(24px + env(safe-area-inset-top, 0px)) 16px calc(24px + env(safe-area-inset-bottom, 0px)); overflow-y: auto; }
.dlg { background: var(--surface); border-radius: 10px; width: 100%; max-width: 680px; padding: 20px; display: flex; flex-direction: column; gap: 14px; border-top: 5px solid var(--yellow); }
.dlg.wide { max-width: 920px; }
.dlg h2 { font-size: 22px; overflow-wrap: anywhere; }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form .full { grid-column: 1 / -1; }
.f { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.f label, .f .lbl { font: 700 12px var(--f-display); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.f input, .f select, .f textarea { border: 1.5px solid var(--line); background: var(--surface); border-radius: 6px; padding: 9px 11px; font-size: 16px; width: 100%; }
.f textarea { min-height: 80px; resize: vertical; }
@media (max-width: 560px) { .form { grid-template-columns: 1fr; } }
.secret { font: 600 14px var(--f-mono); background: var(--surface-2); border-radius: 6px; padding: 10px 12px; overflow-wrap: anywhere; user-select: all; }
.note { font-size: 14px; padding: 10px 12px; border-radius: 6px; background: var(--surface-2); }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.ok { background: var(--ok-soft); color: var(--ok); }
.note.y { background: var(--yellow-soft); }
.qr { width: 200px; height: 200px; image-rendering: pixelated; background: #fff; padding: 8px; border-radius: 6px; }

/* Anmeldung */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 32px 16px; background: var(--head); }
.login .card { background: var(--surface); color: var(--fg); border-radius: 10px; width: 100%; max-width: 400px; padding: 24px; display: flex; flex-direction: column; gap: 14px; border-top: 6px solid var(--yellow); }
.code { letter-spacing: .4em; font-family: var(--f-mono); font-size: 22px !important; text-align: center; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--head); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 600; z-index: 60; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); border-left: 4px solid var(--yellow); max-width: calc(100vw - 32px); }
.toast.err { border-left-color: var(--warn); }
.empty { color: var(--muted); text-align: center; padding: 28px 12px; font-size: 14px; }
.loading { color: var(--muted); padding: 20px; text-align: center; }
footer.foot { max-width: 1240px; margin: 0 auto; padding: 0 16px 24px; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.grow { flex: 1; min-width: 0; border: 1.5px solid var(--line); background: var(--surface); border-radius: 6px; padding: 7px 10px; font-size: 16px; }
details > summary { cursor: pointer; padding: 4px 0; }
details > summary.lbl { font: 700 12px var(--f-display); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
code { font-family: var(--f-mono); font-size: .9em; }
fieldset.perms { border: 0; padding: 0; margin: 0; }
fieldset.perms legend { font: 700 12px var(--f-display); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
label.btn { position: relative; align-self: flex-start; }
.logo:hover { text-decoration: none; }
a.logo { text-decoration: none; }
