/* Kommandozentrale · "Jarvis"-Oberfläche
   Dark Mode, Glasflächen, Neon-Akzent. Die Akzentfarbe (--accent) kommt aus dem Mandanten-Branding. */

:root {
  --accent: #3de1ff;
  --bg: #04070d;
  --bg-2: #0a1322;
  --text: #e6f1ff;
  --muted: #8ea3bf;
  --ok: #3ee6a0;
  --warn: #ffc24b;
  --danger: #ff5d73;
  --info: #7aa8ff;
  --glass: rgba(140, 190, 255, 0.055);
  --glass-2: rgba(140, 190, 255, 0.1);
  --line: color-mix(in srgb, var(--accent) 22%, transparent);
  --line-soft: rgba(150, 190, 240, 0.12);
  --glow: color-mix(in srgb, var(--accent) 35%, transparent);
  --radius: 16px;
  --sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; margin: 0; padding: 0; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.right { text-align: right; }
.pos { color: var(--ok); }
.neg { color: var(--danger); }

/* Hintergrund: Tiefe + feines Raster */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 600px at 12% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 60%),
    radial-gradient(700px 500px at 100% 0%, rgba(122, 100, 255, 0.12), transparent 60%),
    radial-gradient(800px 700px at 60% 110%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 60%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 40%);
}
.backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(140, 200, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(140, 200, 255, 0.045) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at 50% 30%, #000 20%, transparent 75%);
}

/* Grundgerüst */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  border-right: 1px solid var(--line-soft);
  background: rgba(6, 12, 22, 0.6);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; min-height: 40px; }
.brand img { height: 34px; max-width: 120px; object-fit: contain; }
.brand img:not([hidden]) + .brand-mark { display: none; }
.brand-mark {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  border: 2px solid var(--accent);
  box-shadow: 0 0 18px var(--glow), inset 0 0 12px var(--glow);
  background: radial-gradient(circle, var(--accent) 0 22%, transparent 26%);
}
.brand-name { font-weight: 600; letter-spacing: 0.04em; line-height: 1.2; overflow-wrap: anywhere; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px;
  color: var(--muted); border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.nav-item:hover { color: var(--text); background: var(--glass); }
.nav-item.is-active {
  color: var(--text); background: var(--glass-2); border-color: var(--line);
  box-shadow: inset 3px 0 0 var(--accent), 0 0 24px -8px var(--glow);
}
.nav-item.is-active .icon { color: var(--accent); filter: drop-shadow(0 0 6px var(--glow)); }
.nav-label { flex: 1; }
.nav-dot {
  min-width: 9px; height: 9px; border-radius: 9px; background: var(--ok);
  box-shadow: 0 0 8px currentColor; color: var(--ok);
  font: 600 11px/18px var(--mono); text-align: center;
}
.nav-dot:not(:empty) { height: 18px; min-width: 18px; padding: 0 5px; color: #04121a; background: var(--accent); box-shadow: 0 0 10px var(--glow); }
.nav-dot.is-degraded { background: var(--warn); color: var(--warn); }
.nav-dot.is-down { background: var(--danger); color: var(--danger); }
.nav-dot.is-degraded:not(:empty), .nav-dot.is-down:not(:empty) { color: #1a1204; }

.icon { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 28px;
  background: linear-gradient(180deg, rgba(4, 7, 13, 0.92), rgba(4, 7, 13, 0.6));
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar-title { font-size: 20px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.clock { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.clock .mono { font-size: 18px; color: var(--accent); text-shadow: 0 0 12px var(--glow); }
.clock .muted { font-size: 12px; }

.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  font: 600 12px/1 var(--sans); letter-spacing: 0.05em; text-transform: uppercase;
  border: 1px solid currentColor; background: color-mix(in srgb, currentColor 10%, transparent);
  white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
button.pill { cursor: pointer; }
.tone-ok { color: var(--ok); }
.tone-degraded { color: var(--warn); }
.tone-down { color: var(--danger); }
.tone-degraded.pill::before, .tone-down.pill::before { animation: pulse 1.6s ease-in-out infinite; }

.banner {
  margin: 14px 28px 0; padding: 10px 14px; border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  background: color-mix(in srgb, var(--warn) 10%, transparent); color: var(--warn);
}

.view { padding: 22px 28px 60px; display: flex; flex-direction: column; gap: 18px; outline: none; max-width: 1280px; width: 100%; }
.view-body, .view-status, .stack { display: flex; flex-direction: column; gap: 18px; }
.contents { display: contents; }
.view-status:empty { display: none; }

/* Glasflächen */
.panel, .card, .tile, .dialog {
  position: relative;
  background: linear-gradient(160deg, var(--glass-2), var(--glass));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  backdrop-filter: blur(14px) saturate(140%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 18px 40px -22px rgba(0, 0, 0, 0.8);
}
.panel { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.panel::before {
  content: ""; position: absolute; left: 18px; top: -1px; width: 64px; height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent); box-shadow: 0 0 12px var(--glow);
}
.panel-title { font-size: 12px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.card { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; background: rgba(8, 16, 28, 0.55); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }

/* Übersicht */
.overview-top { display: flex; flex-direction: column; gap: 18px; }
.hud-panel { flex-direction: row; align-items: center; gap: 28px; flex-wrap: wrap; }
.hud-wrap { position: relative; width: 210px; height: 210px; flex: none; margin: 0 auto; }
.hud { width: 100%; height: 100%; }
.hud-orbit { fill: none; stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 7; }
.hud-spin { transform-origin: 100px 100px; animation: spin 40s linear infinite; }
.hud-seg { fill: none; stroke-width: 7; stroke-linecap: round; filter: drop-shadow(0 0 5px currentColor); transition: stroke 0.4s; }
.hud-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 2px; }
.hud-state { font: 600 15px/1.2 var(--mono); letter-spacing: 0.14em; text-shadow: 0 0 14px currentColor; }
.hud-sub { font-size: 12px; color: var(--muted); max-width: 110px; }
.hud-side { flex: 1; min-width: 260px; display: flex; flex-direction: column; gap: 12px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.tile { padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; transition: transform 0.15s, border-color 0.15s; }
.tile:hover { transform: translateY(-2px); border-color: var(--line); }
.tile-value { font-size: 34px; line-height: 1.1; color: var(--accent); text-shadow: 0 0 18px var(--glow); }
.tile-label { font-weight: 600; }
.tile-sub { font-size: 13px; color: var(--muted); }
.tile-danger .tile-value { color: var(--danger); text-shadow: 0 0 18px color-mix(in srgb, var(--danger) 40%, transparent); }
.tile-warn .tile-value { color: var(--warn); text-shadow: 0 0 18px color-mix(in srgb, var(--warn) 40%, transparent); }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }

/* Listen */
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 14px; padding: 11px 2px; border-top: 1px solid var(--line-soft); }
.list > .item:first-child { border-top: 0; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 550; overflow-wrap: anywhere; }
.item-sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.item-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.item-time { width: 104px; flex: none; color: var(--muted); font-size: 13px; }
.item.is-done .item-title { text-decoration: line-through; color: var(--muted); }
.day { font-size: 14px; font-weight: 600; letter-spacing: 0.04em; }
.day.is-today { color: var(--accent); }
.bullets { list-style: disc; padding-left: 20px; }
.quote { margin: 8px 0 0; padding: 12px; border-radius: 10px; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line-soft); white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.5 var(--mono); max-height: 260px; overflow: auto; }
details > summary { cursor: pointer; color: var(--muted); }

.check { width: 22px; height: 22px; flex: none; border-radius: 7px; border: 1.5px solid var(--line); background: transparent; cursor: pointer; position: relative; }
.check:hover { border-color: var(--accent); box-shadow: 0 0 10px var(--glow); }
.check.is-on { background: var(--accent); border-color: var(--accent); }
.check.is-on::after { content: ""; position: absolute; left: 6px; top: 2px; width: 6px; height: 11px; border: solid #04121a; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }

.chip {
  display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  color: var(--c, var(--muted)); border: 1px solid color-mix(in srgb, var(--c, var(--muted)) 45%, transparent);
  background: color-mix(in srgb, var(--c, var(--muted)) 12%, transparent);
}
.chip-ok { --c: var(--ok); }
.chip-warn { --c: var(--warn); }
.chip-danger { --c: var(--danger); }
.chip-info { --c: var(--info); }
.chip-accent { --c: var(--accent); }

/* Hinweise */
.notice { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 14px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); background: color-mix(in srgb, var(--c) 10%, transparent); color: var(--c); }
.notice-info { --c: var(--info); }
.notice-warn { --c: var(--warn); }
.notice-error { --c: var(--danger); }
.notice-ok { --c: var(--ok); }
.empty, .loading { padding: 18px 4px; color: var(--muted); }
.loading::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 10px; border-radius: 50%; border: 2px solid var(--accent); border-top-color: transparent; animation: spin 0.8s linear infinite; vertical-align: -1px; }

/* Formulare */
.row { display: flex; align-items: flex-end; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; flex: 1 1 150px; min-width: 0; }
.field-label { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.field-hint { font-size: 12px; color: var(--muted); }
.input {
  width: 100%; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--line-soft); background: rgba(2, 6, 12, 0.6);
  color: var(--text); font: inherit; min-height: 40px;
}
textarea.input { resize: vertical; line-height: 1.5; }
.input:focus-visible, .btn:focus-visible, .check:focus-visible, .tab:focus-visible, .nav-item:focus-visible, .tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); outline: none; }
.input[readonly] { opacity: 0.7; }
.checkline { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; }
.checkline input { width: 18px; height: 18px; accent-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--glass); color: var(--text);
  font: 600 14px/1 var(--sans); cursor: pointer; white-space: nowrap;
  transition: background 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--glass-2); border-color: var(--accent); }
.btn-primary { background: color-mix(in srgb, var(--accent) 18%, transparent); border-color: var(--accent); color: var(--accent); box-shadow: 0 0 22px -8px var(--glow); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 28%, transparent); box-shadow: 0 0 26px -4px var(--glow); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); padding: 8px 10px; }
.btn-ghost:hover { color: var(--text); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.is-busy { position: relative; color: transparent; }
.btn.is-busy::after { content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--accent); border-top-color: transparent; animation: spin 0.7s linear infinite; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { padding: 8px 14px; min-height: 40px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--muted); font: 600 14px var(--sans); cursor: pointer; }
.tab.is-on { color: var(--accent); border-color: var(--line); background: var(--glass-2); }

.dropzone { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 18px; border-radius: 12px; border: 1.5px dashed var(--line); color: var(--text); }
.dropzone > div:first-of-type { flex: 1; min-width: 220px; }
.dropzone .icon { color: var(--accent); filter: drop-shadow(0 0 8px var(--glow)); }
.dropzone.is-over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }

/* Tabellen */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); }
.table tr.is-muted td { color: var(--muted); }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 4px 24px; }
.kv-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--line-soft); color: var(--muted); }
.kv-row strong { color: var(--text); }

/* Dialog & Meldungen */
.dialog { width: min(680px, calc(100vw - 28px)); max-height: calc(100vh - 40px); padding: 0; color: var(--text); background: linear-gradient(160deg, #0d1828, #070d18); border-color: var(--line); overflow: auto; }
.dialog::backdrop { background: rgba(2, 5, 10, 0.72); backdrop-filter: blur(4px); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line-soft); }
.dialog-head h2 { font-size: 17px; overflow-wrap: anywhere; }
.dialog-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 14px; }

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 50; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 36px)); }
.toast { padding: 11px 14px; border-radius: 12px; background: #0c1626; border: 1px solid var(--c, var(--line)); box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.8), 0 0 18px -8px var(--c, var(--glow)); animation: rise 0.2s ease-out; transition: opacity 0.4s; }
.toast.is-leaving { opacity: 0; }
.toast-ok { --c: var(--ok); }
.toast-warn { --c: var(--warn); }
.toast-error { --c: var(--danger); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.35; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

/* Assistent */
.chat-list { display: flex; flex-direction: column; gap: 10px; min-height: 220px; max-height: min(62vh, 760px); overflow-y: auto; padding: 4px 2px; overscroll-behavior: contain; }
.msg { max-width: min(760px, 88%); padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line-soft); background: rgba(8, 16, 28, 0.6); }
.msg-user { align-self: flex-end; background: color-mix(in srgb, var(--accent) 12%, transparent); border-color: var(--line); border-bottom-right-radius: 4px; }
.msg-bot { align-self: flex-start; border-bottom-left-radius: 4px; }
.msg-error { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-time { margin-top: 4px; font-size: 11px; color: var(--muted); text-align: right; }
.msg.is-pending { opacity: 0.75; border-style: dashed; }
.typing { color: var(--muted); }
.typing::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--glow); animation: pulse 1.2s ease-in-out infinite; vertical-align: -1px; }
.action-card { align-self: flex-start; width: min(760px, 100%); border-color: color-mix(in srgb, var(--warn) 35%, var(--line-soft)); }
.action-long { display: flex; flex-direction: column; gap: 2px; grid-column: 1 / -1; padding-top: 6px; border-top: 1px solid var(--line-soft); }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; }
.suggestion { cursor: pointer; font: inherit; font-size: 13px; padding: 6px 12px; white-space: normal; text-align: left; }
.suggestion:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.chat-status:empty { display: none; }
.chat-head { align-items: center; }
.chat-hint { font-size: 13px; }
.action-card .card-head { flex-wrap: wrap; }
.chat-status { display: flex; flex-direction: column; gap: 8px; }
.composer { display: flex; align-items: flex-end; gap: 8px; }
.chat-input { flex: 1; resize: none; min-height: 46px; max-height: 220px; }
.btn.is-recording { color: var(--danger); border-color: var(--danger); animation: pulse 1.2s ease-in-out infinite; }

/* Mobil: Navigation wandert an den unteren Rand */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 10; flex-direction: row; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line-soft); background: rgba(4, 8, 15, 0.92); }
  .brand { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-between; gap: 0; }
  .nav-item { flex-direction: column; gap: 2px; padding: 8px 4px; flex: 1; position: relative; }
  .nav-item.is-active { box-shadow: inset 0 2px 0 var(--accent); }
  .nav-label { display: none; }
  .nav-dot { position: absolute; top: 4px; right: calc(50% - 20px); }
  .topbar { padding: 12px 16px; }
  .topbar-title { font-size: 16px; }
  .clock .muted { display: none; }
  .banner { margin: 12px 16px 0; }
  .view { padding: 16px 16px 110px; }
  .item { flex-wrap: wrap; }
  .item-main { flex-basis: 200px; }
  .item-meta { margin-left: auto; }
  .item-time { width: auto; }
  .toasts { bottom: 84px; }
  /* Am Handy scrollt die Seite; das Eingabefeld bleibt über der Navigation sichtbar */
  .chat-list { max-height: none; min-height: 0; overflow: visible; }
  .composer { position: sticky; bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 4; padding: 10px 0 6px; background: linear-gradient(180deg, transparent, rgba(6, 12, 22, 0.95) 28%); }
  .chat-hint { display: none; }
  .msg { max-width: 94%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; animation-iteration-count: 1 !important; transition: none !important; }
}
