:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1b1f24;
  --muted: #5d6673;
  --border: #d9dde3;
  --accent: #2557d6;
  --low: #1f7a3d;
  --mid: #a86400;
  --high: #c0262d;
  --neutral: #5d6673;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121418;
    --surface: #1b1e24;
    --text: #e6e8eb;
    --muted: #9aa3ae;
    --border: #2f343c;
    --accent: #7ea2ff;
    --low: #5cc77f;
    --mid: #f0a43a;
    --high: #ff6b70;
    --neutral: #9aa3ae;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, sans-serif; }
header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
header form { margin: 0; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
main { max-width: 900px; margin: 0 auto; padding: 16px; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: .5rem 0; word-break: break-all; }
h2 { font-size: 1.15rem; margin-top: 2rem; }
.muted { color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px 20px; }
input, textarea { font: inherit; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); width: 100%; }
button { font: inherit; padding: 10px 16px; border: 0; border-radius: 6px; background: var(--accent); color: #fff; cursor: pointer; }
button.link { background: none; color: var(--accent); padding: 0; }
.search { display: flex; gap: 8px; margin-top: 8px; }
.login { max-width: 360px; margin: 10vh auto; display: grid; gap: 12px; }
.error { color: var(--high); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.risk { display: inline-block; padding: 0 8px; border-radius: 999px; border: 1px solid currentColor; font-size: .85em; }
.risk-niedrig { color: var(--low); }
.risk-mittel { color: var(--mid); }
.risk-hoch { color: var(--high); }
.risk-unklar, .risk-none { color: var(--neutral); }
.report h2 { margin-top: 1.2rem; font-size: 1.1rem; }
.report h2:first-child { margin-top: 0; }
.result-card { margin-top: 16px; }
.result-card h2 { margin-top: 0; }
.external-link-notice { margin: 6px 0; font-size: .85rem; }
.language-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.language-switch button { padding: 6px 14px; border-radius: 0; background: var(--surface); color: var(--accent); }
.language-switch button + button { border-left: 1px solid var(--border); }
.language-switch button.selected { background: var(--accent); color: #fff; }
.global-language input { display: none; }
details { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; margin: 6px 0; padding: 8px 12px; }
summary { cursor: pointer; }
pre { overflow-x: auto; font-size: .85rem; margin: 8px 0 0; }
.progress { display: flex; align-items: center; gap: 8px; }
.spinner { width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 600px) { .search { flex-direction: column; } }
header nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
header nav form { display: inline; }
header nav form:has(.icon) { display: inline-flex; align-items: center; gap: 6px; }
.admin-menu { position: relative; margin: 0; padding: 0; border: 0; background: none; }
.admin-menu > summary { list-style: none; }
.admin-menu > summary::-webkit-details-marker { display: none; }
.admin-menu-pop { position: absolute; z-index: 10; top: calc(100% + 6px); right: 0; min-width: 10rem; display: grid;
  padding: 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: 0 8px 24px rgb(0 0 0 / .14); }
.admin-menu-pop a { padding: 7px 9px; border-radius: 5px; text-decoration: none; white-space: nowrap; }
.admin-menu-pop a:hover, .admin-menu-pop a:focus-visible { background: var(--bg); }
.message { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 6px; padding: 10px 14px; }
.stack { display: grid; gap: 10px; margin-top: 16px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }
.errorlist { color: var(--high); margin: 0; padding-left: 18px; }
.qr { background: #fff; display: inline-block; padding: 8px; border-radius: 6px; margin: 8px 0; }
.qr svg { display: block; width: 220px; height: 220px; }
.copy-row { display: flex; gap: 8px; }
.tile-kind-email .t-kind { color: #805ad5; font-weight: 600; }
.tile-kind-phone .t-kind { color: #c05621; font-weight: 600; }
.tile-kind-ip .t-kind { color: #2563eb; font-weight: 600; }
.tile-kind-host .t-kind { color: #15803d; font-weight: 600; }
.tile-kind-compare .t-kind { color: #0e8a99; font-weight: 600; }

/* Mobil: Tabellen werden zu Kacheln */
@media (max-width: 640px) {
  .table-wrap { overflow: visible; }
  table.tiles, table.tiles tbody, table.tiles-generic, table.tiles-generic tbody { display: block; background: none; }
  table.tiles thead, table.tiles-generic thead { display: none; }
  table.tiles td, table.tiles-generic td { border: 0; padding: 0; white-space: normal; }

  table.tiles tr {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "query query" "kind time" "status user";
    gap: 4px 12px;
    margin-bottom: 10px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--neutral);
    border-radius: 8px;
  }
  table.tiles tr.tile-kind-email { border-left-color: #805ad5; }
  table.tiles tr.tile-kind-phone { border-left-color: #c05621; }
  table.tiles tr.tile-kind-ip { border-left-color: #2563eb; }
  table.tiles tr.tile-kind-host { border-left-color: #15803d; }
  table.tiles tr.tile-kind-compare { border-left-color: #0e8a99; }
  .t-query { grid-area: query; font-weight: 600; font-size: 1.05rem; word-break: break-all; }
  .t-query a { color: var(--text); text-decoration: none; }
  .t-query a::after { content: ""; position: absolute; inset: 0; }  /* ganze Kachel antippbar */
  .t-kind { grid-area: kind; font-size: .9rem; }
  .t-time { grid-area: time; justify-self: end; font-size: .9rem; }
  .t-status { grid-area: status; display: flex; align-items: center; gap: 6px; font-size: .9rem; }
  .t-user { grid-area: user; justify-self: end; font-size: .85rem; word-break: break-all; }

  table.tiles-generic tr {
    display: grid;
    gap: 4px;
    margin-bottom: 10px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
  }
  table.tiles-generic td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .85rem; }
  table.tiles-generic td:first-child { font-weight: 600; word-break: break-all; }
  table.tiles-generic td:first-child::before { content: none; }
  table.tiles-generic td:empty { display: none; }

  header { flex-wrap: wrap; gap: 8px; }
  header nav .muted { display: none; }
  .copy-row { flex-direction: column; }
}

a.button { display: inline-block; font: inherit; padding: 10px 16px; border-radius: 6px; background: var(--accent); color: #fff; text-decoration: none; }
button.secondary { background: var(--surface); color: var(--accent); border: 1px solid var(--accent); }

.hits { list-style: none; padding: 0; }
.hits li { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; margin: 6px 0; }
.hits .hit-url { display: block; font-size: .8rem; word-break: break-all; }
.hits p { margin: 4px 0 0; font-size: .9rem; }

#l-conn { margin: 4px 0; }
#l-progress:empty, #l-error:empty { display: none; }

.opt { margin-top: 10px; align-items: flex-start; font-size: .9rem; }
.opt input { margin-top: 3px; flex: none; }

.flags ul { margin: 6px 0 0; padding-left: 18px; }
.flags li { margin: 4px 0; }

/* Portscan-Tabelle bleibt auch mobil eine Tabelle: Zellen umbrechen statt über den Rand zu laufen */
table.ports td, table.ports th { white-space: normal; overflow-wrap: anywhere; }
table.ports td.nw, table.ports th.nw { white-space: nowrap; }
@media (max-width: 640px) { .table-wrap.keep { overflow-x: auto; } }
table.ports td:first-child { white-space: nowrap; }

.opt-date { display: grid; gap: 4px; margin-top: 10px; font-size: .9rem; }
button.submit { margin-top: 14px; }
@media (max-width: 600px) { button.submit { width: 100%; } }

.sources-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 2rem; }
.sources-head[hidden] { display: none; }
.sources-head h2 { margin: 0; }
button.copy { padding: 4px 12px; font-size: .85rem; }
.raw-tools { text-align: right; margin-top: 6px; }

/* Verlauf: Auswahl zum Löschen (langer Druck auf eine Analyse oder "Auswählen") */
.history-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.pick-bar { display: flex; align-items: center; gap: 8px; }
button.small { padding: 4px 12px; font-size: .85rem; }
button.danger { background: var(--high); }
button:disabled { opacity: .5; cursor: default; }
.search textarea { resize: none; overflow: hidden; line-height: 1.4; }
.pick-bar button { display: inline-flex; align-items: center; gap: 6px; }
.pick-bar svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.pick-bar button.flash-ok { background: var(--low); color: #fff; }
.pick-bar button.flash-fail { background: var(--high); color: #fff; }
.history:not(.picking) [data-pick-count], .history:not(.picking) [data-pick-delete], .history:not(.picking) [data-pick-copy],
.history:not(.picking) [data-pick-compare],
.history:not(.picking) [data-pick-cancel], .history.picking [data-pick-start] { display: none; }
.pick-hint { margin: 0 0 8px; font-size: .85rem; }
.history.picking .pick-hint { display: none; }
.history:not(.picking) .t-pick { display: none; }
.t-pick input { width: auto; }
[data-pick-row] { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.history.picking [data-pick-row] { cursor: pointer; }
.history.picking tr.picked td { background: color-mix(in srgb, var(--accent) 12%, transparent); }
@media (max-width: 640px) {
  /* Handy: nur die Symbole, rechtsbündig */
  .pick-bar { margin-left: auto; }
  .pick-bar .label, .pick-bar [data-pick-count] { display: none; }
  .pick-bar button { width: 38px; height: 38px; padding: 0; justify-content: center; }
  .pick-bar svg { width: 20px; height: 20px; }
  .history.picking .t-query a::after { content: none; }
  .t-pick { position: absolute; top: 12px; right: 14px; }
  .history.picking table.tiles tr { padding-right: 44px; }
  .history.picking table.tiles tr.picked { outline: 2px solid var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
  .history.picking tr.picked td { background: none; }
}

/* Notiz zu einer Analyse */
.note { margin: 0 0 8px; font-style: italic; }
.link-button { appearance: none; border: 0; padding: 0; background: transparent; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
.note-tip { margin: 4px 0 0; font-size: .85rem; }
.t-note { color: var(--muted); font-weight: 400; white-space: normal; word-break: normal; overflow-wrap: anywhere; }

/* Optionen der Suche nur zeigen, solange das Formular den Fokus hat (Klasse setzt app.js) */
#analyze.collapsible:not(.open) .opts { display: none; }
#analyze .opts [hidden] { display: none; }
h2 .count { color: var(--muted); font-weight: 400; }
.t-runs { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 10px; border: 1px solid var(--border); font-size: .8rem; }

details.runs { margin: 0 0 16px; }
details.run { margin: 8px 0 0; background: var(--bg); }
details.run .changes { margin: 8px 0 0; padding-left: 18px; overflow-wrap: anywhere; }
details.run .changes li { margin: 2px 0; }
details.run p { margin: 8px 0 0; }
.run-open { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.run-open a.button { margin-left: auto; }
a.button.small { padding: 4px 12px; font-size: .85rem; }

/* Detailseite: Titel mit Symbolleiste (Notiz, PDF, erneut analysieren) */
.title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.title-row h1 { min-width: 0; }
.toolbar, #l-actions { display: flex; gap: 6px; align-items: center; flex: none; }
.toolbar { margin-top: .5rem; }
.toolbar form { margin: 0; }
.icon { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; padding: 0;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--accent); cursor: pointer; }
.icon:hover { border-color: var(--accent); }
.icon.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.note-pop { width: min(32rem, calc(100vw - 32px)); padding: 16px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); }
.note-pop::backdrop { background: rgb(0 0 0 / .35); }
.enrich-pop { width: min(38rem, calc(100vw - 32px)); }
.enrich-pop select, .enrich-pop input { margin: 4px 0 10px; }
.enrich-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.enrich-fields label { display: grid; }
.enrich-confirm { margin: 4px 0 10px; }
.note-form { display: flex; gap: 8px; margin-top: 8px; }

/* Standortkarte */
.geo-map { height: 340px; border-radius: 8px; margin: 8px 0 12px; z-index: 0; }
.geo-nr { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px;
  border-radius: 50%; border: 2px solid #fff; color: #fff; font-weight: 700; font-size: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .4); box-sizing: border-box; }
.geo-legend td:first-child { width: 28px; }

/* Vergleich: Einzelergebnisse, älteste zuerst */
.compare-members-head { margin-top: 2rem; }
.compare-member { border-left: 4px solid var(--neutral); }
.compare-member.tile-kind-email { border-left-color: #805ad5; }
.compare-member.tile-kind-phone { border-left-color: #c05621; }
.compare-member.tile-kind-ip { border-left-color: #2563eb; }
.compare-member.tile-kind-host { border-left-color: #15803d; }
.compare-member h2 a { color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
details.compare-raw { background: var(--bg); }
