:root {
  --bg: #0f1420;
  --card: #171e2e;
  --line: #26304a;
  --text: #e6ebf5;
  --muted: #8a97b1;
  --accent: #4f8cff;
  --green: #34c759;
  --red: #ff4d4f;
  --amber: #ffb020;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* важнее авторских display, иначе hidden не прячет */
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
h1, h2, h3 { margin: 0 0 10px; }
.muted { color: var(--muted); }
.error { color: var(--red); min-height: 18px; margin-top: 8px; font-size: 13px; }
code { background: #0c1120; padding: 1px 5px; border-radius: 4px; }

input, button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 9px 12px;
}
input { background: #0c1120; color: var(--text); }
input:focus { outline: none; border-color: var(--accent); }
button { background: var(--accent); color: #fff; border: none; cursor: pointer; }
button:hover { filter: brightness(1.08); }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
button.danger { background: var(--red); }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 340px; display: flex; flex-direction: column; gap: 10px; }
.login-card h1 { text-align: center; }
.login-card p { text-align: center; margin: 0 0 6px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 16px;
}

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
}
.layout { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; padding: 16px 22px; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row input { flex: 1; min-width: 140px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #1c2437; }
tbody tr.selected { background: #202a42; }

.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.up { background: var(--green); }
.dot.down { background: var(--red); }
.dot.warn { background: #ffb020; }
.dot.unknown { background: var(--muted); }

.detail-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.stat-row { display: flex; flex-wrap: wrap; gap: 14px; margin: 6px 0 14px; }
.stat { background: #0c1120; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.stat b { display: block; font-size: 18px; }
.stat span { color: var(--muted); font-size: 12px; }
#agent-data { line-height: 1.7; }

/* график: период + контейнер */
.range-row { display: flex; gap: 6px; margin: 4px 0 12px; }
.range-btn {
  background: #0c1120; color: var(--muted); border: 1px solid var(--line);
  padding: 5px 12px; font-size: 13px; border-radius: 8px; cursor: pointer;
}
.range-btn:hover { color: var(--text); }
.range-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.chart-wrap { position: relative; height: 240px; width: 100%; }

/* аудит: строки label — value */
#audit-box, #agent-box { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.arow { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.arow > span { color: var(--muted); white-space: nowrap; }
.arow > b { text-align: right; overflow-wrap: anywhere; }

/* вкладки */
.brand-nav { display: flex; align-items: center; gap: 20px; }
.tabs { display: flex; gap: 4px; }
.tab { background: transparent; border: none; color: var(--muted); padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.tab:hover { color: var(--text); }
.tab.active { background: #202a42; color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* внутренние страницы */
#pages-box, #pages-list { margin-top: 10px; }
.page-item { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; }
.page-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.page-top a { overflow-wrap: anywhere; }
.link-btn { background: transparent; border: none; color: var(--red); cursor: pointer; font-size: 12px; padding: 0; }

/* цепочка редиректов */
.chain-step { padding: 8px 10px; border-left: 3px solid var(--line); margin: 4px 0; background: #0c1120; border-radius: 0 8px 8px 0; overflow-wrap: anywhere; font-size: 13px; }
.chain-step.ok { border-left-color: var(--green); }
.chain-step.redir { border-left-color: var(--amber); }
.chain-step.err { border-left-color: var(--red); }
.chain-step .code { display: inline-block; min-width: 34px; font-weight: 700; }
#redir-result { margin-top: 14px; }

/* обзор проекта */
.overview { display: flex; gap: 12px; flex-wrap: wrap; padding: 16px 22px 0; }
.ov-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 18px; min-width: 120px; flex: 1; }
.ov-card b { display: block; font-size: 22px; }
.ov-card span { color: var(--muted); font-size: 12px; }
.uptime-report { font-size: 13px; margin: 2px 0 12px; }

/* инструменты */
.tools-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; padding: 16px 22px; }
textarea { width: 100%; background: #0c1120; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; font: inherit; resize: vertical; }
.mini-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; }
.mini-table th, .mini-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.mini-table th { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.bulk-ok td:nth-child(3) { color: var(--green); font-weight: 700; }
.bulk-redir td:nth-child(3) { color: var(--amber); font-weight: 700; }
.bulk-err td:nth-child(3) { color: var(--red); font-weight: 700; }

/* внутренние страницы: действия + список без-alt */
.page-actions { display: inline-flex; gap: 10px; align-items: center; white-space: nowrap; }
.chart-btn { color: var(--accent) !important; }
.noalt-list { margin: 6px 0 4px; padding: 8px 10px; background: #0c1120; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; max-height: 220px; overflow: auto; }

/* Core Web Vitals + массовые цепочки */
#cwv-box { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.cwv-run { font-size: 12px; padding: 4px 12px; margin-left: 8px; }
.bulk-item { margin-bottom: 12px; }
.bulk-head { font-weight: 600; margin-bottom: 4px; overflow-wrap: anywhere; }

/* виды: список проектов / страница проекта */
.dash-body { padding: 16px 22px; }
#view-project { padding: 16px 22px; }
#back-btn { margin-bottom: 14px; }
.project-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.project-head h2 { margin: 0; }
#detail-url { font-size: 13px; display: inline-block; margin-top: 2px; overflow-wrap: anywhere; }
.proj-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.proj-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; align-items: start; }
.proj-grid .card { margin: 0; }
.proj-wide { grid-column: 1 / -1; }
@media (max-width: 900px) { .proj-grid { grid-template-columns: 1fr; } }

/* карточки сайтов на дашборде (в строку: имя · отклик · аптайм · SSL · домен · мини-график) */
.site-search { width: 100%; margin-bottom: 12px; }
.site-cards { display: flex; flex-direction: column; gap: 8px; }
.site-card { display: flex; align-items: center; gap: 16px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.site-card:hover { background: #1c2437; border-color: #33406080; }
.site-card .dot { flex: none; }
.sc-name { flex: 1 1 180px; min-width: 0; }
.sc-name b { display: block; overflow-wrap: anywhere; }
.sc-domain { font-size: 12px; }
.sc-metric { flex: none; width: 84px; text-align: right; font-size: 13px; }
.sc-metric b { font-weight: 600; }
.sc-metric span { display: block; color: var(--muted); font-weight: 400; font-size: 11px; margin-top: 1px; }
.sc-spark { flex: none; width: 120px; height: 34px; }
.spark { width: 120px; height: 34px; display: block; }
.sc-arrow { color: var(--muted); flex: none; font-size: 18px; }
@media (max-width: 820px) { .sc-spark { display: none; } }
@media (max-width: 620px) { .sc-metric { width: 62px; font-size: 12px; } }

/* фильтры, теги, мета проекта, отчёты */
.filters-row { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.filters-row .site-search { flex: 1 1 240px; margin-bottom: 0; }
select { background: #0c1120; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; font: inherit; cursor: pointer; }
.proj-meta { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.proj-meta input { flex: 1 1 150px; }
/* шапка карточки: заголовок слева, контрол справа */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head h3 { margin: 0; }
.interval-ctl, .sitemap-ctl { display: flex; align-items: center; gap: 9px; }
.interval-ctl .muted { font-size: 13px; }
.interval-ctl input[type="range"] { width: 130px; accent-color: #4f8cff; cursor: pointer; }
.set-val { font-weight: 600; min-width: 54px; color: var(--text); font-size: 13px; }
.saved-tick { color: #34c759; font-size: 12px; opacity: 0; transition: opacity .3s; }
.saved-tick.show { opacity: 1; }

/* анимированный переключатель true/false */
.switch { position: relative; display: inline-flex; width: 42px; height: 24px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch-track { flex: 1; background: #39415a; border-radius: 999px; transition: background .25s ease; }
.switch-thumb { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,.4); transition: transform .25s cubic-bezier(.34,1.56,.64,1); }
.switch input:checked ~ .switch-track { background: var(--green); }
.switch input:checked ~ .switch-track .switch-thumb { transform: translateX(18px); }
.switch-label { font-size: 13px; color: var(--muted); min-width: 28px; }
.sc-tags { margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 11px; background: #202a42; color: #a9b6d3; padding: 1px 8px; border-radius: 10px; }
.via-badge { display: inline-block; margin-top: 4px; font-size: 11px; color: #7fd3ff; background: rgba(79,140,255,0.12); border: 1px solid rgba(79,140,255,0.32); border-radius: 8px; padding: 1px 8px; }
.auth-switch { text-align: center; margin-top: 12px; font-size: 13px; }
.auth-switch a { color: #4f8cff; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }
.report-table th, .report-table td { white-space: nowrap; }
#report h3 { margin-bottom: 2px; }
.psi-row { display: flex; gap: 20px; flex-wrap: wrap; }
.psi-col { flex: 1 1 150px; }
.psi-head { font-weight: 600; margin-bottom: 4px; }

@media print {
  body * { visibility: hidden; }
  #report, #report * { visibility: visible; }
  #report { position: absolute; left: 0; top: 0; width: 100%; color: #000; }
  #report h3, #report .muted { color: #000; }
  #report td, #report th { border-bottom: 1px solid #ccc; }
}
