:root {
  --ink: #12191f;
  --slate: #55656f;
  --muted: #8a98a1;
  --hairline: #dee5e8;
  --paper: #eff3f4;
  --card: #ffffff;
  --accent: #0a6b63;
  --accent-soft: #e3f0ee;
  --amber: #9c6205;
  --amber-soft: #faf0dd;
  --red: #a32e24;
  --red-soft: #fbeae8;
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- shell */

.shell { display: flex; min-height: 100vh; }

.rail {
  width: 232px;
  flex: 0 0 232px;
  background: var(--card);
  border-right: 1px solid var(--hairline);
  padding: 22px 0;
  display: flex;
  flex-direction: column;
}

.brand {
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 14px;
}
.brand .mark {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.14em;
  color: var(--accent);
  display: block;
}
.brand .host {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  display: block;
  margin-top: 3px;
}

.rail nav { display: flex; flex-direction: column; gap: 1px; padding: 0 10px; }
.rail nav a {
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--slate);
  font-size: 14px;
}
.rail nav a:hover { background: var(--paper); text-decoration: none; color: var(--ink); }
.rail nav a.on {
  background: var(--accent-soft);
  color: var(--accent);
}

.rail .who {
  margin-top: auto;
  padding: 16px 20px 0;
  border-top: 1px solid var(--hairline);
  font-size: 13px;
}
.rail .who .name { font-family: var(--mono); font-size: 12px; color: var(--ink); }
.rail .who .role { color: var(--muted); font-size: 12px; }
.rail .who form { margin: 10px 0 0; }

.main { flex: 1; min-width: 0; padding: 28px 32px 64px; }
.wrap { max-width: 1080px; }

h1 { font-size: 21px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 600; margin: 30px 0 10px; }
.sub { color: var(--slate); font-size: 14px; margin: 0 0 22px; }

/* ---------------------------------------------------------------- banners */

.banner {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 18px;
  border: 1px solid var(--hairline);
  background: var(--card);
}
.banner.demo { background: var(--amber-soft); border-color: #e8d5ac; color: #6d4503; }
.banner.err { background: var(--red-soft); border-color: #edc4bf; color: var(--red); }
.banner.ok { background: var(--accent-soft); border-color: #bcdcd7; color: var(--accent); }
.banner code { font-family: var(--mono); font-size: 12px; }

/* ---------------------------------------------------------------- cards */

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.card {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 14px 16px;
}
.card .label { font-size: 12px; color: var(--muted); text-transform: none; }
.card .value {
  font-family: var(--mono);
  font-size: 26px;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  margin-top: 4px;
}
.card .value.warn { color: var(--red); }

/* ---------------------------------------------------------------- table */

.panel {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  overflow: hidden;
}

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.06em;
  padding: 9px 14px;
  border-bottom: 1px solid var(--hairline);
  background: #fafcfc;
  white-space: nowrap;
}
td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--hairline);
  font-size: 13px;
  vertical-align: middle;
}
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fbfdfd; }

td.m, .m { font-family: var(--mono); font-variant-numeric: tabular-nums; }
td.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.dim { color: var(--muted); }

.tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--hairline);
  color: var(--slate);
}
.tag.test { background: var(--amber-soft); border-color: #e8d5ac; color: #6d4503; }

/* ------------------------------------------------------- pipeline strip */

.pipe { display: inline-flex; gap: 3px; vertical-align: middle; }
.pipe i {
  display: block;
  width: 26px;
  height: 6px;
  border-radius: 2px;
  background: transparent;
  border: 1px solid var(--hairline);
}
.pipe i.done { background: var(--accent); border-color: var(--accent); }
.pipe i.running { background: var(--amber); border-color: var(--amber); }
.pipe i.failed { background: var(--red); border-color: var(--red); }

.pipe-legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.pipe-legend span { display: flex; align-items: center; gap: 6px; }
.pipe-legend i { width: 18px; height: 6px; border-radius: 2px; border: 1px solid var(--hairline); display: block; }

@media (prefers-reduced-motion: no-preference) {
  .pipe i.running { animation: pulse 1.6s ease-in-out infinite; }
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* ---------------------------------------------------------------- forms */

label.field { display: block; margin-bottom: 16px; }
label.field > span {
  display: block;
  font-size: 13px;
  color: var(--slate);
  margin-bottom: 5px;
}
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], textarea, select {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 14px;
}
input.m, textarea.m { font-family: var(--mono); font-size: 13px; }
textarea { resize: vertical; min-height: 76px; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: none; }

.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px 20px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--slate); }
.check input { accent-color: var(--accent); }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 18px; }

button, .btn {
  font-family: var(--ui);
  font-size: 14px;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button:hover, .btn:hover { filter: brightness(1.08); text-decoration: none; }
button.ghost, .btn.ghost {
  background: var(--card);
  color: var(--slate);
  border-color: var(--hairline);
}
button.ghost:hover, .btn.ghost:hover { color: var(--ink); background: var(--paper); }
button.link { background: none; border: none; color: var(--slate); padding: 0; font-size: 13px; text-decoration: underline; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.pad { padding: 18px; }

fieldset {
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 16px 18px;
  margin: 0 0 18px;
  background: var(--card);
}
legend { font-size: 13px; font-weight: 600; padding: 0 6px; }
fieldset.risk { border-color: #e8d5ac; background: var(--amber-soft); }
fieldset.risk legend { color: #6d4503; }
fieldset .note { font-size: 12px; color: var(--slate); margin: 0 0 14px; }

.review {
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: #fafcfc;
}
.review .head { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 8px; }

/* ---------------------------------------------------------------- login */

.gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.gate .box { width: 100%; max-width: 340px; }
.gate .brand { border: 0; padding: 0 0 22px; margin: 0; }
.gate .box form { background: var(--card); border: 1px solid var(--hairline); border-radius: 10px; padding: 22px; }
.gate button { width: 100%; margin-top: 6px; }
.gate .hint { font-size: 12px; color: var(--muted); margin-top: 14px; line-height: 1.7; }
.gate .hint code { font-family: var(--mono); }

/* ---------------------------------------------------------------- misc */

.empty { padding: 34px 18px; text-align: center; color: var(--muted); font-size: 14px; }
.pager { display: flex; gap: 10px; align-items: center; margin-top: 14px; font-size: 13px; color: var(--slate); }
.split { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: start; }
.picks { display: flex; flex-direction: column; gap: 4px; }
.picks a { padding: 7px 11px; border: 1px solid var(--hairline); border-radius: 6px; background: var(--card); font-size: 13px; color: var(--slate); }
.picks a.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .rail { width: auto; flex: none; border-right: 0; border-bottom: 1px solid var(--hairline); padding: 16px 0; }
  .rail nav { flex-direction: row; flex-wrap: wrap; }
  .rail .who { margin-top: 14px; }
  .main { padding: 20px 16px 48px; }
  .split { grid-template-columns: 1fr; }
}

/* ------------------------------------------------ additions for real schema */

.pipe i.unknown { background: repeating-linear-gradient(45deg, var(--hairline) 0 2px, transparent 2px 4px); border-color: var(--hairline); }
.pipe-legend i.done { background: var(--accent); border-color: var(--accent); }
.pipe-legend i.running { background: var(--amber); border-color: var(--amber); }
.pipe-legend i.failed { background: var(--red); border-color: var(--red); }
.pipe-legend i.unknown { background: repeating-linear-gradient(45deg, var(--hairline) 0 2px, transparent 2px 4px); }

.tag.ok { background: var(--accent-soft); border-color: #bcdcd7; color: var(--accent); }
.tag.warn { background: var(--amber-soft); border-color: #e8d5ac; color: #6d4503; }
.tag.bad { background: var(--red-soft); border-color: #edc4bf; color: var(--red); }

.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filters input[type="text"] { flex: 1 1 220px; width: auto; }
.filters select { width: auto; }

form.inline { display: inline-flex; gap: 4px; align-items: center; margin: 0 6px 0 0; }
form.inline select { width: auto; font-size: 12px; padding: 3px 6px; }
button.tiny { font-size: 12px; padding: 3px 9px; }

tr.off td { opacity: 0.5; }
td.small { font-size: 12px; }
.panel.scroll { overflow-x: auto; }
code.big { font-size: 16px; letter-spacing: 0.04em; }
.num.warn { color: var(--red); }
.picks.row { flex-direction: row; margin-bottom: 18px; }
.picks.row a { flex: none; }
.btn.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ------------------------------------------- PWA: картинки и аватарки */

.imgrow { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 14px; }
.imgrow .grow { flex: 1; margin-bottom: 0; }
.imglabel { display: block; font-size: 13px; color: var(--slate); margin-bottom: 6px; }

.thumb {
  display: block;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--surface-1, #fff);
  object-fit: cover;
}
.thumb.icon { width: 72px; height: 72px; }
.thumb.shot { width: 84px; height: 150px; }
.thumb.empty {
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--muted);
}
.shots { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

.reviews .review.extra { opacity: 0.55; }
.reviews .review.extra:focus-within { opacity: 1; }

.avatars { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.av {
  position: relative;
  width: 56px; padding: 4px;
  background: #fff; border: 1px solid var(--hairline); border-radius: 8px;
  cursor: pointer; color: var(--slate);
}
.av:hover { border-color: var(--accent); }
.av img { width: 100%; aspect-ratio: 1; border-radius: 50%; object-fit: cover; display: block; }
.av img.broken { visibility: hidden; }
.av span { display: block; font-size: 11px; font-family: var(--mono); margin-top: 2px; }
.av.on { border-color: var(--amber); }
.av.picked { border-color: var(--accent); border-width: 2px; background: var(--accent-soft); }
.av.picked::after {
  content: attr(data-order);
  position: absolute; top: -6px; right: -6px;
  min-width: 17px; height: 17px; padding: 0 3px;
  background: var(--accent); color: #fff;
  border-radius: 9px; font-size: 11px; line-height: 17px;
  font-family: var(--mono); text-align: center;
}

/* --------------------------------------------- PWA: сетки пресетов

Пропорции взяты с самой панели: иконки квадратами примерно по 8 в ряд,
наборы скриншотов — по 4 в ряд, в каждом видно три кадра 9:16.
*/

.presets {
  display: grid;
  gap: 8px;
  max-height: 460px;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: #fafcfc;
  margin-bottom: 14px;
}
.presets.icons { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.presets.shots { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }

.preset {
  position: relative;
  display: block;
  border: 2px solid var(--hairline);
  border-radius: 8px;
  cursor: pointer;
  overflow: hidden;
  background: #fff;
  line-height: 0;
}
.preset input {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}
.preset:hover { border-color: var(--slate); }
.preset.on { border-color: var(--accent); }
.preset.on::after {
  content: "✓";
  position: absolute; top: 3px; right: 4px;
  color: #fff; font-size: 12px; line-height: 1;
  background: var(--accent); border-radius: 4px; padding: 2px 4px;
  z-index: 2;
}

.presets.icons .preset img {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: block;
  object-fit: cover;
}

.preset .strip { display: flex; gap: 2px; width: 100%; }
.preset .strip img {
  width: calc((100% - 4px) / 3);
  aspect-ratio: 9 / 16;
  object-fit: cover;
  display: block;
}

.preset.own { border-color: var(--amber); }
.preset.own.on { border-color: var(--accent); }
.ownlabel {
  display: flex; align-items: center; justify-content: center;
  width: 100%; aspect-ratio: 1 / 1;
  font-size: 12px; line-height: 1.4; color: #6d4503;
  background: var(--amber-soft);
}
/* Три кадра по 1/3 ширины с соотношением 9:16 дают высоту W*16/27,
   поэтому слот «свои» должен быть 27:16, иначе он растягивает всю строку. */
.preset.set .ownlabel { aspect-ratio: 27 / 16; }

input.range { width: 100%; accent-color: var(--accent); padding: 0; }
.reviews .review[hidden] { display: none; }

/* ------------------------------------------------- Конструктор в рамке */

.panelbar {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.panelbar h1 { margin-bottom: 2px; }
.panelbar .sub { margin-bottom: 0; }

.panelwrap {
  position: relative;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}
.panelwrap iframe {
  display: block;
  width: 100%;
  height: 1400px;
  border: 0;
}
.panelload {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  color: var(--muted);
  font-size: 14px;
}
.panelload[hidden] { display: none; }
