@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&display=swap');

:root {
  /* Markenfarben von janineiten.ch: Koralle (Akzent) + Fast-Schwarz (Ink) */
  --ink: #0B0B0B;
  --ink-soft: #52514E;
  --paper: #FAFAF7;
  /* Farbiger Seitenhintergrund (statt neutralem Weiss) - dezenter Koralle-
     Wash, damit die weissen Karten sich abheben. */
  --page-bg: #FCF1EE;
  --line: #E3E1DA;
  --accent: #F25244;
  /* Für Text auf hellem Grund: --accent hat nur 3.3:1 Kontrast (ok für
     Flächen/Rahmen, zu wenig für Fliesstext) - --accent-text ist dieselbe
     Farbfamilie, abgedunkelt auf 5.1:1 (WCAG AA). */
  --accent-text: #C23A2E;
  --accent-soft: #FBEAE7;
  --amber: #2A78D6;
  --danger: #C0472C;
  --radius: 20px;
  --radius-sm: 12px;
  /* Einheitlicher Abstand zwischen allen Boxen (Karten, Grids, Sections) */
  --gap: 24px;
  --card-shadow: 0 10px 30px -14px rgba(11, 11, 11, 0.16), 0 2px 6px rgba(11, 11, 11, 0.05);
  --font-display: 'Space Grotesk', 'Segoe UI', sans-serif;
  --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--accent-text); }

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

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  padding: 40px 32px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
}

.login-eyebrow {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--ink-soft);
}

.login-card h1 {
  font-family: var(--font-display);
  font-size: 26px;
  margin: 0 0 28px;
}

.login-error {
  color: var(--danger);
  font-size: 14px;
  margin-bottom: 16px;
}

.login-form { display: flex; flex-direction: column; gap: 6px; }

.login-form label {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 12px;
}

.login-form input {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  background: var(--paper);
}

.login-form input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.login-form button {
  margin-top: 24px;
  padding: 11px;
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

.login-form button:hover { background: var(--accent); }

/* ---------- Dashboard ---------- */

.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0;
  padding: 16px clamp(20px, 4vw, 56px);
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.dash-header-left { display: flex; align-items: center; gap: 16px; }

.dash-header h1 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
}

.header-divider { width: 1px; height: 28px; background: var(--line); flex: 0 0 auto; }

.header-controls { display: flex; align-items: center; gap: 16px; }

/* Pillen (Zeitraum-Auswahl, Optimierung-Button) */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.pill-icon { flex: 0 0 auto; color: var(--ink-soft); }

.pill-select { position: relative; padding-right: 12px; }
.pill-select select {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  padding-right: 4px;
}
.pill-select select:focus { outline: none; }
.pill-select:has(select:focus) { outline: 2px solid var(--accent); outline-offset: 1px; }
.pill-chevron { pointer-events: none; }

.pill-button { background: #fff; color: var(--ink); border-color: var(--line); }
.pill-button:hover { background: var(--paper); }
.pill-button .pill-icon { color: var(--accent-text); }

/* Konto-Chip mit Avatar, öffnet ein Dropdown-Panel (Logout, Version) */
.account-menu { position: relative; }

.account-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  padding: 4px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  cursor: pointer;
}
.account-chip:hover { background: var(--paper); }

.account-avatar {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.account-info { text-align: left; }
.account-name { font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.3; }
.account-domain { font-size: 12px; color: var(--ink-soft); line-height: 1.3; }

.account-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 190px;
  background: #fff;
  border-radius: var(--radius-sm);
  box-shadow: var(--card-shadow);
  border: 1px solid var(--line);
  overflow: hidden;
  z-index: 20;
}
.account-dropdown[hidden] { display: none; }

.account-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
}
.account-dropdown-item:hover { background: var(--paper); }
.account-dropdown-item svg { color: var(--ink-soft); flex: 0 0 auto; }

.account-dropdown-version {
  padding: 9px 14px;
  font-size: 11px;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
}

.section-total {
  font-weight: 400;
  color: var(--ink-soft);
  font-size: 13px;
}

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px clamp(20px, 4vw, 56px) 24px;
}

/* Stat row */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--gap);
  margin-bottom: var(--gap);
}

.stat {
  padding: 20px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
}

.stat .label {
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.stat .value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Key-Event KPI-Karten */

.kpi-section { margin-bottom: var(--gap); }

.kpi-section h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 4px;
}

.kpi-section .kpi-subtitle {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0 0 16px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--gap);
}

.kpi-card {
  position: relative;
  overflow: hidden;
  background: var(--kpi-gradient, var(--accent));
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  padding: 22px 20px 20px;
  color: #fff;
}

/* Dekorative, halbtransparente Kreise im Hintergrund - wie im Referenzbild */
.kpi-card::before,
.kpi-card::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  pointer-events: none;
}

.kpi-card::before {
  width: 150px;
  height: 150px;
  right: -55px;
  bottom: -65px;
}

.kpi-card::after {
  width: 84px;
  height: 84px;
  right: 34px;
  bottom: -42px;
  background: rgba(255, 255, 255, 0.1);
}

.kpi-card-top {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.kpi-card .kpi-label {
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.92);
}

.kpi-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.kpi-card .kpi-value {
  position: relative;
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #fff;
  margin-top: 20px;
}

.kpi-sources {
  position: relative;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.25);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-source-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
}

.kpi-source-count {
  font-variant-numeric: tabular-nums;
  color: #fff;
  font-weight: 600;
}

section.block {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  padding: 28px clamp(20px, 3vw, 32px);
  margin-bottom: var(--gap);
}

section.block h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.section-intro {
  font-size: 16px;
  color: var(--ink-soft);
  margin: -4px 0 16px;
}

/* Info-Icon mit Tooltip-Bubble, z. B. Standort-Hinweis bei "Mitbewerber" */
.info-tip {
  position: relative;
  display: inline-flex;
  vertical-align: middle;
  margin-left: 4px;
  cursor: help;
}
.info-tip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--ink-soft);
  color: var(--ink-soft);
  font-size: 11px;
  font-style: italic;
  font-family: Georgia, 'Times New Roman', serif;
  line-height: 1;
}
.info-tip-bubble {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  width: max-content;
  max-width: 280px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  line-height: 1.4;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  box-shadow: var(--card-shadow);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease;
  z-index: 5;
}
.info-tip-bubble::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--ink);
}
.info-tip:hover .info-tip-bubble,
.info-tip:focus .info-tip-bubble,
.info-tip:focus-visible .info-tip-bubble {
  opacity: 1;
  visibility: visible;
}

.inline-form { margin-bottom: 16px; }
.inline-form select {
  font-family: var(--font-body);
  font-size: 14px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  max-width: 100%;
}
.inline-form select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

tr.own-row { background: var(--accent-soft); font-weight: 600; }

.device-chart-row {
  display: flex;
  align-items: center;
  gap: 40px;
  flex-wrap: wrap;
}

.device-chart-wrap {
  width: 160px;
  height: 160px;
  flex: 0 0 auto;
}

.device-legend {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 160px;
}

.device-legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
}

.device-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.device-name {
  color: var(--ink);
}

.device-value {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: var(--gap);
}

@media (max-width: 760px) {
  .grid-2 { grid-template-columns: 1fr; }
}

table { width: 100%; border-collapse: collapse; font-size: 16px; }
th, td { text-align: left; padding: 9px 4px; border-bottom: 1px solid var(--line); }
th { color: var(--ink-soft); font-weight: 500; font-size: 12px; }
tbody tr:hover { background: var(--page-bg); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.path { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bar-list { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 90px 1fr 50px; align-items: center; gap: 10px; font-size: 16px; }
.bar-track { height: 8px; background: var(--line); position: relative; }
.bar-fill { position: absolute; inset: 0; background: var(--accent); }
.bar-fill-amber { background: var(--amber); }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-soft); }

.empty-note { color: var(--ink-soft); font-size: 16px; }

.source-note {
  margin: 14px 0 0;
  font-size: 11px;
  color: var(--ink-soft);
  opacity: 0.75;
}
.table-note { color: var(--ink-soft); font-size: 13px; margin-top: 10px; }

.health-score-row {
  display: flex;
  align-items: center;
  gap: 20px;
}
.health-score-value {
  font-family: var(--font-display);
  font-size: 48px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.health-score-label { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.health-score-detail { font-size: 13px; color: var(--ink-soft); }
.error-box {
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  background: #FBEDE9;
  color: var(--danger);
  padding: 16px 20px;
  font-size: 16px;
  margin: 32px clamp(20px, 4vw, 56px);
}

/* Skeleton-Grid: Platzhalter während die Seite neu lädt (z. B. nach dem
   Keyword-Wechsel bei "Mitbewerber" oder dem Monatswechsel im Header, die
   beide einen frischen API-Call auslösen). */
.skeleton-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  padding: 24px;
  margin-bottom: var(--gap);
}
.skeleton-card-lg { min-height: 140px; }
.stat-row .skeleton-card { margin-bottom: 0; }
.skeleton-grid { display: flex; flex-direction: column; gap: 14px; padding: 4px 0; }
.skeleton-row {
  height: 20px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--line) 25%, #f2f0ea 50%, var(--line) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton-row { animation: none; }
}

.dash-footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px clamp(20px, 4vw, 56px) 32px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 13px;
}

/* "Optimierung anfragen"-Button (.pill.pill-button, siehe oben) + Modal-Formular */

/* Rechtes Sidesheet statt zentriertem Popup */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 11, 11, 0);
  pointer-events: none;
  transition: background 0.25s ease;
  z-index: 100;
}
.modal-overlay.open {
  background: rgba(11, 11, 11, 0.5);
  pointer-events: auto;
}
.modal-overlay[hidden] { display: none; }

.modal-card {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 100%;
  max-width: 420px;
  background: #fff;
  box-shadow: var(--card-shadow);
  padding: 32px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}
.modal-overlay.open .modal-card { transform: translateX(0); }

.modal-card h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 20px;
}
.modal-card .section-intro { margin: 0 0 20px; }

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  border: none;
  background: none;
  font-size: 22px;
  line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 4px;
}
.modal-close:hover { color: var(--ink); }

.contact-profile {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.contact-profile-photo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 85% 25%;
  flex: 0 0 auto;
}
.contact-profile-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 4px;
}
.contact-profile-link {
  display: block;
  font-size: 13px;
  color: var(--accent-text);
  text-decoration: none;
}
.contact-profile-link:hover { text-decoration: underline; }

@media (prefers-reduced-motion: reduce) {
  .modal-overlay, .modal-card { transition: none; }
}

#contactForm { display: flex; flex-direction: column; gap: 6px; }
#contactForm label {
  display: block;
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 12px;
}
#contactForm select,
#contactForm textarea {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  background: var(--paper);
  color: var(--ink);
  resize: vertical;
}

.contact-hours {
  margin-top: 16px;
  border: none;
  padding: 0;
  display: flex;
  gap: 16px;
}
.contact-hours[hidden] { display: none; }
.contact-hours legend {
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 6px;
  padding: 0;
}
.contact-hours label {
  margin-top: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
}

.contact-status { min-height: 20px; font-size: 13px; margin-top: 14px; }
.contact-status-ok { color: #0ca30c; }
.contact-status-error { color: var(--danger); }

.contact-submit {
  margin-top: 12px;
  padding: 11px;
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}
.contact-submit:hover { background: var(--accent); }
.contact-submit:disabled { opacity: 0.6; cursor: default; }
