:root {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
    --radius: 14px;
    --ok: #16a34a; --warn: #d97706; --crit: #dc2626; --unknown: #94a3b8;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b1120; --surface: #131c2e; --surface-2: #0f1828;
        --text: #e2e8f0; --muted: #94a3b8; --border: #1e293b;
        --shadow: 0 1px 3px rgba(0,0,0,.4);
    }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; background: var(--bg); color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; }

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 12px 16px;
    background: var(--surface); border-bottom: 1px solid var(--border);
    backdrop-filter: saturate(180%) blur(6px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand strong { font-size: 1.05rem; }
.overall { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.actions { display: flex; gap: 8px; margin: 0; }
.btn-ghost {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 44px; min-height: 44px; font-size: 1.2rem;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 10px; color: var(--text); cursor: pointer; text-decoration: none;
    transition: background .15s;
}
.btn-ghost:hover, .btn-ghost:focus-visible { background: var(--border); outline: none; }

/* ── Status dot ─────────────────────────────────────────── */
.dot {
    flex: none; width: 11px; height: 11px; border-radius: 50%;
    background: var(--c, var(--unknown)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 22%, transparent);
}
body[data-worst="crit"] .topbar .dot { animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 3px color-mix(in srgb,var(--c) 30%,transparent);} 50% { box-shadow: 0 0 0 7px color-mix(in srgb,var(--c) 8%,transparent);} }

.wrap { max-width: 1100px; margin: 0 auto; padding: 16px 16px 48px; }

/* ── Alerty ─────────────────────────────────────────────── */
.alerts { margin-bottom: 22px; }
.alerts h2 { font-size: .9rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 6px 2px 10px; }
.alert-list { display: grid; gap: 8px; }
.alert {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; background: var(--surface); border-radius: 12px;
    border-left: 4px solid var(--unknown); box-shadow: var(--shadow);
}
.alert.warn { border-left-color: var(--warn); }
.alert.crit { border-left-color: var(--crit); }
.alert-body { min-width: 0; flex: 1; }
.alert-name { font-weight: 600; }
.alert-msg { color: var(--muted); font-size: .9rem; word-break: break-word; }
.alert time { color: var(--muted); font-size: .8rem; white-space: nowrap; }

/* ── Kategorie ──────────────────────────────────────────── */
.cat { margin-bottom: 22px; }
.cat-head {
    display: flex; align-items: center; gap: 10px; cursor: pointer;
    font-size: 1rem; margin: 0 2px 10px; padding: 6px 0; user-select: none;
}
.cat-icon { font-size: 1.1rem; }
.cat-count {
    margin-left: auto; font-size: .8rem; color: var(--muted);
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 999px; padding: 2px 10px; min-width: 28px; text-align: center;
}
.cat.collapsed .grid { display: none; }

.grid { display: grid; grid-template-columns: 1fr; gap: 10px; }

/* ── Karta ──────────────────────────────────────────────── */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow);
    display: flex; flex-direction: column; gap: 6px;
}
.card.crit { border-color: color-mix(in srgb, var(--crit) 40%, var(--border)); }
.card.warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); }
.card-top { display: flex; align-items: center; gap: 9px; }
.card-name { font-weight: 600; word-break: break-word; }
.card-name a { text-decoration: none; }
.card-name a:hover { text-decoration: underline; }
.card-msg { color: var(--muted); font-size: .9rem; word-break: break-word; }
.card-foot { display: flex; align-items: center; gap: 10px; font-size: .78rem; color: var(--muted); margin-top: 2px; }
.badge { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 7px; font-family: ui-monospace, monospace; }
.btn-done {
    min-height: 44px; padding: 8px 16px; cursor: pointer;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text); font-size: .85rem;
}
.btn-done:hover { background: var(--border); }

/* Skróty na desktopie */
@media (min-width: 720px) {
    .grid { grid-template-columns: repeat(2, 1fr); }
    .alert-list { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1000px) {
    .grid { grid-template-columns: repeat(3, 1fr); }
}

.foot { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 24px; }

/* Dostępność: widoczny focus klawiaturowy na elementach interaktywnych */
.cat-head:focus-visible, .btn-done:focus-visible, .card-name a:focus-visible {
    outline: 2px solid #2563eb; outline-offset: 2px; border-radius: 6px;
}
/* Bardzo wąskie ekrany: skróć pasek górny, by nic nie uciekało */
@media (max-width: 380px) {
    .overall { display: none; }
    .brand strong { font-size: 1rem; }
    .wrap { padding: 12px 12px 40px; }
}
/* Szanuj preferencję ograniczenia animacji */
@media (prefers-reduced-motion: reduce) {
    body[data-worst="crit"] .topbar .dot { animation: none; }
}

/* ── Login ──────────────────────────────────────────────── */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card {
    width: 100%; max-width: 360px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 28px 24px; box-shadow: var(--shadow); display: grid; gap: 14px;
}
.login-card h1 { font-size: 1.3rem; margin: 0 0 6px; text-align: center; }
.login-card label { display: grid; gap: 6px; font-size: .85rem; color: var(--muted); }
.login-card input {
    padding: 12px; font-size: 16px; border: 1px solid var(--border);
    border-radius: 10px; background: var(--surface-2); color: var(--text);
}
.login-card input:focus-visible { outline: 2px solid #2563eb; border-color: #2563eb; }
.login-card button {
    min-height: 48px; font-size: 1rem; font-weight: 600; cursor: pointer;
    background: #2563eb; color: #fff; border: none; border-radius: 10px;
}
.login-card button:hover { background: #1d4ed8; }
.login-error { background: color-mix(in srgb, var(--crit) 12%, transparent); color: var(--crit); padding: 10px; border-radius: 8px; margin: 0; font-size: .9rem; text-align: center; }
