:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #687083;
  --line: #e3e6ec;
  --accent: #1f9e8f;
  --danger: #c8443a;
  --gap: #fbeaea;
  --gap-line: #e9a7a1;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 2px 8px rgba(20, 30, 50, .04);
  /* Kosten: Fixkosten, OpenRouter, OpenAI (geprueft auf Farbsehschwaeche, hell und dunkel getrennt) */
  --cost-fixed: #2a78d6;
  --cost-openrouter: #eb6834;
  --cost-openai: #1baf7a;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --card: #1b2029;
    --text: #e6e9ef;
    --muted: #949cad;
    --line: #2c3340;
    --accent: #3cc2b1;
    --danger: #ef6d62;
    --gap: #3a2326;
    --gap-line: #8a4a46;
    --shadow: none;
    --cost-fixed: #3987e5;
    --cost-openrouter: #d95926;
    --cost-openai: #199e70;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
/* hidden muss auch gegen display:flex der Leisten gewinnen */
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, input, select { font: inherit; color: inherit; }
button {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--danger); }
button.small { padding: 2px 8px; font-size: 13px; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px;
  padding: 12px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.sections { display: flex; gap: 2px; padding: 3px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.sections button { border: 0; background: none; font-weight: 650; font-size: 16px; padding: 4px 14px; border-radius: 7px; }
.sections button.active { background: var(--accent); color: #fff; }
#time-actions { display: flex; gap: 8px; }
.top-actions form { margin: 0; }
button.ghost { background: none; border-color: transparent; color: var(--muted); }
button.ghost:hover { color: var(--text); border-color: var(--line); }
.tabs { display: flex; gap: 4px; }
.tabs button.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.datenav { display: flex; align-items: center; gap: 6px; }
#range-label { margin-left: 6px; font-weight: 600; }
.top-actions { margin-left: auto; display: flex; gap: 8px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
button:disabled { opacity: .55; cursor: wait; }
.recording { background: var(--danger) !important; border-color: var(--danger) !important; color: #fff; }
dialog textarea, .work-day textarea { width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; resize: vertical; }
dialog label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.teller { display: flex; flex-direction: column; gap: 8px; }
.proposal { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.proposal input { margin-top: 4px; }
.proposal small { display: block; color: var(--muted); }
.transcript { background: var(--bg); border-radius: 8px; padding: 8px 10px; color: var(--muted); font-size: 14px; }
.ai { color: #8a5cf6; }
.work-day { border-top: 1px solid var(--line); padding: 12px 0; display: grid; grid-template-columns: 170px 1fr 1fr; gap: 12px; }
.work-day:first-of-type { border-top: 0; }
.work-day .nums { font-variant-numeric: tabular-nums; }
.work-day .nums b { font-size: 18px; }
.work-day .field-head { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.work-day.empty { opacity: .55; }
#projects .chip { margin: 0 6px 6px 0; }
#projects select, .actions input, .actions select { padding: 4px 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); }
.actions input { flex: 1; min-width: 160px; }
.project-group { margin-bottom: 10px; }
@media (max-width: 860px) { .work-day { grid-template-columns: 1fr; } }

/* Kosten */
.note:empty { display: none; }
.note { margin: -6px 0 16px; }
td.wrap { white-space: normal; text-align: left; min-width: 220px; max-width: 460px; }
td.left, th.left { text-align: left; }
td.wrap small { display: block; color: var(--muted); }
@media (max-width: 600px) { .opt { display: none; } td.wrap { min-width: 180px; } }

/* Anmeldung */
.login { max-width: 380px; margin: 12vh auto 0; padding: 0 16px; }
.login form { display: flex; flex-direction: column; gap: 10px; padding: 24px; }
.login h1 { margin: 0; font-size: 22px; }
.login .hint { margin: 0 0 4px; }
.login .error:empty { display: none; }
.login label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.login input { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font-size: 16px; }
.login button { margin-top: 6px; padding: 9px 12px; }

main { max-width: 1280px; margin: 0 auto; padding: 20px 24px 40px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 10px; font-size: 15px; }
.grid2 { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; align-items: start; margin-bottom: 16px; }
.grid2 > .card, .col > .card { margin-bottom: 0; }
.col { display: flex; flex-direction: column; gap: 16px; }
.grid2 > *, .col > *, .card { min-width: 0; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 45%), 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: 12px; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }

#timeline svg { width: 100%; height: auto; display: block; }
#timeline .block { cursor: pointer; }
#timeline .block:hover { opacity: .8; }
#timeline .gap { fill: var(--gap); stroke: var(--gap-line); stroke-dasharray: 3 3; cursor: pointer; }
#timeline text { fill: var(--muted); font-size: 16px; }
#timeline .row-label { fill: var(--muted); font-size: 17px; }
#timeline .grid { stroke: var(--line); }
#timeline .now { stroke: var(--danger); stroke-width: 2; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; color: var(--muted); font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .time { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; min-width: 92px; }
.list .what { flex: 1; min-width: 0; }
.list .what small { color: var(--muted); display: block; overflow-wrap: anywhere; }
.list .empty { color: var(--muted); }
.list li.clickable { cursor: pointer; }
.list li.clickable:hover .what { color: var(--accent); }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }
.tag { font-size: 12px; color: var(--muted); }
.warn { color: var(--danger); }

.chart { position: relative; height: 260px; }
.chart.tall { height: 340px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.sub { color: var(--muted); font-size: 13px; margin: -4px 0 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 6px 10px; border-top: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 500; border-top: 0; }
.bar { height: 6px; border-radius: 3px; background: var(--accent); }

dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--text); padding: 20px; width: min(560px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .35); }
dialog h2 { margin: 0 0 12px; font-size: 17px; }
dialog label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); margin-bottom: 10px; flex: 1; }
dialog input, dialog select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); }
dialog .row { display: flex; gap: 10px; flex-wrap: wrap; }
dialog .actions { display: flex; gap: 8px; margin-top: 8px; }
.spacer { flex: 1; }
.error { color: var(--danger); min-height: 1em; margin: 4px 0; font-size: 14px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; }
#toast.show { opacity: 1; }
footer { text-align: center; color: var(--muted); font-size: 12px; padding: 0 0 24px; }

@media (max-width: 600px) {
  .top { padding: 10px 16px; }
  main { padding: 16px; }
  .top-actions { margin-left: 0; }
}
