/* ============================================================
   ПОТРЕБНОСТЬ v448: вид как у АХЧ-заявок. Основа — классы ah-/tk-
   (ahch-v433, tasks-v427), здесь только своё: значки вида, позиции,
   форма с позициями и справочник принтеров. Классы nd-.
   ============================================================ */
:root {
  --nd-mat: #2d6cdf; --nd-mat-bg: #e8f0fd;
  --nd-cart: #7c4dd6; --nd-cart-bg: #f1ebfc;
}
[data-theme=dark] {
  --nd-mat: #8db4f5; --nd-mat-bg: rgba(45, 108, 223, .2);
  --nd-cart: #b99af0; --nd-cart-bg: rgba(124, 77, 214, .22);
}

/* ---- Значок строки: вид вместо фото ---- */
.nd-thumb.is-materials { background: var(--nd-mat-bg); color: var(--nd-mat); }
.nd-thumb.is-cartridges { background: var(--nd-cart-bg); color: var(--nd-cart); }
.nd-thumb .tk-ico { width: 22px; height: 22px; }
.nd-row .ah-main span { color: var(--text-soft, var(--text)); }
.nd-kind-tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  background: var(--nd-mat-bg); color: var(--nd-mat); font-size: 12px; font-weight: 800; white-space: nowrap;
}
.nd-kind-tag.is-cartridges { background: var(--nd-cart-bg); color: var(--nd-cart); }
.nd-kind-tag .tk-ico { width: 14px; height: 14px; }
.ah-sub .nd-kind-tag { font-size: 12.5px; }

/* ---- Справочник принтеров ---- */
.nd-printers-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.nd-printers-head h2 { margin: 0 0 2px; font-size: 18px; }
.nd-printers-head .hint { margin: 0; max-width: 620px; }
.nd-printers-head .primary { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.nd-printer-row.is-archived { opacity: .6; }
.nd-printer-row .ah-main small { gap: 6px; }
.nd-printer-row .ah-main span { white-space: normal; }
.nd-admin { display: grid; gap: 4px; }

/* ---- Страница заявки: позиции ---- */
.nd-lines { display: grid; margin: 6px 0 14px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.nd-line {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 12px; align-items: start;
  padding: 11px 14px; border-top: 1px solid var(--line-soft, var(--line)); background: var(--surface-card);
}
.nd-line:first-child { border-top: 0; }
.nd-line-n {
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface-hover); color: var(--muted); font-size: 12px; font-weight: 800;
}
.nd-line-main { display: grid; gap: 3px; min-width: 0; }
.nd-line-main b { color: var(--text); font-size: 14.5px; overflow-wrap: anywhere; }
.nd-line-main p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.nd-line-qty { padding: 3px 10px; border-radius: 8px; background: var(--surface-hover); color: var(--text); font-size: 13px; font-weight: 800; white-space: nowrap; }
.nd-devices { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0; }
.nd-devices span {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 8px;
  background: var(--nd-cart-bg); color: var(--nd-cart); font-size: 12px; font-weight: 700;
}
.nd-devices .tk-ico { width: 13px; height: 13px; }

/* ---- Уточнения ---- */
.nd-comments { display: grid; gap: 8px; margin: 10px 0 12px; }
.nd-comment { max-width: 88%; padding: 8px 12px; border-radius: 12px; background: var(--surface-hover); }
.nd-comment.is-mine { justify-self: end; background: var(--surface-selected); }
.nd-comment b { display: block; color: var(--text); font-size: 12.5px; }
.nd-comment p { margin: 2px 0; color: var(--text); font-size: 13.5px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.nd-comment small { color: var(--muted); font-size: 11.5px; }
.nd-quiet { margin: 8px 0 12px; }
.nd-comment-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.nd-comment-form textarea { min-height: 44px; resize: vertical; }
.nd-comment-form .primary { display: inline-flex; align-items: center; gap: 6px; }

/* ---- Форма ---- */
dialog:has(> form.nd-form) { width: min(620px, calc(100% - 24px)); }
.nd-form { max-height: min(86vh, 900px); overflow: auto; }
.nd-seg { flex-wrap: wrap; }
.nd-static { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.nd-kinds { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.nd-kind {
  display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 10px; align-items: center; padding: 10px 12px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface-card); color: var(--text); text-align: left;
}
.nd-kind > .tk-ico { width: 36px; height: 36px; padding: 7px; border-radius: 10px; background: var(--nd-mat-bg); color: var(--nd-mat); }
.nd-kind:last-child > .tk-ico { background: var(--nd-cart-bg); color: var(--nd-cart); }
.nd-kind b { display: block; font-size: 14px; }
.nd-kind small { display: block; color: var(--muted); font-size: 12px; font-weight: 600; line-height: 1.3; }
.nd-kind:hover { border-color: var(--brand); }
.nd-kind.is-on { border-color: var(--brand); background: var(--surface-selected); box-shadow: inset 0 0 0 1px var(--brand); }
.nd-pos-list { display: grid; gap: 10px; }
.nd-pos { display: grid; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-card-2, var(--surface-card)); }
.nd-pos > header { display: flex; align-items: center; gap: 8px; }
.nd-pos > header b { font-size: 13.5px; }
.nd-pos-n {
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 12px; font-weight: 800;
}
.nd-qty { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.nd-pos textarea { min-height: 58px !important; }
.nd-add { justify-self: start; display: inline-flex; align-items: center; gap: 6px; }
.nd-warn {
  display: flex; align-items: center; gap: 8px; margin: 0; padding: 8px 10px; border-radius: 10px;
  background: var(--ah-amber-bg); color: var(--ah-amber); font-size: 12.5px; font-weight: 700;
}
.nd-warn .tk-ico { width: 15px; height: 15px; flex: none; }
.nd-devices-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.nd-device {
  position: relative; display: grid !important; grid-template-columns: 18px minmax(0, 1fr); gap: 8px; align-items: center;
  padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface-card);
  font-weight: 500 !important; cursor: pointer;
}
.nd-device input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); }
.nd-device b { display: block; color: var(--text); font-size: 13px; }
.nd-device small { display: block; color: var(--muted); font-size: 11.5px; }
.nd-device.is-on, .nd-device:has(input:checked) { border-color: var(--brand); background: var(--surface-selected); }
.nd-hint { margin: 0 0 4px !important; font-size: 12px !important; }
.nd-dev-list { display: grid; gap: 8px; }
.nd-dev { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.nd-dev select { min-width: 118px; }
.nd-dev input {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-card); color: var(--text); font: inherit; font-size: 14px;
}
.nd-dev input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.nd-check { display: flex !important; align-items: center; gap: 8px; font-weight: 600 !important; }
.nd-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); }

/* ---- Телефон ---- */
@media (max-width: 720px) {
  .nd-printers-head { flex-direction: column; }
  .nd-printers-head .primary { width: 100%; justify-content: center; }
  .nd-line { grid-template-columns: 24px minmax(0, 1fr); padding: 10px 12px; }
  .nd-line-qty { grid-column: 2; justify-self: start; }
  .nd-kinds { grid-template-columns: 1fr; }
  .nd-dev { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .nd-dev > :last-child { grid-column: 1 / -1; justify-self: end; }
  .nd-comment { max-width: 100%; }
  .nd-comment-form { grid-template-columns: 1fr; }
  .nd-form { max-height: none; }
}
