/* ============================================================
   nd_form.css — специфика страницы генерации НД.
   Общее (вкладки, аккордеон, btn-sm, file-btn) — в ui.css.
   ============================================================ */

.nd-page { max-width: 920px; margin: 0 auto; }

/* Шапка страницы */
.nd-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
.nd-h1 { font-size: 26px; font-weight: 900; }
.nd-top-actions { display: flex; gap: 10px; align-items: center; }

/* ─── СЕКЦИИ ФОРМЫ ─── */
.f-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 22px; margin-bottom: 16px;
}
.f-section-title {
  font-size: 13px; font-weight: 700; color: var(--text);
  margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.f-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.f-field { display: flex; flex-direction: column; gap: 6px; }
.f-label { font-size: 13px; font-weight: 500; color: var(--muted); }

/* textarea с ресайзом */
.ta-resize { resize: vertical; min-height: 64px; line-height: 1.5; font-family: inherit; }

/* дата/время в ряд */
.dt-row { display: flex; gap: 10px; }
.dt-row .input { flex: 1; }

/* ─── ЧЛЕНЫ БРИГАДЫ ─── */
.member-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.member-row .input { flex: 1; }

/* ─── МЕРОПРИЯТИЯ (3 поля) ─── */
.measures-head, .measure-row {
  display: grid; grid-template-columns: 1fr 1.6fr 1fr 32px; gap: 8px; align-items: start;
}
.measures-head {
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; padding: 10px 4px 8px;
}
.measure-row { margin-bottom: 8px; }
.m-cell { resize: vertical; min-height: 44px; line-height: 1.4; font-family: inherit; font-size: 13px; }
.m-del { align-self: start; margin-top: 4px; }
.measures-actions { display: flex; gap: 10px; margin-top: 8px; }

/* ─── СПРАВОЧНИКИ ─── */
.refs-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
.refs-file-actions { display: flex; gap: 8px; }

/* строка справочника */
.ref-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.ref-row .input { flex: 1; }
.ref-row select.input { max-width: 240px; flex: 0 1 240px; }
.ref-del {
  width: 32px; height: 32px; flex-shrink: 0; border-radius: 8px;
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  cursor: pointer; font-size: 13px;
}
.ref-del:hover { border-color: var(--c-error); color: var(--c-error); }
.ref-empty { color: var(--muted); font-size: 13px; padding: 12px 0; }

/* карточка сотрудника */
.emp-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px; margin-bottom: 10px;
}
.emp-fio { display: grid; grid-template-columns: 1fr 1fr 1fr 90px minmax(140px, 1fr) 32px; gap: 8px; align-items: center; margin-bottom: 12px; }
.emp-fio .emp-org { min-width: 0; }
.emp-roles-row { display: flex; align-items: flex-start; gap: 12px; }
.emp-roles-label { font-size: 13px; font-weight: 600; color: var(--muted); flex-shrink: 0; padding-top: 1px; }
.emp-roles { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.role-chk { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text); cursor: pointer; }

/* ─── АДАПТИВ ─── */
@media (max-width: 680px) {
  .f-grid-2 { grid-template-columns: 1fr; }
  .measures-head { display: none; }
  .measure-row { grid-template-columns: 1fr 32px; grid-auto-rows: auto; }
  .measure-row .m-cell { grid-column: 1; }
  .measure-row .m-del { grid-column: 2; grid-row: 1; }
  .emp-fio { grid-template-columns: 1fr 32px; }
  .emp-fio .input { grid-column: 1; }
  .emp-fio .ref-del { grid-column: 2; grid-row: 1; }
  .emp-roles-row { flex-direction: column; gap: 6px; }
}

/* ─── МОДАЛКА ГЕНЕРАЦИИ: ПЕЧАТНАЯ МАШИНКА ─── */
.nd-typewriter {
  width: 160px; height: 130px; margin: 0 auto;
  position: relative; display: flex; flex-direction: column; align-items: center;
}
.nd-tw-paper {
  width: 100px; height: 80px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 3px; overflow: hidden; position: relative; z-index: 2;
  animation: nd-paper-feed 3s ease-in-out infinite;
}
.nd-tw-lines { padding: 10px 12px; display: flex; flex-direction: column; gap: 7px; }
.nd-tw-line {
  height: 2px; background: var(--text);
  border-radius: 1px; opacity: 0.5;
  transform: scaleX(0); transform-origin: left;
  animation: nd-tw-type 0.3s ease forwards;
}
.nd-tw-line:nth-child(1) { animation-delay: 0.3s; }
.nd-tw-line:nth-child(2) { animation-delay: 0.6s; }
.nd-tw-line:nth-child(3) { animation-delay: 0.9s; }
.nd-tw-line:nth-child(4) { animation-delay: 1.2s; }
.nd-tw-cursor {
  display: inline-block; width: 2px; height: 11px;
  background: var(--accent); margin-left: 2px; vertical-align: middle;
  animation: nd-tw-blink 0.8s step-end infinite 1.4s; opacity: 0;
}
.nd-tw-machine {
  width: 140px; height: 52px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 8px 8px 4px 4px; position: relative; z-index: 1;
  margin-top: -4px;
}
.nd-tw-slot {
  position: absolute; top: -5px; left: 12px; right: 12px;
  height: 9px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 2px;
}
.nd-tw-keys {
  position: absolute; bottom: 8px; left: 10px; right: 10px;
  display: flex; gap: 5px; flex-wrap: wrap; justify-content: center;
}
.nd-tw-key {
  width: 12px; height: 9px;
  background: var(--border); border-radius: 2px;
  animation: nd-tw-keypress 0.4s ease infinite;
}
.nd-tw-key:nth-child(2) { animation-delay: 0.15s; }
.nd-tw-key:nth-child(3) { animation-delay: 0.30s; }
.nd-tw-key:nth-child(4) { animation-delay: 0.45s; }
.nd-tw-key:nth-child(5) { animation-delay: 0.60s; }
.nd-tw-key:nth-child(6) { animation-delay: 0.75s; }

@keyframes nd-paper-feed {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}
@keyframes nd-tw-type  { to { transform: scaleX(1); } }
@keyframes nd-tw-blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }
@keyframes nd-tw-keypress {
  0%,100% { transform: translateY(0);  background: var(--border); }
  30%     { transform: translateY(2px); background: var(--accent); }
}