/* ИИ Фото · admin — тёмная тема, рабочий инструмент */

:root {
  --bg: #141414;
  --surface: #1c1e24;
  --surface-2: #23262e;
  --surface-3: #2b2f39;
  --border: #2e323c;
  --accent: #e3a84a;
  --accent-dim: rgba(227, 168, 74, 0.16);
  --text: #ececec;
  --muted: #9a9a9a;
  --green: #4cc27a;
  --red: #e25c5c;
  --blue: #5b9cf5;
  --sidebar-w: 220px;
  --radius: 8px;
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  font-weight: 400;
}

body { min-width: 1100px; }

[hidden] { display: none !important; }

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

h1 { font-size: 20px; font-weight: 700; margin: 0; }
h2 { font-size: 14px; font-weight: 700; margin: 0 0 10px; }
h3 { font-size: 13px; font-weight: 700; margin: 0 0 8px; color: var(--text); }

.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; }
.small { font-size: 11px; }
.red { color: var(--red); }
.green { color: var(--green); }
.amber { color: var(--accent); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }

/* ---------- прогресс ---------- */
.progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 1000;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 40% 100%;
  animation: progress 1s linear infinite;
}
@keyframes progress {
  from { background-position: -40% 0; }
  to { background-position: 140% 0; }
}

/* ---------- логин ---------- */
.login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
}
.login-card {
  width: 340px; padding: 28px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; display: flex; flex-direction: column; gap: 14px;
}
.login-logo { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.login-logo span, .logo span { color: var(--accent); font-weight: 600; }
.login-error { color: var(--red); font-size: 12px; }

/* ---------- лейаут ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 14px;
  position: sticky; top: 0; height: 100vh;
}
.logo { font-size: 16px; font-weight: 700; padding: 0 8px 18px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  color: var(--text); padding: 8px 10px; border-radius: 6px; font-weight: 600;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--accent-dim); color: var(--accent); }
.sidebar-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.sidebar-user { color: var(--muted); font-size: 12px; padding: 0 2px; }

.content { flex: 1; min-width: 0; padding: 20px 24px 40px; }
.content-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 16px;
}
.page-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- контролы ---------- */
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 11px; color: var(--muted); font-weight: 600; }
.field-row { display: flex; gap: 12px; }
.field-row > .field { flex: 1; }

input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input[type="datetime-local"], input[type="search"], select, textarea {
  font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 9px;
  outline: none; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input:disabled, select:disabled, textarea:disabled { opacity: 0.5; cursor: not-allowed; }
input[type="number"] { width: 84px; }
input.inline-num { width: 64px; padding: 3px 6px; }
input.inline-num.dirty, input.dirty { border-color: var(--accent); }
textarea { resize: vertical; min-height: 56px; font-size: 12px; line-height: 1.4; }
select option { background: var(--surface-2); }
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; }
input[type="file"] { color: var(--muted); font-size: 12px; }
input::-webkit-calendar-picker-indicator { filter: invert(0.7); }

.btn {
  font: inherit; font-weight: 600; color: var(--text); background: var(--surface-3);
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 12px; cursor: pointer;
  white-space: nowrap; line-height: 1.3;
}
.btn:hover { border-color: #444a58; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #141414; }
.btn-primary:hover { background: #ebb55d; }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: rgba(226, 92, 92, 0.12); }
.btn-sm { padding: 3px 8px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-icon { padding: 4px 8px; background: transparent; border-color: transparent; }
.btn-icon:hover { background: var(--surface-2); }

.segments { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.segments button {
  font: inherit; font-weight: 600; color: var(--muted); background: transparent; border: 0;
  padding: 5px 12px; cursor: pointer;
}
.segments button + button { border-left: 1px solid var(--border); }
.segments button.active { background: var(--accent-dim); color: var(--accent); }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.toolbar input[type="search"], .toolbar input[type="text"] { width: 240px; }

.toggle { position: relative; display: inline-block; width: 34px; height: 18px; vertical-align: middle; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle i {
  position: absolute; inset: 0; background: var(--surface-3); border-radius: 18px;
  border: 1px solid var(--border); transition: background 0.15s; cursor: pointer;
}
.toggle i::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--muted); transition: transform 0.15s, background 0.15s;
}
.toggle input:checked + i { background: var(--accent-dim); border-color: var(--accent); }
.toggle input:checked + i::after { transform: translateX(16px); background: var(--accent); }
.toggle input:disabled + i { opacity: 0.45; cursor: not-allowed; }

/* ---------- бейджи ---------- */
.badge {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 10px;
  border: 1px solid transparent; white-space: nowrap;
}
.badge-green { color: var(--green); background: rgba(76, 194, 122, 0.12); border-color: rgba(76, 194, 122, 0.3); }
.badge-grey { color: var(--muted); background: rgba(154, 154, 154, 0.1); border-color: rgba(154, 154, 154, 0.3); }
.badge-amber { color: var(--accent); background: var(--accent-dim); border-color: rgba(227, 168, 74, 0.35); }
.badge-red { color: var(--red); background: rgba(226, 92, 92, 0.12); border-color: rgba(226, 92, 92, 0.3); }
.badge-blue { color: var(--blue); background: rgba(91, 156, 245, 0.12); border-color: rgba(91, 156, 245, 0.3); }

/* ---------- карточки и панели ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px;
}
.card + .card { margin-top: 14px; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-cards { grid-template-columns: repeat(5, 1fr); }
.section { margin-bottom: 14px; }

.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; min-height: 68px;
}
.stat .label { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.stat .value { font-size: 22px; font-weight: 700; margin-top: 4px; line-height: 1.2; }
.stat .sub { font-size: 11px; color: var(--muted); margin-left: 6px; font-weight: 600; }

.empty { color: var(--muted); padding: 24px; text-align: center; }

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { padding: 7px 9px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
th { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }
td.clickable-cell { cursor: pointer; text-decoration: underline dotted; }
tr.totals td { font-weight: 700; border-top: 2px solid var(--border); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-compact th, .table-compact td { padding: 4px 7px; font-size: 12px; }

.thumb {
  width: 48px; height: 64px; object-fit: cover; border-radius: 4px; background: var(--surface-3);
  display: block;
}
.thumb-ph { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 10px; }
.thumb-sm {
  width: 40px; height: 40px; object-fit: cover; border-radius: 4px; background: var(--surface-3);
  display: inline-block; margin-right: 3px; vertical-align: middle;
}
.pager { display: flex; align-items: center; gap: 10px; margin-top: 12px; color: var(--muted); }

/* ---------- воронка ---------- */
.funnel { display: flex; align-items: flex-end; gap: 0; height: 200px; padding-top: 10px; }
.funnel-step { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.funnel-bar { width: 70%; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; opacity: 0.9; }
.funnel-num { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.funnel-label { font-size: 11px; color: var(--muted); margin-top: 6px; text-align: center; height: 28px; }
.funnel-conv { width: 44px; flex: 0 0 44px; text-align: center; font-size: 11px; color: var(--muted); align-self: center; padding-bottom: 40px; }

/* ---------- горизонтальные полоски ---------- */
.bars { display: flex; flex-direction: column; gap: 7px; }
.bar-row { display: grid; grid-template-columns: 90px 1fr 90px; align-items: center; gap: 8px; font-size: 12px; }
.bar-track { height: 10px; background: var(--surface-3); border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 5px; }
.bar-fill.red { background: var(--red); }
.bar-row .right { color: var(--muted); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 12.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.reasons { list-style: none; margin: 8px 0 0; padding: 0; font-size: 12px; }
.reasons li { display: flex; justify-content: space-between; padding: 2px 0; border-bottom: 1px dashed var(--border); }

/* ---------- drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 50; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 720px; max-width: 95vw; z-index: 51;
  background: var(--surface); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; box-shadow: -8px 0 30px rgba(0, 0, 0, 0.4);
  animation: slidein 0.15s ease-out;
}
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between; padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.drawer-title { font-size: 15px; font-weight: 700; }
.drawer-title .muted { font-weight: 400; font-size: 12px; margin-left: 8px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px 30px; }
.drawer-body .card { background: var(--surface-2); }
.drawer-body .form { display: flex; flex-direction: column; gap: 10px; }
.drawer-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; position: sticky; bottom: 0; background: var(--surface); padding: 10px 0; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.tabs button {
  font: inherit; font-weight: 600; color: var(--muted); background: transparent; border: 0;
  border-bottom: 2px solid transparent; padding: 8px 12px; cursor: pointer; margin-bottom: -1px;
}
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

.preview-current { width: 180px; height: 240px; object-fit: cover; border-radius: 6px; background: var(--surface-3); }
.preview-row { display: flex; gap: 14px; align-items: flex-start; }
.candidates { display: flex; gap: 10px; flex-wrap: wrap; }
.candidate { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.candidate img { width: 120px; height: 160px; object-fit: cover; border-radius: 6px; background: var(--surface-3); }
.frames { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.frames img { width: 140px; height: 186px; object-fit: cover; border-radius: 6px; background: var(--surface-3); cursor: zoom-in; }

.spinner {
  display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite;
  vertical-align: middle; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.inline-form {
  display: flex; gap: 8px; align-items: flex-end; padding: 10px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 6px; margin: 10px 0;
}
.inline-form .field { flex: 1; }

.user-head { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; }
.hint { font-size: 11px; color: var(--muted); }

/* ---------- тосты ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  min-width: 240px; max-width: 420px; padding: 10px 14px; border-radius: 6px; font-weight: 600;
  background: var(--surface-3); border: 1px solid var(--border); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  animation: toastin 0.15s ease-out;
}
.toast-error { border-color: var(--red); color: var(--red); }
.toast-success { border-color: var(--green); color: var(--green); }
@keyframes toastin { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
