/*
  Панель бота «Смотри прическу!»
  Акцент — фиолетовый тонирующий пигмент (тот самый, которым в салоне гасят желтизну
  у блонда). Три сигнальных цвета живут только внутри карты покрытия и бейджей:
  там цвет несёт смысл «пусто / мало / хватает», а не украшает.
*/

:root {
  --ink: #16141c;
  --paper: #faf9fc;
  --surface: #ffffff;
  --muted: #6e6a7b;
  --faint: #9d99a8;
  --line: #e6e3ed;
  --line-strong: #d3cfdd;

  --toner: #6539ff;
  --toner-ink: #4a24d6;
  --toner-soft: #f0ebff;

  --empty: #c2334c;
  --empty-soft: #fdeef1;
  --partial: #b57516;
  --partial-soft: #fdf3e3;
  --full: #23795a;
  --full-soft: #e9f5f0;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(22, 20, 28, .05), 0 8px 24px -16px rgba(22, 20, 28, .35);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

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

a { color: var(--toner-ink); }

code {
  font-family: var(--mono);
  font-size: .92em;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(22, 20, 28, .06);
}

h1, h2, h3 {
  margin: 0;
  letter-spacing: -.022em;
  font-weight: 640;
}
h1 { font-size: 27px; }
h2 { font-size: 19px; }
h3 { font-size: 15px; }

:focus-visible {
  outline: 2px solid var(--toner);
  outline-offset: 2px;
  border-radius: 3px;
}

/* --- шапка --- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 24px;
  height: 58px;
  background: rgba(250, 249, 252, .88);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.wordmark {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-weight: 680;
  letter-spacing: -.03em;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
}
.wordmark .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--toner);
}

.nav { display: flex; gap: 2px; margin-right: auto; flex-wrap: wrap; }
.nav a {
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 520;
}
.nav a:hover { background: var(--surface); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--toner-soft); color: var(--toner-ink); }

.whoami { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.whoami form { margin: 0; }

/* --- каркас --- */

.wrap { max-width: 1180px; margin: 0 auto; padding: 32px 24px 96px; }

.page-head { margin-bottom: 28px; }
.page-head p { margin: 6px 0 0; color: var(--muted); max-width: 62ch; }

.eyebrow {
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 620;
}

/* --- полоса заполненности базы --- */

.fill {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 8px 16px;
  margin: 22px 0 34px;
}
.fill-num {
  font-size: 34px;
  font-weight: 660;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.fill-num span { color: var(--faint); font-size: 20px; font-weight: 560; }
.fill-note { color: var(--muted); font-size: 13px; text-align: right; }
.fill-track {
  grid-column: 1 / -1;
  height: 5px;
  border-radius: 99px;
  background: var(--line);
  overflow: hidden;
}
.fill-bar { height: 100%; background: var(--toner); border-radius: 99px; }

/* --- карта покрытия --- */

.board { display: grid; gap: 26px; }

.board-group {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.board-group > header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.board-group > header .count { color: var(--faint); font-size: 13px; margin-left: auto; }

.matrix {
  display: grid;
  grid-template-columns: 132px repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border-top: 1px solid var(--line);
}
.matrix > * { background: var(--surface); }

.matrix .col-head,
.matrix .row-head,
.matrix .type-head {
  padding: 9px 14px;
  font-size: 12px;
  color: var(--muted);
}
.matrix .col-head {
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: lowercase;
}
.matrix .type-head {
  grid-column: 1 / -1;
  font-weight: 640;
  color: var(--ink);
  font-size: 13px;
  background: #fcfbfe;
}
.matrix .row-head { display: flex; align-items: center; }

/* ячейка = слот под образцы, как гнездо в палитре с прядями */
.cell {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  text-decoration: none;
  color: inherit;
  min-height: 56px;
}
.cell:hover { background: var(--toner-soft); }

.cell .stack { display: flex; }
.cell .stack img {
  width: 34px; height: 40px;
  object-fit: cover;
  border-radius: 4px;
  border: 2px solid var(--surface);
  box-shadow: 0 1px 3px rgba(22, 20, 28, .22);
}
.cell .stack img + img { margin-left: -14px; }

.cell .num {
  font-variant-numeric: tabular-nums;
  font-weight: 620;
  font-size: 15px;
}
.cell .hint { font-size: 12px; color: var(--faint); margin-left: auto; }

.cell.is-empty { background: var(--empty-soft); }
.cell.is-empty:hover { background: #fbe2e7; }
.cell.is-empty .num { color: var(--empty); }
.cell.is-partial .num { color: var(--partial); }
.cell.is-full .num { color: var(--full); }

.slot {
  width: 34px; height: 40px;
  border: 1.5px dashed var(--empty);
  border-radius: 4px;
  opacity: .5;
}

/* --- кнопки --- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 560;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { border-color: var(--faint); }
.btn-primary {
  background: var(--toner);
  border-color: var(--toner);
  color: #fff;
}
.btn-primary:hover { background: var(--toner-ink); border-color: var(--toner-ink); }
.btn-danger { color: var(--empty); border-color: #eccdd4; }
.btn-danger:hover { background: var(--empty-soft); border-color: var(--empty); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 13px; }

/* --- формы --- */

.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > label { font-size: 13px; font-weight: 580; }
.help { font-size: 12px; color: var(--muted); }

input[type="text"], input[type="password"], select, textarea {
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  width: 100%;
}
textarea { min-height: 220px; font-family: var(--mono); font-size: 13px; line-height: 1.6; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--toner); outline-offset: 0; border-color: var(--toner); }

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

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.row .field { margin-bottom: 0; }

/* --- сообщения --- */

.flash { display: grid; gap: 8px; margin-bottom: 22px; }
.flash div {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  border: 1px solid;
}
.flash .ok { background: var(--full-soft); border-color: #c3e2d6; color: #17573f; }
.flash .err { background: var(--empty-soft); border-color: #f0ccd4; color: #8e2337; }
.flash .warn { background: var(--partial-soft); border-color: #eddbb9; color: #7d5210; }

/* --- сетка образцов --- */

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.thumb {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.thumb img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; background: var(--line); }
.thumb .meta { padding: 8px 10px; font-size: 12px; color: var(--muted); display: grid; gap: 6px; }
.thumb .meta .combo { color: var(--ink); font-weight: 560; }
.thumb .acts { display: flex; gap: 6px; }
.thumb { transition: opacity .16s ease, transform .16s ease; }
.thumb img { transition: filter .16s ease; }
.thumb.going { opacity: 0; transform: scale(.96); pointer-events: none; }
.listnote { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.listnote[hidden] { display: none; }

/* карточка «Добавить образец» — всегда последняя в сетке */
.thumb-add {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 210px;
  padding: 18px;
  text-align: center;
  text-decoration: none;
  color: var(--muted);
  border: 1.5px dashed var(--line-strong);
  background: transparent;
  box-shadow: none;
}
.thumb-add:hover { border-color: var(--toner); background: var(--toner-soft); color: var(--toner-ink); }
.thumb-add .plus {
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--toner);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  font-weight: 400;
}
.thumb-add .label { font-weight: 580; color: var(--ink); font-size: 14px; }
.thumb-add:hover .label { color: var(--toner-ink); }
.thumb-add .into { font-size: 12px; }

.thumb.off { opacity: .55; }
.thumb.off img { filter: grayscale(1); }
.thumb .hidden-note { color: var(--partial); }
.thumb .hidden-note[hidden] { display: none; }

/* --- вход --- */

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { font-size: 21px; margin-bottom: 4px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }

/* --- загрузка --- */

/* label по умолчанию строчный — без display блочный <strong> внутри ломает строки */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 34px 22px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.dropzone:hover { border-color: var(--faint); }
.dropzone.hot { border-color: var(--toner); background: var(--toner-soft); color: var(--toner-ink); }
.dropzone strong { color: var(--ink); font-size: 15px; font-weight: 600; }
.dropzone.hot strong { color: var(--toner-ink); }

.preview { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.preview:empty { margin-top: 0; }

.preview-item { position: relative; }
.preview-item img {
  display: block;
  width: 84px; height: 104px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}
.preview-remove {
  position: absolute;
  top: -6px; right: -6px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.preview-remove:hover { color: var(--empty); border-color: var(--empty); }

.linkbtn {
  border: 0;
  background: none;
  padding: 0 0 0 8px;
  font: inherit;
  font-size: 12px;
  color: var(--toner-ink);
  text-decoration: underline;
  cursor: pointer;
}
.linkbtn[hidden] { display: none; }

/* --- просмотр образца поверх страницы --- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 40px 24px;
  background: rgba(16, 14, 22, .82);
  backdrop-filter: blur(3px);
}
.lightbox[hidden] { display: none; }

.lightbox figure {
  margin: 0;
  display: grid;
  gap: 12px;
  justify-items: center;
  max-height: 100%;
}
.lightbox img {
  display: block;
  max-width: min(92vw, 900px);
  max-height: 82vh;
  object-fit: contain;
  border-radius: var(--radius);
  background: var(--ink);
  box-shadow: 0 24px 70px -20px rgba(0, 0, 0, .7);
}
.lightbox figcaption {
  color: rgba(255, 255, 255, .82);
  font-size: 13px;
  text-align: center;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(255, 255, 255, .08);
  color: #fff;
  font: inherit;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.lightbox-close:hover { background: rgba(255, 255, 255, .18); }

.thumb a[data-full] { display: block; cursor: zoom-in; }

/* --- сводка цифр --- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 26px;
}
.stats > div { background: var(--surface); padding: 16px 18px; display: grid; gap: 3px; }
.stat-num {
  font-size: 25px;
  font-weight: 640;
  letter-spacing: -.025em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat-label { font-size: 12px; color: var(--muted); }

/* --- таблицы --- */

.table-card { padding: 0; overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td {
  padding: 11px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.table th {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  background: #fcfbfe;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fcfbfe; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .mono { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.table .dim { color: var(--faint); font-size: 13px; }
.table .wide { min-width: 280px; }
.table .nowrap { white-space: nowrap; }
.table .cut { max-width: 380px; }
.table .muted-row td { opacity: .6; }
.table .err-text {
  margin-top: 4px;
  font-size: 12px;
  color: var(--empty);
  font-family: var(--mono);
  word-break: break-word;
}

.tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 560;
  background: var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.tag-ok { background: var(--full-soft); color: var(--full); }
.tag-err { background: var(--empty-soft); color: var(--empty); }
.tag-warn { background: var(--partial-soft); color: var(--partial); }

/* --- карточки-ссылки и редактор контента --- */

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }

.linkcard {
  display: block;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
}
.linkcard:hover { border-color: var(--toner); }
.linkcard-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.linkcard-head h3 { flex: 1; }
.linkcard-head .dim { font-size: 12px; color: var(--faint); white-space: nowrap; }
.linkcard p { margin: 0 0 12px; }

.snippet {
  margin: 0;
  padding: 10px 12px;
  background: #fbfaFe;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
}

.callout {
  margin-top: 18px;
  padding: 14px 16px;
  background: var(--toner-soft);
  border: 1px solid #ddd2ff;
  border-radius: var(--radius-sm);
}
.callout strong { display: block; font-size: 14px; margin-bottom: 4px; }
.callout p { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips code { background: var(--surface); border: 1px solid #ddd2ff; color: var(--toner-ink); }

.options { display: grid; gap: 8px; margin-bottom: 10px; }
.option-row { display: flex; align-items: center; gap: 10px; }
.option-row input[type="text"] { flex: 1 1 auto; }
.option-slug {
  flex: 0 0 74px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- предпросмотр сообщения --- */

.tg-preview {
  max-width: 420px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fcfbfe;
}
.tg-preview img { display: block; width: 100%; }
.tg-text { padding: 12px 14px; white-space: pre-wrap; word-break: break-word; font-size: 14px; }

.nav-sep {
  width: 1px;
  align-self: stretch;
  margin: 8px 6px;
  background: var(--line-strong);
}

.empty-note {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

@media (max-width: 720px) {
  .topbar { height: auto; padding: 10px 16px; flex-wrap: wrap; gap: 10px 18px; }
  .wrap { padding: 24px 16px 72px; }
  .matrix { grid-template-columns: 96px repeat(2, minmax(0, 1fr)); }
  .cell .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* формы внутри строк таблицы не должны переноситься — иначе строка растёт вдвое */
.table form.row { flex-wrap: nowrap; align-items: center; }
.table form.row select { width: auto; min-width: 130px; }
.table form.row input[type="text"] { width: 150px; }
