/* Layout: Kennzahlen oben, Diagramme, Firmen-Überblick, Arbeitsliste mit Erledigt-Häkchen */
:root {
  --bg: #f6f7f8; --panel: #ffffff; --fg: #1b2127; --muted: #5d6873; --line: #dde1e5;
  --accent: #1f4e79; --accent-soft: #e4edf5; --bad: #b3261e; --warn: #96560a; --good: #1b6e43;
  --bar: #3b6a94; --bar-muted: #c3ccd5;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #12171c; --panel: #1a2128; --fg: #e8ecef; --muted: #9aa6b1; --line: #2c353d;
  --accent: #8db6dd; --accent-soft: #223647; --bad: #ff8a80; --warn: #f0b35c; --good: #6fcf97;
  --bar: #6f9cc6; --bar-muted: #3a4651; color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #12171c; --panel: #1a2128; --fg: #e8ecef; --muted: #9aa6b1; --line: #2c353d;
  --accent: #8db6dd; --accent-soft: #223647; --bad: #ff8a80; --warn: #f0b35c; --good: #6fcf97;
  --bar: #6f9cc6; --bar-muted: #3a4651; color-scheme: dark; }
* { box-sizing: border-box; }
body { background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 14px; line-height: 1.45; padding-block: 20px 40px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.wrap { max-width: 1280px; margin-inline: auto; display: flex; flex-direction: column; gap: 16px; }
.head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 8px 16px; }
h1 { font-size: 1.7rem; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.take { margin: 4px 0 0; color: var(--muted); font-size: 1rem; max-width: 62ch; text-wrap: pretty; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; color: var(--muted); font-size: 12px; }
.meta a { color: var(--fg); text-underline-offset: 2px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), 1fr)); gap: 8px; }
.tile { appearance: none; text-align: left; font: inherit; color: inherit; cursor: pointer; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-height: 5.8rem; }
.tile:hover { border-color: var(--muted); }
.tile[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.tile .l { font-size: 12px; color: var(--muted); }
.tile .n { font-size: 2rem; font-weight: 500; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile .s { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tile.bad .n { color: var(--bad); } .tile.warn .n { color: var(--warn); } .tile.good .n { color: var(--good); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 16px; min-width: 0; }
.card h2 { font-size: 1rem; font-weight: 600; margin: 0; }
.note { margin: 2px 0 10px; font-size: 12px; color: var(--muted); }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: 16px; }
.bars { display: flex; flex-direction: column; gap: 6px; }
.brow { display: grid; grid-template-columns: minmax(6rem, 38%) 1fr auto; gap: 8px; align-items: center; font-size: 12px; background: none; border: 0; color: inherit; font-family: inherit; padding: 2px 0; text-align: left; }
button.brow { cursor: pointer; }
.brow .lab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; color: var(--muted); }
.brow .track { height: 16px; }
.brow .fill { height: 100%; background: var(--bar); border-radius: 3px; min-width: 2px; }
.brow.off .fill { background: var(--bar-muted); }
.brow .val { font-variant-numeric: tabular-nums; min-width: 5.5rem; }
.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.seg button { appearance: none; font: inherit; font-size: 12px; color: var(--fg); background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--bg); border-color: var(--accent); }
select, input[type=search] { font: inherit; font-size: 12px; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; min-width: 0; }
input[type=search] { flex: 1 1 12rem; }
.count { margin-left: auto; font-size: 12px; color: var(--muted); }
.scroll { max-height: 72vh; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
th { position: sticky; top: 0; background: var(--panel); text-align: left; border-bottom: 1px solid var(--line); z-index: 2; white-space: nowrap; padding: 0; }
th > button, th > span { appearance: none; font: inherit; font-weight: 600; color: var(--fg); background: none; border: 0; padding: 9px 10px; width: 100%; text-align: inherit; cursor: pointer; display: block; }
th > span { cursor: default; }
td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:hover td { background: var(--accent-soft); }
td.num, th.num { text-align: right; }
td.w { min-width: 11rem; max-width: 22rem; overflow-wrap: anywhere; }
td a { color: var(--fg); text-underline-offset: 2px; }
tr.isdone td { color: var(--muted); } tr.isdone td.w, tr.isdone td.num { text-decoration: line-through; }
td.chk { width: 2.4rem; text-align: center; }
td.chk input { width: 18px; height: 18px; accent-color: var(--good); cursor: pointer; }
.late { color: var(--bad); font-weight: 600; } .soon { color: var(--warn); font-weight: 600; }
.tag { display: inline-block; margin-left: 6px; padding: 0 6px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 11px; }
.more { appearance: none; font: inherit; font-size: 12px; color: var(--fg); background: transparent; border: 1px solid var(--line); border-radius: 6px; padding: 7px 14px; margin-top: 10px; cursor: pointer; }
.chip { appearance: none; font: inherit; font-size: 12px; color: var(--bg); background: var(--accent); border: 0; border-radius: 999px; padding: 4px 12px; cursor: pointer; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.banner { font-size: 12px; color: var(--warn); }
.overhead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.over tbody tr { cursor: pointer; } .over tbody tr[aria-selected="true"] td { background: var(--accent-soft); }
@media (max-width: 640px) { h1 { font-size: 1.4rem; } .count { margin-left: 0; width: 100%; } .hs { display: none; } }

/* ---- Erweiterungen Serverversion ---- */
body { margin: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.head .right { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.user { position: relative; }
.user > button, .btn { appearance: none; font: inherit; font-size: 12px; color: var(--fg); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; cursor: pointer; }
.btn:hover, .user > button:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.user .menu { position: absolute; right: 0; top: calc(100% + 4px); min-width: 15rem; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px; z-index: 20; box-shadow: 0 6px 20px rgba(0,0,0,.18); display: flex; flex-direction: column; gap: 2px; }
.user .menu[hidden] { display: none; }
.user .menu a, .user .menu button { appearance: none; text-align: left; font: inherit; font-size: 13px; color: var(--fg); background: none; border: 0; border-radius: 4px; padding: 7px 10px; cursor: pointer; text-decoration: none; display: block; width: 100%; }
.user .menu a:hover, .user .menu button:hover { background: var(--accent-soft); }
.user .menu .sep { height: 1px; background: var(--line); margin: 4px 0; }
.user .menu label { font-size: 12px; color: var(--muted); padding: 4px 10px 0; }
.user .menu select { margin: 2px 10px 6px; }
.role { color: var(--muted); }
.viewas { margin: -20px -16px 12px; position: sticky; top: 0; z-index: 50; background: #b3261e; color: #fff; padding: 10px 16px; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; border-bottom: 3px solid #fff3; }
.viewas[hidden] { display: none; }
.viewas .btn { background: #fff; color: #7a1812; border-color: #fff; font-weight: 600; }
.banner.err { color: var(--bad); font-weight: 600; }
.banner.info { color: var(--warn); }
.bulk { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 10px; margin-bottom: 10px; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 6px; font-size: 12px; }
.bulk[hidden] { display: none; }
td.sel, th.sel { width: 2.2rem; text-align: center; }
td.sel input { width: 16px; height: 16px; cursor: pointer; }
tr.cur td { box-shadow: inset 0 2px 0 var(--accent), inset 0 -2px 0 var(--accent); }
tr.cur td:first-child { box-shadow: inset 2px 0 0 var(--accent), inset 0 2px 0 var(--accent), inset 0 -2px 0 var(--accent); }
tr.picked td { background: var(--accent-soft); }
tr.grp td { background: var(--bg); font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); }
tbody tr.grp:hover td { background: var(--bg); }
.helpbtn { appearance: none; font: inherit; font-weight: 600; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--fg); cursor: pointer; }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.overlay[hidden] { display: none; }
.dialog { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 20px; max-width: 30rem; width: 100%; max-height: 90vh; overflow: auto; }
.dialog h2 { margin: 0 0 10px; font-size: 1.1rem; }
.dialog dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 14px; }
.dialog dt { white-space: nowrap; }
kbd { font: 12px ui-monospace, monospace; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 1px 6px; background: var(--bg); }
.hidecol { display: none; }
@media (max-width: 640px) { .head .right { align-items: flex-start; margin-left: 0; } }

/* ---- Admin ---- */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button { appearance: none; font: inherit; font-size: 13px; color: var(--fg); background: none; border: 1px solid transparent; border-bottom: 0; border-radius: 6px 6px 0 0; padding: 8px 14px; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--panel); border-color: var(--line); font-weight: 600; margin-bottom: -1px; }
.form-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 12px; }
.form-row label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); }
input[type=text], input[type=email], input[type=number] { font: inherit; font-size: 13px; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; min-width: 0; }
table.admin td, table.admin th { padding: 8px 10px; }
table.admin th { font-weight: 600; }
.kv { display: grid; grid-template-columns: minmax(10rem, 16rem) 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.ok { color: var(--good); font-weight: 600; } .bad { color: var(--bad); font-weight: 600; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.checks label { display: inline-flex; gap: 4px; align-items: center; font-size: 12px; color: var(--fg); }
.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 8px 16px; border-radius: 6px; z-index: 200; font-size: 13px; }
.toast.err { background: var(--bad); color: #fff; }
.mono { font-family: ui-monospace, monospace; font-size: 12px; }

.warn { color: var(--warn); font-weight: 600; }
