:root {
  --bg: #F5F5F7;
  --surface: #FFFFFF;
  --text: #1D1D1F;
  --text-muted: #6E6E73;
  --accent: #0066CC;
  --accent-dark: #004C99;
  --border: #E5E5EA;
  --green: #1F9254;
  --green-bg: #E9F7EF;
  --yellow: #B7791F;
  --yellow-bg: #FFF7E6;
  --red: #D6392E;
  --red-bg: #FDEAE9;
  --unknown: #86868B;
  --unknown-bg: #F0F0F2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.06);
  --font-body: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-heading: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

/* Globale Absicherung: das [hidden]-Attribut muss IMMER gewinnen, auch wenn
   eine Klasse wie .btn (display:inline-flex) sonst gleiche Spezifitaet hat.
   Das hat bereits zweimal zu unsichtbar-sein-sollenden Elementen gefuehrt,
   die trotzdem angezeigt wurden - daher hier einmalig zentral geloest statt
   an jeder einzelnen Stelle einzeln. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4,
.topbar-title, .card-title, .summary-card .num, .detail-header h1,
.login-card h1, .btn, .chip {
  font-family: var(--font-heading);
}

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

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

/* Gleiche max-width/Seitenabstand wie .container, damit Topbar-Inhalt und
   Seiteninhalt (z. B. die Website-Kacheln) exakt linksbuendig fluchten. */
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
}

.topbar-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}
.topbar-title:hover { text-decoration: none; }

.topbar-icon { width: 26px; height: 26px; display: block; border-radius: 6px; }

.topbar-actions { display: flex; align-items: center; gap: 12px; position: relative; flex: 0 0 auto; }

/* --- Konto-Dropdown --- */
.account-menu { position: relative; }
.account-menu-trigger { display: inline-flex; align-items: center; gap: 6px; }
.account-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 260px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.16);
  border: 1px solid var(--border);
  overflow: hidden;
  z-index: 50;
}
.account-menu-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.account-menu-head strong { display: block; font-size: 15px; color: var(--text); }
.account-menu-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.account-menu-list { padding: 6px; }
.account-menu-item-form { margin: 0; }
.account-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: none;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}
.account-menu-item:hover { background: var(--bg); text-decoration: none; }
.account-menu-item svg { flex-shrink: 0; color: var(--text-muted); }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--text);
  color: #fff;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.05s ease;
}
.btn:hover { background: #000; text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn.secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #b32e25; }
.btn.small { padding: 6px 14px; font-size: 13px; }

/* --- Summary bar --- */
.summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}
.summary-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  text-align: center;
}
.summary-card .num { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.summary-card .label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.summary-card.total .num { color: var(--text); }

/* Drei-Kachel-Variante (Detailseite: Uptime 24h/7T/30T) - eigene Klasse
   statt Inline-Style, damit die Responsive-Regel unten sauber greift. */
.summary-3col { grid-template-columns: repeat(3, 1fr); }
.summary-card.ok .num { color: var(--green); }
.summary-card.warning .num { color: var(--yellow); }
.summary-card.down .num { color: var(--red); }

/* --- Filter-/Suchleiste --- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}
.filter-search {
  flex: 1 1 220px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
}
.filter-search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.chip:hover { background: var(--bg); }
.chip.active { background: var(--text); color: #fff; border-color: var(--text); }
.filter-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 30px 0;
}

/* --- Website cards grid --- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  border-left: 5px solid var(--unknown);
  transition: transform 0.1s ease;
}
.card-link { display: block; color: inherit; }
.card-link[hidden] { display: none; }
.card:hover { transform: translateY(-2px); }
.card.status-green { border-left-color: var(--green); }
.card.status-yellow { border-left-color: var(--yellow); }
.card.status-red { border-left-color: var(--red); }
.card.status-unknown { border-left-color: var(--unknown); }
.card.inactive { opacity: 0.55; }

.card-thumb {
  margin: -20px -20px 14px;
  height: 110px;
  overflow: hidden;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--bg);
}
.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  display: block;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}
.card-title { font-size: 16px; font-weight: 700; }
.card-url { font-size: 13px; color: var(--text-muted); word-break: break-all; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.badge.status-green { background: var(--green-bg); color: var(--green); }
.badge.status-yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge.status-red { background: var(--red-bg); color: var(--red); }
.badge.status-unknown { background: var(--unknown-bg); color: var(--unknown); }

.badge-row { margin-top: 8px; }

.card-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
  margin: 14px 0;
  font-size: 13px;
}
.metric-label { color: var(--text-muted); }
.metric-value { font-weight: 600; }

.uptime-row {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.uptime-row strong { color: var(--text); font-weight: 700; }

.card-error {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--red);
  background: var(--red-bg);
  padding: 8px 10px;
  border-radius: 8px;
  word-break: break-word;
}

.card-footer {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* --- Forms --- */
.form-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  max-width: 560px;
}
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input[type="text"],
.field input[type="url"],
.field input[type="number"],
.field input[type="email"],
.field input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 40px; }
.pw-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
}
.pw-toggle:hover { background: var(--bg); color: var(--text); }
.hint, .field .hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: 16px; height: 16px; }

.errors {
  background: var(--red-bg);
  color: var(--red);
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 18px;
  font-size: 14px;
}
.errors ul { margin: 0; padding-left: 18px; }

.success-msg {
  background: var(--green-bg);
  color: var(--green);
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 18px;
  font-size: 14px;
}

/* --- Detail page --- */
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 22px;
}
.detail-header h1 { margin: 0 0 4px; font-size: 24px; }
.detail-header .url { color: var(--text-muted); font-size: 14px; }

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.panel h2 { font-size: 16px; margin: 0 0 14px; }

/* --- Zugangsdaten: strukturierte Zeilen --- */
.icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--bg);
  color: var(--accent);
  vertical-align: -7px;
  margin-right: 6px;
}
.access-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.access-rows { display: flex; flex-direction: column; }
.access-row {
  display: grid;
  grid-template-columns: 140px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.access-row:last-child { border-bottom: none; }
.access-label { color: var(--text-muted); font-size: 13px; }
.access-value { word-break: break-word; }
.access-value.access-empty { color: var(--text-muted); }
.access-value code, .access-inline-reveal code {
  background: var(--bg);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 13px;
  letter-spacing: 1px;
}
.access-row-btns { display: flex; gap: 2px; }
/* Dezente, randlose Icon-Buttons (Kopieren/Anzeigen/Löschen) - nur ein
   sanfter Hover-Hintergrund statt sichtbarer Box, naeher an der Vorlage. */
.access-copy, .access-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
}
.access-copy:hover, .access-icon-btn:hover { background: var(--bg); color: var(--text); }
.access-copy.copied { color: var(--green); }
.btn.copied { background: var(--green) !important; border-color: var(--green) !important; color: #fff !important; }
.pill {
  display: inline-block;
  background: var(--bg);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}
.access-inline-reveal { margin-left: 10px; font-size: 13px; color: var(--text-muted); }

.access-add-row { border-bottom: none; padding-top: 6px; grid-template-columns: 1fr; }
.access-add-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 0;
  font-family: inherit;
}
.access-add-trigger:hover { text-decoration: underline; }

.access-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.access-meta { font-size: 12px; color: var(--text-muted); }
.notes-display {
  background: var(--bg);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 13.5px;
  color: var(--text);
  white-space: pre-wrap;
  margin-top: 10px;
}

/* Wiederverwendete Bearbeiten-Formular-Box (Zugangsdaten, Notizen) */
.cred-edit-form {
  margin-top: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.cred-edit-form .field { margin-bottom: 10px; }
.cred-edit-form .field label { font-size: 12px; }

.chart-svg {
  width: 100%;
  height: 120px;
  display: block;
}
.chart-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

table.history {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.history th, table.history td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.history th { color: var(--text-muted); font-weight: 600; font-size: 12px; }
.history-wrapper { overflow-x: auto; }

.incident-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.incident-row:last-child { border-bottom: none; }
.incident-cause { color: var(--text-muted); margin-top: 2px; }

.screenshot-wrap img {
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: block;
}

.actions-row { display: flex; gap: 10px; flex-wrap: wrap; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

/* --- Login --- */
.login-wrap {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: url("/public/img/login-bg.webp") center center / cover no-repeat;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
}
.login-card h1 { font-size: 20px; margin: 0 0 6px; }
.login-card p.sub { color: var(--text-muted); font-size: 13.5px; margin: 0 0 22px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 6px; }

/* --- Responsive (iPhone etc.) --- */
@media (max-width: 640px) {
  .summary { grid-template-columns: repeat(2, 1fr); }
  .summary-3col { grid-template-columns: 1fr; }
  .topbar-inner {
    padding: 10px 14px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .topbar-title { font-size: 16px; }
  .topbar-actions { justify-content: flex-start; flex-wrap: wrap; gap: 8px; }
  .topbar-actions form { margin: 0 !important; }
  .container { padding: 18px 14px 40px; }
  .grid { grid-template-columns: 1fr; }
  .card-metrics { grid-template-columns: 1fr 1fr; }
  .form-card { padding: 20px; }
  .detail-header { flex-direction: column; }

  /* Dropdown wuerde relativ zum (jetzt schmalen, umgebrochenen) Trigger
     nach links ueber den Rand hinausragen - auf Mobile stattdessen relativ
     zur vollen Breite der (umgebrochenen) Aktionsleiste positionieren. */
  .account-menu { position: static; }
  .account-menu-panel {
    left: 0;
    right: 0;
    width: auto;
  }

  .access-row {
    grid-template-columns: 1fr auto;
    row-gap: 4px;
  }
  .access-label { grid-column: 1 / -1; font-size: 12px; }
}
