/* Готовые кусочки интерфейса: кнопки, поля, карточки, таблицы, бейджи.
   Общие для всех страниц. Ничего про раскладку конкретной страницы здесь
   быть не должно. */

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid rgb(var(--line)); background: rgb(var(--surface));
  color: rgb(var(--ink)); font-size: .88rem; font-weight: 550;
  cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
}
.btn:hover { border-color: rgb(var(--brand-300)); color: rgb(var(--brand-700)); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }

.btn-primary {
  background: rgb(var(--brand-500)); border-color: rgb(var(--brand-500)); color: #fff;
  box-shadow: 0 1px 2px rgb(var(--brand-700) / .25);
}
.btn-primary:hover { background: rgb(var(--brand-600)); border-color: rgb(var(--brand-600)); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: rgb(var(--muted)); }
.btn-ghost:hover { background: rgb(var(--brand-500) / .1); }
.btn-lg { padding: 11px 22px; font-size: .95rem; }
.btn-icon { width: 34px; height: 34px; padding: 0; flex: none; }

/* ---------- поля ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: .82rem; font-weight: 550; color: rgb(var(--muted)); }
.input {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid rgb(var(--line)); background: rgb(var(--surface));
  font-size: .92rem; transition: border-color .12s, box-shadow .12s;
}
.input:focus { outline: none; border-color: rgb(var(--brand-400)); box-shadow: 0 0 0 3px rgb(var(--brand-500) / .15); }

/* ---------- карточки ---------- */
.card {
  background: rgb(var(--surface)); border: 1px solid rgb(var(--line));
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-pad { padding: 18px 20px; }
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid rgb(var(--line-soft));
}
.card-head h3 { flex: 1; min-width: 0; }

/* ---------- таблица ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th {
  text-align: left; font-weight: 600; font-size: .76rem; letter-spacing: .04em;
  text-transform: uppercase; color: rgb(var(--faint));
  padding: 10px 14px; border-bottom: 1px solid rgb(var(--line));
  white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid rgb(var(--line-soft)); }
.table tbody tr:hover td { background: rgb(var(--brand-500) / .04); }
.table tbody tr:last-child td { border-bottom: none; }

/* ---------- бейджи ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: .74rem; font-weight: 600; white-space: nowrap;
  background: rgb(var(--line-soft)); color: rgb(var(--muted));
}
.badge i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-ok { background: rgb(var(--ok) / .12); color: rgb(var(--ok)); }
.badge-warn { background: rgb(var(--warn) / .14); color: rgb(var(--warn)); }
.badge-bad { background: rgb(var(--bad) / .12); color: rgb(var(--bad)); }
.badge-info { background: rgb(var(--info) / .12); color: rgb(var(--info)); }

/* ---------- пустое состояние ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 64px 24px; text-align: center; color: rgb(var(--muted));
}
.empty .mark {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  background: rgb(var(--brand-500) / .1); color: rgb(var(--brand-600));
}
.empty h3 { color: rgb(var(--ink)); }
.empty p { max-width: 46ch; font-size: .88rem; }

/* ---------- мелочи ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid { display: grid; gap: 16px; }
.note {
  padding: 12px 14px; border-radius: var(--radius-sm); font-size: .85rem;
  background: rgb(var(--brand-500) / .08); color: rgb(var(--brand-700));
  border: 1px solid rgb(var(--brand-500) / .22);
}
.note-bad { background: rgb(var(--bad) / .08); color: rgb(var(--bad)); border-color: rgb(var(--bad) / .25); }

/* ---------- переключатель темы ---------- */
.theme-toggle {
  border: 1px solid rgb(var(--line)); background: rgb(var(--surface));
  color: rgb(var(--muted)); width: 34px; height: 34px; border-radius: var(--radius-sm);
  display: grid; place-items: center; cursor: pointer; flex: none;
}
.theme-toggle:hover { border-color: rgb(var(--brand-300)); color: rgb(var(--brand-700)); }
html:not(.dark) .theme-toggle .moon, html.dark .theme-toggle .sun { display: none; }

/* ---------- окно поверх страницы ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 80;
  background: rgb(16 24 40 / .45);
  display: grid; place-items: center; padding: 20px;
  animation: modal-in .12s ease;
}
@keyframes modal-in { from { opacity: 0; } to { opacity: 1; } }
.modal-card { width: 100%; box-shadow: var(--shadow-lift); }
.modal-body { display: flex; flex-direction: column; gap: 14px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px; border-top: 1px solid rgb(var(--line-soft));
}

.btn-danger { background: rgb(var(--bad)); border-color: rgb(var(--bad)); color: #fff; }
.btn-danger:hover { background: rgb(var(--bad)); border-color: rgb(var(--bad)); color: #fff; filter: brightness(.94); }

/* ---------- флажки ---------- */
.check {
  width: 16px; height: 16px; border-radius: 5px; cursor: pointer;
  border: 1.5px solid rgb(var(--line)); background: rgb(var(--surface));
  appearance: none; display: grid; place-items: center; flex: none;
}
.check:checked { background: rgb(var(--brand-500)); border-color: rgb(var(--brand-500)); }
.check:checked::after {
  content: ""; width: 9px; height: 5px; margin-top: -2px;
  border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg);
}
.check:indeterminate { background: rgb(var(--brand-500)); border-color: rgb(var(--brand-500)); }
.check:indeterminate::after { content: ""; width: 9px; height: 2px; background: #fff; }

/* ---------- переключатель из нескольких кнопок ---------- */
.segments { display: inline-flex; border: 1px solid rgb(var(--line)); border-radius: var(--radius-sm); overflow: hidden; }
.segments button {
  border: none; background: rgb(var(--surface)); color: rgb(var(--muted));
  padding: 8px 12px; font-size: .84rem; cursor: pointer; white-space: nowrap;
}
.segments button + button { border-left: 1px solid rgb(var(--line)); }
.segments button:hover { color: rgb(var(--brand-700)); }
.segments button.on { background: rgb(var(--brand-500) / .12); color: rgb(var(--brand-700)); font-weight: 600; }

/* ---------- поле поиска ---------- */
.search { position: relative; flex: 1; min-width: 200px; max-width: 460px; }
.search input { padding-left: 34px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: rgb(var(--faint)); pointer-events: none; }

/* ---------- выпадающий список ---------- */
.dd { position: relative; display: inline-block; }

.dd-button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid rgb(var(--line)); background: rgb(var(--surface));
  color: rgb(var(--ink)); font-size: .88rem; cursor: pointer; text-align: left;
}
.dd-button:hover { border-color: rgb(var(--brand-300)); }
.dd-open .dd-button { border-color: rgb(var(--brand-400)); box-shadow: 0 0 0 3px rgb(var(--brand-500) / .15); }
.dd-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-placeholder { color: rgb(var(--faint)); }
.dd-chevron { display: grid; place-items: center; color: rgb(var(--faint)); }
.dd-open .dd-chevron { transform: rotate(180deg); }

.dd-list {
  position: absolute; z-index: 50; left: 0; top: calc(100% + 6px); min-width: 100%;
  max-height: 320px; overflow-y: auto; padding: 4px;
  background: rgb(var(--surface)); border: 1px solid rgb(var(--line));
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lift);
}

/* Подсветка серая, а не системная синяя: список должен читаться как часть
   страницы, а не как кусок операционной системы. */
.dd-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 7px; cursor: pointer;
  font-size: .88rem; white-space: nowrap; outline: none;
}
.dd-item:hover, .dd-item:focus { background: rgb(var(--line-soft)); }
.dd-item.on { background: rgb(var(--line-soft)); font-weight: 600; }
.dd-item.on:hover, .dd-item.on:focus { background: rgb(var(--line)); }
.dd-text { flex: 1; display: flex; align-items: baseline; gap: 8px; }
.dd-hint { font-size: .78rem; color: rgb(var(--faint)); font-weight: 400; }
.dd-check { color: rgb(var(--brand-600)); display: grid; place-items: center; width: 14px; }
