/* Stream-Statistik – Gestaltung nach dem Dashboard-Entwurf (docs/design/dashboard) */

@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-display: swap; src: url("fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-display: swap; src: url("fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-display: swap; src: url("fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); }

:root {
  --bg: #F3F4F1;
  --card: #FFFFFF;
  --line: #DCDFDA;
  --line2: #C9CDC7;
  --track: #E7E9E5;
  --seg: #EEF0EC;
  --ink: #15191E;
  --ink2: #3A4148;
  --muted: #535B63;
  --accent: #1F55C0;
  --accent-dark: #163F8F;
  --accent-soft: #E8EEFA;
  --accent2: #C2621A;
  --warn-bg: #FCE9D9;
  --warn-ink: #7A3A0A;
  --sans: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.45; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1 { margin: 0; font-size: 28px; font-weight: 600; letter-spacing: -0.01em; }
h2 { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
code { font-family: var(--mono); font-size: 13px; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.page { max-width: 1320px; margin: 0 auto; padding: 16px 16px 48px; display: flex; flex-direction: column; gap: 16px; }
main { display: flex; flex-direction: column; gap: 16px; }

/* Navigation */
.topnav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; padding: 4px 0 8px; border-bottom: 1px solid var(--line); }
.topnav .brand { font-weight: 600; color: var(--ink); text-decoration: none; }
.topnav .links { display: flex; flex-wrap: wrap; gap: 4px 16px; flex: 1; }
.topnav .links a { color: var(--ink2); text-decoration: none; padding: 6px 0; border-bottom: 2px solid transparent; }
.topnav .links a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.topnav .logout { display: flex; align-items: center; gap: 8px; margin: 0; }
.topnav .who { font-size: 13px; color: var(--muted); }

/* Bausteine */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.note { margin: 0; padding: 10px 12px; background: var(--seg); border-radius: 8px; font-size: 14px; }
.alert { margin: 0; padding: 10px 12px; background: var(--warn-bg); color: var(--warn-ink); border-radius: 8px; font-size: 14px; }
.error { color: #A3260C; font-size: 13px; }
.hints { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--ink2); }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span:first-child, .caption { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.field.wide { width: 100%; }
input, select, textarea { font: inherit; font-size: 15px; color: var(--ink); background: #FFFFFF; border: 1px solid var(--line2); border-radius: 8px; }
input, select { min-height: 44px; padding: 0 10px; }
textarea { padding: 10px; font-family: var(--mono); font-size: 13px; line-height: 1.5; width: 100%; resize: vertical; }
fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
legend { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.two-lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

.button { display: inline-flex; align-items: center; justify-content: center; font: inherit; font-size: 14px; font-weight: 500; min-height: 44px; padding: 0 16px; border: 1px solid var(--line2); border-radius: 8px; background: #FFFFFF; color: var(--ink); cursor: pointer; text-decoration: none; align-self: flex-start; }
.button:hover { border-color: var(--accent); color: var(--ink); }
.button.primary { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }
.button.primary:hover { background: var(--accent-dark); color: #FFFFFF; }
.button.small { min-height: 34px; padding: 0 12px; font-size: 13px; }

/* Anmeldung */
.login { max-width: 420px; margin: 8vh auto 0; display: flex; flex-direction: column; gap: 12px; width: 100%; }

/* Dashboard */
.dash { display: flex; flex-direction: column; gap: 16px; }
.dash-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.dash-head p { margin: 4px 0 0; font-size: 14px; }
.dash-head .program { min-width: 240px; }
.filters { display: flex; flex-direction: column; gap: 16px; }
.filters p { margin: 0; }
.filter-line { display: flex; flex-wrap: wrap; gap: 16px 32px; align-items: flex-end; }
.group { display: flex; flex-direction: column; gap: 6px; }
.group.dates { flex-direction: row; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; background: var(--seg); padding: 4px; border-radius: 10px; }
.seg a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 7px; color: var(--ink2); text-decoration: none; font-size: 14px; font-weight: 500; }
.seg a[aria-current="true"] { background: #FFFFFF; color: var(--ink); }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: end; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.k-label { font-size: 13px; font-weight: 500; color: var(--muted); }
.k-val { font-family: var(--mono); font-size: 26px; font-weight: 500; font-variant-numeric: tabular-nums; }
.k-sub { font-size: 12px; color: var(--muted); }

.chart-card { display: flex; flex-direction: column; gap: 12px; }
.chart-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: baseline; }
.chart-head h2 { font-size: 18px; margin: 0; }
.chart-head span { font-size: 13px; }
.bars { display: grid; grid-template-rows: 240px; border-bottom: 1px solid var(--line2); }
.bar { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; }
.bar span { display: block; background: var(--accent); border-radius: 3px 3px 0 0; }
.bar-labels { display: grid; }
.bar-labels span { font-size: 11px; color: var(--muted); text-align: center; font-family: var(--mono); white-space: nowrap; overflow: visible; }

.list { display: flex; flex-direction: column; gap: 8px; }
.list p { margin: 4px 0 0; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; color: inherit; text-decoration: none; }
a.row:hover { border-color: var(--accent); color: inherit; }
.row.selected { background: var(--accent-soft); border-color: var(--accent); }
.row .name { font-size: 14px; overflow-wrap: anywhere; }
.row .val { font-size: 13px; font-family: var(--mono); color: var(--ink2); white-space: nowrap; }
.row .track { grid-column: 1 / -1; display: block; height: 6px; background: var(--track); border-radius: 3px; overflow: hidden; }
.row .fill { display: block; height: 6px; border-radius: 3px; }
.row .sub { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }

/* Tabellen */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; padding: 8px; border-bottom: 1px solid var(--line2); }
.table td { padding: 8px; border-bottom: 1px solid var(--track); vertical-align: middle; }
.table .num { text-align: right; font-family: var(--mono); white-space: nowrap; }
.table tr.open td { background: #FFF6EE; }
.table select { min-height: 38px; width: 100%; min-width: 160px; }
.table.compact td, .table.compact th { padding: 5px 8px; }
.table .ua { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
section.card > form > button, section.card > form .button { margin-top: 12px; }

/* Benutzer */
form.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
form.inline input { min-height: 34px; width: 170px; }
.table td.actions { white-space: nowrap; }
.table td.actions form + form { margin-left: 4px; }
.table tr.inactive td { color: var(--muted); }
.button.danger { color: #A3260C; }
.button.danger:hover { border-color: #A3260C; color: #A3260C; }
.alert.secret strong { font-family: var(--mono); font-weight: 500; }
.topnav a.who { font-size: 13px; color: var(--muted); text-decoration: none; }
.topnav a.who:hover, .topnav a.who[aria-current="page"] { color: var(--ink); text-decoration: underline; }

.foot { font-size: 12px; color: var(--muted); padding-top: 8px; }
.foot a { color: var(--muted); }

@media (max-width: 640px) {
  h1 { font-size: 24px; }
  .dash-head .program { min-width: 0; width: 100%; }
  .bar-labels span { font-size: 9px; }
}

/* Live */
.live { display: flex; flex-direction: column; gap: 16px; }
.live-chart { width: 100%; height: 220px; display: block; }
.live-axis { display: flex; justify-content: space-between; }
.row.bad { border-color: #E8B7A8; background: #FFF6EE; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-height: 34px; }
.chip { font: inherit; font-size: 13px; min-height: 34px; padding: 0 12px; border: 1px solid var(--accent); border-radius: 17px; background: var(--accent-soft); color: var(--ink); cursor: pointer; }
.chip.clear { border-color: var(--line2); background: #FFFFFF; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button.row { font: inherit; color: inherit; text-align: left; width: 100%; background: #FFFFFF; cursor: pointer; }
button.row:hover { border-color: var(--accent); }
button.row.selected { background: var(--accent-soft); border-color: var(--accent); }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--seg); }
.table tr.selected td { background: var(--accent-soft); }
.table tr.click:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
button.link { font: inherit; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
button.link:hover { text-decoration: underline; }
.table tr.selected td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

.mount-filter { margin-bottom: 8px; }
.check { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 14px; }
.check input { min-height: 0; width: 18px; height: 18px; }

.bulk { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; padding: 12px; margin-bottom: 8px; background: var(--seg); border-radius: 10px; }
.bulk .field { min-width: 200px; }
.bulk-count { font-size: 14px; font-weight: 500; min-height: 44px; display: flex; align-items: center; min-width: 170px; }
.bulk .button[disabled] { opacity: 0.5; cursor: not-allowed; }
.table .pick { width: 36px; }
.table .pick input { width: 18px; height: 18px; min-height: 0; }
.table tr.picked td { background: var(--accent-soft); }
