/* Joe Dashboard - helle Arbeitsoberfläche, Karten, Board. Farben als Tokens, Dunkelmodus separat definiert. */
:root {
  --page: #F4F6FA; --surface: #FFFFFF; --surface-2: #F7F9FC; --border: #E4E8EF; --border-strong: #CBD2DD;
  --text: #0F172A; --text-2: #475569; --muted: #7C8798;
  --primary: #2a78d6; --primary-soft: #E3EEFB; --primary-text: #1C5CAB;
  --good: #0ca30c; --good-soft: #E3F5E3; --warn: #fab219; --warn-soft: #FFF4D6;
  --orange: #ec835a; --orange-soft: #FDEAE1; --red: #d03b3b; --red-soft: #FBE3E3;
  --violet: #6C5CE7; --violet-soft: #ECE9FB;
  --chart-revenue: #2a78d6; --chart-adspend: #eb6834; --grid: #E1E0D9; --axis: #C3C2B7;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 4px 16px rgba(15,23,42,.05);
  --radius: 14px; --gutter: 16px; --sidebar: 250px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #0F1420; --surface: #171D2B; --surface-2: #1F2736; --border: #2A3345; --border-strong: #3A455C;
    --text: #E8ECF3; --text-2: #B6C0D1; --muted: #8B96AA;
    --primary: #3987e5; --primary-soft: #1B2B46; --primary-text: #86B6EF;
    --good: #0ca30c; --good-soft: #14301A; --warn: #fab219; --warn-soft: #3A2E10;
    --orange: #ec835a; --orange-soft: #3A2318; --red: #e66767; --red-soft: #3A1B1B;
    --violet: #9085e9; --violet-soft: #26224A;
    --chart-revenue: #3987e5; --chart-adspend: #d95926; --grid: #2C2C2A; --axis: #383835;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --page: #0F1420; --surface: #171D2B; --surface-2: #1F2736; --border: #2A3345; --border-strong: #3A455C;
  --text: #E8ECF3; --text-2: #B6C0D1; --muted: #8B96AA; --primary: #3987e5; --primary-soft: #1B2B46; --primary-text: #86B6EF;
  --good-soft: #14301A; --warn-soft: #3A2E10; --orange-soft: #3A2318; --red: #e66767; --red-soft: #3A1B1B; --violet: #9085e9; --violet-soft: #26224A;
  --chart-revenue: #3987e5; --chart-adspend: #d95926; --grid: #2C2C2A; --axis: #383835; --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--page); color: var(--text); font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100dvh; }
a { color: inherit; text-decoration: none; }
h1 { font-size: 24px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0; }
h3 { font-size: 14px; margin: 0; }
small, .muted { color: var(--muted); }
.hidden { display: none !important; }
button { font: inherit; }

/* ---- Rahmen ---- */
.shell { display: flex; min-height: 100dvh; }
.sidebar { width: var(--sidebar); flex: none; background: var(--surface); border-right: 1px solid var(--border); padding: 18px 14px; position: sticky; top: 0; height: 100dvh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 12px; }
.brand small { display: block; font-size: 11px; line-height: 1.2; }
.logo { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--primary); color: #fff; font-weight: 800; font-size: 17px; flex: none; }
.me { display: flex; align-items: center; gap: 10px; padding: 8px 6px 14px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.me small { display: block; font-size: 11px; }
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--violet-soft); color: var(--violet); font-weight: 700; flex: none; }
.navgroup { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 12px 8px 4px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--text-2); font-weight: 500; }
.nav a i { font-style: normal; width: 20px; text-align: center; opacity: .8; }
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--primary-soft); color: var(--primary-text); }
.nav a .count { margin-left: auto; }
.nav a .dot { margin-left: auto; }
.count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.count:empty { display: none; }
.count.red { background: var(--red); color: #fff; border-color: var(--red); }
.count.orange { background: var(--orange); color: #fff; border-color: var(--orange); }
#closeNav { display: none; margin-left: auto; }
.backdrop { display: none; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 12px var(--gutter); background: var(--surface); border-bottom: 1px solid var(--border); }
#openNav { display: none; }
.search { flex: 1; max-width: 480px; display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 7px 12px; color: var(--muted); }
.search input { flex: 1; border: 0; background: transparent; color: var(--text); font: inherit; outline: none; min-width: 0; }
.topactions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
#bell .count { position: absolute; top: -4px; right: -4px; }
main { padding: 22px var(--gutter) 40px; max-width: 1280px; width: 100%; }

/* ---- Bausteine ---- */
.pagehead { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.pagehead .sub { color: var(--muted); margin-top: 2px; }
.pagehead .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: 10px; padding: 8px 14px; font-size: 13px; font-weight: 500; cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.ok { border-color: var(--good); color: var(--good); } .btn.bad { border-color: var(--red); color: var(--red); }
.btn:disabled { opacity: .5; cursor: default; }
.iconbtn { position: relative; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font-size: 16px; }
.iconbtn.ghost { border: 0; background: transparent; }
.iconbtn.rec { background: var(--red); border-color: var(--red); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }

.tabsbar { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 6px 0 18px; overflow-x: auto; }
.tabsbar button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 12px; color: var(--muted); font-weight: 500; cursor: pointer; white-space: nowrap; }
.tabsbar button.active { color: var(--primary-text); border-bottom-color: var(--primary); }
.tabsbar button b { margin-left: 6px; }

.grid { display: grid; gap: 14px; }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card.link { cursor: pointer; transition: transform .12s, box-shadow .12s; }
.card.link:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(15,23,42,.08); }
.card > h2, .card > h3 { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: 12px; color: var(--muted); }
.kpi .delta.up { color: #006300; } .kpi .delta.down { color: var(--red); }
.section { margin-top: 22px; }
.section > h2 { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.section > h2 .more { font-size: 13px; color: var(--primary-text); font-weight: 500; }

.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); white-space: nowrap; }
.pill.blue { background: var(--primary-soft); color: var(--primary-text); border-color: transparent; }
.pill.good { background: var(--good-soft); color: #006300; border-color: transparent; }
.pill.orange { background: var(--orange-soft); color: #B3481F; border-color: transparent; }
.pill.red { background: var(--red-soft); color: var(--red); border-color: transparent; }
.pill.violet { background: var(--violet-soft); color: var(--violet); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: #7A5200; border-color: transparent; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; display: inline-block; }
.dot.good { background: var(--good); } .dot.red { background: var(--red); } .dot.orange { background: var(--orange); } .dot.warn { background: var(--warn); }

.progress { height: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--primary); border-radius: 6px; }

.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.item.compact { padding: 8px 10px; font-size: 13px; }
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 600; }
.item .sub { font-size: 12px; color: var(--muted); white-space: pre-wrap; }
.item .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.item.red { border-left: 4px solid var(--red); } .item.orange { border-left: 4px solid var(--orange); } .item.info { border-left: 4px solid var(--primary); }
.sev { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-weight: 800; font-size: 13px; flex: none; }
.sev.red { background: var(--red); color: #fff; } .sev.orange { background: var(--orange); color: #fff; } .sev.info { background: var(--primary-soft); color: var(--primary-text); }
.empty { color: var(--muted); font-size: 13px; padding: 10px 2px; }
.example { font-size: 12px; color: #7A5200; background: var(--warn-soft); border: 1px solid transparent; border-radius: 10px; padding: 8px 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.example .btn { margin-left: auto; }

/* ---- Board ---- */
.board { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; }
.col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; min-height: 160px; }
.col > h3 { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; }
.col > h3 .count { margin-left: 2px; }
.col .cardt { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; box-shadow: var(--shadow); }
.cardt .t { font-weight: 600; margin-bottom: 4px; }
.cardt .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 11px; color: var(--muted); }
.cardt .who { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-text); font-weight: 700; font-size: 11px; }
.cardt .actions { margin-top: 8px; display: flex; gap: 6px; }
.addrow { display: flex; gap: 8px; margin-top: 10px; }
.addrow input, .addrow select { flex: 1; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: 10px; padding: 8px 10px; font: inherit; min-width: 0; }

/* ---- Diagramme ---- */
.chart { position: relative; }
.chart svg { width: 100%; height: 190px; display: block; }
.chart .legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); margin-top: 6px; }
.chart .legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.tooltip { position: fixed; z-index: 30; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; padding: 8px 10px; font-size: 12px; box-shadow: 0 6px 20px rgba(15,23,42,.15); pointer-events: none; }
.tooltip b { display: block; }

/* ---- Chat ---- */
.chatwrap { display: flex; flex-direction: column; height: calc(100dvh - 140px); min-height: 420px; }
.messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px 10px; }
.msg { max-width: 82%; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); }
.msg.user { align-self: flex-end; background: var(--primary); color: #fff; border-color: var(--primary); border-bottom-right-radius: 4px; }
.msg.user .who { color: rgba(255,255,255,.75); }
.msg.assistant { align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.agent { align-self: flex-start; background: var(--good-soft); border-color: transparent; }
.msg.system { align-self: center; background: transparent; border: 0; box-shadow: none; color: var(--red); font-size: 12px; }
.msg .who { display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.msg.thinking { color: var(--muted); font-style: italic; }
.composer { display: flex; gap: 8px; align-items: flex-end; padding-top: 10px; border-top: 1px solid var(--border); }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: 12px; padding: 10px 12px; font: inherit; max-height: 140px; }
.composer .btn.primary { width: 44px; height: 40px; padding: 0; border-radius: 12px; font-size: 18px; }
.composer-hints { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); padding-top: 6px; }
.toggle { display: flex; align-items: center; gap: 6px; cursor: pointer; }

/* ---- Mobile ---- */
.tabs { display: none; }
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.25); }
  .sidebar.open { transform: none; }
  #closeNav { display: inline-block; }
  .backdrop.show { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 39; }
  #openNav { display: inline-block; }
  main { padding-bottom: 90px; }
  .tabs { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); z-index: 20; }
  .tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 6px; color: var(--muted); font-size: 11px; position: relative; }
  .tabs a i { font-style: normal; font-size: 18px; }
  .tabs a.active { color: var(--primary-text); }
  .tabs a .count { position: absolute; top: 2px; right: 18%; }
  .board { grid-template-columns: repeat(4, 78vw); }
  .chatwrap { height: calc(100dvh - 200px); }
  .kpi .value { font-size: 22px; }
  /* Kopfleiste darf nie breiter als der Bildschirm werden (sonst rutscht die ganze Seite seitlich) */
  .topbar { gap: 8px; }
  .search { min-width: 0; }
  .topactions { gap: 6px; flex: none; }
}
@media (max-width: 600px) {
  .live > span { display: none; }          /* nur der Punkt bleibt: gruen = verbunden */
  .topactions .avatar { display: none; }
  .search { padding: 7px 10px; }
  .search > span { display: none; }
}

/* Login */
.overlay { position: fixed; inset: 0; background: var(--page); display: grid; place-items: center; z-index: 50; padding: var(--gutter); }
.card.login { width: min(360px, 100%); display: flex; flex-direction: column; gap: 10px; }
.card.login input { border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); border-radius: 10px; padding: 12px; font: inherit; }
.error { color: var(--red); font-size: 13px; min-height: 1em; margin: 0; }

/* ---- Geruest v3: Briefing, Wartet auf dich, Ampel, Phasen, Aktivitaet, Live ---- */
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--good); display: inline-block; animation: livepulse 2s infinite; }
.live.off i { background: var(--red); animation: none; }
@keyframes livepulse { 50% { opacity: .35; } }
.briefing { border-left: 4px solid var(--primary); }
.briefing p { margin: 6px 0; white-space: pre-wrap; }
.ampel { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.ampel.rot { background: var(--red-soft); color: var(--red); } .ampel.gelb { background: var(--warn-soft); color: #7A5200; } .ampel.gruen { background: var(--good-soft); color: #006300; }
.ampel i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: currentColor; }
.attention .item { border-left: 4px solid var(--red); }
.attention .item.task { border-left-color: var(--primary); }
.age { font-size: 11px; color: var(--muted); white-space: nowrap; }
.steps { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 8px; }
.steps span { flex: 1; min-width: 96px; text-align: center; font-size: 12px; padding: 8px 6px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.steps span.done { color: var(--text-2); border-color: var(--border-strong); }
.steps span.current { background: var(--primary-soft); color: var(--primary-text); border-color: transparent; font-weight: 700; }
.org { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.org .card.geplant { opacity: .72; border-style: dashed; }
.activity .item { align-items: center; }
.activity .kind { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); min-width: 92px; }
