:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e3e6eb;
  --text: #161a21;
  --muted: #687080;
  --accent: #2f6df6;
  --accent-soft: #e8efff;
  --pass: #138a4f;
  --pass-soft: #e3f5ec;
  --warn: #a96400;
  --warn-soft: #fff3dd;
  --fail: #cc2b3b;
  --fail-soft: #fde8ea;
  --manual: #5b48c7;
  --manual-soft: #eeebff;
  --na: #6b7280;
  --na-soft: #eef0f3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1e222a;
    --border: #2a2f39;
    --text: #e7e9ee;
    --muted: #949bab;
    --accent: #6b97ff;
    --accent-soft: #1d2a48;
    --pass: #4fcf8e;
    --pass-soft: #12301f;
    --warn: #f0b354;
    --warn-soft: #362810;
    --fail: #ff6b78;
    --fail-soft: #3a1519;
    --manual: #a797ff;
    --manual-soft: #262046;
    --na: #9aa1ad;
    --na-soft: #23272f;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12.5px; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }

.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; padding: 0 24px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); font-size: 15px; }
.brand:hover { text-decoration: none; }
.logo { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 15px; }
.top-right { display: flex; align-items: center; gap: 12px; }

main { max-width: 1180px; margin: 0 auto; padding: 28px 24px 80px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid transparent; background: var(--accent); color: #fff;
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: filter 0.15s, background 0.15s;
}
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: transparent; color: var(--fail); border-color: var(--border); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }

input, textarea, select {
  width: 100%; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 11px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 64px; }
label { display: block; font-weight: 500; margin-bottom: 6px; }
.field { margin-bottom: 14px; }
.help { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

/* Нова перевірка */
.new-audit { display: flex; gap: 10px; }
.new-audit input { height: 44px; font-size: 15px; }
.new-audit .btn { height: 44px; padding: 0 20px; }
details.opts { margin-top: 12px; }
details.opts summary { cursor: pointer; color: var(--muted); user-select: none; }
.opts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.opts-grid .wide { grid-column: 1 / -1; }

/* Таблиця аудитів */
.section-head { display: flex; align-items: end; justify-content: space-between; margin: 28px 0 12px; gap: 12px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover td { background: var(--surface-2); }
.domain { font-weight: 600; }
.counts { display: flex; gap: 6px; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }

/* Бейджі */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.pill.pass { background: var(--pass-soft); color: var(--pass); }
.pill.warn, .pill.error { background: var(--warn-soft); color: var(--warn); }
.pill.fail { background: var(--fail-soft); color: var(--fail); }
.pill.manual { background: var(--manual-soft); color: var(--manual); }
.pill.na, .pill.none { background: var(--na-soft); color: var(--na); }
.pill.running, .pill.queued { background: var(--accent-soft); color: var(--accent); }
.tag { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; }

.score { font-weight: 700; font-variant-numeric: tabular-nums; }
.score.good { color: var(--pass); } .score.mid { color: var(--warn); } .score.bad { color: var(--fail); }

/* Сторінка аудиту */
.audit-head { display: grid; grid-template-columns: auto 1fr auto; gap: 22px; align-items: center; padding: 22px; }
.ring { --p: 0; --c: var(--accent); width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--surface-2) 0); }
.ring > span { width: 68px; height: 68px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: 22px; font-weight: 700; }
.audit-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 6px; color: var(--muted); font-size: 13px; }
.audit-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 10px; max-width: 420px; }
.progress > i { display: block; height: 100%; background: var(--accent); transition: width 0.4s; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 20px 0 12px; align-items: center; }
.chip { height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip[aria-pressed='true'] { background: var(--text); color: var(--surface); border-color: var(--text); }
.chip b { font-weight: 700; }

.group { margin-top: 18px; }
.group h2 { margin: 0 0 8px 2px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.check { border-bottom: 1px solid var(--border); }
.check:last-child { border-bottom: 0; }
.check-row { display: grid; grid-template-columns: 128px 1fr auto; gap: 14px; align-items: start; padding: 13px 16px; cursor: pointer; }
.check-row:hover { background: var(--surface-2); }
.check-title { font-weight: 600; }
.check-sum { color: var(--muted); font-size: 13px; margin-top: 2px; }
.check-sum .override { color: var(--manual); font-weight: 500; }
.check-row .side { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; }
.chev { transition: transform 0.15s; display: inline-block; }
.check.open .chev { transform: rotate(90deg); }
.check-body { display: none; padding: 0 16px 16px 158px; }
.check.open .check-body { display: block; }
.hint { background: var(--accent-soft); color: var(--text); border-radius: 8px; padding: 9px 12px; font-size: 13px; margin-bottom: 10px; }
.details { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; max-height: 380px; overflow: auto; white-space: pre-wrap; word-break: break-all; margin: 0 0 12px; line-height: 1.6; }
.details .l-pass { color: var(--pass); } .details .l-warn { color: var(--warn); } .details .l-fail { color: var(--fail); }
.manual-box { display: grid; grid-template-columns: 220px 1fr; gap: 10px; align-items: start; }
.manual-box .meta { grid-column: 2; font-size: 12px; color: var(--muted); }

.login { max-width: 360px; margin: 10vh auto 0; }
.login h1 { margin-bottom: 18px; }
.err { color: var(--fail); font-size: 13px; margin-bottom: 10px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface); padding: 9px 16px; border-radius: 8px; font-weight: 500; z-index: 50; }

@media (max-width: 760px) {
  main { padding: 18px 16px 60px; }
  .top { padding: 0 16px; }
  .new-audit { flex-direction: column; }
  .opts-grid { grid-template-columns: 1fr; }
  .audit-head { grid-template-columns: auto 1fr; }
  .audit-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .check-row { grid-template-columns: 1fr; gap: 6px; }
  .check-body { padding: 0 16px 16px; }
  .manual-box { grid-template-columns: 1fr; }
  .manual-box .meta { grid-column: 1; }
  .table .hide-sm { display: none; }
}
@media print {
  .top, .audit-actions, .toolbar, .manual-box select { display: none !important; }
  .check-body { display: block !important; padding-left: 16px; }
  .details { max-height: none; }
  body { background: #fff; }
}

[hidden] { display: none !important; }
.pill.done { background: var(--pass-soft); color: var(--pass); }
.pill.error.audit { background: var(--fail-soft); color: var(--fail); }

/* ---------- PageSpeed-віджет ---------- */
:root { --g-good: #0cce6b; --g-good-t: #008800; --g-avg: #ffa400; --g-avg-t: #c33300; --g-bad: #ff4e42; --g-bad-t: #cc0000; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) { --g-good-t: #3edc8a; --g-avg-t: #ffb547; --g-bad-t: #ff7a70; }
}
.psi { margin-bottom: 14px; }
.psi-tabs { display: flex; justify-content: center; gap: 28px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.psi-tab { display: inline-flex; align-items: center; gap: 8px; background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 6px 9px; font: inherit; font-size: 15px; color: var(--muted); cursor: pointer; }
.psi-tab[aria-selected='true'] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.psi-tab:disabled { opacity: 0.4; cursor: default; }
.psi-section { border-bottom: 1px solid var(--border); padding: 14px 2px; }
.psi-section:last-child { border-bottom: 0; }
.psi-sec-head { display: flex; align-items: center; gap: 12px; }
.psi-sec-title { font-size: 15px; font-weight: 500; flex: 1; }
.psi-sec-right { color: var(--accent); font-size: 14px; }
.psi-dot { width: 28px; height: 28px; border-radius: 50%; flex: none; background: var(--accent-soft); position: relative; }
.psi-dot::after { content: ''; position: absolute; inset: 9px; border-radius: 50%; background: var(--accent); }
.psi-dot.users::after { inset: 8px 10px; border-radius: 2px; }
.psi-lab { border: 1px solid var(--border); border-radius: 10px; padding: 22px 20px 16px; margin-top: 14px; }
.psi-gauges { display: flex; justify-content: center; gap: 28px; flex-wrap: wrap; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.psi-g { width: 104px; text-align: center; font-size: 13px; line-height: 1.35; }
.gauge { display: block; margin: 0 auto 8px; }
.gauge-sm { width: 56px; height: 56px; }
.gauge-lg { width: 128px; height: 128px; }
.gauge circle { fill: none; stroke-width: 8; }
.gauge .gauge-bg { stroke: transparent; }
.gauge .gauge-arc { stroke-linecap: butt; transition: stroke-dasharray 0.6s; }
.gauge text { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 34px; }
.gauge-lg text { font-size: 38px; }
.g-good .gauge-bg { fill: color-mix(in srgb, var(--g-good) 10%, transparent); } .g-good .gauge-arc { stroke: var(--g-good); } .g-good text { fill: var(--g-good-t); }
.g-avg .gauge-bg { fill: color-mix(in srgb, var(--g-avg) 10%, transparent); } .g-avg .gauge-arc { stroke: var(--g-avg); } .g-avg text { fill: var(--g-avg-t); }
.g-bad .gauge-bg { fill: color-mix(in srgb, var(--g-bad) 10%, transparent); } .g-bad .gauge-arc { stroke: var(--g-bad); } .g-bad text { fill: var(--g-bad-t); }
.g-none text { fill: var(--muted); }
.psi-main { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center; padding: 26px 10px 20px; }
.psi-main-left { text-align: center; }
.psi-main-title { font-size: 20px; font-weight: 500; margin-top: 4px; }
.psi-main-note { font-size: 12.5px; max-width: 340px; margin: 6px auto 12px; }
.psi-legend { display: flex; justify-content: center; gap: 16px; font-size: 12.5px; color: var(--muted); }
.psi-legend span { display: inline-flex; align-items: center; gap: 6px; }
.psi-shot { border: 1px solid var(--border); border-radius: 4px; overflow: hidden; background: var(--surface-2); }
.psi-shot img { display: block; }
.psi-shot.mobile img { width: 150px; max-height: 300px; object-fit: cover; object-position: top; }
.psi-shot.desktop img { width: 300px; max-height: 220px; object-fit: cover; object-position: top; }
.mk { display: inline-block; width: 10px; height: 10px; flex: none; }
.mk-good { background: var(--g-good); border-radius: 50%; }
.mk-avg { background: var(--g-avg); }
.mk-bad { width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 10px solid var(--g-bad); }
.mk-none { background: var(--na); border-radius: 50%; }
.v-good { color: var(--g-good-t); } .v-avg { color: var(--g-avg-t); } .v-bad { color: var(--g-bad-t); }
.psi-metrics-head { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); border-top: 1px solid var(--border); padding-top: 16px; }
.psi-metrics { display: grid; grid-template-columns: 1fr 1fr; column-gap: 32px; }
.psi-m { padding: 12px 0; border-bottom: 1px solid var(--border); }
.psi-m-title { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.psi-m-val { font-size: 26px; font-weight: 500; margin: 4px 0 0 20px; font-variant-numeric: tabular-nums; }
.psi-field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px 24px; margin-top: 14px; }
.psi-fm { padding: 10px 0; border-bottom: 1px solid var(--border); }
.psi-fm-title { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.psi-fm-val { font-size: 22px; font-weight: 500; margin: 2px 0 0 18px; }
.psi-fm-cat { font-size: 12px; margin-left: 18px; }
.psi-foot { font-size: 12px; margin-top: 14px; }
@media (max-width: 760px) {
  .psi-gauges { gap: 10px; }
  .psi-g { width: 74px; font-size: 11.5px; }
  .psi-main { grid-template-columns: 1fr; justify-items: center; }
  .psi-metrics { grid-template-columns: 1fr; }
  .psi-tabs { gap: 12px; }
}
@media print { .psi-tabs { display: none; } }
.psi-card { margin-top: 16px; padding: 18px 20px 6px; }
.psi-card-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 4px; }
.table .cb { width: 36px; padding-right: 0; }
.table .cb input, .table .cb input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.table .act { width: 44px; text-align: right; }
.table tr.sel td { background: var(--accent-soft); }
.icon-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 7px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--fail-soft); color: var(--fail); }
.bulk { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.bulk span { flex: 1; }
