/* Hybrid Coach — Oberflaeche fuer Desktop und Mobil.
   Farbrollen als Custom Properties, Dunkelmodus als eigener Satz Schritte
   (nicht als Umkehrung), damit Diagramme auf beiden Flaechen lesbar bleiben. */

:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --plane: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-7: #4a3aa7;

  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --success-text: #006300;

  --radius: 14px;
  --gap: 16px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --plane: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-7: #9085e9;
    --success-text: #0ca30c;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --plane: #0d0d0d;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-7: #9085e9;
  --success-text: #0ca30c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--plane);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

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

/* ----------------------------------------------------------- Grundgeruest */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex: 0 0 220px;
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  font-size: 18px; font-weight: 700; letter-spacing: -0.02em;
  padding: 4px 12px 18px;
}
.brand small { display: block; font-weight: 400; font-size: 12px; color: var(--text-muted); }

.navlink {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  background: none; border: 0; width: 100%; text-align: left;
  color: var(--text-secondary); cursor: pointer; font-size: 14px;
}
.navlink:hover { background: color-mix(in srgb, var(--text-primary) 6%, transparent); }
.navlink[aria-current="page"] {
  background: color-mix(in srgb, var(--series-1) 14%, transparent);
  color: var(--text-primary); font-weight: 600;
}
.navlink .ico { width: 18px; text-align: center; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }

.main { flex: 1; min-width: 0; padding: 24px 28px 64px; }

.topbar {
  display: flex; align-items: baseline; gap: 12px;
  flex-wrap: wrap; margin-bottom: 20px;
}
.topbar h1 { font-size: 24px; margin: 0; letter-spacing: -0.02em; }
.topbar .sub { color: var(--text-muted); font-size: 13px; }
.topbar .spacer { flex: 1; }

.mobilebar { display: none; }

/* ------------------------------------------------------------- Bausteine */

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.card h2 {
  margin: 0 0 4px; font-size: 15px; font-weight: 600;
}
.card .hint { margin: 0 0 14px; font-size: 12.5px; color: var(--text-muted); }

.grid { display: grid; gap: var(--gap); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

.tile .label { font-size: 12px; color: var(--text-muted); text-transform: none; }
.tile .value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; margin-top: 2px; }
.tile .value .unit { font-size: 14px; font-weight: 500; color: var(--text-secondary); margin-left: 3px; }
.tile .delta { font-size: 12.5px; margin-top: 4px; color: var(--text-secondary); }
.delta.up { color: var(--success-text); }
.delta.down { color: var(--critical); }

.hero {
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
}
.hero .figure { font-size: 60px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.hero .verdict {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border);
}
.verdict.go_hard { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--success-text); }
.verdict.steady  { background: color-mix(in srgb, var(--series-1) 16%, transparent); }
.verdict.easy    { background: color-mix(in srgb, var(--warning) 22%, transparent); }
.verdict.rest    { background: color-mix(in srgb, var(--critical) 16%, transparent); color: var(--critical); }
.verdict.no_data { background: color-mix(in srgb, var(--text-muted) 16%, transparent); color: var(--text-secondary); }

.btn {
  padding: 8px 14px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-1);
  color: var(--text-primary); font-size: 13.5px;
}
.btn:hover { background: color-mix(in srgb, var(--text-primary) 5%, transparent); }
.btn.primary { background: var(--series-1); border-color: transparent; color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--critical); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.segmented button {
  border: 0; background: var(--surface-1); padding: 7px 14px;
  cursor: pointer; font-size: 13px; color: var(--text-secondary);
}
.segmented button[aria-pressed="true"] {
  background: color-mix(in srgb, var(--series-1) 16%, transparent);
  color: var(--text-primary); font-weight: 600;
}

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12.5px; color: var(--text-secondary); }
.field input, .field select, .field textarea {
  padding: 9px 11px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--plane);
}
.field textarea { min-height: 74px; resize: vertical; }

.banner {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 14px; border-radius: 10px; font-size: 13px;
  border: 1px solid var(--border); margin-bottom: 16px;
}
.banner.warn { background: color-mix(in srgb, var(--warning) 16%, transparent); }
.banner.crit { background: color-mix(in srgb, var(--critical) 12%, transparent); }

.empty { color: var(--text-muted); font-size: 13px; padding: 16px 0; }

/* ------------------------------------------------------------- Diagramme */

.chart { width: 100%; display: block; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--text-muted); font-size: 11px; }
.chart .lbl { fill: var(--text-secondary); font-size: 11.5px; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { opacity: .13; }
.chart .dot { r: 4; }
.chart .bar { }
.chart .hover-band { fill: transparent; cursor: crosshair; }
.chart .crosshair { stroke: var(--axis); stroke-width: 1; stroke-dasharray: 3 3; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 12.5px; color: var(--text-secondary); }
.legend .item { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 11px; height: 11px; border-radius: 3px; }

.tooltip {
  position: fixed; pointer-events: none; z-index: 60;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 9px; padding: 8px 11px; font-size: 12.5px;
  box-shadow: 0 8px 24px rgba(0,0,0,.16); min-width: 120px;
}
.tooltip .t-date { color: var(--text-muted); margin-bottom: 4px; }
.tooltip .t-row { display: flex; align-items: center; gap: 7px; justify-content: space-between; }
.tooltip .t-row .k { display: inline-flex; align-items: center; gap: 6px; }
.tooltip .t-row .v { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ------------------------------------------------------------- Kalender */

.cal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.cal-head .month { font-size: 17px; font-weight: 650; min-width: 170px; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow {
  font-size: 11.5px; color: var(--text-muted); text-align: center;
  padding-bottom: 4px; font-weight: 600;
}
.cal-day {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 10px; min-height: 92px; padding: 7px; cursor: pointer;
  display: flex; flex-direction: column; gap: 4px;
}
.cal-day:hover { border-color: var(--series-1); }
.cal-day.out { opacity: .38; }
.cal-day.today { border-color: var(--series-1); border-width: 2px; }
.cal-day .dnum { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.cal-day.today .dnum { color: var(--series-1); font-weight: 700; }

.chip {
  font-size: 11px; padding: 3px 6px; border-radius: 6px; line-height: 1.25;
  border-left: 3px solid var(--sport-color, var(--series-1));
  background: color-mix(in srgb, var(--sport-color, var(--series-1)) 13%, transparent);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip.done { opacity: .55; text-decoration: line-through; }

.week-list { display: flex; flex-direction: column; gap: 8px; }
.week-row {
  display: grid; grid-template-columns: 92px 1fr auto; gap: 14px; align-items: center;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px;
}
.week-row.today { border-color: var(--series-1); }
.week-row .wd { font-size: 12.5px; color: var(--text-muted); }
.week-row .wd b { display: block; font-size: 15px; color: var(--text-primary); }
.week-row .desc { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }

/* ----------------------------------------------------------------- Chat */

.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 150px); min-height: 420px; }
.chat-log { flex: 1; overflow-y: auto; padding: 4px 2px 14px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 76ch; padding: 11px 14px; border-radius: 13px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--series-1); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--surface-1); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg .tools { margin-top: 7px; font-size: 11.5px; color: var(--text-muted); }
.chat-input { display: flex; gap: 9px; padding-top: 12px; border-top: 1px solid var(--border); }
.chat-input textarea {
  flex: 1; min-height: 46px; max-height: 160px; padding: 12px;
  border-radius: 11px; border: 1px solid var(--border); background: var(--surface-1); resize: none;
}
.typing { color: var(--text-muted); font-size: 13px; font-style: italic; }

.proposal {
  border: 1px solid var(--series-1); border-radius: 12px; padding: 14px;
  background: color-mix(in srgb, var(--series-1) 7%, transparent); margin-bottom: 12px;
}
.proposal h3 { margin: 0 0 6px; font-size: 13.5px; }
.proposal .why { font-size: 13px; color: var(--text-secondary); margin-bottom: 10px; }
.proposal ul { margin: 0 0 12px; padding-left: 18px; font-size: 12.5px; }
.proposal .actions { display: flex; gap: 8px; }

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

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td {
  text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border);
}
table.data th { color: var(--text-muted); font-weight: 600; font-size: 12px; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }

/* ----------------------------------------------------------------- Login */

.login-wrap { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card { width: 100%; max-width: 340px; }

.hidden { display: none !important; }

/* ------------------------------------------------------------------ Mobil */

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { display: none; }
  .main { padding: 14px 14px 92px; }
  .topbar h1 { font-size: 20px; }
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }

  .mobilebar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: var(--surface-1); border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .mobilebar button {
    flex: 1; border: 0; background: none; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 7px 2px; font-size: 10.5px; color: var(--text-muted);
  }
  .mobilebar button[aria-current="page"] { color: var(--series-1); font-weight: 600; }
  .mobilebar .ico { font-size: 17px; }

  .cal-day { min-height: 62px; padding: 5px; }
  .cal-day .chip { font-size: 9.5px; padding: 2px 4px; }
  .week-row { grid-template-columns: 1fr; gap: 6px; }
  .chat-wrap { height: calc(100vh - 210px); }
  .hero .figure { font-size: 46px; }
}
