/* Sepp WebUI – dunkles, dezentes Sci-Fi-Design, mobile-first */
:root {
  --bg: #070b12;
  --bg-2: #0c1220;
  --panel: rgba(14, 22, 38, 0.75);
  --panel-border: rgba(34, 211, 238, 0.14);
  --text: #e6edf6;
  --muted: #8b9bb4;
  --accent: #22d3ee;
  --accent-2: #14b8a6;
  --accent-dim: rgba(34, 211, 238, 0.18);
  --warn: #f5b942;
  --ok: #34d399;
  --danger: #f87171;
  --radius: 14px;
  --glow: 0 0 18px rgba(34, 211, 238, 0.25);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --tabbar-h: 60px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(34, 211, 238, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(20, 184, 166, 0.08), transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(rgba(34, 211, 238, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, 0.035) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse at center, rgba(0,0,0,0.6), transparent 80%);
}
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 0.78rem; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ---------- Login ---------- */
.login {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 20px;
  background: rgba(7, 11, 18, 0.92);
  backdrop-filter: blur(6px);
}
.login-card {
  width: min(100%, 380px);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 28px 24px;
  box-shadow: var(--glow), 0 20px 60px rgba(0,0,0,0.5);
  display: flex; flex-direction: column; gap: 8px;
  text-align: center;
}
.login-logo { font-size: 44px; filter: drop-shadow(0 0 12px rgba(34,211,238,0.5)); }
.login-card h1 { margin: 0; font-size: 1.6rem; letter-spacing: 0.08em; }
.login-card label { text-align: left; font-size: 0.8rem; color: var(--muted); margin-top: 8px; }
.login-card input {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--panel-border); background: var(--bg-2); color: var(--text);
  font-size: 1rem;
}
#login-error { color: var(--danger); margin: 4px 0 0; min-height: 1em; }
.btn {
  padding: 12px 16px; border-radius: 10px; border: 1px solid var(--panel-border);
  background: var(--bg-2); margin-top: 6px; transition: box-shadow .2s, transform .1s;
}
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #041014; font-weight: 600; border: none; margin-top: 16px; }
.btn.primary:hover { box-shadow: var(--glow); }
.btn.ghost:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }

/* ---------- App shell ---------- */
.app {
  position: relative; z-index: 1;
  height: 100dvh; height: 100vh;
  display: flex; flex-direction: column;
}
@supports (height: 100dvh) { .app { height: 100dvh; } }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(7, 11, 18, 0.7);
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { font-size: 22px; filter: drop-shadow(0 0 8px rgba(34,211,238,0.6)); }
.brand-name { font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; font-size: 0.95rem; }
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 0.72rem; color: var(--muted); margin-left: 6px; }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.conn.online .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.conn.offline .dot { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.topbar-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; font-size: 18px; display: grid; place-items: center;
}
.icon-btn:hover { border-color: var(--panel-border); background: var(--accent-dim); }
.icon-btn[aria-pressed="false"] { opacity: 0.45; }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr; }
.panel {
  display: none; min-height: 0; flex-direction: column;
  padding: 12px 14px calc(12px + var(--tabbar-h) + var(--safe-b));
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.panel.is-active { display: flex; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.panel h2 { margin: 0; font-size: 0.85rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); }
.sub { font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; }

/* ---------- Chat ---------- */
.panel-chat { padding-bottom: calc(6px + var(--tabbar-h) + var(--safe-b)); }
.messages { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px; }
.msg { max-width: 86%; padding: 10px 14px; border-radius: 16px; font-size: 0.97rem; white-space: pre-wrap; word-wrap: break-word; animation: pop .18s ease-out; }
.msg.user { align-self: flex-end; background: linear-gradient(135deg, rgba(34,211,238,0.28), rgba(20,184,166,0.22)); border: 1px solid rgba(34,211,238,0.3); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--panel-border); border-bottom-left-radius: 4px; }
.msg.system { align-self: center; font-size: 0.78rem; color: var(--muted); background: transparent; }
.msg .meta { display: block; font-size: 0.68rem; color: var(--muted); margin-top: 4px; }
@keyframes pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.typing { display: flex; gap: 4px; padding: 6px 12px; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: .4; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100% { opacity: .25; } 40% { opacity: 1; } }

.composer {
  display: flex; align-items: flex-end; gap: 8px; margin-top: 8px;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 22px; padding: 6px;
  box-shadow: 0 0 0 1px transparent; transition: box-shadow .2s;
}
.composer:focus-within { box-shadow: 0 0 0 1px var(--accent), var(--glow); }
.composer textarea {
  flex: 1; resize: none; border: none; background: transparent; color: var(--text);
  font: inherit; font-size: 1rem; padding: 9px 6px; max-height: 140px; line-height: 1.4;
}
.composer textarea:focus { outline: none; }
.mic, .send { width: 40px; height: 40px; border-radius: 50%; border: none; display: grid; place-items: center; font-size: 17px; flex-shrink: 0; }
.mic { background: var(--bg-2); border: 1px solid var(--panel-border); }
.mic.listening { background: var(--danger); color: #fff; animation: pulse 1.2s infinite; }
.mic.recording { background: var(--warn); color: #000; animation: pulse 1.2s infinite; }
.mic:disabled { opacity: .35; cursor: not-allowed; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(248,113,113,.5); } 100% { box-shadow: 0 0 0 12px rgba(248,113,113,0); } }
.send { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #041014; }
.stt-status { font-size: 0.75rem; color: var(--muted); padding: 4px 12px 0; }

/* ---------- Agents ---------- */
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.agent {
  position: relative; background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius);
  padding: 12px; display: flex; flex-direction: column; gap: 6px; min-height: 120px; transition: border-color .3s, box-shadow .3s;
}
.agent.working { border-color: rgba(34,211,238,0.5); box-shadow: var(--glow); }
.agent.waiting { border-color: rgba(245,185,66,0.4); }
.agent-top { display: flex; align-items: center; gap: 8px; }
.agent-emoji { font-size: 20px; }
.agent-name { font-weight: 600; font-size: 0.95rem; }
.agent-role { font-size: 0.7rem; color: var(--muted); margin-top: -4px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: .08em; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.agent.working .status .dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: blink 1.4s infinite; }
.agent.waiting .status .dot { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.agent.working .status { color: var(--accent); }
.agent.waiting .status { color: var(--warn); }
.agent-task { font-size: 0.82rem; min-height: 2.4em; }
.agent-foot { display: flex; justify-content: space-between; font-size: 0.7rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 4px; border-radius: 2px; background: rgba(255,255,255,0.06); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width .6s ease; }
.agent.idle .bar { opacity: .3; }

.activity { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.activity li { display: grid; grid-template-columns: 52px 1fr; gap: 8px; font-size: 0.82rem; padding: 6px 8px; border-left: 2px solid var(--panel-border); animation: pop .25s ease-out; }
.activity li time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.75rem; }
.activity li b { color: var(--accent); font-weight: 600; }
.activity li.warn { border-left-color: var(--warn); }
.activity li.ok { border-left-color: var(--ok); }

/* ---------- Today ---------- */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.list li { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 12px; padding: 10px 12px; font-size: 0.9rem; }
.list .when { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 600; min-width: 48px; font-size: 0.85rem; }
.list .title { flex: 1; }
.list .where, .list .note { display: block; font-size: 0.75rem; color: var(--muted); }
.badge { font-size: 0.66rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--panel-border); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
.badge.open { color: var(--accent); border-color: rgba(34,211,238,.4); }
.badge.waiting { color: var(--warn); border-color: rgba(245,185,66,.4); }
.badge.done { color: var(--ok); border-color: rgba(52,211,153,.4); }
.list li.done .title { text-decoration: line-through; color: var(--muted); }
.alarm-toggle { width: 38px; height: 22px; border-radius: 11px; background: rgba(255,255,255,.08); border: 1px solid var(--panel-border); position: relative; padding: 0; }
.alarm-toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform .2s, background .2s; }
.alarm-toggle[aria-checked="true"] { background: rgba(34,211,238,.25); border-color: var(--accent); }
.alarm-toggle[aria-checked="true"]::after { transform: translateX(16px); background: var(--accent); box-shadow: 0 0 6px var(--accent); }

/* ---------- Tabbar (mobile) ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: rgba(7, 11, 18, 0.85); backdrop-filter: blur(12px);
  border-top: 1px solid var(--panel-border);
}
.tab { background: transparent; border: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 20px; }
.tab span { font-size: 0.68rem; letter-spacing: .06em; text-transform: uppercase; }
.tab.is-active { color: var(--accent); text-shadow: 0 0 10px rgba(34,211,238,.6); }

/* ---------- Desktop: drei Spalten ---------- */
@media (min-width: 960px) {
  .tabbar { display: none; }
  .layout { grid-template-columns: minmax(380px, 1.4fr) 1fr minmax(280px, 0.8fr); gap: 0; }
  .panel { display: flex; padding: 16px 18px; border-right: 1px solid var(--panel-border); }
  .panel:last-child { border-right: none; }
  .panel-chat { padding-bottom: 14px; }
  .agent-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
  .msg { max-width: 78%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
