/* NIPI-163: справочники НИЛЦ. NIPI-168: оформление как у справочников проекта (карточка, шапка с поиском), на всю ширину */
.nilc-nav { margin-bottom: 0; }
.nilc-dir-layout { width: 100%; min-width: 0; }
.nilc-dir { min-width: 0; }
.nilc-dir .card-header { align-items: center; }
.nilc-count { font-size: 14px; font-weight: 400; }
.nilc-filters { flex: 1 1 520px; justify-content: flex-end; align-items: center; gap: 8px 14px; min-width: 0; }
.nilc-filters input[type=search] { flex: 1 1 260px; min-width: 0; max-width: 460px; }
.nilc-filters .checkbox { white-space: nowrap; }
.nilc-dir-table { width: 100%; }
.nilc-dir-table td { vertical-align: top; overflow-wrap: anywhere; }
.nilc-dir-table td small { display: block; }
.nilc-open { color: var(--primary); font-weight: 600; text-decoration: none; }
.nilc-open:hover { text-decoration: underline; }
.nilc-open strong { font-weight: inherit; }
.nilc-actions { white-space: nowrap; text-align: right; }
@media (min-width: 901px) { .nilc-actions { width: 1%; } }
/* Карточки на телефоне: запись открывается ссылкой в заголовке карточки — кнопка не нужна */
@media (max-width: 900px) { .nilc-actions [data-edit] { display: none; } .nilc-actions:not(:has(.badge)) { display: none !important; } }
.nilc-archived td { color: var(--muted); }
.nilc-archived .nilc-open { color: var(--muted); }
.nilc-due-expired { color: #b91c1c; font-weight: 600; }
.nilc-due-soon { color: #b45309; font-weight: 600; }
.nilc-form .nilc-field { min-width: 0; }
.nilc-form textarea { resize: vertical; }
.nilc-fill-hint { margin: 0 0 12px; }
.nilc-fill-note { margin: 10px 0 0; padding: 8px 12px; border-radius: 8px; background: #ecfdf3; color: #166534; font-size: 13px; }
@media (max-width: 700px) {
  /* Вкладки разделов — одной строкой с прокруткой, без переноса на несколько строк */
  .nilc-nav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
  .nilc-nav::-webkit-scrollbar { display: none; }
  .nilc-nav .btn { flex: none; }
  .nilc-filters { flex-basis: 100%; justify-content: stretch; }
  .nilc-filters input[type=search] { flex-basis: 100%; max-width: none; }
  .nilc-filters .btn-primary { flex: 1 1 auto; }
}

/* NIPI-165: методика открывается в панели рядом со списком — поля, файлы и просмотр на одном экране */
.nilc-dir-split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.nilc-dir-split:has(> .nilc-panel:not([hidden])) { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
.nilc-row-open { cursor: pointer; }
.nilc-row-open:hover td { background: var(--primary-soft); }
.nilc-row-selected td { background: var(--primary-soft); box-shadow: inset 0 0 0 9999px rgba(38, 71, 150, .04); }
.nilc-panel { position: sticky; top: 12px; min-width: 0; max-height: calc(100vh - 24px); overflow: auto; }
.nilc-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.nilc-panel-head h3 { margin: 0; overflow-wrap: anywhere; }
.nilc-panel-head h3 small { display: block; font-size: 13px; font-weight: 400; margin-top: 2px; }
.nilc-panel-close { flex: none; width: 32px; height: 32px; border: 0; border-radius: 50%; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); }
.nilc-panel-close:hover { background: var(--primary-soft); color: var(--text); }
.nilc-panel .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.nilc-panel .form-actions { margin-top: 12px; }
.nilc-files { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 14px; }
.nilc-files h4 { margin: 0 0 10px; font-size: 15px; }
.nilc-file-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.nilc-file-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; min-width: 0; }
.nilc-file-list li.active { border-color: var(--primary); background: var(--primary-soft); }
.nilc-file-list li.muted { border: 0; padding: 4px 0; }
.nilc-file-name { flex: 1 1 160px; min-width: 0; overflow-wrap: anywhere; }
.nilc-file-name small { display: block; }
.nilc-file-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.nilc-file-queued { border-style: dashed !important; }
.nilc-file-preview { margin-top: 12px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #f6f7f9; }
.nilc-file-preview img { display: block; max-width: 100%; max-height: 70vh; margin: auto; }
.nilc-file-preview .dv { min-height: 420px; }
.nilc-files-count { white-space: nowrap; }
.nilc-readonly { display: grid; gap: 8px; margin: 0; }
.nilc-readonly div { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 8px; }
.nilc-readonly dt { color: var(--muted); font-size: 13px; }
.nilc-readonly dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 1100px) {
  .nilc-dir-split:has(> .nilc-panel:not([hidden])) { grid-template-columns: minmax(0, 1fr); }
  .nilc-panel { position: static; max-height: none; }
}
@media (max-width: 600px) {
  .nilc-panel .form-grid { grid-template-columns: minmax(0, 1fr); }
  .nilc-readonly div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
}
/* Пока панель открыта, в списке — обозначение, наименование, срок и файлы; строка открывается щелчком */
@media (min-width: 1101px) {
  .nilc-dir-split:has(> .nilc-panel:not([hidden])) .nilc-dir-table :is(th, td):is(:nth-child(3), :nth-child(4), :last-child) { display: none; }
  .nilc-dir-split:has(> .nilc-panel:not([hidden])) .nilc-dir-table { min-width: 0; width: 100%; }
}

/* NIPI-167: приборы, типы проб, допуски — запись на весь экран: слева поля, справа файлы и просмотр */
.nilc-editor-page { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 20px; align-items: start; }
.modal-page #modal-body > .nilc-editor-page { background: none; box-shadow: none; padding: 0; }
.nilc-editor-page > div { min-width: 0; background: var(--surface); border-radius: var(--radius, 14px); box-shadow: var(--shadow); padding: 22px 24px; }
.nilc-editor-page .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.nilc-editor-page .nilc-editor-side { position: sticky; top: 12px; }
.nilc-editor-page .nilc-files { border-top: 0; margin-top: 0; padding-top: 0; }
.nilc-editor-page .nilc-file-preview .dv { min-height: 60vh; }
@media (max-width: 1100px) {
  .nilc-editor-page { grid-template-columns: minmax(0, 1fr); }
  .nilc-editor-page .nilc-editor-side { position: static; }
}
@media (max-width: 600px) {
  .nilc-editor-page > div { padding: 16px; }
  .nilc-editor-page .form-grid { grid-template-columns: minmax(0, 1fr); }
}
