:root {
    --bg: #f5f6f8; --card: #fff; --text: #1d2330; --muted: #6b7385; --line: #e5e8ee;
    --accent: #3b5bdb; --good: #2f9e44; --warn: #e8890c; --bad: #e03131; --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; display: flex; align-items: center; gap: 10px; }
h2 { font-size: 18px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 0 0 12px; }
code, .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

.top { display: flex; justify-content: space-between; align-items: center; padding: 12px 24px; background: #1d2330; }
.top a { color: #fff; }
.top .brand { font-weight: 700; font-size: 16px; }
.top nav a { margin-left: 20px; opacity: .8; }
.top nav a:hover { opacity: 1; text-decoration: none; }
main { max-width: 1280px; margin: 0 auto; padding: 24px; }

.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h3 { margin: 0; }
.card.empty { text-align: center; color: var(--muted); padding: 40px; }
details.card summary { cursor: pointer; }
details.card[open] summary { margin-bottom: 16px; }
.table-wrap { overflow-x: auto; padding: 0; }
.table-wrap table { min-width: 900px; }
.table-wrap th:first-child, .table-wrap td:first-child { padding-left: 18px; }

.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.grid3 .card { margin-bottom: 16px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; border-left: 4px solid var(--line); }
.kpi b { display: block; font-size: 26px; line-height: 1.2; }
.kpi span { color: var(--muted); font-size: 13px; }
.kpi.good { border-left-color: var(--good); }
.kpi.warn { border-left-color: var(--warn); }
.kpi.bad { border-left-color: var(--bad); }
.kpi.bad b { color: var(--bad); }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.right { text-align: right; }
td form { margin: 0; display: inline; }
.row-down { background: #fff5f5; }
.site-name { font-weight: 600; }
.err-msg { max-width: 640px; word-break: break-word; }
.nowrap { white-space: nowrap; }

dl.stats { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 0; }
dl.stats dt { color: var(--muted); }
dl.stats dd { margin: 0; font-weight: 600; text-align: right; }

.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: #adb5bd; flex: none; }
.dot.up { background: var(--good); box-shadow: 0 0 0 3px #2f9e4422; }
.dot.down { background: var(--bad); box-shadow: 0 0 0 3px #e0313133; animation: pulse 1.5s infinite; }
.dot.paused { background: #868e96; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px #e0313111; } }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.good { color: var(--good); }
.warn { color: var(--warn); font-weight: 600; }
.bad { color: var(--bad); font-weight: 600; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: #eef0f4; font-weight: 600; }
.pill.warn { background: #fff4e6; color: #c26b00; }
.pill.bad { background: #fff0f0; color: var(--bad); }
.badge { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; background: #eef0f4; color: var(--muted); }
.badge.ok { background: #ebfbee; color: var(--good); }
.badge.warning { background: #fff4e6; color: #c26b00; }
.badge.error { background: #fff0f0; color: var(--bad); }

.btn { display: inline-block; border: 1px solid var(--line); background: #fff; color: var(--text); padding: 7px 14px; border-radius: 7px; font: inherit; font-weight: 500; cursor: pointer; }
.btn:hover { border-color: #c5cad4; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--bad); border-color: #ffc9c9; }
.btn.small { padding: 3px 9px; font-size: 12px; }

.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; background: #ebfbee; border: 1px solid #b2f2bb; }
.flash.error { background: #fff5f5; border-color: #ffc9c9; }

.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-form .full { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; font-size: 13px; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
input:not([type=checkbox]), select { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
input:focus, select:focus { outline: 2px solid #3b5bdb44; border-color: var(--accent); }

.setup { border-color: #bac8ff; background: #f8f9ff; }
.setup ol { padding-left: 20px; margin: 0; }
.setup li { margin-bottom: 10px; }
.secret { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.secret code { background: #fff; border: 1px solid var(--line); padding: 6px 10px; border-radius: 6px; font-size: 13px; user-select: all; }

.spark { width: 100%; height: 70px; display: block; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.spark .fail { fill: #e0313133; }
.spark-legend { display: flex; justify-content: space-between; margin-top: 4px; }

.login { max-width: 360px; margin: 12vh auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.login h1 { margin-bottom: 20px; }
.login form { display: flex; flex-direction: column; gap: 16px; }

/* Rapport client */
body.report { background: #e9ecef; }
.toolbar { display: flex; gap: 10px; justify-content: center; padding: 16px; }
.toolbar form { margin: 0; }
.sheet { max-width: 820px; margin: 0 auto 40px; background: #fff; padding: 48px 56px; border-radius: 4px; box-shadow: 0 2px 12px #0001; }
.r-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid var(--accent); padding-bottom: 18px; margin-bottom: 24px; }
.r-head h1 { font-size: 24px; display: block; }
.r-head .right { text-align: right; }
.r-month { font-size: 16px; color: var(--accent); font-weight: 600; }
.logo { max-height: 56px; max-width: 200px; display: block; margin-bottom: 6px; }
.r-site { margin-bottom: 24px; }
.r-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 28px; }
.r-kpis div { background: #f4f6fb; border-radius: 8px; padding: 14px; text-align: center; }
.r-kpis b { display: block; font-size: 22px; color: var(--accent); }
.r-kpis span { font-size: 12px; color: var(--muted); }
.sheet section { margin-bottom: 26px; }
.sheet h3 { font-size: 16px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
table.kv th { width: 45%; text-transform: none; font-size: 13px; letter-spacing: 0; }
.r-foot { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 30px; }

@media print {
    body.report { background: #fff; }
    .no-print { display: none !important; }
    .sheet { box-shadow: none; margin: 0; padding: 0; max-width: none; }
    .r-kpis div { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    tr { page-break-inside: avoid; }
}
@media (max-width: 700px) {
    main { padding: 14px; }
    .grid-form { grid-template-columns: 1fr; }
    .r-kpis { grid-template-columns: 1fr 1fr; }
    .sheet { padding: 24px; }
}
