/* ============================================================================
   ElectricTools — общие компоненты личного кабинета и админки

   Наследует дизайн-токены из styles.css (:root). Подключать ПОСЛЕ styles.css.
   Здесь только то, что используется и в ЛК, и в админке: карточки, поля,
   бейджи, toast-уведомления, модальные окна, скелетоны.
   ============================================================================ */

/* ---------- Каркас страниц кабинета ---------- */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app__main {
  flex: 1;
  padding: calc(var(--nav-h) + 36px) 0 72px;
}

.app-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  z-index: 100;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border-bottom: 1px solid var(--line);
}

.app-bar__inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.app-bar__logo img { width: 190px; height: auto; }

.app-bar__side {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.app-bar__user {
  font-size: 14px;
  color: var(--muted);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-bar__link {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  padding: 8px 12px;
  border-radius: 10px;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.app-bar__link:hover { background: var(--bg-tint); color: var(--blue-600); }

/* ---------- Заголовок раздела ---------- */
.page-head { margin-bottom: 32px; }
.page-head__title {
  font-size: clamp(26px, 3.4vw, 36px);
  margin-bottom: 8px;
}
.page-head__lead {
  color: var(--muted);
  font-size: 16.5px;
  max-width: 720px;
}

.block { margin-bottom: 44px; }
.block__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.block__title {
  font-size: 21px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.block__count {
  font-size: 13px;
  font-weight: 700;
  color: var(--blue-600);
  background: var(--bg-tint);
  padding: 3px 10px;
  border-radius: 999px;
}
.block__hint { font-size: 14px; color: var(--muted); }

/* ---------- Карточка ---------- */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  padding: 26px;
}
.card--flat { box-shadow: none; }
.card--pad-sm { padding: 20px; }

/* ---------- Плитки сводки ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 20px 22px;
  box-shadow: var(--sh-sm);
}
.stat__label {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 700;
  margin-bottom: 8px;
}
.stat__value {
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 30px;
  color: var(--ink);
  line-height: 1.1;
}
.stat__note { font-size: 13.5px; color: var(--muted); margin-top: 6px; }

/* ---------- Бейджи статуса ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.chip--ok      { background: #ECFDF5; color: #047857; border-color: #A7F3D0; }
.chip--warn    { background: #FFFBEB; color: #B45309; border-color: #FDE68A; }
.chip--danger  { background: #FEF2F2; color: #B91C1C; border-color: #FECACA; }
.chip--neutral { background: #F1F5F9; color: var(--muted); border-color: #E2E8F0; }
.chip--info    { background: var(--bg-tint); color: var(--blue-700); border-color: #C7DCFB; }
.chip__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- Формы ---------- */
.field { margin-bottom: 18px; }
.field__label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 7px;
}
.field__hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.field__error {
  font-size: 13.5px;
  color: #B91C1C;
  margin-top: 6px;
  display: none;
}
.field.has-error .field__error { display: block; }
.field.has-error .input { border-color: #FCA5A5; background: #FFFBFB; }

.input,
.select,
.textarea {
  width: 100%;
  font: inherit;
  font-size: 15.5px;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, .13);
}
.input::placeholder { color: var(--muted-2); }
.input:disabled,
.select:disabled { background: #F8FAFC; color: var(--muted); cursor: not-allowed; }

.input--key {
  font-family: ui-monospace, SFMono-Regular, 'Cascadia Mono', Consolas, monospace;
  font-size: 17px;
  letter-spacing: .10em;
  text-transform: uppercase;
}
.input--sm { padding: 9px 12px; font-size: 14px; }
.textarea { min-height: 84px; resize: vertical; }

.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.form-row > .field { flex: 1 1 200px; margin-bottom: 0; }

.field-inline {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14.5px;
  color: var(--ink-2);
  cursor: pointer;
}
.checkbox input { margin-top: 3px; width: 17px; height: 17px; accent-color: var(--blue-600); }

/* ---------- Кнопки-дополнения к styles.css ---------- */
.btn.is-busy { opacity: .65; cursor: progress; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none !important; }

.btn--soft {
  background: var(--bg-tint);
  color: var(--blue-700);
  border-color: transparent;
  box-shadow: none;
}
.btn--soft:hover { background: #DCEAFE; transform: none; }

.btn--quiet {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
  box-shadow: none;
}
.btn--quiet:hover { color: var(--ink-2); border-color: var(--muted-2); transform: none; }

.btn--danger {
  background: #fff;
  color: #B91C1C;
  border-color: #FECACA;
  box-shadow: none;
}
.btn--danger:hover { background: #FEF2F2; border-color: #F87171; transform: none; }

.btn--xs {
  padding: 7px 13px;
  font-size: 13px;
  border-radius: 10px;
}

/* ---------- Информационные блоки ---------- */
.note {
  display: flex;
  gap: 14px;
  border-radius: var(--r-md);
  padding: 16px 18px;
  font-size: 14.5px;
  line-height: 1.6;
  border: 1px solid;
}
.note__icon { flex: 0 0 auto; margin-top: 1px; }
.note__body { min-width: 0; }
.note__body strong { display: block; margin-bottom: 3px; color: var(--ink); }
.note--info    { background: var(--bg-tint); border-color: #C7DCFB; color: var(--ink-2); }
.note--warn    { background: #FFFBEB; border-color: #FDE68A; color: #78350F; }
.note--danger  { background: #FEF2F2; border-color: #FECACA; color: #7F1D1D; }
.note--success { background: #ECFDF5; border-color: #A7F3D0; color: #065F46; }

/* ---------- Список правил ---------- */
.rules {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 18px;
}
.rule {
  display: flex;
  gap: 13px;
  align-items: flex-start;
}
.rule__num {
  flex: 0 0 auto;
  width: 28px; height: 28px;
  border-radius: 9px;
  background: var(--grad);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  display: grid;
  place-items: center;
}
.rule__title { font-weight: 700; color: var(--ink); font-size: 15px; margin-bottom: 3px; }
.rule__text { font-size: 14px; color: var(--muted); line-height: 1.55; }

/* ---------- Таблицы ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th,
.table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  font-weight: 700;
  background: #FAFCFF;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #FAFCFF; }
.table__empty {
  padding: 34px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
}
.table__actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Моноширинный код (ключи, ID устройств) ---------- */
.mono {
  font-family: ui-monospace, SFMono-Regular, 'Cascadia Mono', Consolas, monospace;
  font-size: 13.5px;
  letter-spacing: .04em;
}

/* ---------- Toast-уведомления ---------- */
.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(400px, calc(100vw - 40px));
}
.toast {
  background: var(--ink);
  color: #fff;
  padding: 13px 17px;
  border-radius: var(--r-sm);
  font-size: 14.5px;
  line-height: 1.5;
  box-shadow: 0 12px 34px rgba(15, 23, 42, .28);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast--success { background: #047857; }
.toast--error   { background: #B91C1C; }

/* ---------- Модальное окно ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal.is-open { display: flex; }
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .5);
  backdrop-filter: blur(3px);
}
.modal__box {
  position: relative;
  background: #fff;
  border-radius: var(--r-lg);
  box-shadow: var(--sh-lg);
  padding: 30px;
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}
.modal__box--wide { max-width: 760px; }
.modal__title { font-size: 21px; margin-bottom: 10px; }
.modal__text { color: var(--muted); font-size: 15px; line-height: 1.6; margin-bottom: 22px; }
.modal__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 24px;
}

/* ---------- Скелетоны загрузки ---------- */
.skeleton {
  background: linear-gradient(90deg, #EEF4FC 25%, #F7FAFF 50%, #EEF4FC 75%);
  background-size: 200% 100%;
  animation: skeleton-shine 1.3s linear infinite;
  border-radius: 8px;
  color: transparent !important;
}
.skeleton--line { height: 14px; margin-bottom: 10px; }
.skeleton--title { height: 24px; width: 45%; margin-bottom: 16px; }
.skeleton--card { height: 190px; border-radius: var(--r-lg); }
@keyframes skeleton-shine {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}

/* ---------- Пустое состояние ---------- */
.empty {
  text-align: center;
  padding: 48px 24px;
  border: 1.5px dashed var(--line);
  border-radius: var(--r-lg);
  background: #FBFDFF;
}
.empty__icon { color: var(--muted-2); margin-bottom: 14px; }
.empty__title { font-size: 18px; margin-bottom: 8px; }
.empty__text {
  color: var(--muted);
  font-size: 15px;
  max-width: 460px;
  margin: 0 auto 22px;
  line-height: 1.6;
}

/* ---------- Служебное ---------- */
.hidden { display: none !important; }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.text-muted { color: var(--muted); }
.text-small { font-size: 13.5px; }
.nowrap { white-space: nowrap; }

/* ---------- Адаптив ---------- */
@media (max-width: 720px) {
  .app__main { padding-top: calc(var(--nav-h) + 22px); }
  .app-bar__logo img { width: 150px; }
  .app-bar__user { display: none; }
  .card { padding: 20px; }
  .modal__box { padding: 22px; }
}
