/* Каталог и редактор печатных шаблонов */
.tpl-hero { padding-bottom: 1rem; }
.tpl-hero-edit .tpl-back { margin: 0 0 .35rem; }
.tpl-hero-edit .tpl-back a { color: var(--muted, #64748b); text-decoration: none; }
.tpl-hero-edit .tpl-back a:hover { color: var(--accent, #f97316); }

.tpl-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .75rem 1rem;
  margin-bottom: 1.5rem;
  padding: 1rem 1.1rem;
  background: linear-gradient(135deg, rgba(15,23,42,.03), rgba(249,115,22,.06));
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 14px;
}
.tpl-filter label {
  display: block;
  font-size: .78rem;
  font-weight: 650;
  color: var(--muted, #64748b);
  margin-bottom: .3rem;
}
.tpl-filter select,
.tpl-filter input,
.tpl-edit-form input,
.tpl-edit-form select,
.tpl-edit-qty input {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid rgba(15,23,42,.14);
  border-radius: 10px;
  background: #fff;
  font: inherit;
}
.tpl-filter-grow { grid-column: span 1; }

.tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.1rem;
}
.tpl-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  background: #fff;
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 14px;
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.tpl-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 28px rgba(15,23,42,.1);
  border-color: rgba(249,115,22,.35);
}
.tpl-card-preview {
  aspect-ratio: 4 / 3;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.tpl-badge {
  position: absolute;
  top: .55rem;
  left: .55rem;
  z-index: 1;
  padding: .2rem .55rem;
  border-radius: 999px;
  background: #0f172a;
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.tpl-card-desc {
  margin: 0 0 .4rem;
  font-size: .86rem;
  color: var(--muted, #64748b);
  line-height: 1.35;
}
.tpl-card-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: repeating-conic-gradient(#eef2f7 0% 25%, #f8fafc 0% 50%) 50% / 16px 16px;
}
.tpl-card-body { padding: .85rem 1rem 1rem; }
.tpl-card-body h3 {
  margin: 0 0 .35rem;
  font-size: 1.02rem;
  font-weight: 750;
}
.tpl-card-meta {
  margin: 0;
  font-size: .82rem;
  color: var(--muted, #64748b);
}
.tpl-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: .55rem;
}
.tpl-tag {
  font-size: .72rem;
  font-weight: 650;
  padding: .15rem .45rem;
  border-radius: 6px;
  background: rgba(15,23,42,.06);
  color: #334155;
}
.tpl-empty, .tpl-loading {
  grid-column: 1 / -1;
  color: var(--muted, #64748b);
  padding: 2rem 0;
}

/* Редактор */
.tpl-edit-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 1.25rem;
  align-items: start;
}
.tpl-edit-form-wrap {
  background: #fff;
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 14px;
  padding: 1rem 1.05rem 1.15rem;
  position: sticky;
  top: 1rem;
}
.tpl-edit-form .field {
  margin-bottom: .75rem;
}
.tpl-edit-form label {
  display: block;
  font-size: .8rem;
  font-weight: 650;
  margin-bottom: .28rem;
}
.tpl-edit-form .req::after {
  content: ' *';
  color: #dc2626;
}
.tpl-color-row {
  display: flex;
  gap: .5rem;
  align-items: center;
}
.tpl-color-row input[type="color"] {
  width: 2.4rem;
  height: 2.2rem;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}
.tpl-color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: .4rem;
}
.tpl-swatch {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(15,23,42,.2);
  cursor: pointer;
  padding: 0;
}
.tpl-swatch.is-on { box-shadow: 0 0 0 2px var(--accent, #f97316); }
.tpl-logo-row {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
}
.tpl-logo-row input[type="file"] { font-size: .82rem; }
.tpl-edit-qty { margin: .5rem 0 1rem; }
.tpl-edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
}
.tpl-edit-hint { margin: .75rem 0 0; min-height: 1.2em; }

.tpl-edit-preview-wrap {
  background: #fff;
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 14px;
  overflow: hidden;
  min-height: 420px;
}
.tpl-preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .65rem 1rem;
  border-bottom: 1px solid rgba(15,23,42,.08);
  font-weight: 700;
  font-size: .9rem;
}
.tpl-zoom {
  display: flex;
  align-items: center;
  gap: .35rem;
}
.tpl-zoom button {
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 8px;
  border: 1px solid rgba(15,23,42,.15);
  background: #f8fafc;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}
.tpl-zoom span { min-width: 3.2rem; text-align: center; font-size: .85rem; font-weight: 650; }
.tpl-preview-stage {
  padding: 1.25rem;
  background:
    linear-gradient(90deg, rgba(15,23,42,.04) 1px, transparent 1px),
    linear-gradient(rgba(15,23,42,.04) 1px, transparent 1px),
    #e8edf3;
  background-size: 18px 18px;
  overflow: auto;
  max-height: 72vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.tpl-preview-inner {
  transform-origin: top center;
  transition: transform .15s ease;
  background: #fff;
  box-shadow: 0 8px 30px rgba(15,23,42,.12);
}
.tpl-preview-inner svg {
  display: block;
  max-width: 100%;
  height: auto;
}

@media (max-width: 900px) {
  .tpl-filters { grid-template-columns: 1fr 1fr; }
  .tpl-filter-grow { grid-column: 1 / -1; }
  .tpl-edit-layout { grid-template-columns: 1fr; }
  .tpl-edit-form-wrap { position: static; }
}
@media (max-width: 560px) {
  .tpl-filters { grid-template-columns: 1fr; }
}
