:root {
  color-scheme: dark;
  --bg: #111214;
  --surface-1: #191a1d;
  --surface-2: #212226;
  --border: #2c2d32;
  --grid: #2a2b30;
  --text-primary: #efefef;
  --text-secondary: #9c9c9c;
  --text-muted: #6f7076;
  --accent: #338ced;
  --accent-soft: rgba(51, 140, 237, .14);
  --good: #0aac23;
  --good-text: #3fcf57;
  --bad: #dc3c3d;
  --bad-text: #ff6b6b;
  --warn: #fbb315;
  --neutral: #383838;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text-primary); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 15px; }
h3 { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.num, td.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.pos { color: var(--good-text); }
.neg { color: var(--bad-text); }
.muted { color: var(--text-secondary); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* Layout */
.topbar {
  display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 56px;
  background: var(--surface-1); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; letter-spacing: .2px; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); }
nav { display: flex; gap: 4px; flex: 1; }
nav a {
  color: var(--text-secondary); padding: 8px 12px; border-radius: 8px; font-weight: 500;
}
nav a:hover { color: var(--text-primary); background: var(--surface-2); text-decoration: none; }
nav a.active { color: var(--text-primary); background: var(--accent-soft); }
.userbox { display: flex; align-items: center; gap: 12px; color: var(--text-secondary); }
main { max-width: 1320px; margin: 0 auto; padding: 24px; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.view-head h1 { font-size: 20px; }

/* Controls */
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
input, select, textarea, button {
  font: inherit; color: var(--text-primary); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { min-height: 80px; resize: vertical; width: 100%; }
button { cursor: pointer; font-weight: 500; }
button:hover { border-color: #44454b; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad-text); }
button.ghost { background: transparent; }
button.sm { padding: 4px 8px; font-size: 12px; }

/* Cards & KPIs */
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; gap: 8px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { color: var(--text-secondary); font-size: 12px; display: flex; gap: 4px; align-items: center; }
.kpi .value { font-family: var(--mono); font-size: 22px; font-weight: 600; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.info { cursor: help; color: var(--text-muted); border: 1px solid var(--border); border-radius: 50%; width: 14px; height: 14px; font-size: 10px; display: inline-flex; align-items: center; justify-content: center; }
.grid-2 { display: grid; grid-template-columns: minmax(0,2fr) minmax(0,1fr); gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; margin-bottom: 16px; }
@media (max-width: 1000px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 200px; }
.card.fill { display: flex; flex-direction: column; }
.card.fill .chart-box { flex: 1; min-height: 260px; height: auto; }

.banner { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; display: flex; gap: 10px; align-items: center; border: 1px solid; }
.banner.bad { background: rgba(220, 60, 61, .12); border-color: rgba(220, 60, 61, .5); }
.banner.warn { background: rgba(251, 179, 21, .1); border-color: rgba(251, 179, 21, .45); }
.banner .icon { font-weight: 700; }

/* Kalender */
.cal-wrap { display: flex; gap: 20px; flex-wrap: wrap; }
.cal-month h3 { margin-bottom: 6px; }
.cal { display: grid; grid-template-columns: repeat(7, 34px); gap: 3px; }
.cal .dow { font-size: 10px; color: var(--text-muted); text-align: center; }
.cal .day {
  height: 34px; border-radius: 6px; background: var(--surface-2); font-size: 10px; color: var(--text-muted);
  display: flex; align-items: flex-start; justify-content: flex-end; padding: 3px 4px; position: relative;
}
.cal .day.has { color: #fff; cursor: default; }
.cal .day:hover .tip { display: block; }
.tip {
  display: none; position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); z-index: 5;
  background: #0b0c0d; border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; white-space: nowrap;
  font-size: 12px; color: var(--text-primary); pointer-events: none;
}
.legend-scale { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-secondary); margin-top: 10px; }
.legend-scale span.sw { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }

/* Tabellen */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--text-secondary); font-weight: 500; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
td.num, th.num { text-align: right; }
tbody tr:hover { background: var(--surface-2); }
tr.clickable { cursor: pointer; }
.badge { display: inline-block; padding: 2px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; border: 1px solid var(--border); color: var(--text-secondary); }
.badge.long { color: var(--good-text); border-color: rgba(10, 172, 35, .45); }
.badge.short { color: var(--bad-text); border-color: rgba(220, 60, 61, .45); }
.badge.warn { color: var(--warn); border-color: rgba(251, 179, 21, .5); }
.badge.open { color: var(--accent); border-color: rgba(51, 140, 237, .5); }
.toggle-table { font-size: 12px; }

/* Formular */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.field label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 5px; }
.field input, .field select { width: 100%; }
.field.wide { grid-column: 1 / -1; }
.preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 16px 0; }
.preview .kpi .value { font-size: 18px; }
.actions { display: flex; gap: 8px; margin-top: 16px; }
.section { margin-bottom: 16px; }
.keybox { font-family: var(--mono); background: #0b0c0d; border: 1px dashed var(--accent); padding: 10px; border-radius: 8px; word-break: break-all; margin-top: 8px; }
pre.code { font-family: var(--mono); background: #0b0c0d; border: 1px solid var(--border); padding: 12px; border-radius: 8px; overflow-x: auto; font-size: 12px; }

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--surface-2); border: 1px solid var(--border); padding: 10px 14px; border-radius: 8px; z-index: 50; }
.toast.err { border-color: var(--bad); }
.empty { color: var(--text-secondary); padding: 30px; text-align: center; }

/* Login */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { width: 340px; }
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card .field { margin-top: 14px; }
.login-card button { width: 100%; margin-top: 18px; }
.err-text { color: var(--bad-text); margin-top: 12px; min-height: 18px; font-size: 13px; }
