:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1c1f24;
  --muted: #6b7280;
  --line: #e3e6eb;
  --accent: #0a7cff;
  --accent-text: #ffffff;
  --ok-bg: #e7f6ec; --ok-text: #17663a;
  --err-bg: #fdecec; --err-text: #a3221d;
  --warn-bg: #fff4e0; --warn-text: #8a5300;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a; --card: #1d2026; --text: #e8eaed; --muted: #9aa0a8; --line: #2e323a;
    --accent: #4c9dff; --ok-bg: #173323; --ok-text: #7fd6a0; --err-bg: #3a1c1c; --err-text: #f2a19c;
    --warn-bg: #3a2c12; --warn-text: #f0c070;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 14px 24px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text); }
.top nav { display: flex; gap: 16px; align-items: center; }
main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px; display: block; color: var(--text); }
.card.narrow { max-width: 480px; margin: 40px auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid .card { margin-bottom: 0; }
.project-card:hover { border-color: var(--accent); text-decoration: none; }
.card-title { font-weight: 600; font-size: 16px; }
.head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  margin-bottom: 16px; flex-wrap: wrap; }
.crumbs { color: var(--muted); margin: 0 0 8px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.mono { font-family: ui-monospace, Menlo, monospace; }
.small { font-size: 12px; word-break: break-all; }
dl { margin: 0; }
dl > div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0;
  border-bottom: 1px solid var(--line); }
dl > div:last-child { border-bottom: 0; }
dt { color: var(--muted); }
dd { margin: 0; text-align: right; }
dl.mini { margin-top: 12px; }
.form { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%; }
textarea { resize: vertical; }
button, .button { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 8px; padding: 9px 16px; cursor: pointer; display: inline-block; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.button:hover { text-decoration: none; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); }
button.danger, .danger { color: var(--err-text); }
form.inline { display: inline; }
.upload { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.upload select { width: auto; }
.upload input[type=file] { flex: 1; min-width: 200px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; background: var(--ok-bg); color: var(--ok-text); }
.flash.error { background: var(--err-bg); color: var(--err-text); }
.badge { display: inline-block; white-space: nowrap; font-size: 12px; padding: 2px 8px; border-radius: 99px;
  background: var(--line); color: var(--muted); }
.badge.ok { background: var(--ok-bg); color: var(--ok-text); }
.badge.no_access, .badge.error { background: var(--err-bg); color: var(--err-text); }
.badge.warn { background: var(--warn-bg); color: var(--warn-text); margin-top: 8px; }
table.list { width: 100%; border-collapse: collapse; margin-top: 16px; }
table.list th, table.list td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
table.list th { color: var(--muted); font-weight: 500; font-size: 13px; }
.note { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 14px; }
.note-head { display: flex; justify-content: space-between; }
.note p { margin: 6px 0 0; white-space: pre-wrap; }
.empty { text-align: center; }
.service { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin: 12px 0; }
.service.new { border-style: dashed; }
.service-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.service-name { display: flex; gap: 8px; flex: 1 1 100%; min-width: 0; }
.service-name input { font-weight: 600; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin: 12px 0 6px; }
.photo { position: relative; margin: 0; border-radius: 8px; overflow: hidden; background: var(--line); aspect-ratio: 4 / 3; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo form { position: absolute; top: 4px; right: 4px; }
.photo-del { width: 26px; height: 26px; padding: 0; border-radius: 50%; border: 0; line-height: 26px;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: 16px; }
.photo-badge { position: absolute; left: 4px; bottom: 4px; margin: 0; }
.service .upload { margin-top: 8px; }
.add-service { width: 100%; border-style: dashed; margin-top: 4px; }
.table-wrap { overflow-x: auto; }
.table-wrap table.list { min-width: 560px; }
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin: 8px 0 4px; }
.stat { display: flex; flex-direction: column; min-width: 140px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 10px; }
.stat-num { font-size: 22px; font-weight: 600; }
.stat-num.bad { color: var(--err-text); }
.stat-num.small-num { font-size: 15px; padding: 6px 0; }
.small-text { font-size: 13px; }
.goal-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px;
  align-items: end; margin: 12px 0; }
.inline-block { display: inline-block; }
.plan { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.messages { margin: 8px 0; padding-left: 20px; }
.messages li { margin: 4px 0; }
.badge.error { background: var(--err-bg); color: var(--err-text); }
@media (max-width: 640px) {
  table.files th:nth-child(2), table.files td:nth-child(2), table.files th:nth-child(4), table.files td:nth-child(4) { display: none; }
}
.copy-link { margin-top: 8px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; background: var(--card); }
.service.missing { border-color: var(--err-text); }
.progress { display: block; width: 100%; height: 6px; margin: 4px 0 12px; border: 0; border-radius: 99px;
  overflow: hidden; background: var(--line); appearance: none; -webkit-appearance: none; }
.progress::-webkit-progress-bar { background: var(--line); }
.progress::-webkit-progress-value { background: var(--accent); }
.progress::-moz-progress-bar { background: var(--accent); }
h2.mt { margin-top: 18px; }
.step { border-top: 1px solid var(--line); padding: 14px 0; }
.step-head { display: flex; align-items: center; gap: 10px; }
.step-mark { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--line); color: var(--muted); font-size: 13px; font-weight: 600; flex: none; }
.step.done .step-mark { background: var(--ok-bg); color: var(--ok-text); }
.step p { margin: 6px 0 8px; }
.howto { margin: 6px 0 10px; padding-left: 20px; }
.form.compact { max-width: 420px; }
label.check { flex-direction: row; align-items: flex-start; gap: 8px; font-weight: 400; }
label.check input { width: auto; margin-top: 4px; }
.badge.progress-badge { margin-top: 8px; }
.assistant-form { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 6px; }
.assistant-buttons { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.request { border-top: 1px solid var(--line); padding: 12px 0; }
.request-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.request-reply { margin: 6px 0; white-space: pre-wrap; }
.action { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
.action.done { border-color: var(--ok-text); }
.action.failed { border-color: var(--err-text); }
.action-title { font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.action-diff { font-size: 14px; margin-top: 4px; white-space: pre-line; }
.request-buttons { display: flex; gap: 8px; margin-top: 6px; }
.task { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.video-block { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; }
.video { width: 100%; max-height: 360px; border-radius: 8px; background: #000; }
.video-meta { margin: 4px 0 6px; }
.photo-pick { position: absolute; top: 4px; left: 4px; background: rgba(255,255,255,.85); border-radius: 6px;
  padding: 2px 4px; display: flex; }
.photo-pick input { width: 18px; height: 18px; margin: 0; }
.photo-badge-top { position: absolute; left: 4px; bottom: 4px; margin: 0; }
.edit-form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 13px; padding: 4px 10px; border-radius: 99px; }
.edit-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.edits { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.edit { display: flex; gap: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; flex-wrap: wrap; }
.edit.applied { border-color: var(--ok-text); }
.edit.error { border-color: var(--err-text); }
.edit-pics { display: flex; align-items: center; gap: 8px; }
.edit-pics img, .edit-wait { width: 120px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; display: block; }
.edit-wait { display: flex; align-items: center; justify-content: center; background: var(--line); font-size: 13px; }
.arrow { color: var(--muted); }
.edit-body { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 6px; }
.edit-buttons { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bulk { display: flex; gap: 8px; align-items: center; margin: 8px 0; flex-wrap: wrap; }
.ad { border: 1px solid var(--line); border-radius: 10px; margin: 8px 0; }
.ad.off { opacity: .6; }
.ad summary { display: flex; gap: 10px; align-items: center; padding: 10px 12px; cursor: pointer; flex-wrap: wrap; }
.ad summary input { width: auto; }
.ad-title { font-weight: 600; flex: 1; min-width: 160px; }
.ad-body { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.ad-row { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; }
.photo.pick { cursor: pointer; }
.photo.pick input { position: absolute; top: 6px; left: 6px; width: 18px; height: 18px; }
code { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }

/* Позиции и ставки */
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; align-items: end; }
form.stack { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; max-width: 640px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row label { flex: 1 1 120px; }
.target { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 16px; }
.pre { white-space: pre-line; }
details > summary { cursor: pointer; font-weight: 500; }
h3.mt { margin-top: 16px; }
.target .nowrap form.inline + form.inline { margin-left: 12px; }
.with-reveal { display: flex; gap: 6px; align-items: center; }
.with-reveal input { flex: 1; }
button.reveal { text-decoration: none; font-size: 16px; padding: 0 4px; }
.stats-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0; }
ol.recs { padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
.items-table td.num, .items-table th.num { text-align: right; white-space: nowrap; }
.items-table th a { color: inherit; text-decoration: none; }
.items-table th a.active { text-decoration: underline; }
/* Блок «Клиент»: подпись слева, значение и кнопки — слева в своей колонке */
.kv { display: flex; flex-direction: column; }
.kv-row { display: grid; grid-template-columns: 200px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.kv-row:last-child { border-bottom: 0; }
.kv-key { color: var(--muted); }
.kv-actions { margin-top: 8px; }
.kv .hint { margin-top: 6px; }
.ok-text { color: var(--ok-text); font-weight: 500; }
.kv .tz-form select { width: auto; }
@media (max-width: 640px) { .kv-row { grid-template-columns: 1fr; gap: 4px; } }
form.tz-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
form.tz-form select { width: auto; max-width: 100%; }
/* Свёрнутые блоки (анализ аккаунта) */
details.spoiler > summary { list-style: none; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
details.spoiler > summary::-webkit-details-marker { display: none; }
details.spoiler > summary::before { content: "▸"; color: var(--muted); }
details.spoiler[open] > summary::before { content: "▾"; }
.spoiler-title { font-size: 20px; font-weight: 600; }
.spoiler-body { margin-top: 14px; }
.analysis-run { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
p.lead { font-size: 16px; margin: 12px 0; max-width: 820px; }
ul.tight { margin: 4px 0; padding-left: 20px; }
ul.tight li { margin: 2px 0; }
.recs { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.rec { border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.rec-high { border-left-color: var(--err-text); }
.rec-medium { border-left-color: #d9a400; }
.rec-low { border-left-color: var(--ok-text); }
.rec-title { font-weight: 600; margin-bottom: 4px; }
.badge.bad { background: var(--err-bg); color: var(--err-text); }
table.list td.num, table.list th.num { text-align: right; white-space: nowrap; }
.pick-list { max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  display: flex; flex-direction: column; gap: 6px; }
.label { font-weight: 500; margin-bottom: 4px; }
