/* Villa Kasandra · Besucher — Aurora-Palette (Teal/Gold/Creme), mobile-first. */

:root {
  --ink: #16302e;
  --teal: #0e4f49;
  --teal-soft: #2f7d74;
  --gold: #b8924a;
  --gold-deep: #96743a;
  --gold-soft: #d9bd84;
  --paper: #f6f1e6;
  --card: #fffdf8;
  --line: #e8e0cd;
  --muted: #82897f;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Geist", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(217, 189, 132, 0.18), transparent 60%),
    radial-gradient(900px 420px at -10% 0%, rgba(47, 125, 116, 0.08), transparent 55%),
    var(--paper);
  min-height: 100vh;
}

.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* ── Wortmarke ── */
.wordmark {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.35rem;
  letter-spacing: 0.01em;
  color: var(--teal);
  white-space: nowrap;
}
.wordmark i {
  font-style: italic;
  background: linear-gradient(100deg, var(--gold-deep), var(--gold-soft));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ── Login-Gate ── */
.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate-card {
  width: min(360px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 40px 32px 32px;
  text-align: center;
  box-shadow: 0 24px 60px -30px rgba(22, 48, 46, 0.35);
}
.gate-sub {
  margin: 6px 0 26px;
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}
.gate-card input {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  margin-bottom: 12px;
}
.gate-card input:focus { outline: 2px solid var(--teal-soft); outline-offset: 1px; }
.btn {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 10px;
  background: var(--teal);
  color: #fdfaf2;
  cursor: pointer;
}
.btn:hover { background: var(--teal-soft); }
.btn:disabled { opacity: 0.6; cursor: wait; }
.gate-err { min-height: 1.2em; margin-top: 10px; font-size: 0.85rem; color: var(--gold-deep); }

/* ── Layout ── */
.wrap {
  max-width: 880px;
  margin: 0 auto;
  padding: clamp(14px, 3vw, 28px) clamp(14px, 3vw, 24px) 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 6px 2px 18px;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-tag {
  font-size: 0.66rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
}
.controls { display: flex; align-items: center; gap: 10px; }

.seg {
  display: flex;
  background: rgba(22, 48, 46, 0.06);
  border-radius: 999px;
  padding: 3px;
}
.seg button {
  font: inherit;
  font-size: 0.8rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.seg button.active { background: var(--card); color: var(--teal); box-shadow: 0 1px 4px rgba(22,48,46,0.18); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--teal);
  cursor: pointer;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { border-color: var(--gold-soft); }

/* ── Live-Leiste ── */
.livebar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.9rem;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  margin-bottom: 18px;
}
.livebar b { color: var(--teal); }
.livebar-note { margin-left: auto; color: var(--muted); font-size: 0.74rem; }
.pulse {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--teal-soft);
  position: relative;
  flex: none;
}
.pulse.on::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2px solid var(--teal-soft);
  animation: pulse 1.8s ease-out infinite;
}
.pulse.off { background: var(--line); }
@keyframes pulse {
  from { transform: scale(0.5); opacity: 0.9; }
  to   { transform: scale(1.6); opacity: 0; }
}

/* ── KPI-Karten ── */
.kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 18px 14px;
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--gold-soft), transparent 70%);
}
.kpi .label { font-size: 0.7rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.kpi .val {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.9rem, 6vw, 2.6rem);
  line-height: 1.15;
  color: var(--teal);
  margin: 4px 0 2px;
}
.kpi.gold .val { color: var(--gold-deep); }
.kpi .sub { font-size: 0.74rem; color: var(--muted); }

/* ── Karten ── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px clamp(16px, 3vw, 24px);
  margin-bottom: 18px;
  box-shadow: 0 18px 50px -42px rgba(22, 48, 46, 0.5);
}
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.card h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.15rem;
  margin: 0;
  color: var(--teal);
}
.hint { margin: 3px 0 0; font-size: 0.76rem; color: var(--muted); }

.legend { display: flex; gap: 14px; font-size: 0.76rem; color: var(--muted); }
.legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
.dot.gold { background: var(--gold); }
.dot.teal { background: var(--teal-soft); }

/* ── Chart ── */
.chart-card { position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--ink);
  color: #f6f1e6;
  font-size: 0.76rem;
  line-height: 1.5;
  padding: 7px 11px;
  border-radius: 9px;
  transform: translate(-50%, -110%);
  white-space: nowrap;
  z-index: 5;
}
.tooltip b { color: var(--gold-soft); }

/* ── Länder / Listen ── */
.geo-row {
  display: grid;
  grid-template-columns: 34px minmax(90px, 160px) 1fr 48px;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(232, 224, 205, 0.6);
}
.geo-row:last-child { border-bottom: 0; }
.flagbox {
  width: 30px; height: 22px;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(22, 48, 46, 0.14);
  display: grid;
  place-items: center;
  background: #fff;
  font-size: 0.6rem;
  color: var(--muted);
}
.flagbox img { width: 100%; height: 100%; object-fit: cover; display: block; }
.geo-name { font-size: 0.9rem; }
.geo-count { text-align: right; font-family: var(--font-display); font-size: 1.05rem; color: var(--teal); }

.bartrack { height: 7px; border-radius: 99px; background: rgba(22, 48, 46, 0.07); overflow: hidden; }
.barfill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold-soft));
  transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.barfill.teal { background: linear-gradient(90deg, var(--teal), var(--teal-soft)); }

.list-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(232, 224, 205, 0.6);
}
.list-row:last-child { border-bottom: 0; }
.list-row .name { font-size: 0.88rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .name.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.78rem; }
.list-row .v { font-family: var(--font-display); color: var(--teal); }
.list-row .track { grid-column: 1 / -1; }

.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.duo .card { margin-bottom: 18px; }

.empty { padding: 18px 0; color: var(--muted); font-size: 0.86rem; }

/* ── Geräte-Chips ── */
.devices { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.device-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.84rem;
}
.device-chip b { font-family: var(--font-display); color: var(--teal); font-weight: 500; }

.foot { margin-top: 18px; font-size: 0.74rem; line-height: 1.6; color: var(--muted); }

/* ── Lade-Skeleton ── */
.skeleton {
  border-radius: 10px;
  background: linear-gradient(100deg, rgba(22,48,46,0.05) 40%, rgba(22,48,46,0.1) 50%, rgba(22,48,46,0.05) 60%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  color: transparent !important;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Einblend-Choreografie ── */
.reveal { animation: rise 0.55s cubic-bezier(0.22, 1, 0.36, 1) backwards; }
.reveal:nth-of-type(2) { animation-delay: 0.06s; }
.reveal:nth-of-type(3) { animation-delay: 0.12s; }
.reveal:nth-of-type(4) { animation-delay: 0.18s; }
.reveal:nth-of-type(5) { animation-delay: 0.24s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .reveal { animation: none; }
  .pulse.on::after { animation: none; }
  .barfill { transition: none; }
}

/* ── Mobil ── */
@media (max-width: 680px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpis .kpi:first-child { grid-column: 1 / -1; }
  .duo { grid-template-columns: 1fr; gap: 0; }
  .geo-row { grid-template-columns: 34px minmax(70px, 1fr) 1fr 44px; gap: 9px; }
  .livebar-note { display: none; }
}
