/* =====================================================================
   Pulse – Instrumententafel
   Zwei Signalfarben mit Bedeutung:
     amber = passiert jetzt     cyan = bereits erfasst
   Keine externen Schriften (DSGVO), Zahlen durchgehend monospace.
   ===================================================================== */

:root {
  --ink:    #0D1020;
  --panel:  #161B2E;
  --raise:  #1D2338;
  --line:   #252B44;
  --fg:     #E8EAF4;
  --muted:  #757D9C;
  --dim:    #4A5273;

  --live:   #FFB020;
  --data:   #4FD1E8;
  --good:   #48D597;
  --bad:    #FF5C7A;
  --warn:   #FF8A3D;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "Cascadia Mono", Menlo, Consolas, monospace;

  --rail: 210px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--ink);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--data); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 2px solid var(--live); outline-offset: 2px; border-radius: 2px; }

/* ---------------------------------------------------------------- Rail */

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

.rail {
  width: var(--rail); flex: 0 0 var(--rail);
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}

.brand {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--line);
}
.brand b {
  font-size: 15px; letter-spacing: -0.02em; font-weight: 700;
  display: block;
}
.brand span { font-family: var(--mono); font-size: 10px; color: var(--dim); letter-spacing: .08em; }

.sitepick { padding: 12px; border-bottom: 1px solid var(--line); }
.sitepick select {
  width: 100%; background: var(--raise); color: var(--fg);
  border: 1px solid var(--line); border-radius: 4px;
  padding: 7px 8px; font-family: var(--sans); font-size: 13px;
}

.nav { padding: 8px 0; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 16px; color: var(--muted);
  font-size: 13px; border-left: 2px solid transparent;
}
.nav a:hover { color: var(--fg); background: var(--raise); text-decoration: none; }
.nav a.on { color: var(--fg); border-left-color: var(--live); background: var(--raise); }
.nav a .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .5; }
.nav .sect {
  padding: 14px 16px 5px; font-family: var(--mono);
  font-size: 9px; letter-spacing: .12em; color: var(--dim); text-transform: uppercase;
}

.who {
  padding: 12px 16px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--muted);
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.who form { margin: 0; }
.who button {
  background: none; border: 0; color: var(--dim); cursor: pointer;
  font-family: var(--mono); font-size: 10px; letter-spacing: .06em; padding: 0;
}
.who button:hover { color: var(--bad); }

/* ------------------------------------------------------------- Content */

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Signatur: der Pulsstreifen. 60 Balken = 60 Minuten. Der letzte
   Balken atmet, solange Traffic reinkommt. */
.pulse {
  height: 44px; background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: flex-end; gap: 1px;
  padding: 6px 20px 0; position: relative;
}
.pulse i {
  flex: 1; min-height: 1px; background: var(--data);
  opacity: .35; border-radius: 1px 1px 0 0;
  transition: height .4s ease, opacity .4s ease;
}
.pulse i:last-child { background: var(--live); opacity: 1; animation: breathe 2.2s ease-in-out infinite; }
@keyframes breathe { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

.pulse .read {
  position: absolute; right: 20px; top: 8px;
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  display: flex; gap: 14px; align-items: center;
}
.pulse .read b { color: var(--live); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .pulse i:last-child { animation: none; }
  * { transition: none !important; }
}

.bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.bar h1 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -0.02em; }
.bar .sub { font-family: var(--mono); font-size: 11px; color: var(--dim); }

.ranges { display: flex; gap: 2px; }
.ranges a {
  font-family: var(--mono); font-size: 11px; padding: 5px 9px;
  color: var(--muted); border: 1px solid transparent; border-radius: 3px;
}
.ranges a:hover { color: var(--fg); text-decoration: none; }
.ranges a.on { color: var(--ink); background: var(--data); font-weight: 600; }

.wrap { padding: 20px; display: flex; flex-direction: column; gap: 20px; }

/* ------------------------------------------------------------ KPI-Band */

.kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
}
.kpi { padding: 14px 18px; border-right: 1px solid var(--line); }
.kpi:last-child { border-right: 0; }
.kpi label {
  display: block; font-family: var(--mono); font-size: 9.5px;
  letter-spacing: .1em; text-transform: uppercase; color: var(--dim); margin-bottom: 5px;
}
.kpi .v {
  font-family: var(--mono); font-size: 25px; font-weight: 500;
  letter-spacing: -0.03em; line-height: 1.1;
}
.kpi .d { font-family: var(--mono); font-size: 11px; margin-top: 3px; color: var(--muted); }
.kpi .d.up { color: var(--good); }
.kpi .d.dn { color: var(--bad); }

/* -------------------------------------------------------------- Panels */

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.panel > header {
  padding: 11px 16px; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.panel > header h2 {
  margin: 0; font-size: 12px; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
}
.panel > header .note { font-family: var(--mono); font-size: 10.5px; color: var(--dim); }
.panel .body { padding: 14px 16px; }
.panel .body.flush { padding: 0; }

.grid  { display: grid; gap: 20px; }
.g2    { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.g3    { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.wide  { grid-column: 1 / -1; }

/* --------------------------------------------------------------- Chart */

.chart { width: 100%; height: 180px; display: block; }
.chart .area { fill: var(--data); opacity: .12; }
.chart .stroke { fill: none; stroke: var(--data); stroke-width: 1.5; }
.chart .conv { fill: none; stroke: var(--good); stroke-width: 1.2; stroke-dasharray: 3 3; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart text { fill: var(--dim); font-family: var(--mono); font-size: 9px; }

/* ------------------------------------------------------- Balkenlisten */

.rows { display: flex; flex-direction: column; }
.row {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 6px 16px; font-size: 13px; min-height: 30px;
}
.row + .row { border-top: 1px solid rgba(37,43,68,.5); }
.row .fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--data); opacity: .09; pointer-events: none;
}
.row .lbl {
  position: relative; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row .n { position: relative; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.row .n.main { color: var(--fg); }
.row a { color: inherit; }

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

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th {
  text-align: left; font-family: var(--mono); font-size: 9.5px;
  letter-spacing: .1em; text-transform: uppercase; color: var(--dim);
  padding: 9px 12px; border-bottom: 1px solid var(--line); font-weight: 500;
  position: sticky; top: 0; background: var(--panel); white-space: nowrap;
}
td { padding: 8px 12px; border-bottom: 1px solid rgba(37,43,68,.55); vertical-align: middle; }
tbody tr:hover { background: var(--raise); }
td.mono, th.mono, .mono { font-family: var(--mono); }
td.num { text-align: right; font-family: var(--mono); }
.scroll { max-height: 620px; overflow: auto; }

/* ---------------------------------------------------------------- Tags */

.tag {
  display: inline-block; font-family: var(--mono); font-size: 10px;
  padding: 2px 6px; border-radius: 3px; letter-spacing: .03em;
  background: var(--raise); color: var(--muted); border: 1px solid var(--line);
  white-space: nowrap;
}
.tag.paid    { color: var(--warn);  border-color: rgba(255,138,61,.3); }
.tag.organic { color: var(--good);  border-color: rgba(72,213,151,.3); }
.tag.social  { color: #B98CFF;      border-color: rgba(185,140,255,.3); }
.tag.direct  { color: var(--muted); }
.tag.referral{ color: var(--data);  border-color: rgba(79,209,232,.3); }
.tag.email   { color: #FF9CC8;      border-color: rgba(255,156,200,.3); }
.tag.bot     { color: var(--bad);   border-color: rgba(255,92,122,.35); }
.tag.conv    { color: var(--ink);   background: var(--good); border-color: var(--good); font-weight: 600; }

.pill-live {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 11px; color: var(--live);
}
.pill-live::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--live); animation: breathe 2.2s ease-in-out infinite;
}

/* -------------------------------------------------------------- Journey */

.journey { position: relative; padding-left: 22px; }
.journey::before {
  content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px;
  width: 1px; background: var(--line);
}
.step { position: relative; padding: 7px 0; display: flex; gap: 12px; align-items: baseline; }
.step::before {
  content: ''; position: absolute; left: -19px; top: 13px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--data); box-shadow: 0 0 0 3px var(--panel);
}
.step.pageview::before   { background: var(--data); }
.step.click::before      { background: var(--live); }
.step.rage_click::before { background: var(--bad); }
.step.form_submit::before,
.step.conversion::before { background: var(--good); }
.step .t { font-family: var(--mono); font-size: 10.5px; color: var(--dim); flex: 0 0 62px; }
.step .c { flex: 1; min-width: 0; font-size: 13px; }
.step .c small { color: var(--muted); font-family: var(--mono); font-size: 11px; display: block; word-break: break-all; }

/* --------------------------------------------------------------- Forms */

input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  background: var(--raise); border: 1px solid var(--line); color: var(--fg);
  border-radius: 4px; padding: 7px 9px; font-family: var(--sans); font-size: 13px;
}
input::placeholder { color: var(--dim); }
.btn {
  background: var(--data); color: var(--ink); border: 0; border-radius: 4px;
  padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
  font-family: var(--sans);
}
.btn:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); font-weight: 500; }
.btn.ghost:hover { color: var(--fg); border-color: var(--dim); }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid rgba(255,92,122,.3); font-weight: 500; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input, .filters select { font-size: 12px; padding: 6px 8px; }

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

.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(79,209,232,.07), transparent 60%),
    var(--ink);
}
.login {
  width: 100%; max-width: 340px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 26px;
}
.login h1 { margin: 0 0 3px; font-size: 19px; letter-spacing: -0.02em; }
.login p.lead { margin: 0 0 20px; color: var(--dim); font-family: var(--mono); font-size: 11px; letter-spacing: .06em; }
.login label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 5px; }
.login input { width: 100%; }
.login .btn { width: 100%; margin-top: 18px; padding: 10px; }
.err {
  background: rgba(255,92,122,.1); border: 1px solid rgba(255,92,122,.3);
  color: var(--bad); padding: 9px 11px; border-radius: 4px; font-size: 12.5px; margin-bottom: 14px;
}
.ok {
  background: rgba(72,213,151,.08); border: 1px solid rgba(72,213,151,.25);
  color: var(--good); padding: 9px 11px; border-radius: 4px; font-size: 12.5px;
}

.empty { padding: 60px 20px; text-align: center; color: var(--muted); }
.empty h2 { color: var(--fg); font-size: 16px; margin: 0 0 8px; }
code, pre {
  font-family: var(--mono); font-size: 12px;
  background: var(--raise); border: 1px solid var(--line);
  border-radius: 4px; padding: 2px 5px;
}
pre { padding: 12px; overflow-x: auto; line-height: 1.6; white-space: pre-wrap; word-break: break-all; }

.hint { color: var(--dim); font-size: 12px; margin: 6px 0 0; }

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

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .rail { width: 100%; height: auto; position: static; flex: none; }
  .nav { display: flex; flex-wrap: wrap; padding: 4px; }
  .nav .sect { display: none; }
  .nav a { border-left: 0; border-bottom: 2px solid transparent; padding: 8px 12px; }
  .nav a.on { border-left: 0; border-bottom-color: var(--live); }
  .kpi { border-right: 0; border-bottom: 1px solid var(--line); }
  .wrap { padding: 12px; gap: 12px; }
  .pulse { padding: 6px 12px 0; }
  .pulse .read { position: static; margin-left: auto; }
}

/* Sekundärwert in Balkenlisten: fest ausgerichtet, damit die
   Hauptzahl rechts immer an derselben Stelle steht. */
.row .n.sec {
  flex: 0 0 auto; min-width: 62px; text-align: right;
  color: var(--dim); font-size: 11px;
}
.row .n.main { flex: 0 0 auto; min-width: 46px; text-align: right; }
