/* fail2ban-web – Dashboard. Ruhige Werkzeugoptik; das Zeitverlaufsdiagramm ist der Blickfang. */
:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --ink: #172433;
  --muted: #5a6878;
  --faint: #8a97a5;
  --line: #d9dfe6;
  --ban: #b42318;
  --ban-soft: #fbe9e7;
  --free: #23704a;
  --free-soft: #e6f2eb;
  --found: #c27a0e;
  --found-soft: #f6e7cc;
  --focus: #2f6fdb;
  --band-free: #23704a; --band-ban: #b42318; --band-unknown: #6b7886;
  --cpu: #3a6fb0; --mem: #2a8a83; --warn: #b7791f; --ok: #23704a;
  --heat-0: #eef1f4; --heat-1: #f7e3bf; --heat-2: #efc37e; --heat-3: #dd8f2b; --heat-4: #a8510d;
  --radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10161d; --surface: #18212b; --ink: #e6ecf2; --muted: #9aa8b6; --faint: #6d7b89; --line: #283340;
    --ban: #f0645a; --ban-soft: #3a1d1c; --free: #4fbf85; --free-soft: #17302a;
    --found: #f0a93b; --found-soft: #3a2b12; --focus: #7aa7ff;
    --band-free: #1d5e3e; --band-ban: #8f2a22; --band-unknown: #3a4552;
    --cpu: #6f9fe0; --mem: #4fc1b7; --warn: #e0b252; --ok: #4fbf85;
    --heat-0: #1e2833; --heat-1: #3d3220; --heat-2: #6e4f1d; --heat-3: #b07421; --heat-4: #f0a93b;
  }
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; padding-bottom: env(safe-area-inset-bottom); }
h1, h2 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.05rem; font-weight: 600; }
h2 { font-size: 1.05rem; font-weight: 650; letter-spacing: -0.005em; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.note { margin: .25rem 0 0; color: var(--muted); font-size: .85rem; }
.ip, .r, .kpi-value { font-variant-numeric: tabular-nums; }

/* Buttons */
button { cursor: pointer; border: 0; border-radius: 8px; padding: .55rem 1rem; background: var(--ink); color: var(--surface); font-weight: 600; }
button:disabled { opacity: .5; cursor: progress; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); padding: .4rem .8rem; font-weight: 500; }
.btn-light { background: #fff; color: var(--band-ban); padding: .35rem .8rem; }
.btn-small { padding: .2rem .65rem; font-size: .85rem; font-weight: 600; background: transparent; border: 1px solid currentColor; }
.btn-small.unban { color: var(--free); }
.btn-small.ban { color: var(--ban); }

/* Status der eigenen IP */
.me { background: var(--band-free); color: #fff; padding: calc(env(safe-area-inset-top) + .6rem) 1.25rem .6rem; transition: background-color .4s; }
.me.is-banned { background: var(--band-ban); }
.me.is-unknown { background: var(--band-unknown); }
.me-inner { max-width: 76rem; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem 1rem; }
.me-label { opacity: .85; font-size: .9rem; }
.me-ip { font-size: 1.35rem; font-weight: 650; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; word-break: break-all; }
.me-state { font-size: .95rem; }
.me button { margin-left: auto; }

/* Kopfzeile */
.bar { max-width: 76rem; margin: 0 auto; padding: 1.1rem 1.25rem .5rem; display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; align-items: center; }
.bar h1 { margin-right: auto; }
.bar-actions { display: flex; gap: .5rem; align-items: center; }
.bar-actions .muted { font-size: .85rem; }
.period { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.period button { background: transparent; color: var(--muted); font-weight: 600; padding: .3rem .8rem; border-radius: 6px; }
.period button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }

/* Reiter */
.tabs { display: inline-flex; gap: .25rem; }
.tabs button { background: transparent; color: var(--muted); font-weight: 600; padding: .4rem .75rem; border-radius: 0; border-bottom: 3px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tab-badge { display: inline-block; min-width: 1.35rem; padding: 0 .35rem; margin-left: .25rem; border-radius: 999px; font-size: .75rem; line-height: 1.35rem; text-align: center; color: #fff; background: var(--warn); }
.tab-badge.is-crit { background: var(--ban); }
[hidden] { display: none !important; }

/* Raster */
.dash { max-width: 76rem; margin: 0 auto; padding: .75rem 1.25rem 3rem; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem 1.1rem; min-width: 0; }
.panel > h2, .panel-head { margin-bottom: .75rem; }
.panel-head { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; }
.span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
.hero { padding: 1.25rem 1.4rem 1rem; }
.hero h2 { font-size: 1.3rem; }

/* Kennzahlen: ein Streifen, keine Kartenwand */
.kpis { grid-column: span 12; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { display: grid; padding: .35rem 1.25rem; border-left: 1px solid var(--line); }
.kpi:first-child { border-left: 0; padding-left: 0; }
.kpi-label { color: var(--muted); font-size: .9rem; }
.kpi-value { font-size: clamp(1.7rem, 3.4vw, 2.4rem); font-weight: 680; letter-spacing: -0.02em; line-height: 1.15; }
#view-attacks .kpi:nth-child(1) .kpi-value { color: var(--found); }
#view-attacks .kpi:nth-child(2) .kpi-value, #view-attacks .kpi:nth-child(3) .kpi-value { color: var(--ban); }
.kpi-value.warn { color: var(--warn); }
.kpi-value.crit { color: var(--ban); }
.kpi-sub { color: var(--muted); font-size: .82rem; min-height: 1.2em; }

/* Legende */
.legend { display: flex; gap: 1rem; font-size: .85rem; color: var(--muted); }
.key::before { content: ""; display: inline-block; width: .7rem; height: .7rem; border-radius: 2px; margin-right: .35rem; vertical-align: -1px; }
.key-found::before { background: var(--found); }
.key-ban::before { background: var(--ban); }

/* Diagramme (SVG) */
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart svg:focus-visible { outline-offset: 4px; }
.chart .empty { padding: 2rem 0; text-align: center; }
.grid-line { stroke: var(--line); stroke-width: 1; }
.axis-text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.band-text { fill: var(--muted); font-size: 11px; font-weight: 600; }
.bar-found { fill: var(--found); }
.bar-ban { fill: var(--ban); }
.bar-track { fill: var(--bg); }
.hover-col { fill: var(--ink); opacity: .07; }
.label-text { fill: var(--ink); font-size: 13px; font-weight: 600; }
.value-text { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.heat-0 { fill: var(--heat-0); } .heat-1 { fill: var(--heat-1); } .heat-2 { fill: var(--heat-2); }
.heat-3 { fill: var(--heat-3); } .heat-4 { fill: var(--heat-4); }
.heat-cell:hover, .heat-cell.is-active { stroke: var(--ink); stroke-width: 1.5; }
.heat-scale { display: flex; align-items: center; gap: 4px; margin-top: .6rem; font-size: .8rem; color: var(--muted); }
.heat-scale i { width: 14px; height: 10px; border-radius: 2px; display: inline-block; }
.heat-scale i:nth-of-type(1) { background: var(--heat-0); } .heat-scale i:nth-of-type(2) { background: var(--heat-1); }
.heat-scale i:nth-of-type(3) { background: var(--heat-2); } .heat-scale i:nth-of-type(4) { background: var(--heat-3); }
.heat-scale i:nth-of-type(5) { background: var(--heat-4); }

/* Horizontale Balken (Dienste, Netze) */
.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; }
.hbars li { display: grid; grid-template-columns: minmax(6.5rem, 9rem) 1fr auto; gap: .75rem; align-items: center; }
.hbar-label { display: grid; line-height: 1.25; min-width: 0; }
.hbar-label b { font-weight: 600; font-size: .9rem; overflow-wrap: anywhere; }
.hbar-label small, .hbar-values small { color: var(--muted); font-size: .78rem; }
.hbar-track { display: grid; gap: 3px; background: var(--bg); border-radius: 4px; padding: 3px; }
.hbar-found { display: block; height: 10px; border-radius: 3px; background: var(--found); min-width: 2px; }
.hbar-ban { display: block; height: 4px; border-radius: 2px; background: var(--ban); }
.hbar-values { display: grid; text-align: right; font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; line-height: 1.25; }
.hbar-values b { color: var(--ink); font-size: .95rem; }
#chart-heat svg { width: auto; max-width: 100%; }

/* Systemzustand */
.health { border-left: 6px solid var(--faint); }
.health.state-ok { border-left-color: var(--ok); }
.health.state-warn { border-left-color: var(--warn); }
.health.state-crit { border-left-color: var(--ban); }
.health-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem 1rem; }
.health h2 { font-size: 1.3rem; }
.health.state-ok h2 { color: var(--ok); }
.health.state-warn h2 { color: var(--warn); }
.health.state-crit h2 { color: var(--ban); }
.issues { list-style: none; margin: .6rem 0 0; padding: 0; display: grid; gap: .3rem; }
.issues li { display: flex; gap: .55rem; align-items: baseline; font-size: .92rem; }
.issues li::before { content: ""; flex: none; width: .6rem; height: .6rem; border-radius: 50%; background: var(--faint); transform: translateY(-1px); }
.issues li.crit::before { background: var(--ban); }
.issues li.warn::before { background: var(--warn); }
.key-cpu::before { background: var(--cpu); }
.key-mem::before { background: var(--mem); }
.key-io::before { background: var(--found); }
.key-load::before { background: var(--ink); height: 2px; vertical-align: 3px; }
.ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ln-cpu { stroke: var(--cpu); } .ln-mem { stroke: var(--mem); } .ln-io { stroke: var(--found); stroke-width: 1.5; }
.ln-load { stroke: var(--ink); stroke-width: 1.5; }
.ar-cpu { fill: var(--cpu); opacity: .12; }
.ar-load { fill: var(--ink); opacity: .06; }
.ln-limit { stroke: var(--ban); stroke-width: 1; stroke-dasharray: 4 4; }
.hover-line { stroke: var(--ink); stroke-width: 1; opacity: .35; }
.dot { stroke: var(--surface); stroke-width: 2; }
.dot-cpu { fill: var(--cpu); } .dot-mem { fill: var(--mem); } .dot-io { fill: var(--found); } .dot-load { fill: var(--ink); }
.chart-load { margin-top: .5rem; }

.meters { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.meter-head { display: flex; justify-content: space-between; gap: 1rem; font-size: .9rem; }
.meter-head b { font-weight: 600; overflow-wrap: anywhere; }
.meter-head span { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.meter-track { height: 10px; background: var(--bg); border-radius: 5px; margin-top: .35rem; overflow: hidden; }
.meter-fill { display: block; height: 100%; border-radius: 5px; background: var(--ok); }
.meter-fill.warn { background: var(--warn); } .meter-fill.crit { background: var(--ban); }
.meter-sub { color: var(--muted); font-size: .8rem; margin-top: .2rem; }

.facts { display: grid; grid-template-columns: auto 1fr; gap: .55rem 1.25rem; margin: 0; font-size: .92rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.facts dd.warn { color: var(--warn); font-weight: 600; } .facts dd.crit { color: var(--ban); font-weight: 600; }

.units { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(14.5rem, 1fr)); gap: .5rem; }
.units li { display: grid; grid-template-columns: auto 1fr; gap: 0 .6rem; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px; }
.units li::before { content: ""; grid-row: span 2; width: .65rem; height: .65rem; border-radius: 50%; background: var(--ok); margin-top: .4rem; }
.units li.is-down::before { background: var(--ban); }
.units li.is-down { border-color: var(--ban); background: var(--ban-soft); }
.units li.is-off::before { background: var(--faint); }
.unit-name { font-weight: 600; font-size: .92rem; }
.unit-sub { color: var(--muted); font-size: .8rem; }

.table.logs td { font-size: .85rem; }
.table.logs td.msg { overflow-wrap: anywhere; min-width: 14rem; }
.table.logs tr.crit td:first-child { color: var(--ban); font-weight: 700; }
.kernel { list-style: none; margin: 0 0 1rem; padding: .6rem .8rem; background: var(--ban-soft); border-radius: 8px; display: grid; gap: .3rem; font-size: .85rem; }
.kernel b { color: var(--ban); }
.table td.warn { color: var(--warn); font-weight: 600; } .table td.crit { color: var(--ban); font-weight: 600; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.seg button { background: transparent; color: var(--muted); font-weight: 600; font-size: .82rem; padding: .2rem .6rem; border-radius: 6px; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }

.ports { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.ports li { border: 1px solid var(--line); border-radius: 6px; padding: .2rem .55rem; font-size: .85rem; font-variant-numeric: tabular-nums; }
.ports li b { font-weight: 650; }
.ports li span { color: var(--muted); margin-left: .3rem; }
.ports li.local { opacity: .6; }

/* Tooltip */
.tip { position: fixed; z-index: 20; pointer-events: none; background: var(--ink); color: var(--surface); border-radius: 8px; padding: .45rem .7rem; font-size: .85rem; line-height: 1.4; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 16rem; }
.tip b { font-variant-numeric: tabular-nums; }

/* Tabelle */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: .82rem; padding: 0 .5rem .4rem; border-bottom: 1px solid var(--line); }
.table td { padding: .45rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table .nowrap { white-space: nowrap; }
.table td.jails-cell { font-size: .8rem; line-height: 1.3; max-width: 11rem; }
.table tr:last-child td { border-bottom: 0; }
.table .r { text-align: right; }
.table td.ban-count { color: var(--ban); font-weight: 600; }
.table .act { text-align: right; white-space: nowrap; }
.table tr.is-banned .ip::after { content: "gesperrt"; margin-left: .5rem; font-size: .75rem; color: var(--ban); font-weight: 600; }
.table tr.is-me .ip { font-weight: 700; }
.table .muted { color: var(--muted); }

/* Jails */
.jails { border: 1px solid var(--line); border-radius: 10px; }
.jail + .jail { border-top: 1px solid var(--line); }
.jail summary { list-style: none; cursor: pointer; padding: .75rem .9rem; display: grid; grid-template-columns: 1fr auto auto; gap: 1.25rem; align-items: baseline; }
.jail summary::-webkit-details-marker { display: none; }
.jail-name { font-weight: 600; }
.jail-name::before { content: "▸"; display: inline-block; width: 1.1em; color: var(--muted); transition: transform .15s; }
.jail[open] .jail-name::before { transform: rotate(90deg); }
.count { text-align: right; color: var(--muted); font-size: .88rem; white-space: nowrap; }
.count b { font-size: 1.05rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.count.hot b { color: var(--ban); }
.jail-body { padding: 0 .9rem .9rem 2rem; }
.jail-meta { margin: 0 0 .65rem; color: var(--muted); font-size: .88rem; }
.ips { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.ips li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .3rem .6rem; border-radius: 6px; background: var(--ban-soft); }
.ips li.is-me { outline: 2px solid var(--ban); }
.empty { color: var(--muted); margin: 0; }
input[type=search], .ban-form input, .ban-form select, .login-box input { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: .45rem .7rem; min-width: 0; }

/* Jail-Einstellungen */
.tag { display: inline-block; margin-left: .5rem; padding: 0 .45rem; border-radius: 999px; font-size: .72rem; font-weight: 600; line-height: 1.4rem; background: var(--found-soft); color: var(--found); vertical-align: 1px; }
.jail-settings { margin: 0 0 1rem; padding: .85rem; border: 1px solid var(--line); border-radius: 8px; display: grid; gap: .7rem; }
.jail-settings h3 { margin: 0; font-size: .95rem; }
.fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; }
.field { display: grid; gap: .3rem; align-content: start; }
.field-label { font-size: .85rem; color: var(--muted); }
.field input[type=number], .field select { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: .4rem .55rem; min-width: 0; width: 100%; }
.dur { display: grid; grid-template-columns: minmax(3.5rem, 1fr) minmax(5rem, 1fr); gap: .35rem; }
.field input:disabled, .field select:disabled { opacity: .45; }
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.form-actions button[type=submit] { padding: .45rem .9rem; }
.jail-settings .note { margin: 0; }

.settings-table td { vertical-align: middle; }
.settings-table .ignore-cell { font-size: .82rem; overflow-wrap: anywhere; max-width: 16rem; }
.btn-small.edit { color: var(--ink); }

/* Sperren */
.ban-form { display: grid; gap: .75rem; }
.ban-form label, .login-box label { display: grid; gap: .3rem; font-size: .88rem; color: var(--muted); }
.ban-form button { background: var(--ban); color: #fff; justify-self: start; }

/* Verlauf */
.check { display: flex; gap: .4rem; align-items: center; font-size: .88rem; color: var(--muted); }
.events { list-style: none; margin: 0; padding: 0; columns: 2 26rem; column-gap: 2rem; }
.events li { break-inside: avoid; display: grid; grid-template-columns: 9.5rem 7.5rem 1fr auto; gap: .6rem; padding: .4rem 0; border-bottom: 1px solid var(--line); font-size: .88rem; align-items: center; }
.ev-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.ev-kind { font-weight: 600; }
.ev-ban, .ev-restore, .ev-increase { color: var(--ban); }
.ev-unban { color: var(--free); }
.ev-found { color: var(--found); }
.ev-jail { color: var(--muted); text-align: right; }

/* Meldungen */
.toast { position: fixed; left: 50%; bottom: calc(1.25rem + env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: calc(100% - 2rem); z-index: 30; background: var(--ink); color: var(--surface); padding: .7rem 1.1rem; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.toast.is-error { background: var(--ban); color: #fff; }

/* Anmeldung */
body.login { display: grid; place-items: center; padding: 1.25rem; }
.login-box { width: 100%; max-width: 22rem; display: grid; gap: 1.25rem; }
.login-box form { display: grid; gap: .9rem; }
.form-error { margin: 0; color: var(--ban); }

@media (max-width: 64rem) {
  .span-4, .span-5, .span-6, .span-7, .span-8 { grid-column: span 12; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 1rem; }
  .kpi:nth-child(3) { border-left: 0; padding-left: 0; }
}
@media (max-width: 40rem) {
  .bar h1 { width: 100%; }
  .period { order: 3; }
  .hide-s { display: none; }
  .jail summary { grid-template-columns: 1fr auto; }
  .jail summary .count.failed { display: none; }
  .events li { grid-template-columns: auto 1fr auto; row-gap: 0; column-gap: .6rem; }
  .ev-time { grid-column: 1 / -1; font-size: .8rem; }
  .table { font-size: .85rem; }
  .table th, .table td { padding-left: .25rem; padding-right: .25rem; }
  .table tr.is-banned .ip::after { display: block; margin-left: 0; }
  .table .ip { white-space: nowrap; }
  .table th { font-size: .75rem; }
  .table .btn-small { padding: .15rem .45rem; font-size: .78rem; }
  .panel { padding-left: .85rem; padding-right: .85rem; }
  .hbars li { grid-template-columns: minmax(5.5rem, 7rem) 1fr auto; gap: .5rem; }
  .units { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fields { grid-template-columns: 1fr; }
  .jail-body { padding-left: .9rem; }
  .facts { grid-template-columns: 1fr; gap: .1rem; }
  .facts dd { margin-bottom: .45rem; }
  .hero { padding: 1rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
