/* DRK-Farben (Corporate Design): Rot #E60005, Dunkelblau #002D55, Grautöne */
:root {
  --red: #E60005;
  --red-dark: #B80004;
  --red-soft: #FDE8E9;
  --blue: #002D55;
  --blue-soft: #E6ECF2;
  --grey: #A5AAAF;
  --grey-light: #F2F3F4;
  --line: #DADDE0;
  --text: #1C2530;
  --muted: #5F6B77;
  --ok: #1E7B34;
  --ok-soft: #E3F3E7;
  --ok-light: #6A9A1F;
  --warn: #B26B00;
  --bg: #F6F7F8;
  --card: #FFFFFF;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(0, 45, 85, .08), 0 2px 8px rgba(0, 45, 85, .06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 "Helvetica Neue", Helvetica, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
[hidden] { display: none !important; }
h1, h2, h3 { color: var(--blue); margin: 0 0 .5em; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
a { color: var(--blue); }
.muted { color: var(--muted); }
.error { color: var(--red-dark); font-weight: 600; }
small { font-size: .8em; }

.topbar { height: 6px; background: var(--red); }

/* ---------- Kopfbereich ---------- */
.header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.header-inner {
  max-width: 1400px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 24px; min-height: 60px; flex-wrap: wrap;
}
.brand-block { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 4px; background: var(--red);
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.brand-mark::after { content: "AC"; color: #fff; font-weight: 700; font-size: 13px; letter-spacing: .5px; }
.brand-logo { display: block; height: 36px; width: auto; max-width: 180px; object-fit: contain; }
.login .brand-logo { height: 48px; }
.brand-title { font-weight: 700; color: var(--blue); font-size: 1.1rem; }

.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  text-decoration: none; color: var(--blue); font-weight: 600;
  padding: 18px 12px 15px; border-bottom: 3px solid transparent;
}
.nav a:hover { color: var(--red); }
.nav a.active { color: var(--red); border-bottom-color: var(--red); }

.user { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.user-name { color: var(--muted); font-size: .9rem; }
.status { font-size: .8rem; font-weight: 600; color: var(--ok); display: inline-flex; align-items: center; gap: 6px; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status.offline { color: var(--red); }

.main { max-width: 1400px; margin: 0 auto; padding: 20px 16px 60px; }
#app { flex: 1; }
.footer { color: var(--muted); font-size: 11px; text-align: center; padding: 16px; }
.footer a { color: inherit; }

/* ---------- Bausteine ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px;
}
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 160px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head h2 { margin: 0; }

.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--blue); background: #fff; color: var(--blue);
  padding: 8px 14px; border-radius: var(--radius); line-height: 1.2;
}
.btn:hover { background: var(--blue-soft); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn.ghost { border-color: var(--line); color: var(--muted); }
.btn.danger { border-color: var(--red); color: var(--red-dark); }
.btn.danger:hover { background: var(--red-soft); }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.btn.icon { padding: 5px 9px; min-width: 32px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .4; cursor: default; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
input, select, textarea {
  font: inherit; color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 10px; background: #fff; min-width: 0;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible {
  outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--blue);
}
textarea { width: 100%; min-height: 140px; resize: vertical; }
select.big { font-size: 1.1rem; font-weight: 600; color: var(--blue); padding: 10px 12px; }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table.grid { width: 100%; border-collapse: collapse; }
.grid th, .grid td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.grid thead th {
  background: var(--blue); color: #fff; font-size: .85rem; font-weight: 600;
  position: sticky; top: 0; white-space: nowrap;
}
.grid thead th small { display: block; font-weight: 400; opacity: .8; }
.grid tbody tr:nth-child(even) { background: #FAFBFB; }
.grid tbody tr:hover { background: var(--blue-soft); }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.grid .center { text-align: center; }
.grid tfoot td { font-weight: 600; background: var(--grey-light); }
.nr { display: inline-block; min-width: 2.2em; color: var(--muted); font-variant-numeric: tabular-nums; }
.who { font-weight: 600; white-space: nowrap; }

/* Punkte-Eingabe */
.pts {
  display: inline-flex; gap: 4px; padding: 3px; border: 1px solid transparent; border-radius: var(--radius);
  transition: background .4s, border-color .4s;
}
.pts.saving { border-color: var(--warn); background: #FFF8EC; }
.pts.ok { border-color: var(--ok); background: var(--ok-soft); }
.pts.err { border-color: var(--red); background: var(--red-soft); }
.pts.remote { background: var(--blue-soft); border-color: var(--blue); }
.pt {
  display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 96px; min-height: 48px;
  text-align: center; font-size: .9rem;
  padding: 4px 8px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--text); font: inherit; font-weight: 600; line-height: 1.15;
  cursor: pointer; touch-action: manipulation;
}
.pt small { font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.pt:hover { border-color: var(--blue); }
.pt.on small { color: inherit; }
.pt.full.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.pt.most.on { background: var(--ok-light); border-color: var(--ok-light); color: #fff; }
.pt.part.on { background: var(--warn); border-color: var(--warn); color: #fff; }
.pts-note { display: block; margin-top: 2px; color: var(--warn) !important; font-weight: 600; }
.pt.none.on { background: var(--red); border-color: var(--red); color: #fff; }
.free-input { display: inline-flex; align-items: center; gap: 8px; font-size: 1.05rem; }
input.pts-in {
  width: 110px; text-align: right; font-size: 1.15rem; font-weight: 700; padding: 10px 12px;
  font-variant-numeric: tabular-nums; transition: background .4s, border-color .4s;
}
input.pts-in.saving { border-color: var(--warn); background: #FFF8EC; }
input.pts-in.ok { border-color: var(--ok); background: var(--ok-soft); }
input.pts-in.err { border-color: var(--red); background: var(--red-soft); }
input.pts-in.remote { background: var(--blue-soft); border-color: var(--blue); }
.station-mode { margin-top: 8px; gap: 8px; font-size: .9rem; }
.grid td.free-col { background: rgba(0, 45, 85, .04); }
.rate-toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.rate-toolbar select { width: 100%; }
.rate-card { border-left: 4px solid var(--red); }
.rate-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.rate-head h2 { margin: 0; color: var(--blue); font-size: 1.3rem; }
.rate-cat { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 14px; padding: 8px 12px; background: var(--blue-soft); border-radius: var(--radius); }
.rate-cat h3 { margin: 0; font-size: 1rem; color: var(--blue); }
.rate-cat .cat-sum { color: var(--blue); font-size: 1.05rem; }
.rate-group:has(.rate-cat) .rate-task { padding-left: 12px; }
.rate-task { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 16px;
  padding: 12px 0; border-bottom: 1px dashed var(--line); }
.rate-task-name { font-weight: 600; }
.rate-task-name small { display: block; font-weight: 400; color: var(--muted); }
.rate-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; }
.rate-foot .sum { font-size: 1.15rem; }
.rate-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 12px; }
.rate-nav .btn { flex: 1; max-width: 240px; padding: 12px; }
.max { color: var(--muted); font-size: .85rem; margin-left: 4px; }
.sum { font-weight: 700; color: var(--blue); white-space: nowrap; }
.note-btn.has { background: var(--blue); color: #fff; }

/* Übersicht */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--red); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.tile b { display: block; font-size: 1.6rem; color: var(--blue); line-height: 1.1; }
.tile span { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
.bar { height: 6px; background: var(--grey-light); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--red); }
.bar.done > i { background: var(--ok); }
.rank { font-weight: 700; color: var(--blue); }
.total { font-weight: 700; color: var(--red); font-size: 1.05rem; }
.partial { color: var(--muted); }
.grid tr.clickable { cursor: pointer; }
.pct-cell { min-width: 110px; }
.st-progress { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.st-progress .card { padding: 10px 12px; }

/* Verwaltung */
.station-card { border-left: 4px solid var(--red); }
.station-card .station-name { font-weight: 700; color: var(--blue); font-size: 1.05rem; }
.station-card.collapsed { padding: 10px 12px; }
.station-head { display: flex; align-items: center; gap: 8px; }
.station-toggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 4px; margin: -4px;
  background: none; border: 0; border-radius: 8px; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.station-toggle:hover .btn { border-color: var(--blue); }
.station-toggle:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.station-toggle .chev { color: var(--red); font-size: 1rem; width: 1em; flex-shrink: 0; }
.station-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.station-info b { color: var(--blue); font-size: 1.05rem; overflow-wrap: anywhere; }
.station-info small { font-size: .8rem; }
.station-toggle .btn { flex-shrink: 0; }
.station-edit { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.task-row { display: grid; grid-template-columns: 1fr 90px auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.task-row:last-of-type { border-bottom: 0; }
.task-row.has-cat { grid-template-columns: 1fr 150px 90px auto; }
.cat-block { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--line); border-left: 3px solid var(--blue);
  border-radius: var(--radius); background: #FAFBFB; }
.cat-head { display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px; align-items: center; }
.cat-head small { white-space: nowrap; }
.cat-block .cat-name { font-weight: 600; color: var(--blue); }
.cat-block.uncat { border-left-color: var(--grey); }
.cat-title { font-weight: 600; color: var(--muted); }
.task-row input.maxp { text-align: right; }
.btns { display: flex; gap: 4px; }
.add-row { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.admin-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; align-items: start; }
.rater-row { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.p-row { display: grid; grid-template-columns: 80px 1fr auto; gap: 8px; align-items: center; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.danger-zone { border-color: var(--red); }
details summary { cursor: pointer; font-weight: 600; color: var(--blue); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }

/* Login */
.login { flex: 1; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 14px; padding: 28px; }
.login-card h1 { margin: 0; font-size: 1.35rem; }
.login-card p { margin: 0; }

/* Dialog */
.dialog {
  border: 0; border-top: 6px solid var(--red); border-radius: var(--radius);
  padding: 20px; width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}
.dialog::backdrop { background: rgba(0, 45, 85, .45); }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.detail-station { margin-top: 14px; }
.detail-station table { width: 100%; border-collapse: collapse; }
.detail-station td { padding: 4px 0; border-bottom: 1px dashed var(--line); }
.detail-station tr.cat-row td { padding: 8px 8px 4px; background: var(--blue-soft); color: var(--blue); font-weight: 700; border-bottom: 0; }
.detail-station tr.in-cat td:first-child { padding-left: 12px; }
.detail-station th { text-align: left; font-size: .8rem; color: var(--muted); font-weight: 600; padding: 4px 0; border-bottom: 1px solid var(--line); }
.detail-station th.num, .detail-station td.num { text-align: right; padding-left: 14px; white-space: nowrap; }
.detail-station tr.sum-row td { font-weight: 700; color: var(--blue); border-top: 1px solid var(--line); border-bottom: 0; padding-top: 6px; }
.table-wrap-plain { overflow-x: auto; }
.rater-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.rater-table th { text-align: left; font-size: .8rem; color: var(--muted); font-weight: 600; padding: 4px 0; border-bottom: 1px solid var(--line); }
.rater-table td { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.rater-table .num { text-align: right; padding-left: 14px; white-space: nowrap; }
.rater-table tr.mean-row td { font-weight: 700; color: var(--red); border-bottom: 0; border-top: 2px solid var(--blue); }
.note-box { background: var(--grey-light); border-radius: var(--radius); padding: 8px 10px; margin-top: 6px; white-space: pre-wrap; font-size: .92rem; }

/* Hinweis */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(20px);
  background: var(--blue); color: #fff; padding: 10px 18px; border-radius: var(--radius);
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 100; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.err { background: var(--red-dark); }

/* ---------- Mobil / Tablet ---------- */
@media (max-width: 900px) {
  .admin-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .header-inner { gap: 8px; padding-top: 8px; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .nav a { padding: 10px 10px 8px; }
  .user-name { display: none; }

  /* Bewertung: Knöpfe unter der Aufgabe, volle Breite */
  .rate-toolbar { grid-template-columns: 1fr; }
  .rate-task { grid-template-columns: 1fr; gap: 8px; }
  .rate-group:has(.rate-cat) .rate-task { padding-left: 0; }
  .task-row.muted.has-cat { display: none; }
  .task-row.has-cat { grid-template-columns: 1fr 90px; }
  .task-row.has-cat > input:first-child, .task-row.has-cat > .btns { grid-column: 1 / -1; }
  .task-row.has-cat > .btns { justify-content: flex-end; }
  .pts { display: grid; grid-template-columns: 1fr 1fr; }
  .pt { min-width: 0; min-height: 52px; }
}

@media print {
  .topbar, .header, .toolbar, .no-print, .toast { display: none !important; }
  body { background: #fff; font-size: 11px; }
  .main { padding: 0; max-width: none; }
  .table-wrap, .card, .tile { box-shadow: none; }
  .grid thead th { background: #fff !important; color: #000; border-bottom: 2px solid #000; }
  .print-title { display: block !important; }
}
.print-title { display: none; }
