:root {
  --bg: #f5f5f4; --card: #ffffff; --ink: #18181b; --muted: #71717a; --line: #e4e4e7;
  --brand: #111111; --brand-ink: #ffffff; --brand-soft: #ebebeb;
  --warn: #9a5b00; --warn-soft: #fdf1dc; --bad: #a32020; --bad-soft: #fbe5e5; --ok: #1d6b3f; --ok-soft: #e1f3e8;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 "DM Sans", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: Manrope, "DM Sans", sans-serif; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* Kopfzeile mit Suche */
.top { position: sticky; top: 0; z-index: 20; background: var(--brand); color: var(--brand-ink); }
.top-inner { max-width: 1200px; margin: 0 auto; display: flex; gap: 12px; align-items: center; padding: 10px 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: Manrope; font-weight: 800; white-space: nowrap; color: inherit; text-decoration: none; }
.brand img { height: 28px; width: auto; background: #fff; border-radius: 6px; padding: 2px 4px; }
.search { position: relative; flex: 1; max-width: 560px; }
.search input { width: 100%; border: 0; border-radius: 10px; padding: 10px 12px 10px 36px; background: rgba(255,255,255,.14); color: #fff; outline: none; }
.search input::placeholder { color: rgba(255,255,255,.7); }
.search input:focus { background: #fff; color: var(--ink); }
.search input:focus::placeholder { color: var(--muted); }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); opacity: .75; pointer-events: none; }
.search input:focus + .icon { color: var(--muted); }
.kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 12px; opacity: .6; border: 1px solid currentColor; border-radius: 4px; padding: 0 5px; pointer-events: none; }
.results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--card); color: var(--ink); border-radius: var(--radius); box-shadow: 0 10px 40px rgba(0,0,0,.2); max-height: 70vh; overflow: auto; padding: 6px; }
.results .group { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 10px 4px; }
.results button { display: flex; width: 100%; text-align: left; gap: 10px; align-items: center; border: 0; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.results button.active, .results button:hover { background: var(--brand-soft); }
.results .t { font-weight: 600; } .results .s { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results .empty { padding: 14px; color: var(--muted); }
.user { margin-left: auto; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.user .menu-btn { background: rgba(255,255,255,.14); border: 0; color: #fff; border-radius: 10px; padding: 8px 12px; cursor: pointer; }

/* Navigation */
.nav { background: var(--card); border-bottom: 1px solid var(--line); }
.nav-inner { max-width: 1200px; margin: 0 auto; display: flex; gap: 4px; padding: 6px 16px; overflow-x: auto; scrollbar-width: none; }
.nav a { padding: 8px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 600; white-space: nowrap; }
.nav a.on { background: var(--brand-soft); color: var(--brand); }

main { max-width: 1200px; margin: 0 auto; padding: 20px 16px 80px; }
.head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.head h1 { margin-right: auto; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card h2 { margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.muted { color: var(--muted); }
.stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; min-width: 110px; }
.stat b { display: block; font-size: 1.4rem; font-family: Manrope; }
.stat span { color: var(--muted); font-size: 13px; }

/* Listen */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar input, .toolbar select { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 16px; border-top: 1px solid var(--line); cursor: pointer; background: none; border-left: 0; border-right: 0; border-bottom: 0; width: 100%; text-align: left; }
.row:first-child { border-top: 0; }
.row:hover { background: #fafafa; }
.row .t { font-weight: 600; }
.row .s { color: var(--muted); font-size: 13px; grid-column: 1; }
.row .r { grid-row: 1 / span 2; grid-column: 2; align-self: center; text-align: right; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.mini .row { padding: 10px 0; border-top: 1px solid var(--line); }
.mini .row:hover { background: none; }
.empty-state { padding: 28px; text-align: center; color: var(--muted); }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); white-space: nowrap; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.grey { background: #efefef; color: var(--muted); }

/* Buttons & Formulare */
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 14px; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }
form .fields { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.field.wide { grid-column: 1 / -1; }
.field input, .field select, .field textarea { border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; background: #fff; color: var(--ink); font-weight: 400; font-size: 15px; width: 100%; }
.field textarea { min-height: 80px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .toolbar input:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }
.check input { width: auto; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.actions .left { margin-right: auto; }
.error { color: var(--bad); background: var(--bad-soft); border-radius: 8px; padding: 8px 10px; margin-top: 12px; }
.hint { font-size: 12px; font-weight: 400; color: var(--muted); }

dialog { border: 0; border-radius: 16px; padding: 0; width: min(680px, calc(100vw - 24px)); max-height: calc(100vh - 24px); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.5); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; }
.modal-body { padding: 16px 20px 20px; }
.x { border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }
.history { margin-top: 16px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 100; }
#toast.show { opacity: 1; }

/* Anmeldung */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: min(400px, 100%); padding: 28px; }
.auth img { display: block; max-width: 220px; margin: 0 auto 16px; }
.auth h1 { text-align: center; margin-bottom: 6px; }
.auth p { text-align: center; margin: 0 0 18px; }
.auth form { display: grid; gap: 12px; }

@media (max-width: 640px) {
  .brand span { display: none; }
  .kbd { display: none; }
  form .fields { grid-template-columns: 1fr; }
  main { padding-top: 14px; }
  .grid { grid-template-columns: 1fr; }
}
@media print { .top, .nav, .btn { display: none !important; } }
.muted-light { opacity: .8; font-size: 14px; }
@media (max-width: 640px) { .user { display: none; } .top-inner { gap: 8px; } }

/* ---------- Layout mit Seitenleiste ---------- */
.layout { max-width: 1320px; margin: 0 auto; display: grid; grid-template-columns: 220px minmax(0, 1fr); align-items: start; }
.nav { position: sticky; top: 52px; height: calc(100vh - 52px); overflow-y: auto; background: transparent; border: 0; padding: 14px 8px 40px 16px; display: flex; flex-direction: column; gap: 2px; }
.nav a { padding: 7px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; font-weight: 500; white-space: nowrap; }
.nav a:hover { background: #ececec; }
.nav a.on { background: var(--brand); color: #fff; font-weight: 600; }
.nav-group { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 12px 4px; }
.nav-group:first-child { padding-top: 2px; }
main { max-width: none; margin: 0; }
@media (max-width: 900px) {
  .layout { display: block; }
  .nav { position: sticky; top: 52px; z-index: 15; height: auto; flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 6px 12px; background: var(--card); border-bottom: 1px solid var(--line); scrollbar-width: none; }
  .nav-group { display: none; }
}

/* ---------- Bausteine ---------- */
.stat { text-decoration: none; color: inherit; }
.notice { background: var(--brand-soft); color: var(--brand); border-radius: 10px; padding: 10px 14px; margin: 0 0 14px; }
.notice a { font-weight: 700; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.btn.small { padding: 3px 10px; font-size: 13px; }
a.btn { text-decoration: none; color: inherit; display: inline-block; }
a.btn.primary { color: #fff; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.row.static { cursor: default; }
.row.static:hover { background: none; }
label.row { cursor: pointer; }
.field input:disabled, .field select:disabled, .field textarea:disabled { background: #f4f4f5; color: var(--ink); }
details.history summary, details.card summary, details.conditions summary { cursor: pointer; font-weight: 600; }
.history .mini .row { padding: 8px 0; }
.small { font-size: 12px; line-height: 1.5; }
.conditions { margin: 8px 0 12px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; max-height: 320px; overflow: auto; }
.modal-body h3 { margin: 18px 0 8px; }
code { background: #efefef; border-radius: 4px; padding: 0 4px; }

/* Fotos */
.photos { margin-top: 16px; }
.photos h3 { margin-bottom: 8px; display: flex; gap: 8px; align-items: center; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb { position: relative; width: 96px; height: 96px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #f4f4f5; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .pdf { display: grid; place-items: center; height: 100%; font-weight: 700; color: var(--bad); }
.thumb .del { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; line-height: 1; }
.add { width: 96px; height: 96px; border: 2px dashed var(--line); border-radius: 10px; display: grid; place-items: center; text-align: center; color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer; padding: 6px; }
.add:hover { border-color: var(--brand); color: var(--brand); }

/* Endkontrolle */
.checkgroup { border: 1px solid var(--line); border-radius: 12px; margin: 14px 0; padding: 6px 14px 10px; }
.checkgroup legend { font-weight: 700; padding: 0 6px; font-family: Manrope; }
.checkrow { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.checkrow:first-of-type { border-top: 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex-shrink: 0; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 6px 10px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg label + label span { border-left: 1px solid var(--line); }
.seg input:checked + span { background: var(--ok); color: #fff; }
.seg label.bad input:checked + span { background: var(--bad); }
.seg input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: -2px; }
@media (max-width: 640px) { .checkrow { flex-direction: column; align-items: stretch; } .seg { align-self: flex-start; } }

/* Unterschrift */
.sigwrap { position: relative; border: 2px dashed var(--line); border-radius: 12px; background: #fff; }
.sigwrap canvas { width: 100%; height: auto; aspect-ratio: 16 / 5; display: block; touch-action: none; cursor: crosshair; }
.sigwrap .btn { position: absolute; top: 8px; right: 8px; }
.sigwrap::after { content: 'Hier unterschreiben'; position: absolute; left: 16px; bottom: 10px; color: #c4c4c8; font-size: 12px; pointer-events: none; }

/* Bonus */
.bonus .big { font-family: Manrope; font-size: 2rem; font-weight: 800; margin: 4px 0; }
.bonus.ok .big { color: var(--ok); } .bonus.bad .big { color: var(--bad); }
#messages { border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 24px)); }

/* ---------- Werkstattboard ---------- */
.weekstrip { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; scrollbar-width: none; }
.weekstrip button { flex: 1; min-width: 96px; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 10px; text-align: left; cursor: pointer; }
.weekstrip button b { display: block; font-size: 14px; }
.weekstrip button span { font-size: 12px; color: var(--muted); }
.weekstrip button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.weekstrip button.on span { color: rgba(255,255,255,.75); }
.board { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
.bhead, .bbody { display: grid; grid-template-columns: 56px repeat(var(--cols), minmax(150px, 1fr)); min-width: calc(56px + var(--cols) * 150px); }
.bhead { position: sticky; top: 0; background: var(--card); border-bottom: 1px solid var(--line); z-index: 2; }
.bhead > div { padding: 10px; border-left: 1px solid var(--line); }
.bhead > div:first-child { border-left: 0; }
.bhead b { display: block; font-size: 14px; }
.bhead span { font-size: 12px; color: var(--muted); }
.bhead .away span { color: var(--bad); font-weight: 600; }
.bbody { position: relative; }
.times { position: relative; }
.times span { position: absolute; right: 8px; transform: translateY(-50%); font-size: 11px; color: var(--muted); }
.times span:first-child { transform: none; }
.bcol { position: relative; border-left: 1px solid var(--line); cursor: copy; }
.bcol.away { background: repeating-linear-gradient(45deg, #fafafa, #fafafa 8px, #f2f2f2 8px, #f2f2f2 16px); }
.bcol i { position: absolute; left: 0; right: 0; border-top: 1px solid #f0f0f0; }
.lunch { position: absolute; left: 0; right: 0; background: rgba(0,0,0,.035); font-size: 11px; color: var(--muted); padding: 2px 6px; pointer-events: none; }
.blk { position: absolute; left: 4px; right: 4px; border: 0; border-left: 4px solid var(--ink); background: var(--brand-soft); border-radius: 8px; padding: 4px 8px;
  text-align: left; font-size: 12px; line-height: 1.3; overflow: hidden; cursor: pointer; color: var(--ink); z-index: 1; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.blk b { font-size: 13px; }
.blk span { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blk em { display: block; font-style: normal; font-weight: 700; color: var(--bad); }
.blk.warn { background: var(--warn-soft); border-left-color: var(--warn); }
.blk.ok { background: var(--ok-soft); border-left-color: var(--ok); }
.blk.bad { background: var(--bad-soft); border-left-color: var(--bad); }
.blk.grey { background: #f1f1f1; border-left-color: #a1a1aa; }
.blk.conflict { outline: 2px solid var(--bad); outline-offset: -2px; }
.blk:hover { filter: brightness(.97); }
dialog.sub { width: min(620px, calc(100vw - 24px)); }
