:root {
  --bg: #f3f3f2;
  --panel: #ffffff;
  --ink: #1e1f22;
  --muted: #6b6e75;
  --line: #e2e2e0;
  --accent: #e3262e;
  --accent-ink: #ffffff;
  --dark: #3a3c41;
  --ok: #1f8a4c;
  --warn: #b7791f;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: inherit; }
h1 { font-size: 24px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 12px; }
main { max-width: 1280px; margin: 0 auto; padding: 24px 16px 60px; }

header#top { background: var(--dark); color: #fff; }
header#top:empty { display: none; }
.topbar { max-width: 1280px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.logo { font-weight: 700; text-decoration: none; display: flex; align-items: center; gap: 10px; }
.logo i { width: 14px; height: 22px; background: var(--accent); transform: skewX(-12deg); display: inline-block; }
.topbar nav { display: flex; gap: 14px; }
.topbar nav a { text-decoration: none; opacity: .8; }
.topbar nav a.on, .topbar nav a:hover { opacity: 1; text-decoration: underline; }
.topbar .me { margin-left: auto; display: flex; gap: 12px; align-items: center; font-size: 14px; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: rgba(255,255,255,.15); }
.badge.mock { background: var(--warn); color: #fff; }

.btn { border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 8px 14px; border-radius: 8px; cursor: pointer; font: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: #bbb; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(.95); }
.btn.ghost { background: transparent; color: inherit; border-color: rgba(255,255,255,.3); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.danger { color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

label.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--ink); padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(227,38,46,.25); border-color: var(--accent); }
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }

.center-card { max-width: 380px; margin: 60px auto; }
.center-card form { display: flex; flex-direction: column; gap: 12px; }
.err { color: var(--accent); font-size: 14px; min-height: 1em; }

.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .crumb { color: var(--muted); text-decoration: none; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; display: flex; flex-direction: column; }
.card:hover { border-color: #bbb; }
.card .thumb { aspect-ratio: 4/3; background: #ddd center/cover no-repeat; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.card .body { padding: 12px 14px; }
.card .title { font-weight: 600; }

.steps { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .steps { grid-template-columns: 1fr; } }
.step-n { display: inline-flex; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; align-items: center; justify-content: center; font-size: 13px; margin-right: 6px; }

.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 18px; text-align: center; color: var(--muted); cursor: pointer; margin-bottom: 12px; }
.drop.over { border-color: var(--accent); color: var(--accent); }
.sources { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 8px; }
.src-card { cursor: pointer; }
.src { position: relative; border: 3px solid transparent; border-radius: 8px; overflow: hidden; aspect-ratio: 4/3; background: #ddd center/cover; }
.src-card.sel .src { border-color: var(--accent); }
.src-tag { position: absolute; left: 4px; bottom: 4px; background: rgba(0,0,0,.65); color: #fff; font-size: 12px; padding: 1px 7px; border-radius: 4px; }
.src-card.sel .src-tag { background: var(--accent); }
.src-acts { display: flex; gap: 4px; margin-top: 4px; }
.src-acts .btn { flex: 1; justify-content: center; padding: 3px 6px; }
.drop { margin: 10px 0 0; }

.results { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.res { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.res.best { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(227,38,46,.2); }
.res .img { aspect-ratio: 4/3; background: #eee center/contain no-repeat; cursor: zoom-in; display: flex; align-items: center; justify-content: center; color: var(--muted); text-align: center; padding: 10px; }
.res .meta { padding: 10px 12px; font-size: 13px; }
.res .acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.status-error { color: var(--accent); }
.spin { width: 28px; height: 28px; border: 3px solid #ddd; border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

details.prompt summary { cursor: pointer; color: var(--muted); font-size: 13px; }
details.prompt pre { white-space: pre-wrap; font-size: 12px; background: var(--bg); padding: 8px; border-radius: 6px; max-height: 220px; overflow: auto; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 13px; color: var(--muted); font-weight: 500; }
td select { width: auto; }

/* lightbox / compare */
.lb { position: fixed; inset: 0; background: rgba(15,15,18,.92); z-index: 50; display: flex; flex-direction: column; }
.lb-bar { display: flex; gap: 10px; padding: 10px 16px; color: #fff; align-items: center; flex-wrap: wrap; }
.lb-stage { flex: 1; display: flex; align-items: center; justify-content: center; padding: 0 16px 16px; min-height: 0; }
.lb-stage > img { max-width: 100%; max-height: 100%; }
.cmp { position: relative; max-width: 100%; max-height: 100%; user-select: none; touch-action: none; cursor: ew-resize; }
.cmp img { display: block; max-width: 100%; max-height: calc(100vh - 90px); }
.cmp .after { position: absolute; inset: 0; overflow: hidden; }
.cmp .after img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: fill; max-height: none; }
.cmp .handle { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; box-shadow: 0 0 6px rgba(0,0,0,.6); }
.cmp .lbl { position: absolute; top: 8px; background: rgba(0,0,0,.55); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 4px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--dark); color: #fff; padding: 10px 16px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; }
#toast.on { opacity: 1; }
#toast.bad { background: var(--accent); }

/* step 2: вкладки и формы */
.col { display: flex; flex-direction: column; gap: 10px; }
.tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 8px; margin-bottom: 14px; }
.tab { flex: 1; border: 0; background: transparent; padding: 7px 8px; border-radius: 6px; cursor: pointer; font: inherit; color: var(--muted); }
.tab.on { background: var(--panel); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.f-title { font-size: 13px; color: var(--muted); }

/* разметка места на фото местности */
.zone-wrap { position: relative; user-select: none; touch-action: none; cursor: crosshair; line-height: 0; border-radius: 8px; overflow: hidden; }
.zone-wrap > img { width: 100%; display: block; }
.zone-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.z-poly { fill: rgba(227,38,46,.18); stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.z-poly.open { fill: none; stroke-dasharray: 6 4; }
.z-line { fill: none; stroke: #ff00ff; stroke-width: 4; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
#zhandles i { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); cursor: grab; }
#zhandles i.h-line { border-color: #ff00ff; }
#zhandles i.first { width: 18px; height: 18px; margin: -9px 0 0 -9px; background: var(--accent); }
.zone-preview { position: absolute; object-fit: contain; object-position: center bottom; opacity: .7; pointer-events: none; }
.zone-tools { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.zone-hint { min-height: 2.6em; margin: 0 0 8px; }
.dot-line { display: inline-block; width: 14px; height: 3px; background: #ff00ff; border-radius: 2px; margin-right: 2px; }
.cutout-note { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: #fff7e6; border: 1px solid #f0d9a8; border-radius: 8px; padding: 8px 10px; font-size: 13px; margin-bottom: 8px; }
.z-ruler { stroke: #00b8d9; stroke-width: 1.5; stroke-dasharray: 8 5; vector-effect: non-scaling-stroke; }
.z-rubber { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.z-rubber.line { stroke: #ff00ff; }
#zhandles i.h-ruler { border-color: #00b8d9; width: 10px; height: 10px; margin: -5px 0 0 -5px; }
.dot-ruler { display: inline-block; width: 14px; height: 0; border-top: 2px dashed #00b8d9; margin-right: 2px; vertical-align: middle; }
.zone-loupe { position: absolute; top: 8px; width: 150px; height: 150px; border-radius: 50%; border: 3px solid #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,.45); background-repeat: no-repeat; pointer-events: none; z-index: 2; }
.zone-loupe::before, .zone-loupe::after { content: ''; position: absolute; background: rgba(255,0,0,.85); }
.zone-loupe::before { left: 50%; top: 30%; bottom: 30%; width: 1px; }
.zone-loupe::after { top: 50%; left: 30%; right: 30%; height: 1px; }

/* пользователи */
.pw-row { display: flex; gap: 6px; }
.pw-row input { font-family: ui-monospace, Consolas, monospace; }
.created-box { border-color: var(--ok); background: #f1faf4; }
.created-box pre { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.table-wrap { overflow-x: auto; }
tr.off td { color: var(--muted); }
.st-on { color: var(--ok); white-space: nowrap; }
.st-off { color: var(--muted); white-space: nowrap; }
.acts-cell { white-space: nowrap; }
.acts-cell .btn { margin: 2px 0; }
code { font-family: ui-monospace, Consolas, monospace; background: var(--bg); padding: 1px 6px; border-radius: 4px; }
