body {
  min-width: 1120px;
}

.template-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 28px 24px 42px;
  display: grid;
  gap: 18px;
}

.template-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 520px;
  gap: 18px;
  align-items: stretch;
  padding: 28px;
  border-radius: 22px;
  background: #102036;
  color: #fff;
  box-shadow: var(--shadow);
}

.template-head h1 {
  margin: 14px 0 10px;
  font-size: 26px;
  line-height: 1.05;
}

.template-head p {
  margin: 0;
  max-width: 64ch;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.75;
}

.sync-panel,
.template-toolbar,
.template-table-card,
.template-detail {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.sync-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
  border-radius: 16px;
  color: var(--ink);
}

.sync-panel label,
.template-toolbar label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-soft);
}

.sync-panel input,
.template-toolbar input,
.template-toolbar select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
  font: inherit;
}

.check-line {
  display: flex !important;
  align-items: center;
  grid-template-columns: none !important;
  gap: 8px !important;
}

.check-line input {
  width: 16px;
  height: 16px;
}

.btn-primary,
.btn-secondary {
  height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  border: 1px solid transparent;
  font-weight: 800;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-secondary {
  background: var(--surface-soft);
  color: var(--ink);
  border-color: var(--line);
}

.btn-primary:disabled,
.btn-secondary:disabled {
  cursor: wait;
  opacity: 0.68;
}

.template-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-radius: 14px;
}

.toolbar-group {
  display: flex;
  align-items: end;
  gap: 12px;
}

.toolbar-group label {
  min-width: 220px;
}

.toolbar-meta {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
}

.template-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  gap: 18px;
  align-items: start;
}

.template-table-card,
.template-detail {
  border-radius: 14px;
  overflow: hidden;
}

.template-table {
  display: grid;
}

.template-row {
  display: grid;
  grid-template-columns: 126px minmax(0, 1fr) 90px 90px 120px;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.template-row:hover,
.template-row.active {
  background: var(--surface-soft);
}

.template-row.header {
  cursor: default;
  background: #eef3f8;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.template-key {
  display: grid;
  gap: 2px;
}

.template-key strong {
  font-size: 15px;
}

.template-key span,
.template-path span,
.template-count {
  color: var(--ink-soft);
  font-size: 12px;
}

.template-path {
  min-width: 0;
}

.template-path strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.status-badge {
  display: inline-flex;
  width: max-content;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 12px;
  font-weight: 900;
}

.template-detail {
  position: sticky;
  top: 92px;
  padding: 18px;
}

.detail-empty {
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  font-weight: 700;
}

.detail-head {
  display: grid;
  gap: 8px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.detail-head h2 {
  margin: 0;
  font-size: 18px;
}

.detail-head p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.55;
}

.detail-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.detail-stat {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}

.detail-stat span {
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 800;
}

.detail-stat strong {
  font-size: 16px;
}

.attr-list {
  display: grid;
  gap: 10px;
}

.attr-card {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.attr-card strong {
  font-size: 14px;
}

.attr-card span {
  color: var(--ink-soft);
  font-size: 12px;
}

@media (max-width: 1180px) {
  body { min-width: 0; }
  .template-head,
  .template-layout { grid-template-columns: 1fr; }
  .template-detail { position: static; }
  .template-row { grid-template-columns: 110px minmax(0, 1fr) 70px 70px; }
  .template-row > :last-child { display: none; }
}
