:root {
  --bg: #f5f6f8; --card: #fff; --text: #1b1f24; --muted: #6b7280; --line: #e5e7eb;
  --accent: #2f6fed; --accent-ink: #fff;
  --up: #16a34a; --up-bg: #dcfce7; --down: #dc2626; --down-bg: #fee2e2;
  --prot: #b45309; --prot-bg: #fef3c7; --warn: #c2410c; --warn-bg: #ffedd5;
  --new: #475569; --new-bg: #e2e8f0;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 1px 8px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216; --card: #171b21; --text: #e6e8eb; --muted: #8b949e; --line: #2a3038;
    --accent: #5b8cff; --up: #4ade80; --up-bg: #12301f; --down: #f87171; --down-bg: #3a1717;
    --prot: #fbbf24; --prot-bg: #3a2c0c; --warn: #fb923c; --warn-bg: #3a2210; --new: #cbd5e1; --new-bg: #273140;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; }
pre.copy { background: var(--bg); border: 1px solid var(--line); padding: 10px 12px; border-radius: 8px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; cursor: copy; }
h1 { font-size: 24px; margin: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 17px; margin: 0 0 12px; }
h2.sub { margin: 28px 0 10px; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; font-weight: normal; }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }
.pad { padding: 14px 16px; margin: 0; }

/* header */
.top { background: var(--card); border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.top-in { display: flex; align-items: center; justify-content: space-between; height: 56px; gap: 12px; }
.logo { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; font-size: 16px; }
.logo:hover { text-decoration: none; }
.logo-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--up); box-shadow: 0 0 0 4px var(--up-bg); }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav a { color: var(--text); padding: 6px 10px; border-radius: 6px; }
nav a.on { background: var(--bg); font-weight: 600; }
nav a.muted { color: var(--muted); }
nav a:hover { text-decoration: none; background: var(--bg); }

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

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.form { padding: 20px; display: flex; flex-direction: column; gap: 14px; margin-bottom: 16px; }
.empty { padding: 40px 20px; text-align: center; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--down); border-color: var(--down); background: transparent; }
.btn.sm { padding: 4px 10px; font-size: 14px; }
.btn[disabled], .btn.loading { opacity: .6; pointer-events: none; }
.btn.loading::after { content: ""; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* forms */
label { display: flex; flex-direction: column; gap: 5px; font-weight: 500; font-size: 14px; }
label .muted { font-weight: normal; }
input:not([type=checkbox]):not([type=radio]), textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--text); font: inherit; font-weight: normal; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
label.check, label.radio { flex-direction: row; align-items: flex-start; gap: 8px; font-weight: normal; }
label.check input, label.radio input { margin-top: 4px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 0; display: flex; flex-direction: column; gap: 8px; }
legend { font-weight: 600; font-size: 14px; padding: 0 6px; }
.row2, .row3 { display: grid; gap: 14px; }
.row2 { grid-template-columns: 1fr 1fr; }
.row3 { grid-template-columns: 1fr 1fr 1fr; }
.form-actions { display: flex; gap: 8px; }
.form-actions.sticky { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 30%); margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.grid2 > * { min-width: 0; }
details summary { cursor: pointer; color: var(--accent); }
.help-box { font-size: 14px; }
ol.help { padding-left: 20px; margin: 10px 0 0; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }

/* flash */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; background: var(--up-bg); color: var(--text); border-left: 4px solid var(--up); }
.flash.err { background: var(--down-bg); border-color: var(--down); }
.flash.warn { background: var(--warn-bg); border-color: var(--warn); }
.notice { padding: 14px 16px; margin-bottom: 16px; border-left: 4px solid; }
.notice.prot { border-left-color: var(--prot); }
.notice.down { border-left-color: var(--down); }
.notice details { margin-top: 8px; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; color: var(--muted); font-size: 13px; box-shadow: var(--shadow); }
.stat span { display: block; font-size: 22px; font-weight: 700; color: var(--text); }
.stat.up span { color: var(--up); } .stat.down span { color: var(--down); } .stat.prot span { color: var(--prot); }

/* tables */
.table-wrap { overflow-x: auto; }
.table-wrap.scroll { max-height: 520px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 14px; }
tr:last-child td { border-bottom: 0; }
tr.dim { opacity: .55; }
.site-name { font-weight: 600; color: var(--text); }
.url { color: var(--muted); font-size: 13px; word-break: break-all; }
.err-line { color: var(--down); font-size: 13px; margin-top: 2px; }
.actions { text-align: right; }
.actions .btn { margin-left: 4px; }
.t-down { color: var(--down); font-weight: 600; } .t-warn { color: var(--warn); font-weight: 600; }

/* badges */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.up { background: var(--up-bg); color: var(--up); }
.badge.down { background: var(--down-bg); color: var(--down); }
.badge.prot { background: var(--prot-bg); color: var(--prot); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.new, .badge.off { background: var(--new-bg); color: var(--new); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--new); }
.dot.up { background: var(--up); } .dot.down { background: var(--down); } .dot.protected { background: var(--prot); }

/* events */
.events { padding: 6px 0; }
.ev { display: grid; grid-template-columns: 120px 22px 1fr; gap: 8px; padding: 7px 16px; font-size: 14px; border-bottom: 1px solid var(--line); }
.ev:last-child { border-bottom: 0; }
.ev-time { color: var(--muted); font-size: 13px; }

/* chart */
.chart-card { padding: 14px 16px; margin-bottom: 4px; }
.chart-title { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.chart { width: 100%; height: 160px; display: block; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.chart .grid { stroke: var(--line); stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.chart .bar-down { fill: var(--down); opacity: .35; }
.chart .bar-prot { fill: var(--prot); opacity: .3; }
.chart-legend { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 4px 0 10px; vertical-align: -1px; }
.lg.down { background: var(--down); opacity: .5; } .lg.prot { background: var(--prot); opacity: .5; }

.danger-zone { margin: 30px 0 10px; }
.foot { color: var(--muted); font-size: 13px; padding-top: 30px; padding-bottom: 30px; }

/* auth */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.auth-card { width: 100%; max-width: 360px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.auth-card h1 { font-size: 20px; }

/* toast */
.toast { position: fixed; right: 16px; bottom: 16px; max-width: 420px; background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.25); font-size: 14px; white-space: pre-line; z-index: 50; opacity: 0; transform: translateY(10px); transition: .2s; }
.toast.show { opacity: 1; transform: none; }

@media (max-width: 860px) {
  .grid2, .row2, .row3 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .hide-sm { display: none; }
  .ev { grid-template-columns: 1fr; gap: 0; }
  .ev-ico { display: none; }
}
.err-line.prot { color: var(--prot); }
select { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); font: inherit; font-weight: normal; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.t-up { color: var(--up); font-weight: 600; }
.chart .bar-human { fill: var(--up); opacity: .55; }
.chart .bar-bot { fill: var(--down); opacity: .6; }
.lg.human { background: var(--up); opacity: .6; }
.install p { margin: 0; }
.install details { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.install details[open] summary { margin-bottom: 8px; }
.stat span { overflow-wrap: anywhere; }

/* ---- список сайтов: панель инструментов, действия, массовые операции ---- */
.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 12px; flex-wrap: wrap; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 14px; cursor: pointer; }
.chip b { font-weight: 600; margin-left: 4px; color: var(--muted); }
.chip:hover { border-color: var(--muted); }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip.on b { color: inherit; opacity: .75; }
.chip.c-down b { color: var(--down); } .chip.c-prot b { color: var(--prot); } .chip.c-up b { color: var(--up); }
.chip.on.c-down b, .chip.on.c-prot b, .chip.on.c-up b { color: inherit; }
#site-search { max-width: 340px; }
th.cb, td.cb { width: 34px; padding-right: 0; }
td.cb input, th.cb input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }
th.actions { text-align: right; }
tr.sel td { background: color-mix(in srgb, var(--accent) 7%, transparent); }
tr.removing { opacity: .3; transition: opacity .2s; }
.ib { display: inline-grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--text); font-size: 15px; cursor: pointer; text-decoration: none; margin-left: 2px; padding: 0; }
.ib:hover { border-color: var(--muted); text-decoration: none; }
.ib.danger:hover { border-color: var(--down); background: var(--down-bg); }
.ib.loading { opacity: .5; pointer-events: none; }
.site-cell .url a { color: var(--muted); }
.bulkbar { position: sticky; bottom: 12px; margin-top: 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.25); z-index: 20; }
.bulkbar span { margin-right: auto; }
.bulkbar .btn { background: transparent; color: var(--bg); border-color: color-mix(in srgb, var(--bg) 35%, transparent); }
.bulkbar .btn.danger { color: #ff8a8a; border-color: #ff8a8a; }
.bulkbar[hidden], .no-match[hidden] { display: none; }
.inline-select { width: auto; padding: 5px 8px; font-size: 14px; }
@media (max-width: 860px) { #site-search { max-width: none; } .toolbar { flex-direction: column; align-items: stretch; } }
.ico { flex: none; display: block; } .btn .ico { display: inline-block; vertical-align: -3px; } .ib.danger { color: var(--down); }

/* ---- телефон: строки списка карточками, аккуратная шапка ---- */
@media (max-width: 860px) {
  .top-in { height: auto; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }
  nav { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  nav a { white-space: nowrap; }
  table.sites thead { display: none; }
  table.sites tr { display: grid; grid-template-columns: 24px auto 1fr; grid-template-areas: "cb st act" "site site site";
    gap: 8px 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  table.sites tr[hidden] { display: none; }
  table.sites td { padding: 0; border: 0; }
  table.sites td.cb { grid-area: cb; }
  table.sites td:nth-child(2) { grid-area: st; }
  table.sites td.site-cell { grid-area: site; }
  table.sites td.actions { grid-area: act; text-align: right; }
  .bulkbar { bottom: 8px; }
  .bulkbar span { width: 100%; }
}
@media (max-width: 860px) {
  table.sites tr.sel { background: color-mix(in srgb, var(--accent) 7%, transparent); }
  table.sites tr.sel td { background: transparent; }
}
