:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --text: #1b2230;
  --muted: #5d6879;
  --border: #e1e6ee;
  --accent: #3557d4;
  --accent-soft: #e9eefc;
  --ok: #1d7f47;
  --ok-soft: #e5f4ea;
  --warn: #a86a06;
  --warn-soft: #fbf1dc;
  --bad: #c1352f;
  --bad-soft: #fbe7e5;
  --info: #5d6879;
  --bar: #c9d4f6;
  --shadow: 0 1px 2px rgba(20, 30, 50, .05), 0 4px 16px rgba(20, 30, 50, .04);
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1117;
    --surface: #161a22;
    --surface-2: #1b2029;
    --text: #e5e9f0;
    --muted: #9aa4b3;
    --border: #2a303c;
    --accent: #7d98ff;
    --accent-soft: #1f2843;
    --ok: #4cc283;
    --ok-soft: #15291f;
    --warn: #e2a73f;
    --warn-soft: #2d2513;
    --bad: #f07a72;
    --bad-soft: #321a19;
    --info: #9aa4b3;
    --bar: #33416e;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
[hidden] { display: none !important; }

/* шапка */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  height: 56px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 650; }
.conn { display: flex; gap: 14px; margin-left: auto; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.conn .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--bad); vertical-align: 1px; }
.conn .dot.on { background: var(--ok); }
.conn .dot.mid { background: var(--warn); }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.who form { margin: 0; }

/* раскладка */
.layout {
  display: grid; grid-template-columns: minmax(340px, 420px) minmax(0, 1fr); gap: 20px;
  max-width: 1440px; margin: 0 auto; padding: 20px;
  align-items: start;
}
.side { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 16px; max-height: calc(100vh - 96px); overflow: auto; padding-bottom: 4px; }
@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 12px 16px; }
  input, select, textarea { font-size: 16px !important; }   /* iOS Safari не увеличивает страницу при касании поля */
  .side { position: static; max-height: none; overflow: visible; }
  .conn { display: none; }
}
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { display: flex; align-items: center; gap: 10px; }

/* форма */
.composer { display: flex; flex-direction: column; gap: 12px; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; }
.tab { flex: 1; border: 0; background: none; padding: 7px 10px; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 14px; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.label { font-size: 13px; font-weight: 600; }
input[type=text], input[type=url], input[type=password], input:not([type]), select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 44px; }
#title { font-weight: 600; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.url-row { display: flex; gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }
.files { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.composer.drag { outline: 2px dashed var(--accent); outline-offset: 4px; }
.actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 9px 14px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); padding: 10px 18px; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { padding: 6px 10px; font-weight: 500; }
.btn:disabled { opacity: .55; cursor: default; }
.btn kbd { font: 11px var(--mono); opacity: .75; border: 1px solid rgba(255,255,255,.4); border-radius: 4px; padding: 1px 4px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-size: 14px; }
.link:hover { text-decoration: underline; }
.error { color: var(--bad); font-size: 14px; }
.hint { color: var(--muted); }
.switch { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); cursor: pointer; }

/* история */
.hist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.hist li a { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 6px; border-radius: 8px; color: var(--text); text-decoration: none; }
.hist li a:hover { background: var(--surface-2); }
.hist .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.hist .m { grid-column: 1; font-size: 12px; color: var(--muted); }
.hist .s { grid-row: 1 / span 2; grid-column: 2; display: flex; gap: 4px; align-items: center; }

/* результаты */
.results { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
#progress, #report, .card { scroll-margin-top: 66px; }
.empty { padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; color: var(--muted); }
.steps b { color: var(--text); }
.empty .btn { align-self: flex-start; }
.progress h2 { margin-bottom: 12px; }
.stages { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.stages li { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.stages li::before { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); flex: none; }
.stages li.now { color: var(--text); font-weight: 600; }
.stages li.now::before { border-color: var(--accent); border-right-color: transparent; animation: spin .8s linear infinite; }
.stages li.done::before { background: var(--ok); border-color: var(--ok); }
@keyframes spin { to { transform: rotate(360deg); } }
.report { display: flex; flex-direction: column; gap: 16px; }

.banner { padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); font-size: 14px; }
.banner.warn { background: var(--warn-soft); }

/* сводка */
.summary { display: grid; grid-template-columns: auto auto 1fr; gap: 20px; align-items: center; }
@media (max-width: 720px) { .summary { grid-template-columns: auto auto; } .summary .sum-main { grid-column: 1 / -1; } }
.ring {
  --v: 0; --c: var(--accent);
  width: 92px; height: 92px; border-radius: 50%; position: relative; flex: none;
  background: conic-gradient(var(--c) calc(var(--v) * 1%), var(--surface-2) 0);
  display: grid; place-items: center;
}
.ring::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--surface); }
.ring span { position: relative; z-index: 1; font-size: 26px; font-weight: 700; }
.score-box { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.score-box .cap { font-size: 13px; font-weight: 600; }
.sum-main { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.mainq { font-size: 18px; font-weight: 650; }
.mainq .cnt { color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; white-space: nowrap; }
.chip.acc { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
button.chip { cursor: pointer; }
button.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.nav { display: flex; gap: 6px; flex-wrap: wrap; position: sticky; top: 64px; z-index: 5; padding: 6px; background: var(--bg); border-radius: 10px; }
.nav a { padding: 5px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none; font-size: 13.5px; }
.nav a:hover { border-color: var(--accent); }

/* бейджи оценок */
.badge { display: inline-grid; place-items: center; min-width: 38px; height: 26px; padding: 0 7px; border-radius: 7px; font-weight: 700; font-size: 13.5px; }
.badge.g { background: var(--ok-soft); color: var(--ok); }
.badge.y { background: var(--warn-soft); color: var(--warn); }
.badge.r { background: var(--bad-soft); color: var(--bad); }
.badge.n { background: var(--surface-2); color: var(--muted); }

/* проверки */
.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.checks li { display: grid; grid-template-columns: 18px 1fr; gap: 8px; font-size: 14px; align-items: start; }
.checks li::before { content: "✓"; font-weight: 700; color: var(--ok); text-align: center; }
.checks li.warn::before { content: "!"; color: var(--warn); }
.checks li.bad::before { content: "✕"; color: var(--bad); }
.checks li.info::before { content: "i"; color: var(--info); font-style: italic; }

/* заголовки */
.current { padding: 14px; border-radius: 10px; background: var(--surface-2); display: flex; flex-direction: column; gap: 10px; }
.current .ttl { font-size: 17px; font-weight: 650; }
.verdict { font-size: 14px; }
.verdict b { font-weight: 700; }
.variants { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.variant { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px 12px; align-items: start; }
.variant .ttl { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.variant .chip { white-space: normal; }
.variant .meta { grid-column: 2; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12.5px; color: var(--muted); }
.variant .why { grid-column: 2; font-size: 13.5px; color: var(--muted); }
.variant details { grid-column: 2; font-size: 13px; }
.variant .acts { grid-row: 1 / span 3; grid-column: 3; display: flex; flex-direction: column; gap: 6px; }
.icon-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 5px 8px; cursor: pointer; font-size: 12.5px; white-space: nowrap; color: var(--text); }
.icon-btn:hover { border-color: var(--accent); }
.icon-btn.done { color: var(--ok); border-color: var(--ok); }
@media (max-width: 620px) {
  .variant { grid-template-columns: auto minmax(0, 1fr); }
  .variant .acts { grid-row: auto; grid-column: 1 / -1; flex-direction: row; }
}
.mine { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--border); display: flex; flex-direction: column; gap: 8px; }
.mine-row { display: flex; gap: 10px; align-items: center; }
.mine-row input { flex: 1; font-weight: 600; }
.counter { font-size: 12px; color: var(--muted); white-space: nowrap; }
details summary { cursor: pointer; color: var(--accent); }
details[open] summary { margin-bottom: 6px; }

/* спрос */
.demand-top { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 18px; }
@media (max-width: 820px) { .demand-top { grid-template-columns: minmax(0, 1fr); } }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
table.ph { width: 100%; border-collapse: collapse; font-size: 14px; }
table.ph th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 4px 6px; border-bottom: 1px solid var(--border); }
table.ph td { padding: 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.ph tr.other td { color: var(--muted); }
table.ph tr.main td:first-child { font-weight: 700; }
.cnt-cell { width: 34%; }
.barwrap { display: flex; align-items: center; gap: 8px; }
.bar { height: 8px; border-radius: 4px; background: var(--bar); min-width: 2px; }
.tr.main .bar, tr.main .bar { background: var(--accent); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 13px; }
.mark { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; font-size: 12px; font-weight: 700; }
.mark.y { background: var(--ok-soft); color: var(--ok); }
.mark.n { background: var(--surface-2); color: var(--muted); }
.q { font-size: 11px; color: var(--accent); margin-left: 4px; }
.spark { display: flex; flex-direction: column; gap: 6px; }
.spark svg { width: 100%; height: 110px; }
.spark .bars rect { fill: var(--bar); }
.spark .bars rect.max { fill: var(--accent); }
.spark text { fill: var(--muted); font-size: 9px; }
.table-scroll { overflow-x: auto; }

/* сниппеты */
.serp { display: flex; flex-direction: column; gap: 12px; }
.serp-box { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: var(--surface); min-width: 0; max-width: 660px; }
.serp-box .eng { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.serp-y .t { color: #1a0dab; font: 18px/1.3 Arial, sans-serif; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 560px; }
.serp-y .u { color: #006000; font: 13px Arial, sans-serif; margin: 2px 0; }
.serp-y .d { color: #333; font: 13px/1.4 Arial, sans-serif; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; max-width: 560px; }
.serp-g .u { color: #202124; font: 12px Arial, sans-serif; }
.serp-g .t { color: #1a0dab; font: 20px/1.3 Arial, sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 600px; margin: 2px 0; }
.serp-g .d { color: #4d5156; font: 14px/1.58 Arial, sans-serif; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 600px; }
@media (prefers-color-scheme: dark) {
  .serp-box { background: #fff; }
  .serp-box .eng { color: #5f6368; }
}
.cut { font-size: 12px; color: var(--warn); margin-top: 6px; }
.textblock { border-left: 3px solid var(--accent); padding: 8px 12px; background: var(--surface-2); border-radius: 0 8px 8px 0; display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.sub { font-size: 13px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin: 14px 0 8px; }

/* GEO */
.geo-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
@media (max-width: 900px) { .geo-grid { grid-template-columns: minmax(0, 1fr); } }
.recs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.recs li { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; }
.recs .why { grid-column: 2; font-size: 13px; color: var(--muted); }
.prio { font-size: 11.5px; font-weight: 700; padding: 2px 7px; border-radius: 6px; white-space: nowrap; height: fit-content; }
.prio.высокий { background: var(--bad-soft); color: var(--bad); }
.prio.средний { background: var(--warn-soft); color: var(--warn); }
.prio.низкий { background: var(--surface-2); color: var(--muted); }
.faq { display: flex; flex-direction: column; gap: 10px; }
.faq .qq { font-weight: 600; }
pre.code { margin: 0; padding: 12px; background: var(--surface-2); border-radius: 8px; overflow: auto; max-height: 260px; font: 12px/1.5 var(--mono); }
.facts { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.wm td.num { text-align: right; }
ul.kv { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
ul.kv li { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
ul.kv li span:first-child { min-width: 0; overflow-wrap: anywhere; }

/* вход */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; padding: 28px; }
.login h1 { font-size: 20px; }
.login .btn { width: 100%; }

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