/* BUILD Verwaltung – dunkle, warme Oberfläche im Stil moderner KI-Werkzeuge:
   warmes Dunkelgrau, etwas hellere Karten mit weichen Ecken, ein warmer
   Akzentton, feine Linien, Strichsymbole. Inhalt bleibt dicht und sachlich. */

:root {
  --bg: #1f1e1d;
  --surface: #262624;
  --surface-2: #30302e;
  --surface-3: #3b3a37;
  --border: #383733;
  --border-strong: #4a4844;
  --text: #f2f0ea;
  --invert: #f2f0ea;
  --invert-hover: #dbd8d0;
  --muted: #a39e93;
  --accent: #d97757;
  --accent-hover: #e08a65;
  --accent-soft: #3a2a22;
  --ok: #6fb492;
  --warn: #e0a36a;
  --danger: #e0685c;
  --danger-soft: #3a2422;
  --chart-2: #8fa2c0;
  --chart-3: #7fb495;
  --chart-4: #d9b36c;
  --chart-5: #b195ba;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px rgb(0 0 0 / 28%);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100svh;
  padding-bottom: 48px;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.5 var(--font);
  letter-spacing: -.005em;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

a { color: inherit; }
.muted, .dim { color: var(--muted); }

.icon {
  width: 16px;
  height: 16px;
  flex: none;
}

/* --- Kopfzeile ----------------------------------------------------------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px clamp(16px, 3vw, 28px);
  border-bottom: 1px solid var(--border);
  background: rgb(31 30 29 / 88%);
  backdrop-filter: blur(8px);
}

.bar__id {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -.01em;
  text-decoration: none;
  transition: background-color 140ms ease;
}

.bar__id:hover { background: var(--accent-hover); }

.bar__env {
  color: var(--muted);
  font-size: 13px;
}

.bar__right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.bar__who {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* --- Knöpfe und Felder ---------------------------------------------------- */

button,
input {
  font: inherit;
  color: inherit;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

.btn:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.btn:active:not(:disabled) { background: var(--surface-3); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn[data-tone="accent"] {
  border-color: transparent;
  background: var(--accent);
  color: #fff;
}

.btn[data-tone="accent"]:hover:not(:disabled) { background: var(--accent-hover); }

.btn[data-tone="blue"] {
  border-color: transparent;
  background: var(--invert);
  color: var(--bg);
}

.btn[data-tone="blue"]:hover:not(:disabled) { background: var(--invert-hover); }

.btn[data-tone="red"] { color: var(--danger); }
.btn[data-tone="red"]:hover:not(:disabled) { background: var(--danger-soft); border-color: #6a3b35; }

.btn[data-armed="true"] {
  border-color: transparent;
  background: var(--danger);
  color: var(--bg);
}

.btn--step {
  width: 32px;
  height: 32px;
  padding: 0;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}

input[type="text"],
input[type="password"],
input[type="search"] {
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input::placeholder { color: #7d786e; }

input:focus-visible,
button:focus-visible,
a:focus-visible,
tr:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

input:focus-visible { outline-offset: 0; border-color: var(--accent); }

.status {
  min-height: 1.3em;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.status[data-tone="error"] { color: var(--danger); }
.status[data-tone="ok"] { color: var(--ok); }

kbd {
  padding: 2px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font: 500 11px/1.4 var(--mono);
}

/* --- Anmeldung ------------------------------------------------------------ */

.login {
  display: grid;
  place-items: center;
  padding: clamp(48px, 10vh, 120px) 20px;
}

.login__card {
  width: min(100%, 400px);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login__card h1 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -.02em;
}

.login__lead {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 14px;
}

.login__form { display: grid; gap: 14px; }

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.field input { width: 100%; }
.login__form .btn { justify-content: center; padding: 10px 14px; font-size: 14px; }

/* --- Seitengerüst ---------------------------------------------------------- */

.panel-main {
  display: grid;
  gap: 16px;
  max-width: 1560px;
  margin: 0 auto;
  padding: 20px clamp(16px, 3vw, 28px) 0;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.metric {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.metric b {
  display: block;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -.03em;
}

.metric span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12.5px;
}

.metric[data-accent="true"] {
  border-color: #5a3c2e;
  background: var(--accent-soft);
}

.metric[data-accent="true"] b { color: var(--accent-hover); }

.block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.block__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.block__head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -.01em;
  text-transform: none;
}

.block__head .grow { flex: 1; }
.block__head input[type="search"] { width: min(300px, 40vw); }

.create {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.create label {
  color: var(--muted);
  font-size: 13px;
}

.create input { width: 240px; }

.hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12.5px;
}

/* --- Chips ---------------------------------------------------------------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 5px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.chip:hover { background: var(--surface-2); color: var(--text); }

.chip[aria-pressed="true"] {
  border-color: transparent;
  background: var(--invert);
  color: var(--bg);
}

.chips--small .chip { padding: 4px 9px; font-size: 12px; }

/* --- Tabelle -------------------------------------------------------------- */

.table-scroll {
  max-height: 46vh;
  overflow-y: auto;
}

.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.grid thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.grid th[data-sort]:hover { color: var(--text); }
.grid th[data-active="true"] { color: var(--accent-hover); }
.grid th[data-active="true"]::after { content: " ↑"; font-size: 10px; }
.grid th[data-active="true"][data-dir="desc"]::after { content: " ↓"; }

.grid td {
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: middle;
}

.grid tbody tr { cursor: pointer; transition: background-color 100ms ease; }
.grid tbody tr:hover { background: var(--surface-2); }
.grid tbody tr:last-child td { border-bottom: 0; }

.grid tbody tr[aria-selected="true"] {
  background: var(--accent-soft);
  box-shadow: inset 2px 0 0 var(--accent);
}

.cell-nr { width: 32px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cell-name { max-width: 240px; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.cell-card,
.cell-code { font-family: var(--mono); font-size: 12.5px; letter-spacing: -.02em; }
.cell-card { color: var(--muted); }
.cell-code { color: var(--accent-hover); }
.cell-when { color: var(--muted); font-size: 12.5px; }
.cell-actions { width: 1%; }
.cell-actions .btn + .btn { margin-left: 6px; }
.cell-points { font-variant-numeric: tabular-nums; }

tr[data-kind="key"] .cell-name { color: var(--muted); font-weight: 400; }

.bar-dots {
  display: inline-flex;
  gap: 3px;
  margin-right: 8px;
  vertical-align: -2px;
}

.bar-dots i {
  width: 8px;
  height: 14px;
  border-radius: 3px;
  background: var(--surface-3);
}

.bar-dots i[data-on="true"] { background: var(--accent); }
tr[data-full="true"] .bar-dots i[data-on="true"] { background: var(--ok); }

.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.tag[data-tone="free"] { background: #2b313b; color: #9fb2d4; }
.tag[data-tone="full"] { background: #25342c; color: var(--ok); }
.tag[data-tone="prepared"] { background: #3a3323; color: var(--chart-4); }
.tag[data-tone="blocked"] { background: var(--danger-soft); color: var(--danger); }

.empty {
  padding: 22px 16px;
  color: var(--muted);
  text-align: center;
}

/* --- Zwei Spalten ---------------------------------------------------------- */

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr);
  gap: 16px;
  align-items: start;
}

.split--even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

.column {
  display: grid;
  gap: 16px;
  align-content: start;
}

/* --- Detail ---------------------------------------------------------------- */

.detail__body { padding: 6px 16px 16px; }

.placeholder {
  margin: 0;
  padding: 40px 16px;
  color: var(--muted);
  text-align: center;
}

.line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.line:last-child { border-bottom: 0; }

.line__label {
  width: 96px;
  flex: none;
  color: var(--muted);
  font-size: 12.5px;
}

.line__value { font-size: 14px; }
.line__value--accent { color: var(--accent-hover); font-family: var(--mono); font-size: 13px; }
.line input[type="text"] { flex: 1; min-width: 180px; max-width: 320px; }

.points-line { gap: 12px; }

.points-line .score {
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.set-list {
  display: inline-flex;
  gap: 4px;
}

.set-list .btn {
  width: 30px;
  height: 30px;
  padding: 0;
  justify-content: center;
  font-size: 13px;
}

.set-list .btn[aria-pressed="true"] {
  border-color: transparent;
  background: var(--accent);
  color: #fff;
}

/* --- Listen: Log und Historie ---------------------------------------------- */

.log,
.history {
  max-height: 280px;
  margin: 0;
  padding: 8px 16px 12px;
  overflow-y: auto;
  list-style: none;
  font-size: 13px;
}

.log li,
.history li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.log li:last-child,
.history li:last-child { border-bottom: 0; }

.log time,
.history time {
  flex: none;
  min-width: 96px;
  color: var(--muted);
  font-size: 12.5px;
}

.history .delta {
  flex: none;
  width: 30px;
  color: var(--ok);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.history li[data-delta="-1"] .delta { color: var(--danger); }
.history li[data-kind="reward"] .delta { color: var(--accent-hover); }
.log .what { font-weight: 500; }
.log .who,
.history .who { color: var(--muted); }

/* --- Woche und System ------------------------------------------------------ */

.week {
  margin: 0;
  padding: 12px 16px;
  list-style: none;
}

.week li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 3px 0;
  font-size: 13px;
}

.week__day { width: 54px; flex: none; color: var(--muted); }

.week__track {
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.week__fill {
  display: block;
  height: 100%;
  min-width: 3px;
  border-radius: 999px;
  background: var(--accent);
}

.week__n { width: 28px; flex: none; text-align: right; font-variant-numeric: tabular-nums; }

.system {
  padding: 8px 16px 14px;
  font-size: 13px;
}

.sys-line {
  display: flex;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.sys-line:last-child { border-bottom: 0; }
.sys-label { flex: 1; color: var(--muted); }
.sys-value { text-align: right; font-weight: 500; }
.sys-value[data-tone="warn"] { color: var(--danger); }
.sys-value[data-tone="ok"] { color: var(--ok); }

/* --- Analyse ---------------------------------------------------------------- */

.range-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12.5px;
}

.legend__dot {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  background: var(--accent);
}

.legend__dot--extra { margin-left: 8px; background: var(--chart-2); }

.chart-box { padding: 16px; }

.chart-cols {
  display: grid;
  grid-template-columns: repeat(var(--count), minmax(0, 1fr));
  gap: 3px;
  align-items: end;
  height: 160px;
  overflow: visible;
}

.chart-col {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
  min-width: 0;
}

.chart-col__bar {
  position: relative;
  display: block;
  min-height: 2px;
  border-radius: 4px 4px 2px 2px;
  background: var(--surface-3);
  transition: background-color 120ms ease;
}

.chart-col:hover .chart-col__bar,
.chart-col[data-peak="true"] .chart-col__bar { background: var(--accent); }

.chart-col__extra {
  position: absolute;
  inset: auto 0 0 0;
  display: block;
  border-radius: 2px;
  background: var(--chart-2);
}

.chart-col__label {
  margin-top: 6px;
  overflow: visible;
  color: var(--muted);
  font-size: 11px;
  text-align: left;
  white-space: nowrap;
}

.chart-rows {
  margin: 0;
  padding: 0;
  list-style: none;
}

.chart-rows li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  font-size: 13px;
}

.chart-rows__label {
  width: 140px;
  flex: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-rows__track {
  flex: 1;
  height: 12px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.chart-rows__fill {
  display: block;
  height: 100%;
  min-width: 3px;
  border-radius: 999px;
  background: var(--accent);
}

.chart-rows__value { width: 44px; flex: none; text-align: right; font-variant-numeric: tabular-nums; }
.chart-rows__note { width: 78px; flex: none; color: var(--muted); text-align: right; }

/* Linie */

.chart-line__svg {
  display: block;
  width: 100%;
  height: 200px;
  overflow: visible;
}

.chart-line__grid { stroke: var(--border); stroke-width: 1; }
.chart-line__tick { fill: var(--muted); font: 11px var(--font); }

.chart-line__area { fill: var(--accent); fill-opacity: .18; }

.chart-line__stroke {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.chart-line__dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart-line__hit { fill: transparent; }
.chart-line__hit:hover { fill: var(--text); fill-opacity: .06; }

.chart-line__labels {
  display: grid;
  grid-template-columns: repeat(var(--count), minmax(0, 1fr));
  margin-top: 8px;
  padding-left: 30px;
  color: var(--muted);
  font-size: 11px;
}

.chart-line__labels span { white-space: nowrap; }

/* Ring */

.chart-donut {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 24px;
}

.chart-donut__svg { width: 180px; height: 180px; flex: none; }
.chart-donut__track { fill: none; stroke: var(--surface-2); stroke-width: 22; }

.chart-donut__arc {
  fill: none;
  stroke-width: 22;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-width 120ms ease;
}

.chart-donut__arc:hover { stroke-width: 26; }

.chart-donut__total {
  fill: var(--text);
  font: 600 24px var(--font);
  text-anchor: middle;
}

.chart-donut__caption {
  fill: var(--muted);
  font: 12px var(--font);
  text-anchor: middle;
}

.chart-donut__legend {
  flex: 1;
  min-width: 200px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
}

.chart-donut__legend li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.chart-donut__legend li:last-child { border-bottom: 0; }

.chart-donut__dot {
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 3px;
}

.chart-donut__label { flex: 1; }
.chart-donut__value { font-variant-numeric: tabular-nums; font-weight: 500; }
.chart-donut__share { width: 46px; color: var(--muted); text-align: right; }

.notes {
  margin: 0;
  padding: 12px 16px 16px 34px;
  font-size: 13.5px;
  line-height: 1.7;
}

.notes li { padding: 2px 0; }
.notes li::marker { color: var(--accent); }

/* --- Nur PC ---------------------------------------------------------------- */

.handheld {
  display: none;
  margin: 0;
  padding: 80px 24px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 899px) {
  .login,
  .panel-main,
  .bar__right { display: none !important; }
  .handheld { display: block; }
}

@media (max-width: 1180px) {
  .split,
  .split--even { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 1ms !important; }
}
