:root {
  --bg: #0f1216;
  --bg-card: #171b21;
  --border: #262b33;
  --text: #e6e9ee;
  --text-muted: #9aa3b1;
  --accent: #4f8cff;
  --accent-2: #3f6fd6;
  --ok: #3ecf6a;
  --down: #e5534b;
  --danger-bg: #3a1f1f;
  --danger-text: #ff9c96;
  --success-bg: #16321f;
  --success-text: #8fe3a5;
  --info-bg: #17263a;
  --info-text: #9cc4ff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6f8;
    --bg-card: #ffffff;
    --border: #e2e5ea;
    --text: #1b1f27;
    --text-muted: #5b6472;
    --danger-bg: #fdecea;
    --danger-text: #a4271f;
    --success-bg: #e9f9ee;
    --success-text: #1c7a3c;
    --info-bg: #eaf2ff;
    --info-text: #1a4fa0;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

.topnav { display: flex; align-items: center; gap: 20px; }
.topnav a { color: var(--text-muted); text-decoration: none; }
.topnav a:hover { color: var(--text); }
.who { color: var(--text-muted); font-size: 0.9em; }

.link-button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  padding: 0;
}
.link-button:hover { color: var(--text); }

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 32px 24px;
  flex: 1;
  width: 100%;
}

h1 { margin: 0 0 6px; }
.muted { color: var(--text-muted); }
.section-title { margin-top: 40px; }

/* Карта компонентов — одна строка; если карточки не помещаются по
   ширине, ряд становится горизонтально прокручиваемым (как слайдер),
   а не переносится на новую строку. Чисто CSS (scroll-snap), без JS. */
.grid {
  display: flex;
  flex-wrap: nowrap;
  gap: 16px;
  margin-top: 24px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  padding-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.grid::-webkit-scrollbar { height: 8px; }
.grid::-webkit-scrollbar-track { background: transparent; }
.grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  flex: 0 0 300px;
  scroll-snap-align: start;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--accent);
}

.card h2 { font-size: 1.05em; margin: 10px 0 4px; }

.card-url {
  display: inline-block;
  margin-top: 10px;
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
}
.card-url:hover { text-decoration: underline; }

.extra-links {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  font-size: 0.85em;
  color: var(--text-muted);
}
.extra-links li { margin-top: 4px; word-break: break-all; }
.extra-links code { color: var(--text); }

.note {
  font-size: 0.82em;
  color: var(--text-muted);
  margin-top: 10px;
  border-left: 2px solid var(--border);
  padding-left: 8px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.status-up { background: var(--ok); }
.status-down { background: var(--down); }

.related-links { padding-left: 20px; color: var(--text-muted); }
.related-links a { color: var(--accent); text-decoration: none; }
.related-links a:hover { text-decoration: underline; }

.login-wrap {
  display: flex;
  justify-content: center;
  padding-top: 40px;
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 360px;
}

form label {
  display: block;
  margin: 14px 0 6px;
  font-size: 0.88em;
  color: var(--text-muted);
}

input[type="text"], input[type="password"], textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-primary {
  margin-top: 20px;
  width: 100%;
  padding: 11px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:hover { background: var(--accent-2); }

.feedback-wrap { max-width: 560px; }
.feedback-form { margin-top: 20px; }

.honeypot { position: absolute; left: -9999px; top: -9999px; }

.captcha-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}
.captcha-img {
  border: 1px solid var(--border);
  border-radius: 8px;
  display: block;
}
.captcha-input { flex: 1; }
.captcha-input label { margin-top: 0; }
.hidden-form { display: none; }
.hint { font-size: 0.8em; color: var(--text-muted); margin: 6px 0 0; }
.hint a { color: var(--accent); }

.flash-stack { margin-bottom: 20px; }
.flash {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 0.92em;
}
.flash-error { background: var(--danger-bg); color: var(--danger-text); }
.flash-success { background: var(--success-bg); color: var(--success-text); }
.flash-info { background: var(--info-bg); color: var(--info-text); }

.footer {
  text-align: center;
  padding: 18px;
  color: var(--text-muted);
  font-size: 0.82em;
  border-top: 1px solid var(--border);
}

/* --- Публичный лендинг: технический сплэш --- */

.splash-body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text);
}

.splash {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  max-width: 560px;
  padding: 32px;
}

.splash-kicker {
  font-family: "SF Mono", "Cascadia Code", "Consolas", "Menlo", monospace;
  font-size: 0.82em;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-transform: lowercase;
}
.splash-kicker-sep { color: var(--accent); }

.splash-title {
  margin: 0;
  font-size: 2.6em;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.splash-desc {
  margin: 0;
  color: var(--text-muted);
  font-size: 1.05em;
  max-width: 46ch;
}

.splash-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: "SF Mono", "Cascadia Code", "Consolas", "Menlo", monospace;
  font-size: 0.88em;
  color: var(--text-muted);
  margin-top: 4px;
}

.splash-cta {
  margin-top: 18px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 22px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 1.02em;
}
.splash-cta:hover { background: var(--accent-2); }
.splash-cta span { transition: transform 0.15s ease; }
.splash-cta:hover span { transform: translateX(3px); }

.splash-links { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 4px; }
.splash-secondary {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9em;
  border-bottom: 1px dotted var(--border);
}
.splash-secondary:hover { color: var(--text); }

@media (max-width: 480px) {
  .splash-title { font-size: 2em; }
}

.login-register-hint { margin-top: 16px; text-align: center; }

/* --- Админ: пользователи --- */

.users-table-wrap { overflow-x: auto; }
.users-table { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: 0.92em; }
.users-table th, .users-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.users-table th { color: var(--text-muted); font-weight: 600; font-size: 0.85em; }
.users-table tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.8em;
  font-weight: 600;
}
.badge-pending { background: var(--info-bg); color: var(--info-text); }
.badge-active { background: var(--success-bg); color: var(--success-text); }
.badge-disabled { background: var(--danger-bg); color: var(--danger-text); }
.badge-admin { background: var(--accent); color: #fff; }

.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.row-actions form { display: inline; }

.btn-small {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font: inherit;
  font-size: 0.85em;
  cursor: pointer;
}
.btn-small:hover { border-color: var(--accent); }
.btn-small.btn-danger:hover { border-color: var(--down); color: var(--down); }
.btn-small.btn-primary-outline { border-color: var(--accent); color: var(--accent); }
.btn-small.btn-primary-outline:hover { background: var(--accent); color: #fff; }

/* Чекбоксы-кнопки доступа к сервисам на /admin/users — каждый сервис
   переключается отдельной кнопкой-формой (без JS), "включено"/"выключено"
   различаются только цветом, как и остальные статусы в этой таблице. */
.group-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.group-chips form { display: inline; }
.chip {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.8em;
  cursor: pointer;
}
.chip:hover:not(:disabled) { border-color: var(--accent); }
.chip:disabled { cursor: not-allowed; opacity: 0.6; }
.chip-on {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: var(--success-text);
}
.chip-off { color: var(--text-muted); }

/* --- Мастер онбординга проектов (/projects/new) --- */

select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
select:focus { outline: none; border-color: var(--accent); }

.wizard-form { max-width: 640px; padding: 24px; }

.stage-fieldset {
  margin: 16px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.stage-fieldset legend {
  padding: 0 6px;
  font-size: 0.85em;
  color: var(--text-muted);
}
.checkbox-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 4px 16px;
  align-items: start;
}
/* Каждый чекбокс стадии и его подсказка живут в одной ячейке грида —
   раньше подсказка EDT была отдельным соседним элементом грида и могла
   визуально "уехать" под другой чекбокс при переносе строк. */
.stage-checkbox-item { margin: 4px 0; }
.stage-checkbox-item .hint { margin: 0 0 0 26px; font-size: 0.82em; }
.checkbox-row {
  display: flex !important;
  align-items: center;
  gap: 8px;
  margin: 8px 0 !important;
  font-size: 0.95em;
  color: var(--text) !important;
  cursor: pointer;
}
.checkbox-row input[type="checkbox"] { width: auto; margin: 0; }
.checkbox-row-disabled { opacity: 0.5; cursor: not-allowed; }
.stage-edt-hint { margin: -2px 0 4px 26px !important; }

.stage-checkbox-item-danger {
  border-left: 2px solid var(--down);
  padding-left: 8px;
  margin-left: -10px;
  border-radius: 0 4px 4px 0;
}
.stage-checkbox-item-danger .checkbox-row { color: var(--down) !important; opacity: 0.85; }
.stage-checkbox-item-danger .stage-edt-hint {
  color: var(--down);
  text-decoration: underline;
  text-decoration-style: dotted;
}

.hint-details { margin: 4px 0 0; font-size: 0.85em; }
.hint-details summary {
  cursor: pointer;
  color: var(--accent);
}
.hint-details .hint { margin: 6px 0 0; }

.stage-extra {
  margin: 4px 0 16px;
  padding: 12px 14px;
  border-left: 2px solid var(--accent);
  background: var(--bg-card);
  border-radius: 0 8px 8px 0;
}
.stage-extra label:first-child { margin-top: 0; }

.field-error {
  margin: 4px 0 0;
  font-size: 0.85em;
  color: var(--danger-text);
}

.result-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; }
.download-form { margin: 0; }

.list-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.list-header h1 { margin: 0; }

.file-block {
  margin-top: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.file-name {
  padding: 8px 14px;
  font-family: "SF Mono", "Cascadia Code", "Consolas", "Menlo", monospace;
  font-size: 0.85em;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
}
.file-block pre {
  margin: 0;
  padding: 14px;
  overflow-x: auto;
  font-family: "SF Mono", "Cascadia Code", "Consolas", "Menlo", monospace;
  font-size: 0.85em;
  line-height: 1.5;
  white-space: pre;
}
.file-block pre.checklist { white-space: pre-wrap; }
