/* MVAI: панель управления. Тёмная база, спокойные акценты, плотность как у
   рабочего инструмента. Никаких свечений и чистого чёрного. */

:root {
  --bg: #0b0b0e;
  --surface: #131317;
  --surface-2: #17171c;
  --line: #26262e;
  --line-soft: #1d1d24;
  --text: #e6e6ea;
  --muted: #9a9aa6;
  --faint: #6e6e7a;

  --accent: #8fa7d8;
  --accent-dim: #6c82ad;
  --ok: #7aa87a;
  --warn: #c2a45c;
  --bad: #c4817a;

  --radius: 10px;
  --radius-sm: 7px;
  --sidebar-w: 224px;

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

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

button, input, select, textarea { font: inherit; color: inherit; }

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

.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand { display: flex; flex-direction: column; gap: 4px; }

.brand-mark {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.06em;
  color: var(--text);
}

.brand-sub { color: var(--faint); font-size: 12.5px; }

.brand-side {
  padding: 20px 18px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { color: var(--muted); font-size: 12.5px; }

.field input, .field select, .field textarea, .inp {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  outline: none;
  width: 100%;
  transition: border-color 0.12s ease;
}

.field input:focus, .field select:focus, .field textarea:focus, .inp:focus {
  border-color: var(--accent-dim);
}

.login-error { color: var(--bad); font-size: 13px; margin: 0; min-height: 18px; }

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

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100%;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav button {
  text-align: left;
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav button:hover { background: var(--surface-2); color: var(--text); }

.nav button.active {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: inset 2px 0 0 var(--accent-dim);
}

.sidebar-foot {
  border-top: 1px solid var(--line-soft);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.who { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.who > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-role { color: var(--faint); font-size: 11.5px; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 26px;
  border-bottom: 1px solid var(--line-soft);
}

.topbar h1 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.content { padding: 22px 26px 40px; overflow: auto; flex: 1; }

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

.btn {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 13px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
  white-space: nowrap;
}

.btn:hover { background: #1e1e25; border-color: #33333d; }

.btn-primary {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
  color: #0d1220;
  font-weight: 600;
}

.btn-primary:hover { background: var(--accent); border-color: var(--accent); }

.btn-ghost { background: none; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-sm { padding: 5px 9px; font-size: 12.5px; }
.btn-danger { color: var(--bad); }
.btn-danger:hover { border-color: var(--bad); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- карточки статистики ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 15px 16px;
}

.card-label { color: var(--muted); font-size: 12.5px; margin-bottom: 6px; }

.card-value {
  font-size: 25px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.card-note { color: var(--faint); font-size: 12px; margin-top: 4px; }

/* ---------- секции и таблицы ---------- */

.section { margin-bottom: 26px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-head h2 { margin: 0; font-size: 14px; font-weight: 600; }
.section-head .hint { color: var(--faint); font-size: 12.5px; }

.table-wrap {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: auto;
  background: var(--surface);
}

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  padding: 10px 14px;
  background: var(--surface-2);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

td {
  padding: 10px 14px;
  border-top: 1px solid var(--line-soft);
  vertical-align: middle;
}

tbody tr:hover { background: var(--surface-2); }

td.num { font-variant-numeric: tabular-nums; text-align: right; }
td.mono, .mono { font-family: var(--mono); font-size: 12.5px; }

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

/* ---------- бейджи состояния ---------- */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}

.badge-ok { color: var(--ok); border-color: #2c4030; }
.badge-warn { color: var(--warn); border-color: #453b21; }
.badge-bad { color: var(--bad); border-color: #46292a; }

/* ---------- секрет с копированием ---------- */

.secret {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12.5px;
}

.secret code {
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  padding: 3px 7px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- график ---------- */

.chart {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 92px;
  padding-top: 6px;
}

/* Столбец не должен растягиваться, когда день всего один. */
.chart-col {
  flex: 1 1 0;
  max-width: 54px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
}

.chart-bar {
  background: var(--accent-dim);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: background 0.12s ease;
}

.chart-col:hover .chart-bar { background: var(--accent); }
.chart-x { color: var(--faint); font-size: 10.5px; text-align: center; }

/* ---------- формы в модалке ---------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 6, 9, 0.66);
  display: grid;
  place-items: center;
  padding: 22px;
  z-index: 40;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.modal-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-body { padding: 18px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- уведомление ---------- */

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  z-index: 60;
  max-width: 80vw;
}

.toast-bad { border-color: #46292a; color: var(--bad); }

/* ---------- страница «Подключение» ---------- */

.doc-lead {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.doc-lead p { margin: 0 0 14px; color: var(--muted); max-width: 74ch; }

.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 10px 18px;
  align-items: center;
}

.kv-k { color: var(--muted); font-size: 12.5px; }
.kv-v { min-width: 0; }
.kv-v .secret code { max-width: 420px; }

.doc-warn {
  color: var(--warn) !important;
  margin: 14px 0 0 !important;
  font-size: 13px;
}

.doc-list { display: flex; flex-direction: column; gap: 14px; }

.doc-item {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 15px 16px;
}

.doc-title { margin: 0 0 4px; font-size: 13.5px; font-weight: 600; }
.doc-note { margin: 0 0 10px; color: var(--faint); font-size: 12.5px; }

.code-block {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.code-bar {
  display: flex;
  justify-content: flex-end;
  padding: 5px 6px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface-2);
}

pre.code {
  margin: 0;
  padding: 13px 15px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: #d3d7e0;
  tab-size: 2;
}

/* ---------- идущий прогон регера ---------- */

.run-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 2px solid var(--warn);
  border-radius: var(--radius);
  padding: 15px 16px;
  margin-bottom: 22px;
}

.run-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.run-title { font-size: 13.5px; font-weight: 600; }
.run-counter { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }

.run-track {
  height: 4px;
  background: var(--line-soft);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px;
}

.run-fill {
  height: 100%;
  width: 0;
  background: var(--accent-dim);
  border-radius: 999px;
  transition: width 0.4s ease;
}

pre.log {
  margin: 0;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  color: #c9cdd6;
  max-height: 340px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

pre.log.log-live { max-height: 260px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  font-family: var(--mono);
  font-size: 12px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease;
}

.chip:hover { color: var(--text); border-color: var(--accent-dim); }

.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filters select, .filters input { width: auto; min-width: 150px; }

.help {
  color: var(--muted);
  font-size: 12.5px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-left: 2px solid var(--accent-dim);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  margin-bottom: 18px;
}

.help code {
  font-family: var(--mono);
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 4px;
}

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .content { padding: 16px; }
  .topbar { padding: 14px 16px; }
}
